From 41f9a9b0563c3bd523bd534b854e50161a2626b3 Mon Sep 17 00:00:00 2001 From: Javier Date: Sat, 13 Jun 2015 04:24:21 +0200 Subject: continue with paperreplay loading changes --- notebookview.cc | 41 ++++++++++++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 11 deletions(-) (limited to 'notebookview.cc') 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 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 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() -- cgit v1.2.3