]> git.lyx.org Git - lyx.git/blob - src/frontends/qt3/QTocDialog.C
Extracted from r14281
[lyx.git] / src / frontends / qt3 / QTocDialog.C
1 /**
2  * \file QTocDialog.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  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "QTocDialog.h"
14 #include "QToc.h"
15 #include "qt_helpers.h"
16
17 #include <qlistview.h>
18 #include <qpushbutton.h>
19
20 namespace lyx {
21 namespace frontend {
22
23 QTocDialog::QTocDialog(QToc * form)
24         : QTocDialogBase(0, 0, false, 0),
25         form_(form)
26 {
27         // disable sorting
28         tocLV->setSorting(-1);
29
30         // hide the pointless QHeader
31         QWidget * w = static_cast<QWidget*>(tocLV->child("list view header"));
32         if (w)
33                 w->hide();
34
35         connect(closePB, SIGNAL(clicked()), form, SLOT(slotClose()));
36         connect(moveupPB, SIGNAL(clicked()), this, SLOT(moveup_adaptor()));
37         connect(movednPB, SIGNAL(clicked()), this, SLOT(movedn_adaptor()));
38         connect(moveinPB, SIGNAL(clicked()), this, SLOT(movein_adaptor()));
39         connect(moveoutPB, SIGNAL(clicked()), this, SLOT(moveout_adaptor()));
40 }
41
42
43 QTocDialog::~QTocDialog()
44 {
45 }
46
47
48 void QTocDialog::activate_adaptor(int)
49 {
50         form_->updateToc(form_->depth_);
51 }
52
53
54 void QTocDialog::depth_adaptor(int depth)
55 {
56         form_->set_depth(depth);
57 }
58
59
60 void QTocDialog::select_adaptor(QListViewItem * item)
61 {
62         form_->select(fromqstr(item->text(0)));
63 }
64
65
66 void QTocDialog::enableButtons(bool enable)
67 {
68         updatePB->setEnabled(enable);
69
70         if (!form_->canOutline())
71                 enable = false;
72
73         moveupPB->setEnabled(enable);
74         movednPB->setEnabled(enable);
75         moveinPB->setEnabled(enable);
76         moveoutPB->setEnabled(enable);
77 }
78
79
80 void QTocDialog::update_adaptor()
81 {
82         form_->update();
83 }
84
85
86 void QTocDialog::moveup_adaptor()
87 {
88         form_->moveup();
89 }
90
91
92 void QTocDialog::movedn_adaptor()
93 {
94         form_->movedn();
95 }
96
97
98 void QTocDialog::movein_adaptor()
99 {
100         form_->movein();
101 }
102
103
104 void QTocDialog::moveout_adaptor()
105 {
106         form_->moveout();
107 }
108
109
110 void QTocDialog::closeEvent(QCloseEvent * e)
111 {
112         form_->slotWMHide();
113         e->accept();
114 }
115
116 } // namespace frontend
117 } // namespace lyx