forked from osmocom/wireshark
Qt: Consolidate mimedata usage
Ensure, that all mimedata uses similar mimetypes and document the mimetypes being used throughout wireshark Change-Id: I7c02d0a5e12a823153640e600051abb95d58cdeb Reviewed-on: https://code.wireshark.org/review/34923 Petri-Dish: Roland Knall <rknall@gmail.com> Reviewed-by: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot Reviewed-by: Roland Knall <rknall@gmail.com>
This commit is contained in:
parent
d1128e58c4
commit
accd563aaf
|
@ -1363,6 +1363,73 @@ If everything went well, you will now find something like:
|
|||
_WiresharkPortable_{wireshark-version}.paf.exe_ in
|
||||
the _packaging/portableapps_ directory.
|
||||
|
||||
|
||||
[[ChSrcVersioning]]
|
||||
|
||||
==== Packaging Guidelines
|
||||
|
||||
The following guidelines should be followed by anyone creating and
|
||||
distributing third-party Wireshark packages or redistributing official
|
||||
Wireshark packages.
|
||||
|
||||
|
||||
[[ChSrcMimeTypes]]
|
||||
|
||||
=== Mime Types
|
||||
|
||||
Wireshark uses various mime-types for dragging dropping as well as file formats.
|
||||
This chapter gives an overview over all the mimetypes being used, as well as the
|
||||
data format in which data has to be provided for each individual mimetype.
|
||||
|
||||
==== Coloring Rules
|
||||
|
||||
**MimeType**: application/vnd.wireshark.coloringrules
|
||||
|
||||
Coloring Rules are being used for dragging and dropping color rules inside the
|
||||
coloring rules dialog.
|
||||
|
||||
[cols="1,3,1", options="header"]
|
||||
|===
|
||||
|Name
|
||||
|Description
|
||||
|Qt/C++ Type
|
||||
|
||||
|disabled
|
||||
|Is the coloring rule enabled/disabled
|
||||
|bool
|
||||
|
||||
|name
|
||||
|Name to be displayed for it
|
||||
|QString
|
||||
|
||||
|filter
|
||||
|The display filter
|
||||
|QString
|
||||
|
||||
|foreground
|
||||
|Foreground Color
|
||||
|QColor
|
||||
|
||||
|background
|
||||
|Background Color
|
||||
|QColor
|
||||
|===
|
||||
|
||||
==== Filter List
|
||||
|
||||
**MimeType**: application/vnd.wireshark.filterlist
|
||||
|
||||
*_Internal Use only_* - used on the filter list for moving entries within the
|
||||
list
|
||||
|
||||
==== Column List
|
||||
|
||||
**MimeType**: application/vnd.wireshark.columnlist
|
||||
|
||||
*_Internal Use only_* - used on the column list for moving entries within the
|
||||
list
|
||||
|
||||
|
||||
// End of WSDG Chapter Sources
|
||||
|
||||
// vim: set syntax=asciidoc:
|
||||
|
|
|
@ -18,13 +18,10 @@
|
|||
#include <ui/qt/utils/color_utils.h>
|
||||
#include <ui/qt/utils/qt_ui_utils.h>
|
||||
#include <ui/qt/utils/variant_pointer.h>
|
||||
#include <ui/qt/utils/wireshark_mime_data.h>
|
||||
|
||||
#include <QMimeData>
|
||||
|
||||
|
||||
static const QString new_rule_name_ = QObject::tr("New coloring rule");
|
||||
static const QString color_rule_mime_type_ = "application/x-wireshark-coloring-rules";
|
||||
|
||||
ColoringRuleItem::ColoringRuleItem(bool disabled, QString name, QString filter, QColor foreground, QColor background, ColoringRuleItem* parent)
|
||||
: ModelHelperTreeItem<ColoringRuleItem>(parent),
|
||||
disabled_(disabled),
|
||||
|
@ -129,7 +126,7 @@ void ColoringRulesModel::addColor(bool disabled, QString filter, QColor foregrou
|
|||
{
|
||||
//add rule to top of the list
|
||||
beginInsertRows(QModelIndex(), 0, 0);
|
||||
ColoringRuleItem* item = new ColoringRuleItem(disabled, new_rule_name_, filter, foreground, background, root_);
|
||||
ColoringRuleItem* item = new ColoringRuleItem(disabled, tr("New coloring rule"), filter, foreground, background, root_);
|
||||
root_->prependChild(item);
|
||||
endInsertRows();
|
||||
}
|
||||
|
@ -190,7 +187,7 @@ bool ColoringRulesModel::insertRows(int row, int count, const QModelIndex& paren
|
|||
|
||||
for (int i = row; i < row + count; i++)
|
||||
{
|
||||
ColoringRuleItem* item = new ColoringRuleItem(true, new_rule_name_, "", defaultForeground_, defaultBackground_, root_);
|
||||
ColoringRuleItem* item = new ColoringRuleItem(true, tr("New coloring rule"), "", defaultForeground_, defaultBackground_, root_);
|
||||
root_->insertChild(i, item);
|
||||
}
|
||||
|
||||
|
@ -391,10 +388,7 @@ Qt::DropActions ColoringRulesModel::supportedDropActions() const
|
|||
|
||||
QStringList ColoringRulesModel::mimeTypes() const
|
||||
{
|
||||
//Just use plain text to transport data
|
||||
QStringList types;
|
||||
types << color_rule_mime_type_;
|
||||
return types;
|
||||
return QStringList() << WiresharkMimeData::ColoringRulesMimeType;
|
||||
}
|
||||
|
||||
QMimeData* ColoringRulesModel::mimeData(const QModelIndexList &indexes) const
|
||||
|
@ -418,7 +412,7 @@ QMimeData* ColoringRulesModel::mimeData(const QModelIndexList &indexes) const
|
|||
}
|
||||
}
|
||||
|
||||
mimeData->setData(color_rule_mime_type_, encodedData);
|
||||
mimeData->setData(WiresharkMimeData::ColoringRulesMimeType, encodedData);
|
||||
return mimeData;
|
||||
}
|
||||
|
||||
|
@ -430,10 +424,7 @@ bool ColoringRulesModel::dropMimeData(const QMimeData *data, Qt::DropAction acti
|
|||
if (action == Qt::IgnoreAction)
|
||||
return true;
|
||||
|
||||
if (!data->hasFormat(color_rule_mime_type_))
|
||||
return false;
|
||||
|
||||
if (column > 0)
|
||||
if (!data->hasFormat(WiresharkMimeData::ColoringRulesMimeType) || column > 0)
|
||||
return false;
|
||||
|
||||
int beginRow;
|
||||
|
@ -453,7 +444,7 @@ bool ColoringRulesModel::dropMimeData(const QMimeData *data, Qt::DropAction acti
|
|||
ColoringRuleItem* item;
|
||||
QList<QVariant> rules;
|
||||
|
||||
QByteArray encodedData = data->data(color_rule_mime_type_);
|
||||
QByteArray encodedData = data->data(WiresharkMimeData::ColoringRulesMimeType);
|
||||
QDataStream stream(&encodedData, QIODevice::ReadOnly);
|
||||
int rows = 0;
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include <ui/qt/utils/qt_ui_utils.h>
|
||||
#include <ui/qt/widgets/field_filter_edit.h>
|
||||
#include <ui/qt/widgets/syntax_line_edit.h>
|
||||
#include <ui/qt/utils/wireshark_mime_data.h>
|
||||
|
||||
#include <glib.h>
|
||||
#include <epan/column-info.h>
|
||||
|
@ -319,6 +320,11 @@ Qt::ItemFlags ColumnListModel::flags(const QModelIndex &index) const
|
|||
return Qt::ItemIsDropEnabled | defaultFlags;
|
||||
}
|
||||
|
||||
QStringList ColumnListModel::mimeTypes() const
|
||||
{
|
||||
return QStringList() << WiresharkMimeData::ColumnListMimeType;
|
||||
}
|
||||
|
||||
QMimeData *ColumnListModel::mimeData(const QModelIndexList &indexes) const
|
||||
{
|
||||
QMimeData *mimeData = new QMimeData;
|
||||
|
@ -327,14 +333,14 @@ QMimeData *ColumnListModel::mimeData(const QModelIndexList &indexes) const
|
|||
if ( indexes.count() > 0 )
|
||||
row = indexes.at(0).row();
|
||||
|
||||
mimeData->setText(QString::number(row));
|
||||
mimeData->setData(WiresharkMimeData::ColumnListMimeType, QString::number(row).toUtf8());
|
||||
return mimeData;
|
||||
}
|
||||
|
||||
bool ColumnListModel::canDropMimeData(const QMimeData *data,
|
||||
Qt::DropAction /* action */, int /* row */, int /* column */, const QModelIndex &parent) const
|
||||
{
|
||||
if (parent.isValid() || data->text().isEmpty() )
|
||||
if (parent.isValid() || ! data->hasFormat(WiresharkMimeData::ColumnListMimeType) )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
@ -357,7 +363,7 @@ bool ColumnListModel::dropMimeData(const QMimeData *data,
|
|||
moveTo = rowCount(QModelIndex());
|
||||
|
||||
bool ok = false;
|
||||
int moveFrom = data->text().toInt(&ok);
|
||||
int moveFrom = QString(data->data(WiresharkMimeData::ColumnListMimeType)).toInt(&ok);
|
||||
if ( ! ok )
|
||||
return false;
|
||||
|
||||
|
|
|
@ -79,6 +79,7 @@ public:
|
|||
virtual int columnCount(const QModelIndex &parent = QModelIndex()) const;
|
||||
virtual Qt::ItemFlags flags(const QModelIndex &index) const;
|
||||
|
||||
virtual QStringList mimeTypes() const;
|
||||
virtual QMimeData *mimeData(const QModelIndexList &indexes) const;
|
||||
virtual Qt::DropActions supportedDropActions() const;
|
||||
virtual bool canDropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const;
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include <wsutil/filesystem.h>
|
||||
|
||||
#include <ui/qt/utils/qt_ui_utils.h>
|
||||
#include <ui/qt/utils/wireshark_mime_data.h>
|
||||
#include <ui/qt/models/filter_list_model.h>
|
||||
#include <ui/qt/models/profile_model.h>
|
||||
|
||||
|
@ -250,7 +251,7 @@ Qt::DropActions FilterListModel::supportedDropActions() const
|
|||
|
||||
QStringList FilterListModel::mimeTypes() const
|
||||
{
|
||||
return QStringList() << "application/vnd.row.list";
|
||||
return QStringList() << WiresharkMimeData::FilterListMimeType;
|
||||
}
|
||||
|
||||
QMimeData *FilterListModel::mimeData(const QModelIndexList &indexes) const
|
||||
|
@ -264,7 +265,7 @@ QMimeData *FilterListModel::mimeData(const QModelIndexList &indexes) const
|
|||
rows << QString::number(index.row());
|
||||
}
|
||||
|
||||
mimeData->setData("application/vnd.row.list", rows.join(",").toUtf8());
|
||||
mimeData->setData(WiresharkMimeData::FilterListMimeType, rows.join(",").toUtf8());
|
||||
return mimeData;
|
||||
}
|
||||
|
||||
|
@ -273,10 +274,10 @@ bool FilterListModel::dropMimeData(const QMimeData *data, Qt::DropAction action,
|
|||
if ( action != Qt::MoveAction )
|
||||
return true;
|
||||
|
||||
if ( ! data->hasFormat("application/vnd.row.list") )
|
||||
if ( ! data->hasFormat(WiresharkMimeData::FilterListMimeType) )
|
||||
return true;
|
||||
|
||||
QStringList rows = QString(data->data("application/vnd.row.list")).split(",");
|
||||
QStringList rows = QString(data->data(WiresharkMimeData::FilterListMimeType)).split(",");
|
||||
|
||||
int insertRow = parent.isValid() ? parent.row() : row;
|
||||
|
||||
|
|
|
@ -9,6 +9,10 @@
|
|||
|
||||
#include <utils/wireshark_mime_data.h>
|
||||
|
||||
const QString WiresharkMimeData::ColoringRulesMimeType = "application/vnd.wireshark.coloringrules";
|
||||
const QString WiresharkMimeData::ColumnListMimeType = "application/vnd.wireshark.columnlist";
|
||||
const QString WiresharkMimeData::FilterListMimeType = "application/vnd.wireshark.filterlist";
|
||||
|
||||
void WiresharkMimeData::allowPlainText()
|
||||
{
|
||||
setText(labelText());
|
||||
|
|
|
@ -16,6 +16,10 @@ class WiresharkMimeData: public QMimeData {
|
|||
public:
|
||||
virtual QString labelText() const = 0;
|
||||
virtual void allowPlainText();
|
||||
|
||||
static const QString ColoringRulesMimeType;
|
||||
static const QString ColumnListMimeType;
|
||||
static const QString FilterListMimeType;
|
||||
};
|
||||
|
||||
class DisplayFilterMimeData: public WiresharkMimeData {
|
||||
|
|
Loading…
Reference in New Issue