Commit e3140a42 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Use a QSpinBox

parent c792a1f9
......@@ -23,6 +23,7 @@
#include <QCheckBox>
#include <QFormLayout>
#include <QLineEdit>
#include <QSpinBox>
#include <QTest>
QTEST_MAIN(DKIMRuleWidgetTest)
......@@ -67,8 +68,7 @@ void DKIMRuleWidgetTest::shouldHaveDefaultValues()
MessageViewer::DKIMManageRulesComboBox *mRuleType = w.findChild<MessageViewer::DKIMManageRulesComboBox *>(QStringLiteral("ruletype"));
QVERIFY(mRuleType);
QLineEdit *mPriority = w.findChild<QLineEdit *>(QStringLiteral("priority"));
QSpinBox *mPriority = w.findChild<QSpinBox *>(QStringLiteral("priority"));
QVERIFY(mPriority);
QCOMPARE(mPriority->text(), QStringLiteral("1000"));
QVERIFY(mPriority->isClearButtonEnabled());
QCOMPARE(mPriority->value(), 1000);
}
......@@ -24,6 +24,7 @@
#include <QFormLayout>
#include <QLineEdit>
#include <QIntValidator>
#include <QSpinBox>
using namespace MessageViewer;
DKIMRuleWidget::DKIMRuleWidget(QWidget *parent)
......@@ -65,12 +66,11 @@ DKIMRuleWidget::DKIMRuleWidget(QWidget *parent)
mRuleType->setObjectName(QStringLiteral("ruletype"));
layout->addRow(i18n("Rule:"), mRuleType);
QIntValidator *validator = new QIntValidator(1, 9999, this);
mPriority = new QLineEdit(this);
mPriority = new QSpinBox(this);
mPriority->setObjectName(QStringLiteral("priority"));
mPriority->setValidator(validator);
mPriority->setClearButtonEnabled(true);
mPriority->setText(QString::number(1000)); //Default Value
mPriority->setMinimum(1);
mPriority->setMaximum(9999);
mPriority->setValue(1000); //Default Value
layout->addRow(i18n("Priority:"), mPriority);
}
......@@ -91,7 +91,7 @@ void DKIMRuleWidget::loadRule(const MessageViewer::DKIMRule &rule)
mFrom->setText(rule.from());
mListId->setText(rule.listId());
mRuleType->setRuleType(rule.ruleType());
mPriority->setText(QString::number(rule.priority()));
mPriority->setValue(rule.priority());
}
MessageViewer::DKIMRule DKIMRuleWidget::rule() const
......@@ -103,6 +103,6 @@ MessageViewer::DKIMRule DKIMRuleWidget::rule() const
rule.setFrom(mFrom->text());
rule.setListId(mListId->text());
rule.setRuleType(mRuleType->ruleType());
rule.setPriority(mPriority->text().toInt());
rule.setPriority(mPriority->value());
return rule;
}
......@@ -24,6 +24,7 @@
#include <MessageViewer/DKIMRule>
class QCheckBox;
class QLineEdit;
class QSpinBox;
namespace MessageViewer {
class DKIMManageRulesComboBox;
class MESSAGEVIEWER_TESTS_EXPORT DKIMRuleWidget : public QWidget
......@@ -45,7 +46,7 @@ private:
QLineEdit *mSignatureDomainIdentifier = nullptr;
QLineEdit *mFrom = nullptr;
QLineEdit *mListId = nullptr;
QLineEdit *mPriority = nullptr;
QSpinBox *mPriority = nullptr;
DKIMManageRulesComboBox *mRuleType = nullptr;
};
}
......
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