ifdef qt4 and qt5
authorgregor herrmann <gregor@toastfreeware.priv.at>
Wed, 30 Aug 2017 19:15:52 +0000 (21:15 +0200)
committergregor herrmann <gregor@toastfreeware.priv.at>
Wed, 30 Aug 2017 19:15:52 +0000 (21:15 +0200)
confclerk.pro
src/app/app.pro
src/gui/eventdialog.cpp
src/gui/gui.pro
src/gui/mainwindow.h
src/gui/searchhead.h
src/mvc/delegate.h
src/mvc/eventmodel.cpp
src/mvc/mvc.pro
src/sql/sqlengine.cpp

index 22f8f79afc7d441ac529a28e581dd8b6468be044..8171399115a896841ef6b34dc6cb0fe3584a7008 100644 (file)
@@ -3,7 +3,7 @@
 QMAKEVERSION = $$[QMAKE_VERSION]
 ISQT4 = $$find(QMAKEVERSION, ^[2-9])
 isEmpty( ISQT4 ) {
-       error("Use the qmake include with Qt4.4 or greater, on Debian that is qmake-qt4");
+       error("Use the qmake include with Qt4.7 or greater, on Debian that is qmake-qt4");
 }
 
 TEMPLATE = subdirs
index 80baf93608a7c6f9775d75816f9eabf8eeb0186b..37f4f487137270c25e592a85d9e8118030690a99 100644 (file)
@@ -2,7 +2,8 @@ include(../global.pri)
 TEMPLATE = app
 TARGET = confclerk
 DESTDIR = ../bin
-QT += sql xml network widgets
+QT += sql xml network
+greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
 CONFIG(maemo5) {
     QT += maemo5
 }
index 90910c85d8834b0be3c6fe5632df8980779c039f..4103ad6169e79cd68368960e131e932298054fbc 100644 (file)
 #include "appsettings.h"
 #endif
 
+QString toHtmlEscaped(const QString& string) {
+#if QT_VERSION >= 0x050000
+    return string.toHtmlEscaped();
+#else
+    return Qt::escape(string);
+#endif
+}
+
 EventDialog::EventDialog(int conferenceId, int eventId, QWidget *parent): QDialog(parent), mConferenceId(conferenceId), mEventId(eventId) {
     setupUi(this);
 
@@ -38,12 +46,12 @@ EventDialog::EventDialog(int conferenceId, int eventId, QWidget *parent): QDialo
 
     QString info;
     // title
-    info.append(QString("<h1>%1</h1>\n").arg(event.title().toHtmlEscaped()));
+    info.append(QString("<h1>%1</h1>\n").arg(toHtmlEscaped(event.title())));
 
     // persons
     info += QString("<h2>%1</h2>\n").arg(tr("Persons"));
     QStringList persons = event.persons();
-    for (int i = 0; i != persons.size(); ++i) persons[i] = persons[i].toHtmlEscaped();
+    for (int i = 0; i != persons.size(); ++i) persons[i] = toHtmlEscaped(persons[i]);
     info += QString("<p>%1</p>\n").arg(persons.join(", "));
 
     // abstract
@@ -71,7 +79,7 @@ EventDialog::EventDialog(int conferenceId, int eventId, QWidget *parent): QDialo
         QString name(i.key());
         if (url.isEmpty() || url == "http://") continue;
         if (name.isEmpty()) name = url;
-        info += QString("<li><a href=\"%1\">%2</a></li>\n").arg(url.toHtmlEscaped(), name.toHtmlEscaped());
+        info += QString("<li><a href=\"%1\">%2</a></li>\n").arg(toHtmlEscaped(url), toHtmlEscaped(name));
     }
     info += QString("</ul>\n");
     eventInfoTextBrowser->setHtml(info);
index efffb45b642af50deeb83278e72551603a4f3455..cac0bc20b8e8493f20a64940b262ff1bccf123df 100644 (file)
@@ -5,8 +5,8 @@ DESTDIR = ../bin
 CONFIG += static
 QT += sql \
     xml \
