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

Add isValid

parent 34719d5a
Pipeline #132948 failed with stage
in 13 minutes and 45 seconds
......@@ -43,3 +43,8 @@ void OpenUrlWithConfigureCreateWidget::setInfo(const OpenUrlWithInfo &i)
mServerName->setText(i.url);
mCommand->setText(i.command);
}
bool OpenUrlWithConfigureCreateWidget::OpenUrlWithInfo::isValid() const
{
return !url.trimmed().isEmpty() && !command.trimmed().isEmpty();
}
......@@ -15,6 +15,7 @@ public:
struct OpenUrlWithInfo {
QString command;
QString url;
Q_REQUIRED_RESULT bool isValid() const;
};
explicit OpenUrlWithConfigureCreateWidget(QWidget *parent = nullptr);
......@@ -22,7 +23,6 @@ public:
Q_REQUIRED_RESULT OpenUrlWithInfo info() const;
void setInfo(const OpenUrlWithInfo &i);
private:
QLineEdit *const mServerName;
QLineEdit *const mCommand;
......
......@@ -70,9 +70,11 @@ void OpenUrlWithConfigureWidget::slotAddRule()
QPointer<OpenUrlWithConfigureCreateDialog> dlg = new OpenUrlWithConfigureCreateDialog(this);
if (dlg->exec()) {
const OpenUrlWithConfigureCreateWidget::OpenUrlWithInfo info = dlg->info();
auto item = new QTreeWidgetItem(mTreeWidget);
item->setText(0, info.url);
item->setText(1, info.command);
if (info.isValid()) {
auto item = new QTreeWidgetItem(mTreeWidget);
item->setText(0, info.url);
item->setText(1, info.command);
}
}
delete dlg;
}
......@@ -88,8 +90,10 @@ void OpenUrlWithConfigureWidget::slotEditRule()
dlg->setInfo(info);
if (dlg->exec()) {
const OpenUrlWithConfigureCreateWidget::OpenUrlWithInfo info = dlg->info();
item->setText(0, info.url);
item->setText(1, info.command);
if (info.isValid()) {
item->setText(0, info.url);
item->setText(1, info.command);
}
}
delete dlg;
}
......
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