Improve chapter navigation: work around a QUrl bug.
authorAkos Polster <akos@pipacs.com>
Sat, 2 Oct 2010 16:48:42 +0000 (18:48 +0200)
committerAkos Polster <akos@pipacs.com>
Sat, 2 Oct 2010 16:48:42 +0000 (18:48 +0200)
bookview.cpp
model/book.cpp
pkg/changelog

index 59fc173..c665865 100644 (file)
@@ -266,6 +266,7 @@ void BookView::mousePressEvent(QMouseEvent *e)
     // Start monitoring kinetic scroll
     if (scrollerMonitor) {
         killTimer(scrollerMonitor);
+        scrollerMonitor = 0;
     }
     if (scroller) {
         scrollerMonitor = startTimer(500);
@@ -395,8 +396,8 @@ void BookView::showProgress()
 
 void BookView::timerEvent(QTimerEvent *e)
 {
-    if (e->timerId() == scrollerMonitor) {
 #ifdef Q_WS_MAEMO_5
+    if (e->timerId() == scrollerMonitor) {
         if (scroller &&
             ((scroller->state() == QAbstractKineticScroller::AutoScrolling) ||
              (scroller->state() == QAbstractKineticScroller::Pushing))) {
@@ -404,8 +405,10 @@ void BookView::timerEvent(QTimerEvent *e)
         } else {
             killTimer(scrollerMonitor);
         }
-#endif // Q_WS_MAEMO_5
     }
+#else
+    Q_UNUSED(e);
+#endif // Q_WS_MAEMO_5
 }
 
 void BookView::keyPressEvent(QKeyEvent* event)
index 599ab8f..92446f5 100644 (file)
@@ -444,27 +444,25 @@ int Book::partFromChapter(int index)
     Trace t("Book::partFromChapter");
     QString id = chapters[index];
     QString href = content[id].href;
-    QString baseRef(href);
-    QUrl url(QString("file://") + href);
-    if (url.hasFragment()) {
-        QString fragment = url.fragment();
-        baseRef.chop(fragment.length() + 1);
+    int hashPos = href.indexOf("#");
+    if (hashPos != -1) {
+        href = href.left(hashPos);
     }
+
     qDebug() << "Chapter" << index;
     qDebug() << " id" << id;
     qDebug() << " href" << href;
-    qDebug() << " base href" << baseRef;
 
     for (int i = 0; i < parts.size(); i++) {
         QString partId = parts[i];
-        if (content[partId].href == baseRef) {
-            qDebug() << "Part index for" << baseRef << "is" << i;
+        if (content[partId].href == href) {
+            qDebug() << "Part index for" << href << "is" << i;
             return i;
         }
     }
 
     qWarning() << "Book::partFromChapter: Could not find part index for"
-            << baseRef;
+            << href;
     return -1;
 }
 
index 282572b..8b088a6 100644 (file)
@@ -4,6 +4,7 @@ dorian (0.2.1-1) unstable; urgency=low
   * Works on Symbian (far from usable)
   * Make modal dialogs closeable on Mac
   * Fix progress and bookmark positions
+  * Improve chapter navigation: Work around a QUrl bug
 
  -- Akos Polster <akos@pipacs.com>  Thu, 16 Sep 2010 02:00:00 +0200