summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <montel@kde.org>2016-09-28 05:07:03 (GMT)
committerMontel Laurent <montel@kde.org>2016-09-28 05:07:03 (GMT)
commitc11988bb7c86643cba28db4e52c7aeb8f757dd55 (patch)
tree5061fa4b192eaadcd4fa631d4cc7f491fe945120
parent8b64581ac2db86a65f5ed4622df8722972e0fdd3 (diff)
Use a custom QListViewItem
-rw-r--r--plugins/messageviewerplugins/externalscriptplugin/configuredialog/viewerpluginexternalconfigurewidget.cpp45
-rw-r--r--plugins/messageviewerplugins/externalscriptplugin/configuredialog/viewerpluginexternalconfigurewidget.h8
2 files changed, 35 insertions, 18 deletions
diff --git a/plugins/messageviewerplugins/externalscriptplugin/configuredialog/viewerpluginexternalconfigurewidget.cpp b/plugins/messageviewerplugins/externalscriptplugin/configuredialog/viewerpluginexternalconfigurewidget.cpp
index 6aa2ebc..b9a72c8 100644
--- a/plugins/messageviewerplugins/externalscriptplugin/configuredialog/viewerpluginexternalconfigurewidget.cpp
+++ b/plugins/messageviewerplugins/externalscriptplugin/configuredialog/viewerpluginexternalconfigurewidget.cpp
@@ -28,6 +28,33 @@
#include <KMessageBox>
#include <QPointer>
+class ViewerPluginExternalScriptItem : public QListWidgetItem
+{
+public:
+ ViewerPluginExternalScriptItem(QListWidget *parent);
+
+ void setScriptInfo(const ViewerPluginExternalScriptInfo &scriptInfo);
+ ViewerPluginExternalScriptInfo scriptInfo() const;
+private:
+ ViewerPluginExternalScriptInfo mScriptInfo;
+};
+
+ViewerPluginExternalScriptItem::ViewerPluginExternalScriptItem(QListWidget *parent)
+ : QListWidgetItem(parent)
+{
+
+}
+
+void ViewerPluginExternalScriptItem::setScriptInfo(const ViewerPluginExternalScriptInfo &scriptInfo)
+{
+ mScriptInfo = scriptInfo;
+}
+
+ViewerPluginExternalScriptInfo ViewerPluginExternalScriptItem::scriptInfo() const
+{
+ return mScriptInfo;
+}
+
ViewerPluginExternalConfigureWidget::ViewerPluginExternalConfigureWidget(QWidget *parent)
: QWidget(parent)
{
@@ -75,7 +102,7 @@ void ViewerPluginExternalConfigureWidget::slotRemoveScript()
{
QListWidgetItem *item = mListExternal->currentItem();
if (item) {
-
+ ViewerPluginExternalScriptItem *scriptItem = static_cast<ViewerPluginExternalScriptItem *>(item);
}
}
@@ -83,7 +110,7 @@ void ViewerPluginExternalConfigureWidget::slotModifyScript()
{
QListWidgetItem *item = mListExternal->currentItem();
if (item) {
-
+ ViewerPluginExternalScriptItem *scriptItem = static_cast<ViewerPluginExternalScriptItem *>(item);
}
}
@@ -91,7 +118,7 @@ void ViewerPluginExternalConfigureWidget::slotAddScript()
{
QListWidgetItem *item = mListExternal->currentItem();
if (item) {
-
+ ViewerPluginExternalScriptItem *scriptItem = static_cast<ViewerPluginExternalScriptItem *>(item);
}
}
@@ -108,12 +135,8 @@ void ViewerPluginExternalConfigureWidget::load()
void ViewerPluginExternalConfigureWidget::fillScriptInfo(const QVector<ViewerPluginExternalScriptInfo> &scriptInfos)
{
Q_FOREACH (const ViewerPluginExternalScriptInfo &script, scriptInfos) {
- QListWidgetItem *item = new QListWidgetItem(mListExternal);
- item->setData(ReadOnly, script.isReadOnly());
- item->setData(FileName, script.fileName());
- item->setData(CommandName, script.commandLine());
- item->setData(Executable, script.executable());
- item->setData(IconName, script.icon());
+ ViewerPluginExternalScriptItem *item = new ViewerPluginExternalScriptItem(mListExternal);
+ item->setScriptInfo(script);
}
}
@@ -131,7 +154,8 @@ void ViewerPluginExternalConfigureWidget::updateButtons()
{
QListWidgetItem *item = mListExternal->currentItem();
if (item) {
- const bool isReadOnly = item->data(ReadOnly).toBool();
+ ViewerPluginExternalScriptItem *scriptItem = static_cast<ViewerPluginExternalScriptItem *>(item);
+ const bool isReadOnly = scriptItem->scriptInfo().isReadOnly();
mRemoveScript->setEnabled(!isReadOnly);
mModifyScript->setEnabled(!isReadOnly);
} else {
@@ -139,3 +163,4 @@ void ViewerPluginExternalConfigureWidget::updateButtons()
mModifyScript->setEnabled(false);
}
}
+
diff --git a/plugins/messageviewerplugins/externalscriptplugin/configuredialog/viewerpluginexternalconfigurewidget.h b/plugins/messageviewerplugins/externalscriptplugin/configuredialog/viewerpluginexternalconfigurewidget.h
index 657a10c..a96a481 100644
--- a/plugins/messageviewerplugins/externalscriptplugin/configuredialog/viewerpluginexternalconfigurewidget.h
+++ b/plugins/messageviewerplugins/externalscriptplugin/configuredialog/viewerpluginexternalconfigurewidget.h
@@ -34,14 +34,6 @@ public:
void save();
void reset();
private:
- enum ItemScriptInfo {
- FileName = Qt::UserRole + 1,
- ReadOnly = Qt::UserRole + 2,
- CommandName = Qt::UserRole + 3,
- Executable = Qt::UserRole + 4,
- IconName = Qt::UserRole + 5,
- };
-
void fillScriptInfo(const QVector<ViewerPluginExternalScriptInfo> &scriptInfos);
void slotAddScript();
void slotModifyScript();