| 1 |
From: "Dr. Tobias Quathamer" <[email protected]> |
| 2 |
Date: Mon, 11 Jan 2016 12:10:12 +0100 |
| 3 |
Subject: Update code to work with Qt5 |
| 4 |
|
| 5 |
--- |
| 6 |
qbrew.pro | 2 ++ |
| 7 |
src/configstate.h | 2 +- |
| 8 |
src/databasetool.cpp | 8 ++++---- |
| 9 |
src/grainmodel.cpp | 3 ++- |
| 10 |
src/hopmodel.cpp | 3 ++- |
| 11 |
src/main.cpp | 4 ++-- |
| 12 |
src/miscmodel.cpp | 3 ++- |
| 13 |
src/qbrew.cpp | 12 ++++++------ |
| 14 |
src/resource.h | 4 ++-- |
| 15 |
src/stylemodel.cpp | 3 ++- |
| 16 |
src/view.cpp | 6 +++--- |
| 17 |
11 files changed, 28 insertions(+), 22 deletions(-) |
| 18 |
|
| 19 |
diff --git a/qbrew.pro b/qbrew.pro |
| 20 |
index 02f437a..af0632f 100755 |
| 21 |
--- a/qbrew.pro |
| 22 |
+++ b/qbrew.pro |
| 23 |
@@ -7,6 +7,8 @@ TARGET = qbrew |
| 24 |
TEMPLATE = app |
| 25 |
CONFIG += qt warn_on |
| 26 |
|
| 27 |
+QT += widgets printsupport |
| 28 |
+ |
| 29 |
MOC_DIR = build |
| 30 |
OBJECTS_DIR = build |
| 31 |
RCC_DIR = build |
| 32 |
diff --git a/src/configstate.h b/src/configstate.h |
| 33 |
index 400e355..c729023 100644 |
| 34 |
--- a/src/configstate.h |
| 35 |
+++ b/src/configstate.h |
| 36 |
@@ -38,7 +38,7 @@ |
| 37 |
#include "resource.h" |
| 38 |
|
| 39 |
struct WinConfigState { |
| 40 |
|
| 41 |
+#if defined (Q_OS_MAC) |
| 42 |
WinConfigState() : statusbar(true) { ; } |
| 43 |
#else |
| 44 |
WinConfigState() : statusbar(false) { ; } |
| 45 |
diff --git a/src/databasetool.cpp b/src/databasetool.cpp |
| 46 |
index c2d06bd..80d5b90 100644 |
| 47 |
--- a/src/databasetool.cpp |
| 48 |
+++ b/src/databasetool.cpp |
| 49 |
@@ -65,7 +65,7 @@ DatabaseTool::DatabaseTool(QWidget* parent) |
| 50 |
|
| 51 |
grainpage.view->verticalHeader()->setDefaultSectionSize(mh); |
| 52 |
grainpage.view->verticalHeader()->hide(); |
| 53 |
|
| 54 |
+ grainpage.view->horizontalHeader()->setSectionsClickable(true); |
| 55 |
grainpage.view->horizontalHeader()->setHighlightSections(false); |
| 56 |
|
| 57 |
grainpage.view->setColumnWidth(GrainModel::NAME, 20*mw); |
| 58 |
@@ -88,7 +88,7 @@ DatabaseTool::DatabaseTool(QWidget* parent) |
| 59 |
|
| 60 |
hoppage.view->verticalHeader()->setDefaultSectionSize(mh); |
| 61 |
hoppage.view->verticalHeader()->hide(); |
| 62 |
|
| 63 |
+ hoppage.view->horizontalHeader()->setSectionsClickable(true); |
| 64 |
hoppage.view->horizontalHeader()->setHighlightSections(false); |
| 65 |
|
| 66 |
hoppage.view->setColumnHidden(HopModel::WEIGHT, true); |
| 67 |
@@ -110,7 +110,7 @@ DatabaseTool::DatabaseTool(QWidget* parent) |
| 68 |
|
| 69 |
miscpage.view->verticalHeader()->setDefaultSectionSize(mh); |
| 70 |
miscpage.view->verticalHeader()->hide(); |
| 71 |
|
| 72 |
+ miscpage.view->horizontalHeader()->setSectionsClickable(true); |
| 73 |
miscpage.view->horizontalHeader()->setHighlightSections(false); |
| 74 |
|
| 75 |
miscpage.view->setColumnHidden(MiscModel::QUANTITY, true); |
| 76 |
@@ -131,7 +131,7 @@ DatabaseTool::DatabaseTool(QWidget* parent) |
| 77 |
|
| 78 |
stylepage.view->verticalHeader()->setDefaultSectionSize(mh); |
| 79 |
stylepage.view->verticalHeader()->hide(); |
| 80 |
|
| 81 |
+ stylepage.view->horizontalHeader()->setSectionsClickable(true); |
| 82 |
stylepage.view->horizontalHeader()->setHighlightSections(false); |
| 83 |
|
| 84 |
stylepage.view->setColumnWidth(StyleModel::NAME, 20*mw); |
| 85 |
diff --git a/src/grainmodel.cpp b/src/grainmodel.cpp |
| 86 |
index 78f0269..0b57340 100644 |
| 87 |
--- a/src/grainmodel.cpp |
| 88 |
+++ b/src/grainmodel.cpp |
| 89 |
@@ -35,10 +35,11 @@ GrainModel::~GrainModel(){} |
| 90 |
// flush() |
| 91 |
// ------- |
| 92 |
// Reset the model |
| 93 |
+// The reset() method is obsolete with Qt5. |
| 94 |
|
| 95 |
void GrainModel::flush() |
| 96 |
{ |
| 97 |
|
| 98 |
+// reset(); |
| 99 |
} |
| 100 |
|
| 101 |
////////////////////////////////////////////////////////////////////////////// |
| 102 |
diff --git a/src/hopmodel.cpp b/src/hopmodel.cpp |
| 103 |
index fe3d1f1..fd13e04 100644 |
| 104 |
--- a/src/hopmodel.cpp |
| 105 |
+++ b/src/hopmodel.cpp |
| 106 |
@@ -31,10 +31,11 @@ HopModel::~HopModel() {} |
| 107 |
// flush() |
| 108 |
// ------- |
| 109 |
// Reset the model |
| 110 |
+// The reset() method is obsolete with Qt5. |
| 111 |
|
| 112 |
void HopModel::flush() |
| 113 |
{ |
| 114 |
|
| 115 |
+// reset(); |
| 116 |
} |
| 117 |
|
| 118 |
////////////////////////////////////////////////////////////////////////////// |
| 119 |
diff --git a/src/main.cpp b/src/main.cpp |
| 120 |
index aa9b267..0699ad7 100644 |
| 121 |
--- a/src/main.cpp |
| 122 |
+++ b/src/main.cpp |
| 123 |
@@ -40,7 +40,7 @@ |
| 124 |
#include <QTextStream> |
| 125 |
#include <QTranslator> |
| 126 |
|
| 127 |
|
| 128 |
+#if defined(Q_OS_MAC) |
| 129 |
extern void qt_mac_set_menubar_icons(bool enable); |
| 130 |
#endif |
| 131 |
|
| 132 |
@@ -130,7 +130,7 @@ int main(int argc, char **argv) |
| 133 |
app.setApplicationName(PACKAGE); |
| 134 |
app.setOrganizationName(TITLE); |
| 135 |
|
| 136 |
|
| 137 |
+#if defined(Q_OS_MAC) |
| 138 |
// disable icons on Mac menus (as is customary) |
| 139 |
qt_mac_set_menubar_icons(false); |
| 140 |
#endif |
| 141 |
diff --git a/src/miscmodel.cpp b/src/miscmodel.cpp |
| 142 |
index d2ffde5..d7c75f9 100644 |
| 143 |
--- a/src/miscmodel.cpp |
| 144 |
+++ b/src/miscmodel.cpp |
| 145 |
@@ -31,10 +31,11 @@ MiscModel::~MiscModel() {} |
| 146 |
// flush() |
| 147 |
// ------- |
| 148 |
// Reset the model |
| 149 |
+// The reset() method is obsolete with Qt5. |
| 150 |
|
| 151 |
void MiscModel::flush() |
| 152 |
{ |
| 153 |
|
| 154 |
+// reset(); |
| 155 |
} |
| 156 |
|
| 157 |
////////////////////////////////////////////////////////////////////////////// |
| 158 |
diff --git a/src/qbrew.cpp b/src/qbrew.cpp |
| 159 |
index 88aed0d..a1b36d2 100755 |
| 160 |
--- a/src/qbrew.cpp |
| 161 |
+++ b/src/qbrew.cpp |
| 162 |
@@ -7,7 +7,7 @@ |
| 163 |
Please see the header file for copyright and license information. |
| 164 |
***************************************************************************/ |
| 165 |
|
| 166 |
|
| 167 |
+#include <QtWidgets> |
| 168 |
|
| 169 |
#include "alcoholtool.h" |
| 170 |
#include "configure.h" |
| 171 |
@@ -73,7 +73,7 @@ void QBrew::initialize(const QString &filename) |
| 172 |
// setup UI |
| 173 |
ui.setupUi(this); |
| 174 |
initActions(); |
| 175 |
|
| 176 |
+#if defined (Q_OS_MAC) |
| 177 |
// initial defaults for mac |
| 178 |
setUnifiedTitleAndToolBarOnMac(false); |
| 179 |
ui.maintoolbar->setVisible(false); |
| 180 |
@@ -1248,7 +1248,7 @@ QString QBrew::dataBase() |
| 181 |
// TODO: can QDesktopServices help us here? |
| 182 |
QString base = qApp->applicationDirPath(); |
| 183 |
|
| 184 |
|
| 185 |
+#if defined(Q_OS_UNIX) |
| 186 |
if (QRegExp("qbrew/?$").indexIn(base) != -1) { |
| 187 |
// we have our own application directory (it ends in 'qbrew') |
| 188 |
base += "/"; |
| 189 |
@@ -1260,7 +1260,7 @@ QString QBrew::dataBase() |
| 190 |
base += "/"; |
| 191 |
} |
| 192 |
|
| 193 |
|
| 194 |
+#elif defined(Q_OS_MAC) |
| 195 |
if (QRegExp("Contents/MacOS/?$").indexIn(base) != -1) { |
| 196 |
// we're pointing inside an application bundle |
| 197 |
base += "/../Resources/"; |
| 198 |
@@ -1284,7 +1284,7 @@ QString QBrew::docBase() |
| 199 |
{ |
| 200 |
QString base = qApp->applicationDirPath(); |
| 201 |
|
| 202 |
|
| 203 |
+#if defined(Q_OS_UNIX) |
| 204 |
if (QRegExp("qbrew/?$").indexIn(base) != -1) { |
| 205 |
// we have our own application directory (it ends in 'qbrew') |
| 206 |
base += "/doc/"; |
| 207 |
@@ -1296,7 +1296,7 @@ QString QBrew::docBase() |
| 208 |
base += "/doc/"; |
| 209 |
} |
| 210 |
|
| 211 |
|
| 212 |
+#elif defined(Q_OS_MAC) |
| 213 |
if (QRegExp("Contents/MacOS/?$").indexIn(base) != -1) { |
| 214 |
// we're pointing inside an application bundle |
| 215 |
base += "/../Resources/en.lproj/"; |
| 216 |
diff --git a/src/resource.h b/src/resource.h |
| 217 |
index 98e76cb..6044160 100644 |
| 218 |
--- a/src/resource.h |
| 219 |
+++ b/src/resource.h |
| 220 |
@@ -40,9 +40,9 @@ |
| 221 |
#define VERSION "0.4.1" |
| 222 |
|
| 223 |
// some stuff to differentiate between platforms |
| 224 |
|
| 225 |
+#if defined(Q_OS_UNIX) |
| 226 |
#define QDIR_HOME QDir::homePath() |
| 227 |
|
| 228 |
+#elif defined(Q_OS_MAC) |
| 229 |
#define QDIR_HOME QDir::homePath() |
| 230 |
#else |
| 231 |
#define QDIR_HOME QDir::currentPath() |
| 232 |
diff --git a/src/stylemodel.cpp b/src/stylemodel.cpp |
| 233 |
index be53317..389b756 100644 |
| 234 |
--- a/src/stylemodel.cpp |
| 235 |
+++ b/src/stylemodel.cpp |
| 236 |
@@ -31,10 +31,11 @@ StyleModel::~StyleModel(){} |
| 237 |
// flush() |
| 238 |
// ------- |
| 239 |
// Reset the model |
| 240 |
+// The reset() method is obsolete with Qt5. |
| 241 |
|
| 242 |
void StyleModel::flush() |
| 243 |
{ |
| 244 |
|
| 245 |
+// reset(); |
| 246 |
} |
| 247 |
|
| 248 |
////////////////////////////////////////////////////////////////////////////// |
| 249 |
diff --git a/src/view.cpp b/src/view.cpp |
| 250 |
index b520e88..56e41f8 100644 |
| 251 |
--- a/src/view.cpp |
| 252 |
+++ b/src/view.cpp |
| 253 |
@@ -72,7 +72,7 @@ View::View(QWidget *parent, Recipe *recipe) |
| 254 |
|
| 255 |
grainpage.view->verticalHeader()->setDefaultSectionSize(mh); |
| 256 |
grainpage.view->verticalHeader()->hide(); |
| 257 |
|
| 258 |
+ grainpage.view->horizontalHeader()->setSectionsClickable(true); |
| 259 |
grainpage.view->horizontalHeader()->setHighlightSections(false); |
| 260 |
|
| 261 |
grainpage.view->setColumnWidth(GrainModel::NAME, 20*mw); |
| 262 |
@@ -94,7 +94,7 @@ View::View(QWidget *parent, Recipe *recipe) |
| 263 |
|
| 264 |
hoppage.view->verticalHeader()->setDefaultSectionSize(mh); |
| 265 |
hoppage.view->verticalHeader()->hide(); |
| 266 |
|
| 267 |
+ hoppage.view->horizontalHeader()->setSectionsClickable(true); |
| 268 |
hoppage.view->horizontalHeader()->setHighlightSections(false); |
| 269 |
|
| 270 |
hoppage.view->setColumnWidth(HopModel::NAME, 20*mw); |
| 271 |
@@ -115,7 +115,7 @@ View::View(QWidget *parent, Recipe *recipe) |
| 272 |
|
| 273 |
miscpage.view->verticalHeader()->setDefaultSectionSize(mh); |
| 274 |
miscpage.view->verticalHeader()->hide(); |
| 275 |
|
| 276 |
+ miscpage.view->horizontalHeader()->setSectionsClickable(true); |
| 277 |
miscpage.view->horizontalHeader()->setHighlightSections(false); |
| 278 |
|
| 279 |
miscpage.view->setColumnWidth(MiscModel::NAME, 20*mw); |