diff options
Diffstat (limited to 'notebookview.cc')
-rw-r--r-- | notebookview.cc | 41 |
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() |