summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <montel@kde.org>2016-10-31 12:57:02 (GMT)
committerMontel Laurent <montel@kde.org>2016-10-31 12:57:02 (GMT)
commit1acb0b96c42c62362328116dc9f698bef01bfa8e (patch)
treed231ad7b8ca7a13518a7c7405c3b9ea8eaab89c5
parente9d264720e630e12df6f9bdc8be84c888224a2fd (diff)
Allow to rename file
-rw-r--r--src/kmanagesieve/sievejob.cpp4
-rw-r--r--src/ksieveui/widgets/managesievewidget.cpp20
-rw-r--r--src/ksieveui/widgets/managesievewidget.h1
3 files changed, 22 insertions, 3 deletions
diff --git a/src/kmanagesieve/sievejob.cpp b/src/kmanagesieve/sievejob.cpp
index 29e111e..fa0ccc4 100644
--- a/src/kmanagesieve/sievejob.cpp
+++ b/src/kmanagesieve/sievejob.cpp
@@ -97,7 +97,8 @@ void SieveJob::Private::run(Session *session)
}
case Rename: {
const QString filename = mUrl.fileName(/*QUrl::ObeyTrailingSlash*/);
- session->sendData("RENAMESCRIPT \"" + filename.toUtf8() + "\" \"" + mNewName.toUtf8() + "\"");
+ const QByteArray ba = QByteArray("RENAMESCRIPT \"" + filename.toUtf8() + "\" \"" + mNewName.toUtf8() + "\"");
+ session->sendData(ba);
break;
}
@@ -341,7 +342,6 @@ SieveJob *SieveJob::deactivate(const QUrl &url)
{
QStack<Private::Command> commands;
commands.push(Private::Deactivate);
-
SieveJob *job = new SieveJob;
job->d->mUrl = url;
job->d->mCommands = commands;
diff --git a/src/ksieveui/widgets/managesievewidget.cpp b/src/ksieveui/widgets/managesievewidget.cpp
index a22b173..3bbc3e0 100644
--- a/src/ksieveui/widgets/managesievewidget.cpp
+++ b/src/ksieveui/widgets/managesievewidget.cpp
@@ -379,7 +379,25 @@ void ManageSieveWidget::slotRenameScript()
if (u.isEmpty()) {
return;
}
- //TODO
+
+ const QString newName = QInputDialog::getText(this, i18n("New Script Name"), i18n("Script Name:"), QLineEdit::Normal, u.fileName());
+ if (newName.isEmpty()) {
+ return;
+ }
+
+ u = u.adjusted(QUrl::RemoveFilename);
+ u.setPath(u.path() + QLatin1Char('/') + currentItem->text(0));
+
+ qDebug()<<" u " << u;
+ KManageSieve::SieveJob *job = KManageSieve::SieveJob::rename(u, newName);
+ connect(job, &KManageSieve::SieveJob::result, this, &ManageSieveWidget::slotRenameResult);
+ //TODO ? Q_EMIT scriptRenamed(u);
+ slotRefresh();
+}
+
+void ManageSieveWidget::slotRenameResult(KManageSieve::SieveJob *job, bool success)
+{
+ qDebug()<<" void ManageSieveWidget::slotRenameResult(KManageSieve::SieveJob *job, bool success)"<<success;
}
void ManageSieveWidget::slotDeleteScript()
diff --git a/src/ksieveui/widgets/managesievewidget.h b/src/ksieveui/widgets/managesievewidget.h
index 75862eb..dd0307f 100644
--- a/src/ksieveui/widgets/managesievewidget.h
+++ b/src/ksieveui/widgets/managesievewidget.h
@@ -71,6 +71,7 @@ private Q_SLOTS:
void setActiveScripts(ParseUserScriptJob *job);
void slotCancelFetch();
+ void slotRenameResult(KManageSieve::SieveJob *job, bool success);
public Q_SLOTS:
void slotRenameScript();
void slotGotList(KManageSieve::SieveJob *job, bool success, const QStringList &listScript, const QString &activeScript);