Qt: Convert our widgets and models to new-style signals & slots

Convert our remaining widget and model code to new-style signals and
slots.
This commit is contained in:
Gerald Combs 2022-12-04 14:21:39 -08:00
parent 0c1a10b02b
commit cb85a4b1a4
11 changed files with 21 additions and 18 deletions

View File

@ -236,7 +236,6 @@ private:
signals:
void setDissectedCaptureFile(capture_file *cf);
void displayFilterSuccess(bool success);
void closePacketDialogs();
void reloadFields();
void packetInfoChanged(struct _packet_info *pinfo);

View File

@ -52,6 +52,8 @@ public:
public slots:
void setDisplayFilter(QString filter, FilterAction::Action action, FilterAction::ActionType filterType);
virtual void filterPackets(QString, bool) = 0;
virtual void showPreferencesDialog(QString module_name) = 0;
void layoutPanes();
void applyRecentPaneGeometry();
@ -92,6 +94,7 @@ signals:
void fieldSelected(FieldInformation *);
void framesSelected(QList<int>);
void filterAction(QString filter, FilterAction::Action action, FilterAction::ActionType type);
void displayFilterSuccess(bool success);
};

View File

@ -704,7 +704,7 @@ void PacketListModel::dissectIdle(bool reset)
}
if (idle_dissection_row_ < physical_rows_.count()) {
QTimer::singleShot(0, this, SLOT(dissectIdle()));
QTimer::singleShot(0, this, [=]() { dissectIdle(); });
} else {
idle_dissection_timer_->invalidate();
}
@ -733,7 +733,7 @@ gint PacketListModel::appendPacket(frame_data *fdata)
if (new_visible_rows_.count() < 2) {
// This is the first queued packet. Schedule an insertion for
// the next UI update.
QTimer::singleShot(0, this, SLOT(flushVisibleRows()));
QTimer::singleShot(0, this, &PacketListModel::flushVisibleRows);
}
pos = static_cast<int>( visible_rows_.count() + new_visible_rows_.count() ) - 1;
}

View File

@ -119,7 +119,7 @@ public:
bool checkIfDeleted(int row) const;
bool checkDuplicate(const QModelIndex &index, bool isOriginalToDuplicate = false) const;
Q_SIGNALS:
signals:
void itemChanged(const QModelIndex &idx);
protected:

View File

@ -27,7 +27,7 @@ public:
void setFilename(QString filename);
Q_SIGNALS:
signals:
void copyProfile(QString filename);
private:

View File

@ -126,18 +126,19 @@ DisplayFilterEdit::DisplayFilterEdit(QWidget *parent, DisplayFilterEditType type
connect(mainApp, &MainApplication::appInitialized, this, &DisplayFilterEdit::updateBookmarkMenu);
connect(mainApp, &MainApplication::displayFilterListChanged, this, &DisplayFilterEdit::updateBookmarkMenu);
connect(mainApp, SIGNAL(preferencesChanged()), this, SLOT(checkFilter()));
connect(mainApp, &MainApplication::preferencesChanged, this, [=](){ checkFilter(); });
connect(mainApp, SIGNAL(appInitialized()), this, SLOT(connectToMainWindow()));
connect(mainApp, &MainApplication::appInitialized, this, &DisplayFilterEdit::connectToMainWindow);
}
void DisplayFilterEdit::connectToMainWindow()
{
connect(this, SIGNAL(filterPackets(QString, bool)), mainApp->mainWindow(), SLOT(filterPackets(QString, bool)));
connect(this, SIGNAL(showPreferencesDialog(QString)),
mainApp->mainWindow(), SLOT(showPreferencesDialog(QString)));
connect(mainApp->mainWindow(), SIGNAL(displayFilterSuccess(bool)),
this, SLOT(displayFilterSuccess(bool)));
connect(this, &DisplayFilterEdit::filterPackets, qobject_cast<MainWindow *>(mainApp->mainWindow()),
&MainWindow::filterPackets);
connect(this, &DisplayFilterEdit::showPreferencesDialog,
qobject_cast<MainWindow *>(mainApp->mainWindow()), &MainWindow::showPreferencesDialog);
connect(qobject_cast<MainWindow *>(mainApp->mainWindow()), &MainWindow::displayFilterSuccess,
this, &DisplayFilterEdit::displayFilterSuccess);
}
void DisplayFilterEdit::contextMenuEvent(QContextMenuEvent *event) {

View File

@ -25,7 +25,7 @@ public:
virtual void clear();
Q_SIGNALS:
signals:
void actionMoved(QAction * action, int oldPos, int newPos);
void newFilterDropped(QString description, QString filter);

View File

@ -48,7 +48,7 @@ ProfileTreeView::ProfileTreeView(QWidget *parent) :
setItemDelegateForColumn(ProfileModel::COL_NAME, delegate_);
connect(this, &QAbstractItemView::clicked, this, &ProfileTreeView::clicked);
connect(delegate_, SIGNAL(commitData(QWidget *)), this, SIGNAL(itemUpdated()));
connect(delegate_, &ProfileTreeEditDelegate::commitData, this, &ProfileTreeView::itemUpdated);
}
ProfileTreeView::~ProfileTreeView()

View File

@ -49,7 +49,7 @@ public:
void selectRow(int row);
bool activeEdit();
Q_SIGNALS:
signals:
void itemUpdated();
// QWidget interface

View File

@ -44,6 +44,7 @@
#include <QGraphicsScene>
#include <QToolTip>
#include <ui/qt/main_window.h>
#include "packet_list.h"
#include <ui/qt/models/packet_list_model.h>
@ -297,7 +298,7 @@ void WirelessTimeline::captureFileReadFinished()
void WirelessTimeline::appInitialized()
{
connect(mainApp->mainWindow(), SIGNAL(framesSelected(QList<int>)), this, SLOT(selectedFrameChanged(QList<int>)));
connect(qobject_cast<MainWindow *>(mainApp->mainWindow()), &MainWindow::framesSelected, this, &WirelessTimeline::selectedFrameChanged);
GString *error_string;
error_string = register_tap_listener("wlan_radio_timeline", this, NULL, TL_REQUIRES_NOTHING, tap_timeline_reset, tap_timeline_packet, NULL/*tap_draw_cb tap_draw*/, NULL);
@ -342,7 +343,7 @@ WirelessTimeline::WirelessTimeline(QWidget *parent) : QWidget(parent)
capfile = NULL;
radio_packet_list = g_hash_table_new(g_direct_hash, g_direct_equal);
connect(mainApp, SIGNAL(appInitialized()), this, SLOT(appInitialized()));
connect(mainApp, &MainApplication::appInitialized, this, &WirelessTimeline::appInitialized);
}
WirelessTimeline::~WirelessTimeline()

View File

@ -245,7 +245,6 @@ private:
signals:
void setDissectedCaptureFile(capture_file *cf);
void displayFilterSuccess(bool success);
void closePacketDialogs();
void reloadFields();
void packetInfoChanged(struct _packet_info *pinfo);