[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 layout of delegatese
From:       Montel Laurent <montel () kde ! org>
Date:       2016-08-05 12:00:04
Message-ID: E1bVdnI-0002Y2-4F () code ! kde ! org
[Download RAW message or body]

Git commit 09f84fc16956d637d52786432e68a077d9a39ec0 by Montel Laurent.
Committed on 05/08/2016 at 11:43.
Pushed by mlaurent into branch 'Applications/16.08'.

Fix layout of delegateselector. I think that nobody uses this feature.

Add autotests too to be sure that it will not break in the future

M  +2    -1    plugins/messageviewer/bodypartformatter/autotests/CMakeLists.txt
A  +58   -0    plugins/messageviewer/bodypartformatter/autotests/delegateselectortest.cpp \
[License: GPL (v2+)] A  +35   -0    \
plugins/messageviewer/bodypartformatter/autotests/delegateselectortest.h     \
[License: GPL (v2+)] M  +21   -16   \
plugins/messageviewer/bodypartformatter/calendar/delegateselector.cpp

http://commits.kde.org/kdepim-addons/09f84fc16956d637d52786432e68a077d9a39ec0

diff --git a/plugins/messageviewer/bodypartformatter/autotests/CMakeLists.txt \
b/plugins/messageviewer/bodypartformatter/autotests/CMakeLists.txt index \
                a187479..49b2a12 100644
--- a/plugins/messageviewer/bodypartformatter/autotests/CMakeLists.txt
+++ b/plugins/messageviewer/bodypartformatter/autotests/CMakeLists.txt
@@ -23,7 +23,8 @@ macro(add_messageviewer_bodyformatter_class_unittest _source \
_additional)  ecm_add_test(${_test}
                  TEST_NAME ${_name}
                  NAME_PREFIX "messageviewerplugins-"
-                 LINK_LIBRARIES KF5::MessageViewer Qt5::Test KF5::PimTextEdit \
KF5::I18n +                 LINK_LIBRARIES KF5::MessageViewer Qt5::Test \
KF5::PimTextEdit KF5::I18n KF5::Completion KF5::Libkdepim  )
 endmacro ()
 add_messageviewer_bodyformatter_class_unittest(reactiontoinvitationdialogtest.cpp \
"../calendar/reactiontoinvitationdialog.cpp") \
+add_messageviewer_bodyformatter_class_unittest(delegateselectortest.cpp \
                "../calendar/delegateselector.cpp")
diff --git a/plugins/messageviewer/bodypartformatter/autotests/delegateselectortest.cpp \
b/plugins/messageviewer/bodypartformatter/autotests/delegateselectortest.cpp new file \
mode 100644 index 0000000..4b1f768
--- /dev/null
+++ b/plugins/messageviewer/bodypartformatter/autotests/delegateselectortest.cpp
@@ -0,0 +1,58 @@
+/*
+   Copyright (C) 2016 Montel Laurent <montel@kde.org>
+
+   This program is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public
+   License as published by the Free Software Foundation; either
+   version 2 of the License, or (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; see the file COPYING.  If not, write to
+   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+   Boston, MA 02110-1301, USA.
+*/
+
+#include "delegateselectortest.h"
+#include "../calendar/delegateselector.h"
+#include <QTest>
+#include <QLabel>
+#include <QCheckBox>
+#include <QDialogButtonBox>
+#include <Libkdepim/AddresseeLineEdit>
+
+DelegateSelectorTest::DelegateSelectorTest(QObject *parent)
+    : QObject(parent)
+{
+
+}
+
+DelegateSelectorTest::~DelegateSelectorTest()
+{
+
+}
+
+void DelegateSelectorTest::shouldHaveDefaultValue()
+{
+    DelegateSelector w;
+    QLabel *label = w.findChild<QLabel *>(QStringLiteral("label"));
+    QVERIFY(label);
+    QVERIFY(!label->text().isEmpty());
+
+    KPIM::AddresseeLineEdit *mDelegate = w.findChild<KPIM::AddresseeLineEdit \
*>(QStringLiteral("delegate")); +    QVERIFY(mDelegate);
+
+    QCheckBox *mRsvp = w.findChild<QCheckBox *>(QStringLiteral("informcheckbox"));
+    QVERIFY(mRsvp);
+    QVERIFY(mRsvp->isChecked());
+    QVERIFY(!mRsvp->text().isEmpty());
+
+    QDialogButtonBox *buttonBox = w.findChild<QDialogButtonBox \
*>(QStringLiteral("buttonbox")); +    QVERIFY(buttonBox);
+}
+
+QTEST_MAIN(DelegateSelectorTest)
diff --git a/plugins/messageviewer/bodypartformatter/autotests/delegateselectortest.h \
b/plugins/messageviewer/bodypartformatter/autotests/delegateselectortest.h new file \
mode 100644 index 0000000..f2f575c
--- /dev/null
+++ b/plugins/messageviewer/bodypartformatter/autotests/delegateselectortest.h
@@ -0,0 +1,35 @@
+/*
+   Copyright (C) 2016 Montel Laurent <montel@kde.org>
+
+   This program is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public
+   License as published by the Free Software Foundation; either
+   version 2 of the License, or (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; see the file COPYING.  If not, write to
+   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+   Boston, MA 02110-1301, USA.
+*/
+
+#ifndef DELEGATESELECTORTEST_H
+#define DELEGATESELECTORTEST_H
+
+#include <QObject>
+
+class DelegateSelectorTest : public QObject
+{
+    Q_OBJECT
+public:
+    explicit DelegateSelectorTest(QObject *parent = Q_NULLPTR);
+    ~DelegateSelectorTest();
+private Q_SLOTS:
+    void shouldHaveDefaultValue();
+};
+
+#endif // DELEGATESELECTORTEST_H
diff --git a/plugins/messageviewer/bodypartformatter/calendar/delegateselector.cpp \
b/plugins/messageviewer/bodypartformatter/calendar/delegateselector.cpp index \
                38e6b0d..7dc79ba 100644
--- a/plugins/messageviewer/bodypartformatter/calendar/delegateselector.cpp
+++ b/plugins/messageviewer/bodypartformatter/calendar/delegateselector.cpp
@@ -36,30 +36,35 @@ DelegateSelector::DelegateSelector(QWidget *parent)
     : QDialog(parent)
 {
     setWindowTitle(i18n("Select delegate"));
-    QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | \
                QDialogButtonBox::Cancel);
-    QVBoxLayout *mainLayout = new QVBoxLayout;
-    setLayout(mainLayout);
+    QVBoxLayout *mainLayout = new QVBoxLayout(this);
+
+    QLabel *label = new QLabel(i18n("Delegate:"), this);
+    label->setObjectName(QStringLiteral("label"));
+    mainLayout->addWidget(label);
+
+    mDelegate = new KPIM::AddresseeLineEdit(this);
+    mDelegate->setObjectName(QStringLiteral("delegate"));
+    mainLayout->addWidget(mDelegate);
+
+    connect(mDelegate, &KPIM::AddresseeLineEdit::textChanged, this, \
&DelegateSelector::slotTextChanged); +    mRsvp = new QCheckBox(i18n("Keep me \
informed about status changes of this incidence."), this); +    \
mRsvp->setObjectName(QStringLiteral("informcheckbox")); +
+    mRsvp->setChecked(true);
+    mainLayout->addWidget(mRsvp);
+
+
+    QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | \
QDialogButtonBox::Cancel, this); +    \
buttonBox->setObjectName(QStringLiteral("buttonbox"));  mOkButton = \
buttonBox->button(QDialogButtonBox::Ok);  mOkButton->setDefault(true);
     mOkButton->setShortcut(Qt::CTRL | Qt::Key_Return);
     connect(buttonBox, &QDialogButtonBox::accepted, this, \
                &DelegateSelector::accept);
     connect(buttonBox, &QDialogButtonBox::rejected, this, \
&DelegateSelector::reject);  mOkButton->setDefault(true);
+    mOkButton->setEnabled(false);
 
-    QWidget *delegateBox = new QWidget(this);
-    QHBoxLayout *delegateBoxHBoxLayout = new QHBoxLayout(delegateBox);
-    delegateBoxHBoxLayout->setMargin(0);
-    new QLabel(i18n("Delegate:"), delegateBox);
-    mDelegate = new KPIM::AddresseeLineEdit(delegateBox);
-    connect(mDelegate, &KPIM::AddresseeLineEdit::textChanged, this, \
                &DelegateSelector::slotTextChanged);
-    mRsvp = new QCheckBox(i18n("Keep me informed about status changes of this \
                incidence."), this);
-    mRsvp->setChecked(true);
-
-    mainLayout->addWidget(delegateBox);
-    mainLayout->addWidget(mRsvp);
     mainLayout->addWidget(buttonBox);
-
-    mOkButton->setEnabled(false);
 }
 
 void DelegateSelector::slotTextChanged(const QString &text)


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

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