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( itemActivated(QListWidgetItem *) ),
46 this, SLOT( refSelected(QListWidgetItem *) ) );
47 connect( sortCB, SIGNAL( clicked(bool) ),
48 this, SLOT( sortToggled(bool) ) );
49 connect( gotoPB, SIGNAL( clicked() ),
50 this, SLOT( gotoClicked() ) );
51 connect( updatePB, SIGNAL( clicked() ),
52 this, SLOT( updateClicked() ) );
53 connect( bufferCO, SIGNAL( activated(int) ),
54 this, SLOT( updateClicked() ) );
58 void QRefDialog::show()
65 void QRefDialog::changed_adaptor()
71 void QRefDialog::gotoClicked()
77 void QRefDialog::refHighlighted(QListWidgetItem * sel)
79 if (form_->readOnly())
82 /* int const cur_item = refsLW->currentRow();
83 bool const cur_item_selected = cur_item >= 0 ?
84 refsLB->isSelected(cur_item) : false;*/
85 bool const cur_item_selected = refsLW->isItemSelected(sel);
87 if (cur_item_selected)
88 referenceED->setText(sel->text());
92 gotoPB->setEnabled(true);
93 if (form_->typeAllowed())
94 typeCO->setEnabled(true);
95 if (form_->nameAllowed())
96 nameED->setEnabled(true);
100 void QRefDialog::refSelected(QListWidgetItem * sel)
102 if (form_->readOnly())
105 /* int const cur_item = refsLW->currentRow();
106 bool const cur_item_selected = cur_item >= 0 ?
107 refsLB->isSelected(cur_item) : false;*/
108 bool const cur_item_selected = refsLW->isItemSelected(sel);
110 if (cur_item_selected)
111 referenceED->setText(sel->text());
112 // <enter> or double click, inserts ref and closes dialog
117 void QRefDialog::sortToggled(bool on)
124 void QRefDialog::updateClicked()
130 void QRefDialog::closeEvent(QCloseEvent * e)
136 } // namespace frontend
139 #include "QRefDialog_moc.cpp"