From: APTX Date: Tue, 3 Mar 2026 00:43:11 +0000 (+0900) Subject: Cleanup old Qt version checks X-Git-Url: https://gitweb.tyo.aptx.org/?a=commitdiff_plain;h=9e691efc1c213f0a571e8db5f30c0b616ffdcbac;p=localmylist.git Cleanup old Qt version checks --- diff --git a/localmylist-management/qtsingleapplication/qtlocalpeer.cpp b/localmylist-management/qtsingleapplication/qtlocalpeer.cpp index c81f2c6..ba7b859 100644 --- a/localmylist-management/qtsingleapplication/qtlocalpeer.cpp +++ b/localmylist-management/qtsingleapplication/qtlocalpeer.cpp @@ -120,7 +120,7 @@ bool QtLocalPeer::isClient() return true; bool res = server->listen(socketName); -#if defined(Q_OS_UNIX) && (QT_VERSION >= QT_VERSION_CHECK(4,5,0)) +#if defined(Q_OS_UNIX) // ### Workaround if (!res && server->serverError() == QAbstractSocket::AddressInUseError) { QFile::remove(QDir::cleanPath(QDir::tempPath())+QLatin1Char('/')+socketName); diff --git a/localmylist-management/tabs/dynamicmodeltab.cpp b/localmylist-management/tabs/dynamicmodeltab.cpp index 9ff9512..90e9596 100644 --- a/localmylist-management/tabs/dynamicmodeltab.cpp +++ b/localmylist-management/tabs/dynamicmodeltab.cpp @@ -28,9 +28,7 @@ DynamicModelTab::DynamicModelTab(QWidget *parent) : { ui->setupUi(this); setLabel(name()); -#if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0) ui->filterInput->setClearButtonEnabled(true); -#endif } DynamicModelTab::~DynamicModelTab() @@ -81,11 +79,7 @@ void DynamicModelTab::init() ui->myListView->setSelectionBehavior(QAbstractItemView::SelectRows); ui->myListView->setSelectionMode(QAbstractItemView::ExtendedSelection); -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) ui->myListView->header()->setSectionResizeMode(0, QHeaderView::Stretch); -#else - ui->myListView->header()->setResizeMode(0, QHeaderView::Stretch); -#endif ui->myListView->header()->setStretchLastSection(false); ui->myListView->header()->resizeSection(4, 200); diff --git a/localmylist-management/tabs/hosttab.cpp b/localmylist-management/tabs/hosttab.cpp index a1918b0..b0ed835 100644 --- a/localmylist-management/tabs/hosttab.cpp +++ b/localmylist-management/tabs/hosttab.cpp @@ -66,10 +66,8 @@ void HostTab::addEntry() void HostTab::saveChanges() { -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) if(!model->isDirty()) return; -#endif if (model->submitAll()) return; diff --git a/localmylist-management/tabs/mylisttab.cpp b/localmylist-management/tabs/mylisttab.cpp index fb29b02..1311ebf 100644 --- a/localmylist-management/tabs/mylisttab.cpp +++ b/localmylist-management/tabs/mylisttab.cpp @@ -23,9 +23,7 @@ MyListTab::MyListTab(QWidget *parent) : { ui->setupUi(this); setLabel(name()); -#if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0) ui->filterInput->setClearButtonEnabled(true); -#endif } MyListTab::~MyListTab() @@ -49,11 +47,7 @@ void MyListTab::init() myListFilterModel->setSourceModel(myListModel()); ui->myListView->setModel(myListFilterModel); ui->myListView->setItemDelegate(new MyListItemDelegate(ui->myListView)); -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) ui->myListView->header()->setSectionResizeMode(0, QHeaderView::Stretch); -#else - ui->myListView->header()->setResizeMode(0, QHeaderView::Stretch); -#endif ui->myListView->header()->setStretchLastSection(false); ui->myListView->header()->resizeSection(4, 200); diff --git a/localmylist-management/tabs/pathmappingtab.cpp b/localmylist-management/tabs/pathmappingtab.cpp index 243bbc1..bea1a12 100644 --- a/localmylist-management/tabs/pathmappingtab.cpp +++ b/localmylist-management/tabs/pathmappingtab.cpp @@ -78,10 +78,8 @@ void PathMappingTab::addEntry() void PathMappingTab::saveChanges() { -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) if(!model->isDirty()) return; -#endif if (model->submitAll()) return; diff --git a/localmylist-management/tabs/searchtab.cpp b/localmylist-management/tabs/searchtab.cpp index 45d8695..b6a4ce1 100644 --- a/localmylist-management/tabs/searchtab.cpp +++ b/localmylist-management/tabs/searchtab.cpp @@ -14,9 +14,7 @@ SearchTab::SearchTab(QWidget *parent) : { ui->setupUi(this); m_label = name(); -#if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0) ui->input->setClearButtonEnabled(true); -#endif } SearchTab::~SearchTab() diff --git a/localmylist-management/tabs/watcheddirectoriestab.cpp b/localmylist-management/tabs/watcheddirectoriestab.cpp index 72c2721..c2525d3 100644 --- a/localmylist-management/tabs/watcheddirectoriestab.cpp +++ b/localmylist-management/tabs/watcheddirectoriestab.cpp @@ -70,10 +70,8 @@ void WatchedDirectoriesTab::addEntry() void WatchedDirectoriesTab::saveChanges() { -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) if(!model->isDirty()) return; -#endif if (model->submitAll()) return; diff --git a/localmylist/database.cpp b/localmylist/database.cpp index 0f8ce73..1bd819e 100644 --- a/localmylist/database.cpp +++ b/localmylist/database.cpp @@ -1819,13 +1819,8 @@ bool Database::connect() d = new DatabaseInternal(); d->db = QSqlDatabase::addDatabase("QPSQL", connectionName); -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) QObject::connect(d->db.driver(), SIGNAL(notification(QString,QSqlDriver::NotificationSource,QVariant)), this, SLOT(handleNotification(QString,QSqlDriver::NotificationSource,QVariant))); -#else - QObject::connect(d->db.driver(), SIGNAL(notification(QString)), - this, SLOT(handleNotification(QString))); -#endif } else if (d->db.isOpen()) { @@ -1852,12 +1847,6 @@ bool Database::connect() return success; } - -// Workaround for https://bugreports.qt-project.org/browse/QTBUG-30076 -#if QT_VERSION <= QT_VERSION_CHECK(4, 8, 4) || (QT_VERSION > QT_VERSION_CHECK(5, 0, 0) && QT_VERSION <= QT_VERSION_CHECK(5, 0, 2)) - exec("SET standard_conforming_strings = 'off'"); -#endif - // If the previous connection was terminated in an unusual way, the DB // driver will not delete its subscriptions and refuse to subscribe again. unsubscribeFromNotifications(); @@ -2291,18 +2280,10 @@ bool Database::notifyRenameDataChanged() return notify("rename_data_changed"); } -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) void Database::handleNotification(const QString &name, QSqlDriver::NotificationSource source, const QVariant &payload) -#else -void Database::handleNotification(const QString &name) -#endif { -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) Q_UNUSED(source); qDebug() << QString("[%1] Received notification %2, %3").arg(connectionName).arg(name).arg(payload.toString()); -#else - qDebug() << QString("[%1] Received notification %2").arg(connectionName).arg(name); -#endif if (name == "new_pending_request") { emit newPendingRequest(); @@ -2319,7 +2300,6 @@ void Database::handleNotification(const QString &name) { emit configChanged(); } -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) else if (name == "anime_update") { int id = payload.toInt(); @@ -2485,7 +2465,6 @@ void Database::handleNotification(const QString &name) if (id && id == LocalMyList::instance()->hostId()) emit watchedDirectoriesChanged(); } -#endif } void Database::startPingTimer() diff --git a/localmylist/database.h b/localmylist/database.h index 5ee7dbd..677c309 100644 --- a/localmylist/database.h +++ b/localmylist/database.h @@ -226,13 +226,7 @@ signals: void fileLocationDelete(int locationId, int fid); private slots: -// moc doesn't expand macros -// QT_VERSION_CHECK(5, 0, 0) == 0x050000 -#if QT_VERSION >= 0x050000 void handleNotification(const QString &name, QSqlDriver::NotificationSource source, const QVariant &payload); -#else - void handleNotification(const QString &name); -#endif void startPingTimer(); void stopPingTimer(); diff --git a/localmylist/messagehandler.cpp b/localmylist/messagehandler.cpp index 78d3440..78b9a9d 100644 --- a/localmylist/messagehandler.cpp +++ b/localmylist/messagehandler.cpp @@ -39,7 +39,6 @@ const char *messageType2Str(QtMsgType type) * but for some reason it can't print a timestamp so a custom handler * is still required. */ -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) static const QtMessageHandler qtMessageHandler = []() -> QtMessageHandler { @@ -69,34 +68,10 @@ void messageHandler(QtMsgType type, const QMessageLogContext &context, const QSt MyList::signalDebugMessage(message); } -#else -void messageHandler(QtMsgType type, const char *msg) -{ - const char *typeStr = messageType2Str(type); - const QString message = QString("[%3]%2 %1").arg( - msg, typeStr, - QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss.zzz")); - - QByteArray buf = message.toLocal8Bit(); - - qInstallMsgHandler(0); - // qt_message_output is the default message handler in Qt4. - // If you set your own handler it will just call that instead of - // actually printing the message. - qt_message_output(type, buf.constData()); - qInstallMsgHandler(messageHandler); - - MyList::signalDebugMessage(message); -} -#endif void installMessageHandler() { -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) qInstallMessageHandler(messageHandler); -#else - qInstallMsgHandler(messageHandler); -#endif } } // namespace LocalMyList diff --git a/localmylist/sqlasyncquery.h b/localmylist/sqlasyncquery.h index 2ee6363..f222ff3 100644 --- a/localmylist/sqlasyncquery.h +++ b/localmylist/sqlasyncquery.h @@ -3,11 +3,7 @@ #include "localmylist_global.h" #include -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) -# include -#else -# include -#endif +#include #include #include "sqlresultiteratorinterface.h" diff --git a/localmylist/sqlasyncqueryinternal.h b/localmylist/sqlasyncqueryinternal.h index 92b67e0..f095d07 100644 --- a/localmylist/sqlasyncqueryinternal.h +++ b/localmylist/sqlasyncqueryinternal.h @@ -2,13 +2,9 @@ #define SQLASYNCQUERYINTERNAL_H #include "sqlasyncquery.h" +#include #include #include -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) -# include -#else -# include -#endif namespace LocalMyList {