summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <[email protected]>2015-11-04 13:24:18 +0100
committerMontel Laurent <[email protected]>2015-11-04 13:24:18 +0100
commitda76b0c90baa585d200c7af3962ea5c414a1d315 (patch)
treea5b98ccc71812dc663ac3749e963102a43e9ff61
parent2a6f160fbfe1f89c3626f07540fc973ef5a00553 (diff)
Improve synchronize dialog
-rw-r--r--pimsettingexporter/gui/autotests/CMakeLists.txt2
-rw-r--r--pimsettingexporter/gui/autotests/synchronizeresourcedialogtest.cpp17
-rw-r--r--pimsettingexporter/gui/dialog/synchronizeresourcedialog.cpp40
-rw-r--r--pimsettingexporter/gui/dialog/synchronizeresourcedialog.h8
4 files changed, 63 insertions, 4 deletions
diff --git a/pimsettingexporter/gui/autotests/CMakeLists.txt b/pimsettingexporter/gui/autotests/CMakeLists.txt
index 6742340..bb78ba3 100644
--- a/pimsettingexporter/gui/autotests/CMakeLists.txt
+++ b/pimsettingexporter/gui/autotests/CMakeLists.txt
@@ -1,5 +1,5 @@
add_executable( synchronizeresourcedialogtest synchronizeresourcedialogtest.cpp ../dialog/synchronizeresourcedialog.cpp)
add_test(synchronizeresourcedialogtest synchronizeresourcedialogtest)
ecm_mark_as_test(synchronizeresourcedialogtest)
-target_link_libraries(synchronizeresourcedialogtest Qt5::Test Qt5::Widgets KF5::I18n)
+target_link_libraries(synchronizeresourcedialogtest Qt5::Test Qt5::Widgets KF5::I18n KF5::ItemViews KF5::ConfigCore)
diff --git a/pimsettingexporter/gui/autotests/synchronizeresourcedialogtest.cpp b/pimsettingexporter/gui/autotests/synchronizeresourcedialogtest.cpp
index 18261dd..a12508c 100644
--- a/pimsettingexporter/gui/autotests/synchronizeresourcedialogtest.cpp
+++ b/pimsettingexporter/gui/autotests/synchronizeresourcedialogtest.cpp
@@ -19,11 +19,16 @@
#include "../dialog/synchronizeresourcedialog.h"
#include <QDialogButtonBox>
#include <QTest>
+#include <QListWidget>
+#include <KListWidgetSearchLine>
+#include <QStandardPaths>
+
+#include <QLabel>
SynchronizeResourceDialogTest::SynchronizeResourceDialogTest(QObject *parent)
: QObject(parent)
{
-
+ QStandardPaths::setTestModeEnabled(true);
}
SynchronizeResourceDialogTest::~SynchronizeResourceDialogTest()
@@ -36,6 +41,16 @@ void SynchronizeResourceDialogTest::shouldHaveDefaultValue()
SynchronizeResourceDialog dlg;
QDialogButtonBox *buttonBox = dlg.findChild<QDialogButtonBox *>(QStringLiteral("buttonbox"));
QVERIFY(buttonBox);
+
+ QListWidget *listWidget = dlg.findChild<QListWidget *>(QStringLiteral("listresourcewidget"));
+ QVERIFY(listWidget);
+
+ KListWidgetSearchLine *searchLine = dlg.findChild<KListWidgetSearchLine *>(QStringLiteral("listwidgetsearchline"));
+ QVERIFY(searchLine);
+
+ QLabel *label = dlg.findChild<QLabel *>(QStringLiteral("label"));
+ QVERIFY(label);
+ QVERIFY(label->wordWrap());
}
QTEST_MAIN(SynchronizeResourceDialogTest)
diff --git a/pimsettingexporter/gui/dialog/synchronizeresourcedialog.cpp b/pimsettingexporter/gui/dialog/synchronizeresourcedialog.cpp
index 04e1545..da9256a 100644
--- a/pimsettingexporter/gui/dialog/synchronizeresourcedialog.cpp
+++ b/pimsettingexporter/gui/dialog/synchronizeresourcedialog.cpp
@@ -18,9 +18,15 @@
#include "synchronizeresourcedialog.h"
#include <KLocalizedString>
+#include <KListWidgetSearchLine>
+
#include <QPushButton>
#include <QDialogButtonBox>
#include <QVBoxLayout>
+#include <QListWidget>
+#include <QLabel>
+#include <KConfigGroup>
+#include <KSharedConfig>
SynchronizeResourceDialog::SynchronizeResourceDialog(QWidget *parent)
: QDialog(parent)
@@ -33,16 +39,28 @@ SynchronizeResourceDialog::SynchronizeResourceDialog(QWidget *parent)
QPushButton *okButton = buttonBox->button(QDialogButtonBox::Ok);
okButton->setDefault(true);
okButton->setShortcut(Qt::CTRL | Qt::Key_Return);
+ mListResourceWidget = new QListWidget(this);
+ mListResourceWidget->setObjectName(QStringLiteral("listresourcewidget"));
+ 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 resource that you want to sync:"));
+ lab->setWordWrap(true);
+ lab->setObjectName(QStringLiteral("label"));
connect(buttonBox, &QDialogButtonBox::accepted, this, &SynchronizeResourceDialog::slotAccepted);
connect(buttonBox, &QDialogButtonBox::rejected, this, &SynchronizeResourceDialog::reject);
okButton->setDefault(true);
setModal(true);
+
+ topLayout->addWidget(listWidgetSearchLine);
+ topLayout->addWidget(mListResourceWidget);
topLayout->addWidget(buttonBox);
+ readConfig();
}
SynchronizeResourceDialog::~SynchronizeResourceDialog()
{
-
+ writeConfig();
}
void SynchronizeResourceDialog::setResources(const QStringList &resources)
@@ -50,7 +68,27 @@ void SynchronizeResourceDialog::setResources(const QStringList &resources)
//TODO
}
+QStringList SynchronizeResourceDialog::resources() const
+{
+ return QStringList();
+}
+
void SynchronizeResourceDialog::slotAccepted()
{
accept();
}
+
+void SynchronizeResourceDialog::readConfig()
+{
+ KConfigGroup group(KSharedConfig::openConfig(), "SynchronizeResourceDialog");
+ const QSize sizeDialog = group.readEntry("Size", QSize(600, 400));
+ if (sizeDialog.isValid()) {
+ resize(sizeDialog);
+ }
+}
+
+void SynchronizeResourceDialog::writeConfig()
+{
+ KConfigGroup group(KSharedConfig::openConfig(), "SynchronizeResourceDialog");
+ group.writeEntry("Size", size());
+}
diff --git a/pimsettingexporter/gui/dialog/synchronizeresourcedialog.h b/pimsettingexporter/gui/dialog/synchronizeresourcedialog.h
index 73fb46a..7d62922 100644
--- a/pimsettingexporter/gui/dialog/synchronizeresourcedialog.h
+++ b/pimsettingexporter/gui/dialog/synchronizeresourcedialog.h
@@ -20,7 +20,7 @@
#define SYNCHRONIZERESOURCEDIALOG_H
#include <QDialog>
-
+class QListWidget;
class SynchronizeResourceDialog : public QDialog
{
Q_OBJECT
@@ -29,9 +29,15 @@ public:
~SynchronizeResourceDialog();
void setResources(const QStringList &resources);
+ QStringList resources() const;
private Q_SLOTS:
void slotAccepted();
+
+private:
+ void readConfig();
+ void writeConfig();
+ QListWidget *mListResourceWidget;
};
#endif // SYNCHRONIZERESOURCEDIALOG_H