]> git.lyx.org Git - lyx.git/blob - src/frontends/qt3/QRefDialog.C
Extracted from r14281
[lyx.git] / src / frontends / qt3 / QRefDialog.C
1 /**
2  * \file QRefDialog.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Kalle Dalheimer
7  * \author John Levon
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #include <config.h>
13
14 #include "QRefDialog.h"
15 #include "QRef.h"
16
17 #include <qcombobox.h>
18 #include <qlineedit.h>
19 #include <qlistbox.h>
20 #include <qpushbutton.h>
21
22 namespace lyx {
23 namespace frontend {
24
25 QRefDialog::QRefDialog(QRef * form)
26         : QRefDialogBase(0, 0, false, 0),
27         form_(form)
28 {
29         connect(okPB, SIGNAL(clicked()),
30                 form_, SLOT(slotOK()));
31         connect(applyPB, SIGNAL(clicked()),
32                 form_, SLOT(slotApply()));
33         connect(closePB, SIGNAL(clicked()),
34                 form_, SLOT(slotClose()));
35 }
36
37
38 void QRefDialog::show()
39 {
40         QRefDialogBase::show();
41         refsLB->setFocus();
42 }
43
44
45 void QRefDialog::changed_adaptor()
46 {
47         form_->changed();
48 }
49
50
51 void QRefDialog::gotoClicked()
52 {
53         form_->gotoRef();
54 }
55
56
57 void QRefDialog::refHighlighted(const QString & sel)
58 {
59         if (form_->readOnly())
60                 return;
61
62         int const cur_item = refsLB->currentItem();
63         bool const cur_item_selected = cur_item >= 0 ?
64                 refsLB->isSelected(cur_item) : false;
65
66         if (cur_item_selected)
67                 referenceED->setText(sel);
68
69         if (form_->at_ref_)
70                 form_->gotoRef();
71         gotoPB->setEnabled(true);
72         if (form_->typeAllowed())
73                 typeCO->setEnabled(true);
74         if (form_->nameAllowed())
75                 nameED->setEnabled(true);
76 }
77
78
79 void QRefDialog::refSelected(const QString & sel)
80 {
81         if (form_->readOnly())
82                 return;
83
84         int const cur_item = refsLB->currentItem();
85         bool const cur_item_selected = cur_item >= 0 ?
86                 refsLB->isSelected(cur_item) : false;
87
88         if (cur_item_selected)
89                 referenceED->setText(sel);
90         // <enter> or double click, inserts ref and closes dialog
91         form_->slotOK();
92 }
93
94
95 void QRefDialog::sortToggled(bool on)
96 {
97         form_->sort_ = on;
98         form_->redoRefs();
99 }
100
101
102 void QRefDialog::updateClicked()
103 {
104         form_->updateRefs();
105 }
106
107
108 void QRefDialog::closeEvent(QCloseEvent * e)
109 {
110         form_->slotWMHide();
111         e->accept();
112 }
113
114 } // namespace frontend
115 } // namespace lyx