]> Some of my projects - localmylist.git/commitdiff
Cleanup old Qt version checks
authorAPTX <redacted>
Tue, 3 Mar 2026 00:43:11 +0000 (09:43 +0900)
committerAPTX <redacted>
Sat, 7 Mar 2026 03:43:55 +0000 (12:43 +0900)
12 files changed:
localmylist-management/qtsingleapplication/qtlocalpeer.cpp
localmylist-management/tabs/dynamicmodeltab.cpp
localmylist-management/tabs/hosttab.cpp
localmylist-management/tabs/mylisttab.cpp
localmylist-management/tabs/pathmappingtab.cpp
localmylist-management/tabs/searchtab.cpp
localmylist-management/tabs/watcheddirectoriestab.cpp
localmylist/database.cpp
localmylist/database.h
localmylist/messagehandler.cpp
localmylist/sqlasyncquery.h
localmylist/sqlasyncqueryinternal.h

index c81f2c6..ba7b859 100644 (file)
@@ -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);
index 9ff9512..90e9596 100644 (file)
@@ -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);
 
index a1918b0..b0ed835 100644 (file)
@@ -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;
index fb29b02..1311ebf 100644 (file)
@@ -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);
 
index 243bbc1..bea1a12 100644 (file)
@@ -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;
index 45d8695..b6a4ce1 100644 (file)
@@ -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()
index 72c2721..c2525d3 100644 (file)
@@ -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;
index 0f8ce73..1bd819e 100644 (file)
@@ -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()
index 5ee7dbd..677c309 100644 (file)
@@ -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();
index 78d3440..78b9a9d 100644 (file)
@@ -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
index 2ee6363..f222ff3 100644 (file)
@@ -3,11 +3,7 @@
 
 #include "localmylist_global.h"
 #include <QObject>
-#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
-#      include <QSql>
-#else
-#      include <QtSql>
-#endif
+#include <QSql>
 #include <functional>
 
 #include "sqlresultiteratorinterface.h"
index 92b67e0..f095d07 100644 (file)
@@ -2,13 +2,9 @@
 #define SQLASYNCQUERYINTERNAL_H
 
 #include "sqlasyncquery.h"
+#include <QSql>
 #include <QStringList>
 #include <QVariant>
-#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
-#      include <QSql>
-#else
-#      include <QtSql>
-#endif
 
 namespace LocalMyList {