Table of contents navigation.
[mebook:mebook.git] / ui / mainwindow.cpp
1 #include "mainwindow.h"
2 #include "selectordialog.h"
3 #include <QToolBar>
4 #include <QAction>
5
6 MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
7 {
8     bookView = new BookView(this);
9     setCentralWidget(bookView); 
10
11     Book *book = new Book();
12     book->openBook("books/Bram Stoker - Dracula.epub");
13     currentBook = book;
14
15     bookView->setBook(book);
16
17
18     QToolBar *toolbar = new QToolBar("toolbar", this);
19     QAction *tocAction = toolbar->addAction("TOC");
20     connect(tocAction, SIGNAL(triggered()), this, SLOT(tocNavigation()));
21
22     addToolBar(toolbar);
23 }
24
25 MainWindow::~MainWindow()
26 {
27
28 }
29
30
31 void MainWindow::tocNavigation()
32 {
33     QList<QString> toc = currentBook->getTOC();
34     SelectorDialog dialog(toc, this);
35     connect(&dialog, SIGNAL(selectedString(QString)), bookView, SLOT(goToChapter(QString)));
36
37     dialog.exec();
38
39 }