]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiDocument.cpp
The default modules should be kept in order.
[lyx.git] / src / frontends / qt4 / GuiDocument.cpp
index 947f929aa5961051b0a75eddd914557af714f615..6a9cdf79e4b59b379b715ed562994d8418cff108 100644 (file)
@@ -15,6 +15,7 @@
 
 #include "GuiApplication.h"
 #include "GuiBranches.h"
+#include "GuiSelectionManager.h"
 #include "LaTeXHighlighter.h"
 #include "LengthCombo.h"
 #include "PanelStack.h"
@@ -70,15 +71,21 @@ namespace {
 
 char const * const tex_graphics[] =
 {
-       "default", "dvips", "dvitops", "emtex",
-       "ln", "oztex", "textures", "none", ""
+       "default", "dvialw", "dvilaser", "dvipdf", "dvipdfm", "dvipdfmx",
+       "dvips", "dvipsone", "dvitops", "dviwin", "dviwindo", "dvi2ps", "emtex",
+       "ln", "oztex", "pctexhp", "pctexps", "pctexwin", "pctex32", "pdftex",
+       "psprint", "pubps", "tcidvi", "textures", "truetex", "vtex", "xdvi",
+       "xetex", "none", ""
 };
 
 
 char const * const tex_graphics_gui[] =
 {
-       N_("Default"), "Dvips", "DVItoPS", "EmTeX",
-       "LN", "OzTeX", "Textures", N_("None"), ""
+       N_("Default"), "dvialw", "DviLaser", "dvipdf", "DVIPDFM", "DVIPDFMx",
+       "Dvips", "DVIPSONE", "DVItoPS", "DVIWIN", "DVIWindo", "dvi2ps", "EmTeX",
+       "LN", "OzTeX", "pctexhp", "pctexps", "pctexwin", "PCTeX32", "pdfTeX",
+       "psprint", "pubps", "tcidvi", "Textures", "TrueTeX", "VTeX", "xdvi",
+       "XeTeX", N_("None"), ""
 };
 
 
@@ -140,7 +147,7 @@ class less_textclass_avail_desc
        : public binary_function<string, string, int>
 {
 public:
-       int operator()(string const & lhs, string const & rhs) const
+       bool operator()(string const & lhs, string const & rhs) const
        {
                // Ordering criteria:
                //   1. Availability of text class
@@ -156,20 +163,6 @@ public:
 }
 
 namespace frontend {
-
-
-/// 
-QModelIndex getSelectedIndex(QListView * lv)
-{
-       QModelIndex retval = QModelIndex();
-       QModelIndexList selIdx = 
-                       lv->selectionModel()->selectedIndexes();
-       if (!selIdx.empty())
-               retval = selIdx.first();
-       return retval;
-}
-
-
 namespace {
 
 vector<string> getRequiredList(string const & modName) 
@@ -225,20 +218,45 @@ bool isModuleAvailable(string const & modName)
 //
 /////////////////////////////////////////////////////////////////////
 
-ModuleSelectionManager::ModuleSelectionManager(
-       QListView * availableLV, 
-       QListView * selectedLV,
-       QPushButton * addPB, 
-       QPushButton * delPB, 
-       QPushButton * upPB, 
-       QPushButton * downPB,
-       GuiIdListModel * availableModel,
-       GuiIdListModel * selectedModel) :
-GuiSelectionManager(availableLV, selectedLV, addPB, delPB,
+/// SelectionManager for use with modules
+class ModuleSelectionManager : public GuiSelectionManager 
+{
+public:
+       ModuleSelectionManager(
+               QListView * availableLV, 
+               QListView * selectedLV,
+               QPushButton * addPB, 
+               QPushButton * delPB, 
+               QPushButton * upPB, 
+               QPushButton * downPB,
+               GuiIdListModel * availableModel,
+               GuiIdListModel * selectedModel)
+       : GuiSelectionManager(availableLV, selectedLV, addPB, delPB,
                     upPB, downPB, availableModel, selectedModel) 
-{}
+               {}
        
 
+private:
+       ///
+       virtual void updateAddPB();
+       ///
+       virtual void updateUpPB();
+       ///
+       virtual void updateDownPB();
+       ///
+       virtual void updateDelPB();
+       /// returns availableModel as a GuiIdListModel
+       GuiIdListModel * getAvailableModel() 
+       {
+               return dynamic_cast<GuiIdListModel *>(availableModel);
+       }
+       /// returns selectedModel as a GuiIdListModel
+       GuiIdListModel * getSelectedModel() 
+       {
+               return dynamic_cast<GuiIdListModel *>(selectedModel);
+       }
+};
+
 void ModuleSelectionManager::updateAddPB() 
 {
        int const arows = availableModel->rowCount();
@@ -1576,9 +1594,9 @@ void GuiDocument::apply(BufferParams & params)
                params.addLayoutModule(modules_sel_model_.getIDString(i));
        // update the list of removed modules
        params.clearRemovedModules();
-       set<string> const & reqmods = params.baseClass()->defaultModules();
-       set<string>::const_iterator rit = reqmods.begin();
-       set<string>::const_iterator ren = reqmods.end();
+       list<string> const & reqmods = params.baseClass()->defaultModules();
+       list<string>::const_iterator rit = reqmods.begin();
+       list<string>::const_iterator ren = reqmods.end();
        // check each of the required modules
        for (; rit != ren; rit++) {
                vector<string>::const_iterator mit = params.getModules().begin();
@@ -2204,7 +2222,7 @@ char const * GuiDocument::fontfamilies_gui[5] = {
 
 bool GuiDocument::initialiseParams(string const &)
 {
-       BufferView * view = bufferview();
+       BufferView const * view = bufferview();
        if (!view) {
                bp_ = BufferParams();
                paramsToDialog(bp_);
@@ -2293,7 +2311,7 @@ void GuiDocument::dispatchParams()
                           support::onlyPath(buffer().absFileName()));
                if (isLyXFilename(master_file.absFilename())) {
                        Buffer * master = checkAndLoadLyXFile(master_file);
-                       buffer().setParent(master);
+                       const_cast<Buffer &>(buffer()).setParent(master);
                }
        }
 
@@ -2303,9 +2321,9 @@ void GuiDocument::dispatchParams()
                BranchList::const_iterator it = branchlist.begin();
                BranchList::const_iterator const end = branchlist.end();
                for (; it != end; ++it) {
-                       docstring const & current_branch = it->getBranch();
+                       docstring const & current_branch = it->branch();
                        Branch const * branch = branchlist.find(current_branch);
-                       string const x11hexname = X11hexname(branch->getColor());
+                       string const x11hexname = X11hexname(branch->color());
                        // display the new color
                        docstring const str = current_branch + ' ' + from_ascii(x11hexname);
                        dispatch(FuncRequest(LFUN_SET_COLOR, str));
@@ -2316,7 +2334,8 @@ void GuiDocument::dispatchParams()
                        "assign branch"));
        }
        // FIXME: If we used an LFUN, we would not need those two lines:
-       bufferview()->processUpdateFlags(Update::Force | Update::FitCursor);
+       BufferView * bv = const_cast<BufferView *>(bufferview());
+       bv->processUpdateFlags(Update::Force | Update::FitCursor);
 }