diff options
author | Michael Mann <mmann78@netscape.net> | 2018-01-12 12:50:52 -0500 |
---|---|---|
committer | Michael Mann <mmann78@netscape.net> | 2018-01-14 22:19:12 +0000 |
commit | 6b4d1cf931c31edcd6dc27a4c20fb90a76bf122f (patch) | |
tree | f6fd293fae13a0eaa03ac815bec3d1ceac53ccbf /ui/qt/models | |
parent | 9cc00c562369fe0b9149eb2aeee090cf52167285 (diff) |
InterfaceFrame: don't use pointers for models
Change-Id: I6d41ba89006abb8f8e703f6d703370169062f7e9
Reviewed-on: https://code.wireshark.org/review/25285
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot
Reviewed-by: Roland Knall <rknall@gmail.com>
Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'ui/qt/models')
-rw-r--r-- | ui/qt/models/info_proxy_model.cpp | 34 | ||||
-rw-r--r-- | ui/qt/models/info_proxy_model.h | 4 |
2 files changed, 35 insertions, 3 deletions
diff --git a/ui/qt/models/info_proxy_model.cpp b/ui/qt/models/info_proxy_model.cpp index 4d61434687..197cc9e0d8 100644 --- a/ui/qt/models/info_proxy_model.cpp +++ b/ui/qt/models/info_proxy_model.cpp @@ -14,9 +14,10 @@ #include <QFont> -InfoProxyModel::InfoProxyModel(int column, QObject * parent) : QIdentityProxyModel (parent) +InfoProxyModel::InfoProxyModel(QObject * parent) + : QIdentityProxyModel(parent), + column_(-1) { - column_ = column; } InfoProxyModel::~InfoProxyModel() @@ -98,6 +99,35 @@ QModelIndex InfoProxyModel::mapFromSource(const QModelIndex &fromIndex) const return QIdentityProxyModel::mapFromSource(fromIndex); } +void InfoProxyModel::setColumn(int column) +{ + int old_column = column_; + column_ = column; + +#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) + QVector<int> roles; + roles << Qt::DisplayRole; +#endif + + if (old_column >= 0) { + //Notify old column has changed + emit dataChanged(index(0, old_column), index(rowCount(), old_column) +#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) + , roles +#endif + ); + } + + if (column_ >= 0) { + //Notify new column has changed + emit dataChanged(index(0, column_), index(rowCount(), column_) +#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) + , roles +#endif + ); + } +} + /* * Editor modelines * diff --git a/ui/qt/models/info_proxy_model.h b/ui/qt/models/info_proxy_model.h index 72b36f85ee..9574882f5a 100644 --- a/ui/qt/models/info_proxy_model.h +++ b/ui/qt/models/info_proxy_model.h @@ -21,7 +21,7 @@ class InfoProxyModel : public QIdentityProxyModel Q_OBJECT public: - explicit InfoProxyModel(int column, QObject * parent); + explicit InfoProxyModel(QObject * parent = 0); ~InfoProxyModel(); virtual int rowCount(const QModelIndex &parent = QModelIndex()) const; @@ -36,6 +36,8 @@ public: void appendInfo(QString info); void clearInfos(); + void setColumn(int column); + private: int column_; |