aboutsummaryrefslogtreecommitdiff
path: root/notebookview.cc
diff options
context:
space:
mode:
authorJavier <dev.git@javispedro.com>2015-06-13 04:24:21 +0200
committerJavier <dev.git@javispedro.com>2015-06-13 04:24:21 +0200
commit41f9a9b0563c3bd523bd534b854e50161a2626b3 (patch)
tree8c30aacdb80e26fd4202d345b30cab84ba437437 /notebookview.cc
parent6cb50e66f3c196a2a4bcc95a419260d6b8c2461f (diff)
downloadscribiu-41f9a9b0563c3bd523bd534b854e50161a2626b3.tar.gz
scribiu-41f9a9b0563c3bd523bd534b854e50161a2626b3.zip
continue with paperreplay loading changes
Diffstat (limited to 'notebookview.cc')
-rw-r--r--notebookview.cc41
1 files changed, 30 insertions, 11 deletions
diff --git a/notebookview.cc b/notebookview.cc
index 2605792..aa37ac9 100644
--- a/notebookview.cc
+++ b/notebookview.cc
@@ -6,7 +6,7 @@
#define PAGE_SEPARATION 100
NotebookView::NotebookView(QWidget *parent) :
- QGraphicsView(parent), _nb(new AfdNotebook(this)),
+ QGraphicsView(parent), _nb(new AfdNotebook(this)), _replay(new PaperReplay(this)),
_zoom(100), _curPage(0)
{
setScene(new QGraphicsScene(this));
@@ -18,14 +18,11 @@ NotebookView::NotebookView(QWidget *parent) :
void NotebookView::setNotebook(const QString &path)
{
removePages();
+
+ _nbPath = path;
+
if (!path.isEmpty()) {
- if (_nb->open(path)) {
- _nbPath = path;
- if (_zoom > 100) {
- _zoom = 100;
- emit zoomChanged();
- }
- createPages();
+ if (createPages()) {
emit pageNumbersChanged();
if (!_pages.isEmpty()) {
_curPage = _pages.begin().key();
@@ -43,6 +40,17 @@ QString NotebookView::notebook() const
return _nbPath;
}
+void NotebookView::setPaperReplay(const QString &path)
+{
+ _replayPath = path;
+ // TODO reload; for now, please set this before the notebook
+}
+
+QString NotebookView::paperReplay() const
+{
+ return _replayPath;
+}
+
QList<int> NotebookView::pageNumbers() const
{
return _pages.keys();
@@ -132,16 +140,25 @@ void NotebookView::removePages()
scene()->clear();
scene()->setSceneRect(QRectF());
_nb->close();
- _nbPath.clear();
+ _replay->close();
_maxPageSize.setWidth(0);
_maxPageSize.setHeight(0);
+ if (_zoom > 100) {
+ _zoom = 100;
+ emit zoomChanged();
+ }
resetTransform();
}
-void NotebookView::createPages()
+bool NotebookView::createPages()
{
+ if (!_nb->open(_nbPath)) return false;
+
QStringList pens = _nb->penSerials();
- if (pens.isEmpty()) return;
+ if (pens.isEmpty()) return false;
+
+ // Failure to open paperreplay data is not fatal
+ _replay->open(_replayPath, pens[0], _nb->guid());
QList<int> pagesWithStrokes = _nb->pagesWithStrokes(pens.first());
Q_ASSERT(_pages.isEmpty());
@@ -173,6 +190,8 @@ void NotebookView::createPages()
}
scene()->setSceneRect(0, 0, _maxPageSize.width(), curY);
+
+ return true;
}
void NotebookView::calculateScale()