Qt: change obsolete qVariantFromValue into QVariant::fromValue.
authorDario Lombardo <lomato@gmail.com>
Mon, 15 Jan 2018 07:53:55 +0000 (08:53 +0100)
committerAnders Broman <a.broman58@gmail.com>
Mon, 15 Jan 2018 12:20:32 +0000 (12:20 +0000)
Change-Id: I767b06c0e316347cdb28b769f1032e6d44cba45b
Reviewed-on: https://code.wireshark.org/review/25321
Petri-Dish: Roland Knall <rknall@gmail.com>
Tested-by: Roland Knall <rknall@gmail.com>
Reviewed-by: Roland Knall <rknall@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
17 files changed:
tools/checkAPIs.pl
ui/qt/bluetooth_att_server_attributes_dialog.cpp
ui/qt/byte_view_tab.cpp
ui/qt/capture_interfaces_dialog.cpp
ui/qt/conversation_dialog.cpp
ui/qt/display_filter_expression_dialog.cpp
ui/qt/interface_frame.cpp
ui/qt/main_window.cpp
ui/qt/models/astringlist_list_model.cpp
ui/qt/models/interface_tree_model.cpp
ui/qt/models/numeric_value_chooser_delegate.cpp
ui/qt/packet_list.cpp
ui/qt/proto_tree.cpp
ui/qt/traffic_table_dialog.cpp
ui/qt/utils/variant_pointer.h
ui/qt/widgets/byte_view_text.cpp
ui/qt/widgets/drag_drop_toolbar.cpp

index ca326d4474ae1ea3f20b30c09f1bd2a77b3d28ab..a523b4235c52a39153d79fcc6d1c5a022e7940ec 100755 (executable)
@@ -276,6 +276,7 @@ my %APIs = (
                 'G_WIN32_DLLMAIN_FOR_DLL_NAME',
                 'g_win32_get_package_installation_directory',
                 'g_win32_get_package_installation_subdirectory',
+                'qVariantFromValue'
                 ] },
 
         # APIs that make the program exit. Dissectors shouldn't call these
index daef9d5fecc9518c5d4e3e4d96746c82d940b696..0ddddffefc921a1f2778d5fd1090c291f0a571e0 100644 (file)
@@ -299,7 +299,7 @@ gboolean BluetoothAttServerAttributesDialog::tapPacket(void *tapinfo_ptr, packet
     item->setText(column_number_handle, handle);
     item->setText(column_number_uuid, uuid);
     item->setText(column_number_uuid_name,  uuid_name);
-    item->setData(0, Qt::UserRole, qVariantFromValue(pinfo->num));
+    item->setData(0, Qt::UserRole, QVariant::fromValue(pinfo->num));
 
     for (int i = 0; i < dialog->ui->tableTreeWidget->columnCount(); i++) {
         dialog->ui->tableTreeWidget->resizeColumnToContents(i);
index dd5e08153193389622358283a88166eff7b56f99..f8ef447ca9cf9f2fbd56b656dbff71a7b3e3ad72 100644 (file)
@@ -113,7 +113,7 @@ void ByteViewTab::addTab(const char *name, tvbuff_t *tvb) {
     }
 
     int idx = QTabWidget::addTab(byte_view_text, name);
-    byte_view_text->setProperty("tab_index", qVariantFromValue(idx));
+    byte_view_text->setProperty("tab_index", QVariant::fromValue(idx));
 
     QTabWidget::setTabToolTip(idx, name);
 }
index 6e4939fb08f4fdaac1cfe201f337ce4272e9d24c..456cb2701ff93c95bcdc428f8a6d3c43a4e9fcc6 100644 (file)
@@ -668,7 +668,7 @@ void CaptureInterfacesDialog::updateInterfaces()
             InterfaceTreeWidgetItem *ti = new InterfaceTreeWidgetItem(ui->interfaceTree);
             ti->setFlags(ti->flags() | Qt::ItemIsEditable);
             ti->setData(col_interface_, Qt::UserRole, QString(device->name));
-            ti->setData(col_traffic_, Qt::UserRole, qVariantFromValue(ti->points));
+            ti->setData(col_traffic_, Qt::UserRole, QVariant::fromValue(ti->points));
 
             ti->setText(col_interface_, device->display_name);
             if (device->no_addresses > 0) {
@@ -789,7 +789,7 @@ void CaptureInterfacesDialog::updateStatistics(void)
             }
             QList<int> points = ti->data(col_traffic_, Qt::UserRole).value<QList<int> >();
             points.append(device->packet_diff);
-            ti->setData(col_traffic_, Qt::UserRole, qVariantFromValue(points));
+            ti->setData(col_traffic_, Qt::UserRole, QVariant::fromValue(points));
         }
     }
     connect(ui->interfaceTree, SIGNAL(itemChanged(QTreeWidgetItem*,int)), this, SLOT(interfaceItemChanged(QTreeWidgetItem*,int)));
