4 * John Levon, moz@compsoc.man.ac.uk
7 /***************************************************************************
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
14 ***************************************************************************/
18 #include "FormIndexDialog.h"
22 #include "FormIndex.h"
28 #include <qlineedit.h>
29 #include <qpushbutton.h>
31 FormIndex::FormIndex(LyXView *v, Dialogs *d)
32 : dialog_(0), lv_(v), d_(d), inset_(0), h_(0), u_(0), ih_(0)
34 // let the dialog be shown
35 // This is a permanent connection so we won't bother
36 // storing a copy because we won't be disconnecting.
37 d->showIndex.connect(slot(this, &FormIndex::showIndex));
38 d->createIndex.connect(slot(this, &FormIndex::createIndex));
41 FormIndex::~FormIndex()
46 void FormIndex::showIndex(InsetCommand * const inset)
48 // FIXME: when could inset be 0 here ?
53 readonly = lv_->buffer()->isReadonly();
54 ih_ = inset_->hide.connect(slot(this,&FormIndex::hide));
55 params = inset->params();
60 void FormIndex::createIndex(string const & arg)
62 // we could already be showing a URL, clear it out
66 readonly = lv_->buffer()->isReadonly();
67 params.setFromString(arg);
71 void FormIndex::update()
73 dialog_->keywordED->setText(params.getContents().c_str());
76 dialog_->keywordED->setFocusPolicy(QWidget::NoFocus);
77 dialog_->okPB->setEnabled(false);
78 dialog_->cancelPB->setText(_("Close"));
80 dialog_->keywordED->setFocusPolicy(QWidget::StrongFocus);
81 dialog_->keywordED->setFocus();
82 dialog_->okPB->setEnabled(true);
83 dialog_->cancelPB->setText(_("Cancel"));
87 void FormIndex::apply()
92 params.setContents(dialog_->keywordED->text().latin1());
95 if (params != inset_->params()) {
96 inset_->setParams(params);
97 lv_->view()->updateInset(inset_, true);
100 lv_->getLyXFunc()->Dispatch(LFUN_INDEX_INSERT, params.getAsString().c_str());
103 void FormIndex::show()
106 dialog_ = new FormIndexDialog(this, 0, _("LyX: Index"), false);
108 if (!dialog_->isVisible()) {
109 h_ = d_->hideBufferDependent.connect(slot(this, &FormIndex::hide));
110 u_ = d_->updateBufferDependent.connect(slot(this, &FormIndex::update));
114 dialog_->setActiveWindow();
120 void FormIndex::close()
128 void FormIndex::hide()