2 * $Id: FormCitationDialogImpl.C,v 1.3 2001/03/29 18:58:47 kalle Exp $
5 #include "FormCitationDialogImpl.h"
7 #include "FormCitation.h"
10 #include <qmultilineedit.h>
20 // PENDING(kalle) Wire text before and citation style
23 * Constructs a FormCitationDialogImpl which is a child of 'parent', with the
24 * name 'name' and widget flags set to 'f'
26 * The dialog will by default be modeless, unless you set 'modal' to
27 * TRUE to construct a modal dialog.
29 FormCitationDialogImpl::FormCitationDialogImpl( FormCitation* form, QWidget* parent, const char* name, bool modal, WFlags fl )
30 : FormCitationDialog( parent, name, modal, fl ),
36 * Destroys the object and frees any allocated resources
38 FormCitationDialogImpl::~FormCitationDialogImpl()
40 // no need to delete child widgets, Qt does it all for us
45 // These slots correspond to the XForms input() method.
46 void FormCitationDialogImpl::slotBibSelected( int sel )
48 insetKeysLB->clearSelection();
50 if( sel < 0 || sel > form_->bibkeys.size()-1)
53 // Put into browser_info the additional info associated with
54 // the selected browser_bib key
56 infoML->append( form_->bibkeysInfo[sel].c_str() );
58 // Highlight the selected browser_bib key in browser_cite if present
59 vector<string>::iterator it =
60 ::find(form_->citekeys.begin(), form_->citekeys.end(), form_->bibkeys[sel]);
62 if (it != form_->citekeys.end()) {
63 int n = static_cast<int>(it - form_->citekeys.begin());
64 insetKeysLB->setSelected( n, true );
67 if (!form_->lv_->buffer()->isReadonly()) {
68 if (it != form_->citekeys.end()) {
69 form_->setBibButtons(FormCitation::OFF);
70 form_->setCiteButtons(FormCitation::ON);
72 form_->setBibButtons(FormCitation::ON);
73 form_->setCiteButtons(FormCitation::OFF);
80 void FormCitationDialogImpl::slotInsetSelected( int sel )
82 if (sel < 0 || sel > form_->citekeys.size() -1 )
85 if (!form_->lv_->buffer()->isReadonly()) {
86 form_->setBibButtons(FormCitation::OFF);
87 form_->setCiteButtons(FormCitation::ON);
90 // Highlight the selected browser_cite key in browser_bib
91 vector<string>::iterator it =
92 ::find(form_->bibkeys.begin(), form_->bibkeys.end(), form_->citekeys[sel]);
94 if (it != form_->bibkeys.end()) {
95 int n = static_cast<int>(it - form_->bibkeys.begin());
96 bibliographyKeysLB->setSelected( n, true );
98 // Put into browser_info the additional info associated with
99 // the selected browser_cite key
101 infoML->append( form_->bibkeysInfo[n].c_str() );
106 void FormCitationDialogImpl::slotAddClicked()
108 qDebug( "FormCitationDialogImpl::slotAddClicked()" );
109 int sel = bibliographyKeysLB->currentItem();
110 if (sel < 0 || sel > form_->bibkeys.size() -1 )
113 qDebug( "sel = %d" );
114 qDebug( "bibkeys.size() = %d", form_->bibkeys.size() );
116 // Add the selected browser_bib key to browser_cite
117 insetKeysLB->insertItem( form_->bibkeys[sel].c_str());
118 form_->citekeys.push_back(form_->bibkeys[sel]);
120 int n = static_cast<int>(form_->citekeys.size());
121 insetKeysLB->setSelected( n, true );
123 form_->setBibButtons(FormCitation::OFF);
124 form_->setCiteButtons(FormCitation::ON);
128 void FormCitationDialogImpl::slotDelClicked()
130 int sel = insetKeysLB->currentItem();
131 if (sel < 0 || sel > form_->citekeys.size()-1)
134 // Remove the selected key from browser_cite
135 insetKeysLB->removeItem( sel );
136 form_->citekeys.erase(form_->citekeys.begin() + sel);
138 form_->setBibButtons(FormCitation::ON);
139 form_->setCiteButtons(FormCitation::OFF);
143 void FormCitationDialogImpl::slotUpClicked()
145 int sel = insetKeysLB->currentItem();
146 if (sel < 1 || sel > form_->citekeys.size()-1)
149 // Move the selected key up one line
150 vector<string>::iterator it = form_->citekeys.begin() + sel;
153 insetKeysLB->removeItem( sel );
154 form_->citekeys.erase(it);
156 insetKeysLB->insertItem( tmp.c_str(), sel-1 );
157 insetKeysLB->setSelected( sel-1, true );
158 form_->citekeys.insert(it-1, tmp);
159 form_->setCiteButtons(FormCitation::ON);
163 void FormCitationDialogImpl::slotDownClicked()
165 int sel = insetKeysLB->currentItem();
166 if (sel < 0 || sel > form_->citekeys.size()-2)
169 // Move the selected key down one line
170 vector<string>::iterator it = form_->citekeys.begin() + sel;
173 insetKeysLB->removeItem( sel );
174 form_->citekeys.erase(it);
176 insetKeysLB->insertItem( tmp.c_str(), sel+1 );
177 insetKeysLB->setSelected( sel+1, true );
178 form_->citekeys.insert(it+1, tmp);
179 form_->setCiteButtons(FormCitation::ON);
183 void FormCitationDialogImpl::apply_adaptor()
189 void FormCitationDialogImpl::close_adaptor()