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()));
37 connect( typeCO, SIGNAL( activated(int) ),
38 this, SLOT( changed_adaptor() ) );
39 connect( referenceED, SIGNAL( textChanged(const QString&) ),
40 this, SLOT( changed_adaptor() ) );
41 connect( nameED, SIGNAL( textChanged(const QString&) ),
42 this, SLOT( changed_adaptor() ) );
43 connect( refsLW, SIGNAL( itemClicked(QListWidgetItem *) ),
44 this, SLOT( refHighlighted(QListWidgetItem *) ) );
45 connect( refsLW, SIGNAL( itemSelectionChanged() ),
46 this, SLOT( selectionChanged() ) );
47 connect( refsLW, SIGNAL( itemActivated(QListWidgetItem *) ),
48 this, SLOT( refSelected(QListWidgetItem *) ) );
49 connect( sortCB, SIGNAL( clicked(bool) ),
50 this, SLOT( sortToggled(bool) ) );
51 connect( gotoPB, SIGNAL( clicked() ),
52 this, SLOT( gotoClicked() ) );
53 connect( updatePB, SIGNAL( clicked() ),
54 this, SLOT( updateClicked() ) );
55 connect( bufferCO, SIGNAL( activated(int) ),
56 this, SLOT( updateClicked() ) );
58 setFocusProxy(refsLW);
61 void QRefDialog::show()
67 void QRefDialog::changed_adaptor()
73 void QRefDialog::gotoClicked()
78 void QRefDialog::selectionChanged()
80 if (form_->readOnly())
83 QList<QListWidgetItem *> selections = refsLW->selectedItems();
84 if (selections.isEmpty())
86 QListWidgetItem * sel = selections.first();
91 void QRefDialog::refHighlighted(QListWidgetItem * sel)
93 if (form_->readOnly())
96 /* int const cur_item = refsLW->currentRow();
97 bool const cur_item_selected = cur_item >= 0 ?
98 refsLB->isSelected(cur_item) : false;*/
99 bool const cur_item_selected = refsLW->isItemSelected(sel);
101 if (cur_item_selected)
102 referenceED->setText(sel->text());
106 gotoPB->setEnabled(true);
107 if (form_->typeAllowed())
108 typeCO->setEnabled(true);
109 if (form_->nameAllowed())
110 nameED->setEnabled(true);
114 void QRefDialog::refSelected(QListWidgetItem * sel)
116 if (form_->readOnly())
119 /* int const cur_item = refsLW->currentRow();
120 bool const cur_item_selected = cur_item >= 0 ?
121 refsLB->isSelected(cur_item) : false;*/
122 bool const cur_item_selected = refsLW->isItemSelected(sel);
124 if (cur_item_selected)
125 referenceED->setText(sel->text());
126 // <enter> or double click, inserts ref and closes dialog
131 void QRefDialog::sortToggled(bool on)
138 void QRefDialog::updateClicked()
144 void QRefDialog::closeEvent(QCloseEvent * e)
150 } // namespace frontend
153 #include "QRefDialog_moc.cpp"