summaryrefslogtreecommitdiffstats
path: root/packaging/ubuntu/0001-Make-build-with-Qt4.patch
blob: a1e44fe0c88e8ba91089b839f07b9d332ef29220 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
From 936f3bab5be5d6c7d8da0a2d2d7e9da42bcd96c1 Mon Sep 17 00:00:00 2001
From: Dirk Hohndel <dirk@hohndel.org>
Date: Thu, 19 Feb 2015 21:51:22 -0800
Subject: [PATCH] Make build with Qt4

This is just a best effort patch - Qt4 is no longer officially supported

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
---
 helpers.h                          |  1 +
 qt-ui/divelogexportdialog.cpp      |  7 ++++++-
 qt-ui/divelogexportdialog.h        |  4 ++++
 qt-ui/divelogimportdialog.cpp      | 34 ++++++++++++++++++++++++++++++++++
 qt-ui/downloadfromdivecomputer.cpp | 12 ++++++++++++
 qt-ui/plannerSettings.ui           |  4 ++--
 qthelper.cpp                       | 10 ++++++++++
 7 files changed, 69 insertions(+), 3 deletions(-)

diff --git a/helpers.h b/helpers.h
index 885b73e58235..64fdc9ed5d27 100644
--- a/helpers.h
+++ b/helpers.h
@@ -8,6 +8,7 @@
 #define HELPERS_H
 
 #include <QString>
+#include <QPair>
 #include "dive.h"
 #include "qthelper.h"
 
diff --git a/qt-ui/divelogexportdialog.cpp b/qt-ui/divelogexportdialog.cpp
index 43c41550f145..8c6d2899f0f0 100644
--- a/qt-ui/divelogexportdialog.cpp
+++ b/qt-ui/divelogexportdialog.cpp
@@ -1,8 +1,9 @@
 #include <QFileDialog>
 #include <QShortcut>
 #include <QSettings>
+#if QT_VERSION >= 0x050000
 #include <QtConcurrent>
-
+#endif
 #include "divelogexportdialog.h"
 #include "diveshareexportdialog.h"
 #include "ui_divelogexportdialog.h"
@@ -313,7 +314,11 @@ void DiveLogExportDialog::on_buttonBox_accepted()
 		settings.endGroup();
 		// the non XSLT exports are called directly above, the XSLT based ons are called here
 		if (!stylesheet.isEmpty())
+#if QT_VERSION >= 0x050000
 			future = QtConcurrent::run(export_dives_xslt, filename.toUtf8(), ui->exportSelected->isChecked(), ui->CSVUnits_2->currentIndex(), stylesheet.toUtf8());
+#else
+			export_dives_xslt(filename.toUtf8(), ui->exportSelected->isChecked(), ui->CSVUnits_2->currentIndex(), stylesheet.toUtf8());
+#endif
 	}
 }
 
diff --git a/qt-ui/divelogexportdialog.h b/qt-ui/divelogexportdialog.h
index 14f8f453980f..524416414a8e 100644
--- a/qt-ui/divelogexportdialog.h
+++ b/qt-ui/divelogexportdialog.h
@@ -3,7 +3,9 @@
 
 #include <QDialog>
 #include <QTextStream>
+#if QT_VERSION >= 0x050000
 #include <QFuture>
+#endif
 #include "helpers.h"
 #include "statistics.h"
 
@@ -28,7 +30,9 @@ slots:
 	void on_exportGroup_buttonClicked(QAbstractButton *);
 
 private:
+#if QT_VERSION >= 0x050000
 	QFuture<int> future;
+#endif
 	Ui::DiveLogExportDialog *ui;
 	void showExplanation();
 	void exportHtmlInit(const QString &filename);
diff --git a/qt-ui/divelogimportdialog.cpp b/qt-ui/divelogimportdialog.cpp
index ce12ef7ec34b..f4e43ef9068f 100644
--- a/qt-ui/divelogimportdialog.cpp
+++ b/qt-ui/divelogimportdialog.cpp
@@ -377,14 +377,22 @@ void DiveLogImportDialog::loadFileContents(int value, whatChanged triggeredBy)
 		seabear = true;
 		firstLine = "Sample time;Sample depth;Sample NDL;Sample TTS;Sample stopdepth;Sample temperature;Sample pressure";
 		blockSignals(true);
