Added next/previous page
authorDmitriy Morozov <dmitriy@mrzv.org>
Mon, 17 Jan 2011 09:08:22 -0800
changeset 8 6e21d1f3b806
parent 7 a01d4a949adf
child 9 6f17855970fc
Added next/previous page
mainwindow.cpp
mainwindow.h
--- a/mainwindow.cpp	Sat Nov 27 09:58:18 2010 -0800
+++ b/mainwindow.cpp	Mon Jan 17 09:08:22 2011 -0800
@@ -68,6 +68,8 @@
 
     iMoveMenu->addAction(new IpeAction(ENextView, "Next view", "PgDown", this));
     iMoveMenu->addAction(new IpeAction(EPreviousView, "Previous view", "PgUp", this));
+    iMoveMenu->addAction(new IpeAction(ENextPage, "Next page", "N", this));
+    iMoveMenu->addAction(new IpeAction(EPreviousPage, "Previous ", "P", this));
     iMoveMenu->addAction(new IpeAction(EFirstView, "First view", "Home", this));
     iMoveMenu->addAction(new IpeAction(ELastView, "Last view", "End", this));
     iMoveMenu->addAction(new IpeAction(EJumpTo, "Jump to...", "J", this));
@@ -134,6 +136,12 @@
         case EPreviousView:
             nextView(-1);
             break;
+        case ENextPage:
+            nextPage(+1);
+            break;
+        case EPreviousPage:
+            nextPage(-1);
+            break;
         case EFirstView:
             firstView();
             break;
@@ -285,6 +293,19 @@
     setView();
 }
 
+void MainWindow::nextPage(int delta)
+{
+    int newPageNo = iPageNo + delta;
+    newPageNo = (newPageNo < 0 ? 0 : newPageNo);
+    newPageNo = (newPageNo > iDoc->countPages() - 1 ? iDoc->countPages() - 1 : newPageNo);
+    if (newPageNo != iPageNo)
+    {
+        iPageNo = newPageNo;
+        iViewNo = 0;
+        setView();
+    }
+}
+
 void MainWindow::firstView()
 {
     iPageNo = 0;
--- a/mainwindow.h	Sat Nov 27 09:58:18 2010 -0800
+++ b/mainwindow.h	Mon Jan 17 09:08:22 2011 -0800
@@ -58,6 +58,7 @@
         { 
             EOpen, EQuit, EFullScreen, EFitPage,
             EZoomIn, EZoomOut, ENextView, EPreviousView, EFirstView, ELastView,
+            ENextPage, EPreviousPage,
             ENumActions, EToggleTimeCounting, ETimeCountdown, ESetTime,
             EJumpTo, EShowPresentation
         };
@@ -67,6 +68,7 @@
 
         // void zoom(int delta);
         void nextView(int delta);
+        void nextPage(int delta);
         void firstView();
         void lastView();
         void fitBox(const Rect &box, Canvas* canvas);