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 ***************************************************************************/
19 #include "FormIndex.h"
24 #include "formindexdialog.h"
26 FormIndex::FormIndex(LyXView *v, Dialogs *d)
27 : dialog_(0), lv_(v), d_(d), inset_(0), h_(0), u_(0), ih_(0)
29 // let the dialog be shown
30 // This is a permanent connection so we won't bother
31 // storing a copy because we won't be disconnecting.
32 d->showIndex.connect(slot(this, &FormIndex::showIndex));
33 d->createIndex.connect(slot(this, &FormIndex::createIndex));
36 FormIndex::~FormIndex()
41 void FormIndex::showIndex(InsetCommand * const inset)
43 // FIXME: when could inset be 0 here ?
48 readonly = lv_->buffer()->isReadonly();
49 ih_ = inset_->hide.connect(slot(this,&FormIndex::hide));
50 params = inset->params();
55 void FormIndex::createIndex(string const & arg)
57 // we could already be showing a URL, clear it out
61 readonly = lv_->buffer()->isReadonly();
62 params.setFromString(arg);
66 void FormIndex::update()
68 dialog_->index->setText(params.getContents().c_str());
71 dialog_->index->setFocusPolicy(QWidget::NoFocus);
72 dialog_->buttonOk->setEnabled(false);
73 dialog_->buttonCancel->setText(_("Close"));
75 dialog_->index->setFocusPolicy(QWidget::StrongFocus);
76 dialog_->index->setFocus();
77 dialog_->buttonOk->setEnabled(true);
78 dialog_->buttonCancel->setText(_("Cancel"));
82 void FormIndex::apply()
87 params.setContents(dialog_->index->text());
90 if (params != inset_->params()) {
91 inset_->setParams(params);
92 lv_->view()->updateInset(inset_, true);
95 lv_->getLyXFunc()->Dispatch(LFUN_INDEX_INSERT, params.getAsString().c_str());
98 void FormIndex::show()
101 dialog_ = new FormIndexDialog(this, 0, _("LyX: Index"), false);
103 if (!dialog_->isVisible()) {
104 h_ = d_->hideBufferDependent.connect(slot(this, &FormIndex::hide));
105 u_ = d_->updateBufferDependent.connect(slot(this, &FormIndex::update));
109 dialog_->setActiveWindow();
115 void FormIndex::close()
123 void FormIndex::hide()