Qt: Remove checks for version below 5.2

This stops the main source from being buildable by Qt 4.x

Change-Id: I61edbae04ac2b3bf0ae8ee8e09d335083945c176
Reviewed-on: https://code.wireshark.org/review/26756
Petri-Dish: Roland Knall <rknall@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Gerald Combs <gerald@wireshark.org>
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
This commit is contained in:
Roland Knall 2018-04-05 15:12:39 +02:00 committed by Alexis La Goutte
parent c4da7ed843
commit 3a928f1f87
38 changed files with 52 additions and 335 deletions

View File

@ -110,11 +110,7 @@ BluetoothDeviceDialog::BluetoothDeviceDialog(QWidget &parent, CaptureFile &cf, Q
connect(ui->tableWidget, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(tableContextMenu(const QPoint &)));
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
ui->tableWidget->horizontalHeader()->setResizeMode(0, QHeaderView::Stretch);
#else
ui->tableWidget->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch);
#endif
ui->tableWidget->setStyleSheet("QTableView::item:hover{background-color:lightyellow; color:black;}");

View File

@ -167,11 +167,7 @@ void ExtArgSelector::onReloadTriggered()
int counter = 0;
int selected = -1;
#if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
QString call = boxSelection->currentData().toString();
#else
QString call = boxSelection->itemData(boxSelection->currentIndex()).toString();
#endif
const char *prefval = _argument->pref_valptr ? *_argument->pref_valptr : NULL;
QString stored(prefval ? prefval : "");
if ( call != stored )
@ -223,11 +219,7 @@ QString ExtArgSelector::value()
if ( boxSelection == 0 )
return QString();
#if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
QVariant data = boxSelection->currentData();
#else
QVariant data = boxSelection->itemData(boxSelection->currentIndex());
#endif
return data.toString();
}

View File

