Attached is the last patch in this series (but for bugfixing): It adds the frontend for selecting modules, etc. Comments welcome.
It doesn't actually seem to work at the moment. Something is broken in this dialog and in the citation dialog. This is presumably a consequence of the recent chaos in src/frontends/.
Richard -- ================================================================== Richard G Heck, Jr Professor of Philosophy Brown University http://frege.brown.edu/heck/ ================================================================== Get my public key from http://sks.keyserver.penguin.de Hash: 0x1DE91F1E66FFBDEC Learn how to sign your email using Thunderbird and GnuPG at: http://dudu.dyn.2-h.org/nist/gpg-enigmail-howto
Index: src/frontends/qt4/GuiDocument.h =================================================================== --- src/frontends/qt4/GuiDocument.h (revision 20265) +++ src/frontends/qt4/GuiDocument.h (working copy) @@ -5,6 +5,7 @@ * Licence details can be found in the file COPYING. * * \author Edwin Leuven + * \author Richard Heck (modules) * * Full author contact details are available in file CREDITS. */ @@ -15,6 +16,7 @@ #include "GuiDialog.h" #include "BulletsModule.h" #include "ControlDocument.h" +#include "GuiSelectionManager.h" #include "ui_DocumentUi.h" #include "ui_FontUi.h" @@ -29,6 +31,8 @@ #include "ui_PreambleUi.h" #include <QDialog> +#include <QStringList> +#include <QStringListModel> #include <vector> #include <string> @@ -49,15 +53,12 @@ namespace frontend { class GuiBranches; -class GuiDocument; class PreambleModule; class GuiDocumentDialog : public GuiDialog, public Ui::DocumentUi { Q_OBJECT public: - friend class GuiDocument; - GuiDocumentDialog(LyXView & lv); void updateParams(BufferParams const & params); @@ -89,7 +90,7 @@ void enableSkip(bool); void portraitChanged(); void classChanged(); - + private: void closeEvent(QCloseEvent * e); @@ -104,17 +105,23 @@ UiWidget<Ui::MathsUi> *mathsModule; UiWidget<Ui::LaTeXUi> *latexModule; PreambleModule *preambleModule; - + GuiBranches *branchesModule; BulletsModule * bulletsModule; FloatPlacement * floatModule; - /// FIXME + GuiSelectionManager * selectionManager; + + // FIXME std::vector<std::string> lang_; /// parent controller ControlDocument & controller(); + /// Available modules + QStringListModel * availableModel() { return &available_model_; } + /// Selected modules + QStringListModel * selectedModel() { return &selected_model_; } private: /// Apply changes void applyView(); @@ -124,6 +131,12 @@ void saveDocDefault(); /// reset to default params void useClassDefaults(); + /// available modules + QStringListModel available_model_; + /// selected modules + QStringListModel selected_model_; + +protected: /// return false if validate_listings_params returns error bool isValid(); }; @@ -158,4 +171,4 @@ } // namespace frontend } // namespace lyx -#endif // GUIDOCUMENT_H +#endif // QDOCUMENT_H Index: src/frontends/qt4/GuiDocument.cpp =================================================================== --- src/frontends/qt4/GuiDocument.cpp (revision 20265) +++ src/frontends/qt4/GuiDocument.cpp (working copy) @@ -4,6 +4,7 @@ * Licence details can be found in the file COPYING. * * \author Edwin Leuven + * \author Richard Heck (modules) * * Full author contact details are available in file CREDITS. */ @@ -565,12 +566,26 @@ this, SLOT(change_adaptor())); connect(latexModule->classCO, SIGNAL(activated(int)), this, SLOT(classChanged())); - // packages + + selectionManager = + new GuiSelectionManager(latexModule->availableLV, latexModule->selectedLV, + latexModule->addPB, latexModule->deletePB, + latexModule->upPB, latexModule->downPB, + availableModel(), selectedModel()); + connect(selectionManager, SIGNAL(updateHook()), + this, SLOT(update())); + connect(selectionManager, SIGNAL(updateHook()), + this, SLOT(change_adaptor())); + + // postscript drivers for (int n = 0; tex_graphics[n][0]; ++n) { QString enc = qt_(tex_graphics_gui[n]); latexModule->psdriverCO->addItem(enc); } - // latex + // latex classes + //FIXME This seems too involved with the kernel. Some of this + //should be moved to the controller---which should perhaps just + //give us a list of entries or something of the sort. for (TextClassList::const_iterator cit = textclasslist.begin(); cit != textclasslist.end(); ++cit) { if (cit->isTeXClassAvailable()) { @@ -970,7 +985,14 @@ // packages params.graphicsDriver = tex_graphics[latexModule->psdriverCO->currentIndex()]; + + // Modules + params.clearLayoutModules(); + QStringList const selMods = selectedModel()->stringList(); + for (int i = 0; i != selMods.size(); ++i) + params.addLayoutModule(lyx::fromqstr(selMods[i])); + if (mathsModule->amsautoCB->isChecked()) { params.use_amsmath = BufferParams::package_auto; } else { @@ -1252,7 +1274,40 @@ int nitem = findToken(tex_graphics, params.graphicsDriver); if (nitem >= 0) latexModule->psdriverCO->setCurrentIndex(nitem); - + selectionManager->updateView(); + //Module description + QListView const * const lv = selectionManager->selectedFocused() ? + latexModule->selectedLV : + latexModule->availableLV; + if (lv->selectionModel()->selectedIndexes().isEmpty()) + latexModule->infoML->document()->clear(); + else { + QModelIndex const idx = lv->selectionModel()->currentIndex(); + string const modName = fromqstr(idx.data().toString()); + string desc = controller().getModuleDescription(modName); + vector<string> pkgList = controller().getPackageList(modName); + string pkgdesc; + //this mess formats the package list as "pkg1, pkg2, and pkg3" + int const pkgListSize = pkgList.size(); + for (int i = 0; i < pkgListSize; ++i) { + if (i == 1) { + if (i == pkgListSize - 1) //last element + pkgdesc += " and "; + else + pkgdesc += ", "; + } else if (i > 1) { + if (i == pkgListSize - 1) //last element + pkgdesc += ", and "; + else + pkgdesc += ", "; + } + pkgdesc += pkgList[i]; + } + if (!pkgdesc.empty()) + desc += " Requires " + pkgdesc + "."; + latexModule->infoML->document()->setPlainText(toqstr(desc)); + } + mathsModule->amsCB->setChecked( params.use_amsmath == BufferParams::package_on); mathsModule->amsautoCB->setChecked( @@ -1272,7 +1327,7 @@ // text layout latexModule->classCO->setCurrentIndex(params.getBaseClass()); - + updatePagestyle(controller().textClass().opt_pagestyle(), params.pagestyle); @@ -1283,12 +1338,10 @@ } setLSpacing(nitem); - if (params.paragraph_separation - == BufferParams::PARSEP_INDENT) { + if (params.paragraph_separation == BufferParams::PARSEP_INDENT) textLayoutModule->indentRB->setChecked(true); - } else { + else textLayoutModule->skipRB->setChecked(true); - } int skip = 0; switch (params.getDefSkip().kind()) { @@ -1420,12 +1473,6 @@ } -void GuiDocumentDialog::updateContents() -{ - updateParams(controller().params()); -} - - void GuiDocumentDialog::saveDocDefault() { // we have to apply the params first @@ -1434,12 +1481,31 @@ } +void GuiDocumentDialog::updateContents() +{ + //update list of available modules + QStringList strlist; + vector<string> const modNames = controller().getModuleNames(); + vector<string>::const_iterator it = modNames.begin(); + for (; it != modNames.end(); ++it) + strlist.push_back(toqstr(*it)); + available_model_.setStringList(strlist); + //and selected ones, too + QStringList strlist2; + vector<string> const & selMods = controller().getSelectedModules(); + it = selMods.begin(); + for (; it != selMods.end(); ++it) + strlist2.push_back(toqstr(*it)); + selected_model_.setStringList(strlist2); + + updateParams(controller().params()); +} + void GuiDocumentDialog::useClassDefaults() { BufferParams & params = controller().params(); params.setJustBaseClass(latexModule->classCO->currentIndex()); - params.useClassDefaults(); updateContents(); } Index: src/frontends/qt4/ui/LaTeXUi.ui =================================================================== --- src/frontends/qt4/ui/LaTeXUi.ui (revision 20265) +++ src/frontends/qt4/ui/LaTeXUi.ui (working copy) @@ -1,12 +1,15 @@ <ui version="4.0" > + <author></author> + <comment></comment> + <exportmacro></exportmacro> <class>LaTeXUi</class> <widget class="QWidget" name="LaTeXUi" > <property name="geometry" > <rect> <x>0</x> <y>0</y> - <width>307</width> - <height>178</height> + <width>428</width> + <height>465</height> </rect> </property> <property name="windowTitle" > @@ -19,49 +22,139 @@ <property name="spacing" > <number>6</number> </property> - <item row="3" column="1" > + <item row="5" column="2" colspan="2" > <spacer> <property name="orientation" > <enum>Qt::Vertical</enum> </property> <property name="sizeHint" > <size> - <width>20</width> - <height>40</height> + <width>84</width> + <height>41</height> </size> </property> </spacer> </item> - <item row="2" column="2" > + <item row="4" column="3" > <spacer> <property name="orientation" > <enum>Qt::Horizontal</enum> </property> <property name="sizeHint" > <size> - <width>40</width> - <height>20</height> + <width>261</width> + <height>22</height> </size> </property> </spacer> </item> - <item row="2" column="1" > + <item row="4" column="2" > <widget class="QComboBox" name="psdriverCO" > <property name="duplicatesEnabled" > <bool>false</bool> </property> </widget> </item> - <item row="0" column="0" > - <widget class="QLabel" name="classL" > + <item row="4" column="0" colspan="2" > + <widget class="QLabel" name="psdriverL" > <property name="text" > - <string>Document &class:</string> + <string>Postscript &driver:</string> </property> <property name="buddy" > - <cstring>classCO</cstring> + <cstring>psdriverCO</cstring> </property> </widget> </item> + <item row="3" column="0" colspan="4" > + <widget class="QTextBrowser" name="infoML" /> + </item> + <item row="2" column="0" colspan="4" > + <widget class="QGroupBox" name="modulesGB" > + <property name="title" > + <string>Modules</string> + </property> + <layout class="QGridLayout" > + <property name="margin" > + <number>9</number> + </property> + <property name="spacing" > + <number>6</number> + </property> + <item row="0" column="0" > + <widget class="QLabel" name="availmodL" > + <property name="text" > + <string>Available Modules</string> + </property> + </widget> + </item> + <item row="0" column="2" > + <widget class="QLabel" name="selmodL" > + <property name="text" > + <string>Selected Modules</string> + </property> + </widget> + </item> + <item rowspan="5" row="1" column="0" > + <widget class="QListView" name="availableLV" > + <property name="editTriggers" > + <set>QAbstractItemView::NoEditTriggers</set> + </property> + </widget> + </item> + <item row="1" column="1" > + <widget class="QPushButton" name="addPB" > + <property name="text" > + <string>Add</string> + </property> + </widget> + </item> + <item rowspan="5" row="1" column="2" > + <widget class="QListView" name="selectedLV" > + <property name="editTriggers" > + <set>QAbstractItemView::NoEditTriggers</set> + </property> + </widget> + </item> + <item row="2" column="1" > + <widget class="QPushButton" name="deletePB" > + <property name="text" > + <string>Delete</string> + </property> + </widget> + </item> + <item row="3" column="1" > + <widget class="QPushButton" name="upPB" > + <property name="text" > + <string>Up</string> + </property> + </widget> + </item> + <item row="4" column="1" > + <widget class="QPushButton" name="downPB" > + <property name="text" > + <string>Down</string> + </property> + </widget> + </item> + <item row="5" column="1" > + <spacer> + <property name="orientation" > + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" > + <size> + <width>80</width> + <height>46</height> + </size> + </property> + </spacer> + </item> + </layout> + </widget> + </item> + <item row="1" column="1" colspan="3" > + <widget class="QLineEdit" name="optionsLE" /> + </item> <item row="1" column="0" > <widget class="QLabel" name="optionsL" > <property name="text" > @@ -72,27 +165,32 @@ </property> </widget> </item> - <item row="2" column="0" > - <widget class="QLabel" name="psdriverL" > + <item row="0" column="1" colspan="3" > + <widget class="QComboBox" name="classCO" /> + </item> + <item row="0" column="0" > + <widget class="QLabel" name="classL" > <property name="text" > - <string>Postscript &driver:</string> + <string>Document &class:</string> </property> <property name="buddy" > - <cstring>psdriverCO</cstring> + <cstring>classCO</cstring> </property> </widget> </item> - <item row="0" column="1" colspan="2" > - <widget class="QComboBox" name="classCO" /> - </item> - <item row="1" column="1" colspan="2" > - <widget class="QLineEdit" name="optionsLE" /> - </item> </layout> </widget> + <pixmapfunction></pixmapfunction> <tabstops> <tabstop>classCO</tabstop> <tabstop>optionsLE</tabstop> + <tabstop>availableLV</tabstop> + <tabstop>addPB</tabstop> + <tabstop>deletePB</tabstop> + <tabstop>upPB</tabstop> + <tabstop>downPB</tabstop> + <tabstop>selectedLV</tabstop> + <tabstop>infoML</tabstop> <tabstop>psdriverCO</tabstop> </tabstops> <includes> Index: src/frontends/controllers/ControlDocument.cpp =================================================================== --- src/frontends/controllers/ControlDocument.cpp (revision 20265) +++ src/frontends/controllers/ControlDocument.cpp (working copy) @@ -4,6 +4,7 @@ * Licence details can be found in the file COPYING. * * \author Edwin Leuven + * \author Richard Heck (modules) * * Full author contact details are available in file CREDITS. */ @@ -17,11 +18,12 @@ #include "BufferParams.h" #include "BufferView.h" #include "buffer_funcs.h" +#include "Color.h" #include "FuncRequest.h" #include "gettext.h" #include "Language.h" #include "LaTeXFeatures.h" -#include "Color.h" +#include "ModuleList.h" #include "OutputParams.h" #include "TextClassList.h" @@ -34,6 +36,7 @@ using std::ostringstream; using std::string; +using std::vector; namespace lyx { namespace frontend { @@ -61,6 +64,7 @@ { bp_.reset(new BufferParams); *bp_ = buffer().params(); + loadModuleNames(); return true; } @@ -84,6 +88,36 @@ } +vector<string> ControlDocument::getModuleNames() +{ + return moduleNames_; +} + + +vector<string> const & ControlDocument::getSelectedModules() +{ + return params().getModules(); +} + + +string ControlDocument::getModuleDescription(string modName) const +{ + LyXModule const * const mod = moduleList[modName]; + if (!mod) + return string("Module unavailable!"); + return mod->description; +} + + +std::vector<std::string> + ControlDocument::getPackageList(std::string modName) const { + LyXModule const * const mod = moduleList[modName]; + if (!mod) + return std::vector<std::string>(); //empty such thing + return mod->packageList; +} + + TextClass const & ControlDocument::textClass() const { return textclasslist[bp_->getBaseClass()]; @@ -207,5 +241,16 @@ } +void ControlDocument::loadModuleNames () +{ + moduleNames_.clear(); + LyXModuleList::const_iterator it = moduleList.begin(); + for (; it != moduleList.end(); ++it) + moduleNames_.push_back(it->name); + if (!moduleNames_.empty()) + sort(moduleNames_.begin(), moduleNames_.end()); +} + + } // namespace frontend } // namespace lyx Index: src/frontends/controllers/ControlDocument.h =================================================================== --- src/frontends/controllers/ControlDocument.h (revision 20265) +++ src/frontends/controllers/ControlDocument.h (working copy) @@ -5,6 +5,7 @@ * Licence details can be found in the file COPYING. * * \author Edwin Leuven + * \author Richard Heck (modules) * * Full author contact details are available in file CREDITS. */ @@ -13,8 +14,12 @@ #define CONTROLDOCUMENT_H #include "Dialog.h" +#include "support/FileName.h" +#include "support/filetools.h" #include "support/types.h" #include <boost/scoped_ptr.hpp> +#include <map> +#include <vector> namespace lyx { @@ -22,9 +27,11 @@ class TextClass; namespace frontend { - + /// typedef void const * BufferId; +/// +typedef std::map<std::string, support::FileName> ModuleMap; /** A controller for Document dialogs. */ @@ -54,7 +61,15 @@ BufferParams & params() const; /// BufferId id() const; + /// List of available modules + std::vector<std::string> getModuleNames(); + /// Modules in use in current buffer + std::vector<std::string> const & getSelectedModules(); /// + std::string getModuleDescription(std::string modName) const; + /// + std::vector<std::string> getPackageList(std::string modName) const; + /// void setLanguage() const; /// void saveAsDefault() const; @@ -68,7 +83,11 @@ bool const providesScale(std::string const & font) const; private: /// + void loadModuleNames(); + /// boost::scoped_ptr<BufferParams> bp_; + /// List of names of available modules + std::vector<std::string> moduleNames_; }; } // namespace frontend