]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/QToc.C
Added initial qt4 work by Abdelrazak Younes
[lyx.git] / src / frontends / qt4 / QToc.C
1 /**
2  * \file QToc.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author John Levon
7  * \author Abdelrazak Younes
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #include <config.h>
13
14 #include "QToc.h"
15 #include "QTocDialog.h"
16 #include "Qt2BC.h"
17 #include "qt_helpers.h"
18
19 #include "debug.h"
20
21 #include "controllers/ControlToc.h"
22
23 using std::endl;
24
25 using std::pair;
26 using std::vector;
27 using std::string;
28
29 namespace lyx {
30 namespace frontend {
31
32 typedef QController<ControlToc, QView<QTocDialog> > base_class;
33
34 QToc::QToc(Dialog & parent)
35         : base_class(parent, _("Table of Contents"))
36 {}
37
38
39 void QToc::build_dialog()
40 {
41         dialog_.reset(new QTocDialog(this));
42
43         // Manage the cancel/close button
44         bcview().setCancel(dialog_->closePB);
45 }
46
47
48 void QToc::update_contents()
49 {
50         dialog_->updateType();
51         dialog_->updateToc();
52 }
53
54
55 void QToc::select(string const & text)
56 {
57         toc::Toc::const_iterator iter = toclist.begin();
58
59         for (; iter != toclist.end(); ++iter) {
60                 if (iter->str == text)
61                         break;
62         }
63
64         if (iter == toclist.end()) {
65                 lyxerr[Debug::GUI] << "Couldn't find highlighted TOC entry: "
66                         << text << endl;
67                 return;
68         }
69
70         controller().goTo(*iter);
71 }
72
73 } // namespace frontend
74 } // namespace lyx