[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kdepim-addons/Applications/16.08] plugins/messageviewer/bodypartformatter: Fix enable disable ok bu
From:       Montel Laurent <montel () kde ! org>
Date:       2016-08-05 12:00:04
Message-ID: E1bVdnI-0002Y2-4t () code ! kde ! org
[Download RAW message or body]

Git commit 936758922f3e30ecd2542809e5c2e8c165e8bc48 by Montel Laurent.
Committed on 05/08/2016 at 11:51.
Pushed by mlaurent into branch 'Applications/16.08'.

Fix enable disable ok button

M  +27   -0    plugins/messageviewer/bodypartformatter/autotests/delegateselectortest.cpp
 M  +1    -0    plugins/messageviewer/bodypartformatter/autotests/delegateselectortest.h
 M  +2    -1    plugins/messageviewer/bodypartformatter/calendar/delegateselector.cpp

http://commits.kde.org/kdepim-addons/936758922f3e30ecd2542809e5c2e8c165e8bc48

diff --git a/plugins/messageviewer/bodypartformatter/autotests/delegateselectortest.cpp \
b/plugins/messageviewer/bodypartformatter/autotests/delegateselectortest.cpp index \
                4b1f768..480560e 100644
--- a/plugins/messageviewer/bodypartformatter/autotests/delegateselectortest.cpp
+++ b/plugins/messageviewer/bodypartformatter/autotests/delegateselectortest.cpp
@@ -22,6 +22,7 @@
 #include <QTest>
 #include <QLabel>
 #include <QCheckBox>
+#include <QPushButton>
 #include <QDialogButtonBox>
 #include <Libkdepim/AddresseeLineEdit>
 
@@ -45,6 +46,7 @@ void DelegateSelectorTest::shouldHaveDefaultValue()
 
     KPIM::AddresseeLineEdit *mDelegate = w.findChild<KPIM::AddresseeLineEdit \
*>(QStringLiteral("delegate"));  QVERIFY(mDelegate);
+    QVERIFY(mDelegate->text().isEmpty());
 
     QCheckBox *mRsvp = w.findChild<QCheckBox *>(QStringLiteral("informcheckbox"));
     QVERIFY(mRsvp);
@@ -53,6 +55,31 @@ void DelegateSelectorTest::shouldHaveDefaultValue()
 
     QDialogButtonBox *buttonBox = w.findChild<QDialogButtonBox \
*>(QStringLiteral("buttonbox"));  QVERIFY(buttonBox);
+
+    QPushButton *mOkButton = buttonBox->button(QDialogButtonBox::Ok);
+    QVERIFY(mOkButton);
+    QVERIFY(!mOkButton->isEnabled());
+}
+
+void DelegateSelectorTest::shouldChangeOkButtonState()
+{
+    DelegateSelector w;
+    KPIM::AddresseeLineEdit *mDelegate = w.findChild<KPIM::AddresseeLineEdit \
*>(QStringLiteral("delegate")); +    mDelegate->setEnableAkonadiSearch(false);
+    mDelegate->setEnableBalooSearch(false);
+
+    QDialogButtonBox *buttonBox = w.findChild<QDialogButtonBox \
*>(QStringLiteral("buttonbox")); +    QPushButton *mOkButton = \
buttonBox->button(QDialogButtonBox::Ok); +    QVERIFY(!mOkButton->isEnabled());
+
+
+    mDelegate->setText(QStringLiteral("foo"));
+    QVERIFY(mOkButton->isEnabled());
+
+    mDelegate->clear();
+    QVERIFY(!mOkButton->isEnabled());
+    mDelegate->setText(QStringLiteral(" "));
+    QVERIFY(!mOkButton->isEnabled());
 }
 
 QTEST_MAIN(DelegateSelectorTest)
diff --git a/plugins/messageviewer/bodypartformatter/autotests/delegateselectortest.h \
b/plugins/messageviewer/bodypartformatter/autotests/delegateselectortest.h index \
                f2f575c..7e3b65d 100644
--- a/plugins/messageviewer/bodypartformatter/autotests/delegateselectortest.h
+++ b/plugins/messageviewer/bodypartformatter/autotests/delegateselectortest.h
@@ -30,6 +30,7 @@ public:
     ~DelegateSelectorTest();
 private Q_SLOTS:
     void shouldHaveDefaultValue();
+    void shouldChangeOkButtonState();
 };
 
 #endif // DELEGATESELECTORTEST_H
diff --git a/plugins/messageviewer/bodypartformatter/calendar/delegateselector.cpp \
b/plugins/messageviewer/bodypartformatter/calendar/delegateselector.cpp index \
                7dc79ba..9e71207 100644
--- a/plugins/messageviewer/bodypartformatter/calendar/delegateselector.cpp
+++ b/plugins/messageviewer/bodypartformatter/calendar/delegateselector.cpp
@@ -57,6 +57,7 @@ DelegateSelector::DelegateSelector(QWidget *parent)
     QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | \
QDialogButtonBox::Cancel, this);  \
buttonBox->setObjectName(QStringLiteral("buttonbox"));  mOkButton = \
buttonBox->button(QDialogButtonBox::Ok); +    \
mOkButton->setObjectName(QStringLiteral("okbutton"));  mOkButton->setDefault(true);
     mOkButton->setShortcut(Qt::CTRL | Qt::Key_Return);
     connect(buttonBox, &QDialogButtonBox::accepted, this, \
&DelegateSelector::accept); @@ -69,7 +70,7 @@ \
DelegateSelector::DelegateSelector(QWidget *parent)  
 void DelegateSelector::slotTextChanged(const QString &text)
 {
-    mOkButton->setEnabled(!text.isEmpty());
+    mOkButton->setEnabled(!text.trimmed().isEmpty());
 }
 
 QString DelegateSelector::delegate() const


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic