summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <montel@kde.org>2016-09-30 05:27:31 (GMT)
committerMontel Laurent <montel@kde.org>2016-09-30 05:27:31 (GMT)
commit93044cf7cdc21f0e0c424eb311d3f7a6ecc0fcb1 (patch)
tree43579c75fb888067370e6ec06bbb046db143307c
parent54c8c7474b89541ca0ef66d96b2967b850c6d20b (diff)
Allow to modify item when we double click
-rw-r--r--plugins/messageviewerplugins/externalscriptplugin/configuredialog/viewerpluginexternalconfigurewidget.cpp28
-rw-r--r--plugins/messageviewerplugins/externalscriptplugin/configuredialog/viewerpluginexternalconfigurewidget.h3
2 files changed, 24 insertions, 7 deletions
diff --git a/plugins/messageviewerplugins/externalscriptplugin/configuredialog/viewerpluginexternalconfigurewidget.cpp b/plugins/messageviewerplugins/externalscriptplugin/configuredialog/viewerpluginexternalconfigurewidget.cpp
index c46962f..229374d 100644
--- a/plugins/messageviewerplugins/externalscriptplugin/configuredialog/viewerpluginexternalconfigurewidget.cpp
+++ b/plugins/messageviewerplugins/externalscriptplugin/configuredialog/viewerpluginexternalconfigurewidget.cpp
@@ -79,6 +79,7 @@ ViewerPluginExternalConfigureWidget::ViewerPluginExternalConfigureWidget(QWidget
mListExternal->setSelectionMode(QAbstractItemView::SingleSelection);
listLayout->addWidget(mListExternal);
connect(mListExternal, &QListWidget::itemSelectionChanged, this, &ViewerPluginExternalConfigureWidget::updateButtons);
+ connect(mListExternal, &QListWidget::itemDoubleClicked, this, &ViewerPluginExternalConfigureWidget::slotDoubleClicked);
QVBoxLayout *buttonLayout = new QVBoxLayout;
mainLayout->addLayout(buttonLayout);
@@ -121,13 +122,7 @@ void ViewerPluginExternalConfigureWidget::slotModifyScript()
{
QListWidgetItem *item = mListExternal->currentItem();
if (item) {
- ViewerPluginExternalScriptItem *scriptItem = static_cast<ViewerPluginExternalScriptItem *>(item);
- QPointer<ViewerPluginExternalEditDialog> dlg = new ViewerPluginExternalEditDialog(this);
- dlg->setScriptInfo(scriptItem->scriptInfo());
- if (dlg->exec()) {
- scriptItem->setScriptInfo(dlg->scriptInfo());
- }
- delete dlg;
+ modifyScript(item);
}
}
@@ -204,3 +199,22 @@ void ViewerPluginExternalConfigureWidget::updateButtons()
}
}
+void ViewerPluginExternalConfigureWidget::slotDoubleClicked(QListWidgetItem * item)
+{
+ if (item) {
+ modifyScript(item);
+ }
+}
+
+void ViewerPluginExternalConfigureWidget::modifyScript(QListWidgetItem *item)
+{
+ ViewerPluginExternalScriptItem *scriptItem = static_cast<ViewerPluginExternalScriptItem *>(item);
+ if (!scriptItem->scriptInfo().isReadOnly()) {
+ QPointer<ViewerPluginExternalEditDialog> dlg = new ViewerPluginExternalEditDialog(this);
+ dlg->setScriptInfo(scriptItem->scriptInfo());
+ if (dlg->exec()) {
+ scriptItem->setScriptInfo(dlg->scriptInfo());
+ }
+ delete dlg;
+ }
+}
diff --git a/plugins/messageviewerplugins/externalscriptplugin/configuredialog/viewerpluginexternalconfigurewidget.h b/plugins/messageviewerplugins/externalscriptplugin/configuredialog/viewerpluginexternalconfigurewidget.h
index bbaee26..7798f45 100644
--- a/plugins/messageviewerplugins/externalscriptplugin/configuredialog/viewerpluginexternalconfigurewidget.h
+++ b/plugins/messageviewerplugins/externalscriptplugin/configuredialog/viewerpluginexternalconfigurewidget.h
@@ -24,6 +24,7 @@
#include "../viewerpluginexternalscriptsloadjob.h"
class QListWidget;
class QPushButton;
+class QListWidgetItem;
class ViewerPluginExternalConfigureWidget : public QWidget
{
Q_OBJECT
@@ -34,11 +35,13 @@ public:
void save();
void reset();
private:
+ void modifyScript(QListWidgetItem *item);
void fillScriptInfo(const QVector<ViewerPluginExternalScriptInfo> &scriptInfos);
void slotAddScript();
void slotModifyScript();
void updateButtons();
void slotRemoveScript();
+ void slotDoubleClicked(QListWidgetItem *item);
QStringList mFilesToRemove;
QListWidget *mListExternal;