* 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.
*/
#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"
using std::ostringstream;
using std::string;
+using std::vector;
namespace lyx {
namespace frontend {
{
bp_.reset(new BufferParams);
*bp_ = buffer().params();
+ loadModuleNames();
return true;
}
}
+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()];
}
+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
* 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.
*/
#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 {
class TextClass;
namespace frontend {
-
+
///
typedef void const * BufferId;
+///
+typedef std::map<std::string, support::FileName> ModuleMap;
/** A controller for Document dialogs.
*/
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;
///
/// does this font provide size adjustment?
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
* 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.
*/
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(updateModuleInfo()));
+ 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()) {
}
+void GuiDocumentDialog::updateModuleInfo()
+{
+ selectionManager->update();
+ //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));
+ }
+}
+
+
void GuiDocumentDialog::updateNumbering()
{
TextClass const & tclass = controller().params().getTextClass();
// 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;
}
+void GuiDocumentDialog::updateParams()
+{
+ BufferParams const & params = controller().params();
+ updateParams(params);
+}
+
+
void GuiDocumentDialog::updateParams(BufferParams const & params)
{
// set the default unit
int nitem = findToken(tex_graphics, params.graphicsDriver);
if (nitem >= 0)
latexModule->psdriverCO->setCurrentIndex(nitem);
-
+ updateModuleInfo();
+
mathsModule->amsCB->setChecked(
params.use_amsmath == BufferParams::package_on);
mathsModule->amsautoCB->setChecked(
// text layout
latexModule->classCO->setCurrentIndex(params.getBaseClass());
-
+
updatePagestyle(controller().textClass().opt_pagestyle(),
params.pagestyle);
}
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()) {
}
-void GuiDocumentDialog::updateContents()
-{
- updateParams(controller().params());
-}
-
-
void GuiDocumentDialog::saveDocDefault()
{
// we have to apply the params first
}
+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();
}
* 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.
*/
#include "GuiDialog.h"
#include "BulletsModule.h"
#include "ControlDocument.h"
+#include "GuiSelectionManager.h"
#include "ui_DocumentUi.h"
#include "ui_FontUi.h"
#include "ui_PreambleUi.h"
#include <QDialog>
+#include <QStringList>
+#include <QStringListModel>
#include <vector>
#include <string>
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);
void useDefaultsClicked();
private Q_SLOTS:
+ void updateParams();
void setLSpacing(int);
void setMargins(bool);
void setCustomPapersize(int);
void enableSkip(bool);
void portraitChanged();
void classChanged();
-
+ void updateModuleInfo();
+
private:
void closeEvent(QCloseEvent * e);
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();
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();
};
} // namespace frontend
} // namespace lyx
-#endif // GUIDOCUMENT_H
+#endif // QDOCUMENT_H
<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" >
<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" >
</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>