@ -239,6 +239,8 @@ void FollowStreamDialog::findText(bool go_back)
{
if (ui->leFind->text().isEmpty()) return;
/* Version check due to find on teStreamContent. Expects regex since 5.3
* http://doc.qt.io/qt-5/qplaintextedit.html#find-1 */
#if (QT_VERSION >= QT_VERSION_CHECK(5, 3, 0))
bool found;
if (use_regex_find_) {

View File

@ -244,15 +244,7 @@ QWidget *InterfaceToolbar::createSelector(iface_toolbar_control *control)
combobox->addItem(display, value);
if (val->is_default)
{
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
combobox->setCurrentText(display);
#else
int new_index = combobox->findText(display);
if (new_index >= 0)
{
combobox->setCurrentIndex(new_index);
}
#endif
setDefaultValue(control->num, value.toUtf8());
}
foreach (QString ifname, interface_.keys())
@ -764,15 +756,7 @@ void InterfaceToolbar::startCapture(GArray *ifaces)
if (!selected_found && !first_capturing_ifname.isEmpty())
{
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
ui->interfacesComboBox->setCurrentText(first_capturing_ifname);
#else
int new_index = ui->interfacesComboBox->findText(first_capturing_ifname);
if (new_index >= 0)
{
ui->interfacesComboBox->setCurrentIndex(new_index);
}
#endif
}
else
{
@ -786,9 +770,7 @@ void InterfaceToolbar::stopCapture()
{
if (interface_[ifname].reader_thread)
{
#if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
interface_[ifname].reader_thread->requestInterruption();
#endif
interface_[ifname].reader_thread = NULL;
}
@ -952,15 +934,7 @@ void InterfaceToolbar::interfaceListChanged()
if (selected_ifname.compare(device->name) == 0)
{
// Keep selected interface
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
ui->interfacesComboBox->setCurrentText(device->name);
#else
int new_index = ui->interfacesComboBox->findText(device->name);
if (new_index >= 0)
{
ui->interfacesComboBox->setCurrentIndex(new_index);
}
#endif
keep_selected = true;
}
}

View File

@ -96,12 +96,10 @@ int InterfaceToolbarReader::pipe_read(char *data, int nbyte)
total_len += read_len;
}
#if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
if (QThread::currentThread()->isInterruptionRequested())
{
return -1;
}
#endif
}
return total_len;
@ -141,12 +139,10 @@ void InterfaceToolbarReader::loop()
break;
}
#if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
if (QThread::currentThread()->isInterruptionRequested())
{
break;
}
#endif
if (ret == 0 || !FD_ISSET(fd_in_, &readfds))
{

View File

@ -238,7 +238,6 @@ static void plugin_if_mainwindow_update_toolbars(GHashTable * data_set)
}
}
#if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
static void mainwindow_add_toolbar(const iface_toolbar *toolbar_entry)
{
if (gbl_cur_main_window_ && toolbar_entry)
@ -254,7 +253,6 @@ static void mainwindow_remove_toolbar(const gchar *menu_title)
gbl_cur_main_window_->removeInterfaceToolbar(menu_title);
}
}
#endif
QMenu* MainWindow::findOrAddMenu(QMenu *parent_menu, QString& menu_text) {
QList<QAction *> actions = parent_menu->actions();
@ -296,7 +294,7 @@ MainWindow::MainWindow(QWidget *parent) :
#else
, pipe_notifier_(NULL)
#endif
#if defined(Q_OS_MAC) && QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
#if defined(Q_OS_MAC)
, dock_menu_(NULL)
#endif
{
@ -458,7 +456,7 @@ MainWindow::MainWindow(QWidget *parent) :
#endif
// Set OS specific shortcuts for fullscreen mode
#if defined(Q_OS_MAC) && QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
#if defined(Q_OS_MAC)
main_ui_->actionViewFullScreen->setShortcut(QKeySequence::FullScreen);
#else
main_ui_->actionViewFullScreen->setShortcut(QKeySequence(Qt::Key_F11));
@ -701,14 +699,8 @@ MainWindow::MainWindow(QWidget *parent) :
#endif
plugin_if_register_gui_cb(PLUGIN_IF_REMOVE_TOOLBAR, plugin_if_mainwindow_update_toolbars);
#if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
// Register Interface Toolbar callbacks
//
// Qt version must be 5.2 or higher because the use of
// QThread::requestInterruption() in interface_toolbar.cpp and
// QThread::isInterruptionRequested() in interface_toolbar_reader.cpp
/* Register Interface Toolbar callbacks */
iface_toolbar_register_cb(mainwindow_add_toolbar, mainwindow_remove_toolbar);
#endif
main_ui_->mainStack->setCurrentWidget(main_welcome_);
}
@ -2434,11 +2426,9 @@ void MainWindow::changeEvent(QEvent* event)
wsApp->loadLanguage(locale);
}
break;
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
case QEvent::WindowStateChange:
main_ui_->actionViewFullScreen->setChecked(this->isFullScreen());
break;
#endif
default:
break;
}
@ -2531,12 +2521,7 @@ void MainWindow::addMenuActions(QList<QAction *> &actions, int menu_group)
QMenu *cur_menu = main_ui_->menuTools;
while (menu_path.length() > 1) {
QString menu_title = menu_path.takeFirst();
#if (QT_VERSION > QT_VERSION_CHECK(5, 0, 0))
QMenu *submenu = cur_menu->findChild<QMenu *>(menu_title.toLower(), Qt::FindDirectChildrenOnly);
#else
QMenu *submenu = cur_menu->findChild<QMenu *>(menu_title.toLower());
if (submenu && submenu->parent() != cur_menu) submenu = NULL;
#endif
if (!submenu) {
submenu = cur_menu->addMenu(menu_title);
submenu->setObjectName(menu_title.toLower());
@ -2596,12 +2581,7 @@ void MainWindow::removeMenuActions(QList<QAction *> &actions, int menu_group)
QMenu *cur_menu = main_ui_->menuTools;
while (menu_path.length() > 1) {
QString menu_title = menu_path.takeFirst();
#if (QT_VERSION > QT_VERSION_CHECK(5, 0, 0))
QMenu *submenu = cur_menu->findChild<QMenu *>(menu_title.toLower(), Qt::FindDirectChildrenOnly);
#else
QMenu *submenu = cur_menu->findChild<QMenu *>(menu_title.toLower());
if (submenu && submenu->parent() != cur_menu) submenu = NULL;
#endif
cur_menu = submenu;
}
cur_menu->removeAction(action);

View File

@ -67,9 +67,6 @@ namespace Ui {
class MainWindow;
}
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
Q_DECLARE_METATYPE(QToolBar *)
#endif
Q_DECLARE_METATYPE(ts_type)
Q_DECLARE_METATYPE(ts_precision)
@ -190,7 +187,7 @@ private:
QSocketNotifier *pipe_notifier_;
#endif
#if defined(Q_OS_MAC) && QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
#if defined(Q_OS_MAC)
QMenu *dock_menu_;
#endif

View File

@ -164,7 +164,7 @@ DIAG_ON(frame-larger-than=)
// XXX You must uncomment QT_WINEXTRAS_LIB lines in CMakeList.txt and
// cmakeconfig.h.in.
// #if defined(QT_WINEXTRAS_LIB) && QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
// #if defined(QT_WINEXTRAS_LIB)
// #include <QWinJumpList>
// #include <QWinJumpListCategory>
// #include <QWinJumpListItem>
@ -1245,15 +1245,17 @@ void MainWindow::updateRecentCaptures() {
}
recentMenu->clear();
// #if defined(QT_WINEXTRAS_LIB) && QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
// QWinJumpList recent_jl(this);
// QWinJumpListCategory *recent_jlc = recent_jl.recent();
// if (recent_jlc) {
// recent_jlc->clear();
// recent_jlc->setVisible(true);
// }
// #endif
#if defined(Q_OS_MAC) && QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
#if 0
#if defined(QT_WINEXTRAS_LIB)
QWinJumpList recent_jl(this);
QWinJumpListCategory *recent_jlc = recent_jl.recent();
if (recent_jlc) {
recent_jlc->clear();
recent_jlc->setVisible(true);
}
#endif
#endif
#if defined(Q_OS_MAC)
if (!dock_menu_) {
dock_menu_ = new QMenu();
dock_menu_->setAsDockMenu();
@ -1279,22 +1281,24 @@ void MainWindow::updateRecentCaptures() {
ra->setText(action_cf_name);
connect(ra, SIGNAL(triggered()), this, SLOT(recentActionTriggered()));
// This is slow, at least on my VM here. The added links also open Wireshark
// in a new window. It might make more sense to add a recent item when we
// open a capture file.
// #if defined(QT_WINEXTRAS_LIB) && QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
// if (recent_jlc) {
// QFileInfo fi(ri->filename);
// QWinJumpListItem *jli = recent_jlc->addLink(
// fi.fileName(),
// QApplication::applicationFilePath(),
// QStringList() << "-r" << ri->filename
// );
// // XXX set icon
// jli->setWorkingDirectory(QDir::toNativeSeparators(QApplication::applicationDirPath()));
// }
// #endif
#if defined(Q_OS_MAC) && QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
/* This is slow, at least on my VM here. The added links also open Wireshark
* in a new window. It might make more sense to add a recent item when we
* open a capture file. */
#if 0
#if defined(QT_WINEXTRAS_LIB)
if (recent_jlc) {
QFileInfo fi(ri->filename);
QWinJumpListItem *jli = recent_jlc->addLink(
fi.fileName(),
QApplication::applicationFilePath(),
QStringList() << "-r" << ri->filename
);
// XXX set icon
jli->setWorkingDirectory(QDir::toNativeSeparators(QApplication::applicationDirPath()));
}
#endif
#endif
#if defined(Q_OS_MAC)
QAction *rda = new QAction(dock_menu_);
QFileInfo fi(ri->filename);
rda->setText(fi.fileName());

View File

@ -358,16 +358,10 @@ bool ColoringRulesModel::setData(const QModelIndex &dataIndex, const QVariant &v
return false;
}
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
QVector<int> roles;
roles << role;
#endif
emit dataChanged(topLeft, bottomRight
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
, roles
#endif
);
emit dataChanged(topLeft, bottomRight, roles);
return true;

View File

@ -295,28 +295,14 @@ void DecodeAsDelegate::setEditorData(QWidget *editor, const QModelIndex &index)
{
QComboBox *combobox = static_cast<QComboBox *>(editor);
const QString &data = index.model()->data(index, Qt::EditRole).toString();
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
combobox->setCurrentText(data);
#else
int new_index = combobox->findText(data);
if (new_index >= 0) {
combobox->setCurrentIndex(new_index);
}
#endif
}
break;
case DecodeAsModel::colSelector:
if (isSelectorCombo(item)) {
QComboBox *combobox = static_cast<QComboBox *>(editor);
const QString &data = index.model()->data(index, Qt::EditRole).toString();
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
combobox->setCurrentText(data);
#else
int new_index = combobox->findText(data);
if (new_index >= 0) {
combobox->setCurrentIndex(new_index);
}
#endif
}
else {
QStyledItemDelegate::setEditorData(editor, index);

View File

@ -385,11 +385,7 @@ bool DecodeAsModel::copyRow(int dst_row, int src_row)
QVector<int> roles;
roles << Qt::EditRole << Qt::BackgroundRole;
emit dataChanged(index(dst_row, 0), index(dst_row, columnCount())
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
, roles
#endif
);
emit dataChanged(index(dst_row, 0), index(dst_row, columnCount()), roles );
return true;
}

View File

@ -252,11 +252,7 @@ bool EnabledProtocolsModel::setData(const QModelIndex &index, const QVariant &va
QVector<int> roles;
roles << role;
emit dataChanged(index, index
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
, roles
#endif
);
emit dataChanged(index, index, roles);
return true;
}

View File

@ -104,27 +104,17 @@ 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
);
emit dataChanged(index(0, old_column), index(rowCount(), old_column), roles );
}
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
);
emit dataChanged(index(0, column_), index(rowCount(), column_), roles);
}
}

