aboutsummaryrefslogtreecommitdiff
path: root/notebookview.h
diff options
context:
space:
mode:
authorJavier <dev.git@javispedro.com>2015-06-07 21:22:45 +0200
committerJavier <dev.git@javispedro.com>2015-06-07 21:22:45 +0200
commita69e97943539a8abc4d2762638c169dc19c88516 (patch)
treef3516ea29745db65971247cee4c260b49f1067b2 /notebookview.h
downloadscribiu-a69e97943539a8abc4d2762638c169dc19c88516.tar.gz
scribiu-a69e97943539a8abc4d2762638c169dc19c88516.zip
initial import
Diffstat (limited to 'notebookview.h')
-rw-r--r--notebookview.h59
1 files changed, 59 insertions, 0 deletions
diff --git a/notebookview.h b/notebookview.h
new file mode 100644
index 0000000..e51afa3
--- /dev/null
+++ b/notebookview.h
@@ -0,0 +1,59 @@
+#ifndef NOTEBOOKVIEW_H
+#define NOTEBOOKVIEW_H
+
+#include <QtGui/QGraphicsView>
+#include <QtGui/QGraphicsItem>
+#include "afdnotebook.h"
+#include "pageitem.h"
+
+class NotebookView : public QGraphicsView
+{
+ Q_OBJECT
+ Q_PROPERTY(QString notebook WRITE setNotebook READ notebook)
+ Q_PROPERTY(QList<int> pageNumbers READ pageNumbers NOTIFY pageNumbersChanged)
+ Q_PROPERTY(int curPage READ curPage WRITE setCurPage NOTIFY curPageChanged)
+ Q_PROPERTY(int zoom READ zoom WRITE setZoom NOTIFY zoomChanged)
+
+public:
+ explicit NotebookView(QWidget *parent = 0);
+
+ void setNotebook(const QString &path);
+ QString notebook() const;
+
+ QList<int> pageNumbers() const;
+
+ int curPage() const;
+ void setCurPage(int page);
+
+ int zoom() const;
+
+signals:
+ void pageNumbersChanged();
+ void curPageChanged();
+ void zoomChanged();
+
+public slots:
+ void clear();
+ void setZoom(int zoom);
+ void prevPage();
+ void nextPage();
+
+protected:
+ void resizeEvent(QResizeEvent *event);
+ void scrollContentsBy(int dx, int dy);
+
+private:
+ void removePages();
+ void createPages();
+ void calculateScale();
+
+private:
+ AfdNotebook *_nb;
+ QString _nbPath;
+ QMap<int, PageItem*> _pages;
+ QSizeF _maxPageSize;
+ int _zoom;
+ int _curPage;
+};
+
+#endif // NOTEBOOKVIEW_H