From 79a76710bddc969dada6e3303d553d0d928134be Mon Sep 17 00:00:00 2001 From: gregor herrmann Date: Wed, 30 Aug 2017 21:15:52 +0200 Subject: [PATCH] ifdef qt4 and qt5 --- confclerk.pro | 2 +- src/app/app.pro | 3 ++- src/gui/eventdialog.cpp | 14 +++++++++++--- src/gui/gui.pro | 4 ++-- src/gui/mainwindow.h | 5 +++++ src/gui/searchhead.h | 5 +++++ src/mvc/delegate.h | 5 +++++ src/mvc/eventmodel.cpp | 4 ++-- src/mvc/mvc.pro | 4 ++-- src/sql/sqlengine.cpp | 9 +++++++++ 10 files changed, 44 insertions(+), 11 deletions(-) diff --git a/confclerk.pro b/confclerk.pro index 22f8f79..8171399 100644 --- a/confclerk.pro +++ b/confclerk.pro @@ -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 diff --git a/src/app/app.pro b/src/app/app.pro index 80baf93..37f4f48 100644 --- a/src/app/app.pro +++ b/src/app/app.pro @@ -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 } diff --git a/src/gui/eventdialog.cpp b/src/gui/eventdialog.cpp index 90910c8..4103ad6 100644 --- a/src/gui/eventdialog.cpp +++ b/src/gui/eventdialog.cpp @@ -27,6 +27,14 @@ #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("

%1

\n").arg(event.title().toHtmlEscaped())); + info.append(QString("

%1

\n").arg(toHtmlEscaped(event.title()))); // persons info += QString("

%1

\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("

%1

\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("
  • %2
  • \n").arg(url.toHtmlEscaped(), name.toHtmlEscaped()); + info += QString("
  • %2
  • \n").arg(toHtmlEscaped(url), toHtmlEscaped(name)); } info += QString("\n"); eventInfoTextBrowser->setHtml(info); diff --git a/src/gui/gui.pro b/src/gui/gui.pro index efffb45..cac0bc2 100644 --- a/src/gui/gui.pro +++ b/src/gui/gui.pro @@ -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 diff --git a/src/gui/mainwindow.h b/src/gui/mainwindow.h index 09203e4..91b3c11 100644 --- a/src/gui/mainwindow.h +++ b/src/gui/mainwindow.h @@ -20,7 +20,12 @@ #ifndef MAINWINDOW_H #define MAINWINDOW_H +#include "qglobal.h" +#if QT_VERSION >= 0x050000 #include +#else +#include +#endif #include #include "ui_mainwindow.h" diff --git a/src/gui/searchhead.h b/src/gui/searchhead.h index 2a56d4b..39303f0 100644 --- a/src/gui/searchhead.h +++ b/src/gui/searchhead.h @@ -20,7 +20,12 @@ #ifndef SEARCHHEAD_H #define SEARCHHEAD_H +#include "qglobal.h" +#if QT_VERSION >= 0x050000 #include +#else +#include +#endif #include #include "ui_searchhead.h" diff --git a/src/mvc/delegate.h b/src/mvc/delegate.h index e9f3439..2ee765f 100644 --- a/src/mvc/delegate.h +++ b/src/mvc/delegate.h @@ -20,7 +20,12 @@ #ifndef DELEGATE_H #define DELEGATE_H +#include "qglobal.h" +#if QT_VERSION >= 0x050000 #include +#else +#include +#endif class Delegate : public QItemDelegate { diff --git a/src/mvc/eventmodel.cpp b/src/mvc/eventmodel.cpp index 674bbcd..ff3d0eb 100644 --- a/src/mvc/eventmodel.cpp +++ b/src/mvc/eventmodel.cpp @@ -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(index.internalPointer()); - return createIndex(mParents[event->id()], 0, (quintptr) 0); + return createIndex(mParents[event->id()], 0); } return QModelIndex(); diff --git a/src/mvc/mvc.pro b/src/mvc/mvc.pro index bf4c275..966d315 100644 --- a/src/mvc/mvc.pro +++ b/src/mvc/mvc.pro @@ -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 diff --git a/src/sql/sqlengine.cpp b/src/sql/sqlengine.cpp index 8c6294d..9f5b8cd 100644 --- a/src/sql/sqlengine.cpp +++ b/src/sql/sqlengine.cpp @@ -23,7 +23,12 @@ #include #include #include +#include "qglobal.h" +#if QT_VERSION >= 0x050000 #include +#else +#include +#endif #include #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"); } -- 2.39.5