-    network \
-    widgets
+    network
+greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
 QMAKE_CLEAN += ../bin/libgui.a
 
 # module dependencies
index 09203e406aa44bb830040dd102029c66fe7afb2a..91b3c114e5b1490474e8a08a0ae43853205c6f7d 100644 (file)
 #ifndef MAINWINDOW_H
 #define MAINWINDOW_H
 
+#include "qglobal.h"
+#if QT_VERSION >= 0x050000
 #include <QtWidgets>
+#else
+#include <QtGui/QMainWindow>
+#endif
 #include <QSslError>
 
 #include "ui_mainwindow.h"
index 2a56d4b76f150035f29b14b95a9b01909399937e..39303f00d77064a7be7093342ea23d43b2c1e4c3 100644 (file)
 #ifndef SEARCHHEAD_H
 #define SEARCHHEAD_H
 
+#include "qglobal.h"
+#if QT_VERSION >= 0x050000
 #include <QtWidgets>
+#else
+#include <QtGui/QWidget>
+#endif
 #include <QDebug>
 #include "ui_searchhead.h"
 
index e9f3439decc305e19f249efc7f4bb43c2a16292e..2ee765f88a077119e6aa5a38e3c93be032f76c07 100644 (file)
 #ifndef DELEGATE_H
 #define DELEGATE_H
 
+#include "qglobal.h"
+#if QT_VERSION >= 0x050000
 #include <QtWidgets>
+#else
+#include <QtGui>
+#endif
 
 class Delegate : public QItemDelegate
 {
index 674bbcd5be62234296f354f199e285649262685a..ff3d0ebede1201bb1ad6bc6e7a8e3d20e6a0bebf 100644 (file)
@@ -176,7 +176,7 @@ QModelIndex EventModel::index(int row, int column, const QModelIndex& parent) co
 
     if (!parent.isValid())
     {
-        return createIndex(row, column, (quintptr) 0);
+        return createIndex(row, column);
     }
     else if (parent.internalId() == 0)
     {
@@ -201,7 +201,7 @@ QModelIndex EventModel::parent(const QModelIndex & index) const
 
         Event * event = static_cast<Event*>(index.internalPointer());
 
-        return createIndex(mParents[event->id()], 0, (quintptr) 0);
+        return createIndex(mParents[event->id()], 0);
     }
 
     return QModelIndex();
index bf4c275846bc06fa6246486e780778610280ebd8..966d3150be155219cee2eeec33606ca565f1786f 100644 (file)
@@ -3,8 +3,8 @@ TEMPLATE = lib
 TARGET = mvc
 DESTDIR = ../bin
 CONFIG += static
-QT += sql \
-    widgets
+QT += sql
+greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
 QMAKE_CLEAN += ../bin/libmvc.a
 
 # module dependencies
index 8c6294dbe1114219d7296b62f14cee474df25db2..9f5b8cdb0959b29a127a7da198b9782ab72c78c1 100644 (file)
 #include <QSqlRecord>
 #include <QVariant>
 #include <QDateTime>
+#include "qglobal.h"
+#if QT_VERSION >= 0x050000
 #include <QStandardPaths>
+#else
+#include <QDesktopServices>
+#endif
 
 #include <QDir>
 #include "sqlengine.h"
@@ -36,7 +41,11 @@ const QString DATE_FORMAT ("yyyy-MM-dd");
 const QString TIME_FORMAT ("hh:mm");
 
 SqlEngine::SqlEngine(QObject *aParent): QObject(aParent) {
+#if QT_VERSION >= 0x050000
     QDir dbPath(QStandardPaths::writableLocation(QStandardPaths::DataLocation));
+#else
+    QDir dbPath(QDesktopServices::storageLocation(QDesktopServices::DataLocation));
+#endif
     dbFilename = dbPath.absoluteFilePath("ConfClerk.sqlite");
 }