]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiIndex.cpp
* fix spelling in comments to please John.
[lyx.git] / src / frontends / qt4 / GuiIndex.cpp
index c9e114d948e8df41aa415d0b09c0e9dd180997ea..0f25c93da72f4f3d32825e568e4d8857c8f444fd 100644 (file)
  * This file is part of LyX, the document processor.
  * Licence details can be found in the file COPYING.
  *
- * \author John Levon
+ * \author Angus Leeming
+ * \author Martin Vermeer
+ * \author Jürgen Spitzmüller
  *
  * Full author contact details are available in file CREDITS.
  */
 
 #include <config.h>
 
-#include "debug.h"
-#include "ControlCommand.h"
-#include "qt_helpers.h"
-
 #include "GuiIndex.h"
-#include "Qt2BC.h"
-#include "ButtonController.h"
 
-#include <QLabel>
-#include <QPushButton>
-#include <QLineEdit>
-#include <QWhatsThis>
-#include <QCloseEvent>
+#include "qt_helpers.h"
 
+#include "Buffer.h"
+#include "BufferParams.h"
+#include "FuncRequest.h"
+#include "IndicesList.h"
 
-using std::string;
+#include "insets/InsetIndex.h"
 
-/////////////////////////////////////////////////////////////////////
-//
-// GuiIndexDialog
-//
-/////////////////////////////////////////////////////////////////////
+#include <QPushButton>
+
+using namespace std;
 
 namespace lyx {
 namespace frontend {
 
-GuiIndexDialog::GuiIndexDialog(GuiIndex * form)
-       : form_(form)
+GuiIndex::GuiIndex(GuiView & lv)
+       : GuiDialog(lv, "index", qt_("Index Entry Settings"))
 {
        setupUi(this);
 
-       connect(okPB, SIGNAL(clicked()), form, SLOT(slotOK()));
-       connect(closePB, SIGNAL(clicked()), form, SLOT(slotClose()));
-       connect( keywordED, SIGNAL(textChanged(const QString &)),
-               this, SLOT(change_adaptor()));
-
-       setFocusProxy(keywordED);
-
-       keywordED->setWhatsThis( qt_(
-               "The format of the entry in the index.\n"
-               "\n"
-               "An entry can be specified as a sub-entry of\n"
-               "another with \"!\":\n"
-               "\n"
-               "cars!mileage\n"
-               "\n"
-               "You can cross-refer to another entry like so:\n"
-               "\n"
-               "cars!mileage|see{economy}\n"
-               "\n"
-               "For further details refer to the local LaTeX\n"
-               "documentation.\n")
-       );
-}
-
+       connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
+       connect(cancelPB, SIGNAL(clicked()), this, SLOT(slotClose()));
+       connect(indicesCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
 
-void GuiIndexDialog::change_adaptor()
-{
-       form_->changed();
+       bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
+       bc().setOK(okPB);
+       bc().setCancel(cancelPB);
 }
 
 
-void GuiIndexDialog::reject()
+void GuiIndex::change_adaptor()
 {
-       form_->slotClose();
+       changed();
 }
 
 
-void GuiIndexDialog::closeEvent(QCloseEvent * e)
+void GuiIndex::updateContents()
 {
-       form_->slotWMHide();
-       e->accept();
-}
-
+       typedef IndicesList::const_iterator const_iterator;
 
-/////////////////////////////////////////////////////////////////////
-//
-// GuiIndex
-//
-/////////////////////////////////////////////////////////////////////
+       IndicesList const & indiceslist = buffer().params().indiceslist();
+       docstring const cur_index = params_.index;
 
+       indicesCO->clear();
 
-typedef QController<ControlCommand, GuiView<GuiIndexDialog> > IndexBase;
+       const_iterator const begin = indiceslist.begin();
+       const_iterator const end = indiceslist.end();
+       for (const_iterator it = begin; it != end; ++it)
+               indicesCO->addItem(toqstr(it->index()),
+                       QVariant(toqstr(it->shortcut())));
 
-GuiIndex::GuiIndex(Dialog & parent, docstring const & title, QString const & label)
-       : IndexBase(parent, title), label_(label)
-{
+       int const pos = indicesCO->findData(toqstr(cur_index));
+       indicesCO->setCurrentIndex(pos);
 }
 
 
-void GuiIndex::build_dialog()
+void GuiIndex::applyView()
 {
-       dialog_.reset(new GuiIndexDialog(this));
-
-       dialog_->keywordLA->setText(label_);
-
-       bcview().setOK(dialog_->okPB);
-       bcview().setCancel(dialog_->closePB);
-       bcview().addReadOnly(dialog_->keywordED);
+       QString const index = indicesCO->itemData(
+               indicesCO->currentIndex()).toString();
+       params_.index = qstring_to_ucs4(index);
 }
 
 
-void GuiIndex::update_contents()
+bool GuiIndex::initialiseParams(string const & data)
 {
-       docstring const contents = controller().params()["name"];
-       dialog_->keywordED->setText(toqstr(contents));
-
-       bc().valid(!contents.empty());
+       InsetIndex::string2params(data, params_);
+       return true;
 }
 
 
-void GuiIndex::apply()
+void GuiIndex::clearParams()
 {
-       controller().params()["name"] = qstring_to_ucs4(dialog_->keywordED->text());
+       params_ = InsetIndexParams();
 }
 
 
-bool GuiIndex::isValid()
+void GuiIndex::dispatchParams()
 {
-       return !dialog_->keywordED->text().isEmpty();
+       dispatch(FuncRequest(getLfun(), InsetIndex::params2string(params_)));
 }
 
+
+Dialog * createGuiIndex(GuiView & lv) { return new GuiIndex(lv); }
+
+
 } // namespace frontend
 } // namespace lyx
 
-#include "GuiIndex_moc.cpp"
+#include "moc_GuiIndex.cpp"