]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/QToc.C
Transfered closePB handlling (GUI code) from QToc.C to QTocDialog.C
[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
44
45 void QToc::update_contents()
46 {
47         dialog_->updateType();
48         dialog_->updateToc();
49 }
50
51
52 void QToc::select(string const & text)
53 {
54         toc::Toc::const_iterator iter = toclist.begin();
55
56         for (; iter != toclist.end(); ++iter) {
57                 if (iter->str == text)
58                         break;
59         }
60
61         if (iter == toclist.end()) {
62                 lyxerr[Debug::GUI] << "Couldn't find highlighted TOC entry: "
63                         << text << endl;
64                 return;
65         }
66
67         controller().goTo(*iter);
68 }
69
70 void QToc::moveUp()
71 {
72         controller().outline(toc::UP);
73         update_contents();
74 }
75
76
77 void QToc::moveDown()
78 {
79         controller().outline(toc::DOWN);
80         update_contents();
81 }
82
83
84 void QToc::moveIn()
85 {
86         controller().outline(toc::IN);
87         update_contents();
88 }
89
90
91 void QToc::moveOut()
92 {
93         controller().outline(toc::OUT);
94         update_contents();
95 }
96
97
98 } // namespace frontend
99 } // namespace lyx