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

Extract code for updating global script

parent fc9a3ea5
......@@ -318,22 +318,8 @@ void ManageSieveWidget::slotDeactivateScript()
}
}
void ManageSieveWidget::changeActiveScript(QTreeWidgetItem *item, bool activate)
bool ManageSieveWidget::updateGlobalScript(QTreeWidgetItem *item, const QUrl &u)
{
if (!item) {
return;
}
if (!mUrls.contains(item)) {
return;
}
if (!d->mSelectedItems.contains(item)) {
return;
}
QUrl u = mUrls[item];
if (u.isEmpty()) {
return;
}
if (item->data(0, SIEVE_SERVER_MODE).toInt() == Kep14EditorMode) {
QStringList activeScripts;
for (int i = 0; i < item->childCount(); ++i) {
......@@ -348,8 +334,28 @@ void ManageSieveWidget::changeActiveScript(QTreeWidgetItem *item, bool activate)
connect(job, &GenerateGlobalScriptJob::success, this, &ManageSieveWidget::slotRefresh);
connect(job, &GenerateGlobalScriptJob::error, this, &ManageSieveWidget::slotGenerateGlobalScriptError);
job->start();
return true;
}
return false;
}
void ManageSieveWidget::changeActiveScript(QTreeWidgetItem *item, bool activate)
{
if (!item) {
return;
}
if (!mUrls.contains(item)) {
return;
}
if (!d->mSelectedItems.contains(item)) {
return;
}
QUrl u = mUrls[item];
if (u.isEmpty()) {
return;
}
if (updateGlobalScript(item, u))
return;
QTreeWidgetItem *selected = d->mSelectedItems[item];
if (!selected) {
......
......@@ -103,6 +103,7 @@ private:
bool isFileNameItem(QTreeWidgetItem *item) const;
bool itemIsActived(QTreeWidgetItem *item) const;
void changeActiveScript(QTreeWidgetItem *item, bool activate);
Q_REQUIRED_RESULT bool updateGlobalScript(QTreeWidgetItem *item, const QUrl &u);
void slotGenerateGlobalScriptError(const QString &errorStr);
std::unique_ptr<ManageSieveWidgetPrivate> const d;
};
......
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