#include "newprofile.h" #include "ui_newprofile.h" #include "mainwindow.h" newProfile::newProfile(QWidget *parent) : QDialog(parent), ui(new Ui::newProfile) { ui->setupUi(this); listProfiles(); //connect(ui->profileList, SIGNAL(itemDoubleClicked(QListWidgetItem*)), SLOT(editEntryName(QListWidgetItem*))); SignalItemDelegate *delegate = new SignalItemDelegate(ui->profileList); connect(delegate, SIGNAL(editFinished()), SLOT(saveChange())); ui->profileList->setItemDelegate(delegate); } newProfile::~newProfile() { delete ui; } void newProfile::on_profileNameEdit_textChanged(const QString &arg1) { newProfileName = arg1; } void newProfile::saveChange() { //qDebug() << "edit finished"; //QListWidgetItem *item = ui->profileList->item(latestIndex); newProfileList.clear(); for (int i=0; iprofileList->count(); i++) { newProfileList.append(ui->profileList->item(i)->text()); //qDebug() << newProfileList[i]; ui->profileList->item(i)->setFlags(Qt::ItemIsEnabled); } } void newProfile::on_saveButton_clicked() { QSettings settings("tuxclocker"); // Add the new ones for (int i=0; iprofileList->addItem(groups[i]); origProfileList.append(groups[i]); newProfileList.append(groups[i]); } } // Make the items editable for (int i=0; iprofileList->count(); i++) { ui->profileList->item(i)->setFlags(Qt::ItemIsEnabled); } } /*void newProfile::editEntryName(QListWidgetItem *item) { qDebug() << "item dblclicked"; ui->profileList->editItem(item); latestIndex = ui->profileList->currentRow(); }*/ void newProfile::on_cancelButton_clicked() { close(); } void newProfile::on_addButton_pressed() { ui->profileList->addItem(""); int itemCount = ui->profileList->count()-1; latestIndex = itemCount; ui->profileList->item(itemCount)->setFlags(Qt::ItemIsEditable | Qt::ItemIsEnabled); ui->profileList->editItem(ui->profileList->item(itemCount)); } void newProfile::on_removeButton_pressed() { if (ui->profileList->count() > 1) { int index = ui->profileList->currentRow(); QListWidgetItem *item = ui->profileList->item(index); removedList.append(item->text()); newProfileList.removeAt(index); ui->profileList->takeItem(index); delete item; } }