summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <[email protected]>2015-11-06 22:14:50 +0100
committerMontel Laurent <[email protected]>2015-11-06 22:14:50 +0100
commit80570c51e5211016893978633d93ea6a37a3bdf9 (patch)
tree0bf4b9156e33769f12e1a603a333a3b68e870920
parent2b32c071ffbf0763ee868a7505a99f65a0ef9f2c (diff)
Add button for select/unselect all resources
-rw-r--r--pimsettingexporter/gui/autotests/synchronizeresourcedialogtest.cpp8
-rw-r--r--pimsettingexporter/gui/dialog/synchronizeresourcedialog.cpp45
-rw-r--r--pimsettingexporter/gui/dialog/synchronizeresourcedialog.h5
3 files changed, 52 insertions, 6 deletions
diff --git a/pimsettingexporter/gui/autotests/synchronizeresourcedialogtest.cpp b/pimsettingexporter/gui/autotests/synchronizeresourcedialogtest.cpp
index d99c56e..724dffa 100644
--- a/pimsettingexporter/gui/autotests/synchronizeresourcedialogtest.cpp
+++ b/pimsettingexporter/gui/autotests/synchronizeresourcedialogtest.cpp
@@ -24,6 +24,7 @@
#include <QStandardPaths>
#include <QLabel>
+#include <QPushButton>
SynchronizeResourceDialogTest::SynchronizeResourceDialogTest(QObject *parent)
: QObject(parent)
@@ -52,6 +53,13 @@ void SynchronizeResourceDialogTest::shouldHaveDefaultValue()
QVERIFY(label);
QVERIFY(label->wordWrap());
+
+ QPushButton *selectAll = dlg.findChild<QPushButton *>(QStringLiteral("selectall_button"));
+ QVERIFY(selectAll);
+
+ QPushButton *unselectAll = dlg.findChild<QPushButton *>(QStringLiteral("unselectall_button"));
+ QVERIFY(unselectAll);
+
QVERIFY(dlg.resources().isEmpty());
}
diff --git a/pimsettingexporter/gui/dialog/synchronizeresourcedialog.cpp b/pimsettingexporter/gui/dialog/synchronizeresourcedialog.cpp
index 5b9ee0e..4401856 100644
--- a/pimsettingexporter/gui/dialog/synchronizeresourcedialog.cpp
+++ b/pimsettingexporter/gui/dialog/synchronizeresourcedialog.cpp
@@ -31,10 +31,17 @@ SynchronizeResourceDialog::SynchronizeResourceDialog(QWidget *parent)
: QDialog(parent)
{
setWindowTitle(i18n("Synchronize Resources"));
- QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
- buttonBox->setObjectName(QStringLiteral("buttonbox"));
QVBoxLayout *topLayout = new QVBoxLayout;
setLayout(topLayout);
+
+ QLabel *lab = new QLabel(i18n("Some resources were added but data were not sync. Select resources that you want to sync:"));
+ lab->setWordWrap(true);
+ lab->setObjectName(QStringLiteral("label"));
+
+
+
+ QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
+ buttonBox->setObjectName(QStringLiteral("buttonbox"));
QPushButton *okButton = buttonBox->button(QDialogButtonBox::Ok);
okButton->setDefault(true);
okButton->setShortcut(Qt::CTRL | Qt::Key_Return);
@@ -43,9 +50,18 @@ SynchronizeResourceDialog::SynchronizeResourceDialog(QWidget *parent)
KListWidgetSearchLine *listWidgetSearchLine = new KListWidgetSearchLine(this, mListResourceWidget);
listWidgetSearchLine->setObjectName(QStringLiteral("listwidgetsearchline"));
- QLabel *lab = new QLabel(i18n("Some resources were added but data were not sync. Select resources that you want to sync:"));
- lab->setWordWrap(true);
- lab->setObjectName(QStringLiteral("label"));
+
+ QHBoxLayout *hbox = new QHBoxLayout;
+ QPushButton *selectAll = new QPushButton(i18n("Select All"));
+ selectAll->setObjectName(QStringLiteral("selectall_button"));
+ connect(selectAll, &QPushButton::clicked, this, &SynchronizeResourceDialog::slotSelectAll);
+ hbox->addWidget(selectAll);
+
+ QPushButton *unselectAll = new QPushButton(i18n("Unselect All"));
+ unselectAll->setObjectName(QStringLiteral("unselectall_button"));
+ connect(unselectAll, &QPushButton::clicked, this, &SynchronizeResourceDialog::slotUnselectAll);
+ hbox->addWidget(unselectAll);
+
connect(buttonBox, &QDialogButtonBox::accepted, this, &SynchronizeResourceDialog::slotAccepted);
connect(buttonBox, &QDialogButtonBox::rejected, this, &SynchronizeResourceDialog::reject);
okButton->setDefault(true);
@@ -54,6 +70,7 @@ SynchronizeResourceDialog::SynchronizeResourceDialog(QWidget *parent)
topLayout->addWidget(lab);
topLayout->addWidget(listWidgetSearchLine);
topLayout->addWidget(mListResourceWidget);
+ topLayout->addLayout(hbox);
topLayout->addWidget(buttonBox);
readConfig();
}
@@ -63,6 +80,24 @@ SynchronizeResourceDialog::~SynchronizeResourceDialog()
writeConfig();
}
+void SynchronizeResourceDialog::slotSelectAll()
+{
+ selectItem(true);
+}
+
+void SynchronizeResourceDialog::slotUnselectAll()
+{
+ selectItem(false);
+}
+
+void SynchronizeResourceDialog::selectItem(bool state)
+{
+ for (int i = 0; i < mListResourceWidget->count(); ++i) {
+ QListWidgetItem *item = mListResourceWidget->item(i);
+ item->setCheckState(state ? Qt::Checked : Qt::Unchecked);
+ }
+}
+
void SynchronizeResourceDialog::setResources(const QHash<QString, QString> &resources)
{
QHashIterator<QString, QString> i(resources);
diff --git a/pimsettingexporter/gui/dialog/synchronizeresourcedialog.h b/pimsettingexporter/gui/dialog/synchronizeresourcedialog.h
index 5a0bf5c..84d4d1f 100644
--- a/pimsettingexporter/gui/dialog/synchronizeresourcedialog.h
+++ b/pimsettingexporter/gui/dialog/synchronizeresourcedialog.h
@@ -31,7 +31,9 @@ public:
QStringList resources() const;
private Q_SLOTS:
- void slotAccepted();
+ void slotAccepted();
+ void slotSelectAll();
+ void slotUnselectAll();
private:
enum DataType {
@@ -40,6 +42,7 @@ private:
void readConfig();
void writeConfig();
+ void selectItem(bool state);
QListWidget *mListResourceWidget;
};