View File

@ -516,18 +516,12 @@ bool AdvancedPrefsModel::setData(const QModelIndex &dataindex, const QVariant &v
}
}
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
QVector<int> roles;
roles << role;
#endif
// The status field may change as well as the value, so mark them for update
emit dataChanged(index(dataindex.row(), AdvancedPrefsModel::colStatus),
index(dataindex.row(), AdvancedPrefsModel::colValue)
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
, roles
#endif
);
index(dataindex.row(), AdvancedPrefsModel::colValue), roles);
return true;
}

View File

@ -28,11 +28,10 @@ ProtoTreeModel::ProtoTreeModel(QObject * parent) :
Qt::ItemFlags ProtoTreeModel::flags(const QModelIndex &index) const
{
Qt::ItemFlags item_flags = QAbstractItemModel::flags(index);
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
if (rowCount(index) < 1) {
item_flags |= Qt::ItemNeverHasChildren;
}
#endif
return item_flags;
}

View File

@ -36,21 +36,13 @@ RelatedPacketDelegate::RelatedPacketDelegate(QWidget *parent) :
void RelatedPacketDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
const QModelIndex &index) const
{
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
QStyleOptionViewItemV4 option_vi = option;
#else
QStyleOptionViewItem option_vi = option;
#endif
QStyledItemDelegate::initStyleOption(&option_vi, index);
int em_w = option_vi.fontMetrics.height();
int en_w = (em_w + 1) / 2;
int line_w = (option_vi.fontMetrics.lineWidth());
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
option_vi.features |= QStyleOptionViewItemV4::HasDecoration;
#else
option_vi.features |= QStyleOptionViewItem::HasDecoration;
#endif
option_vi.decorationSize.setHeight(1);
option_vi.decorationSize.setWidth(em_w);
QStyledItemDelegate::paint(painter, option_vi, index);

View File

@ -147,14 +147,7 @@ void UatDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const
{
QComboBox *combobox = static_cast<QComboBox *>(editor);
const QString &data = index.model()->data(index, Qt::EditRole).toString();
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
combobox->setCurrentText(data);
#else
int new_index = combobox->findText(data);
if (new_index >= 0) {
combobox->setCurrentIndex(new_index);
}
#endif
break;
}

View File

@ -256,18 +256,10 @@ bool UatModel::setData(const QModelIndex &index, const QVariant &value, int role
// The validation status for other columns were also affected by
// changing this field, mark those as dirty!
emit dataChanged(this->index(row, updated_cols.first()),
this->index(row, updated_cols.last())
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
, roles
#endif
);
this->index(row, updated_cols.last()), roles);
} else {
emit dataChanged(index, index
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
, roles
#endif
);
emit dataChanged(index, index, roles);
}
return true;
}
@ -357,11 +349,7 @@ bool UatModel::copyRow(int dst_row, int src_row)
QVector<int> roles;
roles << Qt::EditRole << Qt::BackgroundRole;
emit dataChanged(index(dst_row, 0), index(dst_row, columnCount())
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
, roles
#endif
);
emit dataChanged(index(dst_row, 0), index(dst_row, columnCount()), roles);
return true;
}

