2 * $Id: FormCitationDialogImpl.C,v 1.1 2001/03/16 17:20:06 kalle Exp $
5 #include "FormCitationDialogImpl.h"
7 #include "FormCitation.h"
10 #include <qmultilineedit.h>
17 // PENDING(kalle) Wire text before and citaiton style
20 * Constructs a FormCitationDialogImpl which is a child of 'parent', with the
21 * name 'name' and widget flags set to 'f'
23 * The dialog will by default be modeless, unless you set 'modal' to
24 * TRUE to construct a modal dialog.
26 FormCitationDialogImpl::FormCitationDialogImpl( FormCitation* form, QWidget* parent, const char* name, bool modal, WFlags fl )
27 : FormCitationDialog( parent, name, modal, fl ),
33 * Destroys the object and frees any allocated resources
35 FormCitationDialogImpl::~FormCitationDialogImpl()
37 // no need to delete child widgets, Qt does it all for us
42 // These slots correspond to the XForms input() method.
43 void FormCitationDialogImpl::slotBibSelected( int sel )
45 insetKeysLB->clearSelection();
47 if( sel < 0 || sel > form_->bibkeys.size()-1)
50 // Put into browser_info the additional info associated with
51 // the selected browser_bib key
53 infoML->append( form_->bibkeysInfo[sel].c_str() );
55 // Highlight the selected browser_bib key in browser_cite if present
56 vector<string>::iterator it =
57 ::find(form_->citekeys.begin(), form_->citekeys.end(), form_->bibkeys[sel]);
59 if (it != form_->citekeys.end()) {
60 int n = static_cast<int>(it - form_->citekeys.begin());
61 insetKeysLB->setSelected( n, true );
64 if (!form_->lv_->buffer()->isReadonly()) {
65 if (it != form_->citekeys.end()) {
66 form_->setBibButtons(FormCitation::OFF);
67 form_->setCiteButtons(FormCitation::ON);
69 form_->setBibButtons(FormCitation::ON);
70 form_->setCiteButtons(FormCitation::OFF);
77 void FormCitationDialogImpl::slotInsetSelected( int sel )
79 if (sel < 0 || sel > form_->citekeys.size() -1 )
82 if (!form_->lv_->buffer()->isReadonly()) {
83 form_->setBibButtons(FormCitation::OFF);
84 form_->setCiteButtons(FormCitation::ON);
87 // Highlight the selected browser_cite key in browser_bib
88 vector<string>::iterator it =
89 ::find(form_->bibkeys.begin(), form_->bibkeys.end(), form_->citekeys[sel]);
91 if (it != form_->bibkeys.end()) {
92 int n = static_cast<int>(it - form_->bibkeys.begin());
93 bibliographyKeysLB->setSelected( n, true );
95 // Put into browser_info the additional info associated with
96 // the selected browser_cite key
98 infoML->append( form_->bibkeysInfo[n].c_str() );
103 void FormCitationDialogImpl::slotAddClicked()
105 qDebug( "FormCitationDialogImpl::slotAddClicked()" );
106 int sel = bibliographyKeysLB->currentItem();
107 if (sel < 0 || sel > form_->bibkeys.size() -1 )
110 qDebug( "sel = %d" );
111 qDebug( "bibkeys.size() = %d", form_->bibkeys.size() );
113 // Add the selected browser_bib key to browser_cite
114 insetKeysLB->insertItem( form_->bibkeys[sel].c_str());
115 form_->citekeys.push_back(form_->bibkeys[sel]);
117 int n = static_cast<int>(form_->citekeys.size());
118 insetKeysLB->setSelected( n, true );
120 form_->setBibButtons(FormCitation::OFF);
121 form_->setCiteButtons(FormCitation::ON);
125 void FormCitationDialogImpl::slotDelClicked()
127 int sel = insetKeysLB->currentItem();
128 if (sel < 0 || sel > form_->citekeys.size()-1)
131 // Remove the selected key from browser_cite
132 insetKeysLB->removeItem( sel );
133 form_->citekeys.erase(form_->citekeys.begin() + sel);
135 form_->setBibButtons(FormCitation::ON);
136 form_->setCiteButtons(FormCitation::OFF);
140 void FormCitationDialogImpl::slotUpClicked()
142 int sel = insetKeysLB->currentItem();
143 if (sel < 1 || sel > form_->citekeys.size()-1)
146 // Move the selected key up one line
147 vector<string>::iterator it = form_->citekeys.begin() + sel;
150 insetKeysLB->removeItem( sel );
151 form_->citekeys.erase(it);
153 insetKeysLB->insertItem( tmp.c_str(), sel-1 );
154 insetKeysLB->setSelected( sel-1, true );
155 form_->citekeys.insert(it-1, tmp);
156 form_->setCiteButtons(FormCitation::ON);
160 void FormCitationDialogImpl::slotDownClicked()
162 int sel = insetKeysLB->currentItem();
163 if (sel < 0 || sel > form_->citekeys.size()-2)
166 // Move the selected key down one line
167 vector<string>::iterator it = form_->citekeys.begin() + sel;
170 insetKeysLB->removeItem( sel );
171 form_->citekeys.erase(it);
173 insetKeysLB->insertItem( tmp.c_str(), sel+1 );
174 insetKeysLB->setSelected( sel+1, true );
175 form_->citekeys.insert(it+1, tmp);
176 form_->setCiteButtons(FormCitation::ON);
180 void FormCitationDialogImpl::apply_adaptor()
186 void FormCitationDialogImpl::close_adaptor()