Hi Chris, Merkaartoranians,

On Fri, Oct 08, 2010 at 01:10:14 -0700, Chris Browet wrote:
> Not quite true. As of june 1st, it compiled fine under Qt 4.4.3.

I was the one who had reported success with Qt 4.4.3, and had pointed
out one or two incompatibilites.

> Although I don't have a Qt 4.4.X anymore, I'll keep Merkaartor compatible if
> compatibility problems are reported to me (although 3 majors version has
> passed, now, and 2 majors for all distros).

In the meantime (since 0.16.1), a few 4.5-isms and even 4.6-isms have
crept in. I have attempted to work around them with the attached patch.
It "works for me", again with Qt 4.4.3.

Note that I'm building with something like
  qmake Merkaartor.pro PREFIX=${PREFIX} NODEBUG=1 GEOIMAGE=0 GPSD=1 \
  GDAL=0 NVIDIA_HACK=1 FORCE_CUSTOM_STYLE=1 USE_BUILTIN_BOOST=1
  TRANSDIR_SYSTEM="${QTDIR}/translations"
so many feature paths (covered by gdal, geoimage) are not checked!

One would either need to try to build the full-featured merkaartor on
such a system (I'm not willing to try, due to all the missing libs and
their additional dependencies), or we'd have to review the used Qt
functions piece by piece and check their documentation for "was
introduced in". And even that is not sufficient, see:
http://doc.trolltech.com/4.5/qprintpreviewdialog.html#printer
which was introduced in 4.5, but is not described as such.

Until then, Qt < 4.5 is just "best effort". But you should try to get
rid of the 4.6-isms to increase the number of supported platforms.

Note that in the attached patch, indentation is not fully correct, to
keep the amount of diff low. Furthermore, I did some mimicing to
recreate QUrl::fromUserInput(), but that makes some small assumptions.
Some quessing about the constraints was done from my side. A different
"fix" might be better.

Moritz
diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp
index 33ef2bb..f6d19d8 100644
--- a/src/MainWindow.cpp
+++ b/src/MainWindow.cpp
@@ -2029,12 +2029,7 @@ void 
MainWindow::on_roadAddStreetNumbersAction_triggered()
 
 void MainWindow::on_roadSubdivideAction_triggered()
 {
-    QInputDialog *Dlg = new QInputDialog(this);
-    Dlg->setInputMode(QInputDialog::IntInput);
-    Dlg->setIntRange(2, 99);
-    Dlg->setLabelText(tr("Number of segments to divide into"));
-    if (Dlg->exec() == QDialog::Accepted) {
-        int divisions = Dlg->intValue();
+    int divisions = QInputDialog::getInteger(this, MainWindow::tr("Number of 
segments to divide into"), MainWindow::tr("Specify the number of segments"), 2, 
99);
         CommandList* theList = new CommandList(MainWindow::tr("Subdivide road 
into %1").arg(divisions), NULL);
         subdivideRoad(theDocument, theList, p->theProperties, divisions);
         if (theList->empty())
@@ -2043,8 +2038,6 @@ void MainWindow::on_roadSubdivideAction_triggered()
             theDocument->addHistory(theList);
             invalidateView();
         }
-    }
-    delete Dlg;
 }
 
 void MainWindow::on_roadAxisAlignAction_triggered()
@@ -2923,9 +2916,9 @@ void MainWindow::on_editSelectAction_triggered()
             terms.append(t);
         }
 
-        if (terms.length()) {
-            out += terms[terms.length()-1]->asExpression(true);
-            for (int i=terms.length()-2; i>=0; --i) {
+        if (terms.count()) {
+            out += terms[terms.count()-1]->asExpression(true);
+            for (int i=terms.count()-2; i>=0; --i) {
                 out += " and parent(";
                 out += terms[i]->asExpression(true);
                 out += ") ";
diff --git a/src/Preferences/MerkaartorPreferences.cpp 
b/src/Preferences/MerkaartorPreferences.cpp
index 63d0c33..f52a1d9 100644
--- a/src/Preferences/MerkaartorPreferences.cpp
+++ b/src/Preferences/MerkaartorPreferences.cpp
@@ -964,7 +964,26 @@ QString MerkaartorPreferences::getOsmWebsite() const
     else
         s = "www.openstreetmap.org";
 
+#if (QT_VERSION >= QT_VERSION_CHECK(4, 6, 0))
     QUrl u = QUrl::fromUserInput(s);
+#else
+    // convenience for creating a valid URL
+    // fails miserably if QString s already contains a schema
+    QString h; // intermediate host
+    QString p; // intermediate path
+
+    int slashpos = s.indexOf('/');
+    if (slashpos >= 1) // there's a path element in s
+    {
+        h = s.left(slashpos);
+        p = s.right(s.size() - 1 - slashpos);
+    }
+
+    QUrl u;
+    u.setHost(h);
+    u.setScheme("http");
+    u.setPath(p);
+#endif
     if (u.path().isEmpty())
         u.setPath("/api/" + apiVersion());
 
@@ -1298,7 +1317,7 @@ QNetworkProxy MerkaartorPreferences::getProxy(const QUrl 
& requestUrl)
             return theProxy;
         }
 #endif
-#if QT_VERSION >= 0x040500
+#if (QT_VERSION >= QT_VERSION_CHECK(4, 5, 0))
         // Ask Qt for the system proxy (Qt >= 4.5.0), libproxy is preferred if 
available since QNetworkProxyFactory
         // doesn't yet support auto-config (PAC) on MacOS or system settings 
on linux while libproxy does
         QList<QNetworkProxy> systemProxies = 
QNetworkProxyFactory::systemProxyForQuery(
diff --git a/src/Render/NativeRenderDialog.cpp 
b/src/Render/NativeRenderDialog.cpp
index a75cdc3..a601295 100644
--- a/src/Render/NativeRenderDialog.cpp
+++ b/src/Render/NativeRenderDialog.cpp
@@ -158,7 +158,11 @@ void NativeRenderDialog::exportPDF()
     if (s.isNull())
         return;
 
+#if (QT_VERSION >= QT_VERSION_CHECK(4, 5, 0))
     QPrinter* prt = preview->printer();
+#else
+    QPrinter* prt = thePrinter;
+#endif
     prt->setOutputFormat(QPrinter::PdfFormat);
     prt->setOutputFileName(s);
     print(prt);
@@ -170,7 +174,11 @@ void NativeRenderDialog::exportRaster()
     if (s.isNull())
         return;
 
+#if (QT_VERSION >= QT_VERSION_CHECK(4, 5, 0))
     QRect theR = preview->printer()->pageRect();
+#else
+    QRect theR = thePrinter->pageRect();
+#endif
     theR.moveTo(0, 0);
 
     QPixmap pix(theR.size());
@@ -195,11 +203,15 @@ void NativeRenderDialog::exportSVG()
         return;
 
     QSvgGenerator svgg;
+#if (QT_VERSION >= QT_VERSION_CHECK(4, 5, 0))
     QRect theR = preview->printer()->pageRect();
+#else
+    QRect theR = thePrinter->pageRect();
+#endif
     theR.moveTo(0, 0);
     svgg.setSize(theR.size());
     svgg.setFileName(s);
-#if QT_VERSION >= 0x040500
+#if (QT_VERSION >= QT_VERSION_CHECK(4, 5, 0))
         svgg.setViewBox(theR);
 #endif
 
_______________________________________________
Merkaartor mailing list
[email protected]
http://lists.openstreetmap.org/listinfo/merkaartor

Reply via email to