aboutsummaryrefslogtreecommitdiff
path: root/notebookview.h
blob: 1b3eb4648b3553bcbbab4994460d349ca5dd94c8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#ifndef NOTEBOOKVIEW_H
#define NOTEBOOKVIEW_H

#include <QtGui/QGraphicsView>
#include <QtGui/QGraphicsItem>
#include "afdnotebook.h"
#include "paperreplay.h"
#include "pageitem.h"

class NotebookView : public QGraphicsView
{
	Q_OBJECT
	Q_PROPERTY(QString notebook WRITE setNotebook READ notebook)
	Q_PROPERTY(QString paperReplay WRITE setPaperReplay READ paperReplay)
	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;

	void setPaperReplay(const QString &path);
	QString paperReplay() const;

	QList<int> pageNumbers() const;

	int curPage() const;
	void setCurPage(int page);

	int zoom() const;

	void requestPaperReplay(const QString &file, qint64 time);

signals:
	void pageNumbersChanged();
	void curPageChanged();
	void zoomChanged();
	void paperReplayRequested(const QString &file, qint64 time);

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();
	bool createPages();
	void calculateScale();

private:
	AfdNotebook *_nb;
	PaperReplay *_replay;
	QString _nbPath;
	QString _replayPath;
	QMap<int, PageItem*> _pages;
	QSizeF _maxPageSize;
	int _zoom;
	int _curPage;
};

#endif // NOTEBOOKVIEW_H