Commit 09f84fc1 authored by Laurent Montel's avatar Laurent Montel 😁

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
parent 597b6235
......@@ -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")
/*
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)
/*
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
......@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment