diff --git a/development/scons/scons_manifest.py b/development/scons/scons_manifest.py index 5e62aa2340..feb2db8755 100644 --- a/development/scons/scons_manifest.py +++ b/development/scons/scons_manifest.py @@ -727,6 +727,7 @@ src_frontends_qt4_header_files = Split(''' GuiIdListModel.h GuiImage.h GuiInclude.h + GuiIndex.h GuiIndices.h GuiInfo.h GuiKeySymbol.h @@ -820,6 +821,7 @@ src_frontends_qt4_files = Split(''' GuiIdListModel.cpp GuiImage.cpp GuiInclude.cpp + GuiIndex.cpp GuiIndices.cpp GuiInfo.cpp GuiKeySymbol.cpp @@ -904,6 +906,7 @@ src_frontends_qt4_ui_files = Split(''' HSpaceUi.ui HyperlinkUi.ui IncludeUi.ui + IndexUi.ui IndicesUi.ui InfoUi.ui LabelUi.ui diff --git a/lib/ui/stdcontext.inc b/lib/ui/stdcontext.inc index e0db52cb4b..1cf9fb4d38 100644 --- a/lib/ui/stdcontext.inc +++ b/lib/ui/stdcontext.inc @@ -480,6 +480,8 @@ Menuset OptItem "Close Inset|C" "inset-toggle close" Separator Item "Dissolve Inset|D" "inset-dissolve" + Separator + OptItem "Settings...|S" "inset-settings" End # diff --git a/lib/ui/stdmenus.inc b/lib/ui/stdmenus.inc index 85ecdf445c..a3b90891bb 100644 --- a/lib/ui/stdmenus.inc +++ b/lib/ui/stdmenus.inc @@ -123,6 +123,7 @@ Menuset OptItem "Phantom Settings...|h" "inset-settings phantom" OptItem "Branch Settings...|B" "inset-settings branch" OptItem "Box Settings...|x" "inset-settings box" + OptItem "Index Entry Settings...|C" "inset-settings inset" OptItem "Listings Settings...|g" "inset-settings listings" # Hey, guess what's broken ? Surprise surprise, it's tabular stuff # This is in the Table submenu instead for now. diff --git a/src/LyXAction.cpp b/src/LyXAction.cpp index 5f0bdae955..8b5ffbc511 100644 --- a/src/LyXAction.cpp +++ b/src/LyXAction.cpp @@ -2246,11 +2246,11 @@ void LyXAction::init() * \var lyx::FuncCode lyx::LFUN_INSET_SETTINGS * \li Action: Open the inset's properties dialog. * \li Notion: Used for bibitem, bibtex, box, branch, citation, ert, external, - * float, graphics, href, include, label, listings, note, phantom, + * float, graphics, href, include, index, label, listings, note, phantom, * ref, space, tabular, vspace, wrap insets. * \li Syntax: inset-settings * \li Params: : . * \endvar */ diff --git a/src/frontends/qt4/GuiIndex.cpp b/src/frontends/qt4/GuiIndex.cpp new file mode 100644 index 0000000000..0f25c93da7 --- /dev/null +++ b/src/frontends/qt4/GuiIndex.cpp @@ -0,0 +1,107 @@ +/** + * \file GuiIndex.cpp + * This file is part of LyX, the document processor. + * Licence details can be found in the file COPYING. + * + * \author Angus Leeming + * \author Martin Vermeer + * \author Jürgen Spitzmüller + * + * Full author contact details are available in file CREDITS. + */ + +#include + +#include "GuiIndex.h" + +#include "qt_helpers.h" + +#include "Buffer.h" +#include "BufferParams.h" +#include "FuncRequest.h" +#include "IndicesList.h" + +#include "insets/InsetIndex.h" + +#include + +using namespace std; + +namespace lyx { +namespace frontend { + +GuiIndex::GuiIndex(GuiView & lv) + : GuiDialog(lv, "index", qt_("Index Entry Settings")) +{ + setupUi(this); + + connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK())); + connect(cancelPB, SIGNAL(clicked()), this, SLOT(slotClose())); + connect(indicesCO, SIGNAL(activated(int)), this, SLOT(change_adaptor())); + + bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy); + bc().setOK(okPB); + bc().setCancel(cancelPB); +} + + +void GuiIndex::change_adaptor() +{ + changed(); +} + + +void GuiIndex::updateContents() +{ + typedef IndicesList::const_iterator const_iterator; + + IndicesList const & indiceslist = buffer().params().indiceslist(); + docstring const cur_index = params_.index; + + indicesCO->clear(); + + 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()))); + + int const pos = indicesCO->findData(toqstr(cur_index)); + indicesCO->setCurrentIndex(pos); +} + + +void GuiIndex::applyView() +{ + QString const index = indicesCO->itemData( + indicesCO->currentIndex()).toString(); + params_.index = qstring_to_ucs4(index); +} + + +bool GuiIndex::initialiseParams(string const & data) +{ + InsetIndex::string2params(data, params_); + return true; +} + + +void GuiIndex::clearParams() +{ + params_ = InsetIndexParams(); +} + + +void GuiIndex::dispatchParams() +{ + dispatch(FuncRequest(getLfun(), InsetIndex::params2string(params_))); +} + + +Dialog * createGuiIndex(GuiView & lv) { return new GuiIndex(lv); } + + +} // namespace frontend +} // namespace lyx + +#include "moc_GuiIndex.cpp" diff --git a/src/frontends/qt4/GuiIndex.h b/src/frontends/qt4/GuiIndex.h new file mode 100644 index 0000000000..8a74c8087d --- /dev/null +++ b/src/frontends/qt4/GuiIndex.h @@ -0,0 +1,56 @@ +// -*- C++ -*- +/** + * \file GuiIndex.h + * This file is part of LyX, the document processor. + * Licence details can be found in the file COPYING. + * + * \author Angus Leeming + * \author Martin Vermeer + * \author Jürgen Spitzmüller + * + * Full author contact details are available in file CREDITS. + */ + +#ifndef GUIINDEX_H +#define GUIINDEX_H + +#include "GuiDialog.h" +#include "ui_IndexUi.h" +#include "insets/InsetIndex.h" + + +namespace lyx { +namespace frontend { + +class GuiIndex : public GuiDialog, public Ui::IndexUi +{ + Q_OBJECT + +public: + GuiIndex(GuiView & lv); + +private Q_SLOTS: + void change_adaptor(); + +private: + /// Apply changes + void applyView(); + /// Update dialog before showing it + void updateContents(); + /// + bool initialiseParams(std::string const & data); + /// + void clearParams(); + /// + void dispatchParams(); + /// + bool isBufferDependent() const { return true; } + + /// + InsetIndexParams params_; +}; + +} // namespace frontend +} // namespace lyx + +#endif // GUIINDEX_H diff --git a/src/frontends/qt4/GuiView.cpp b/src/frontends/qt4/GuiView.cpp index 6157a09293..8e678745ed 100644 --- a/src/frontends/qt4/GuiView.cpp +++ b/src/frontends/qt4/GuiView.cpp @@ -2576,6 +2576,7 @@ Dialog * createGuiExternal(GuiView & lv); Dialog * createGuiFloat(GuiView & lv); Dialog * createGuiGraphics(GuiView & lv); Dialog * createGuiInclude(GuiView & lv); +Dialog * createGuiIndex(GuiView & lv); Dialog * createGuiInfo(GuiView & lv); Dialog * createGuiLabel(GuiView & lv); Dialog * createGuiListings(GuiView & lv); @@ -2647,6 +2648,8 @@ Dialog * GuiView::build(string const & name) return createGuiGraphics(*this); if (name == "include") return createGuiInclude(*this); + if (name == "index") + return createGuiIndex(*this); if (name == "info") return createGuiInfo(*this); if (name == "nomenclature") diff --git a/src/frontends/qt4/Makefile.am b/src/frontends/qt4/Makefile.am index 084cf8f2eb..3a50203a06 100644 --- a/src/frontends/qt4/Makefile.am +++ b/src/frontends/qt4/Makefile.am @@ -90,6 +90,7 @@ SOURCEFILES = \ GuiIdListModel.cpp \ GuiImage.cpp \ GuiInclude.cpp \ + GuiIndex.cpp \ GuiIndices.cpp \ GuiInfo.cpp \ GuiKeySymbol.cpp \ @@ -187,6 +188,7 @@ MOCHEADER = \ GuiHSpace.h \ GuiHyperlink.h \ GuiInclude.h \ + GuiIndex.h \ GuiIndices.h \ GuiInfo.h \ GuiLabel.h \ @@ -256,6 +258,7 @@ UIFILES = \ HSpaceUi.ui \ HyperlinkUi.ui \ IncludeUi.ui \ + IndexUi.ui \ IndicesUi.ui \ InfoUi.ui \ LabelUi.ui \ diff --git a/src/frontends/qt4/ui/IndexUi.ui b/src/frontends/qt4/ui/IndexUi.ui new file mode 100644 index 0000000000..6a3a74629d --- /dev/null +++ b/src/frontends/qt4/ui/IndexUi.ui @@ -0,0 +1,97 @@ + + IndexUi + + + + 0 + 0 + 262 + 108 + + + + + + + true + + + + 9 + + + 6 + + + + + Qt::Horizontal + + + + 71 + 20 + + + + + + + + &OK + + + false + + + + + + + 0 + + + 6 + + + + + A&vailable indices: + + + indicesCO + + + + + + + Select the index this entry should be listed in. + + + + + + + + + &Cancel + + + true + + + + + + + indicesCO + okPB + cancelPB + + + qt_i18n.h + + + + diff --git a/src/insets/InsetIndex.cpp b/src/insets/InsetIndex.cpp index 495b612e9f..2827488221 100644 --- a/src/insets/InsetIndex.cpp +++ b/src/insets/InsetIndex.cpp @@ -14,6 +14,7 @@ #include "Buffer.h" #include "BufferParams.h" +#include "BufferView.h" #include "ColorSet.h" #include "DispatchResult.h" #include "Encoding.h" @@ -170,6 +171,14 @@ int InsetIndex::docbook(odocstream & os, OutputParams const & runparams) const } +bool InsetIndex::showInsetDialog(BufferView * bv) const +{ + bv->showDialog("index", params2string(params_), + const_cast(this)); + return true; +} + + void InsetIndex::doDispatch(Cursor & cur, FuncRequest & cmd) { switch (cmd.action) { @@ -180,8 +189,17 @@ void InsetIndex::doDispatch(Cursor & cur, FuncRequest & cmd) setLayout(cur.buffer()->params()); break; } + InsetIndexParams params; + InsetIndex::string2params(to_utf8(cmd.argument()), params); + params_.index = params.index; + setLayout(cur.buffer()->params()); + break; } + case LFUN_INSET_DIALOG_UPDATE: + cur.bv().updateDialog("index", params2string(params_)); + break; + default: InsetCollapsable::doDispatch(cur, cmd); break; @@ -205,6 +223,15 @@ bool InsetIndex::getStatus(Cursor & cur, FuncRequest const & cmd, from_utf8(cmd.getArg(1)) == params_.index); return true; } + flag.setEnabled(true); + return true; + + case LFUN_INSET_DIALOG_UPDATE: + case LFUN_INSET_SETTINGS: { + Buffer const & realbuffer = *buffer().masterBuffer(); + flag.setEnabled(realbuffer.params().use_indices); + return true; + } default: return InsetCollapsable::getStatus(cur, cmd, flag); @@ -263,6 +290,30 @@ void InsetIndex::read(Lexer & lex) } +string InsetIndex::params2string(InsetIndexParams const & params) +{ + ostringstream data; + data << "index"; + params.write(data); + return data.str(); +} + + +void InsetIndex::string2params(string const & in, InsetIndexParams & params) +{ + params = InsetIndexParams(); + if (in.empty()) + return; + + istringstream data(in); + Lexer lex; + lex.setStream(data); + lex.setContext("InsetIndex::string2params"); + lex >> "index"; + params.read(lex); +} + + void InsetIndex::addToToc(DocIterator const & cpit) { DocIterator pit = cpit; diff --git a/src/insets/InsetIndex.h b/src/insets/InsetIndex.h index 15c5e7e3fd..9070e621e8 100644 --- a/src/insets/InsetIndex.h +++ b/src/insets/InsetIndex.h @@ -39,6 +39,10 @@ class InsetIndex : public InsetCollapsable { public: /// InsetIndex(Buffer const &, InsetIndexParams const &); + /// + static std::string params2string(InsetIndexParams const &); + /// + static void string2params(std::string const &, InsetIndexParams &); private: /// EDITABLE editable() const { return HIGHLY_EDITABLE; } @@ -55,6 +59,8 @@ private: /// int latex(odocstream &, OutputParams const &) const; /// + bool showInsetDialog(BufferView *) const; + /// bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const; /// void doDispatch(Cursor & cur, FuncRequest & cmd);