summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorRoland Knall <rknall@gmail.com>2017-03-03 11:53:39 +0100
committerRoland Knall <rknall@gmail.com>2017-03-03 15:13:13 +0000
commit85aa48cef2d6334a05963bf36711d47eceb3d209 (patch)
treea99443e60b1c7d8367e09e1d0a63baff8fbb7871 /plugins
parent9eca0390e70bf72573189c6f4d20d352ace8b814 (diff)
downloadwireshark-85aa48cef2d6334a05963bf36711d47eceb3d209.tar.gz
pluginIf: Add/Remove single entries from selector
Allow to add and remove single items from a selector list and also fixing the selection of items in a selector list Change-Id: I0c69ea97db6ca1a6932939f0df9049c6fb720f77 Reviewed-on: https://code.wireshark.org/review/20363 Petri-Dish: Roland Knall <rknall@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Roland Knall <rknall@gmail.com>
Diffstat (limited to 'plugins')
-rw-r--r--plugins/pluginifdemo/ui/pluginifdemo_main.cpp56
-rw-r--r--plugins/pluginifdemo/ui/pluginifdemo_main.h1
-rw-r--r--plugins/pluginifdemo/ui/pluginifdemo_main.ui27
3 files changed, 84 insertions, 0 deletions
diff --git a/plugins/pluginifdemo/ui/pluginifdemo_main.cpp b/plugins/pluginifdemo/ui/pluginifdemo_main.cpp
index 33f88356e1..58e9542e23 100644
--- a/plugins/pluginifdemo/ui/pluginifdemo_main.cpp
+++ b/plugins/pluginifdemo/ui/pluginifdemo_main.cpp
@@ -244,6 +244,21 @@ void PluginIFDemo_Main::on_btnAddItem_clicked()
return;
listModel->appendRow(new QStandardItem(content));
+
+ if ( ui->chkAddRemoveImmediate->checkState() == Qt::Checked )
+ {
+ ext_toolbar_t * item = ext_toolbar_entry_by_label(_toolbar, ui->cmbElements->currentText().toStdString().c_str());
+ if ( ! item || item->item_type != EXT_TOOLBAR_SELECTOR )
+ return;
+
+ bool silent = ui->chkSilent->checkState() == Qt::Checked ? true : false;
+
+ gchar * value = g_strdup(ui->txtNewItemValue->text().toUtf8().constData());
+ gchar * display = g_strdup(ui->txtNewItemDisplay->text().toUtf8().constData());
+ ext_toolbar_update_data_add_entry(item, display, value, silent);
+ g_free(value);
+ g_free(display);
+ }
}
void PluginIFDemo_Main::on_btnRemoveItem_clicked()
@@ -255,7 +270,28 @@ void PluginIFDemo_Main::on_btnRemoveItem_clicked()
QModelIndexList selIndeces = selModel-> selectedIndexes();
foreach(QModelIndex idx, selIndeces)
+ {
+ if ( ui->chkAddRemoveImmediate->checkState() == Qt::Checked )
+ {
+ ext_toolbar_t * item = ext_toolbar_entry_by_label(_toolbar, ui->cmbElements->currentText().toStdString().c_str());
+ if ( ! item || item->item_type != EXT_TOOLBAR_SELECTOR )
+ return;
+
+ bool silent = ui->chkSilent->checkState() == Qt::Checked ? true : false;
+
+ QString content = listModel->data(idx).toString();
+ int pos = content.indexOf(":");
+
+ gchar * value = g_strdup(content.left(pos).toUtf8().constData() );
+ /* -2 because removal of : and space */
+ gchar * display = g_strdup(content.right(content.size() - pos - 2).toUtf8().constData());
+ ext_toolbar_update_data_remove_entry(item, display, value, silent);
+ g_free(value);
+ g_free(display);
+ }
+
listModel->removeRow(idx.row());
+ }
}
void PluginIFDemo_Main::on_btnSendList_clicked()
@@ -306,6 +342,26 @@ void PluginIFDemo_Main::on_btnSendUpdateItem_clicked()
(gpointer) displayValue.toStdString().c_str(), (gpointer) cmbIndexText.toStdString().c_str(), silent );
}
+void PluginIFDemo_Main::on_lstItems_clicked(const QModelIndex &idx)
+{
+ if ( ! _toolbar || ! idx.isValid() )
+ return;
+
+ ext_toolbar_t * item = ext_toolbar_entry_by_label(_toolbar, ui->cmbElements->currentText().toStdString().c_str());
+ if ( ! item || item->item_type != EXT_TOOLBAR_SELECTOR )
+ return;
+
+ bool silent = ui->chkSilent->checkState() == Qt::Checked ? true : false;
+
+ QString content = listModel->data(listModel->index(idx.row(), 0)).toString();
+ int pos = content.indexOf(":");
+
+ gchar * idxData = g_strdup(content.left(pos).toUtf8().constData() );
+
+ ext_toolbar_update_value(item, idxData, silent);
+ g_free(idxData);
+
+}
/*
* Editor modelines
*
diff --git a/plugins/pluginifdemo/ui/pluginifdemo_main.h b/plugins/pluginifdemo/ui/pluginifdemo_main.h
index 439712e556..2138301fd0 100644
--- a/plugins/pluginifdemo/ui/pluginifdemo_main.h
+++ b/plugins/pluginifdemo/ui/pluginifdemo_main.h
@@ -101,6 +101,7 @@ private slots:
void on_btnRemoveItem_clicked();
void on_btnSendList_clicked();
void on_cmbElements_currentTextChanged(const QString & newText);
+ void on_lstItems_clicked(const QModelIndex &idx);
void logChanged(QString message);
void closeDialog();
diff --git a/plugins/pluginifdemo/ui/pluginifdemo_main.ui b/plugins/pluginifdemo/ui/pluginifdemo_main.ui
index 0871ee8e81..ec71781e93 100644
--- a/plugins/pluginifdemo/ui/pluginifdemo_main.ui
+++ b/plugins/pluginifdemo/ui/pluginifdemo_main.ui
@@ -217,6 +217,33 @@
</layout>
</item>
<item>
+ <widget class="QCheckBox" name="chkAddRemoveImmediate">
+ <property name="text">
+ <string>Add and remove will immediately be send to interface</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="chkSendSelect">
+ <property name="text">
+ <string>Update interface with selection</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="Line" name="line_2">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </widget>
+ </item>
+ <item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QLabel" name="label_5">