diff --git a/development/scons/scons_manifest.py b/development/scons/scons_manifest.py index feb2db8755..f34ff1d1f3 100644 --- a/development/scons/scons_manifest.py +++ b/development/scons/scons_manifest.py @@ -742,6 +742,7 @@ src_frontends_qt4_header_files = Split(''' GuiPhantom.h GuiPrefs.h GuiPrint.h + GuiPrintindex.h GuiRef.h GuiSearch.h GuiSelection.h @@ -836,6 +837,7 @@ src_frontends_qt4_files = Split(''' GuiPhantom.cpp GuiPrefs.cpp GuiPrint.cpp + GuiPrintindex.cpp GuiRef.cpp GuiSearch.cpp GuiSelection.cpp @@ -947,6 +949,7 @@ src_frontends_qt4_ui_files = Split(''' PrefUi.ui PrefsUi.ui PrintUi.ui + PrintindexUi.ui RefUi.ui SearchUi.ui SendtoUi.ui diff --git a/lib/ui/stdcontext.inc b/lib/ui/stdcontext.inc index 1cf9fb4d38..5eb179b472 100644 --- a/lib/ui/stdcontext.inc +++ b/lib/ui/stdcontext.inc @@ -490,6 +490,8 @@ Menuset Menu "context-indexprint" IndicesListsContext + Separator + OptItem "Settings...|S" "inset-settings" End End diff --git a/lib/ui/stdmenus.inc b/lib/ui/stdmenus.inc index a3b90891bb..c394b1c97d 100644 --- a/lib/ui/stdmenus.inc +++ b/lib/ui/stdmenus.inc @@ -123,7 +123,8 @@ 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 "Index Entry Settings...|C" "inset-settings index" + OptItem "Index Settings...|C" "inset-settings index_print" 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 8b5ffbc511..1d2025a8ba 100644 --- a/src/LyXAction.cpp +++ b/src/LyXAction.cpp @@ -2246,12 +2246,12 @@ 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, index, label, listings, note, phantom, - * ref, space, tabular, vspace, wrap insets. + * float, graphics, href, include, index, index_print, label, listings, + * note, phantom, ref, space, tabular, vspace, wrap insets. * \li Syntax: inset-settings * \li Params: : . + * graphics|href|include|index|index_print|label|listings| + * note|phantom|ref|space|tabular|vspace|wrap>. * \endvar */ { LFUN_INSET_SETTINGS, "inset-settings", ReadOnly | AtPoint, Edit }, diff --git a/src/Text3.cpp b/src/Text3.cpp index 1b9b40aa00..0cbef5f727 100644 --- a/src/Text3.cpp +++ b/src/Text3.cpp @@ -2017,6 +2017,8 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & cmd, code = INCLUDE_CODE; else if (cmd.argument() == "index") code = INDEX_CODE; + else if (cmd.argument() == "index_print") + code = INDEX_PRINT_CODE; else if (cmd.argument() == "nomenclature") code = NOMENCL_CODE; else if (cmd.argument() == "label") diff --git a/src/factory.cpp b/src/factory.cpp index 641d96cfb6..6cab8f69cf 100644 --- a/src/factory.cpp +++ b/src/factory.cpp @@ -301,7 +301,7 @@ Inset * createInsetHelper(Buffer & buf, FuncRequest const & cmd) case NOMENCL_CODE: { InsetCommandParams icp(code); - InsetCommand::string2params(name, lyx::to_utf8(cmd.argument()), icp); + InsetCommand::string2params(name, to_utf8(cmd.argument()), icp); return new InsetNomencl(icp); } diff --git a/src/frontends/qt4/GuiPrintindex.cpp b/src/frontends/qt4/GuiPrintindex.cpp new file mode 100644 index 0000000000..53278497e0 --- /dev/null +++ b/src/frontends/qt4/GuiPrintindex.cpp @@ -0,0 +1,113 @@ +/** + * \file GuiPrintindex.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 "GuiPrintindex.h" + +#include "qt_helpers.h" + +#include "Buffer.h" +#include "BufferParams.h" +#include "FuncRequest.h" +#include "IndicesList.h" + +#include "insets/InsetCommand.h" + +#include + +using namespace std; + +namespace lyx { +namespace frontend { + +GuiPrintindex::GuiPrintindex(GuiView & lv) + : GuiDialog(lv, "index_print", qt_("Index Settings")), + params_(insetCode("index_print")) +{ + 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 GuiPrintindex::change_adaptor() +{ + changed(); +} + + +void GuiPrintindex::updateContents() +{ + typedef IndicesList::const_iterator const_iterator; + + IndicesList const & indiceslist = buffer().params().indiceslist(); + docstring const cur_index = params_["type"]; + + 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 GuiPrintindex::applyView() +{ + QString const index = indicesCO->itemData( + indicesCO->currentIndex()).toString(); + params_["type"] = qstring_to_ucs4(index); +} + + +void GuiPrintindex::paramsToDialog(InsetCommandParams const & /*icp*/) +{ + int const pos = indicesCO->findData(toqstr(params_["type"])); + indicesCO->setCurrentIndex(pos); + bc().setValid(isValid()); +} + + +bool GuiPrintindex::initialiseParams(string const & data) +{ + // The name passed with LFUN_INSET_APPLY is also the name + // used to identify the mailer. + InsetCommand::string2params("index_print", data, params_); + return true; +} + + +void GuiPrintindex::dispatchParams() +{ + std::string const lfun = InsetCommand::params2string("index_print", params_); + dispatch(FuncRequest(getLfun(), lfun)); +} + + +Dialog * createGuiPrintindex(GuiView & lv) { return new GuiPrintindex(lv); } + + +} // namespace frontend +} // namespace lyx + +#include "moc_GuiPrintindex.cpp" diff --git a/src/frontends/qt4/GuiPrintindex.h b/src/frontends/qt4/GuiPrintindex.h new file mode 100644 index 0000000000..74343057c2 --- /dev/null +++ b/src/frontends/qt4/GuiPrintindex.h @@ -0,0 +1,58 @@ +// -*- C++ -*- +/** + * \file GuiPrintindex.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 GUIPRINTINDEX_H +#define GUIPRINTINDEX_H + +#include "GuiDialog.h" +#include "ui_PrintindexUi.h" +#include "insets/InsetCommandParams.h" + + +namespace lyx { +namespace frontend { + +class GuiPrintindex : public GuiDialog, public Ui::PrintindexUi +{ + Q_OBJECT + +public: + GuiPrintindex(GuiView & lv); + +private Q_SLOTS: + void change_adaptor(); + +private: + /// Apply changes + void applyView(); + /// Update dialog before showing it + void updateContents(); + /// + void paramsToDialog(InsetCommandParams const & icp); + /// + bool initialiseParams(std::string const & data); + /// clean-up on hide. + void clearParams() { params_.clear(); } + /// + void dispatchParams(); + /// + bool isBufferDependent() const { return true; } + + /// + InsetCommandParams params_; +}; + +} // namespace frontend +} // namespace lyx + +#endif // GUIPRINTINDEX_H diff --git a/src/frontends/qt4/GuiView.cpp b/src/frontends/qt4/GuiView.cpp index 8e678745ed..607c37a98c 100644 --- a/src/frontends/qt4/GuiView.cpp +++ b/src/frontends/qt4/GuiView.cpp @@ -2392,8 +2392,8 @@ namespace { char const * const dialognames[] = { "aboutlyx", "bibitem", "bibtex", "box", "branch", "changes", "character", "citation", "document", "errorlist", "ert", "external", "file", "findreplace", -"float", "graphics", "include", "index", "info", "nomenclature", "label", -"log", "mathdelimiter", "mathmatrix", "mathspace", "note", "paragraph", +"float", "graphics", "include", "index", "index_print", "info", "nomenclature", +"label", "log", "mathdelimiter", "mathmatrix", "mathspace", "note", "paragraph", "phantom", "prefs", "print", "ref", "sendto", "space", "spellchecker", "symbols", "tabular", "tabularcreate", @@ -2589,6 +2589,7 @@ Dialog * createGuiParagraph(GuiView & lv); Dialog * createGuiPhantom(GuiView & lv); Dialog * createGuiPreferences(GuiView & lv); Dialog * createGuiPrint(GuiView & lv); +Dialog * createGuiPrintindex(GuiView & lv); Dialog * createGuiRef(GuiView & lv); Dialog * createGuiSearch(GuiView & lv); Dialog * createGuiSearchAdv(GuiView & lv); @@ -2698,6 +2699,8 @@ Dialog * GuiView::build(string const & name) #endif if (name == "href") return createGuiHyperlink(*this); + if (name == "index_print") + return createGuiPrintindex(*this); if (name == "listings") return createGuiListings(*this); if (name == "toc") diff --git a/src/frontends/qt4/Makefile.am b/src/frontends/qt4/Makefile.am index 3a50203a06..a14f8cec38 100644 --- a/src/frontends/qt4/Makefile.am +++ b/src/frontends/qt4/Makefile.am @@ -105,6 +105,7 @@ SOURCEFILES = \ GuiPhantom.cpp \ GuiPrefs.cpp \ GuiPrint.cpp \ + GuiPrintindex.cpp \ GuiRef.cpp \ GuiSearch.cpp \ GuiSelection.cpp \ @@ -201,6 +202,7 @@ MOCHEADER = \ GuiPhantom.h \ GuiPrefs.h \ GuiPrint.h \ + GuiPrintindex.h \ GuiRef.h \ GuiSearch.h \ GuiSelection.h \ @@ -299,6 +301,7 @@ UIFILES = \ PrefsUi.ui \ PrefUi.ui \ PrintUi.ui \ + PrintindexUi.ui \ RefUi.ui \ SearchUi.ui \ SendtoUi.ui \ diff --git a/src/frontends/qt4/ui/PrintindexUi.ui b/src/frontends/qt4/ui/PrintindexUi.ui new file mode 100644 index 0000000000..62b9506fd6 --- /dev/null +++ b/src/frontends/qt4/ui/PrintindexUi.ui @@ -0,0 +1,97 @@ + + PrintindexUi + + + + 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/InsetCommandParams.cpp b/src/insets/InsetCommandParams.cpp index d3db765d3f..13e31a7b00 100644 --- a/src/insets/InsetCommandParams.cpp +++ b/src/insets/InsetCommandParams.cpp @@ -55,7 +55,7 @@ static ParamInfo const & findInfo(InsetCode code, string const & cmdName) case BIBTEX_CODE: return InsetBibtex::findInfo(cmdName); case CITE_CODE: - return InsetCitation::findInfo(cmdName); + return InsetCitation::findInfo(cmdName); case FLOAT_LIST_CODE: return InsetFloatList::findInfo(cmdName); case HYPERLINK_CODE: @@ -65,7 +65,7 @@ static ParamInfo const & findInfo(InsetCode code, string const & cmdName) case INDEX_PRINT_CODE: return InsetPrintIndex::findInfo(cmdName); case LABEL_CODE: - return InsetLabel::findInfo(cmdName); + return InsetLabel::findInfo(cmdName); case NOMENCL_CODE: return InsetNomencl::findInfo(cmdName); case NOMENCL_PRINT_CODE: diff --git a/src/insets/InsetIndex.cpp b/src/insets/InsetIndex.cpp index 2827488221..f086f8ff12 100644 --- a/src/insets/InsetIndex.cpp +++ b/src/insets/InsetIndex.cpp @@ -400,21 +400,57 @@ docstring InsetPrintIndex::screenLabel() const } +void InsetPrintIndex::doDispatch(Cursor & cur, FuncRequest & cmd) +{ + switch (cmd.action) { + + case LFUN_INSET_MODIFY: { + InsetCommandParams p(INDEX_PRINT_CODE); + // FIXME UNICODE + InsetCommand::string2params("index_print", + to_utf8(cmd.argument()), p); + if (p.getCmdName().empty()) { + cur.noUpdate(); + break; + } + setParam("type", p["type"]); + break; + } + + default: + InsetCommand::doDispatch(cur, cmd); + break; + } +} + + bool InsetPrintIndex::getStatus(Cursor & cur, FuncRequest const & cmd, FuncStatus & status) const { switch (cmd.action) { case LFUN_INSET_MODIFY: { - InsetCommandParams p(INDEX_PRINT_CODE); - InsetCommand::string2params("index_print", to_utf8(cmd.argument()), p); + if (cmd.getArg(0) == "index_print" + && cmd.getArg(1) == "InsetCommand") { + InsetCommandParams p(INDEX_PRINT_CODE); + InsetCommand::string2params("index_print", + to_utf8(cmd.argument()), p); + Buffer const & realbuffer = *buffer().masterBuffer(); + IndicesList const & indiceslist = + realbuffer.params().indiceslist(); + Index const * index = indiceslist.findShortcut(p["type"]); + status.setEnabled(index != 0); + status.setOnOff(p["type"] == getParam("type")); + return true; + } + } + + case LFUN_INSET_DIALOG_UPDATE: + case LFUN_INSET_SETTINGS: { Buffer const & realbuffer = *buffer().masterBuffer(); - IndicesList const & indiceslist = realbuffer.params().indiceslist(); - Index const * index = indiceslist.findShortcut(p["type"]); - status.setEnabled(index != 0); - status.setOnOff(p["type"] == getParam("type")); + status.setEnabled(realbuffer.params().use_indices); return true; - } + } default: return InsetCommand::getStatus(cur, cmd, status); @@ -448,4 +484,12 @@ docstring InsetPrintIndex::contextMenu(BufferView const &, int, int) const from_ascii("context-indexprint") : docstring(); } + +Inset::EDITABLE InsetPrintIndex::editable() const +{ + return buffer().masterBuffer()->params().use_indices ? + IS_EDITABLE : NOT_EDITABLE; +} + + } // namespace lyx diff --git a/src/insets/InsetIndex.h b/src/insets/InsetIndex.h index 9070e621e8..99d8b8923d 100644 --- a/src/insets/InsetIndex.h +++ b/src/insets/InsetIndex.h @@ -103,6 +103,8 @@ public: /// int latex(odocstream &, OutputParams const &) const; /// + void doDispatch(Cursor & cur, FuncRequest & cmd); + /// bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const; /// virtual docstring contextMenu(BufferView const & bv, int x, int y) const; @@ -110,7 +112,7 @@ private: /// Updates needed features for this inset. void validate(LaTeXFeatures & features) const; /// - EDITABLE editable() const { return NOT_EDITABLE; } + EDITABLE editable() const; /// DisplayType display() const { return AlignCenter; } ///