diff options
Diffstat (limited to 'mainwindow.cc')
-rw-r--r-- | mainwindow.cc | 41 |
1 files changed, 35 insertions, 6 deletions
diff --git a/mainwindow.cc b/mainwindow.cc index e269c61..dd687a2 100644 --- a/mainwindow.cc +++ b/mainwindow.cc @@ -8,7 +8,9 @@ MainWindow::MainWindow(QWidget *parent) : _notebooks(new NotebookModel(this)), _manager(new SmartpenManager(this)), _media(new Phonon::MediaObject(this)), - _mediaOutput(new Phonon::AudioOutput(this)) + _mediaOutput(new Phonon::AudioOutput(this)), + _replay(new PaperReplay(this)), + _replayModel(new PaperReplayModel(_replay, this)) { ui->setupUi(this); ui->notebookTree->setModel(_notebooks); @@ -16,6 +18,11 @@ MainWindow::MainWindow(QWidget *parent) : ui->notebookTree->header()->setResizeMode(1, QHeaderView::Fixed); ui->notebookTree->header()->setResizeMode(2, QHeaderView::Fixed); ui->notebookTree->expandAll(); + ui->notebookView->setVisible(false); + ui->paperReplayView->setModel(_replayModel); + ui->paperReplayView->horizontalHeader()->setResizeMode(0, QHeaderView::Stretch); + ui->paperReplayView->horizontalHeader()->setResizeMode(1, QHeaderView::Fixed); + ui->paperReplayView->setVisible(false); Phonon::createPath(_media, _mediaOutput); ui->replaySlider->setMediaObject(_media); ui->pauseButton->setVisible(false); @@ -32,22 +39,38 @@ void MainWindow::closeNotebook() { _curPenName.clear(); _curNotebookName.clear(); + _replay->close(); ui->notebookView->setNotebook(QString()); + ui->notebookView->setVisible(false); + ui->paperReplayView->setVisible(false); } void MainWindow::openNotebook(const QString &pen, const QString ¬ebook) { if (_curPenName == pen && _curNotebookName == notebook) return; + closeNotebook(); + _curPenName = pen; _curNotebookName = notebook; - QString nbDir = _notebooks->notebookDirectory(_curPenName, _curNotebookName); + if (_curNotebookName == PAPER_REPLAY) { + QString replayDir = _notebooks->paperReplayDirectory(_curPenName); + + if (_replay->open(replayDir, 0)) { + _replayModel->refresh(); + } - qDebug() << "Opening notebook" << _curPenName << _curNotebookName << nbDir; + ui->paperReplayView->setVisible(true); + } else { + QString nbDir = _notebooks->notebookDirectory(_curPenName, _curNotebookName); - ui->notebookView->setPaperReplay(_notebooks->paperReplayDirectory(_curPenName)); - ui->notebookView->setNotebook(nbDir); + qDebug() << "Opening notebook" << _curPenName << _curNotebookName << nbDir; + + ui->notebookView->setPaperReplay(_notebooks->paperReplayDirectory(_curPenName)); + ui->notebookView->setNotebook(nbDir); + ui->notebookView->setVisible(true); + } } void MainWindow::handleNotebookSelected(const QModelIndex &index) @@ -56,6 +79,7 @@ void MainWindow::handleNotebookSelected(const QModelIndex &index) closeNotebook(); return; } + QModelIndex parent = index.parent(); if (!parent.isValid()) { closeNotebook(); @@ -73,6 +97,12 @@ void MainWindow::handleCurPageChanged() ui->pageEdit->setText(QString::number(ui->notebookView->curPage() + 1)); } +void MainWindow::handlePaperReplaySelected(const QModelIndex &index) +{ + QString file = _replayModel->sessionFilename(index); + handlePaperReplayRequested(file, 0); +} + void MainWindow::handlePaperReplayRequested(const QString &file, qint64 time) { QFileInfo finfo(file); @@ -113,7 +143,6 @@ void MainWindow::handlePaperReplayPause() void MainWindow::handleMediaStateChange(Phonon::State state) { - qDebug() << "Media state change:" << state; switch (state) { case Phonon::PlayingState: ui->playButton->setVisible(false); |