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"
17 #include <qlineedit.h>
18 #include <q3listbox.h>
19 #include <qpushbutton.h>
21 #include <QCloseEvent>
26 QRefDialog::QRefDialog(QRef * form)
31 connect(okPB, SIGNAL(clicked()),
32 form_, SLOT(slotOK()));
33 connect(applyPB, SIGNAL(clicked()),
34 form_, SLOT(slotApply()));
35 connect(closePB, SIGNAL(clicked()),
36 form_, SLOT(slotClose()));
38 connect( typeCO, SIGNAL( activated(int) ), this, SLOT( changed_adaptor() ) );
39 connect( referenceED, SIGNAL( textChanged(const QString&) ), this, SLOT( changed_adaptor() ) );
40 connect( nameED, SIGNAL( textChanged(const QString&) ), this, SLOT( changed_adaptor() ) );
41 connect( refsLB, SIGNAL( highlighted(const QString&) ), this, SLOT( refHighlighted(const QString&) ) );
42 connect( refsLB, SIGNAL( selected(const QString&) ), this, SLOT( refSelected(const QString&) ) );
43 connect( sortCB, SIGNAL( toggled(bool) ), this, SLOT( sortToggled(bool) ) );
44 connect( gotoPB, SIGNAL( clicked() ), this, SLOT( gotoClicked() ) );
45 connect( updatePB, SIGNAL( clicked() ), this, SLOT( updateClicked() ) );
46 connect( bufferCO, SIGNAL( activated(int) ), this, SLOT( updateClicked() ) );
50 void QRefDialog::show()
57 void QRefDialog::changed_adaptor()
63 void QRefDialog::gotoClicked()
69 void QRefDialog::refHighlighted(const QString & sel)
71 if (form_->readOnly())
74 int const cur_item = refsLB->currentItem();
75 bool const cur_item_selected = cur_item >= 0 ?
76 refsLB->isSelected(cur_item) : false;
78 if (cur_item_selected)
79 referenceED->setText(sel);
83 gotoPB->setEnabled(true);
84 if (form_->typeAllowed())
85 typeCO->setEnabled(true);
86 if (form_->nameAllowed())
87 nameED->setEnabled(true);
91 void QRefDialog::refSelected(const QString & sel)
93 if (form_->readOnly())
96 int const cur_item = refsLB->currentItem();
97 bool const cur_item_selected = cur_item >= 0 ?
98 refsLB->isSelected(cur_item) : false;
100 if (cur_item_selected)
101 referenceED->setText(sel);
102 // <enter> or double click, inserts ref and closes dialog
107 void QRefDialog::sortToggled(bool on)
114 void QRefDialog::updateClicked()
120 void QRefDialog::closeEvent(QCloseEvent * e)
126 } // namespace frontend