@@ -1141,7 +1141,7 @@ QVariant InterfaceTreeWidgetItem::data(int column, int role) const
 {
     // See setData for the special col_traffic_ treatment.
     if (column == col_traffic_ && role == Qt::UserRole) {
-        return qVariantFromValue(points);
+        return QVariant::fromValue(points);
     }
 
     return QTreeWidgetItem::data(column, role);
index 1ab3cbcf02a6c24a26a4476dcd48c4a190ac8a7b..e4456d49cefd2b8512cab231912489ecbc3b0030 100644 (file)
@@ -438,7 +438,7 @@ public:
             if (column == CONV_COLUMN_DURATION) {
                 span_px.start -= start_px;
             }
-            return qVariantFromValue(span_px);
+            return QVariant::fromValue(span_px);
 
             break;
         }
index cb0d75bfa594144697984e392743664c28795868..16031b6ef8d046050392526269a84ac868fdf918 100644 (file)
@@ -129,7 +129,7 @@ void DisplayFilterExpressionDialog::fillTree()
                 .arg(proto_get_protocol_short_name(protocol))
                 .arg(proto_get_protocol_long_name(protocol));
         proto_ti->setText(0, label);
-        proto_ti->setData(0, Qt::UserRole, qVariantFromValue(proto_id));
+        proto_ti->setData(0, Qt::UserRole, QVariant::fromValue(proto_id));
         proto_list << proto_ti;
     }
 
index 92a10f7efa72ebdcb6098d737bf8d191735a985b..078c199bb1c16057784772f88c5a8adfd4b06e85 100644 (file)
@@ -123,7 +123,7 @@ QMenu * InterfaceFrame::getSelectionMenu()
         if ( typesDisplayed.contains(ifType) )
         {
             QAction *endp_action = new QAction(it.value(), this);
-            endp_action->setData(qVariantFromValue(ifType));
+            endp_action->setData(QVariant::fromValue(ifType));
             endp_action->setCheckable(true);
             endp_action->setChecked(proxyModel.isInterfaceTypeShown(ifType));
             connect(endp_action, SIGNAL(triggered()), this, SLOT(triggeredIfTypeButton()));
index 4e6ef646e9ef187ee534b4dd5e1d389c06845286..bb24456955afb43183c35711329928ffded4a88c 100644 (file)
@@ -786,7 +786,7 @@ void MainWindow::addInterfaceToolbar(const iface_toolbar *toolbar_entry)
     toolbar->setMovable(false);
     toolbar->setVisible(visible);
 
-    action->setData(qVariantFromValue(toolbar));
+    action->setData(QVariant::fromValue(toolbar));
 
     addToolBar(Qt::TopToolBarArea, toolbar);
     insertToolBarBreak(toolbar);
@@ -1943,7 +1943,7 @@ void MainWindow::initShowHideMainWidgets()
     shmw_actions[main_ui_->actionViewPacketBytes] = byte_view_tab_;
 
     foreach (QAction *shmwa, shmw_actions.keys()) {
-        shmwa->setData(qVariantFromValue(shmw_actions[shmwa]));
+        shmwa->setData(QVariant::fromValue(shmw_actions[shmwa]));
         show_hide_actions_->addAction(shmwa);
         showHideMainWidgets(shmwa);
     }
@@ -1977,7 +1977,7 @@ void MainWindow::initTimeDisplayFormatMenu()
     td_actions[main_ui_->actionViewTimeDisplayFormatUTCTimeOfDay] = TS_UTC;
 
     foreach (QAction* tda, td_actions.keys()) {
-        tda->setData(qVariantFromValue(td_actions[tda]));
+        tda->setData(QVariant::fromValue(td_actions[tda]));
         time_display_actions_->addAction(tda);
     }
 
@@ -2001,7 +2001,7 @@ void MainWindow::initTimePrecisionFormatMenu()
     tp_actions[main_ui_->actionViewTimeDisplayFormatPrecisionNanoseconds] = TS_PREC_FIXED_NSEC;
 
     foreach (QAction* tpa, tp_actions.keys()) {
-        tpa->setData(qVariantFromValue(tp_actions[tpa]));
+        tpa->setData(QVariant::fromValue(tp_actions[tpa]));
         time_precision_actions_->addAction(tpa);
     }
 
index 87c9cf84aad89d302109a06185358cd418d03b1d..21edc03ef1e1c84043393339a69dd62000d1d635 100644 (file)
@@ -53,7 +53,7 @@ QVariant AStringListListModel::headerData(int section, Qt::Orientation orientati
 
     QStringList columns = headerColumns();
     if ( role == Qt::DisplayRole && section < columns.count() )
-        return qVariantFromValue(columns[section]);
+        return QVariant::fromValue(columns[section]);
 
     return QVariant();
 }
@@ -68,7 +68,7 @@ QVariant AStringListListModel::data(const QModelIndex &index, int role) const
         QStringList data = modelData.at(index.row());
 
         if ( index.column() < columnCount() )
-            return qVariantFromValue(data.at(index.column()));
+            return QVariant::fromValue(data.at(index.column()));
     }
 
     return QVariant();