+#if QT_VERSION >= 0x050000
 		ui->knownImports->setCurrentText("Seabear CSV");
+#else
+		ui->knownImports->setCurrentIndex(4);
+#endif
 		blockSignals(false);
 	} else if (firstLine.contains("Tauchgangs-Nr.:")) {
 		xp5 = true;
 		//"Abgelaufene Tauchzeit (Std:Min.)\tTiefe\tStickstoff Balkenanzeige\tSauerstoff Balkenanzeige\tAufstiegsgeschwindigkeit\tRestluftzeit\tRestliche Tauchzeit\tDekompressionszeit (Std:Min)\tDekostopp-Tiefe\tTemperatur\tPO2\tPressluftflasche\tLesen des Druckes\tStatus der Verbindung\tTauchstatus";
 		firstLine = "Sample time\tSample depth\t\t\t\t\t\t\t\tSample temperature\t";
 		blockSignals(true);
+#if QT_VERSION >= 0x050000
 		ui->knownImports->setCurrentText("XP5");
+#else
+		ui->knownImports->setCurrentIndex(2);
+#endif
 		blockSignals(false);
 	}
 
@@ -393,9 +401,17 @@ void DiveLogImportDialog::loadFileContents(int value, whatChanged triggeredBy)
 		apd=true;
 		firstLine = "Sample time\tSample depth\t\t\t\t\tSample pO₂\t\t\t\t\t\t\t\t\tSample temperature\t\tSample CNS\tSample stopdepth";
 		blockSignals(true);
+#if QT_VERSION >= 0x050000
 		ui->CSVSeparator->setCurrentText(tr("Tab"));
+#else
+		ui->CSVSeparator->setCurrentIndex(0);
+#endif
 		if (triggeredBy == INITIAL && fileNames.first().contains(".apd", Qt::CaseInsensitive))
+#if QT_VERSION >= 0x050000
 			ui->knownImports->setCurrentText("APD Log Viewer");
+#else
+			ui->knownImports->setCurrentIndex(1);
+#endif
 		blockSignals(false);
 	}
 
@@ -414,7 +430,16 @@ void DiveLogImportDialog::loadFileContents(int value, whatChanged triggeredBy)
 			separator = ";";
 		if (ui->CSVSeparator->currentText() != separator) {
 			blockSignals(true);
+#if QT_VERSION >= 0x050000
 			ui->CSVSeparator->setCurrentText(separator);
+#else
+			if (separator == "Tab")
+				ui->CSVSeparator->setCurrentIndex(0);
+			else if (separator == ",")
+				ui->CSVSeparator->setCurrentIndex(1);
+			else
+				ui->CSVSeparator->setCurrentIndex(2);
+#endif
 			blockSignals(false);
 			currColumns = firstLine.split(separator);
 		}
