From b27e55b0bbba9a1678159abe44280e173374f971 Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Sat, 16 Jun 2018 13:55:35 +0200 Subject: Sort .profile by time Remove ProfileInterface::setProfiles ProfileView: Add General tab ProfileView: some cleanup ProfileView: Add Cookies tab --- .../ProfileEditor/forms/profilemanagerdialog.cpp | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'plugins/ProfileEditor/forms/profilemanagerdialog.cpp') diff --git a/plugins/ProfileEditor/forms/profilemanagerdialog.cpp b/plugins/ProfileEditor/forms/profilemanagerdialog.cpp index 2f0f4a2..427330a 100644 --- a/plugins/ProfileEditor/forms/profilemanagerdialog.cpp +++ b/plugins/ProfileEditor/forms/profilemanagerdialog.cpp @@ -3,11 +3,11 @@ #include "ui_profilemanagerdialog.h" #include #include +#include -ProfileManagerDialog::ProfileManagerDialog(QHash *profiles, QWidget *parent) +ProfileManagerDialog::ProfileManagerDialog(const QVector &profiles, QWidget *parent) : QDialog(parent) , ui(new Ui::ProfileManagerDialog) - , profiles(profiles) { ui->setupUi(this); @@ -18,8 +18,12 @@ ProfileManagerDialog::ProfileManagerDialog(QHash *profile deleteProfile(ui->listWidget->currentItem()); }); - for(auto i = profiles->constBegin(); i != profiles->constEnd(); ++i) { - ui->listWidget->addItem(i.key()); + for(auto *profile : profiles) { + auto *item = new QListWidgetItem(ui->listWidget); + item->setText(profile->name()); + + auto pointer = QPointer(profile); + item->setData(Qt::UserRole, QVariant::fromValue(pointer)); } } @@ -43,7 +47,8 @@ void ProfileManagerDialog::showProfile(QListWidgetItem *item) } ui->groupBox->setVisible(true); - auto *v = new ProfileView(profiles->value(item->text()), this); + auto profile = item->data(Qt::UserRole).value>(); + auto *v = new ProfileView(profile.data(), this); ui->groupBox->layout()->addWidget(v); v->adjustSize(); } @@ -60,8 +65,8 @@ void ProfileManagerDialog::deleteProfile(QListWidgetItem *item) delete i; } - auto *profile = profiles->value(item->text()); - Q_CHECK_PTR(profile); + auto profile = item->data(Qt::UserRole).value>(); + Q_ASSERT(!profile.isNull()); qDebug("deleting profile %s", qUtf8Printable(profile->name())); qDebug("deleting %s: %s", qUtf8Printable(profile->configurationPath()), QFile(profile->configurationPath()).remove() ? "okay" : "failed"); @@ -69,5 +74,5 @@ void ProfileManagerDialog::deleteProfile(QListWidgetItem *item) qDebug("deleting %s: %s", qUtf8Printable(profile->cachePath()), QDir(profile->cachePath()).removeRecursively() ? "okay" : "failed"); delete item; - delete profile; + delete profile.data(); } -- cgit v1.2.1