View File

@ -1624,9 +1624,7 @@ void PacketList::drawNearOverlay()
if (!prefs.gui_packet_list_show_minimap) return;
qreal dp_ratio = 1.0;
#if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)
dp_ratio = overlay_sb_->devicePixelRatio();
#endif
int o_height = overlay_sb_->height() * dp_ratio;
int o_rows = qMin(packet_list_model_->rowCount(), o_height);
int o_width = (wsApp->fontMetrics().height() * 2 * dp_ratio) + 2; // 2ems + 1-pixel border on either side.
@ -1695,11 +1693,9 @@ void PacketList::drawFarOverlay()
if (!prefs.gui_packet_list_show_minimap) return;
QSize groove_size = overlay_sb_->grooveRect().size();
#if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)
qreal dp_ratio = 1.0;
dp_ratio = overlay_sb_->devicePixelRatio();
groove_size *= dp_ratio;
#endif
int o_width = groove_size.width();
int o_height = groove_size.height();
int pl_rows = packet_list_model_->rowCount();

View File

@ -90,11 +90,9 @@ ProgressFrame::ProgressFrame(QWidget *parent) :
ui(new Ui::ProgressFrame)
, terminate_is_stop_(false)
, stop_flag_(NULL)
#if QT_VERSION > QT_VERSION_CHECK(5, 0, 0)
, show_timer_(-1)
, effect_(NULL)
, animation_(NULL)
#endif
#ifdef QWINTASKBARPROGRESS_H
, update_taskbar_(false)
, taskbar_progress_(NULL)
@ -130,11 +128,8 @@ ProgressFrame::ProgressFrame(QWidget *parent) :
"}"
);
#if QT_VERSION > QT_VERSION_CHECK(5, 0, 0)
effect_ = new QGraphicsOpacityEffect(this);
animation_ = new QPropertyAnimation(effect_, "opacity", this);
#endif
connect(this, SIGNAL(showRequested(bool,bool,gboolean*)),
this, SLOT(show(bool,bool,gboolean*)));
hide();
@ -218,7 +213,6 @@ void ProgressFrame::setValue(int value)
emit valueChanged(value);
}
#if QT_VERSION > QT_VERSION_CHECK(5, 0, 0)
void ProgressFrame::timerEvent(QTimerEvent *event)
{
if (event->timerId() == show_timer_) {
@ -238,13 +232,10 @@ void ProgressFrame::timerEvent(QTimerEvent *event)
QFrame::timerEvent(event);
}
}
#endif
void ProgressFrame::hide()
{
#if QT_VERSION > QT_VERSION_CHECK(5, 0, 0)
show_timer_ = -1;
#endif
emit setHidden();
QFrame::hide();
#ifdef QWINTASKBARPROGRESS_H
@ -261,9 +252,7 @@ void ProgressFrame::on_stopButton_clicked()
emit stopLoading();
}
#if QT_VERSION > QT_VERSION_CHECK(5, 0, 0)
const int show_delay_ = 500; // ms
#endif
void ProgressFrame::show(bool animate, bool terminate_is_stop, gboolean *stop_flag)
{
@ -276,16 +265,11 @@ void ProgressFrame::show(bool animate, bool terminate_is_stop, gboolean *stop_fl
ui->stopButton->hide();
}
#if QT_VERSION > QT_VERSION_CHECK(5, 0, 0)
if (animate) {
show_timer_ = startTimer(show_delay_);
} else {
QFrame::show();
}
#else
Q_UNUSED(animate)
QFrame::show();
#endif
#ifdef QWINTASKBARPROGRESS_H
// windowHandle() is picky about returning a non-NULL value so we check it

View File

@ -17,7 +17,7 @@ namespace Ui {
class ProgressFrame;
}
#if defined(Q_OS_WIN) && QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
#if defined(Q_OS_WIN)
#include <QWinTaskbarButton>
#include <QWinTaskbarProgress>
#endif
@ -62,9 +62,7 @@ signals:
void stopLoading();
protected:
#if QT_VERSION > QT_VERSION_CHECK(5, 0, 0)
void timerEvent(QTimerEvent *event);
#endif
private:
Ui::ProgressFrame *ui;
@ -74,11 +72,9 @@ private:
QString status_;
bool terminate_is_stop_;
gboolean *stop_flag_;
#if QT_VERSION > QT_VERSION_CHECK(5, 0, 0)
int show_timer_;
QGraphicsOpacityEffect *effect_;
QPropertyAnimation *animation_;
#endif
#ifdef QWINTASKBARPROGRESS_H
bool update_taskbar_;
QWinTaskbarProgress *taskbar_progress_;

View File

@ -28,9 +28,7 @@
#include <QStack>
#include <QUrl>
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
#include <QWindow>
#endif
// To do:
// - Fix "apply as filter" behavior.
@ -563,13 +561,9 @@ bool ProtoTree::eventFilter(QObject * obj, QEvent * event)
DragLabel * content = new DragLabel(dfmd->labelText(), this);
#if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)
qreal dpr = window()->windowHandle()->devicePixelRatio();
QPixmap pixmap(content->size() * dpr);
pixmap.setDevicePixelRatio(dpr);
#else
QPixmap pixmap(content->size());
#endif
content->render(&pixmap);
drag->setPixmap(pixmap);

View File

@ -82,11 +82,6 @@ enum {
graph_data_col_ = src_port_col_ // QCPGraph
};
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
Q_DECLARE_METATYPE(RtpAudioStream *)
Q_DECLARE_METATYPE(QCPGraph *)
#endif
#ifdef QT_MULTIMEDIA_LIB
static const double wf_graph_normal_width_ = 0.5;
static const double wf_graph_selected_width_ = 2.0;

View File

@ -27,23 +27,14 @@ SCTPChunkStatisticsDialog::SCTPChunkStatisticsDialog(QWidget *parent, sctp_assoc
| Qt::WindowMaximizeButtonHint
| Qt::WindowCloseButtonHint;
this->setWindowFlags(flags);
#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
ui->tableWidget->verticalHeader()->setClickable(true);
ui->tableWidget->verticalHeader()->setMovable(true);
#else
ui->tableWidget->verticalHeader()->setSectionsClickable(true);
ui->tableWidget->verticalHeader()->setSectionsMovable(true);
#endif
ui->tableWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
ui->tableWidget->setSelectionMode(QAbstractItemView::SingleSelection);
#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
ui->tableWidget->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents);
#else
ui->tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
#endif
this->setWindowTitle(QString(tr("SCTP Chunk Statistics: %1 Port1 %2 Port2 %3")).arg(cf_get_display_name(cap_file_)).arg(selected_assoc->port1).arg(selected_assoc->port2));
// connect(ui->tableWidget->verticalHeader(), SIGNAL(sectionMoved(int,int,int)), this, SLOT(on_sectionMoved(int, int, int)));

View File

@ -20,9 +20,7 @@
#include <ui/qt/utils/qt_ui_utils.h>
#include "wireshark_application.h"
#if (QT_VERSION > QT_VERSION_CHECK(5, 2, 0))
#include <QCheckBox>
#endif
#include <QMessageBox>
#include <QRegExp>
#include <QTextCodec>
@ -94,7 +92,6 @@ simple_message_box(ESD_TYPE_E type, gboolean *notagain,
sd.setDetailedText(secondary_msg);
#if (QT_VERSION > QT_VERSION_CHECK(5, 2, 0))
QCheckBox *cb = NULL;
if (notagain) {
cb = new QCheckBox();
@ -102,15 +99,12 @@ simple_message_box(ESD_TYPE_E type, gboolean *notagain,
cb->setText(QObject::tr("Don't show this message again."));
sd.setCheckBox(cb);
}
#endif
sd.exec();
#if (QT_VERSION > QT_VERSION_CHECK(5, 2, 0))
if (notagain && cb) {
*notagain = cb->isChecked();
}
#endif
}
/*
@ -161,9 +155,7 @@ simple_error_message_box(const char *msg_format, ...)
}
SimpleDialog::SimpleDialog(QWidget *parent, ESD_TYPE_E type, int btn_mask, const char *msg_format, va_list ap) :
#if (QT_VERSION > QT_VERSION_CHECK(5, 2, 0))
check_box_(0),
#endif
message_box_(0)
{
gchar *vmessage;
@ -193,10 +185,7 @@ SimpleDialog::SimpleDialog(QWidget *parent, ESD_TYPE_E type, int btn_mask, const
message_box_ = new QMessageBox(parent);
message_box_->setTextFormat(Qt::PlainText);
#if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)
message_box_->setTextInteractionFlags(Qt::TextSelectableByMouse);
#endif
switch(type) {
case ESD_TYPE_ERROR:
@ -307,9 +296,7 @@ int SimpleDialog::exec()
}
message_box_->setDetailedText(detailed_text_);
#if (QT_VERSION > QT_VERSION_CHECK(5, 2, 0))
message_box_->setCheckBox(check_box_);
#endif
int status = message_box_->exec();
delete message_box_;

View File

@ -22,9 +22,7 @@
typedef QPair<QString,QString> MessagePair;
#if (QT_VERSION > QT_VERSION_CHECK(5, 2, 0))
class QCheckBox;
#endif
class QMessageBox;
class QWidget;
@ -37,17 +35,13 @@ public:
static void displayQueuedMessages(QWidget *parent = 0);
void setDetailedText(QString text) { detailed_text_ = text; }
#if (QT_VERSION > QT_VERSION_CHECK(5, 2, 0))
void setCheckBox(QCheckBox *cb) { check_box_ = cb; }
#endif
int exec();
private:
const MessagePair splitMessage(QString &message) const;
QString detailed_text_;
#if (QT_VERSION > QT_VERSION_CHECK(5, 2, 0))
QCheckBox *check_box_;
#endif
QMessageBox *message_box_;
};

View File

@ -270,9 +270,7 @@ TCPStreamDialog::TCPStreamDialog(QWidget *parent, capture_file *cf, tcp_graph_ty
// Duplicate ACK Graph - displays duplicate ack ticks
// QCustomPlot doesn't have QCPScatterStyle::ssTick so we have to make our own.
int tick_len = 3;
#if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)
tick_len *= devicePixelRatio();
#endif
QPixmap da_tick_pm = QPixmap(1, tick_len * 2);
da_tick_pm.fill(Qt::transparent);
QPainter painter(&da_tick_pm);

View File

@ -60,11 +60,7 @@ UatDialog::UatDialog(QWidget *parent, epan_uat *uat) :
// very long filenames in the SSL RSA keys dialog, it also results in a
// vertical scrollbar. Maybe remove this since the editor is not limited to
// the column width (and overlays other fields if more width is needed)?
#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
ui->uatTreeView->header()->setResizeMode(QHeaderView::ResizeToContents);
#else
ui->uatTreeView->header()->setSectionResizeMode(QHeaderView::ResizeToContents);
#endif
// start editing as soon as the field is selected or when typing starts
ui->uatTreeView->setEditTriggers(ui->uatTreeView->editTriggers() |

View File

@ -51,11 +51,7 @@ UatFrame::UatFrame(QWidget *parent) :
// very long filenames in the SSL RSA keys dialog, it also results in a
// vertical scrollbar. Maybe remove this since the editor is not limited to
// the column width (and overlays other fields if more width is needed)?
#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
ui->uatTreeView->header()->setResizeMode(QHeaderView::ResizeToContents);
#else
ui->uatTreeView->header()->setSectionResizeMode(QHeaderView::ResizeToContents);
#endif
// start editing as soon as the field is selected or when typing starts
ui->uatTreeView->setEditTriggers(ui->uatTreeView->editTriggers() |

View File

@ -34,11 +34,6 @@
#include <QUrl>
#include <QUuid>
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
// Qt::escape
#include <QTextDocument>
#endif
/* Make the format_size_flags_e enum usable in C++ */
format_size_flags_e operator|(format_size_flags_e lhs, format_size_flags_e rhs) {
return (format_size_flags_e) ((int)lhs| (int)rhs);
@ -169,11 +164,7 @@ const QString time_t_to_qstring(time_t ti_time)
}
QString html_escape(const QString plain_string) {
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
return Qt::escape(plain_string);
#else
return plain_string.toHtmlEscaped();
#endif
}

View File

@ -229,11 +229,9 @@ void ByteViewText::paintEvent(QPaintEvent *)
QColor ho_color = palette().text().color();
if (marked_byte_offset_ < 0) {
hover_alpha = 0.3;
#if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)
if (devicePixelRatio() > 1) {
pen_width = 0.5;
}
#endif
}
ho_pen.setWidthF(pen_width);
ho_color.setAlphaF(hover_alpha);

View File

@ -20,9 +20,7 @@
#include <QLayout>
#include <QMimeData>
#include <QMouseEvent>
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
#include <QWindow>
#endif
#define drag_drop_toolbar_action_ "drag_drop_toolbar_action_"
@ -122,13 +120,10 @@ bool DragDropToolBar::eventFilter(QObject * obj, QEvent * event)
QDrag * drag = new QDrag(this);
drag->setMimeData(temd);
#if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)
qreal dpr = window()->windowHandle()->devicePixelRatio();
QPixmap pixmap(lbl->size() * dpr);
pixmap.setDevicePixelRatio(dpr);
#else
QPixmap pixmap(lbl->size());
#endif
lbl->render(&pixmap);
drag->setPixmap(pixmap);

View File

@ -18,6 +18,9 @@ void FindLineEdit::contextMenuEvent(QContextMenuEvent *event)
{
QMenu *menu = createStandardContextMenu();
/* This version check is implemented, because using this function leads to using
* a regular expression for search in follow_stream_dialog.cpp as well as
* show_packet_bytes_dialog.cpp. Both instances are not compatible with < 5.3 */
#if (QT_VERSION >= QT_VERSION_CHECK(5, 3, 0))
QAction *action;

View File

@ -105,9 +105,7 @@ void OverlayScrollBar::setNearOverlayImage(QImage &overlay_image, int packet_cou
if (old_width != packet_map_img_.width()) {
qreal dp_ratio = 1.0;
#if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)
dp_ratio = devicePixelRatio();
#endif
packet_map_width_ = packet_map_img_.width() / dp_ratio;
@ -119,9 +117,7 @@ void OverlayScrollBar::setNearOverlayImage(QImage &overlay_image, int packet_cou
void OverlayScrollBar::setMarkedPacketImage(QImage &mp_image)
{
qreal dp_ratio = 1.0;
#if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)
dp_ratio = devicePixelRatio();
#endif
marked_packet_img_ = mp_image;
marked_packet_width_ = mp_image.width() / dp_ratio;
@ -151,10 +147,8 @@ void OverlayScrollBar::paintEvent(QPaintEvent *event)
{
qreal dp_ratio = 1.0;
QSize pm_size(packet_map_width_, geometry().height());
#if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)
dp_ratio = devicePixelRatio();
pm_size *= dp_ratio;
#endif
QPainter painter(this);
@ -190,9 +184,7 @@ void OverlayScrollBar::paintEvent(QPaintEvent *event)
pm_painter.restore();
// Draw the map.
#if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)
packet_map.setDevicePixelRatio(dp_ratio);
#endif
painter.drawImage(0, 0, packet_map);
}
}
@ -207,12 +199,10 @@ bool OverlayScrollBar::eventFilter(QObject *watched, QEvent *event)
if (!marked_packet_img_.isNull()) {
QRect groove_rect = grooveRect();
#if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)
qreal dp_ratio = 1.0;
dp_ratio = devicePixelRatio();
groove_rect.setTopLeft(groove_rect.topLeft() * dp_ratio);
groove_rect.setSize(groove_rect.size() * dp_ratio);
#endif
QImage marked_map(groove_rect.width(), groove_rect.height(), QImage::Format_ARGB32_Premultiplied);
marked_map.fill(Qt::transparent);
@ -223,9 +213,7 @@ bool OverlayScrollBar::eventFilter(QObject *watched, QEvent *event)
QRect far_dest(0, 0, groove_rect.width(), groove_rect.height());
mm_painter.drawImage(far_dest, marked_packet_img_.scaled(far_dest.size(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
#if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)
marked_map.setDevicePixelRatio(dp_ratio);
#endif
QPainter painter(&child_sb_);
painter.drawImage(groove_rect.left(), groove_rect.top(), marked_map);
}

View File

@ -48,9 +48,6 @@ public:
QRect grooveRect();
public slots:
// Qt 4's QScrollBar::setRange isn't a slot. We can't wrap this in
//#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
// because Qt 4's MOC doesn't support macros.
void setChildRange(int min, int max) { child_sb_.setRange(min, max); }
protected:

View File

@ -111,11 +111,7 @@ static void accumulate_rgb(float rgb[TIMELINE_HEIGHT][3], int height, int dfilte
void WirelessTimeline::mousePressEvent(QMouseEvent *event)
{
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
start_x = last_x = event->localPos().x();
#else
start_x = last_x = event->posF().x();
#endif
}
@ -124,13 +120,8 @@ void WirelessTimeline::mouseMoveEvent(QMouseEvent *event)
if (event->buttons() == Qt::NoButton)
return;
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
qreal offset = event->localPos().x() - last_x;
last_x = event->localPos().x();
#else
qreal offset = event->posF().x() - last_x;
last_x = event->posF().x();
#endif
qreal shift = ((qreal) (end_tsf - start_tsf))/width() * offset;
start_tsf -= shift;
@ -146,11 +137,7 @@ void WirelessTimeline::mouseMoveEvent(QMouseEvent *event)
void WirelessTimeline::mouseReleaseEvent(QMouseEvent *event)
{
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
QPointF localPos = event->localPos();
#else
QPointF localPos = event->posF();
#endif
qreal offset = localPos.x() - start_x;
/* if this was a drag, ignore it */
@ -491,10 +478,7 @@ WirelessTimeline::paintEvent(QPaintEvent *qpe)
QPainter p(this);
// painting is done in device pixels in the x axis, get the ratio here
float ratio = 1.0;
#if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)
ratio = p.device()->devicePixelRatio();
#endif
float ratio = p.device()->devicePixelRatio();
unsigned int packet;
double zoom;

View File

@ -87,10 +87,8 @@
#include <QUrl>
#include <qmath.h>
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
#include <QFontDatabase>
#include <QMimeDatabase>
#endif
#ifdef _MSC_VER
#pragma warning(pop)
@ -109,8 +107,6 @@ static QHash<int, QList<QAction *> > removed_menu_groups_;
QString WiresharkApplication::window_title_separator_ = QString::fromUtf8(" " UTF8_MIDDLE_DOT " ");
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
// QMimeDatabase parses a large-ish XML file and can be slow to initialize.
// Do so in a worker thread as early as possible.
// https://github.com/lxde/pcmanfm-qt/issues/415
@ -133,7 +129,6 @@ private:
QFontDatabase font_db;
}
};
#endif
void
topic_action(topic_action_e action)
@ -496,11 +491,7 @@ void WiresharkApplication::applyCustomColorsFromRecent()
for (GList *custom_color = recent.custom_colors; custom_color; custom_color = custom_color->next) {
QRgb rgb = QString((const char *)custom_color->data).toUInt(&ok, 16);
if (ok) {
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
QColorDialog::setCustomColor(i++, rgb);
#else
QColorDialog::setCustomColor(i++, QColor(rgb));
#endif
}
}
}
@ -523,11 +514,7 @@ void WiresharkApplication::storeCustomColorsInRecent()
prefs_clear_string_list(recent.custom_colors);
recent.custom_colors = NULL;
for (int i = 0; i < QColorDialog::customCount(); i++) {
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
QRgb rgb = QColorDialog::customColor(i);
#else
QRgb rgb = QColorDialog::customColor(i).rgb();
#endif
recent.custom_colors = g_list_append(recent.custom_colors, g_strdup_printf("%08x", rgb));
}
}
@ -736,12 +723,10 @@ WiresharkApplication::WiresharkApplication(int &argc, char **argv) :
wsApp = this;
setApplicationName("Wireshark");
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
MimeDatabaseInitThread *mime_db_init_thread = new(MimeDatabaseInitThread);
QThreadPool::globalInstance()->start(mime_db_init_thread);
FontDatabaseInitThread *font_db_init_thread = new (FontDatabaseInitThread);
QThreadPool::globalInstance()->start(font_db_init_thread);
#endif
Q_INIT_RESOURCE(about);
Q_INIT_RESOURCE(i18n);
@ -755,9 +740,7 @@ WiresharkApplication::WiresharkApplication(int &argc, char **argv) :
ws_load_library("riched20.dll");
#endif // Q_OS_WIN
#if (QT_VERSION >= QT_VERSION_CHECK(5, 1, 0))
setAttribute(Qt::AA_UseHighDpiPixmaps);
#endif
//
// XXX - this means we try to check for the existence of all files
// in the recent list every 2 seconds; that causes noticeable network

View File

@ -110,10 +110,6 @@
#include "epan/crypt/dot11decrypt_ws.h"
#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
#include <QTextCodec>
#endif
#include <ui/qt/utils/qt_ui_utils.h>
#define INVALID_OPTION 1
@ -259,7 +255,6 @@ get_wireshark_runtime_info(GString *str)
#endif
}
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
static void
g_log_message_handler(QtMsgType type, const QMessageLogContext &, const QString &msg)
{
@ -286,7 +281,6 @@ g_log_message_handler(QtMsgType type, const QMessageLogContext &, const QString
}
g_log(LOG_DOMAIN_MAIN, log_level, "%s", qUtf8Printable(msg));
}
#endif
#ifdef HAVE_LIBPCAP
/* Check if there's something important to tell the user during startup.
@ -403,16 +397,6 @@ int main(int argc, char *qt_argv[])
#endif /* DEBUG_STARTUP_TIME */
cmdarg_err_init(wireshark_cmdarg_err, wireshark_cmdarg_err_cont);
// In Qt 5, C strings are treated always as UTF-8 when converted to
// QStrings; in Qt 4, the codec must be set to make that happen
#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
// Hopefully we won't have to use QString::fromUtf8() in as many places.
QTextCodec *utf8codec = QTextCodec::codecForName("UTF-8");
QTextCodec::setCodecForCStrings(utf8codec);
// XXX - QObject doesn't *have* a tr method in 5.0, as far as I can see...
QTextCodec::setCodecForTr(utf8codec);
#endif
/* Set the C-language locale to the native environment. */
setlocale(LC_ALL, "");
@ -609,9 +593,7 @@ int main(int argc, char *qt_argv[])
}
set_console_log_handler();
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
qInstallMessageHandler(g_log_message_handler);
#endif
#ifdef DEBUG_STARTUP_TIME
g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_INFO, "set_console_log_handler, elapsed time %" G_GUINT64_FORMAT " us \n", g_get_monotonic_time() - start_time);
#endif