Commit 522e1a38 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Use directly RemoteContentStatusTypeComboBox

parent 47c07529
Pipeline #53588 passed with stage
in 41 minutes and 17 seconds
......@@ -5,9 +5,9 @@
*/
#include "remotecontentwidgettest.h"
#include "remote-content/remotecontentstatustypecombobox.h"
#include "remote-content/remotecontentwidget.h"
#include <QCheckBox>
#include <QFormLayout>
#include <QHBoxLayout>
#include <QLineEdit>
#include <QTest>
QTEST_MAIN(RemoteContentWidgetTest)
......@@ -19,7 +19,7 @@ RemoteContentWidgetTest::RemoteContentWidgetTest(QObject *parent)
void RemoteContentWidgetTest::shouldHaveDefaultValues()
{
MessageViewer::RemoteContentWidget w;
auto mainLayout = w.findChild<QFormLayout *>(QStringLiteral("mainLayout"));
auto mainLayout = w.findChild<QHBoxLayout *>(QStringLiteral("mainLayout"));
QVERIFY(mainLayout);
QCOMPARE(mainLayout->contentsMargins(), {});
......@@ -27,6 +27,6 @@ void RemoteContentWidgetTest::shouldHaveDefaultValues()
QVERIFY(mLineEdit);
QVERIFY(mLineEdit->text().isEmpty());
auto mStatusCheckBox = w.findChild<QCheckBox *>(QStringLiteral("mStatusCheckBox"));
QVERIFY(mStatusCheckBox);
auto mStatusComboBox = w.findChild<MessageViewer::RemoteContentStatusTypeComboBox *>(QStringLiteral("mStatusComboBox"));
QVERIFY(mStatusComboBox);
}
......@@ -5,10 +5,11 @@
*/
#include "remotecontentwidget.h"
#include "remotecontentstatustypecombobox.h"
#include <KLocalizedString>
#include <QCheckBox>
#include <QFormLayout>
#include <QHBoxLayout>
#include <QLabel>
#include <QLineEdit>
......@@ -16,17 +17,19 @@ using namespace MessageViewer;
RemoteContentWidget::RemoteContentWidget(QWidget *parent)
: QWidget(parent)
, mLineEdit(new QLineEdit(this))
, mStatusCheckBox(new QCheckBox(i18n("Authorized"), this))
, mStatusComboBox(new RemoteContentStatusTypeComboBox(this))
{
auto mainLayout = new QFormLayout(this);
auto mainLayout = new QHBoxLayout(this);
mainLayout->setObjectName(QStringLiteral("mainLayout"));
mainLayout->setContentsMargins({});
mLineEdit->setObjectName(QStringLiteral("mLineEdit"));
mainLayout->addRow(i18n("Domain:"), mLineEdit);
QLabel *label = new QLabel(i18n("Domain:"), this);
mainLayout->addWidget(label);
mainLayout->addWidget(mLineEdit);
mStatusCheckBox->setObjectName(QStringLiteral("mStatusCheckBox"));
mainLayout->addRow(mStatusCheckBox);
mStatusComboBox->setObjectName(QStringLiteral("mStatusComboBox"));
mainLayout->addWidget(mStatusComboBox);
connect(mLineEdit, &QLineEdit::textChanged, this, &RemoteContentWidget::slotTextChanged);
}
......@@ -43,12 +46,12 @@ RemoteContentInfo RemoteContentWidget::info() const
{
RemoteContentInfo info;
info.setUrl(mLineEdit->text());
info.setStatus(mStatusCheckBox->isChecked() ? RemoteContentInfo::RemoteContentInfoStatus::Authorized : RemoteContentInfo::RemoteContentInfoStatus::Blocked);
info.setStatus(mStatusComboBox->status());
return info;
}
void RemoteContentWidget::setInfo(const RemoteContentInfo &info)
{
mLineEdit->setText(info.url());
mStatusCheckBox->setChecked(info.status() == RemoteContentInfo::RemoteContentInfoStatus::Authorized);
mStatusComboBox->setStatus(info.status());
}
......@@ -11,9 +11,9 @@
#include "remotecontentinfo.h"
#include <QWidget>
class QLineEdit;
class QCheckBox;
namespace MessageViewer
{
class RemoteContentStatusTypeComboBox;
class MESSAGEVIEWER_TESTS_EXPORT RemoteContentWidget : public QWidget
{
Q_OBJECT
......@@ -30,7 +30,7 @@ Q_SIGNALS:
private:
void slotTextChanged(const QString &url);
QLineEdit *const mLineEdit;
QCheckBox *const mStatusCheckBox;
RemoteContentStatusTypeComboBox *const mStatusComboBox;
};
}
#endif // REMOTECONTENTWIDGET_H
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