index bd96411e6d493b14fa83e6125995ed8f6c8bcf41..8bcf4e63c99216ee7f144964b3153f0330478a82 100644 (file)
@@ -211,7 +211,7 @@ QVariant InterfaceTreeModel::data(const QModelIndex &index, int role) const
             if ( col == IFTREE_COL_STATS )
             {
                 if ( points.contains(device->name) )
-                    return qVariantFromValue(points[device->name]);
+                    return QVariant::fromValue(points[device->name]);
             }
             else if ( col == IFTREE_COL_HIDDEN )
             {
index cdcd41f35984c0d718ae9fb5e0929dd2925e0dc1..7966915b2ffd801b92199ffc0fbcdee6138aefc4 100644 (file)
@@ -45,7 +45,7 @@ void NumericValueChooserDelegate::setMinMaxRange(int min, int max)
     _max = qMax(min, max);
     /* ensure, that the default value is within the new min<->max */
     _default = qMin(_max, qMax(_min, _default));
-    _defReturn = qVariantFromValue(_default);
+    _defReturn = QVariant::fromValue(_default);
 }
 
 void NumericValueChooserDelegate::setDefaultValue(int defValue, QVariant defaultReturn)
@@ -91,7 +91,7 @@ void NumericValueChooserDelegate::setModelData(QWidget *editor, QAbstractItemMod
 {
     if ( index.isValid() ) {
         QSpinBox * spinBox = qobject_cast<QSpinBox *>(editor);
-        model->setData(index, _default == spinBox->value() ? _defReturn : qVariantFromValue(spinBox->value()));
+        model->setData(index, _default == spinBox->value() ? _defReturn : QVariant::fromValue(spinBox->value()));
     } else {
         QStyledItemDelegate::setModelData(editor, model, index);
     }
index 891ff4585a329c34aa36d8b581a657b337290182..02f69bbbea9b03d58771a7bf81f6e898dfd02f3d 100644 (file)
@@ -547,7 +547,7 @@ void PacketList::contextMenuEvent(QContextMenuEvent *event)
     action = window()->findChild<QAction *>("actionViewShowPacketInNewWindow");
     ctx_menu_.addAction(action);
 
-    decode_as_->setData(qVariantFromValue(true));
+    decode_as_->setData(QVariant::fromValue(true));
     ctx_column_ = columnAt(event->x());
 
     // Set menu sensitivity for the current column and set action data.
@@ -685,7 +685,7 @@ void PacketList::initHeaderContextMenu()
     header_actions_[caRemoveColumn] = header_ctx_menu_.addAction(tr("Remove This Column"));
 
     foreach (ColumnActions ca, header_actions_.keys()) {
-        header_actions_[ca]->setData(qVariantFromValue(ca));
+        header_actions_[ca]->setData(QVariant::fromValue(ca));
         connect(header_actions_[ca], SIGNAL(triggered()), this, SLOT(headerMenuTriggered()));
     }
 
@@ -1335,7 +1335,7 @@ void PacketList::showHeaderMenu(QPoint pos)
         QAction *action = new QAction(get_column_title(i), &header_ctx_menu_);
         action->setCheckable(true);
         action->setChecked(get_column_visible(i));
-        action->setData(qVariantFromValue(i));
+        action->setData(QVariant::fromValue(i));
         connect(action, SIGNAL(triggered()), this, SLOT(columnVisibilityTriggered()));
         header_ctx_menu_.insertAction(show_hide_separator_, action);
         show_hide_actions_ << action;
index 902a52df2cc7507a4dfccf036b033b57ac3eb57f..9fdb182dc5761cb7232d2df6030e766d7408de3c 100644 (file)
@@ -181,7 +181,7 @@ void ProtoTree::contextMenuEvent(QContextMenuEvent *event)
 
     proto_prefs_menu_.setModule(finfo.moduleName());
 
-    decode_as_->setData(qVariantFromValue(true));
+    decode_as_->setData(QVariant::fromValue(true));
 
     // Set menu sensitivity and action data.
     emit fieldSelected(&finfo);
index 87b3bd92a8a9c93c68e590b2229886535790b58f..7d9326486198bb69104645bbe145207a588c7f93 100644 (file)
@@ -132,7 +132,7 @@ gboolean TrafficTableDialog::fillTypeMenuFunc(const void *key, void *value, void
     int proto_id = get_conversation_proto_id(ct);
 
     QAction *endp_action = new QAction(title, data->dialog_);
-    endp_action->setData(qVariantFromValue(proto_id));
+    endp_action->setData(QVariant::fromValue(proto_id));
     endp_action->setCheckable(true);
     endp_action->setChecked(data->enabled_protos_.contains(proto_id));
     data->dialog_->connect(endp_action, SIGNAL(triggered()), data->dialog_, SLOT(toggleTable()));
index 7069fc3db1720f929fa90d8d2e9b6caaffd70be2..9ebf1e7832d3ca5b892869dfbe05bab6fa00c98c 100644 (file)
@@ -39,7 +39,7 @@ public:
 
     static QVariant asQVariant(T* ptr)
     {
-        return qVariantFromValue((void *) ptr);
+        return QVariant::fromValue((void *) ptr);
     }
 };
 
index 232ee46f8a4ca791c60c9b1598ab3106bc2372cc..d38dd62bc8f859ca1a669969926c521917f1a7e1 100644 (file)
@@ -84,13 +84,13 @@ void ByteViewText::createContextMenu()
 
     QActionGroup * format_actions = new QActionGroup(this);
     action = format_actions->addAction(tr("Show bytes as hexadecimal"));
-    action->setData(qVariantFromValue(BYTES_HEX));
+    action->setData(QVariant::fromValue(BYTES_HEX));
     action->setCheckable(true);
     if (recent.gui_bytes_view == BYTES_HEX) {
         action->setChecked(true);
     }
     action = format_actions->addAction(tr(UTF8_HORIZONTAL_ELLIPSIS "as bits"));
-    action->setData(qVariantFromValue(BYTES_BITS));
+    action->setData(QVariant::fromValue(BYTES_BITS));
     action->setCheckable(true);
     if (recent.gui_bytes_view == BYTES_BITS) {
         action->setChecked(true);
@@ -103,19 +103,19 @@ void ByteViewText::createContextMenu()
 
     QActionGroup * encoding_actions = new QActionGroup(this);
     action = encoding_actions->addAction(tr("Show text based on packet"));
-    action->setData(qVariantFromValue(BYTES_ENC_FROM_PACKET));
+    action->setData(QVariant::fromValue(BYTES_ENC_FROM_PACKET));
     action->setCheckable(true);
     if (recent.gui_bytes_encoding == BYTES_ENC_FROM_PACKET) {
         action->setChecked(true);
     }
     action = encoding_actions->addAction(tr(UTF8_HORIZONTAL_ELLIPSIS "as ASCII"));
-    action->setData(qVariantFromValue(BYTES_ENC_ASCII));
+    action->setData(QVariant::fromValue(BYTES_ENC_ASCII));
     action->setCheckable(true);
     if (recent.gui_bytes_encoding == BYTES_ENC_ASCII) {
         action->setChecked(true);
     }
     action = encoding_actions->addAction(tr(UTF8_HORIZONTAL_ELLIPSIS "as EBCDIC"));
-    action->setData(qVariantFromValue(BYTES_ENC_EBCDIC));
+    action->setData(QVariant::fromValue(BYTES_ENC_EBCDIC));
     action->setCheckable(true);
     if (recent.gui_bytes_encoding == BYTES_ENC_EBCDIC) {
         action->setChecked(true);
index 0e4d174d2f877910a4dd0440257399ba9892561c..647236def165d056d80871fc9ddb2696fc482665 100644 (file)
@@ -67,7 +67,7 @@ void DragDropToolBar::childEvent(QChildEvent * event)
                 childCounter = 0;
 
             ((QWidget *)event->child())->installEventFilter(this);
-            event->child()->setProperty(drag_drop_toolbar_action_, qVariantFromValue(childCounter));
+            event->child()->setProperty(drag_drop_toolbar_action_, QVariant::fromValue(childCounter));
             childCounter++;
         }
     }