3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Kalle Dalheimer
9 * Full author contact details are available in file CREDITS.
14 #include "QRefDialog.h"
18 #include <QListWidget>
19 #include <QPushButton>
20 #include <QCloseEvent>
25 QRefDialog::QRefDialog(QRef * form)
30 connect(okPB, SIGNAL(clicked()),
31 form_, SLOT(slotOK()));
32 connect(applyPB, SIGNAL(clicked()),
33 form_, SLOT(slotApply()));
34 connect(closePB, SIGNAL(clicked()),
35 form_, SLOT(slotClose()));
36 connect(closePB, SIGNAL(clicked()),
37 this, SLOT( reset_dialog() ) );
39 connect( typeCO, SIGNAL( activated(int) ),
40 this, SLOT( changed_adaptor() ) );
41 connect( referenceED, SIGNAL( textChanged(const QString&) ),
42 this, SLOT( changed_adaptor() ) );
43 connect( nameED, SIGNAL( textChanged(const QString&) ),
44 this, SLOT( changed_adaptor() ) );
45 connect( refsLW, SIGNAL( itemClicked(QListWidgetItem *) ),
46 this, SLOT( refHighlighted(QListWidgetItem *) ) );
47 connect( refsLW, SIGNAL( itemSelectionChanged() ),
48 this, SLOT( selectionChanged() ) );
49 connect( refsLW, SIGNAL( itemActivated(QListWidgetItem *) ),
50 this, SLOT( refSelected(QListWidgetItem *) ) );
51 connect( sortCB, SIGNAL( clicked(bool) ),
52 this, SLOT( sortToggled(bool) ) );
53 connect( gotoPB, SIGNAL( clicked() ),
54 this, SLOT( gotoClicked() ) );
55 connect( updatePB, SIGNAL( clicked() ),
56 this, SLOT( updateClicked() ) );
57 connect( bufferCO, SIGNAL( activated(int) ),
58 this, SLOT( updateClicked() ) );
60 setFocusProxy(refsLW);
63 void QRefDialog::show()
69 void QRefDialog::changed_adaptor()
75 void QRefDialog::gotoClicked()
80 void QRefDialog::selectionChanged()
82 if (form_->readOnly())
85 QList<QListWidgetItem *> selections = refsLW->selectedItems();
86 if (selections.isEmpty())
88 QListWidgetItem * sel = selections.first();
93 void QRefDialog::refHighlighted(QListWidgetItem * sel)
95 if (form_->readOnly())
98 /* int const cur_item = refsLW->currentRow();
99 bool const cur_item_selected = cur_item >= 0 ?
100 refsLB->isSelected(cur_item) : false;*/
101 bool const cur_item_selected = refsLW->isItemSelected(sel);
103 if (cur_item_selected)
104 referenceED->setText(sel->text());
108 gotoPB->setEnabled(true);
109 if (form_->typeAllowed())
110 typeCO->setEnabled(true);
111 if (form_->nameAllowed())
112 nameED->setEnabled(true);
116 void QRefDialog::refSelected(QListWidgetItem * sel)
118 if (form_->readOnly())
121 /* int const cur_item = refsLW->currentRow();
122 bool const cur_item_selected = cur_item >= 0 ?
123 refsLB->isSelected(cur_item) : false;*/
124 bool const cur_item_selected = refsLW->isItemSelected(sel);
126 if (cur_item_selected)
127 referenceED->setText(sel->text());
128 // <enter> or double click, inserts ref and closes dialog
133 void QRefDialog::sortToggled(bool on)
140 void QRefDialog::updateClicked()
146 void QRefDialog::reset_dialog() {
147 form_->at_ref_ = false;
152 void QRefDialog::closeEvent(QCloseEvent * e)
159 } // namespace frontend
162 #include "QRefDialog_moc.cpp"