@@ -465,7 +490,16 @@ void DiveLogImportDialog::loadFileContents(int value, whatChanged triggeredBy)
 
 		if (ui->CSVSeparator->currentText() != separator || separator == "Tab") {
 			ui->CSVSeparator->blockSignals(true);
+#if QT_VERSION >= 0x050000
 			ui->CSVSeparator->setCurrentText(separator);
+#else
+			if (separator == "Tab")
+				ui->CSVSeparator->setCurrentIndex(0);
+			else if (separator == ",")
+				ui->CSVSeparator->setCurrentIndex(1);
+			else
+				ui->CSVSeparator->setCurrentIndex(2);
+#endif
 			ui->CSVSeparator->blockSignals(false);
 			if (separator == "Tab")
 				separator = "\t";
diff --git a/qt-ui/downloadfromdivecomputer.cpp b/qt-ui/downloadfromdivecomputer.cpp
index c57aa1ef2c00..4e5b27c6b21f 100644
--- a/qt-ui/downloadfromdivecomputer.cpp
+++ b/qt-ui/downloadfromdivecomputer.cpp
@@ -602,19 +602,31 @@ QVariant DiveImportedModel::data(const QModelIndex &index, int role) const
 void DiveImportedModel::changeSelected(QModelIndex clickedIndex)
 {
 	checkStates[clickedIndex.row()] = !checkStates[clickedIndex.row()];
+#if QT_VERSION >= 0x050000
 	dataChanged(index(0, clickedIndex.row()), index(0, clickedIndex.row()), QVector<int>() << Qt::CheckStateRole);
+#else
+	dataChanged(index(0, clickedIndex.row()), index(0, clickedIndex.row()));
+#endif
 }
 
 void DiveImportedModel::selectAll()
 {
 	memset(checkStates, true, lastIndex - firstIndex + 1);
+#if QT_VERSION >= 0x050000
 	dataChanged(index(0, 0), index(0, lastIndex - firstIndex), QVector<int>() << Qt::CheckStateRole);
+#else
+	dataChanged(index(0, 0), index(0, lastIndex - firstIndex));
+#endif
 }
 
 void DiveImportedModel::selectNone()
 {
 	memset(checkStates, false, lastIndex - firstIndex + 1);
+#if QT_VERSION >= 0x050000
 	dataChanged(index(0, 0), index(0, lastIndex - firstIndex), QVector<int>() << Qt::CheckStateRole);
+#else
+	dataChanged(index(0, 0), index(0, lastIndex - firstIndex ));
+#endif
 }
 
 Qt::ItemFlags DiveImportedModel::flags(const QModelIndex &index) const
diff --git a/qt-ui/plannerSettings.ui b/qt-ui/plannerSettings.ui
index 440fb534a6b5..89ffc89e1c38 100644
--- a/qt-ui/plannerSettings.ui
+++ b/qt-ui/plannerSettings.ui
@@ -338,8 +338,8 @@
           </item>
           <item row="5" column="1">
            <widget class="QComboBox" name="rebreathermode">
-            <property name="currentText">
-             <string/>
+            <property name="currentIndex">
+		    <number>0</number>
             </property>
             <property name="maxVisibleItems">
              <number>6</number>
diff --git a/qthelper.cpp b/qthelper.cpp
index b26bdf467dec..1981571b2007 100644
--- a/qthelper.cpp
+++ b/qthelper.cpp
@@ -12,6 +12,7 @@
 #include <QDir>
 #include <QDebug>
 #include <QSettings>
+#if QT_VERSION >= 0x050000
 #include <QStandardPaths>
 #include <QJsonDocument>
 #include <QJsonArray>
@@ -21,6 +22,9 @@
 #include <QNetworkAccessManager>
 #include <QUrlQuery>
 #include <QEventLoop>
+#else
+#include <QDesktopServices>
+#endif
 
 #include <libxslt/documents.h>
 
@@ -304,6 +308,7 @@ extern "C" const char *system_default_directory(void)
 	static char filename[PATH_MAX];
 
 	if (!*filename) {
+#if QT_VERSION >= 0x050000
 		enum QStandardPaths::StandardLocation location;
 #if QT_VERSION >= 0x050400
 		location = QStandardPaths::AppDataLocation;
@@ -311,6 +316,9 @@ extern "C" const char *system_default_directory(void)
 		location = QStandardPaths::DataLocation;
 #endif
 		QString name = QStandardPaths::standardLocations(location).first();
+#else
+		QString name = QDesktopServices::storageLocation(QDesktopServices::DataLocation);
+#endif
 		QDir dir(name);
 		dir.mkpath(name);
 		// Why no "dir.encodeName()"? Crazy Qt
@@ -379,6 +387,7 @@ void selectedDivesGasUsed(QVector<QPair<QString, int> > &gasUsedOrdered)
 
 extern "C" void reverseGeoLookup(degrees_t latitude, degrees_t longitude, uint32_t uuid)
 {
+#if QT_VERSION >= 0x050000
 	QNetworkRequest request;
 	QNetworkAccessManager *rgl = new QNetworkAccessManager();
 	request.setUrl(QString("http://open.mapquestapi.com/nominatim/v1/reverse.php?format=json&accept-language=%1&lat=%2&lon=%3")
@@ -400,4 +409,5 @@ extern "C" void reverseGeoLookup(degrees_t latitude, degrees_t longitude, uint32
 		struct dive_site *ds = get_dive_site_by_uuid(uuid);
 		ds->notes = add_to_string(ds->notes, "countrytag: %s", address.value("country").toString().toUtf8().data());
 	}
+#endif
 }
-- 
1.8.0.rc0.18.gf84667d