2006-03-05 17:24:44 +00:00
/**
2007-08-31 05:53:55 +00:00
* \ file GuiDocument . cpp
2006-03-05 17:24:44 +00:00
* This file is part of LyX , the document processor .
* Licence details can be found in the file COPYING .
*
* \ author Edwin Leuven
This is the last of a series of patches that merges the layout modules development in personal/branches/rgheck back into the tree.
Design goal: Allow the use of layout "modules", which are to LaTeX packages as layout files are to LaTeX document classes. Thus, one could have a module that defined certain character styles, environments, commands, or what have you, and include it in various documents, each of which uses a different document class, without having to modify the layout files themselves. For example, a theorems.module could be used with article.layout to provide support for theorem-type environments, without having to modify article.layout itself, and the same module could be used with book.layout, etc.
This patch adds the GUI for managing modules.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20282 a592a061-630c-0410-9148-cb99ea01b6c8
2007-09-15 01:55:09 +00:00
* \ author Richard Heck ( modules )
2006-03-05 17:24:44 +00:00
*
* Full author contact details are available in file CREDITS .
*/
# include <config.h>
2007-08-31 05:53:55 +00:00
# include "GuiDocument.h"
2006-03-05 17:24:44 +00:00
2012-10-09 05:22:48 +00:00
# include "CategorizedCombo.h"
2008-05-08 09:18:45 +00:00
# include "GuiApplication.h"
# include "GuiBranches.h"
2009-04-16 07:29:01 +00:00
# include "GuiIndices.h"
2008-09-20 13:44:51 +00:00
# include "GuiSelectionManager.h"
2008-05-08 09:18:45 +00:00
# include "LaTeXHighlighter.h"
# include "LengthCombo.h"
# include "PanelStack.h"
# include "Validator.h"
2008-03-07 03:53:21 +00:00
# include "LayoutFile.h"
2007-10-06 22:43:21 +00:00
# include "BranchList.h"
# include "buffer_funcs.h"
# include "Buffer.h"
# include "BufferParams.h"
# include "BufferView.h"
2007-11-02 23:42:27 +00:00
# include "Color.h"
2009-04-11 21:40:11 +00:00
# include "ColorCache.h"
2007-10-06 22:43:21 +00:00
# include "Encoding.h"
2006-08-25 13:40:01 +00:00
# include "FloatPlacement.h"
2009-04-10 11:06:53 +00:00
# include "Format.h"
2007-10-06 22:43:21 +00:00
# include "FuncRequest.h"
2009-07-19 21:13:27 +00:00
# include "HSpace.h"
2009-04-16 07:29:01 +00:00
# include "IndicesList.h"
2007-10-06 22:43:21 +00:00
# include "Language.h"
# include "LaTeXFeatures.h"
2012-08-16 11:23:39 +00:00
# include "LaTeXFonts.h"
2007-09-29 20:02:32 +00:00
# include "Layout.h"
2012-10-09 05:22:48 +00:00
# include "LayoutEnums.h"
2009-02-12 15:07:22 +00:00
# include "LayoutModuleList.h"
2009-02-06 21:24:13 +00:00
# include "LyXRC.h"
2007-10-06 22:43:21 +00:00
# include "ModuleList.h"
# include "OutputParams.h"
# include "PDFOptions.h"
2007-05-14 12:09:14 +00:00
# include "qt_helpers.h"
2007-10-06 22:43:21 +00:00
# include "Spacing.h"
A UI for document-local layout information. LyX has supported this for a
while, but without any UI for it. (There has been local layout in the
Customization manual for a long time, in fact.)
Yes, this is an advanced feature. But, absent a layout editor, it is the
one thing that will make it easier, and possible, for "normal users" to
experiment with layout without having to go through reconfiguration,
etc, etc. To keep too many people from shooting themselves, we validate
the layout information before allowing the user to apply it.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@35061 a592a061-630c-0410-9148-cb99ea01b6c8
2010-08-05 22:47:42 +00:00
# include "TextClass.h"
2007-05-14 12:09:14 +00:00
Add support for listings package. Two listings command \lstinline, \lstinputlisting and an environment \lstlisting are supported, along with preamble \lstset. \lstinputlisting is implemented through Include dialog, and the other two are implemented with a new inset listings, along with its dialog.
* src/LyXAction.cpp: listing-insert action
* src/insets/Inset.h,cpp: LISTINGS_CODE
* src/insets/InsetInclude.cpp: handle \lstinputlisting
* src/insets/InsetListings.h,cpp: new listings inset
* src/insets/InsetListingsParams.h,cpp: parameters from listings package
* src/insets/InsetCommandParams.h,cpp: handle lstinputlisting option
* src/Bidi.cpp: handle LISTINGS_CODE
* src/frontends/qt4/ui/TextLayoutUi.ui: update UI
* src/frontends/qt4/ui/ListingsUi.ui: new dialog
* src/frontends/qt4/ui/IncludeUi.ui: update UI
* src/frontends/qt4/QInclude.h,cpp: add lstinputlisting
* src/frontends/qt4/QDocument.h,cpp: add textedit for preamble listings_params
* src/frontends/qt4/QListings.h,cpp: new listings inset
* src/frontends/qt4/Dialogs.cpp: new listings dialog
* src/frontends/controllers/ControlInclude.h,cpp: add lstinputlisting
* src/frontends/controllers/ControlListings.h,cpp: new listings inset
* src/LyXFunc.cpp: handle LISTING_CODE
* src/Paragraph.cpp: handle LISTING_CODE
* src/factory.cpp: new listings inset
* src/CutAndPaste.cpp: handle LISTINGS_CODE
* src/LaTeXFeatures.cpp: require listings
* src/Text3.cpp: Handle LISTINGS_CODE
* src/lfuns.h: add LFUN_LISTING_INSERT
* src/Buffer.cpp: change lyx file format to 269
* src/BufferParams.h,cpp: add listings_params to preamble
* lib/lyx2lyx/LyX.py: lyx2lyx
* lib/lyx2lyx/lyx_1_5.py: lyx2lyx
* lib/ui/stdmenus.inc: new menu item (no shortcut!)
* src/insets/Makefile.am: update autotools
* src/frontends/controllers/Makefile.am
* src/frontends/qt4/Makefile.dialogs
* src/frontends/qt4/Makefile.am
* po/POTFILES.in: a few more translatable files.
* development/scons/scons_manifest.py: scons build system
* development/FORMAT: document format changes
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@18243 a592a061-630c-0410-9148-cb99ea01b6c8
2007-05-09 19:11:42 +00:00
# include "insets/InsetListingsParams.h"
2006-03-05 17:24:44 +00:00
2008-02-28 21:04:55 +00:00
# include "support/debug.h"
2007-12-05 09:23:19 +00:00
# include "support/FileName.h"
# include "support/filetools.h"
2008-05-08 09:18:45 +00:00
# include "support/gettext.h"
2012-01-03 20:51:07 +00:00
# include "support/lassert.h"
2006-03-05 17:24:44 +00:00
# include "support/lstrings.h"
2008-01-15 10:38:19 +00:00
# include "frontends/alert.h"
2008-05-14 10:34:19 +00:00
# include <QAbstractItemModel>
2009-08-18 07:20:40 +00:00
# include <QHeaderView>
2009-04-11 21:40:11 +00:00
# include <QColor>
# include <QColorDialog>
2007-05-14 12:09:14 +00:00
# include <QCloseEvent>
2009-04-06 06:58:30 +00:00
# include <QFontDatabase>
2007-05-14 14:23:55 +00:00
# include <QScrollBar>
2007-05-14 12:09:14 +00:00
# include <QTextCursor>
2006-03-05 17:24:44 +00:00
2007-10-06 22:43:21 +00:00
# include <sstream>
2008-10-14 14:04:21 +00:00
# include <vector>
2006-03-05 17:24:44 +00:00
2008-04-16 16:48:12 +00:00
# ifdef IN
# undef IN
# endif
2009-04-11 21:40:11 +00:00
// a style sheet for buttons
// this is for example used for the background color setting button
2009-04-12 09:13:46 +00:00
static inline QString colorButtonStyleSheet ( QColor const & bgColor )
2009-04-11 21:40:11 +00:00
{
2009-04-12 09:13:46 +00:00
if ( bgColor . isValid ( ) ) {
2010-04-02 23:50:39 +00:00
QString rc = QLatin1String ( " background-color: " ) ;
2009-04-12 09:13:46 +00:00
rc + = bgColor . name ( ) ;
return rc ;
}
2009-04-12 10:11:54 +00:00
return QString ( ) ;
2009-04-11 21:40:11 +00:00
}
2007-12-12 10:16:00 +00:00
using namespace std ;
2007-12-12 19:57:42 +00:00
using namespace lyx : : support ;
2007-04-24 19:37:34 +00:00
2008-01-14 19:52:16 +00:00
2008-02-28 21:04:55 +00:00
namespace {
2008-01-14 19:52:16 +00:00
2007-09-05 20:33:29 +00:00
char const * const tex_graphics [ ] =
{
2008-09-29 19:33:37 +00:00
" 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 " , " "
2007-04-30 21:01:24 +00:00
} ;
2007-09-05 20:33:29 +00:00
char const * const tex_graphics_gui [ ] =
{
2008-09-29 19:33:37 +00:00
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 " ) , " "
2007-06-01 17:44:04 +00:00
} ;
2008-10-13 16:01:02 +00:00
char const * backref_opts [ ] =
{
" false " , " section " , " slide " , " page " , " "
} ;
char const * backref_opts_gui [ ] =
{
N_ ( " Off " ) , N_ ( " Section " ) , N_ ( " Slide " ) , N_ ( " Page " ) , " "
} ;
2012-01-03 20:51:07 +00:00
char const * packages_gui [ ] [ 4 ] =
{
{ " amsmath " ,
2012-05-06 18:48:04 +00:00
N_ ( " &Use amsmath package automatically " ) ,
N_ ( " Use ams&math package " ) ,
N_ ( " The LaTeX package amsmath is only used if AMS formula types or symbols from the AMS math toolbars are inserted into formulas " ) } ,
{ " amssymb " ,
N_ ( " &Use amssymb package automatically " ) ,
N_ ( " Use amssymb package " ) ,
N_ ( " The LaTeX package amssymb is only used if symbols from the AMS math toolbars are inserted into formulas " ) } ,
2012-01-03 20:51:07 +00:00
{ " esint " ,
N_ ( " Use esint package &automatically " ) ,
N_ ( " Use &esint package " ) ,
N_ ( " The LaTeX package esint is only used if special integral symbols are inserted into formulas " ) } ,
{ " mathdots " ,
N_ ( " Use math&dots package automatically " ) ,
N_ ( " Use mathdo&ts package " ) ,
N_ ( " The LaTeX package mathdots is only used if the command \\ iddots is inserted into formulas " ) } ,
2012-01-05 20:53:48 +00:00
{ " mathtools " ,
N_ ( " Use mathtools package automatically " ) ,
N_ ( " Use mathtools package " ) ,
N_ ( " The LaTeX package mathtools is only used if some mathematical relations are inserted into formulas " ) } ,
2012-01-03 20:51:07 +00:00
{ " mhchem " ,
N_ ( " Use mhchem &package automatically " ) ,
N_ ( " Use mh&chem package " ) ,
N_ ( " The LaTeX package mhchem is only used if either the command \\ ce or \\ cf is inserted into formulas " ) } ,
2012-12-28 18:51:28 +00:00
{ " stackrel " ,
N_ ( " Use stackrel package automatically " ) ,
N_ ( " Use stackrel package " ) ,
N_ ( " The LaTeX package stackrel is only used if the command \\ stackrel with subscript is inserted into formulas " ) } ,
2012-12-15 12:02:40 +00:00
{ " stmaryrd " ,
N_ ( " Use stmaryrd package automatically " ) ,
N_ ( " Use stmaryrd package " ) ,
N_ ( " The LaTeX package stmaryrd is only used if symbols from the St Mary's Road symbol font for theoretical computer science are inserted into formulas " ) } ,
2012-01-03 20:51:07 +00:00
{ " undertilde " ,
N_ ( " Use u&ndertilde package automatically " ) ,
N_ ( " Use undertilde pac&kage " ) ,
N_ ( " The LaTeX package undertilde is only used if you use the math frame decoration 'utilde' " ) } ,
{ " " , " " , " " , " " }
} ;
2012-03-01 00:41:30 +00:00
vector < string > engine_types_ ;
2008-09-20 12:57:12 +00:00
vector < pair < string , QString > > pagestyles ;
2007-06-01 17:44:04 +00:00
2012-08-16 11:23:39 +00:00
QMap < QString , QString > rmfonts_ ;
QMap < QString , QString > sffonts_ ;
QMap < QString , QString > ttfonts_ ;
2012-09-22 15:44:00 +00:00
QMap < QString , QString > mathfonts_ ;
2012-08-16 11:23:39 +00:00
2007-06-01 17:44:04 +00:00
2008-02-28 21:04:55 +00:00
} // anonymous namespace
2007-04-25 10:25:37 +00:00
namespace lyx {
2008-02-28 21:04:55 +00:00
2009-04-11 21:40:11 +00:00
RGBColor set_backgroundcolor ;
2010-04-05 20:31:10 +00:00
bool is_backgroundcolor ;
2010-04-02 23:39:36 +00:00
RGBColor set_fontcolor ;
bool is_fontcolor ;
2010-03-31 00:46:50 +00:00
RGBColor set_notefontcolor ;
2010-04-08 00:14:08 +00:00
RGBColor set_boxbgcolor ;
2009-04-11 21:40:11 +00:00
2008-02-28 21:04:55 +00:00
namespace {
// used when sorting the textclass list.
class less_textclass_avail_desc
: public binary_function < string , string , int >
{
public :
2008-09-20 13:44:51 +00:00
bool operator ( ) ( string const & lhs , string const & rhs ) const
2008-02-28 21:04:55 +00:00
{
// Ordering criteria:
// 1. Availability of text class
// 2. Description (lexicographic)
2008-03-07 03:53:21 +00:00
LayoutFile const & tc1 = LayoutFileList : : get ( ) [ lhs ] ;
LayoutFile const & tc2 = LayoutFileList : : get ( ) [ rhs ] ;
2009-08-06 12:44:06 +00:00
int const order = compare_no_case (
2009-03-18 18:47:42 +00:00
translateIfPossible ( from_utf8 ( tc1 . description ( ) ) ) ,
translateIfPossible ( from_utf8 ( tc2 . description ( ) ) ) ) ;
2008-02-28 21:04:55 +00:00
return ( tc1 . isTeXClassAvailable ( ) & & ! tc2 . isTeXClassAvailable ( ) ) | |
2009-08-06 12:44:06 +00:00
( tc1 . isTeXClassAvailable ( ) = = tc2 . isTeXClassAvailable ( ) & & order < 0 ) ;
2008-02-28 21:04:55 +00:00
}
} ;
}
2007-04-25 10:25:37 +00:00
namespace frontend {
2008-01-09 18:51:02 +00:00
namespace {
2011-12-03 22:15:11 +00:00
vector < string > getRequiredList ( string const & modName )
2008-09-20 12:17:15 +00:00
{
2009-08-14 15:37:34 +00:00
LyXModule const * const mod = theModuleList [ modName ] ;
2008-09-20 12:17:15 +00:00
if ( ! mod )
return vector < string > ( ) ; //empty such thing
return mod - > getRequiredModules ( ) ;
}
2008-01-09 18:51:02 +00:00
2008-09-20 12:17:15 +00:00
vector < string > getExcludedList ( string const & modName )
{
2009-08-14 15:37:34 +00:00
LyXModule const * const mod = theModuleList [ modName ] ;
2008-09-20 12:17:15 +00:00
if ( ! mod )
return vector < string > ( ) ; //empty such thing
return mod - > getExcludedModules ( ) ;
}
2008-01-09 18:51:02 +00:00
2012-03-08 16:43:04 +00:00
docstring getModuleCategory ( string const & modName )
{
LyXModule const * const mod = theModuleList [ modName ] ;
if ( ! mod )
return docstring ( ) ;
return from_utf8 ( mod - > category ( ) ) ;
}
2008-09-20 12:17:15 +00:00
docstring getModuleDescription ( string const & modName )
{
2009-08-14 15:37:34 +00:00
LyXModule const * const mod = theModuleList [ modName ] ;
2008-09-20 12:17:15 +00:00
if ( ! mod )
return _ ( " Module not found! " ) ;
2008-11-04 15:44:02 +00:00
// FIXME Unicode
2008-11-04 15:38:37 +00:00
return translateIfPossible ( from_utf8 ( mod - > getDescription ( ) ) ) ;
2008-09-20 12:17:15 +00:00
}
2008-01-09 18:51:02 +00:00
2008-09-20 12:17:15 +00:00
vector < string > getPackageList ( string const & modName )
{
2009-08-14 15:37:34 +00:00
LyXModule const * const mod = theModuleList [ modName ] ;
2008-09-20 12:17:15 +00:00
if ( ! mod )
return vector < string > ( ) ; //empty such thing
return mod - > getPackageList ( ) ;
}
2008-01-09 18:51:02 +00:00
2008-09-20 12:17:15 +00:00
bool isModuleAvailable ( string const & modName )
{
2009-08-14 15:46:10 +00:00
LyXModule const * const mod = theModuleList [ modName ] ;
2008-09-20 12:17:15 +00:00
if ( ! mod )
return false ;
return mod - > isAvailable ( ) ;
}
} // anonymous namespace
/////////////////////////////////////////////////////////////////////
//
// ModuleSelectionManager
//
/////////////////////////////////////////////////////////////////////
2008-01-09 18:51:02 +00:00
2008-09-20 13:44:51 +00:00
/// SelectionManager for use with modules
2011-12-03 22:15:11 +00:00
class ModuleSelectionManager : public GuiSelectionManager
2008-09-20 13:44:51 +00:00
{
public :
2008-10-16 13:41:25 +00:00
///
2008-09-20 13:44:51 +00:00
ModuleSelectionManager (
2009-08-14 20:37:22 +00:00
QTreeView * availableLV ,
2008-09-20 13:44:51 +00:00
QListView * selectedLV ,
2011-12-03 22:15:11 +00:00
QPushButton * addPB ,
QPushButton * delPB ,
QPushButton * upPB ,
2008-09-20 13:44:51 +00:00
QPushButton * downPB ,
GuiIdListModel * availableModel ,
2008-10-20 19:53:15 +00:00
GuiIdListModel * selectedModel ,
GuiDocument const * container )
2008-09-20 13:44:51 +00:00
: GuiSelectionManager ( availableLV , selectedLV , addPB , delPB ,
2008-10-20 19:53:15 +00:00
upPB , downPB , availableModel , selectedModel ) , container_ ( container )
2008-09-20 13:44:51 +00:00
{ }
2008-10-23 00:27:03 +00:00
///
2011-12-03 22:15:11 +00:00
void updateProvidedModules ( LayoutModuleList const & pm )
2009-02-12 15:07:22 +00:00
{ provided_modules_ = pm . list ( ) ; }
2008-10-23 00:27:03 +00:00
///
2011-12-03 22:15:11 +00:00
void updateExcludedModules ( LayoutModuleList const & em )
2009-02-12 15:07:22 +00:00
{ excluded_modules_ = em . list ( ) ; }
2008-09-20 13:44:51 +00:00
private :
///
virtual void updateAddPB ( ) ;
///
virtual void updateUpPB ( ) ;
///
virtual void updateDownPB ( ) ;
///
virtual void updateDelPB ( ) ;
/// returns availableModel as a GuiIdListModel
2011-12-03 22:15:11 +00:00
GuiIdListModel * getAvailableModel ( )
2008-09-20 13:44:51 +00:00
{
return dynamic_cast < GuiIdListModel * > ( availableModel ) ;
}
/// returns selectedModel as a GuiIdListModel
2011-12-03 22:15:11 +00:00
GuiIdListModel * getSelectedModel ( )
2008-09-20 13:44:51 +00:00
{
return dynamic_cast < GuiIdListModel * > ( selectedModel ) ;
}
2008-10-23 00:27:03 +00:00
/// keeps a list of the modules the text class provides
2010-01-01 02:43:44 +00:00
list < string > provided_modules_ ;
2008-10-23 00:27:03 +00:00
/// similarly...
2010-01-01 02:43:44 +00:00
list < string > excluded_modules_ ;
2011-12-03 22:15:11 +00:00
///
2008-10-20 19:53:15 +00:00
GuiDocument const * container_ ;
2008-09-20 13:44:51 +00:00
} ;
2011-12-03 22:15:11 +00:00
void ModuleSelectionManager : : updateAddPB ( )
2008-01-09 18:51:02 +00:00
{
This commit changes the way individual LyXModule's are represented, both internally and in the .lyx files. The earlier version represented them by their `descriptive name', e.g., "Endnote" or "Theorems (AMS)", these being the same names used in the UI. This was a mistake, as becomes readily apparent when one starts to think about translating these strings. The modules ought to be represented by their filename, without the extension, just as TextClass's are.
The changes that accomplish this part are in ModuleList.{h,cpp}, configure.py, and the *.module files themselves. This is a format change, and the lyx2lyx is in those files.
By itself, that change would not be major, except for the fact that we do not want the module to be represented in the UI by its filename---e.g., theorems-std---but rather by a descriptive name, such as "Theorems". But that change turns out to be wholly non-trivial. The mechanism for choosing modules was the same as---indeed, was borrowed from---that in GuiCitation: You get a list of modules, and choosing them involves moving strings from one QListView to another. The models underlying these views are just QStringListModels, which means that, when you want to know what modules have been selected, you see what strings are in the "selected" QListView. But these are just the descriptive names, and we can't look up a module by its descriptive name if it's been translated. That, indeed, was the whole point of the change to the new representation.
So, we need a more complicated model underlying the QListView, one that will pair an identifying string---the filename minus the extension, in this case---with each item. This turns out not to be terribly difficult, though it took rather a while for me to understand why it's not difficult. There are two parts:
(i) GuiSelectionManger gets re-written to use any QAbstractListModel, not just a QStringListModel. This actually seems to improve the code, independently.
(ii) We then subclass QAbstractListModel to get the associated ID string, using the Qt::UserRole slot associated with each item to store its ID. This would be almost completely trivial if QAbstractListItem::itemData() included the QVariant associated with this role, but it doesn't, so there are some additional hoops through which to jump.
The new model, a GuiIdListModel, is defined in the files by that name. The changes in GuiSelectionManger.{h,cpp} make it more abstract; the changes in GuiDocument.{h,cpp} adapt it to the new framework.
I've also updated the module documenation to accord with this change.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22501 a592a061-630c-0410-9148-cb99ea01b6c8
2008-01-12 04:28:12 +00:00
int const arows = availableModel - > rowCount ( ) ;
2011-12-03 22:15:11 +00:00
QModelIndexList const avail_sels =
2008-01-09 18:51:02 +00:00
availableLV - > selectionModel ( ) - > selectedIndexes ( ) ;
2008-10-16 15:04:48 +00:00
// disable if there aren't any modules (?), if none of them is chosen
// in the dialog, or if the chosen one is already selected for use.
2008-10-20 20:31:33 +00:00
if ( arows = = 0 | | avail_sels . isEmpty ( ) | | isSelected ( avail_sels . first ( ) ) ) {
2008-01-09 18:51:02 +00:00
addPB - > setEnabled ( false ) ;
return ;
}
2008-10-16 15:04:48 +00:00
2008-01-09 18:51:02 +00:00
QModelIndex const & idx = availableLV - > selectionModel ( ) - > currentIndex ( ) ;
2008-10-20 20:31:33 +00:00
string const modname = getAvailableModel ( ) - > getIDString ( idx . row ( ) ) ;
2008-01-09 18:51:02 +00:00
2011-12-03 22:15:11 +00:00
bool const enable =
2012-12-05 16:16:21 +00:00
container_ - > params ( ) . layoutModuleCanBeAdded ( modname ) ;
2008-10-20 19:53:15 +00:00
addPB - > setEnabled ( enable ) ;
2008-01-09 18:51:02 +00:00
}
This commit changes the way individual LyXModule's are represented, both internally and in the .lyx files. The earlier version represented them by their `descriptive name', e.g., "Endnote" or "Theorems (AMS)", these being the same names used in the UI. This was a mistake, as becomes readily apparent when one starts to think about translating these strings. The modules ought to be represented by their filename, without the extension, just as TextClass's are.
The changes that accomplish this part are in ModuleList.{h,cpp}, configure.py, and the *.module files themselves. This is a format change, and the lyx2lyx is in those files.
By itself, that change would not be major, except for the fact that we do not want the module to be represented in the UI by its filename---e.g., theorems-std---but rather by a descriptive name, such as "Theorems". But that change turns out to be wholly non-trivial. The mechanism for choosing modules was the same as---indeed, was borrowed from---that in GuiCitation: You get a list of modules, and choosing them involves moving strings from one QListView to another. The models underlying these views are just QStringListModels, which means that, when you want to know what modules have been selected, you see what strings are in the "selected" QListView. But these are just the descriptive names, and we can't look up a module by its descriptive name if it's been translated. That, indeed, was the whole point of the change to the new representation.
So, we need a more complicated model underlying the QListView, one that will pair an identifying string---the filename minus the extension, in this case---with each item. This turns out not to be terribly difficult, though it took rather a while for me to understand why it's not difficult. There are two parts:
(i) GuiSelectionManger gets re-written to use any QAbstractListModel, not just a QStringListModel. This actually seems to improve the code, independently.
(ii) We then subclass QAbstractListModel to get the associated ID string, using the Qt::UserRole slot associated with each item to store its ID. This would be almost completely trivial if QAbstractListItem::itemData() included the QVariant associated with this role, but it doesn't, so there are some additional hoops through which to jump.
The new model, a GuiIdListModel, is defined in the files by that name. The changes in GuiSelectionManger.{h,cpp} make it more abstract; the changes in GuiDocument.{h,cpp} adapt it to the new framework.
I've also updated the module documenation to accord with this change.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22501 a592a061-630c-0410-9148-cb99ea01b6c8
2008-01-12 04:28:12 +00:00
2008-09-20 12:17:15 +00:00
void ModuleSelectionManager : : updateDownPB ( )
2008-01-10 01:33:24 +00:00
{
This commit changes the way individual LyXModule's are represented, both internally and in the .lyx files. The earlier version represented them by their `descriptive name', e.g., "Endnote" or "Theorems (AMS)", these being the same names used in the UI. This was a mistake, as becomes readily apparent when one starts to think about translating these strings. The modules ought to be represented by their filename, without the extension, just as TextClass's are.
The changes that accomplish this part are in ModuleList.{h,cpp}, configure.py, and the *.module files themselves. This is a format change, and the lyx2lyx is in those files.
By itself, that change would not be major, except for the fact that we do not want the module to be represented in the UI by its filename---e.g., theorems-std---but rather by a descriptive name, such as "Theorems". But that change turns out to be wholly non-trivial. The mechanism for choosing modules was the same as---indeed, was borrowed from---that in GuiCitation: You get a list of modules, and choosing them involves moving strings from one QListView to another. The models underlying these views are just QStringListModels, which means that, when you want to know what modules have been selected, you see what strings are in the "selected" QListView. But these are just the descriptive names, and we can't look up a module by its descriptive name if it's been translated. That, indeed, was the whole point of the change to the new representation.
So, we need a more complicated model underlying the QListView, one that will pair an identifying string---the filename minus the extension, in this case---with each item. This turns out not to be terribly difficult, though it took rather a while for me to understand why it's not difficult. There are two parts:
(i) GuiSelectionManger gets re-written to use any QAbstractListModel, not just a QStringListModel. This actually seems to improve the code, independently.
(ii) We then subclass QAbstractListModel to get the associated ID string, using the Qt::UserRole slot associated with each item to store its ID. This would be almost completely trivial if QAbstractListItem::itemData() included the QVariant associated with this role, but it doesn't, so there are some additional hoops through which to jump.
The new model, a GuiIdListModel, is defined in the files by that name. The changes in GuiSelectionManger.{h,cpp} make it more abstract; the changes in GuiDocument.{h,cpp} adapt it to the new framework.
I've also updated the module documenation to accord with this change.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22501 a592a061-630c-0410-9148-cb99ea01b6c8
2008-01-12 04:28:12 +00:00
int const srows = selectedModel - > rowCount ( ) ;
2008-01-10 01:33:24 +00:00
if ( srows = = 0 ) {
downPB - > setEnabled ( false ) ;
return ;
}
2008-10-20 20:31:33 +00:00
QModelIndex const & curidx = selectedLV - > selectionModel ( ) - > currentIndex ( ) ;
int const curRow = curidx . row ( ) ;
2008-10-14 17:14:25 +00:00
if ( curRow < 0 | | curRow > = srows - 1 ) { // invalid or last item
2008-01-10 01:33:24 +00:00
downPB - > setEnabled ( false ) ;
return ;
}
2008-10-14 17:14:25 +00:00
// determine whether immediately succeding element requires this one
2008-10-20 20:31:33 +00:00
string const curmodname = getSelectedModel ( ) - > getIDString ( curRow ) ;
string const nextmodname = getSelectedModel ( ) - > getIDString ( curRow + 1 ) ;
2008-01-10 01:33:24 +00:00
2008-10-20 20:31:33 +00:00
vector < string > reqs = getRequiredList ( nextmodname ) ;
2008-01-10 01:33:24 +00:00
2008-10-12 22:21:56 +00:00
// if it doesn't require anything....
2008-01-10 01:33:24 +00:00
if ( reqs . empty ( ) ) {
downPB - > setEnabled ( true ) ;
return ;
}
2008-10-12 22:21:56 +00:00
// Enable it if this module isn't required.
2011-12-03 22:15:11 +00:00
// FIXME This should perhaps be more flexible and check whether, even
2008-10-14 17:35:49 +00:00
// if the next one is required, there is also an earlier one that will do.
2008-01-10 01:33:24 +00:00
downPB - > setEnabled (
2008-10-20 20:31:33 +00:00
find ( reqs . begin ( ) , reqs . end ( ) , curmodname ) = = reqs . end ( ) ) ;
2008-01-10 01:33:24 +00:00
}
2011-12-03 22:15:11 +00:00
void ModuleSelectionManager : : updateUpPB ( )
2008-01-10 01:33:24 +00:00
{
This commit changes the way individual LyXModule's are represented, both internally and in the .lyx files. The earlier version represented them by their `descriptive name', e.g., "Endnote" or "Theorems (AMS)", these being the same names used in the UI. This was a mistake, as becomes readily apparent when one starts to think about translating these strings. The modules ought to be represented by their filename, without the extension, just as TextClass's are.
The changes that accomplish this part are in ModuleList.{h,cpp}, configure.py, and the *.module files themselves. This is a format change, and the lyx2lyx is in those files.
By itself, that change would not be major, except for the fact that we do not want the module to be represented in the UI by its filename---e.g., theorems-std---but rather by a descriptive name, such as "Theorems". But that change turns out to be wholly non-trivial. The mechanism for choosing modules was the same as---indeed, was borrowed from---that in GuiCitation: You get a list of modules, and choosing them involves moving strings from one QListView to another. The models underlying these views are just QStringListModels, which means that, when you want to know what modules have been selected, you see what strings are in the "selected" QListView. But these are just the descriptive names, and we can't look up a module by its descriptive name if it's been translated. That, indeed, was the whole point of the change to the new representation.
So, we need a more complicated model underlying the QListView, one that will pair an identifying string---the filename minus the extension, in this case---with each item. This turns out not to be terribly difficult, though it took rather a while for me to understand why it's not difficult. There are two parts:
(i) GuiSelectionManger gets re-written to use any QAbstractListModel, not just a QStringListModel. This actually seems to improve the code, independently.
(ii) We then subclass QAbstractListModel to get the associated ID string, using the Qt::UserRole slot associated with each item to store its ID. This would be almost completely trivial if QAbstractListItem::itemData() included the QVariant associated with this role, but it doesn't, so there are some additional hoops through which to jump.
The new model, a GuiIdListModel, is defined in the files by that name. The changes in GuiSelectionManger.{h,cpp} make it more abstract; the changes in GuiDocument.{h,cpp} adapt it to the new framework.
I've also updated the module documenation to accord with this change.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22501 a592a061-630c-0410-9148-cb99ea01b6c8
2008-01-12 04:28:12 +00:00
int const srows = selectedModel - > rowCount ( ) ;
2008-01-10 01:33:24 +00:00
if ( srows = = 0 ) {
upPB - > setEnabled ( false ) ;
return ;
}
This commit changes the way individual LyXModule's are represented, both internally and in the .lyx files. The earlier version represented them by their `descriptive name', e.g., "Endnote" or "Theorems (AMS)", these being the same names used in the UI. This was a mistake, as becomes readily apparent when one starts to think about translating these strings. The modules ought to be represented by their filename, without the extension, just as TextClass's are.
The changes that accomplish this part are in ModuleList.{h,cpp}, configure.py, and the *.module files themselves. This is a format change, and the lyx2lyx is in those files.
By itself, that change would not be major, except for the fact that we do not want the module to be represented in the UI by its filename---e.g., theorems-std---but rather by a descriptive name, such as "Theorems". But that change turns out to be wholly non-trivial. The mechanism for choosing modules was the same as---indeed, was borrowed from---that in GuiCitation: You get a list of modules, and choosing them involves moving strings from one QListView to another. The models underlying these views are just QStringListModels, which means that, when you want to know what modules have been selected, you see what strings are in the "selected" QListView. But these are just the descriptive names, and we can't look up a module by its descriptive name if it's been translated. That, indeed, was the whole point of the change to the new representation.
So, we need a more complicated model underlying the QListView, one that will pair an identifying string---the filename minus the extension, in this case---with each item. This turns out not to be terribly difficult, though it took rather a while for me to understand why it's not difficult. There are two parts:
(i) GuiSelectionManger gets re-written to use any QAbstractListModel, not just a QStringListModel. This actually seems to improve the code, independently.
(ii) We then subclass QAbstractListModel to get the associated ID string, using the Qt::UserRole slot associated with each item to store its ID. This would be almost completely trivial if QAbstractListItem::itemData() included the QVariant associated with this role, but it doesn't, so there are some additional hoops through which to jump.
The new model, a GuiIdListModel, is defined in the files by that name. The changes in GuiSelectionManger.{h,cpp} make it more abstract; the changes in GuiDocument.{h,cpp} adapt it to the new framework.
I've also updated the module documenation to accord with this change.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22501 a592a061-630c-0410-9148-cb99ea01b6c8
2008-01-12 04:28:12 +00:00
QModelIndex const & curIdx = selectedLV - > selectionModel ( ) - > currentIndex ( ) ;
int curRow = curIdx . row ( ) ;
2008-10-14 17:14:25 +00:00
if ( curRow < = 0 | | curRow > srows - 1 ) { // first item or invalid
upPB - > setEnabled ( false ) ;
This commit changes the way individual LyXModule's are represented, both internally and in the .lyx files. The earlier version represented them by their `descriptive name', e.g., "Endnote" or "Theorems (AMS)", these being the same names used in the UI. This was a mistake, as becomes readily apparent when one starts to think about translating these strings. The modules ought to be represented by their filename, without the extension, just as TextClass's are.
The changes that accomplish this part are in ModuleList.{h,cpp}, configure.py, and the *.module files themselves. This is a format change, and the lyx2lyx is in those files.
By itself, that change would not be major, except for the fact that we do not want the module to be represented in the UI by its filename---e.g., theorems-std---but rather by a descriptive name, such as "Theorems". But that change turns out to be wholly non-trivial. The mechanism for choosing modules was the same as---indeed, was borrowed from---that in GuiCitation: You get a list of modules, and choosing them involves moving strings from one QListView to another. The models underlying these views are just QStringListModels, which means that, when you want to know what modules have been selected, you see what strings are in the "selected" QListView. But these are just the descriptive names, and we can't look up a module by its descriptive name if it's been translated. That, indeed, was the whole point of the change to the new representation.
So, we need a more complicated model underlying the QListView, one that will pair an identifying string---the filename minus the extension, in this case---with each item. This turns out not to be terribly difficult, though it took rather a while for me to understand why it's not difficult. There are two parts:
(i) GuiSelectionManger gets re-written to use any QAbstractListModel, not just a QStringListModel. This actually seems to improve the code, independently.
(ii) We then subclass QAbstractListModel to get the associated ID string, using the Qt::UserRole slot associated with each item to store its ID. This would be almost completely trivial if QAbstractListItem::itemData() included the QVariant associated with this role, but it doesn't, so there are some additional hoops through which to jump.
The new model, a GuiIdListModel, is defined in the files by that name. The changes in GuiSelectionManger.{h,cpp} make it more abstract; the changes in GuiDocument.{h,cpp} adapt it to the new framework.
I've also updated the module documenation to accord with this change.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22501 a592a061-630c-0410-9148-cb99ea01b6c8
2008-01-12 04:28:12 +00:00
return ;
}
2008-10-20 20:31:33 +00:00
string const curmodname = getSelectedModel ( ) - > getIDString ( curRow ) ;
2008-10-14 17:35:49 +00:00
// determine whether immediately preceding element is required by this one
2008-10-20 20:31:33 +00:00
vector < string > reqs = getRequiredList ( curmodname ) ;
2008-10-16 13:41:25 +00:00
2008-10-12 22:21:56 +00:00
// if this one doesn't require anything....
2008-01-10 01:33:24 +00:00
if ( reqs . empty ( ) ) {
upPB - > setEnabled ( true ) ;
return ;
}
2008-10-12 22:21:56 +00:00
// Enable it if the preceding module isn't required.
2011-12-03 22:15:11 +00:00
// NOTE This is less flexible than it might be. We could check whether, even
2008-10-14 17:35:49 +00:00
// if the previous one is required, there is an earlier one that would do.
2008-10-20 20:31:33 +00:00
string const premod = getSelectedModel ( ) - > getIDString ( curRow - 1 ) ;
upPB - > setEnabled ( find ( reqs . begin ( ) , reqs . end ( ) , premod ) = = reqs . end ( ) ) ;
2008-01-10 01:33:24 +00:00
}
2011-12-03 22:15:11 +00:00
void ModuleSelectionManager : : updateDelPB ( )
2008-01-10 01:33:24 +00:00
{
This commit changes the way individual LyXModule's are represented, both internally and in the .lyx files. The earlier version represented them by their `descriptive name', e.g., "Endnote" or "Theorems (AMS)", these being the same names used in the UI. This was a mistake, as becomes readily apparent when one starts to think about translating these strings. The modules ought to be represented by their filename, without the extension, just as TextClass's are.
The changes that accomplish this part are in ModuleList.{h,cpp}, configure.py, and the *.module files themselves. This is a format change, and the lyx2lyx is in those files.
By itself, that change would not be major, except for the fact that we do not want the module to be represented in the UI by its filename---e.g., theorems-std---but rather by a descriptive name, such as "Theorems". But that change turns out to be wholly non-trivial. The mechanism for choosing modules was the same as---indeed, was borrowed from---that in GuiCitation: You get a list of modules, and choosing them involves moving strings from one QListView to another. The models underlying these views are just QStringListModels, which means that, when you want to know what modules have been selected, you see what strings are in the "selected" QListView. But these are just the descriptive names, and we can't look up a module by its descriptive name if it's been translated. That, indeed, was the whole point of the change to the new representation.
So, we need a more complicated model underlying the QListView, one that will pair an identifying string---the filename minus the extension, in this case---with each item. This turns out not to be terribly difficult, though it took rather a while for me to understand why it's not difficult. There are two parts:
(i) GuiSelectionManger gets re-written to use any QAbstractListModel, not just a QStringListModel. This actually seems to improve the code, independently.
(ii) We then subclass QAbstractListModel to get the associated ID string, using the Qt::UserRole slot associated with each item to store its ID. This would be almost completely trivial if QAbstractListItem::itemData() included the QVariant associated with this role, but it doesn't, so there are some additional hoops through which to jump.
The new model, a GuiIdListModel, is defined in the files by that name. The changes in GuiSelectionManger.{h,cpp} make it more abstract; the changes in GuiDocument.{h,cpp} adapt it to the new framework.
I've also updated the module documenation to accord with this change.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22501 a592a061-630c-0410-9148-cb99ea01b6c8
2008-01-12 04:28:12 +00:00
int const srows = selectedModel - > rowCount ( ) ;
2008-01-10 01:33:24 +00:00
if ( srows = = 0 ) {
deletePB - > setEnabled ( false ) ;
return ;
}
2008-10-20 19:53:15 +00:00
2011-12-03 22:15:11 +00:00
QModelIndex const & curidx =
This commit changes the way individual LyXModule's are represented, both internally and in the .lyx files. The earlier version represented them by their `descriptive name', e.g., "Endnote" or "Theorems (AMS)", these being the same names used in the UI. This was a mistake, as becomes readily apparent when one starts to think about translating these strings. The modules ought to be represented by their filename, without the extension, just as TextClass's are.
The changes that accomplish this part are in ModuleList.{h,cpp}, configure.py, and the *.module files themselves. This is a format change, and the lyx2lyx is in those files.
By itself, that change would not be major, except for the fact that we do not want the module to be represented in the UI by its filename---e.g., theorems-std---but rather by a descriptive name, such as "Theorems". But that change turns out to be wholly non-trivial. The mechanism for choosing modules was the same as---indeed, was borrowed from---that in GuiCitation: You get a list of modules, and choosing them involves moving strings from one QListView to another. The models underlying these views are just QStringListModels, which means that, when you want to know what modules have been selected, you see what strings are in the "selected" QListView. But these are just the descriptive names, and we can't look up a module by its descriptive name if it's been translated. That, indeed, was the whole point of the change to the new representation.
So, we need a more complicated model underlying the QListView, one that will pair an identifying string---the filename minus the extension, in this case---with each item. This turns out not to be terribly difficult, though it took rather a while for me to understand why it's not difficult. There are two parts:
(i) GuiSelectionManger gets re-written to use any QAbstractListModel, not just a QStringListModel. This actually seems to improve the code, independently.
(ii) We then subclass QAbstractListModel to get the associated ID string, using the Qt::UserRole slot associated with each item to store its ID. This would be almost completely trivial if QAbstractListItem::itemData() included the QVariant associated with this role, but it doesn't, so there are some additional hoops through which to jump.
The new model, a GuiIdListModel, is defined in the files by that name. The changes in GuiSelectionManger.{h,cpp} make it more abstract; the changes in GuiDocument.{h,cpp} adapt it to the new framework.
I've also updated the module documenation to accord with this change.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22501 a592a061-630c-0410-9148-cb99ea01b6c8
2008-01-12 04:28:12 +00:00
selectedLV - > selectionModel ( ) - > currentIndex ( ) ;
2008-10-20 20:31:33 +00:00
int const curRow = curidx . row ( ) ;
2008-10-14 17:14:25 +00:00
if ( curRow < 0 | | curRow > = srows ) { // invalid index?
This commit changes the way individual LyXModule's are represented, both internally and in the .lyx files. The earlier version represented them by their `descriptive name', e.g., "Endnote" or "Theorems (AMS)", these being the same names used in the UI. This was a mistake, as becomes readily apparent when one starts to think about translating these strings. The modules ought to be represented by their filename, without the extension, just as TextClass's are.
The changes that accomplish this part are in ModuleList.{h,cpp}, configure.py, and the *.module files themselves. This is a format change, and the lyx2lyx is in those files.
By itself, that change would not be major, except for the fact that we do not want the module to be represented in the UI by its filename---e.g., theorems-std---but rather by a descriptive name, such as "Theorems". But that change turns out to be wholly non-trivial. The mechanism for choosing modules was the same as---indeed, was borrowed from---that in GuiCitation: You get a list of modules, and choosing them involves moving strings from one QListView to another. The models underlying these views are just QStringListModels, which means that, when you want to know what modules have been selected, you see what strings are in the "selected" QListView. But these are just the descriptive names, and we can't look up a module by its descriptive name if it's been translated. That, indeed, was the whole point of the change to the new representation.
So, we need a more complicated model underlying the QListView, one that will pair an identifying string---the filename minus the extension, in this case---with each item. This turns out not to be terribly difficult, though it took rather a while for me to understand why it's not difficult. There are two parts:
(i) GuiSelectionManger gets re-written to use any QAbstractListModel, not just a QStringListModel. This actually seems to improve the code, independently.
(ii) We then subclass QAbstractListModel to get the associated ID string, using the Qt::UserRole slot associated with each item to store its ID. This would be almost completely trivial if QAbstractListItem::itemData() included the QVariant associated with this role, but it doesn't, so there are some additional hoops through which to jump.
The new model, a GuiIdListModel, is defined in the files by that name. The changes in GuiSelectionManger.{h,cpp} make it more abstract; the changes in GuiDocument.{h,cpp} adapt it to the new framework.
I've also updated the module documenation to accord with this change.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22501 a592a061-630c-0410-9148-cb99ea01b6c8
2008-01-12 04:28:12 +00:00
deletePB - > setEnabled ( false ) ;
return ;
}
2008-10-16 13:41:25 +00:00
2008-10-20 20:31:33 +00:00
string const curmodname = getSelectedModel ( ) - > getIDString ( curRow ) ;
2008-10-16 13:41:25 +00:00
2008-10-12 22:21:56 +00:00
// We're looking here for a reason NOT to enable the button. If we
// find one, we disable it and return. If we don't, we'll end up at
// the end of the function, and then we enable it.
This commit changes the way individual LyXModule's are represented, both internally and in the .lyx files. The earlier version represented them by their `descriptive name', e.g., "Endnote" or "Theorems (AMS)", these being the same names used in the UI. This was a mistake, as becomes readily apparent when one starts to think about translating these strings. The modules ought to be represented by their filename, without the extension, just as TextClass's are.
The changes that accomplish this part are in ModuleList.{h,cpp}, configure.py, and the *.module files themselves. This is a format change, and the lyx2lyx is in those files.
By itself, that change would not be major, except for the fact that we do not want the module to be represented in the UI by its filename---e.g., theorems-std---but rather by a descriptive name, such as "Theorems". But that change turns out to be wholly non-trivial. The mechanism for choosing modules was the same as---indeed, was borrowed from---that in GuiCitation: You get a list of modules, and choosing them involves moving strings from one QListView to another. The models underlying these views are just QStringListModels, which means that, when you want to know what modules have been selected, you see what strings are in the "selected" QListView. But these are just the descriptive names, and we can't look up a module by its descriptive name if it's been translated. That, indeed, was the whole point of the change to the new representation.
So, we need a more complicated model underlying the QListView, one that will pair an identifying string---the filename minus the extension, in this case---with each item. This turns out not to be terribly difficult, though it took rather a while for me to understand why it's not difficult. There are two parts:
(i) GuiSelectionManger gets re-written to use any QAbstractListModel, not just a QStringListModel. This actually seems to improve the code, independently.
(ii) We then subclass QAbstractListModel to get the associated ID string, using the Qt::UserRole slot associated with each item to store its ID. This would be almost completely trivial if QAbstractListItem::itemData() included the QVariant associated with this role, but it doesn't, so there are some additional hoops through which to jump.
The new model, a GuiIdListModel, is defined in the files by that name. The changes in GuiSelectionManger.{h,cpp} make it more abstract; the changes in GuiDocument.{h,cpp} adapt it to the new framework.
I've also updated the module documenation to accord with this change.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22501 a592a061-630c-0410-9148-cb99ea01b6c8
2008-01-12 04:28:12 +00:00
for ( int i = curRow + 1 ; i < srows ; + + i ) {
string const thisMod = getSelectedModel ( ) - > getIDString ( i ) ;
vector < string > reqs = getRequiredList ( thisMod ) ;
2008-01-10 01:33:24 +00:00
//does this one require us?
2008-10-20 20:31:33 +00:00
if ( find ( reqs . begin ( ) , reqs . end ( ) , curmodname ) = = reqs . end ( ) )
2008-01-10 01:33:24 +00:00
//no...
continue ;
2008-10-12 22:21:56 +00:00
// OK, so this module requires us
// is there an EARLIER module that also satisfies the require?
// NOTE We demand that it be earlier to keep the list of modules
// consistent with the rule that a module must be proceeded by a
// required module. There would be more flexible ways to proceed,
// but that would be a lot more complicated, and the logic here is
// already complicated. (That's why I've left the debugging code.)
2010-01-01 02:43:44 +00:00
// lyxerr << "Testing " << thisMod << endl;
2008-10-20 20:31:33 +00:00
bool foundone = false ;
This commit changes the way individual LyXModule's are represented, both internally and in the .lyx files. The earlier version represented them by their `descriptive name', e.g., "Endnote" or "Theorems (AMS)", these being the same names used in the UI. This was a mistake, as becomes readily apparent when one starts to think about translating these strings. The modules ought to be represented by their filename, without the extension, just as TextClass's are.
The changes that accomplish this part are in ModuleList.{h,cpp}, configure.py, and the *.module files themselves. This is a format change, and the lyx2lyx is in those files.
By itself, that change would not be major, except for the fact that we do not want the module to be represented in the UI by its filename---e.g., theorems-std---but rather by a descriptive name, such as "Theorems". But that change turns out to be wholly non-trivial. The mechanism for choosing modules was the same as---indeed, was borrowed from---that in GuiCitation: You get a list of modules, and choosing them involves moving strings from one QListView to another. The models underlying these views are just QStringListModels, which means that, when you want to know what modules have been selected, you see what strings are in the "selected" QListView. But these are just the descriptive names, and we can't look up a module by its descriptive name if it's been translated. That, indeed, was the whole point of the change to the new representation.
So, we need a more complicated model underlying the QListView, one that will pair an identifying string---the filename minus the extension, in this case---with each item. This turns out not to be terribly difficult, though it took rather a while for me to understand why it's not difficult. There are two parts:
(i) GuiSelectionManger gets re-written to use any QAbstractListModel, not just a QStringListModel. This actually seems to improve the code, independently.
(ii) We then subclass QAbstractListModel to get the associated ID string, using the Qt::UserRole slot associated with each item to store its ID. This would be almost completely trivial if QAbstractListItem::itemData() included the QVariant associated with this role, but it doesn't, so there are some additional hoops through which to jump.
The new model, a GuiIdListModel, is defined in the files by that name. The changes in GuiSelectionManger.{h,cpp} make it more abstract; the changes in GuiDocument.{h,cpp} adapt it to the new framework.
I've also updated the module documenation to accord with this change.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22501 a592a061-630c-0410-9148-cb99ea01b6c8
2008-01-12 04:28:12 +00:00
for ( int j = 0 ; j < curRow ; + + j ) {
string const mod = getSelectedModel ( ) - > getIDString ( j ) ;
2010-01-01 02:43:44 +00:00
// lyxerr << "In loop: Testing " << mod << endl;
2011-12-03 22:15:11 +00:00
// do we satisfy the require?
This commit changes the way individual LyXModule's are represented, both internally and in the .lyx files. The earlier version represented them by their `descriptive name', e.g., "Endnote" or "Theorems (AMS)", these being the same names used in the UI. This was a mistake, as becomes readily apparent when one starts to think about translating these strings. The modules ought to be represented by their filename, without the extension, just as TextClass's are.
The changes that accomplish this part are in ModuleList.{h,cpp}, configure.py, and the *.module files themselves. This is a format change, and the lyx2lyx is in those files.
By itself, that change would not be major, except for the fact that we do not want the module to be represented in the UI by its filename---e.g., theorems-std---but rather by a descriptive name, such as "Theorems". But that change turns out to be wholly non-trivial. The mechanism for choosing modules was the same as---indeed, was borrowed from---that in GuiCitation: You get a list of modules, and choosing them involves moving strings from one QListView to another. The models underlying these views are just QStringListModels, which means that, when you want to know what modules have been selected, you see what strings are in the "selected" QListView. But these are just the descriptive names, and we can't look up a module by its descriptive name if it's been translated. That, indeed, was the whole point of the change to the new representation.
So, we need a more complicated model underlying the QListView, one that will pair an identifying string---the filename minus the extension, in this case---with each item. This turns out not to be terribly difficult, though it took rather a while for me to understand why it's not difficult. There are two parts:
(i) GuiSelectionManger gets re-written to use any QAbstractListModel, not just a QStringListModel. This actually seems to improve the code, independently.
(ii) We then subclass QAbstractListModel to get the associated ID string, using the Qt::UserRole slot associated with each item to store its ID. This would be almost completely trivial if QAbstractListItem::itemData() included the QVariant associated with this role, but it doesn't, so there are some additional hoops through which to jump.
The new model, a GuiIdListModel, is defined in the files by that name. The changes in GuiSelectionManger.{h,cpp} make it more abstract; the changes in GuiDocument.{h,cpp} adapt it to the new framework.
I've also updated the module documenation to accord with this change.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22501 a592a061-630c-0410-9148-cb99ea01b6c8
2008-01-12 04:28:12 +00:00
if ( find ( reqs . begin ( ) , reqs . end ( ) , mod ) ! = reqs . end ( ) ) {
2010-01-01 02:43:44 +00:00
// lyxerr << mod << " does the trick." << endl;
2008-10-20 20:31:33 +00:00
foundone = true ;
2008-01-10 01:33:24 +00:00
break ;
}
}
2008-10-12 22:21:56 +00:00
// did we find a module to satisfy the require?
2008-10-20 20:31:33 +00:00
if ( ! foundone ) {
2010-01-01 02:43:44 +00:00
// lyxerr << "No matching module found." << endl;
2008-01-10 01:33:24 +00:00
deletePB - > setEnabled ( false ) ;
return ;
}
}
2010-01-01 02:43:44 +00:00
// lyxerr << "All's well that ends well." << endl;
2008-01-10 01:33:24 +00:00
deletePB - > setEnabled ( true ) ;
}
2008-01-09 18:51:02 +00:00
2007-05-14 12:09:14 +00:00
/////////////////////////////////////////////////////////////////////
//
// PreambleModule
//
/////////////////////////////////////////////////////////////////////
2008-09-20 12:17:15 +00:00
PreambleModule : : PreambleModule ( ) : current_id_ ( 0 )
2007-05-14 12:09:14 +00:00
{
// This is not a memory leak. The object will be destroyed
// with this.
( void ) new LaTeXHighlighter ( preambleTE - > document ( ) ) ;
setFocusProxy ( preambleTE ) ;
2007-05-14 16:54:27 +00:00
connect ( preambleTE , SIGNAL ( textChanged ( ) ) , this , SIGNAL ( changed ( ) ) ) ;
2007-05-14 12:09:14 +00:00
}
2007-05-14 16:41:50 +00:00
void PreambleModule : : update ( BufferParams const & params , BufferId id )
2007-05-14 12:09:14 +00:00
{
QString preamble = toqstr ( params . preamble ) ;
// Nothing to do if the params and preamble are unchanged.
2007-05-28 22:27:45 +00:00
if ( id = = current_id_
2007-05-14 12:09:14 +00:00
& & preamble = = preambleTE - > document ( ) - > toPlainText ( ) )
return ;
QTextCursor cur = preambleTE - > textCursor ( ) ;
// Save the coords before switching to the new one.
2007-05-28 22:27:45 +00:00
preamble_coords_ [ current_id_ ] =
2007-05-14 12:09:14 +00:00
make_pair ( cur . position ( ) , preambleTE - > verticalScrollBar ( ) - > value ( ) ) ;
// Save the params address for further use.
current_id_ = id ;
preambleTE - > document ( ) - > setPlainText ( preamble ) ;
Coords : : const_iterator it = preamble_coords_ . find ( current_id_ ) ;
if ( it = = preamble_coords_ . end ( ) )
// First time we open this one.
2008-09-08 01:18:33 +00:00
preamble_coords_ [ current_id_ ] = make_pair ( 0 , 0 ) ;
2007-05-14 12:09:14 +00:00
else {
// Restore saved coords.
QTextCursor cur = preambleTE - > textCursor ( ) ;
cur . setPosition ( it - > second . first ) ;
preambleTE - > setTextCursor ( cur ) ;
preambleTE - > verticalScrollBar ( ) - > setValue ( it - > second . second ) ;
}
}
void PreambleModule : : apply ( BufferParams & params )
{
params . preamble = fromqstr ( preambleTE - > document ( ) - > toPlainText ( ) ) ;
}
void PreambleModule : : closeEvent ( QCloseEvent * e )
{
// Save the coords before closing.
QTextCursor cur = preambleTE - > textCursor ( ) ;
2007-05-28 22:27:45 +00:00
preamble_coords_ [ current_id_ ] =
2007-05-14 12:09:14 +00:00
make_pair ( cur . position ( ) , preambleTE - > verticalScrollBar ( ) - > value ( ) ) ;
e - > accept ( ) ;
}
A UI for document-local layout information. LyX has supported this for a
while, but without any UI for it. (There has been local layout in the
Customization manual for a long time, in fact.)
Yes, this is an advanced feature. But, absent a layout editor, it is the
one thing that will make it easier, and possible, for "normal users" to
experiment with layout without having to go through reconfiguration,
etc, etc. To keep too many people from shooting themselves, we validate
the layout information before allowing the user to apply it.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@35061 a592a061-630c-0410-9148-cb99ea01b6c8
2010-08-05 22:47:42 +00:00
/////////////////////////////////////////////////////////////////////
//
// LocalLayout
//
/////////////////////////////////////////////////////////////////////
2012-04-21 20:25:38 +00:00
LocalLayout : : LocalLayout ( ) : current_id_ ( 0 ) , validated_ ( false )
A UI for document-local layout information. LyX has supported this for a
while, but without any UI for it. (There has been local layout in the
Customization manual for a long time, in fact.)
Yes, this is an advanced feature. But, absent a layout editor, it is the
one thing that will make it easier, and possible, for "normal users" to
experiment with layout without having to go through reconfiguration,
etc, etc. To keep too many people from shooting themselves, we validate
the layout information before allowing the user to apply it.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@35061 a592a061-630c-0410-9148-cb99ea01b6c8
2010-08-05 22:47:42 +00:00
{
connect ( locallayoutTE , SIGNAL ( textChanged ( ) ) , this , SLOT ( textChanged ( ) ) ) ;
connect ( validatePB , SIGNAL ( clicked ( ) ) , this , SLOT ( validatePressed ( ) ) ) ;
2011-05-08 00:54:17 +00:00
connect ( convertPB , SIGNAL ( clicked ( ) ) , this , SLOT ( convertPressed ( ) ) ) ;
A UI for document-local layout information. LyX has supported this for a
while, but without any UI for it. (There has been local layout in the
Customization manual for a long time, in fact.)
Yes, this is an advanced feature. But, absent a layout editor, it is the
one thing that will make it easier, and possible, for "normal users" to
experiment with layout without having to go through reconfiguration,
etc, etc. To keep too many people from shooting themselves, we validate
the layout information before allowing the user to apply it.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@35061 a592a061-630c-0410-9148-cb99ea01b6c8
2010-08-05 22:47:42 +00:00
}
void LocalLayout : : update ( BufferParams const & params , BufferId id )
{
QString layout = toqstr ( params . local_layout ) ;
// Nothing to do if the params and preamble are unchanged.
if ( id = = current_id_
& & layout = = locallayoutTE - > document ( ) - > toPlainText ( ) )
return ;
// Save the params address for further use.
current_id_ = id ;
locallayoutTE - > document ( ) - > setPlainText ( layout ) ;
validate ( ) ;
}
void LocalLayout : : apply ( BufferParams & params )
{
string const layout = fromqstr ( locallayoutTE - > document ( ) - > toPlainText ( ) ) ;
params . local_layout = layout ;
}
void LocalLayout : : textChanged ( )
{
2012-04-21 20:22:28 +00:00
static const QString message =
qt_ ( " Press button to check validity... " ) ;
string const layout =
fromqstr ( locallayoutTE - > document ( ) - > toPlainText ( ) . trimmed ( ) ) ;
A UI for document-local layout information. LyX has supported this for a
while, but without any UI for it. (There has been local layout in the
Customization manual for a long time, in fact.)
Yes, this is an advanced feature. But, absent a layout editor, it is the
one thing that will make it easier, and possible, for "normal users" to
experiment with layout without having to go through reconfiguration,
etc, etc. To keep too many people from shooting themselves, we validate
the layout information before allowing the user to apply it.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@35061 a592a061-630c-0410-9148-cb99ea01b6c8
2010-08-05 22:47:42 +00:00
2012-04-21 20:22:28 +00:00
if ( layout . empty ( ) ) {
2012-04-21 20:25:38 +00:00
validated_ = true ;
2012-04-21 20:22:28 +00:00
validatePB - > setEnabled ( false ) ;
validLB - > setText ( " " ) ;
convertPB - > hide ( ) ;
convertLB - > hide ( ) ;
changed ( ) ;
} else if ( ! validatePB - > isEnabled ( ) ) {
// if that's already enabled, we shouldn't need to do anything.
2012-04-21 20:25:38 +00:00
validated_ = false ;
2012-04-21 20:22:28 +00:00
validLB - > setText ( message ) ;
validatePB - > setEnabled ( true ) ;
convertPB - > setEnabled ( false ) ;
changed ( ) ;
}
2011-05-08 00:54:17 +00:00
}
void LocalLayout : : convert ( ) {
string const layout =
fromqstr ( locallayoutTE - > document ( ) - > toPlainText ( ) . trimmed ( ) ) ;
string const newlayout = TextClass : : convert ( layout ) ;
LYXERR0 ( newlayout ) ;
if ( newlayout . empty ( ) ) {
Alert : : error ( _ ( " Conversion Failed! " ) ,
_ ( " Failed to convert local layout to current format. " ) ) ;
} else {
locallayoutTE - > setPlainText ( toqstr ( newlayout ) ) ;
}
validate ( ) ;
}
void LocalLayout : : convertPressed ( ) {
convert ( ) ;
A UI for document-local layout information. LyX has supported this for a
while, but without any UI for it. (There has been local layout in the
Customization manual for a long time, in fact.)
Yes, this is an advanced feature. But, absent a layout editor, it is the
one thing that will make it easier, and possible, for "normal users" to
experiment with layout without having to go through reconfiguration,
etc, etc. To keep too many people from shooting themselves, we validate
the layout information before allowing the user to apply it.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@35061 a592a061-630c-0410-9148-cb99ea01b6c8
2010-08-05 22:47:42 +00:00
changed ( ) ;
}
void LocalLayout : : validate ( ) {
static const QString valid = qt_ ( " Layout is valid! " ) ;
static const QString vtext =
2011-12-03 22:15:11 +00:00
toqstr ( " <p style= \" font-weight: bold; \" > " )
A UI for document-local layout information. LyX has supported this for a
while, but without any UI for it. (There has been local layout in the
Customization manual for a long time, in fact.)
Yes, this is an advanced feature. But, absent a layout editor, it is the
one thing that will make it easier, and possible, for "normal users" to
experiment with layout without having to go through reconfiguration,
etc, etc. To keep too many people from shooting themselves, we validate
the layout information before allowing the user to apply it.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@35061 a592a061-630c-0410-9148-cb99ea01b6c8
2010-08-05 22:47:42 +00:00
+ valid + toqstr ( " </p> " ) ;
static const QString invalid = qt_ ( " Layout is invalid! " ) ;
static const QString ivtext =
2011-12-03 22:15:11 +00:00
toqstr ( " <p style= \" color: #c00000; font-weight: bold; \" > " )
A UI for document-local layout information. LyX has supported this for a
while, but without any UI for it. (There has been local layout in the
Customization manual for a long time, in fact.)
Yes, this is an advanced feature. But, absent a layout editor, it is the
one thing that will make it easier, and possible, for "normal users" to
experiment with layout without having to go through reconfiguration,
etc, etc. To keep too many people from shooting themselves, we validate
the layout information before allowing the user to apply it.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@35061 a592a061-630c-0410-9148-cb99ea01b6c8
2010-08-05 22:47:42 +00:00
+ invalid + toqstr ( " </p> " ) ;
2011-12-03 22:15:11 +00:00
string const layout =
2010-09-03 13:33:05 +00:00
fromqstr ( locallayoutTE - > document ( ) - > toPlainText ( ) . trimmed ( ) ) ;
2012-04-21 20:22:28 +00:00
if ( ! layout . empty ( ) ) {
2011-05-08 00:54:17 +00:00
TextClass : : ReturnValues const ret = TextClass : : validate ( layout ) ;
2012-04-21 20:25:38 +00:00
validated_ = ( ret = = TextClass : : OK ) | | ( ret = = TextClass : : OK_OLDFORMAT ) ;
2011-05-08 00:54:17 +00:00
validatePB - > setEnabled ( false ) ;
2012-04-21 20:25:38 +00:00
validLB - > setText ( validated_ ? vtext : ivtext ) ;
2011-05-08 00:54:17 +00:00
if ( ret = = TextClass : : OK_OLDFORMAT ) {
convertPB - > show ( ) ;
convertPB - > setEnabled ( true ) ;
convertLB - > setText ( qt_ ( " Convert to current format " ) ) ;
convertLB - > show ( ) ;
} else {
convertPB - > hide ( ) ;
convertLB - > hide ( ) ;
}
2010-09-03 13:33:05 +00:00
}
A UI for document-local layout information. LyX has supported this for a
while, but without any UI for it. (There has been local layout in the
Customization manual for a long time, in fact.)
Yes, this is an advanced feature. But, absent a layout editor, it is the
one thing that will make it easier, and possible, for "normal users" to
experiment with layout without having to go through reconfiguration,
etc, etc. To keep too many people from shooting themselves, we validate
the layout information before allowing the user to apply it.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@35061 a592a061-630c-0410-9148-cb99ea01b6c8
2010-08-05 22:47:42 +00:00
}
void LocalLayout : : validatePressed ( ) {
validate ( ) ;
changed ( ) ;
}
2007-04-24 19:37:34 +00:00
/////////////////////////////////////////////////////////////////////
//
// DocumentDialog
//
/////////////////////////////////////////////////////////////////////
2007-09-03 05:59:32 +00:00
2007-11-23 09:44:02 +00:00
GuiDocument : : GuiDocument ( GuiView & lv )
2008-05-15 08:41:17 +00:00
: GuiDialog ( lv , " document " , qt_ ( " Document Settings " ) )
2007-04-24 19:37:34 +00:00
{
setupUi ( this ) ;
2008-03-08 07:59:47 +00:00
2007-09-05 20:33:29 +00:00
connect ( okPB , SIGNAL ( clicked ( ) ) , this , SLOT ( slotOK ( ) ) ) ;
connect ( applyPB , SIGNAL ( clicked ( ) ) , this , SLOT ( slotApply ( ) ) ) ;
connect ( closePB , SIGNAL ( clicked ( ) ) , this , SLOT ( slotClose ( ) ) ) ;
connect ( restorePB , SIGNAL ( clicked ( ) ) , this , SLOT ( slotRestore ( ) ) ) ;
2007-04-24 19:37:34 +00:00
2007-04-25 10:25:37 +00:00
connect ( savePB , SIGNAL ( clicked ( ) ) , this , SLOT ( saveDefaultClicked ( ) ) ) ;
connect ( defaultPB , SIGNAL ( clicked ( ) ) , this , SLOT ( useDefaultsClicked ( ) ) ) ;
2007-04-24 19:37:34 +00:00
// Manage the restore, ok, apply, restore and cancel/close buttons
2007-09-05 20:33:29 +00:00
bc ( ) . setPolicy ( ButtonPolicy : : NoRepeatedApplyReadOnlyPolicy ) ;
bc ( ) . setOK ( okPB ) ;
bc ( ) . setApply ( applyPB ) ;
bc ( ) . setCancel ( closePB ) ;
bc ( ) . setRestore ( restorePB ) ;
2007-04-24 19:37:34 +00:00
2010-04-02 22:11:50 +00:00
2007-04-24 19:37:34 +00:00
// text layout
2010-04-02 22:11:50 +00:00
textLayoutModule = new UiWidget < Ui : : TextLayoutUi > ;
2007-04-25 10:25:37 +00:00
connect ( textLayoutModule - > lspacingCO , SIGNAL ( activated ( int ) ) ,
this , SLOT ( change_adaptor ( ) ) ) ;
connect ( textLayoutModule - > lspacingCO , SIGNAL ( activated ( int ) ) ,
this , SLOT ( setLSpacing ( int ) ) ) ;
2008-02-23 16:45:38 +00:00
connect ( textLayoutModule - > lspacingLE , SIGNAL ( textChanged ( const QString & ) ) ,
2007-04-25 10:25:37 +00:00
this , SLOT ( change_adaptor ( ) ) ) ;
2009-07-19 21:13:27 +00:00
2007-04-25 10:25:37 +00:00
connect ( textLayoutModule - > indentRB , SIGNAL ( clicked ( ) ) ,
this , SLOT ( change_adaptor ( ) ) ) ;
2009-07-19 21:13:27 +00:00
connect ( textLayoutModule - > indentRB , SIGNAL ( toggled ( bool ) ) ,
textLayoutModule - > indentCO , SLOT ( setEnabled ( bool ) ) ) ;
connect ( textLayoutModule - > indentCO , SIGNAL ( activated ( int ) ) ,
this , SLOT ( change_adaptor ( ) ) ) ;
connect ( textLayoutModule - > indentCO , SIGNAL ( activated ( int ) ) ,
this , SLOT ( setIndent ( int ) ) ) ;
connect ( textLayoutModule - > indentLE , SIGNAL ( textChanged ( const QString & ) ) ,
this , SLOT ( change_adaptor ( ) ) ) ;
connect ( textLayoutModule - > indentLengthCO , SIGNAL ( activated ( int ) ) ,
this , SLOT ( change_adaptor ( ) ) ) ;
connect ( textLayoutModule - > skipRB , SIGNAL ( clicked ( ) ) ,
this , SLOT ( change_adaptor ( ) ) ) ;
connect ( textLayoutModule - > skipRB , SIGNAL ( toggled ( bool ) ) ,
textLayoutModule - > skipCO , SLOT ( setEnabled ( bool ) ) ) ;
2007-04-25 10:25:37 +00:00
connect ( textLayoutModule - > skipCO , SIGNAL ( activated ( int ) ) ,
this , SLOT ( change_adaptor ( ) ) ) ;
2009-07-19 21:13:27 +00:00
connect ( textLayoutModule - > skipCO , SIGNAL ( activated ( int ) ) ,
this , SLOT ( setSkip ( int ) ) ) ;
2007-04-25 10:25:37 +00:00
connect ( textLayoutModule - > skipLE , SIGNAL ( textChanged ( const QString & ) ) ,
this , SLOT ( change_adaptor ( ) ) ) ;
connect ( textLayoutModule - > skipLengthCO , SIGNAL ( activated ( int ) ) ,
this , SLOT ( change_adaptor ( ) ) ) ;
2009-07-19 21:13:27 +00:00
connect ( textLayoutModule - > indentRB , SIGNAL ( toggled ( bool ) ) ,
this , SLOT ( enableIndent ( bool ) ) ) ;
2007-04-25 10:25:37 +00:00
connect ( textLayoutModule - > skipRB , SIGNAL ( toggled ( bool ) ) ,
this , SLOT ( enableSkip ( bool ) ) ) ;
2009-07-19 21:13:27 +00:00
2007-04-25 10:25:37 +00:00
connect ( textLayoutModule - > twoColumnCB , SIGNAL ( clicked ( ) ) ,
this , SLOT ( change_adaptor ( ) ) ) ;
2008-02-19 05:39:36 +00:00
connect ( textLayoutModule - > twoColumnCB , SIGNAL ( clicked ( ) ) ,
this , SLOT ( setColSep ( ) ) ) ;
2011-12-07 22:33:25 +00:00
connect ( textLayoutModule - > justCB , SIGNAL ( clicked ( ) ) ,
this , SLOT ( change_adaptor ( ) ) ) ;
2009-07-20 08:09:32 +00:00
2007-04-24 19:37:34 +00:00
textLayoutModule - > lspacingLE - > setValidator ( new QDoubleValidator (
textLayoutModule - > lspacingLE ) ) ;
2009-07-19 21:13:27 +00:00
textLayoutModule - > indentLE - > setValidator ( unsignedLengthValidator (
textLayoutModule - > indentLE ) ) ;
2009-07-20 05:05:48 +00:00
textLayoutModule - > skipLE - > setValidator ( unsignedGlueLengthValidator (
2007-04-24 19:37:34 +00:00
textLayoutModule - > skipLE ) ) ;
2009-07-19 21:13:27 +00:00
textLayoutModule - > indentCO - > addItem ( qt_ ( " Default " ) ) ;
textLayoutModule - > indentCO - > addItem ( qt_ ( " Custom " ) ) ;
2007-04-24 19:37:34 +00:00
textLayoutModule - > skipCO - > addItem ( qt_ ( " SmallSkip " ) ) ;
textLayoutModule - > skipCO - > addItem ( qt_ ( " MedSkip " ) ) ;
textLayoutModule - > skipCO - > addItem ( qt_ ( " BigSkip " ) ) ;
2009-07-20 08:14:21 +00:00
textLayoutModule - > skipCO - > addItem ( qt_ ( " Custom " ) ) ;
2007-04-24 19:37:34 +00:00
textLayoutModule - > lspacingCO - > insertItem (
Spacing : : Single , qt_ ( " Single " ) ) ;
textLayoutModule - > lspacingCO - > insertItem (
Spacing : : Onehalf , qt_ ( " OneHalf " ) ) ;
textLayoutModule - > lspacingCO - > insertItem (
Spacing : : Double , qt_ ( " Double " ) ) ;
textLayoutModule - > lspacingCO - > insertItem (
Spacing : : Other , qt_ ( " Custom " ) ) ;
// initialize the length validator
2009-07-19 21:13:27 +00:00
bc ( ) . addCheckedLineEdit ( textLayoutModule - > indentLE ) ;
2007-09-05 20:33:29 +00:00
bc ( ) . addCheckedLineEdit ( textLayoutModule - > skipLE ) ;
2007-04-24 19:37:34 +00:00
2010-04-02 22:11:50 +00:00
2010-01-07 10:01:26 +00:00
// master/child handling
masterChildModule = new UiWidget < Ui : : MasterChildUi > ;
connect ( masterChildModule - > childrenTW , SIGNAL ( itemDoubleClicked ( QTreeWidgetItem * , int ) ) ,
this , SLOT ( includeonlyClicked ( QTreeWidgetItem * , int ) ) ) ;
connect ( masterChildModule - > includeonlyRB , SIGNAL ( toggled ( bool ) ) ,
masterChildModule - > childrenTW , SLOT ( setEnabled ( bool ) ) ) ;
2010-01-10 13:25:41 +00:00
connect ( masterChildModule - > includeonlyRB , SIGNAL ( toggled ( bool ) ) ,
masterChildModule - > maintainAuxCB , SLOT ( setEnabled ( bool ) ) ) ;
2010-01-07 10:01:26 +00:00
connect ( masterChildModule - > includeallRB , SIGNAL ( clicked ( ) ) ,
this , SLOT ( change_adaptor ( ) ) ) ;
connect ( masterChildModule - > includeonlyRB , SIGNAL ( clicked ( ) ) ,
this , SLOT ( change_adaptor ( ) ) ) ;
2010-01-10 13:25:41 +00:00
connect ( masterChildModule - > maintainAuxCB , SIGNAL ( clicked ( ) ) ,
this , SLOT ( change_adaptor ( ) ) ) ;
2010-01-07 10:01:26 +00:00
masterChildModule - > childrenTW - > setColumnCount ( 2 ) ;
masterChildModule - > childrenTW - > headerItem ( ) - > setText ( 0 , qt_ ( " Child Document " ) ) ;
masterChildModule - > childrenTW - > headerItem ( ) - > setText ( 1 , qt_ ( " Include to Output " ) ) ;
masterChildModule - > childrenTW - > resizeColumnToContents ( 1 ) ;
masterChildModule - > childrenTW - > resizeColumnToContents ( 2 ) ;
2010-04-02 22:11:50 +00:00
2009-04-10 11:06:53 +00:00
// output
outputModule = new UiWidget < Ui : : OutputUi > ;
connect ( outputModule - > defaultFormatCO , SIGNAL ( activated ( int ) ) ,
this , SLOT ( change_adaptor ( ) ) ) ;
2010-04-21 15:20:31 +00:00
connect ( outputModule - > mathimgSB , SIGNAL ( valueChanged ( double ) ) ,
this , SLOT ( change_adaptor ( ) ) ) ;
connect ( outputModule - > strictCB , SIGNAL ( stateChanged ( int ) ) ,
this , SLOT ( change_adaptor ( ) ) ) ;
2011-12-06 22:17:26 +00:00
connect ( outputModule - > cssCB , SIGNAL ( stateChanged ( int ) ) ,
this , SLOT ( change_adaptor ( ) ) ) ;
2010-04-21 15:20:31 +00:00
connect ( outputModule - > mathoutCB , SIGNAL ( currentIndexChanged ( int ) ) ,
this , SLOT ( change_adaptor ( ) ) ) ;
2009-04-10 11:06:53 +00:00
2010-05-25 11:53:58 +00:00
connect ( outputModule - > outputsyncCB , SIGNAL ( clicked ( ) ) ,
this , SLOT ( change_adaptor ( ) ) ) ;
connect ( outputModule - > synccustomCB , SIGNAL ( editTextChanged ( QString ) ) ,
this , SLOT ( change_adaptor ( ) ) ) ;
outputModule - > synccustomCB - > addItem ( " " ) ;
outputModule - > synccustomCB - > addItem ( " \\ synctex=1 " ) ;
outputModule - > synccustomCB - > addItem ( " \\ synctex=-1 " ) ;
outputModule - > synccustomCB - > addItem ( " \\ usepackage[active]{srcltx} " ) ;
2010-04-02 22:11:50 +00:00
2011-09-24 16:39:23 +00:00
outputModule - > synccustomCB - > setValidator ( new NoNewLineValidator (
outputModule - > synccustomCB ) ) ;
2007-04-24 19:37:34 +00:00
// fonts
2009-04-10 11:06:53 +00:00
fontModule = new UiWidget < Ui : : FontUi > ;
2010-11-26 09:42:03 +00:00
connect ( fontModule - > osFontsCB , SIGNAL ( clicked ( ) ) ,
this , SLOT ( change_adaptor ( ) ) ) ;
connect ( fontModule - > osFontsCB , SIGNAL ( toggled ( bool ) ) ,
this , SLOT ( osFontsChanged ( bool ) ) ) ;
2007-04-25 10:25:37 +00:00
connect ( fontModule - > fontsRomanCO , SIGNAL ( activated ( int ) ) ,
this , SLOT ( change_adaptor ( ) ) ) ;
connect ( fontModule - > fontsRomanCO , SIGNAL ( activated ( int ) ) ,
this , SLOT ( romanChanged ( int ) ) ) ;
connect ( fontModule - > fontsSansCO , SIGNAL ( activated ( int ) ) ,
this , SLOT ( change_adaptor ( ) ) ) ;
connect ( fontModule - > fontsSansCO , SIGNAL ( activated ( int ) ) ,
this , SLOT ( sansChanged ( int ) ) ) ;
connect ( fontModule - > fontsTypewriterCO , SIGNAL ( activated ( int ) ) ,
this , SLOT ( change_adaptor ( ) ) ) ;
connect ( fontModule - > fontsTypewriterCO , SIGNAL ( activated ( int ) ) ,
this , SLOT ( ttChanged ( int ) ) ) ;
2012-09-22 15:44:00 +00:00
connect ( fontModule - > fontsMathCO , SIGNAL ( activated ( int ) ) ,
this , SLOT ( change_adaptor ( ) ) ) ;
connect ( fontModule - > fontsMathCO , SIGNAL ( activated ( int ) ) ,
this , SLOT ( mathFontChanged ( int ) ) ) ;
2007-04-25 10:25:37 +00:00
connect ( fontModule - > fontsDefaultCO , SIGNAL ( activated ( int ) ) ,
this , SLOT ( change_adaptor ( ) ) ) ;
2009-11-29 14:43:00 +00:00
connect ( fontModule - > fontencCO , SIGNAL ( activated ( int ) ) ,
this , SLOT ( change_adaptor ( ) ) ) ;
connect ( fontModule - > fontencCO , SIGNAL ( activated ( int ) ) ,
this , SLOT ( fontencChanged ( int ) ) ) ;
connect ( fontModule - > fontencLE , SIGNAL ( textChanged ( const QString & ) ) ,
this , SLOT ( change_adaptor ( ) ) ) ;
2007-04-25 10:25:37 +00:00
connect ( fontModule - > fontsizeCO , SIGNAL ( activated ( int ) ) ,
this , SLOT ( change_adaptor ( ) ) ) ;
2008-06-05 06:18:34 +00:00
connect ( fontModule - > cjkFontLE , SIGNAL ( textChanged ( const QString & ) ) ,
this , SLOT ( change_adaptor ( ) ) ) ;
2007-04-25 10:25:37 +00:00
connect ( fontModule - > scaleSansSB , SIGNAL ( valueChanged ( int ) ) ,
this , SLOT ( change_adaptor ( ) ) ) ;
connect ( fontModule - > scaleTypewriterSB , SIGNAL ( valueChanged ( int ) ) ,
this , SLOT ( change_adaptor ( ) ) ) ;
connect ( fontModule - > fontScCB , SIGNAL ( clicked ( ) ) ,
this , SLOT ( change_adaptor ( ) ) ) ;
connect ( fontModule - > fontOsfCB , SIGNAL ( clicked ( ) ) ,
this , SLOT ( change_adaptor ( ) ) ) ;
2007-04-24 19:37:34 +00:00
2011-09-24 16:39:23 +00:00
fontModule - > fontencLE - > setValidator ( new NoNewLineValidator (
fontModule - > fontencLE ) ) ;
fontModule - > cjkFontLE - > setValidator ( new NoNewLineValidator (
fontModule - > cjkFontLE ) ) ;
2009-04-06 06:58:30 +00:00
updateFontlist ( ) ;
2007-04-24 19:37:34 +00:00
2007-06-01 17:44:04 +00:00
fontModule - > fontsizeCO - > addItem ( qt_ ( " Default " ) ) ;
2007-04-24 19:37:34 +00:00
fontModule - > fontsizeCO - > addItem ( qt_ ( " 10 " ) ) ;
fontModule - > fontsizeCO - > addItem ( qt_ ( " 11 " ) ) ;
fontModule - > fontsizeCO - > addItem ( qt_ ( " 12 " ) ) ;
2012-08-16 11:23:39 +00:00
fontModule - > fontencCO - > addItem ( qt_ ( " Default " ) , QString ( " global " ) ) ;
fontModule - > fontencCO - > addItem ( qt_ ( " Custom " ) , QString ( " custom " ) ) ;
fontModule - > fontencCO - > addItem ( qt_ ( " None (no fontenc) " ) , QString ( " default " ) ) ;
2009-11-29 14:43:00 +00:00
2007-10-06 22:43:21 +00:00
for ( int n = 0 ; GuiDocument : : fontfamilies_gui [ n ] [ 0 ] ; + + n )
2007-04-24 19:37:34 +00:00
fontModule - > fontsDefaultCO - > addItem (
2007-10-06 22:43:21 +00:00
qt_ ( GuiDocument : : fontfamilies_gui [ n ] ) ) ;
2007-04-24 19:37:34 +00:00
2011-02-09 08:23:11 +00:00
if ( ! LaTeXFeatures : : isAvailable ( " fontspec " ) )
fontModule - > osFontsCB - > setToolTip (
2011-02-09 08:31:18 +00:00
qt_ ( " Use OpenType and TrueType fonts directly (requires XeTeX or LuaTeX) \n "
2011-02-09 08:23:11 +00:00
" You need to install the package \" fontspec \" to use this feature " ) ) ;
2007-04-24 19:37:34 +00:00
// page layout
2010-04-02 22:11:50 +00:00
pageLayoutModule = new UiWidget < Ui : : PageLayoutUi > ;
2007-04-25 10:25:37 +00:00
connect ( pageLayoutModule - > papersizeCO , SIGNAL ( activated ( int ) ) ,
2009-07-16 08:39:22 +00:00
this , SLOT ( papersizeChanged ( int ) ) ) ;
2007-04-25 10:25:37 +00:00
connect ( pageLayoutModule - > papersizeCO , SIGNAL ( activated ( int ) ) ,
2009-07-16 08:39:22 +00:00
this , SLOT ( papersizeChanged ( int ) ) ) ;
2007-04-25 10:25:37 +00:00
connect ( pageLayoutModule - > portraitRB , SIGNAL ( clicked ( ) ) ,
2010-05-18 02:56:36 +00:00
this , SLOT ( change_adaptor ( ) ) ) ;
2007-04-25 10:25:37 +00:00
connect ( pageLayoutModule - > papersizeCO , SIGNAL ( activated ( int ) ) ,
this , SLOT ( change_adaptor ( ) ) ) ;
connect ( pageLayoutModule - > paperheightLE , SIGNAL ( textChanged ( const QString & ) ) ,
this , SLOT ( change_adaptor ( ) ) ) ;
connect ( pageLayoutModule - > paperwidthLE , SIGNAL ( textChanged ( const QString & ) ) ,
this , SLOT ( change_adaptor ( ) ) ) ;
connect ( pageLayoutModule - > paperwidthUnitCO , SIGNAL ( activated ( int ) ) ,
this , SLOT ( change_adaptor ( ) ) ) ;
connect ( pageLayoutModule - > paperheightUnitCO , SIGNAL ( activated ( int ) ) ,
this , SLOT ( change_adaptor ( ) ) ) ;
connect ( pageLayoutModule - > portraitRB , SIGNAL ( clicked ( ) ) ,
this , SLOT ( change_adaptor ( ) ) ) ;
connect ( pageLayoutModule - > landscapeRB , SIGNAL ( clicked ( ) ) ,
this , SLOT ( change_adaptor ( ) ) ) ;
connect ( pageLayoutModule - > facingPagesCB , SIGNAL ( clicked ( ) ) ,
this , SLOT ( change_adaptor ( ) ) ) ;
connect ( pageLayoutModule - > pagestyleCO , SIGNAL ( activated ( int ) ) ,
this , SLOT ( change_adaptor ( ) ) ) ;
2011-12-03 22:15:11 +00:00
2007-06-01 17:44:04 +00:00
pageLayoutModule - > pagestyleCO - > addItem ( qt_ ( " Default " ) ) ;
2007-04-24 19:37:34 +00:00
pageLayoutModule - > pagestyleCO - > addItem ( qt_ ( " empty " ) ) ;
pageLayoutModule - > pagestyleCO - > addItem ( qt_ ( " plain " ) ) ;
pageLayoutModule - > pagestyleCO - > addItem ( qt_ ( " headings " ) ) ;
pageLayoutModule - > pagestyleCO - > addItem ( qt_ ( " fancy " ) ) ;
2007-09-05 20:33:29 +00:00
bc ( ) . addCheckedLineEdit ( pageLayoutModule - > paperheightLE ,
2007-04-24 19:37:34 +00:00
pageLayoutModule - > paperheightL ) ;
2007-09-05 20:33:29 +00:00
bc ( ) . addCheckedLineEdit ( pageLayoutModule - > paperwidthLE ,
2007-04-24 19:37:34 +00:00
pageLayoutModule - > paperwidthL ) ;
QComboBox * cb = pageLayoutModule - > papersizeCO ;
cb - > addItem ( qt_ ( " Default " ) ) ;
cb - > addItem ( qt_ ( " Custom " ) ) ;
cb - > addItem ( qt_ ( " US letter " ) ) ;
cb - > addItem ( qt_ ( " US legal " ) ) ;
cb - > addItem ( qt_ ( " US executive " ) ) ;
2010-05-18 01:22:08 +00:00
cb - > addItem ( qt_ ( " A0 " ) ) ;
cb - > addItem ( qt_ ( " A1 " ) ) ;
cb - > addItem ( qt_ ( " A2 " ) ) ;
2007-04-24 19:37:34 +00:00
cb - > addItem ( qt_ ( " A3 " ) ) ;
cb - > addItem ( qt_ ( " A4 " ) ) ;
cb - > addItem ( qt_ ( " A5 " ) ) ;
2010-05-18 01:22:08 +00:00
cb - > addItem ( qt_ ( " A6 " ) ) ;
cb - > addItem ( qt_ ( " B0 " ) ) ;
cb - > addItem ( qt_ ( " B1 " ) ) ;
cb - > addItem ( qt_ ( " B2 " ) ) ;
2007-04-24 19:37:34 +00:00
cb - > addItem ( qt_ ( " B3 " ) ) ;
cb - > addItem ( qt_ ( " B4 " ) ) ;
cb - > addItem ( qt_ ( " B5 " ) ) ;
2010-05-18 01:22:08 +00:00
cb - > addItem ( qt_ ( " B6 " ) ) ;
2010-07-13 01:06:20 +00:00
cb - > addItem ( qt_ ( " C0 " ) ) ;
cb - > addItem ( qt_ ( " C1 " ) ) ;
cb - > addItem ( qt_ ( " C2 " ) ) ;
cb - > addItem ( qt_ ( " C3 " ) ) ;
cb - > addItem ( qt_ ( " C4 " ) ) ;
cb - > addItem ( qt_ ( " C5 " ) ) ;
cb - > addItem ( qt_ ( " C6 " ) ) ;
2010-05-18 01:22:08 +00:00
cb - > addItem ( qt_ ( " JIS B0 " ) ) ;
cb - > addItem ( qt_ ( " JIS B1 " ) ) ;
cb - > addItem ( qt_ ( " JIS B2 " ) ) ;
cb - > addItem ( qt_ ( " JIS B3 " ) ) ;
cb - > addItem ( qt_ ( " JIS B4 " ) ) ;
cb - > addItem ( qt_ ( " JIS B5 " ) ) ;
cb - > addItem ( qt_ ( " JIS B6 " ) ) ;
2007-04-24 19:37:34 +00:00
// remove the %-items from the unit choice
pageLayoutModule - > paperwidthUnitCO - > noPercents ( ) ;
pageLayoutModule - > paperheightUnitCO - > noPercents ( ) ;
pageLayoutModule - > paperheightLE - > setValidator ( unsignedLengthValidator (
pageLayoutModule - > paperheightLE ) ) ;
pageLayoutModule - > paperwidthLE - > setValidator ( unsignedLengthValidator (
pageLayoutModule - > paperwidthLE ) ) ;
// margins
2010-04-02 22:11:50 +00:00
marginsModule = new UiWidget < Ui : : MarginsUi > ;
2007-04-25 10:25:37 +00:00
connect ( marginsModule - > marginCB , SIGNAL ( toggled ( bool ) ) ,
this , SLOT ( setCustomMargins ( bool ) ) ) ;
connect ( marginsModule - > marginCB , SIGNAL ( clicked ( ) ) ,
this , SLOT ( change_adaptor ( ) ) ) ;
2008-09-20 12:57:12 +00:00
connect ( marginsModule - > topLE , SIGNAL ( textChanged ( QString ) ) ,
2007-04-25 10:25:37 +00:00
this , SLOT ( change_adaptor ( ) ) ) ;
connect ( marginsModule - > topUnit , SIGNAL ( activated ( int ) ) ,
this , SLOT ( change_adaptor ( ) ) ) ;
2008-09-20 12:57:12 +00:00
connect ( marginsModule - > bottomLE , SIGNAL ( textChanged ( QString ) ) ,
2007-04-25 10:25:37 +00:00
this , SLOT ( change_adaptor ( ) ) ) ;
connect ( marginsModule - > bottomUnit , SIGNAL ( activated ( int ) ) ,
this , SLOT ( change_adaptor ( ) ) ) ;
2008-09-20 12:57:12 +00:00
connect ( marginsModule - > innerLE , SIGNAL ( textChanged ( QString ) ) ,
2007-04-25 10:25:37 +00:00
this , SLOT ( change_adaptor ( ) ) ) ;
connect ( marginsModule - > innerUnit , SIGNAL ( activated ( int ) ) ,
this , SLOT ( change_adaptor ( ) ) ) ;
2008-09-20 12:57:12 +00:00
connect ( marginsModule - > outerLE , SIGNAL ( textChanged ( QString ) ) ,
2007-04-25 10:25:37 +00:00
this , SLOT ( change_adaptor ( ) ) ) ;
connect ( marginsModule - > outerUnit , SIGNAL ( activated ( int ) ) ,
this , SLOT ( change_adaptor ( ) ) ) ;
2008-09-20 12:57:12 +00:00
connect ( marginsModule - > headheightLE , SIGNAL ( textChanged ( QString ) ) ,
2007-04-25 10:25:37 +00:00
this , SLOT ( change_adaptor ( ) ) ) ;
connect ( marginsModule - > headheightUnit , SIGNAL ( activated ( int ) ) ,
this , SLOT ( change_adaptor ( ) ) ) ;
2008-09-20 12:57:12 +00:00
connect ( marginsModule - > headsepLE , SIGNAL ( textChanged ( QString ) ) ,
2007-04-25 10:25:37 +00:00
this , SLOT ( change_adaptor ( ) ) ) ;
connect ( marginsModule - > headsepUnit , SIGNAL ( activated ( int ) ) ,
this , SLOT ( change_adaptor ( ) ) ) ;
2008-09-20 12:57:12 +00:00
connect ( marginsModule - > footskipLE , SIGNAL ( textChanged ( QString ) ) ,
2007-04-25 10:25:37 +00:00
this , SLOT ( change_adaptor ( ) ) ) ;
connect ( marginsModule - > footskipUnit , SIGNAL ( activated ( int ) ) ,
this , SLOT ( change_adaptor ( ) ) ) ;
2008-09-20 12:57:12 +00:00
connect ( marginsModule - > columnsepLE , SIGNAL ( textChanged ( QString ) ) ,
2008-02-19 05:24:48 +00:00
this , SLOT ( change_adaptor ( ) ) ) ;
connect ( marginsModule - > columnsepUnit , SIGNAL ( activated ( int ) ) ,
this , SLOT ( change_adaptor ( ) ) ) ;
2007-04-24 19:37:34 +00:00
marginsModule - > topLE - > setValidator ( unsignedLengthValidator (
marginsModule - > topLE ) ) ;
marginsModule - > bottomLE - > setValidator ( unsignedLengthValidator (
marginsModule - > bottomLE ) ) ;
marginsModule - > innerLE - > setValidator ( unsignedLengthValidator (
marginsModule - > innerLE ) ) ;
marginsModule - > outerLE - > setValidator ( unsignedLengthValidator (
marginsModule - > outerLE ) ) ;
marginsModule - > headsepLE - > setValidator ( unsignedLengthValidator (
marginsModule - > headsepLE ) ) ;
marginsModule - > headheightLE - > setValidator ( unsignedLengthValidator (
marginsModule - > headheightLE ) ) ;
marginsModule - > footskipLE - > setValidator ( unsignedLengthValidator (
marginsModule - > footskipLE ) ) ;
2008-02-19 05:24:48 +00:00
marginsModule - > columnsepLE - > setValidator ( unsignedLengthValidator (
marginsModule - > columnsepLE ) ) ;
2007-04-24 19:37:34 +00:00
2007-09-05 20:33:29 +00:00
bc ( ) . addCheckedLineEdit ( marginsModule - > topLE ,
2007-04-24 19:37:34 +00:00
marginsModule - > topL ) ;
2007-09-05 20:33:29 +00:00
bc ( ) . addCheckedLineEdit ( marginsModule - > bottomLE ,
2007-04-24 19:37:34 +00:00
marginsModule - > bottomL ) ;
2007-09-05 20:33:29 +00:00
bc ( ) . addCheckedLineEdit ( marginsModule - > innerLE ,
2007-04-24 19:37:34 +00:00
marginsModule - > innerL ) ;
2007-09-05 20:33:29 +00:00
bc ( ) . addCheckedLineEdit ( marginsModule - > outerLE ,
2007-04-24 19:37:34 +00:00
marginsModule - > outerL ) ;
2007-09-05 20:33:29 +00:00
bc ( ) . addCheckedLineEdit ( marginsModule - > headsepLE ,
2007-04-24 19:37:34 +00:00
marginsModule - > headsepL ) ;
2007-09-05 20:33:29 +00:00
bc ( ) . addCheckedLineEdit ( marginsModule - > headheightLE ,
2007-04-24 19:37:34 +00:00
marginsModule - > headheightL ) ;
2007-09-05 20:33:29 +00:00
bc ( ) . addCheckedLineEdit ( marginsModule - > footskipLE ,
2007-04-24 19:37:34 +00:00
marginsModule - > footskipL ) ;
2008-02-19 05:24:48 +00:00
bc ( ) . addCheckedLineEdit ( marginsModule - > columnsepLE ,
marginsModule - > columnsepL ) ;
2007-04-24 19:37:34 +00:00
// language & quote
2010-04-02 22:11:50 +00:00
langModule = new UiWidget < Ui : : LanguageUi > ;
2012-06-08 17:21:30 +00:00
connect ( langModule - > languageCO , SIGNAL ( activated ( int ) ) ,
this , SLOT ( change_adaptor ( ) ) ) ;
2007-04-25 10:25:37 +00:00
connect ( langModule - > languageCO , SIGNAL ( activated ( int ) ) ,
2012-06-08 03:39:00 +00:00
this , SLOT ( languageChanged ( int ) ) ) ;
2007-09-19 12:29:08 +00:00
connect ( langModule - > defaultencodingRB , SIGNAL ( clicked ( ) ) ,
this , SLOT ( change_adaptor ( ) ) ) ;
connect ( langModule - > otherencodingRB , SIGNAL ( clicked ( ) ) ,
2007-04-25 10:25:37 +00:00
this , SLOT ( change_adaptor ( ) ) ) ;
connect ( langModule - > encodingCO , SIGNAL ( activated ( int ) ) ,
this , SLOT ( change_adaptor ( ) ) ) ;
connect ( langModule - > quoteStyleCO , SIGNAL ( activated ( int ) ) ,
this , SLOT ( change_adaptor ( ) ) ) ;
2011-02-03 14:17:31 +00:00
connect ( langModule - > languagePackageCO , SIGNAL ( activated ( int ) ) ,
this , SLOT ( change_adaptor ( ) ) ) ;
2011-09-24 16:39:20 +00:00
connect ( langModule - > languagePackageLE , SIGNAL ( textChanged ( QString ) ) ,
2011-02-03 14:17:31 +00:00
this , SLOT ( change_adaptor ( ) ) ) ;
connect ( langModule - > languagePackageCO , SIGNAL ( currentIndexChanged ( int ) ) ,
this , SLOT ( languagePackageChanged ( int ) ) ) ;
2010-04-02 22:11:50 +00:00
2011-09-24 16:39:23 +00:00
langModule - > languagePackageLE - > setValidator ( new NoNewLineValidator (
langModule - > languagePackageLE ) ) ;
2008-05-14 10:34:19 +00:00
QAbstractItemModel * language_model = guiApp - > languageModel ( ) ;
// FIXME: it would be nice if sorting was enabled/disabled via a checkbox.
language_model - > sort ( 0 ) ;
langModule - > languageCO - > setModel ( language_model ) ;
2010-02-10 08:10:31 +00:00
langModule - > languageCO - > setModelColumn ( 0 ) ;
2007-04-24 19:37:34 +00:00
// Always put the default encoding in the first position.
2008-09-01 08:39:19 +00:00
langModule - > encodingCO - > addItem ( qt_ ( " Language Default (no inputenc) " ) ) ;
2008-07-11 08:56:17 +00:00
QStringList encodinglist ;
2007-04-24 19:37:34 +00:00
Encodings : : const_iterator it = encodings . begin ( ) ;
Encodings : : const_iterator const end = encodings . end ( ) ;
for ( ; it ! = end ; + + it )
2012-12-30 19:39:33 +00:00
if ( ! it - > unsafe ( ) )
encodinglist . append ( qt_ ( it - > guiName ( ) ) ) ;
2008-07-11 08:56:17 +00:00
encodinglist . sort ( ) ;
langModule - > encodingCO - > addItems ( encodinglist ) ;
2007-04-24 19:37:34 +00:00
2012-07-01 09:27:42 +00:00
langModule - > quoteStyleCO - > addItem (
qt_ ( " ``text'' " ) , InsetQuotes : : EnglishQuotes ) ;
langModule - > quoteStyleCO - > addItem (
qt_ ( " ''text'' " ) , InsetQuotes : : SwedishQuotes ) ;
langModule - > quoteStyleCO - > addItem
( qt_ ( " ,,text`` " ) , InsetQuotes : : GermanQuotes ) ;
langModule - > quoteStyleCO - > addItem (
qt_ ( " ,,text'' " ) , InsetQuotes : : PolishQuotes ) ;
langModule - > quoteStyleCO - > addItem (
qt_ ( " <<text>> " ) , InsetQuotes : : FrenchQuotes ) ;
langModule - > quoteStyleCO - > addItem (
qt_ ( " >>text<< " ) , InsetQuotes : : DanishQuotes ) ;
2007-04-24 19:37:34 +00:00
2011-02-03 14:17:31 +00:00
langModule - > languagePackageCO - > addItem (
qt_ ( " Default " ) , toqstr ( " default " ) ) ;
langModule - > languagePackageCO - > addItem (
qt_ ( " Automatic " ) , toqstr ( " auto " ) ) ;
langModule - > languagePackageCO - > addItem (
qt_ ( " Always Babel " ) , toqstr ( " babel " ) ) ;
langModule - > languagePackageCO - > addItem (
qt_ ( " Custom " ) , toqstr ( " custom " ) ) ;
langModule - > languagePackageCO - > addItem (
qt_ ( " None[[language package]] " ) , toqstr ( " none " ) ) ;
2007-04-24 19:37:34 +00:00
2010-04-02 22:11:50 +00:00
// color
colorModule = new UiWidget < Ui : : ColorUi > ;
2010-04-02 23:39:36 +00:00
connect ( colorModule - > fontColorPB , SIGNAL ( clicked ( ) ) ,
this , SLOT ( changeFontColor ( ) ) ) ;
connect ( colorModule - > delFontColorTB , SIGNAL ( clicked ( ) ) ,
this , SLOT ( deleteFontColor ( ) ) ) ;
2010-04-02 22:11:50 +00:00
connect ( colorModule - > noteFontColorPB , SIGNAL ( clicked ( ) ) ,
this , SLOT ( changeNoteFontColor ( ) ) ) ;
connect ( colorModule - > delNoteFontColorTB , SIGNAL ( clicked ( ) ) ,
this , SLOT ( deleteNoteFontColor ( ) ) ) ;
connect ( colorModule - > backgroundPB , SIGNAL ( clicked ( ) ) ,
this , SLOT ( changeBackgroundColor ( ) ) ) ;
2010-04-05 20:31:10 +00:00
connect ( colorModule - > delBackgroundTB , SIGNAL ( clicked ( ) ) ,
2010-04-02 22:11:50 +00:00
this , SLOT ( deleteBackgroundColor ( ) ) ) ;
2010-04-08 00:14:08 +00:00
connect ( colorModule - > boxBackgroundPB , SIGNAL ( clicked ( ) ) ,
this , SLOT ( changeBoxBackgroundColor ( ) ) ) ;
connect ( colorModule - > delBoxBackgroundTB , SIGNAL ( clicked ( ) ) ,
this , SLOT ( deleteBoxBackgroundColor ( ) ) ) ;
2010-04-02 22:11:50 +00:00
2007-04-24 19:37:34 +00:00
// numbering
2010-04-02 22:11:50 +00:00
numberingModule = new UiWidget < Ui : : NumberingUi > ;
2007-04-25 10:25:37 +00:00
connect ( numberingModule - > depthSL , SIGNAL ( valueChanged ( int ) ) ,
this , SLOT ( change_adaptor ( ) ) ) ;
connect ( numberingModule - > tocSL , SIGNAL ( valueChanged ( int ) ) ,
this , SLOT ( change_adaptor ( ) ) ) ;
connect ( numberingModule - > depthSL , SIGNAL ( valueChanged ( int ) ) ,
this , SLOT ( updateNumbering ( ) ) ) ;
connect ( numberingModule - > tocSL , SIGNAL ( valueChanged ( int ) ) ,
this , SLOT ( updateNumbering ( ) ) ) ;
2007-04-24 19:37:34 +00:00
numberingModule - > tocTW - > setColumnCount ( 3 ) ;
numberingModule - > tocTW - > headerItem ( ) - > setText ( 0 , qt_ ( " Example " ) ) ;
numberingModule - > tocTW - > headerItem ( ) - > setText ( 1 , qt_ ( " Numbered " ) ) ;
numberingModule - > tocTW - > headerItem ( ) - > setText ( 2 , qt_ ( " Appears in TOC " ) ) ;
2013-02-03 11:23:31 +00:00
setSectionResizeMode ( numberingModule - > tocTW - > header ( ) , QHeaderView : : ResizeToContents ) ;
2007-04-24 19:37:34 +00:00
2010-04-02 22:11:50 +00:00
// biblio
2007-04-24 19:37:34 +00:00
biblioModule = new UiWidget < Ui : : BiblioUi > ;
2012-01-09 13:16:38 +00:00
connect ( biblioModule - > citeDefaultRB , SIGNAL ( toggled ( bool ) ) ,
this , SLOT ( setNumerical ( bool ) ) ) ;
connect ( biblioModule - > citeJurabibRB , SIGNAL ( toggled ( bool ) ) ,
this , SLOT ( setAuthorYear ( bool ) ) ) ;
2007-04-25 10:25:37 +00:00
connect ( biblioModule - > citeNatbibRB , SIGNAL ( toggled ( bool ) ) ,
biblioModule - > citationStyleL , SLOT ( setEnabled ( bool ) ) ) ;
connect ( biblioModule - > citeNatbibRB , SIGNAL ( toggled ( bool ) ) ,
biblioModule - > citeStyleCO , SLOT ( setEnabled ( bool ) ) ) ;
connect ( biblioModule - > citeDefaultRB , SIGNAL ( clicked ( ) ) ,
2011-12-12 16:04:00 +00:00
this , SLOT ( biblioChanged ( ) ) ) ;
2007-04-25 10:25:37 +00:00
connect ( biblioModule - > citeNatbibRB , SIGNAL ( clicked ( ) ) ,
2011-12-12 16:04:00 +00:00
this , SLOT ( biblioChanged ( ) ) ) ;
2007-04-25 10:25:37 +00:00
connect ( biblioModule - > citeStyleCO , SIGNAL ( activated ( int ) ) ,
2011-12-12 16:04:00 +00:00
this , SLOT ( biblioChanged ( ) ) ) ;
2007-04-25 10:25:37 +00:00
connect ( biblioModule - > citeJurabibRB , SIGNAL ( clicked ( ) ) ,
2011-12-12 16:04:00 +00:00
this , SLOT ( biblioChanged ( ) ) ) ;
2007-04-25 10:25:37 +00:00
connect ( biblioModule - > bibtopicCB , SIGNAL ( clicked ( ) ) ,
2011-12-12 16:04:00 +00:00
this , SLOT ( biblioChanged ( ) ) ) ;
2009-05-22 07:20:00 +00:00
connect ( biblioModule - > bibtexCO , SIGNAL ( activated ( int ) ) ,
this , SLOT ( bibtexChanged ( int ) ) ) ;
2011-09-24 16:39:20 +00:00
connect ( biblioModule - > bibtexOptionsLE , SIGNAL ( textChanged ( QString ) ) ,
2011-12-12 16:04:00 +00:00
this , SLOT ( biblioChanged ( ) ) ) ;
2011-12-12 14:45:30 +00:00
connect ( biblioModule - > bibtexStyleLE , SIGNAL ( textChanged ( QString ) ) ,
2011-12-12 16:04:00 +00:00
this , SLOT ( biblioChanged ( ) ) ) ;
2010-04-02 22:11:50 +00:00
2011-09-24 16:39:23 +00:00
biblioModule - > bibtexOptionsLE - > setValidator ( new NoNewLineValidator (
biblioModule - > bibtexOptionsLE ) ) ;
2011-12-12 14:45:30 +00:00
biblioModule - > bibtexStyleLE - > setValidator ( new NoNewLineValidator (
biblioModule - > bibtexStyleLE ) ) ;
2011-09-24 16:39:23 +00:00
2007-04-24 19:37:34 +00:00
biblioModule - > citeStyleCO - > addItem ( qt_ ( " Author-year " ) ) ;
biblioModule - > citeStyleCO - > addItem ( qt_ ( " Numerical " ) ) ;
biblioModule - > citeStyleCO - > setCurrentIndex ( 0 ) ;
2011-02-04 07:37:12 +00:00
// NOTE: we do not provide "custom" here for security reasons!
2009-05-22 07:20:00 +00:00
biblioModule - > bibtexCO - > clear ( ) ;
biblioModule - > bibtexCO - > addItem ( qt_ ( " Default " ) , QString ( " default " ) ) ;
2009-05-28 12:49:41 +00:00
for ( set < string > : : const_iterator it = lyxrc . bibtex_alternatives . begin ( ) ;
2009-05-22 07:20:00 +00:00
it ! = lyxrc . bibtex_alternatives . end ( ) ; + + it ) {
QString const command = toqstr ( * it ) . left ( toqstr ( * it ) . indexOf ( " " ) ) ;
biblioModule - > bibtexCO - > addItem ( command , command ) ;
}
2011-02-03 15:03:38 +00:00
2007-04-24 19:37:34 +00:00
2009-04-16 07:29:01 +00:00
// indices
indicesModule = new GuiIndices ;
connect ( indicesModule , SIGNAL ( changed ( ) ) ,
this , SLOT ( change_adaptor ( ) ) ) ;
2007-04-24 19:37:34 +00:00
2010-04-02 22:11:50 +00:00
// maths
2012-01-03 20:51:07 +00:00
// FIXME This UI has problems:
// 1) It is not generic, packages_gui needs to be changed for each new package
// 2) Two checkboxes have 4 states, but one is invalid (both pressed)
// 3) The auto cb is not disabled if the use cb is checked
2007-04-24 19:37:34 +00:00
mathsModule = new UiWidget < Ui : : MathsUi > ;
2012-01-03 20:51:07 +00:00
vector < string > const & packages = BufferParams : : auto_packages ( ) ;
for ( size_t i = 0 ; i < packages . size ( ) ; + + i ) {
// Use the order of BufferParams::auto_packages() for easier
// access in applyView() and paramsToDialog()
int n = 0 ;
for ( n = 0 ; packages_gui [ n ] [ 0 ] [ 0 ] ; n + + )
if ( packages_gui [ n ] [ 0 ] = = packages [ i ] )
break ;
// If this fires somebody changed
// BufferParams::auto_packages() without adjusting packages_gui
LASSERT ( packages_gui [ n ] [ 0 ] [ 0 ] , /**/ ) ;
QString autoText = qt_ ( packages_gui [ n ] [ 1 ] ) ;
QString alwaysText = qt_ ( packages_gui [ n ] [ 2 ] ) ;
QString autoTooltip = qt_ ( packages_gui [ n ] [ 3 ] ) ;
QString alwaysTooltip ;
if ( packages [ i ] = = " amsmath " )
alwaysTooltip =
qt_ ( " The AMS LaTeX packages are always used " ) ;
else
alwaysTooltip = toqstr ( bformat (
_ ( " The LaTeX package %1$s is always used " ) ,
from_ascii ( packages [ i ] ) ) ) ;
QCheckBox * autoCB = new QCheckBox ( autoText , mathsModule ) ;
QCheckBox * alwaysCB = new QCheckBox ( alwaysText , mathsModule ) ;
mathsModule - > gridLayout - > addWidget ( autoCB , 2 * i , 0 ) ;
mathsModule - > gridLayout - > addWidget ( alwaysCB , 2 * i + 1 , 0 ) ;
autoCB - > setToolTip ( autoTooltip ) ;
alwaysCB - > setToolTip ( alwaysTooltip ) ;
connect ( autoCB , SIGNAL ( toggled ( bool ) ) ,
alwaysCB , SLOT ( setDisabled ( bool ) ) ) ;
connect ( autoCB , SIGNAL ( clicked ( ) ) ,
this , SLOT ( change_adaptor ( ) ) ) ;
connect ( alwaysCB , SIGNAL ( clicked ( ) ) ,
this , SLOT ( change_adaptor ( ) ) ) ;
}
QSpacerItem * spacer = new QSpacerItem ( 20 , 20 , QSizePolicy : : Minimum ,
QSizePolicy : : Expanding ) ;
mathsModule - > gridLayout - > addItem ( spacer , 2 * packages . size ( ) , 0 ) ;
2011-12-03 22:15:11 +00:00
2010-04-02 22:11:50 +00:00
2007-04-24 19:37:34 +00:00
// latex class
2010-04-02 22:11:50 +00:00
latexModule = new UiWidget < Ui : : LaTeXUi > ;
2008-09-20 12:57:12 +00:00
connect ( latexModule - > optionsLE , SIGNAL ( textChanged ( QString ) ) ,
2007-04-25 10:25:37 +00:00
this , SLOT ( change_adaptor ( ) ) ) ;
2008-10-12 09:36:00 +00:00
connect ( latexModule - > defaultOptionsCB , SIGNAL ( clicked ( ) ) ,
this , SLOT ( change_adaptor ( ) ) ) ;
2007-04-25 10:25:37 +00:00
connect ( latexModule - > psdriverCO , SIGNAL ( activated ( int ) ) ,
this , SLOT ( change_adaptor ( ) ) ) ;
connect ( latexModule - > classCO , SIGNAL ( activated ( int ) ) ,
this , SLOT ( classChanged ( ) ) ) ;
2008-01-15 10:38:19 +00:00
connect ( latexModule - > classCO , SIGNAL ( activated ( int ) ) ,
this , SLOT ( change_adaptor ( ) ) ) ;
2008-03-10 21:31:22 +00:00
connect ( latexModule - > layoutPB , SIGNAL ( clicked ( ) ) ,
this , SLOT ( browseLayout ( ) ) ) ;
2008-07-11 02:43:02 +00:00
connect ( latexModule - > layoutPB , SIGNAL ( clicked ( ) ) ,
this , SLOT ( change_adaptor ( ) ) ) ;
2008-04-28 16:38:56 +00:00
connect ( latexModule - > childDocGB , SIGNAL ( clicked ( ) ) ,
this , SLOT ( change_adaptor ( ) ) ) ;
2008-09-20 12:57:12 +00:00
connect ( latexModule - > childDocLE , SIGNAL ( textChanged ( QString ) ) ,
2008-04-28 16:38:56 +00:00
this , SLOT ( change_adaptor ( ) ) ) ;
connect ( latexModule - > childDocPB , SIGNAL ( clicked ( ) ) ,
this , SLOT ( browseMaster ( ) ) ) ;
2009-08-14 00:52:33 +00:00
connect ( latexModule - > suppressDateCB , SIGNAL ( clicked ( ) ) ,
this , SLOT ( change_adaptor ( ) ) ) ;
2010-10-13 12:36:53 +00:00
connect ( latexModule - > refstyleCB , SIGNAL ( clicked ( ) ) ,
this , SLOT ( change_adaptor ( ) ) ) ;
2008-10-20 19:53:15 +00:00
2011-09-24 16:39:23 +00:00
latexModule - > optionsLE - > setValidator ( new NoNewLineValidator (
latexModule - > optionsLE ) ) ;
latexModule - > childDocLE - > setValidator ( new NoNewLineValidator (
latexModule - > childDocLE ) ) ;
This is the last of a series of patches that merges the layout modules development in personal/branches/rgheck back into the tree.
Design goal: Allow the use of layout "modules", which are to LaTeX packages as layout files are to LaTeX document classes. Thus, one could have a module that defined certain character styles, environments, commands, or what have you, and include it in various documents, each of which uses a different document class, without having to modify the layout files themselves. For example, a theorems.module could be used with article.layout to provide support for theorem-type environments, without having to modify article.layout itself, and the same module could be used with book.layout, etc.
This patch adds the GUI for managing modules.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20282 a592a061-630c-0410-9148-cb99ea01b6c8
2007-09-15 01:55:09 +00:00
// postscript drivers
2007-04-24 19:37:34 +00:00
for ( int n = 0 ; tex_graphics [ n ] [ 0 ] ; + + n ) {
2007-06-01 17:44:04 +00:00
QString enc = qt_ ( tex_graphics_gui [ n ] ) ;
2007-04-24 19:37:34 +00:00
latexModule - > psdriverCO - > addItem ( enc ) ;
}
This is the last of a series of patches that merges the layout modules development in personal/branches/rgheck back into the tree.
Design goal: Allow the use of layout "modules", which are to LaTeX packages as layout files are to LaTeX document classes. Thus, one could have a module that defined certain character styles, environments, commands, or what have you, and include it in various documents, each of which uses a different document class, without having to modify the layout files themselves. For example, a theorems.module could be used with article.layout to provide support for theorem-type environments, without having to modify article.layout itself, and the same module could be used with book.layout, etc.
This patch adds the GUI for managing modules.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20282 a592a061-630c-0410-9148-cb99ea01b6c8
2007-09-15 01:55:09 +00:00
// latex classes
2008-03-07 03:53:21 +00:00
LayoutFileList const & bcl = LayoutFileList : : get ( ) ;
This is the last of the commits that hopes to enforce the distinction between "layout files" and "document classes" that was introduced by the modules code. For the most part, these changes just refactor code from TextClass between: (a) a TextClass base class; (b) a LayoutFile subclass, which represents the information in a .layout file; and (c) a DocumentClass subclass, which represents the layout information associated with a Buffer---a LayoutFile plus Modules. Methods from TextClass have been apportioned between the three classes depending upon what is needed where, and signatures have been changed where necessary so that the right kind of class is required.
At this point, there are no simple TextClass objects in the main LyX code, and it is impossible to create them, since the TextClass constructor is protected. Only LayoutFile and DocumentClass objects can be constructed, and for the most part these are constructed only by their respective containers: BaseClassList and DocumentClassBundle. There is an exception: LayoutFile does have a public default constructor, but if anyone knows how to make it go away, please do.
There will be one or two more commits along these lines, but these will be simple renamings. For example, BaseClassList should be LayoutFileList.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23343 a592a061-630c-0410-9148-cb99ea01b6c8
2008-02-29 02:45:33 +00:00
vector < LayoutFileIndex > classList = bcl . classList ( ) ;
2008-02-28 21:04:55 +00:00
sort ( classList . begin ( ) , classList . end ( ) , less_textclass_avail_desc ( ) ) ;
This is the last of the commits that hopes to enforce the distinction between "layout files" and "document classes" that was introduced by the modules code. For the most part, these changes just refactor code from TextClass between: (a) a TextClass base class; (b) a LayoutFile subclass, which represents the information in a .layout file; and (c) a DocumentClass subclass, which represents the layout information associated with a Buffer---a LayoutFile plus Modules. Methods from TextClass have been apportioned between the three classes depending upon what is needed where, and signatures have been changed where necessary so that the right kind of class is required.
At this point, there are no simple TextClass objects in the main LyX code, and it is impossible to create them, since the TextClass constructor is protected. Only LayoutFile and DocumentClass objects can be constructed, and for the most part these are constructed only by their respective containers: BaseClassList and DocumentClassBundle. There is an exception: LayoutFile does have a public default constructor, but if anyone knows how to make it go away, please do.
There will be one or two more commits along these lines, but these will be simple renamings. For example, BaseClassList should be LayoutFileList.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23343 a592a061-630c-0410-9148-cb99ea01b6c8
2008-02-29 02:45:33 +00:00
vector < LayoutFileIndex > : : const_iterator cit = classList . begin ( ) ;
vector < LayoutFileIndex > : : const_iterator cen = classList . end ( ) ;
2008-02-28 21:04:55 +00:00
for ( int i = 0 ; cit ! = cen ; + + cit , + + i ) {
This is the last of the commits that hopes to enforce the distinction between "layout files" and "document classes" that was introduced by the modules code. For the most part, these changes just refactor code from TextClass between: (a) a TextClass base class; (b) a LayoutFile subclass, which represents the information in a .layout file; and (c) a DocumentClass subclass, which represents the layout information associated with a Buffer---a LayoutFile plus Modules. Methods from TextClass have been apportioned between the three classes depending upon what is needed where, and signatures have been changed where necessary so that the right kind of class is required.
At this point, there are no simple TextClass objects in the main LyX code, and it is impossible to create them, since the TextClass constructor is protected. Only LayoutFile and DocumentClass objects can be constructed, and for the most part these are constructed only by their respective containers: BaseClassList and DocumentClassBundle. There is an exception: LayoutFile does have a public default constructor, but if anyone knows how to make it go away, please do.
There will be one or two more commits along these lines, but these will be simple renamings. For example, BaseClassList should be LayoutFileList.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23343 a592a061-630c-0410-9148-cb99ea01b6c8
2008-02-29 02:45:33 +00:00
LayoutFile const & tc = bcl [ * cit ] ;
2012-10-09 05:22:48 +00:00
bool const available = tc . isTeXClassAvailable ( ) ;
docstring const guiname = translateIfPossible ( from_utf8 ( tc . description ( ) ) ) ;
// tooltip sensu "KOMA-Script Article [Class 'scrartcl']"
QString tooltip = toqstr ( bformat ( _ ( " %1$s [Class '%2$s'] " ) , guiname , from_utf8 ( tc . latexname ( ) ) ) ) ;
if ( ! available ) {
docstring const output_type = ( tc . outputType ( ) = = lyx : : DOCBOOK ) ? _ ( " DocBook " ) : _ ( " LaTeX " ) ;
tooltip + = ' \n ' + toqstr ( wrap ( bformat ( _ ( " Class not found by LyX. "
" Please check if you have the matching %1$s class "
2013-01-20 14:32:49 +00:00
" and all required packages (%2$s) installed. " ) ,
2012-10-09 05:22:48 +00:00
output_type , from_utf8 ( tc . prerequisites ( " , " ) ) ) ) ) ;
}
latexModule - > classCO - > addItemSort ( toqstr ( tc . name ( ) ) ,
toqstr ( guiname ) ,
toqstr ( translateIfPossible ( from_utf8 ( tc . category ( ) ) ) ) ,
tooltip ,
true , true , true , available ) ;
2007-04-24 19:37:34 +00:00
}
2010-04-02 22:11:50 +00:00
2007-04-24 19:37:34 +00:00
// branches
2007-08-31 05:53:55 +00:00
branchesModule = new GuiBranches ;
2007-04-25 10:25:37 +00:00
connect ( branchesModule , SIGNAL ( changed ( ) ) ,
this , SLOT ( change_adaptor ( ) ) ) ;
2009-07-10 06:49:51 +00:00
connect ( branchesModule , SIGNAL ( renameBranches ( docstring const & , docstring const & ) ) ,
this , SLOT ( branchesRename ( docstring const & , docstring const & ) ) ) ;
2012-03-03 14:39:32 +00:00
connect ( branchesModule , SIGNAL ( okPressed ( ) ) , this , SLOT ( slotOK ( ) ) ) ;
2009-07-09 09:48:34 +00:00
updateUnknownBranches ( ) ;
2007-04-24 19:37:34 +00:00
2010-04-02 22:11:50 +00:00
2007-04-24 19:37:34 +00:00
// preamble
2007-05-14 12:09:14 +00:00
preambleModule = new PreambleModule ;
connect ( preambleModule , SIGNAL ( changed ( ) ) ,
2007-04-24 19:37:34 +00:00
this , SLOT ( change_adaptor ( ) ) ) ;
2011-12-03 22:15:11 +00:00
A UI for document-local layout information. LyX has supported this for a
while, but without any UI for it. (There has been local layout in the
Customization manual for a long time, in fact.)
Yes, this is an advanced feature. But, absent a layout editor, it is the
one thing that will make it easier, and possible, for "normal users" to
experiment with layout without having to go through reconfiguration,
etc, etc. To keep too many people from shooting themselves, we validate
the layout information before allowing the user to apply it.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@35061 a592a061-630c-0410-9148-cb99ea01b6c8
2010-08-05 22:47:42 +00:00
localLayout = new LocalLayout ;
connect ( localLayout , SIGNAL ( changed ( ) ) ,
this , SLOT ( change_adaptor ( ) ) ) ;
2007-04-24 19:37:34 +00:00
2010-04-02 22:11:50 +00:00
2007-04-24 19:37:34 +00:00
// bullets
bulletsModule = new BulletsModule ;
2007-04-25 10:25:37 +00:00
connect ( bulletsModule , SIGNAL ( changed ( ) ) ,
this , SLOT ( change_adaptor ( ) ) ) ;
2007-04-24 19:37:34 +00:00
2010-04-02 22:11:50 +00:00
2008-10-19 01:21:59 +00:00
// Modules
modulesModule = new UiWidget < Ui : : ModulesUi > ;
2009-08-17 18:43:25 +00:00
modulesModule - > availableLV - > header ( ) - > setVisible ( false ) ;
2013-02-03 11:23:31 +00:00
setSectionResizeMode ( modulesModule - > availableLV - > header ( ) , QHeaderView : : ResizeToContents ) ;
2011-02-15 09:37:19 +00:00
modulesModule - > availableLV - > header ( ) - > setStretchLastSection ( false ) ;
2008-10-19 01:21:59 +00:00
selectionManager =
new ModuleSelectionManager ( modulesModule - > availableLV ,
modulesModule - > selectedLV ,
modulesModule - > addPB , modulesModule - > deletePB ,
modulesModule - > upPB , modulesModule - > downPB ,
2008-10-20 19:53:15 +00:00
availableModel ( ) , selectedModel ( ) , this ) ;
2008-10-19 01:21:59 +00:00
connect ( selectionManager , SIGNAL ( updateHook ( ) ) ,
this , SLOT ( updateModuleInfo ( ) ) ) ;
connect ( selectionManager , SIGNAL ( updateHook ( ) ) ,
this , SLOT ( change_adaptor ( ) ) ) ;
2008-10-20 19:31:05 +00:00
connect ( selectionManager , SIGNAL ( selectionChanged ( ) ) ,
this , SLOT ( modulesChanged ( ) ) ) ;
2008-10-19 01:21:59 +00:00
2010-04-02 22:11:50 +00:00
2007-09-20 22:31:18 +00:00
// PDF support
pdfSupportModule = new UiWidget < Ui : : PDFSupportUi > ;
2007-09-22 22:20:15 +00:00
connect ( pdfSupportModule - > use_hyperrefGB , SIGNAL ( toggled ( bool ) ) ,
2008-06-09 15:20:38 +00:00
this , SLOT ( change_adaptor ( ) ) ) ;
2008-09-20 12:57:12 +00:00
connect ( pdfSupportModule - > titleLE , SIGNAL ( textChanged ( QString ) ) ,
2007-09-20 22:31:18 +00:00
this , SLOT ( change_adaptor ( ) ) ) ;
2008-09-20 12:57:12 +00:00
connect ( pdfSupportModule - > authorLE , SIGNAL ( textChanged ( QString ) ) ,
2007-09-20 22:31:18 +00:00
this , SLOT ( change_adaptor ( ) ) ) ;
2008-09-20 12:57:12 +00:00
connect ( pdfSupportModule - > subjectLE , SIGNAL ( textChanged ( QString ) ) ,
2007-09-20 22:31:18 +00:00
this , SLOT ( change_adaptor ( ) ) ) ;
2008-09-20 12:57:12 +00:00
connect ( pdfSupportModule - > keywordsLE , SIGNAL ( textChanged ( QString ) ) ,
2007-09-20 22:31:18 +00:00
this , SLOT ( change_adaptor ( ) ) ) ;
connect ( pdfSupportModule - > bookmarksGB , SIGNAL ( toggled ( bool ) ) ,
this , SLOT ( change_adaptor ( ) ) ) ;
connect ( pdfSupportModule - > bookmarksnumberedCB , SIGNAL ( toggled ( bool ) ) ,
this , SLOT ( change_adaptor ( ) ) ) ;
connect ( pdfSupportModule - > bookmarksopenGB , SIGNAL ( toggled ( bool ) ) ,
this , SLOT ( change_adaptor ( ) ) ) ;
2007-09-22 22:20:15 +00:00
connect ( pdfSupportModule - > bookmarksopenlevelSB , SIGNAL ( valueChanged ( int ) ) ,
2007-09-20 22:31:18 +00:00
this , SLOT ( change_adaptor ( ) ) ) ;
connect ( pdfSupportModule - > breaklinksCB , SIGNAL ( toggled ( bool ) ) ,
this , SLOT ( change_adaptor ( ) ) ) ;
connect ( pdfSupportModule - > pdfborderCB , SIGNAL ( toggled ( bool ) ) ,
this , SLOT ( change_adaptor ( ) ) ) ;
connect ( pdfSupportModule - > colorlinksCB , SIGNAL ( toggled ( bool ) ) ,
this , SLOT ( change_adaptor ( ) ) ) ;
2008-10-13 16:01:02 +00:00
connect ( pdfSupportModule - > backrefCO , SIGNAL ( activated ( int ) ) ,
2007-09-20 22:31:18 +00:00
this , SLOT ( change_adaptor ( ) ) ) ;
2007-10-10 00:34:23 +00:00
connect ( pdfSupportModule - > pdfusetitleCB , SIGNAL ( toggled ( bool ) ) ,
this , SLOT ( change_adaptor ( ) ) ) ;
2007-09-20 22:31:18 +00:00
connect ( pdfSupportModule - > fullscreenCB , SIGNAL ( toggled ( bool ) ) ,
this , SLOT ( change_adaptor ( ) ) ) ;
2008-09-20 12:57:12 +00:00
connect ( pdfSupportModule - > optionsLE , SIGNAL ( textChanged ( QString ) ) ,
2007-09-20 22:31:18 +00:00
this , SLOT ( change_adaptor ( ) ) ) ;
2007-04-24 19:37:34 +00:00
2011-09-24 16:39:23 +00:00
pdfSupportModule - > titleLE - > setValidator ( new NoNewLineValidator (
pdfSupportModule - > titleLE ) ) ;
pdfSupportModule - > authorLE - > setValidator ( new NoNewLineValidator (
pdfSupportModule - > authorLE ) ) ;
pdfSupportModule - > subjectLE - > setValidator ( new NoNewLineValidator (
pdfSupportModule - > subjectLE ) ) ;
pdfSupportModule - > keywordsLE - > setValidator ( new NoNewLineValidator (
pdfSupportModule - > keywordsLE ) ) ;
pdfSupportModule - > optionsLE - > setValidator ( new NoNewLineValidator (
pdfSupportModule - > optionsLE ) ) ;
2008-10-13 16:01:02 +00:00
for ( int i = 0 ; backref_opts [ i ] [ 0 ] ; + + i )
pdfSupportModule - > backrefCO - > addItem ( qt_ ( backref_opts_gui [ i ] ) ) ;
2010-04-02 22:11:50 +00:00
2007-04-24 19:37:34 +00:00
// float
floatModule = new FloatPlacement ;
2007-04-25 10:25:37 +00:00
connect ( floatModule , SIGNAL ( changed ( ) ) ,
this , SLOT ( change_adaptor ( ) ) ) ;
2007-04-24 19:37:34 +00:00
2010-04-02 22:11:50 +00:00
2009-07-20 08:09:32 +00:00
// listings
listingsModule = new UiWidget < Ui : : ListingsSettingsUi > ;
connect ( listingsModule - > listingsED , SIGNAL ( textChanged ( ) ) ,
this , SLOT ( change_adaptor ( ) ) ) ;
2011-12-03 22:15:11 +00:00
connect ( listingsModule - > bypassCB , SIGNAL ( clicked ( ) ) ,
2009-07-20 08:09:32 +00:00
this , SLOT ( change_adaptor ( ) ) ) ;
2011-12-03 22:15:11 +00:00
connect ( listingsModule - > bypassCB , SIGNAL ( clicked ( ) ) ,
2009-07-20 08:09:32 +00:00
this , SLOT ( setListingsMessage ( ) ) ) ;
connect ( listingsModule - > listingsED , SIGNAL ( textChanged ( ) ) ,
this , SLOT ( setListingsMessage ( ) ) ) ;
listingsModule - > listingsTB - > setPlainText (
qt_ ( " Input listings parameters below. Enter ? for a list of parameters. " ) ) ;
2010-04-02 22:11:50 +00:00
// add the panels
2008-03-05 20:48:19 +00:00
docPS - > addPanel ( latexModule , qt_ ( " Document Class " ) ) ;
2010-01-07 10:01:26 +00:00
docPS - > addPanel ( masterChildModule , qt_ ( " Child Documents " ) ) ;
2008-10-19 01:21:59 +00:00
docPS - > addPanel ( modulesModule , qt_ ( " Modules " ) ) ;
2010-09-17 01:46:45 +00:00
docPS - > addPanel ( localLayout , qt_ ( " Local Layout " ) ) ;
2008-03-05 20:48:19 +00:00
docPS - > addPanel ( fontModule , qt_ ( " Fonts " ) ) ;
docPS - > addPanel ( textLayoutModule , qt_ ( " Text Layout " ) ) ;
docPS - > addPanel ( pageLayoutModule , qt_ ( " Page Layout " ) ) ;
docPS - > addPanel ( marginsModule , qt_ ( " Page Margins " ) ) ;
docPS - > addPanel ( langModule , qt_ ( " Language " ) ) ;
2010-04-02 22:11:50 +00:00
docPS - > addPanel ( colorModule , qt_ ( " Colors " ) ) ;
2008-03-05 20:48:19 +00:00
docPS - > addPanel ( numberingModule , qt_ ( " Numbering & TOC " ) ) ;
docPS - > addPanel ( biblioModule , qt_ ( " Bibliography " ) ) ;
2009-05-02 15:54:45 +00:00
docPS - > addPanel ( indicesModule , qt_ ( " Indexes " ) ) ;
2008-03-05 20:48:19 +00:00
docPS - > addPanel ( pdfSupportModule , qt_ ( " PDF Properties " ) ) ;
docPS - > addPanel ( mathsModule , qt_ ( " Math Options " ) ) ;
docPS - > addPanel ( floatModule , qt_ ( " Float Placement " ) ) ;
2012-04-10 18:21:01 +00:00
docPS - > addPanel ( listingsModule , qt_ ( " Listings[[inset]] " ) ) ;
2008-03-05 20:48:19 +00:00
docPS - > addPanel ( bulletsModule , qt_ ( " Bullets " ) ) ;
docPS - > addPanel ( branchesModule , qt_ ( " Branches " ) ) ;
2009-04-10 11:06:53 +00:00
docPS - > addPanel ( outputModule , qt_ ( " Output " ) ) ;
2008-03-05 20:48:19 +00:00
docPS - > addPanel ( preambleModule , qt_ ( " LaTeX Preamble " ) ) ;
docPS - > setCurrentPanel ( qt_ ( " Document Class " ) ) ;
2007-04-24 19:37:34 +00:00
// FIXME: hack to work around resizing bug in Qt >= 4.2
// bug verified with Qt 4.2.{0-3} (JSpitzm)
# if QT_VERSION >= 0x040200
docPS - > updateGeometry ( ) ;
# endif
}
2007-10-06 22:43:21 +00:00
void GuiDocument : : saveDefaultClicked ( )
2007-04-24 19:37:34 +00:00
{
2007-09-05 20:33:29 +00:00
saveDocDefault ( ) ;
2007-04-24 19:37:34 +00:00
}
2007-10-06 22:43:21 +00:00
void GuiDocument : : useDefaultsClicked ( )
2007-04-24 19:37:34 +00:00
{
2007-09-05 20:33:29 +00:00
useClassDefaults ( ) ;
2007-04-24 19:37:34 +00:00
}
2007-10-06 22:43:21 +00:00
void GuiDocument : : change_adaptor ( )
2007-04-24 19:37:34 +00:00
{
2007-09-05 20:33:29 +00:00
changed ( ) ;
2007-04-24 19:37:34 +00:00
}
2010-01-07 10:01:26 +00:00
void GuiDocument : : includeonlyClicked ( QTreeWidgetItem * item , int )
{
if ( item = = 0 )
return ;
string child = fromqstr ( item - > text ( 0 ) ) ;
if ( child . empty ( ) )
return ;
if ( std : : find ( includeonlys_ . begin ( ) ,
includeonlys_ . end ( ) , child ) ! = includeonlys_ . end ( ) )
includeonlys_ . remove ( child ) ;
else
includeonlys_ . push_back ( child ) ;
2011-12-03 22:15:11 +00:00
2010-01-07 10:01:26 +00:00
updateIncludeonlys ( ) ;
changed ( ) ;
}
2008-09-20 12:07:18 +00:00
QString GuiDocument : : validateListingsParameters ( )
2007-07-27 18:17:00 +00:00
{
// use a cache here to avoid repeated validation
// of the same parameters
2008-09-20 12:07:18 +00:00
static string param_cache ;
static QString msg_cache ;
2011-12-03 22:15:11 +00:00
2009-07-20 08:09:32 +00:00
if ( listingsModule - > bypassCB - > isChecked ( ) )
2008-09-20 12:07:18 +00:00
return QString ( ) ;
2007-07-27 18:17:00 +00:00
2009-07-20 08:09:32 +00:00
string params = fromqstr ( listingsModule - > listingsED - > toPlainText ( ) ) ;
2007-07-27 18:17:00 +00:00
if ( params ! = param_cache ) {
param_cache = params ;
2008-09-20 12:07:18 +00:00
msg_cache = toqstr ( InsetListingsParams ( params ) . validate ( ) ) ;
2007-07-27 18:17:00 +00:00
}
return msg_cache ;
}
2008-09-20 12:07:18 +00:00
void GuiDocument : : setListingsMessage ( )
Add support for listings package. Two listings command \lstinline, \lstinputlisting and an environment \lstlisting are supported, along with preamble \lstset. \lstinputlisting is implemented through Include dialog, and the other two are implemented with a new inset listings, along with its dialog.
* src/LyXAction.cpp: listing-insert action
* src/insets/Inset.h,cpp: LISTINGS_CODE
* src/insets/InsetInclude.cpp: handle \lstinputlisting
* src/insets/InsetListings.h,cpp: new listings inset
* src/insets/InsetListingsParams.h,cpp: parameters from listings package
* src/insets/InsetCommandParams.h,cpp: handle lstinputlisting option
* src/Bidi.cpp: handle LISTINGS_CODE
* src/frontends/qt4/ui/TextLayoutUi.ui: update UI
* src/frontends/qt4/ui/ListingsUi.ui: new dialog
* src/frontends/qt4/ui/IncludeUi.ui: update UI
* src/frontends/qt4/QInclude.h,cpp: add lstinputlisting
* src/frontends/qt4/QDocument.h,cpp: add textedit for preamble listings_params
* src/frontends/qt4/QListings.h,cpp: new listings inset
* src/frontends/qt4/Dialogs.cpp: new listings dialog
* src/frontends/controllers/ControlInclude.h,cpp: add lstinputlisting
* src/frontends/controllers/ControlListings.h,cpp: new listings inset
* src/LyXFunc.cpp: handle LISTING_CODE
* src/Paragraph.cpp: handle LISTING_CODE
* src/factory.cpp: new listings inset
* src/CutAndPaste.cpp: handle LISTINGS_CODE
* src/LaTeXFeatures.cpp: require listings
* src/Text3.cpp: Handle LISTINGS_CODE
* src/lfuns.h: add LFUN_LISTING_INSERT
* src/Buffer.cpp: change lyx file format to 269
* src/BufferParams.h,cpp: add listings_params to preamble
* lib/lyx2lyx/LyX.py: lyx2lyx
* lib/lyx2lyx/lyx_1_5.py: lyx2lyx
* lib/ui/stdmenus.inc: new menu item (no shortcut!)
* src/insets/Makefile.am: update autotools
* src/frontends/controllers/Makefile.am
* src/frontends/qt4/Makefile.dialogs
* src/frontends/qt4/Makefile.am
* po/POTFILES.in: a few more translatable files.
* development/scons/scons_manifest.py: scons build system
* development/FORMAT: document format changes
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@18243 a592a061-630c-0410-9148-cb99ea01b6c8
2007-05-09 19:11:42 +00:00
{
static bool isOK = true ;
2008-09-20 12:07:18 +00:00
QString msg = validateListingsParameters ( ) ;
if ( msg . isEmpty ( ) ) {
2007-06-12 17:10:28 +00:00
if ( isOK )
return ;
isOK = true ;
// listingsTB->setTextColor("black");
2009-07-20 08:09:32 +00:00
listingsModule - > listingsTB - > setPlainText (
qt_ ( " Input listings parameters below. "
2008-09-20 12:07:18 +00:00
" Enter ? for a list of parameters. " ) ) ;
2007-06-12 17:10:28 +00:00
} else {
Add support for listings package. Two listings command \lstinline, \lstinputlisting and an environment \lstlisting are supported, along with preamble \lstset. \lstinputlisting is implemented through Include dialog, and the other two are implemented with a new inset listings, along with its dialog.
* src/LyXAction.cpp: listing-insert action
* src/insets/Inset.h,cpp: LISTINGS_CODE
* src/insets/InsetInclude.cpp: handle \lstinputlisting
* src/insets/InsetListings.h,cpp: new listings inset
* src/insets/InsetListingsParams.h,cpp: parameters from listings package
* src/insets/InsetCommandParams.h,cpp: handle lstinputlisting option
* src/Bidi.cpp: handle LISTINGS_CODE
* src/frontends/qt4/ui/TextLayoutUi.ui: update UI
* src/frontends/qt4/ui/ListingsUi.ui: new dialog
* src/frontends/qt4/ui/IncludeUi.ui: update UI
* src/frontends/qt4/QInclude.h,cpp: add lstinputlisting
* src/frontends/qt4/QDocument.h,cpp: add textedit for preamble listings_params
* src/frontends/qt4/QListings.h,cpp: new listings inset
* src/frontends/qt4/Dialogs.cpp: new listings dialog
* src/frontends/controllers/ControlInclude.h,cpp: add lstinputlisting
* src/frontends/controllers/ControlListings.h,cpp: new listings inset
* src/LyXFunc.cpp: handle LISTING_CODE
* src/Paragraph.cpp: handle LISTING_CODE
* src/factory.cpp: new listings inset
* src/CutAndPaste.cpp: handle LISTINGS_CODE
* src/LaTeXFeatures.cpp: require listings
* src/Text3.cpp: Handle LISTINGS_CODE
* src/lfuns.h: add LFUN_LISTING_INSERT
* src/Buffer.cpp: change lyx file format to 269
* src/BufferParams.h,cpp: add listings_params to preamble
* lib/lyx2lyx/LyX.py: lyx2lyx
* lib/lyx2lyx/lyx_1_5.py: lyx2lyx
* lib/ui/stdmenus.inc: new menu item (no shortcut!)
* src/insets/Makefile.am: update autotools
* src/frontends/controllers/Makefile.am
* src/frontends/qt4/Makefile.dialogs
* src/frontends/qt4/Makefile.am
* po/POTFILES.in: a few more translatable files.
* development/scons/scons_manifest.py: scons build system
* development/FORMAT: document format changes
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@18243 a592a061-630c-0410-9148-cb99ea01b6c8
2007-05-09 19:11:42 +00:00
isOK = false ;
// listingsTB->setTextColor("red");
2009-07-20 08:09:32 +00:00
listingsModule - > listingsTB - > setPlainText ( msg ) ;
Add support for listings package. Two listings command \lstinline, \lstinputlisting and an environment \lstlisting are supported, along with preamble \lstset. \lstinputlisting is implemented through Include dialog, and the other two are implemented with a new inset listings, along with its dialog.
* src/LyXAction.cpp: listing-insert action
* src/insets/Inset.h,cpp: LISTINGS_CODE
* src/insets/InsetInclude.cpp: handle \lstinputlisting
* src/insets/InsetListings.h,cpp: new listings inset
* src/insets/InsetListingsParams.h,cpp: parameters from listings package
* src/insets/InsetCommandParams.h,cpp: handle lstinputlisting option
* src/Bidi.cpp: handle LISTINGS_CODE
* src/frontends/qt4/ui/TextLayoutUi.ui: update UI
* src/frontends/qt4/ui/ListingsUi.ui: new dialog
* src/frontends/qt4/ui/IncludeUi.ui: update UI
* src/frontends/qt4/QInclude.h,cpp: add lstinputlisting
* src/frontends/qt4/QDocument.h,cpp: add textedit for preamble listings_params
* src/frontends/qt4/QListings.h,cpp: new listings inset
* src/frontends/qt4/Dialogs.cpp: new listings dialog
* src/frontends/controllers/ControlInclude.h,cpp: add lstinputlisting
* src/frontends/controllers/ControlListings.h,cpp: new listings inset
* src/LyXFunc.cpp: handle LISTING_CODE
* src/Paragraph.cpp: handle LISTING_CODE
* src/factory.cpp: new listings inset
* src/CutAndPaste.cpp: handle LISTINGS_CODE
* src/LaTeXFeatures.cpp: require listings
* src/Text3.cpp: Handle LISTINGS_CODE
* src/lfuns.h: add LFUN_LISTING_INSERT
* src/Buffer.cpp: change lyx file format to 269
* src/BufferParams.h,cpp: add listings_params to preamble
* lib/lyx2lyx/LyX.py: lyx2lyx
* lib/lyx2lyx/lyx_1_5.py: lyx2lyx
* lib/ui/stdmenus.inc: new menu item (no shortcut!)
* src/insets/Makefile.am: update autotools
* src/frontends/controllers/Makefile.am
* src/frontends/qt4/Makefile.dialogs
* src/frontends/qt4/Makefile.am
* po/POTFILES.in: a few more translatable files.
* development/scons/scons_manifest.py: scons build system
* development/FORMAT: document format changes
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@18243 a592a061-630c-0410-9148-cb99ea01b6c8
2007-05-09 19:11:42 +00:00
}
}
2007-10-06 22:43:21 +00:00
void GuiDocument : : setLSpacing ( int item )
2007-04-24 19:37:34 +00:00
{
textLayoutModule - > lspacingLE - > setEnabled ( item = = 3 ) ;
}
2009-07-19 21:13:27 +00:00
void GuiDocument : : setIndent ( int item )
{
bool const enable = ( item = = 1 ) ;
textLayoutModule - > indentLE - > setEnabled ( enable ) ;
textLayoutModule - > indentLengthCO - > setEnabled ( enable ) ;
textLayoutModule - > skipLE - > setEnabled ( false ) ;
textLayoutModule - > skipLengthCO - > setEnabled ( false ) ;
isValid ( ) ;
}
void GuiDocument : : enableIndent ( bool indent )
{
textLayoutModule - > skipLE - > setEnabled ( ! indent ) ;
textLayoutModule - > skipLengthCO - > setEnabled ( ! indent ) ;
if ( indent )
setIndent ( textLayoutModule - > indentCO - > currentIndex ( ) ) ;
}
2007-10-06 22:43:21 +00:00
void GuiDocument : : setSkip ( int item )
2007-04-24 19:37:34 +00:00
{
bool const enable = ( item = = 3 ) ;
textLayoutModule - > skipLE - > setEnabled ( enable ) ;
textLayoutModule - > skipLengthCO - > setEnabled ( enable ) ;
2009-07-19 21:13:27 +00:00
isValid ( ) ;
2007-04-24 19:37:34 +00:00
}
2007-10-06 22:43:21 +00:00
void GuiDocument : : enableSkip ( bool skip )
2007-04-24 19:37:34 +00:00
{
2009-07-19 21:13:27 +00:00
textLayoutModule - > indentLE - > setEnabled ( ! skip ) ;
textLayoutModule - > indentLengthCO - > setEnabled ( ! skip ) ;
2007-04-24 19:37:34 +00:00
if ( skip )
setSkip ( textLayoutModule - > skipCO - > currentIndex ( ) ) ;
}
2009-04-06 06:58:30 +00:00
2010-05-18 02:56:36 +00:00
void GuiDocument : : setMargins ( )
2007-04-24 19:37:34 +00:00
{
2009-03-28 10:48:16 +00:00
bool const extern_geometry =
documentClass ( ) . provides ( " geometry " ) ;
marginsModule - > marginCB - > setEnabled ( ! extern_geometry ) ;
if ( extern_geometry ) {
marginsModule - > marginCB - > setChecked ( false ) ;
setCustomMargins ( true ) ;
2010-05-18 21:08:06 +00:00
} else {
marginsModule - > marginCB - > setChecked ( ! bp_ . use_geometry ) ;
setCustomMargins ( ! bp_ . use_geometry ) ;
2009-03-28 10:48:16 +00:00
}
2007-04-24 19:37:34 +00:00
}
2009-07-16 08:39:22 +00:00
void GuiDocument : : papersizeChanged ( int paper_size )
2007-04-24 19:37:34 +00:00
{
2009-07-16 08:39:22 +00:00
setCustomPapersize ( paper_size = = 1 ) ;
}
2007-04-24 19:37:34 +00:00
2009-07-16 08:39:22 +00:00
void GuiDocument : : setCustomPapersize ( bool custom )
{
2007-04-24 19:37:34 +00:00
pageLayoutModule - > paperwidthL - > setEnabled ( custom ) ;
pageLayoutModule - > paperwidthLE - > setEnabled ( custom ) ;
pageLayoutModule - > paperwidthUnitCO - > setEnabled ( custom ) ;
pageLayoutModule - > paperheightL - > setEnabled ( custom ) ;
pageLayoutModule - > paperheightLE - > setEnabled ( custom ) ;
pageLayoutModule - > paperheightLE - > setFocus ( ) ;
pageLayoutModule - > paperheightUnitCO - > setEnabled ( custom ) ;
}
2008-02-19 05:39:36 +00:00
void GuiDocument : : setColSep ( )
{
setCustomMargins ( marginsModule - > marginCB - > checkState ( ) = = Qt : : Checked ) ;
}
2007-10-06 22:43:21 +00:00
void GuiDocument : : setCustomMargins ( bool custom )
2007-04-24 19:37:34 +00:00
{
marginsModule - > topL - > setEnabled ( ! custom ) ;
marginsModule - > topLE - > setEnabled ( ! custom ) ;
marginsModule - > topUnit - > setEnabled ( ! custom ) ;
marginsModule - > bottomL - > setEnabled ( ! custom ) ;
marginsModule - > bottomLE - > setEnabled ( ! custom ) ;
marginsModule - > bottomUnit - > setEnabled ( ! custom ) ;
marginsModule - > innerL - > setEnabled ( ! custom ) ;
marginsModule - > innerLE - > setEnabled ( ! custom ) ;
marginsModule - > innerUnit - > setEnabled ( ! custom ) ;
marginsModule - > outerL - > setEnabled ( ! custom ) ;
marginsModule - > outerLE - > setEnabled ( ! custom ) ;
marginsModule - > outerUnit - > setEnabled ( ! custom ) ;
marginsModule - > headheightL - > setEnabled ( ! custom ) ;
marginsModule - > headheightLE - > setEnabled ( ! custom ) ;
marginsModule - > headheightUnit - > setEnabled ( ! custom ) ;
marginsModule - > headsepL - > setEnabled ( ! custom ) ;
marginsModule - > headsepLE - > setEnabled ( ! custom ) ;
marginsModule - > headsepUnit - > setEnabled ( ! custom ) ;
marginsModule - > footskipL - > setEnabled ( ! custom ) ;
marginsModule - > footskipLE - > setEnabled ( ! custom ) ;
marginsModule - > footskipUnit - > setEnabled ( ! custom ) ;
2008-02-19 05:24:48 +00:00
2011-12-03 22:15:11 +00:00
bool const enableColSep = ! custom & &
2008-02-19 05:39:36 +00:00
textLayoutModule - > twoColumnCB - > checkState ( ) = = Qt : : Checked ;
marginsModule - > columnsepL - > setEnabled ( enableColSep ) ;
marginsModule - > columnsepLE - > setEnabled ( enableColSep ) ;
marginsModule - > columnsepUnit - > setEnabled ( enableColSep ) ;
2007-04-24 19:37:34 +00:00
}
2010-04-02 22:11:50 +00:00
2009-04-11 21:40:11 +00:00
void GuiDocument : : changeBackgroundColor ( )
{
2009-04-12 09:13:46 +00:00
QColor const & newColor = QColorDialog : : getColor (
2009-04-12 12:33:35 +00:00
rgb2qcolor ( set_backgroundcolor ) , asQWidget ( ) ) ;
2009-04-11 21:40:11 +00:00
if ( ! newColor . isValid ( ) )
return ;
2010-04-05 20:31:10 +00:00
// set the button color and text
2010-04-02 22:11:50 +00:00
colorModule - > backgroundPB - > setStyleSheet (
2009-04-11 21:40:11 +00:00
colorButtonStyleSheet ( newColor ) ) ;
2011-03-18 14:11:36 +00:00
colorModule - > backgroundPB - > setText ( qt_ ( " &Change... " ) ) ;
2009-04-12 09:13:46 +00:00
// save color
2009-04-11 21:40:11 +00:00
set_backgroundcolor = rgbFromHexName ( fromqstr ( newColor . name ( ) ) ) ;
2010-04-05 20:31:10 +00:00
is_backgroundcolor = true ;
2009-04-11 21:40:11 +00:00
changed ( ) ;
}
void GuiDocument : : deleteBackgroundColor ( )
{
2011-03-18 14:40:38 +00:00
// set the button color back to default by setting an empty StyleSheet
2010-04-05 20:31:10 +00:00
colorModule - > backgroundPB - > setStyleSheet ( QLatin1String ( " " ) ) ;
// change button text
2011-03-18 14:11:36 +00:00
colorModule - > backgroundPB - > setText ( qt_ ( " &Default... " ) ) ;
2010-04-05 20:31:10 +00:00
// save default color (white)
2009-04-11 21:40:11 +00:00
set_backgroundcolor = rgbFromHexName ( " #ffffff " ) ;
2010-04-05 20:31:10 +00:00
is_backgroundcolor = false ;
2009-04-11 21:40:11 +00:00
changed ( ) ;
}
2007-04-24 19:37:34 +00:00
2010-04-02 23:39:36 +00:00
void GuiDocument : : changeFontColor ( )
{
QColor const & newColor = QColorDialog : : getColor (
rgb2qcolor ( set_fontcolor ) , asQWidget ( ) ) ;
if ( ! newColor . isValid ( ) )
return ;
// set the button color and text
colorModule - > fontColorPB - > setStyleSheet (
colorButtonStyleSheet ( newColor ) ) ;
2011-03-18 14:11:36 +00:00
colorModule - > fontColorPB - > setText ( qt_ ( " &Change... " ) ) ;
2010-04-02 23:39:36 +00:00
// save color
set_fontcolor = rgbFromHexName ( fromqstr ( newColor . name ( ) ) ) ;
is_fontcolor = true ;
changed ( ) ;
}
void GuiDocument : : deleteFontColor ( )
{
2011-03-18 14:40:38 +00:00
// set the button color back to default by setting an empty StyleSheet
2010-04-02 23:39:36 +00:00
colorModule - > fontColorPB - > setStyleSheet ( QLatin1String ( " " ) ) ;
// change button text
2011-03-18 14:11:36 +00:00
colorModule - > fontColorPB - > setText ( qt_ ( " &Default... " ) ) ;
2010-04-02 23:39:36 +00:00
// save default color (black)
set_fontcolor = rgbFromHexName ( " #000000 " ) ;
is_fontcolor = false ;
changed ( ) ;
}
2010-03-31 00:46:50 +00:00
void GuiDocument : : changeNoteFontColor ( )
{
QColor const & newColor = QColorDialog : : getColor (
rgb2qcolor ( set_notefontcolor ) , asQWidget ( ) ) ;
if ( ! newColor . isValid ( ) )
return ;
// set the button color
2010-04-02 22:11:50 +00:00
colorModule - > noteFontColorPB - > setStyleSheet (
2010-03-31 00:46:50 +00:00
colorButtonStyleSheet ( newColor ) ) ;
// save color
set_notefontcolor = rgbFromHexName ( fromqstr ( newColor . name ( ) ) ) ;
changed ( ) ;
}
void GuiDocument : : deleteNoteFontColor ( )
{
2011-03-18 14:40:38 +00:00
// set the button color back to pref
2011-03-19 10:34:59 +00:00
theApp ( ) - > getRgbColor ( Color_greyedouttext , set_notefontcolor ) ;
2010-04-02 22:11:50 +00:00
colorModule - > noteFontColorPB - > setStyleSheet (
2011-03-18 14:40:38 +00:00
colorButtonStyleSheet ( rgb2qcolor ( set_notefontcolor ) ) ) ;
2010-03-31 00:46:50 +00:00
changed ( ) ;
}
2010-04-08 00:14:08 +00:00
void GuiDocument : : changeBoxBackgroundColor ( )
{
QColor const & newColor = QColorDialog : : getColor (
rgb2qcolor ( set_boxbgcolor ) , asQWidget ( ) ) ;
if ( ! newColor . isValid ( ) )
return ;
// set the button color
colorModule - > boxBackgroundPB - > setStyleSheet (
colorButtonStyleSheet ( newColor ) ) ;
// save color
set_boxbgcolor = rgbFromHexName ( fromqstr ( newColor . name ( ) ) ) ;
changed ( ) ;
}
void GuiDocument : : deleteBoxBackgroundColor ( )
{
2011-03-18 14:40:38 +00:00
// set the button color back to pref
theApp ( ) - > getRgbColor ( Color_shadedbg , set_boxbgcolor ) ;
2010-04-08 00:14:08 +00:00
colorModule - > boxBackgroundPB - > setStyleSheet (
2011-03-18 14:40:38 +00:00
colorButtonStyleSheet ( rgb2qcolor ( set_boxbgcolor ) ) ) ;
2010-04-08 00:14:08 +00:00
changed ( ) ;
}
2012-06-08 03:39:00 +00:00
void GuiDocument : : languageChanged ( int i )
{
// some languages only work with polyglossia/XeTeX
2012-06-08 10:54:57 +00:00
Language const * lang = lyx : : languages . getLanguage (
fromqstr ( langModule - > languageCO - > itemData ( i ) . toString ( ) ) ) ;
if ( lang - > babel ( ) . empty ( ) & & ! lang - > polyglossia ( ) . empty ( ) ) {
2012-06-08 03:39:00 +00:00
fontModule - > osFontsCB - > setChecked ( true ) ;
fontModule - > osFontsCB - > setEnabled ( false ) ;
}
else
fontModule - > osFontsCB - > setEnabled ( true ) ;
2012-07-01 09:27:42 +00:00
// set appropriate quotation mark style
if ( ! lang - > quoteStyle ( ) . empty ( ) ) {
langModule - > quoteStyleCO - > setCurrentIndex (
bp_ . getQuoteStyle ( lang - > quoteStyle ( ) ) ) ;
}
2012-06-08 03:39:00 +00:00
}
2010-11-26 09:42:03 +00:00
void GuiDocument : : osFontsChanged ( bool nontexfonts )
2009-04-06 06:58:30 +00:00
{
2010-11-26 09:42:03 +00:00
bool const tex_fonts = ! nontexfonts ;
2009-04-06 06:58:30 +00:00
updateFontlist ( ) ;
2012-06-07 19:27:01 +00:00
// store default format
QString const dformat = outputModule - > defaultFormatCO - > itemData (
outputModule - > defaultFormatCO - > currentIndex ( ) ) . toString ( ) ;
2009-04-10 11:06:53 +00:00
updateDefaultFormat ( ) ;
2012-06-07 19:27:01 +00:00
// try to restore default format
int index = outputModule - > defaultFormatCO - > findData ( dformat ) ;
// set to default if format is not found
if ( index = = - 1 )
index = 0 ;
outputModule - > defaultFormatCO - > setCurrentIndex ( index ) ;
2010-11-26 09:42:03 +00:00
langModule - > encodingCO - > setEnabled ( tex_fonts & &
2009-04-06 06:58:30 +00:00
! langModule - > defaultencodingRB - > isChecked ( ) ) ;
2010-11-26 09:42:03 +00:00
langModule - > defaultencodingRB - > setEnabled ( tex_fonts ) ;
langModule - > otherencodingRB - > setEnabled ( tex_fonts ) ;
2009-04-10 14:39:22 +00:00
2010-11-26 09:42:03 +00:00
fontModule - > fontsDefaultCO - > setEnabled ( tex_fonts ) ;
fontModule - > fontsDefaultLA - > setEnabled ( tex_fonts ) ;
fontModule - > cjkFontLE - > setEnabled ( tex_fonts ) ;
fontModule - > cjkFontLA - > setEnabled ( tex_fonts ) ;
2012-08-16 11:23:39 +00:00
updateFontOptions ( ) ;
fontModule - > fontencLA - > setEnabled ( tex_fonts ) ;
fontModule - > fontencCO - > setEnabled ( tex_fonts ) ;
if ( ! tex_fonts )
fontModule - > fontencLE - > setEnabled ( false ) ;
else
fontencChanged ( fontModule - > fontencCO - > currentIndex ( ) ) ;
}
2012-09-22 15:44:00 +00:00
void GuiDocument : : mathFontChanged ( int )
{
updateFontOptions ( ) ;
}
2012-08-16 11:23:39 +00:00
void GuiDocument : : updateFontOptions ( )
{
bool const tex_fonts = ! fontModule - > osFontsCB - > isChecked ( ) ;
QString font ;
2010-11-26 09:42:03 +00:00
if ( tex_fonts )
2012-08-16 11:23:39 +00:00
font = fontModule - > fontsSansCO - > itemData (
fontModule - > fontsSansCO - > currentIndex ( ) ) . toString ( ) ;
2009-04-10 14:39:22 +00:00
bool scaleable = providesScale ( font ) ;
fontModule - > scaleSansSB - > setEnabled ( scaleable ) ;
fontModule - > scaleSansLA - > setEnabled ( scaleable ) ;
2010-11-26 09:42:03 +00:00
if ( tex_fonts )
2012-08-16 11:23:39 +00:00
font = fontModule - > fontsTypewriterCO - > itemData (
fontModule - > fontsTypewriterCO - > currentIndex ( ) ) . toString ( ) ;
2009-04-10 14:39:22 +00:00
scaleable = providesScale ( font ) ;
fontModule - > scaleTypewriterSB - > setEnabled ( scaleable ) ;
fontModule - > scaleTypewriterLA - > setEnabled ( scaleable ) ;
2010-11-26 09:42:03 +00:00
if ( tex_fonts )
2012-08-16 11:23:39 +00:00
font = fontModule - > fontsRomanCO - > itemData (
fontModule - > fontsRomanCO - > currentIndex ( ) ) . toString ( ) ;
2009-04-10 14:39:22 +00:00
fontModule - > fontScCB - > setEnabled ( providesSC ( font ) ) ;
fontModule - > fontOsfCB - > setEnabled ( providesOSF ( font ) ) ;
2012-09-22 15:44:00 +00:00
updateMathFonts ( font ) ;
2009-04-06 06:58:30 +00:00
}
2007-10-06 22:43:21 +00:00
void GuiDocument : : updateFontsize ( string const & items , string const & sel )
2007-04-24 19:37:34 +00:00
{
fontModule - > fontsizeCO - > clear ( ) ;
2007-06-01 17:44:04 +00:00
fontModule - > fontsizeCO - > addItem ( qt_ ( " Default " ) ) ;
2007-04-24 19:37:34 +00:00
for ( int n = 0 ; ! token ( items , ' | ' , n ) . empty ( ) ; + + n )
fontModule - > fontsizeCO - >
addItem ( toqstr ( token ( items , ' | ' , n ) ) ) ;
for ( int n = 0 ; n < fontModule - > fontsizeCO - > count ( ) ; + + n ) {
if ( fromqstr ( fontModule - > fontsizeCO - > itemText ( n ) ) = = sel ) {
fontModule - > fontsizeCO - > setCurrentIndex ( n ) ;
break ;
}
}
}
2012-08-16 11:23:39 +00:00
bool GuiDocument : : ot1 ( ) const
{
QString const fontenc =
fontModule - > fontencCO - > itemData ( fontModule - > fontencCO - > currentIndex ( ) ) . toString ( ) ;
return ( fontenc = = " default "
| | ( fontenc = = " global " & & ( lyxrc . fontenc = = " default " | | lyxrc . fontenc = = " OT1 " ) )
| | ( fontenc = = " custom " & & fontModule - > fontencLE - > text ( ) = = " OT1 " ) ) ;
}
2012-09-22 08:59:53 +00:00
bool GuiDocument : : completeFontset ( ) const
{
return ( fontModule - > fontsSansCO - > itemData (
fontModule - > fontsSansCO - > currentIndex ( ) ) . toString ( ) = = " default "
& & fontModule - > fontsSansCO - > itemData (
fontModule - > fontsSansCO - > currentIndex ( ) ) . toString ( ) = = " default " ) ;
}
2012-09-22 15:44:00 +00:00
bool GuiDocument : : noMathFont ( ) const
{
return ( fontModule - > fontsMathCO - > itemData (
fontModule - > fontsMathCO - > currentIndex ( ) ) . toString ( ) = = " default " ) ;
}
2012-08-16 11:23:39 +00:00
void GuiDocument : : updateTexFonts ( )
{
LaTeXFonts : : TexFontMap texfontmap = theLaTeXFonts ( ) . getLaTeXFonts ( ) ;
LaTeXFonts : : TexFontMap : : const_iterator it = texfontmap . begin ( ) ;
LaTeXFonts : : TexFontMap : : const_iterator end = texfontmap . end ( ) ;
for ( ; it ! = end ; + + it ) {
LaTeXFont lf = it - > second ;
2012-08-25 08:48:37 +00:00
if ( lf . name ( ) . empty ( ) ) {
LYXERR0 ( " Error: Unnamed font: " < < it - > first ) ;
continue ;
}
2012-08-16 11:23:39 +00:00
docstring const family = lf . family ( ) ;
docstring guiname = translateIfPossible ( lf . guiname ( ) ) ;
2012-09-22 15:44:00 +00:00
if ( ! lf . available ( ot1 ( ) , noMathFont ( ) ) )
2012-08-16 11:23:39 +00:00
guiname + = _ ( " (not installed) " ) ;
if ( family = = " rm " )
rmfonts_ . insert ( toqstr ( guiname ) , toqstr ( it - > first ) ) ;
else if ( family = = " sf " )
sffonts_ . insert ( toqstr ( guiname ) , toqstr ( it - > first ) ) ;
else if ( family = = " tt " )
ttfonts_ . insert ( toqstr ( guiname ) , toqstr ( it - > first ) ) ;
2012-09-22 15:44:00 +00:00
else if ( family = = " math " )
mathfonts_ . insert ( toqstr ( guiname ) , toqstr ( it - > first ) ) ;
2012-08-16 11:23:39 +00:00
}
}
2009-04-06 06:58:30 +00:00
void GuiDocument : : updateFontlist ( )
{
fontModule - > fontsRomanCO - > clear ( ) ;
fontModule - > fontsSansCO - > clear ( ) ;
fontModule - > fontsTypewriterCO - > clear ( ) ;
2012-09-22 15:44:00 +00:00
fontModule - > fontsMathCO - > clear ( ) ;
2009-04-06 06:58:30 +00:00
// With XeTeX, we have access to all system fonts, but not the LaTeX fonts
2010-11-26 09:42:03 +00:00
if ( fontModule - > osFontsCB - > isChecked ( ) ) {
2011-04-08 20:37:17 +00:00
fontModule - > fontsRomanCO - > addItem ( qt_ ( " Default " ) , QString ( " default " ) ) ;
fontModule - > fontsSansCO - > addItem ( qt_ ( " Default " ) , QString ( " default " ) ) ;
fontModule - > fontsTypewriterCO - > addItem ( qt_ ( " Default " ) , QString ( " default " ) ) ;
2012-09-24 11:19:25 +00:00
QString unimath = qt_ ( " Non-TeX Fonts Default " ) ;
if ( ! LaTeXFeatures : : isAvailable ( " unicode-math " ) )
unimath + = qt_ ( " (not available) " ) ;
fontModule - > fontsMathCO - > addItem ( qt_ ( " Class Default (TeX Fonts) " ) , QString ( " auto " ) ) ;
fontModule - > fontsMathCO - > addItem ( unimath , QString ( " default " ) ) ;
2011-12-03 22:15:11 +00:00
2009-04-06 06:58:30 +00:00
QFontDatabase fontdb ;
QStringList families ( fontdb . families ( ) ) ;
for ( QStringList : : Iterator it = families . begin ( ) ; it ! = families . end ( ) ; + + it ) {
2011-04-08 20:37:17 +00:00
fontModule - > fontsRomanCO - > addItem ( * it , * it ) ;
fontModule - > fontsSansCO - > addItem ( * it , * it ) ;
fontModule - > fontsTypewriterCO - > addItem ( * it , * it ) ;
2009-04-06 06:58:30 +00:00
}
return ;
}
2012-08-16 11:23:39 +00:00
if ( rmfonts_ . empty ( ) )
updateTexFonts ( ) ;
fontModule - > fontsRomanCO - > addItem ( qt_ ( " Default " ) , QString ( " default " ) ) ;
QMap < QString , QString > : : const_iterator rmi = rmfonts_ . constBegin ( ) ;
while ( rmi ! = rmfonts_ . constEnd ( ) ) {
fontModule - > fontsRomanCO - > addItem ( rmi . key ( ) , rmi . value ( ) ) ;
+ + rmi ;
2009-04-06 06:58:30 +00:00
}
2012-08-16 11:23:39 +00:00
fontModule - > fontsSansCO - > addItem ( qt_ ( " Default " ) , QString ( " default " ) ) ;
QMap < QString , QString > : : const_iterator sfi = sffonts_ . constBegin ( ) ;
while ( sfi ! = sffonts_ . constEnd ( ) ) {
fontModule - > fontsSansCO - > addItem ( sfi . key ( ) , sfi . value ( ) ) ;
+ + sfi ;
2009-04-06 06:58:30 +00:00
}
2012-08-16 11:23:39 +00:00
fontModule - > fontsTypewriterCO - > addItem ( qt_ ( " Default " ) , QString ( " default " ) ) ;
QMap < QString , QString > : : const_iterator tti = ttfonts_ . constBegin ( ) ;
while ( tti ! = ttfonts_ . constEnd ( ) ) {
fontModule - > fontsTypewriterCO - > addItem ( tti . key ( ) , tti . value ( ) ) ;
+ + tti ;
2009-04-06 06:58:30 +00:00
}
2012-09-22 15:44:00 +00:00
fontModule - > fontsMathCO - > addItem ( qt_ ( " Automatic " ) , QString ( " auto " ) ) ;
fontModule - > fontsMathCO - > addItem ( qt_ ( " Class Default " ) , QString ( " default " ) ) ;
QMap < QString , QString > : : const_iterator mmi = mathfonts_ . constBegin ( ) ;
while ( mmi ! = mathfonts_ . constEnd ( ) ) {
fontModule - > fontsMathCO - > addItem ( mmi . key ( ) , mmi . value ( ) ) ;
+ + mmi ;
}
2009-04-06 06:58:30 +00:00
}
2009-11-29 14:43:00 +00:00
void GuiDocument : : fontencChanged ( int item )
{
2012-08-16 11:23:39 +00:00
fontModule - > fontencLE - > setEnabled (
fontModule - > fontencCO - > itemData ( item ) . toString ( ) = = " custom " ) ;
// The availability of TeX fonts depends on the font encoding
updateTexFonts ( ) ;
updateFontOptions ( ) ;
2009-11-29 14:43:00 +00:00
}
2012-09-22 15:44:00 +00:00
void GuiDocument : : updateMathFonts ( QString const & rm )
{
if ( fontModule - > osFontsCB - > isChecked ( ) )
return ;
QString const math =
fontModule - > fontsMathCO - > itemData ( fontModule - > fontsMathCO - > currentIndex ( ) ) . toString ( ) ;
int const i = fontModule - > fontsMathCO - > findData ( " default " ) ;
if ( providesNoMath ( rm ) & & i = = - 1 )
fontModule - > fontsMathCO - > insertItem ( 1 , qt_ ( " Class Default " ) , QString ( " default " ) ) ;
else if ( ! providesNoMath ( rm ) & & i ! = - 1 ) {
int const c = fontModule - > fontsMathCO - > currentIndex ( ) ;
fontModule - > fontsMathCO - > removeItem ( i ) ;
if ( c = = i )
fontModule - > fontsMathCO - > setCurrentIndex ( 0 ) ;
}
}
2007-10-06 22:43:21 +00:00
void GuiDocument : : romanChanged ( int item )
2007-04-24 19:37:34 +00:00
{
2010-11-26 09:42:03 +00:00
if ( fontModule - > osFontsCB - > isChecked ( ) )
2009-04-06 06:58:30 +00:00
return ;
2012-08-16 11:23:39 +00:00
QString const font =
fontModule - > fontsRomanCO - > itemData ( item ) . toString ( ) ;
2007-10-06 22:43:21 +00:00
fontModule - > fontScCB - > setEnabled ( providesSC ( font ) ) ;
fontModule - > fontOsfCB - > setEnabled ( providesOSF ( font ) ) ;
2012-09-22 15:44:00 +00:00
updateMathFonts ( font ) ;
2007-04-24 19:37:34 +00:00
}
2007-10-06 22:43:21 +00:00
void GuiDocument : : sansChanged ( int item )
2007-04-24 19:37:34 +00:00
{
2010-11-26 09:42:03 +00:00
if ( fontModule - > osFontsCB - > isChecked ( ) )
2009-04-06 06:58:30 +00:00
return ;
2012-08-16 11:23:39 +00:00
QString const font =
fontModule - > fontsSansCO - > itemData ( item ) . toString ( ) ;
2007-10-06 22:43:21 +00:00
bool scaleable = providesScale ( font ) ;
2007-04-24 19:37:34 +00:00
fontModule - > scaleSansSB - > setEnabled ( scaleable ) ;
fontModule - > scaleSansLA - > setEnabled ( scaleable ) ;
}
2007-10-06 22:43:21 +00:00
void GuiDocument : : ttChanged ( int item )
2007-04-24 19:37:34 +00:00
{
2010-11-26 09:42:03 +00:00
if ( fontModule - > osFontsCB - > isChecked ( ) )
2009-04-06 06:58:30 +00:00
return ;
2012-08-16 11:23:39 +00:00
QString const font =
fontModule - > fontsTypewriterCO - > itemData ( item ) . toString ( ) ;
2007-10-06 22:43:21 +00:00
bool scaleable = providesScale ( font ) ;
2007-04-24 19:37:34 +00:00
fontModule - > scaleTypewriterSB - > setEnabled ( scaleable ) ;
fontModule - > scaleTypewriterLA - > setEnabled ( scaleable ) ;
}
2007-10-06 22:43:21 +00:00
void GuiDocument : : updatePagestyle ( string const & items , string const & sel )
2007-04-24 19:37:34 +00:00
{
2007-06-01 17:44:04 +00:00
pagestyles . clear ( ) ;
2007-04-24 19:37:34 +00:00
pageLayoutModule - > pagestyleCO - > clear ( ) ;
2007-06-01 17:44:04 +00:00
pageLayoutModule - > pagestyleCO - > addItem ( qt_ ( " Default " ) ) ;
2007-04-24 19:37:34 +00:00
2008-09-20 12:57:12 +00:00
for ( int n = 0 ; ! token ( items , ' | ' , n ) . empty ( ) ; + + n ) {
2007-06-01 17:44:04 +00:00
string style = token ( items , ' | ' , n ) ;
2008-09-20 12:57:12 +00:00
QString style_gui = qt_ ( style ) ;
pagestyles . push_back ( pair < string , QString > ( style , style_gui ) ) ;
pageLayoutModule - > pagestyleCO - > addItem ( style_gui ) ;
2007-06-01 17:44:04 +00:00
}
2007-04-24 19:37:34 +00:00
2007-06-01 17:44:04 +00:00
if ( sel = = " default " ) {
pageLayoutModule - > pagestyleCO - > setCurrentIndex ( 0 ) ;
return ;
2007-04-24 19:37:34 +00:00
}
2007-06-01 17:44:04 +00:00
2007-09-08 21:00:49 +00:00
int nn = 0 ;
2007-06-01 17:44:04 +00:00
for ( size_t i = 0 ; i < pagestyles . size ( ) ; + + i )
if ( pagestyles [ i ] . first = = sel )
2008-09-20 12:57:12 +00:00
nn = pageLayoutModule - > pagestyleCO - > findText ( pagestyles [ i ] . second ) ;
2007-06-01 17:44:04 +00:00
2007-09-08 21:00:49 +00:00
if ( nn > 0 )
2007-09-08 22:08:46 +00:00
pageLayoutModule - > pagestyleCO - > setCurrentIndex ( nn ) ;
2007-04-24 19:37:34 +00:00
}
2008-03-10 21:31:22 +00:00
void GuiDocument : : browseLayout ( )
{
QString const label1 = qt_ ( " Layouts|#o#O " ) ;
QString const dir1 = toqstr ( lyxrc . document_path ) ;
2008-04-20 19:56:01 +00:00
QStringList const filter ( qt_ ( " LyX Layout (*.layout) " )) ;
2011-06-01 13:18:08 +00:00
QString file = browseRelToParent ( QString ( ) , bufferFilePath ( ) ,
2008-03-10 21:31:22 +00:00
qt_ ( " Local layout file " ) , filter , false ,
label1 , dir1 ) ;
2008-04-20 21:05:35 +00:00
if ( ! file . endsWith ( " .layout " ) )
2008-03-10 21:31:22 +00:00
return ;
2008-04-21 06:36:06 +00:00
FileName layoutFile = support : : makeAbsPath ( fromqstr ( file ) ,
2010-04-21 01:19:30 +00:00
fromqstr ( bufferFilePath ( ) ) ) ;
2011-12-03 22:15:11 +00:00
2008-07-11 02:43:02 +00:00
int const ret = Alert : : prompt ( _ ( " Local layout file " ) ,
_ ( " The layout file you have selected is a local layout \n "
" file, not one in the system or user directory. Your \n "
" document may not work with this layout if you do not \n "
" keep the layout file in the document directory. " ) ,
1 , 1 , _ ( " &Set Layout " ) , _ ( " &Cancel " ) ) ;
if ( ret = = 1 )
return ;
2008-03-10 21:31:22 +00:00
// load the layout file
LayoutFileList & bcl = LayoutFileList : : get ( ) ;
string classname = layoutFile . onlyFileName ( ) ;
2008-07-11 02:43:02 +00:00
// this will update an existing layout if that layout has been loaded before.
LayoutFileIndex name = bcl . addLocalLayout (
2008-03-10 21:31:22 +00:00
classname . substr ( 0 , classname . size ( ) - 7 ) ,
2010-04-21 01:19:09 +00:00
layoutFile . onlyPath ( ) . absFileName ( ) ) ;
2008-03-10 21:31:22 +00:00
if ( name . empty ( ) ) {
Alert : : error ( _ ( " Error " ) ,
2011-12-03 22:15:11 +00:00
_ ( " Unable to read local layout file. " ) ) ;
2008-03-10 21:31:22 +00:00
return ;
}
// do not trigger classChanged if there is no change.
if ( latexModule - > classCO - > currentText ( ) = = toqstr ( name ) )
return ;
2011-12-03 22:15:11 +00:00
2008-03-10 21:31:22 +00:00
// add to combo box
2012-10-09 05:22:48 +00:00
bool const avail = latexModule - > classCO - > set ( toqstr ( name ) ) ;
if ( ! avail ) {
LayoutFile const & tc = bcl [ name ] ;
docstring const guiname = translateIfPossible ( from_utf8 ( tc . description ( ) ) ) ;
// tooltip sensu "KOMA-Script Article [Class 'scrartcl']"
QString tooltip = toqstr ( bformat ( _ ( " %1$s [Class '%2$s'] " ) , guiname , from_utf8 ( tc . latexname ( ) ) ) ) ;
tooltip + = ' \n ' + qt_ ( " This is a local layout file. " ) ;
latexModule - > classCO - > addItemSort ( toqstr ( tc . name ( ) ) , toqstr ( guiname ) ,
toqstr ( translateIfPossible ( from_utf8 ( tc . category ( ) ) ) ) ,
tooltip ,
true , true , true , true ) ;
latexModule - > classCO - > set ( toqstr ( name ) ) ;
}
2011-12-03 22:15:11 +00:00
2008-03-10 21:31:22 +00:00
classChanged ( ) ;
}
2008-04-28 16:38:56 +00:00
void GuiDocument : : browseMaster ( )
{
QString const title = qt_ ( " Select master document " ) ;
QString const dir1 = toqstr ( lyxrc . document_path ) ;
QString const old = latexModule - > childDocLE - > text ( ) ;
QString const docpath = toqstr ( support : : onlyPath ( buffer ( ) . absFileName ( ) ) ) ;
QStringList const filter ( qt_ ( " LyX Files (*.lyx) " )) ;
2011-06-01 13:18:08 +00:00
QString file = browseRelToSub ( old , docpath , title , filter , false ,
2008-04-28 16:38:56 +00:00
qt_ ( " Documents|#o#O " ) , toqstr ( lyxrc . document_path ) ) ;
2010-01-01 02:45:22 +00:00
if ( ! file . isEmpty ( ) )
latexModule - > childDocLE - > setText ( file ) ;
2008-04-28 16:38:56 +00:00
}
2007-10-06 22:43:21 +00:00
void GuiDocument : : classChanged ( )
2007-04-24 19:37:34 +00:00
{
2008-02-28 21:04:55 +00:00
int idx = latexModule - > classCO - > currentIndex ( ) ;
2011-12-03 22:15:11 +00:00
if ( idx < 0 )
2008-02-28 21:04:55 +00:00
return ;
2012-10-09 05:22:48 +00:00
string const classname = fromqstr ( latexModule - > classCO - > getData ( idx ) ) ;
2008-07-11 02:43:02 +00:00
2008-10-14 17:03:57 +00:00
// check whether the selected modules have changed.
2008-10-20 20:31:33 +00:00
bool modules_changed = false ;
2008-10-14 17:35:49 +00:00
unsigned int const srows = selectedModel ( ) - > rowCount ( ) ;
2008-10-14 17:03:57 +00:00
if ( srows ! = bp_ . getModules ( ) . size ( ) )
2008-10-20 20:31:33 +00:00
modules_changed = true ;
2008-10-14 17:03:57 +00:00
else {
list < string > : : const_iterator mit = bp_ . getModules ( ) . begin ( ) ;
list < string > : : const_iterator men = bp_ . getModules ( ) . end ( ) ;
2008-10-14 17:35:49 +00:00
for ( unsigned int i = 0 ; i < srows & & mit ! = men ; + + i , + + mit )
2008-10-14 17:03:57 +00:00
if ( selectedModel ( ) - > getIDString ( i ) ! = * mit ) {
2008-10-20 20:31:33 +00:00
modules_changed = true ;
2008-10-14 17:03:57 +00:00
break ;
}
}
2008-10-20 20:31:33 +00:00
if ( modules_changed | | lyxrc . auto_reset_options ) {
2008-01-15 10:38:19 +00:00
if ( applyPB - > isEnabled ( ) ) {
int const ret = Alert : : prompt ( _ ( " Unapplied changes " ) ,
2008-03-02 12:36:30 +00:00
_ ( " Some changes in the dialog were not yet applied. \n "
2008-01-15 10:38:19 +00:00
" If you do not apply now, they will be lost after this action. " ) ,
1 , 1 , _ ( " &Apply " ) , _ ( " &Dismiss " ) ) ;
if ( ret = = 0 )
applyView ( ) ;
}
2008-01-10 06:22:42 +00:00
}
2008-10-14 18:06:08 +00:00
// We load the TextClass as soon as it is selected. This is
// necessary so that other options in the dialog can be updated
2011-12-03 22:15:11 +00:00
// according to the new class. Note, however, that, if you use
// the scroll wheel when sitting on the combo box, we'll load a
2008-10-14 18:06:08 +00:00
// lot of TextClass objects very quickly....
if ( ! bp_ . setBaseClass ( classname ) ) {
Alert : : error ( _ ( " Error " ) , _ ( " Unable to set document class. " ) ) ;
return ;
}
if ( lyxrc . auto_reset_options )
bp_ . useClassDefaults ( ) ;
2011-12-03 22:15:11 +00:00
// With the introduction of modules came a distinction between the base
// class and the document class. The former corresponds to the main layout
2008-10-12 22:21:56 +00:00
// file; the latter is that plus the modules (or the document-specific layout,
2011-12-03 22:15:11 +00:00
// or whatever else there could be). Our parameters come from the document
// class. So when we set the base class, we also need to recreate the document
2008-10-12 22:02:31 +00:00
// class. Otherwise, we still have the old one.
bp_ . makeDocumentClass ( ) ;
2008-10-14 16:59:28 +00:00
paramsToDialog ( ) ;
2007-04-24 19:37:34 +00:00
}
2011-02-03 14:17:31 +00:00
void GuiDocument : : languagePackageChanged ( int i )
{
2011-09-24 16:39:20 +00:00
langModule - > languagePackageLE - > setEnabled (
2011-02-03 14:17:31 +00:00
langModule - > languagePackageCO - > itemData ( i ) . toString ( ) = = " custom " ) ;
}
2011-12-12 16:04:00 +00:00
void GuiDocument : : biblioChanged ( )
{
2011-12-12 16:38:04 +00:00
biblioChanged_ = true ;
2011-12-12 16:04:00 +00:00
changed ( ) ;
}
2009-05-22 07:20:00 +00:00
void GuiDocument : : bibtexChanged ( int n )
{
2011-09-24 16:39:20 +00:00
biblioModule - > bibtexOptionsLE - > setEnabled (
2011-02-04 07:37:12 +00:00
biblioModule - > bibtexCO - > itemData ( n ) . toString ( ) ! = " default " ) ;
2011-12-12 16:04:00 +00:00
biblioChanged ( ) ;
2009-05-22 07:20:00 +00:00
}
2012-01-09 13:16:38 +00:00
void GuiDocument : : setAuthorYear ( bool authoryear )
{
if ( authoryear )
biblioModule - > citeStyleCO - > setCurrentIndex ( 0 ) ;
biblioChanged ( ) ;
}
void GuiDocument : : setNumerical ( bool numerical )
{
if ( numerical )
biblioModule - > citeStyleCO - > setCurrentIndex ( 1 ) ;
biblioChanged ( ) ;
}
2012-03-01 00:41:30 +00:00
void GuiDocument : : updateEngineType ( string const & items , CiteEngineType const & sel )
{
engine_types_ . clear ( ) ;
int nn = 0 ;
for ( int n = 0 ; ! token ( items , ' | ' , n ) . empty ( ) ; + + n ) {
nn + = 1 ;
string style = token ( items , ' | ' , n ) ;
engine_types_ . push_back ( style ) ;
}
switch ( sel ) {
case ENGINE_TYPE_AUTHORYEAR :
biblioModule - > citeStyleCO - > setCurrentIndex ( 0 ) ;
break ;
case ENGINE_TYPE_NUMERICAL :
biblioModule - > citeStyleCO - > setCurrentIndex ( 1 ) ;
break ;
}
biblioModule - > citationStyleL - > setEnabled ( nn > 1 ) ;
biblioModule - > citeStyleCO - > setEnabled ( nn > 1 ) ;
if ( nn ! = 1 )
return ;
// If the textclass allows only one of authoryear or numerical,
// we have no choice but to force that engine type.
if ( engine_types_ [ 0 ] = = " authoryear " )
biblioModule - > citeStyleCO - > setCurrentIndex ( 0 ) ;
else
biblioModule - > citeStyleCO - > setCurrentIndex ( 1 ) ;
}
2008-01-09 18:51:02 +00:00
namespace {
2011-12-03 22:15:11 +00:00
// FIXME unicode
2010-10-29 13:06:52 +00:00
// both of these should take a vector<docstring>
2011-12-03 22:15:11 +00:00
2008-02-24 15:44:11 +00:00
// This is an insanely complicated attempt to make this sort of thing
// work with RTL languages.
2011-12-03 22:15:11 +00:00
docstring formatStrVec ( vector < string > const & v , docstring const & s )
2008-01-09 18:51:02 +00:00
{
//this mess formats the list as "v[0], v[1], ..., [s] v[n]"
2012-05-28 20:41:32 +00:00
if ( v . empty ( ) )
2008-01-09 18:51:02 +00:00
return docstring ( ) ;
2011-12-03 22:15:11 +00:00
if ( v . size ( ) = = 1 )
2010-10-29 08:34:26 +00:00
return translateIfPossible ( from_utf8 ( v [ 0 ] ) ) ;
2008-09-20 12:57:12 +00:00
if ( v . size ( ) = = 2 ) {
2008-01-09 18:51:02 +00:00
docstring retval = _ ( " %1$s and %2$s " ) ;
retval = subst ( retval , _ ( " and " ) , s ) ;
2010-10-29 08:34:26 +00:00
return bformat ( retval , translateIfPossible ( from_utf8 ( v [ 0 ] ) ) ,
translateIfPossible ( from_utf8 ( v [ 1 ] ) ) ) ;
2008-01-09 18:51:02 +00:00
}
2008-09-20 12:57:12 +00:00
// The idea here is to format all but the last two items...
int const vSize = v . size ( ) ;
2008-01-09 18:51:02 +00:00
docstring t2 = _ ( " %1$s, %2$s " ) ;
2010-10-29 08:34:26 +00:00
docstring retval = translateIfPossible ( from_utf8 ( v [ 0 ] ) ) ;
2008-01-09 18:51:02 +00:00
for ( int i = 1 ; i < vSize - 2 ; + + i )
2011-12-03 22:15:11 +00:00
retval = bformat ( t2 , retval , translateIfPossible ( from_utf8 ( v [ i ] ) ) ) ;
2008-01-09 18:51:02 +00:00
//...and then to plug them, and the last two, into this schema
docstring t = _ ( " %1$s, %2$s, and %3$s " ) ;
t = subst ( t , _ ( " and " ) , s ) ;
2010-10-29 08:34:26 +00:00
return bformat ( t , retval , translateIfPossible ( from_utf8 ( v [ vSize - 2 ] ) ) ,
translateIfPossible ( from_utf8 ( v [ vSize - 1 ] ) ) ) ;
2008-01-09 18:51:02 +00:00
}
2011-12-03 22:15:11 +00:00
This commit changes the way individual LyXModule's are represented, both internally and in the .lyx files. The earlier version represented them by their `descriptive name', e.g., "Endnote" or "Theorems (AMS)", these being the same names used in the UI. This was a mistake, as becomes readily apparent when one starts to think about translating these strings. The modules ought to be represented by their filename, without the extension, just as TextClass's are.
The changes that accomplish this part are in ModuleList.{h,cpp}, configure.py, and the *.module files themselves. This is a format change, and the lyx2lyx is in those files.
By itself, that change would not be major, except for the fact that we do not want the module to be represented in the UI by its filename---e.g., theorems-std---but rather by a descriptive name, such as "Theorems". But that change turns out to be wholly non-trivial. The mechanism for choosing modules was the same as---indeed, was borrowed from---that in GuiCitation: You get a list of modules, and choosing them involves moving strings from one QListView to another. The models underlying these views are just QStringListModels, which means that, when you want to know what modules have been selected, you see what strings are in the "selected" QListView. But these are just the descriptive names, and we can't look up a module by its descriptive name if it's been translated. That, indeed, was the whole point of the change to the new representation.
So, we need a more complicated model underlying the QListView, one that will pair an identifying string---the filename minus the extension, in this case---with each item. This turns out not to be terribly difficult, though it took rather a while for me to understand why it's not difficult. There are two parts:
(i) GuiSelectionManger gets re-written to use any QAbstractListModel, not just a QStringListModel. This actually seems to improve the code, independently.
(ii) We then subclass QAbstractListModel to get the associated ID string, using the Qt::UserRole slot associated with each item to store its ID. This would be almost completely trivial if QAbstractListItem::itemData() included the QVariant associated with this role, but it doesn't, so there are some additional hoops through which to jump.
The new model, a GuiIdListModel, is defined in the files by that name. The changes in GuiSelectionManger.{h,cpp} make it more abstract; the changes in GuiDocument.{h,cpp} adapt it to the new framework.
I've also updated the module documenation to accord with this change.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22501 a592a061-630c-0410-9148-cb99ea01b6c8
2008-01-12 04:28:12 +00:00
vector < string > idsToNames ( vector < string > const & idList )
{
vector < string > retval ;
vector < string > : : const_iterator it = idList . begin ( ) ;
vector < string > : : const_iterator end = idList . end ( ) ;
for ( ; it ! = end ; + + it ) {
2009-08-14 15:37:34 +00:00
LyXModule const * const mod = theModuleList [ * it ] ;
This commit changes the way individual LyXModule's are represented, both internally and in the .lyx files. The earlier version represented them by their `descriptive name', e.g., "Endnote" or "Theorems (AMS)", these being the same names used in the UI. This was a mistake, as becomes readily apparent when one starts to think about translating these strings. The modules ought to be represented by their filename, without the extension, just as TextClass's are.
The changes that accomplish this part are in ModuleList.{h,cpp}, configure.py, and the *.module files themselves. This is a format change, and the lyx2lyx is in those files.
By itself, that change would not be major, except for the fact that we do not want the module to be represented in the UI by its filename---e.g., theorems-std---but rather by a descriptive name, such as "Theorems". But that change turns out to be wholly non-trivial. The mechanism for choosing modules was the same as---indeed, was borrowed from---that in GuiCitation: You get a list of modules, and choosing them involves moving strings from one QListView to another. The models underlying these views are just QStringListModels, which means that, when you want to know what modules have been selected, you see what strings are in the "selected" QListView. But these are just the descriptive names, and we can't look up a module by its descriptive name if it's been translated. That, indeed, was the whole point of the change to the new representation.
So, we need a more complicated model underlying the QListView, one that will pair an identifying string---the filename minus the extension, in this case---with each item. This turns out not to be terribly difficult, though it took rather a while for me to understand why it's not difficult. There are two parts:
(i) GuiSelectionManger gets re-written to use any QAbstractListModel, not just a QStringListModel. This actually seems to improve the code, independently.
(ii) We then subclass QAbstractListModel to get the associated ID string, using the Qt::UserRole slot associated with each item to store its ID. This would be almost completely trivial if QAbstractListItem::itemData() included the QVariant associated with this role, but it doesn't, so there are some additional hoops through which to jump.
The new model, a GuiIdListModel, is defined in the files by that name. The changes in GuiSelectionManger.{h,cpp} make it more abstract; the changes in GuiDocument.{h,cpp} adapt it to the new framework.
I've also updated the module documenation to accord with this change.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22501 a592a061-630c-0410-9148-cb99ea01b6c8
2008-01-12 04:28:12 +00:00
if ( ! mod )
2011-12-03 22:15:11 +00:00
retval . push_back ( to_utf8 ( bformat ( _ ( " %1$s (unavailable) " ) ,
2010-10-29 13:06:52 +00:00
translateIfPossible ( from_utf8 ( * it ) ) ) ) ) ;
This commit changes the way individual LyXModule's are represented, both internally and in the .lyx files. The earlier version represented them by their `descriptive name', e.g., "Endnote" or "Theorems (AMS)", these being the same names used in the UI. This was a mistake, as becomes readily apparent when one starts to think about translating these strings. The modules ought to be represented by their filename, without the extension, just as TextClass's are.
The changes that accomplish this part are in ModuleList.{h,cpp}, configure.py, and the *.module files themselves. This is a format change, and the lyx2lyx is in those files.
By itself, that change would not be major, except for the fact that we do not want the module to be represented in the UI by its filename---e.g., theorems-std---but rather by a descriptive name, such as "Theorems". But that change turns out to be wholly non-trivial. The mechanism for choosing modules was the same as---indeed, was borrowed from---that in GuiCitation: You get a list of modules, and choosing them involves moving strings from one QListView to another. The models underlying these views are just QStringListModels, which means that, when you want to know what modules have been selected, you see what strings are in the "selected" QListView. But these are just the descriptive names, and we can't look up a module by its descriptive name if it's been translated. That, indeed, was the whole point of the change to the new representation.
So, we need a more complicated model underlying the QListView, one that will pair an identifying string---the filename minus the extension, in this case---with each item. This turns out not to be terribly difficult, though it took rather a while for me to understand why it's not difficult. There are two parts:
(i) GuiSelectionManger gets re-written to use any QAbstractListModel, not just a QStringListModel. This actually seems to improve the code, independently.
(ii) We then subclass QAbstractListModel to get the associated ID string, using the Qt::UserRole slot associated with each item to store its ID. This would be almost completely trivial if QAbstractListItem::itemData() included the QVariant associated with this role, but it doesn't, so there are some additional hoops through which to jump.
The new model, a GuiIdListModel, is defined in the files by that name. The changes in GuiSelectionManger.{h,cpp} make it more abstract; the changes in GuiDocument.{h,cpp} adapt it to the new framework.
I've also updated the module documenation to accord with this change.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22501 a592a061-630c-0410-9148-cb99ea01b6c8
2008-01-12 04:28:12 +00:00
else
retval . push_back ( mod - > getName ( ) ) ;
}
return retval ;
}
2010-07-12 17:40:54 +00:00
} // end anonymous namespace
2008-01-09 18:51:02 +00:00
2008-10-20 20:38:40 +00:00
void GuiDocument : : modulesToParams ( BufferParams & bp )
2008-10-20 19:31:05 +00:00
{
// update list of loaded modules
2008-10-20 20:38:40 +00:00
bp . clearLayoutModules ( ) ;
2008-10-20 19:31:05 +00:00
int const srows = modules_sel_model_ . rowCount ( ) ;
for ( int i = 0 ; i < srows ; + + i )
2008-10-20 20:38:40 +00:00
bp . addLayoutModule ( modules_sel_model_ . getIDString ( i ) ) ;
2008-10-20 19:31:05 +00:00
// update the list of removed modules
2008-10-20 20:38:40 +00:00
bp . clearRemovedModules ( ) ;
2009-02-12 15:07:22 +00:00
LayoutModuleList const & reqmods = bp . baseClass ( ) - > defaultModules ( ) ;
2008-10-20 19:31:05 +00:00
list < string > : : const_iterator rit = reqmods . begin ( ) ;
list < string > : : const_iterator ren = reqmods . end ( ) ;
// check each of the default modules
2012-05-28 20:41:32 +00:00
for ( ; rit ! = ren ; + + rit ) {
2008-10-20 20:38:40 +00:00
list < string > : : const_iterator mit = bp . getModules ( ) . begin ( ) ;
list < string > : : const_iterator men = bp . getModules ( ) . end ( ) ;
2008-10-20 19:31:05 +00:00
bool found = false ;
2012-05-28 20:41:32 +00:00
for ( ; mit ! = men ; + + mit ) {
2008-10-20 19:31:05 +00:00
if ( * rit = = * mit ) {
found = true ;
break ;
}
}
if ( ! found ) {
// the module isn't present so must have been removed by the user
2008-10-20 20:38:40 +00:00
bp . addRemovedModule ( * rit ) ;
2008-10-20 19:31:05 +00:00
}
}
2008-10-20 20:38:40 +00:00
}
void GuiDocument : : modulesChanged ( )
{
modulesToParams ( bp_ ) ;
2008-10-20 19:31:05 +00:00
bp_ . makeDocumentClass ( ) ;
paramsToDialog ( ) ;
}
2007-10-06 22:43:21 +00:00
void GuiDocument : : updateModuleInfo ( )
This is the last of a series of patches that merges the layout modules development in personal/branches/rgheck back into the tree.
Design goal: Allow the use of layout "modules", which are to LaTeX packages as layout files are to LaTeX document classes. Thus, one could have a module that defined certain character styles, environments, commands, or what have you, and include it in various documents, each of which uses a different document class, without having to modify the layout files themselves. For example, a theorems.module could be used with article.layout to provide support for theorem-type environments, without having to modify article.layout itself, and the same module could be used with book.layout, etc.
This patch adds the GUI for managing modules.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20282 a592a061-630c-0410-9148-cb99ea01b6c8
2007-09-15 01:55:09 +00:00
{
selectionManager - > update ( ) ;
2011-12-03 22:15:11 +00:00
This is the last of a series of patches that merges the layout modules development in personal/branches/rgheck back into the tree.
Design goal: Allow the use of layout "modules", which are to LaTeX packages as layout files are to LaTeX document classes. Thus, one could have a module that defined certain character styles, environments, commands, or what have you, and include it in various documents, each of which uses a different document class, without having to modify the layout files themselves. For example, a theorems.module could be used with article.layout to provide support for theorem-type environments, without having to modify article.layout itself, and the same module could be used with book.layout, etc.
This patch adds the GUI for managing modules.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20282 a592a061-630c-0410-9148-cb99ea01b6c8
2007-09-15 01:55:09 +00:00
//Module description
2008-10-20 20:31:33 +00:00
bool const focus_on_selected = selectionManager - > selectedFocused ( ) ;
2009-08-14 20:37:12 +00:00
QAbstractItemView * lv ;
if ( focus_on_selected )
lv = modulesModule - > selectedLV ;
else
2012-03-08 16:43:02 +00:00
lv = modulesModule - > availableLV ;
This commit changes the way individual LyXModule's are represented, both internally and in the .lyx files. The earlier version represented them by their `descriptive name', e.g., "Endnote" or "Theorems (AMS)", these being the same names used in the UI. This was a mistake, as becomes readily apparent when one starts to think about translating these strings. The modules ought to be represented by their filename, without the extension, just as TextClass's are.
The changes that accomplish this part are in ModuleList.{h,cpp}, configure.py, and the *.module files themselves. This is a format change, and the lyx2lyx is in those files.
By itself, that change would not be major, except for the fact that we do not want the module to be represented in the UI by its filename---e.g., theorems-std---but rather by a descriptive name, such as "Theorems". But that change turns out to be wholly non-trivial. The mechanism for choosing modules was the same as---indeed, was borrowed from---that in GuiCitation: You get a list of modules, and choosing them involves moving strings from one QListView to another. The models underlying these views are just QStringListModels, which means that, when you want to know what modules have been selected, you see what strings are in the "selected" QListView. But these are just the descriptive names, and we can't look up a module by its descriptive name if it's been translated. That, indeed, was the whole point of the change to the new representation.
So, we need a more complicated model underlying the QListView, one that will pair an identifying string---the filename minus the extension, in this case---with each item. This turns out not to be terribly difficult, though it took rather a while for me to understand why it's not difficult. There are two parts:
(i) GuiSelectionManger gets re-written to use any QAbstractListModel, not just a QStringListModel. This actually seems to improve the code, independently.
(ii) We then subclass QAbstractListModel to get the associated ID string, using the Qt::UserRole slot associated with each item to store its ID. This would be almost completely trivial if QAbstractListItem::itemData() included the QVariant associated with this role, but it doesn't, so there are some additional hoops through which to jump.
The new model, a GuiIdListModel, is defined in the files by that name. The changes in GuiSelectionManger.{h,cpp} make it more abstract; the changes in GuiDocument.{h,cpp} adapt it to the new framework.
I've also updated the module documenation to accord with this change.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22501 a592a061-630c-0410-9148-cb99ea01b6c8
2008-01-12 04:28:12 +00:00
if ( lv - > selectionModel ( ) - > selectedIndexes ( ) . isEmpty ( ) ) {
2008-10-19 01:21:59 +00:00
modulesModule - > infoML - > document ( ) - > clear ( ) ;
This commit changes the way individual LyXModule's are represented, both internally and in the .lyx files. The earlier version represented them by their `descriptive name', e.g., "Endnote" or "Theorems (AMS)", these being the same names used in the UI. This was a mistake, as becomes readily apparent when one starts to think about translating these strings. The modules ought to be represented by their filename, without the extension, just as TextClass's are.
The changes that accomplish this part are in ModuleList.{h,cpp}, configure.py, and the *.module files themselves. This is a format change, and the lyx2lyx is in those files.
By itself, that change would not be major, except for the fact that we do not want the module to be represented in the UI by its filename---e.g., theorems-std---but rather by a descriptive name, such as "Theorems". But that change turns out to be wholly non-trivial. The mechanism for choosing modules was the same as---indeed, was borrowed from---that in GuiCitation: You get a list of modules, and choosing them involves moving strings from one QListView to another. The models underlying these views are just QStringListModels, which means that, when you want to know what modules have been selected, you see what strings are in the "selected" QListView. But these are just the descriptive names, and we can't look up a module by its descriptive name if it's been translated. That, indeed, was the whole point of the change to the new representation.
So, we need a more complicated model underlying the QListView, one that will pair an identifying string---the filename minus the extension, in this case---with each item. This turns out not to be terribly difficult, though it took rather a while for me to understand why it's not difficult. There are two parts:
(i) GuiSelectionManger gets re-written to use any QAbstractListModel, not just a QStringListModel. This actually seems to improve the code, independently.
(ii) We then subclass QAbstractListModel to get the associated ID string, using the Qt::UserRole slot associated with each item to store its ID. This would be almost completely trivial if QAbstractListItem::itemData() included the QVariant associated with this role, but it doesn't, so there are some additional hoops through which to jump.
The new model, a GuiIdListModel, is defined in the files by that name. The changes in GuiSelectionManger.{h,cpp} make it more abstract; the changes in GuiDocument.{h,cpp} adapt it to the new framework.
I've also updated the module documenation to accord with this change.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22501 a592a061-630c-0410-9148-cb99ea01b6c8
2008-01-12 04:28:12 +00:00
return ;
}
QModelIndex const & idx = lv - > selectionModel ( ) - > currentIndex ( ) ;
2011-12-03 22:15:11 +00:00
GuiIdListModel const & id_model =
2008-10-20 20:31:33 +00:00
focus_on_selected ? modules_sel_model_ : modules_av_model_ ;
string const modName = id_model . getIDString ( idx . row ( ) ) ;
This commit changes the way individual LyXModule's are represented, both internally and in the .lyx files. The earlier version represented them by their `descriptive name', e.g., "Endnote" or "Theorems (AMS)", these being the same names used in the UI. This was a mistake, as becomes readily apparent when one starts to think about translating these strings. The modules ought to be represented by their filename, without the extension, just as TextClass's are.
The changes that accomplish this part are in ModuleList.{h,cpp}, configure.py, and the *.module files themselves. This is a format change, and the lyx2lyx is in those files.
By itself, that change would not be major, except for the fact that we do not want the module to be represented in the UI by its filename---e.g., theorems-std---but rather by a descriptive name, such as "Theorems". But that change turns out to be wholly non-trivial. The mechanism for choosing modules was the same as---indeed, was borrowed from---that in GuiCitation: You get a list of modules, and choosing them involves moving strings from one QListView to another. The models underlying these views are just QStringListModels, which means that, when you want to know what modules have been selected, you see what strings are in the "selected" QListView. But these are just the descriptive names, and we can't look up a module by its descriptive name if it's been translated. That, indeed, was the whole point of the change to the new representation.
So, we need a more complicated model underlying the QListView, one that will pair an identifying string---the filename minus the extension, in this case---with each item. This turns out not to be terribly difficult, though it took rather a while for me to understand why it's not difficult. There are two parts:
(i) GuiSelectionManger gets re-written to use any QAbstractListModel, not just a QStringListModel. This actually seems to improve the code, independently.
(ii) We then subclass QAbstractListModel to get the associated ID string, using the Qt::UserRole slot associated with each item to store its ID. This would be almost completely trivial if QAbstractListItem::itemData() included the QVariant associated with this role, but it doesn't, so there are some additional hoops through which to jump.
The new model, a GuiIdListModel, is defined in the files by that name. The changes in GuiSelectionManger.{h,cpp} make it more abstract; the changes in GuiDocument.{h,cpp} adapt it to the new framework.
I've also updated the module documenation to accord with this change.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22501 a592a061-630c-0410-9148-cb99ea01b6c8
2008-01-12 04:28:12 +00:00
docstring desc = getModuleDescription ( modName ) ;
2009-02-12 15:07:22 +00:00
LayoutModuleList const & provmods = bp_ . baseClass ( ) - > providedModules ( ) ;
2008-10-23 00:27:03 +00:00
if ( std : : find ( provmods . begin ( ) , provmods . end ( ) , modName ) ! = provmods . end ( ) ) {
if ( ! desc . empty ( ) )
desc + = " \n " ;
desc + = _ ( " Module provided by document class. " ) ;
}
2012-03-08 16:43:04 +00:00
docstring cat = getModuleCategory ( modName ) ;
if ( ! cat . empty ( ) ) {
if ( ! desc . empty ( ) )
desc + = " \n " ;
desc + = bformat ( _ ( " Category: %1$s. " ) , cat ) ;
}
2008-10-20 20:31:33 +00:00
vector < string > pkglist = getPackageList ( modName ) ;
docstring pkgdesc = formatStrVec ( pkglist , _ ( " and " ) ) ;
This commit changes the way individual LyXModule's are represented, both internally and in the .lyx files. The earlier version represented them by their `descriptive name', e.g., "Endnote" or "Theorems (AMS)", these being the same names used in the UI. This was a mistake, as becomes readily apparent when one starts to think about translating these strings. The modules ought to be represented by their filename, without the extension, just as TextClass's are.
The changes that accomplish this part are in ModuleList.{h,cpp}, configure.py, and the *.module files themselves. This is a format change, and the lyx2lyx is in those files.
By itself, that change would not be major, except for the fact that we do not want the module to be represented in the UI by its filename---e.g., theorems-std---but rather by a descriptive name, such as "Theorems". But that change turns out to be wholly non-trivial. The mechanism for choosing modules was the same as---indeed, was borrowed from---that in GuiCitation: You get a list of modules, and choosing them involves moving strings from one QListView to another. The models underlying these views are just QStringListModels, which means that, when you want to know what modules have been selected, you see what strings are in the "selected" QListView. But these are just the descriptive names, and we can't look up a module by its descriptive name if it's been translated. That, indeed, was the whole point of the change to the new representation.
So, we need a more complicated model underlying the QListView, one that will pair an identifying string---the filename minus the extension, in this case---with each item. This turns out not to be terribly difficult, though it took rather a while for me to understand why it's not difficult. There are two parts:
(i) GuiSelectionManger gets re-written to use any QAbstractListModel, not just a QStringListModel. This actually seems to improve the code, independently.
(ii) We then subclass QAbstractListModel to get the associated ID string, using the Qt::UserRole slot associated with each item to store its ID. This would be almost completely trivial if QAbstractListItem::itemData() included the QVariant associated with this role, but it doesn't, so there are some additional hoops through which to jump.
The new model, a GuiIdListModel, is defined in the files by that name. The changes in GuiSelectionManger.{h,cpp} make it more abstract; the changes in GuiDocument.{h,cpp} adapt it to the new framework.
I've also updated the module documenation to accord with this change.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22501 a592a061-630c-0410-9148-cb99ea01b6c8
2008-01-12 04:28:12 +00:00
if ( ! pkgdesc . empty ( ) ) {
if ( ! desc . empty ( ) )
desc + = " \n " ;
desc + = bformat ( _ ( " Package(s) required: %1$s. " ) , pkgdesc ) ;
}
2008-01-09 18:51:02 +00:00
2008-10-20 20:31:33 +00:00
pkglist = getRequiredList ( modName ) ;
if ( ! pkglist . empty ( ) ) {
vector < string > const reqdescs = idsToNames ( pkglist ) ;
pkgdesc = formatStrVec ( reqdescs , _ ( " or " ) ) ;
This commit changes the way individual LyXModule's are represented, both internally and in the .lyx files. The earlier version represented them by their `descriptive name', e.g., "Endnote" or "Theorems (AMS)", these being the same names used in the UI. This was a mistake, as becomes readily apparent when one starts to think about translating these strings. The modules ought to be represented by their filename, without the extension, just as TextClass's are.
The changes that accomplish this part are in ModuleList.{h,cpp}, configure.py, and the *.module files themselves. This is a format change, and the lyx2lyx is in those files.
By itself, that change would not be major, except for the fact that we do not want the module to be represented in the UI by its filename---e.g., theorems-std---but rather by a descriptive name, such as "Theorems". But that change turns out to be wholly non-trivial. The mechanism for choosing modules was the same as---indeed, was borrowed from---that in GuiCitation: You get a list of modules, and choosing them involves moving strings from one QListView to another. The models underlying these views are just QStringListModels, which means that, when you want to know what modules have been selected, you see what strings are in the "selected" QListView. But these are just the descriptive names, and we can't look up a module by its descriptive name if it's been translated. That, indeed, was the whole point of the change to the new representation.
So, we need a more complicated model underlying the QListView, one that will pair an identifying string---the filename minus the extension, in this case---with each item. This turns out not to be terribly difficult, though it took rather a while for me to understand why it's not difficult. There are two parts:
(i) GuiSelectionManger gets re-written to use any QAbstractListModel, not just a QStringListModel. This actually seems to improve the code, independently.
(ii) We then subclass QAbstractListModel to get the associated ID string, using the Qt::UserRole slot associated with each item to store its ID. This would be almost completely trivial if QAbstractListItem::itemData() included the QVariant associated with this role, but it doesn't, so there are some additional hoops through which to jump.
The new model, a GuiIdListModel, is defined in the files by that name. The changes in GuiSelectionManger.{h,cpp} make it more abstract; the changes in GuiDocument.{h,cpp} adapt it to the new framework.
I've also updated the module documenation to accord with this change.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22501 a592a061-630c-0410-9148-cb99ea01b6c8
2008-01-12 04:28:12 +00:00
if ( ! desc . empty ( ) )
desc + = " \n " ;
2010-10-28 20:23:39 +00:00
desc + = bformat ( _ ( " Modules required: %1$s. " ) , pkgdesc ) ;
This commit changes the way individual LyXModule's are represented, both internally and in the .lyx files. The earlier version represented them by their `descriptive name', e.g., "Endnote" or "Theorems (AMS)", these being the same names used in the UI. This was a mistake, as becomes readily apparent when one starts to think about translating these strings. The modules ought to be represented by their filename, without the extension, just as TextClass's are.
The changes that accomplish this part are in ModuleList.{h,cpp}, configure.py, and the *.module files themselves. This is a format change, and the lyx2lyx is in those files.
By itself, that change would not be major, except for the fact that we do not want the module to be represented in the UI by its filename---e.g., theorems-std---but rather by a descriptive name, such as "Theorems". But that change turns out to be wholly non-trivial. The mechanism for choosing modules was the same as---indeed, was borrowed from---that in GuiCitation: You get a list of modules, and choosing them involves moving strings from one QListView to another. The models underlying these views are just QStringListModels, which means that, when you want to know what modules have been selected, you see what strings are in the "selected" QListView. But these are just the descriptive names, and we can't look up a module by its descriptive name if it's been translated. That, indeed, was the whole point of the change to the new representation.
So, we need a more complicated model underlying the QListView, one that will pair an identifying string---the filename minus the extension, in this case---with each item. This turns out not to be terribly difficult, though it took rather a while for me to understand why it's not difficult. There are two parts:
(i) GuiSelectionManger gets re-written to use any QAbstractListModel, not just a QStringListModel. This actually seems to improve the code, independently.
(ii) We then subclass QAbstractListModel to get the associated ID string, using the Qt::UserRole slot associated with each item to store its ID. This would be almost completely trivial if QAbstractListItem::itemData() included the QVariant associated with this role, but it doesn't, so there are some additional hoops through which to jump.
The new model, a GuiIdListModel, is defined in the files by that name. The changes in GuiSelectionManger.{h,cpp} make it more abstract; the changes in GuiDocument.{h,cpp} adapt it to the new framework.
I've also updated the module documenation to accord with this change.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22501 a592a061-630c-0410-9148-cb99ea01b6c8
2008-01-12 04:28:12 +00:00
}
2008-01-09 18:51:02 +00:00
2008-10-20 20:31:33 +00:00
pkglist = getExcludedList ( modName ) ;
if ( ! pkglist . empty ( ) ) {
vector < string > const reqdescs = idsToNames ( pkglist ) ;
pkgdesc = formatStrVec ( reqdescs , _ ( " and " ) ) ;
This commit changes the way individual LyXModule's are represented, both internally and in the .lyx files. The earlier version represented them by their `descriptive name', e.g., "Endnote" or "Theorems (AMS)", these being the same names used in the UI. This was a mistake, as becomes readily apparent when one starts to think about translating these strings. The modules ought to be represented by their filename, without the extension, just as TextClass's are.
The changes that accomplish this part are in ModuleList.{h,cpp}, configure.py, and the *.module files themselves. This is a format change, and the lyx2lyx is in those files.
By itself, that change would not be major, except for the fact that we do not want the module to be represented in the UI by its filename---e.g., theorems-std---but rather by a descriptive name, such as "Theorems". But that change turns out to be wholly non-trivial. The mechanism for choosing modules was the same as---indeed, was borrowed from---that in GuiCitation: You get a list of modules, and choosing them involves moving strings from one QListView to another. The models underlying these views are just QStringListModels, which means that, when you want to know what modules have been selected, you see what strings are in the "selected" QListView. But these are just the descriptive names, and we can't look up a module by its descriptive name if it's been translated. That, indeed, was the whole point of the change to the new representation.
So, we need a more complicated model underlying the QListView, one that will pair an identifying string---the filename minus the extension, in this case---with each item. This turns out not to be terribly difficult, though it took rather a while for me to understand why it's not difficult. There are two parts:
(i) GuiSelectionManger gets re-written to use any QAbstractListModel, not just a QStringListModel. This actually seems to improve the code, independently.
(ii) We then subclass QAbstractListModel to get the associated ID string, using the Qt::UserRole slot associated with each item to store its ID. This would be almost completely trivial if QAbstractListItem::itemData() included the QVariant associated with this role, but it doesn't, so there are some additional hoops through which to jump.
The new model, a GuiIdListModel, is defined in the files by that name. The changes in GuiSelectionManger.{h,cpp} make it more abstract; the changes in GuiDocument.{h,cpp} adapt it to the new framework.
I've also updated the module documenation to accord with this change.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22501 a592a061-630c-0410-9148-cb99ea01b6c8
2008-01-12 04:28:12 +00:00
if ( ! desc . empty ( ) )
desc + = " \n " ;
desc + = bformat ( _ ( " Modules excluded: %1$s. " ) , pkgdesc ) ;
}
2008-01-09 18:51:02 +00:00
This commit changes the way individual LyXModule's are represented, both internally and in the .lyx files. The earlier version represented them by their `descriptive name', e.g., "Endnote" or "Theorems (AMS)", these being the same names used in the UI. This was a mistake, as becomes readily apparent when one starts to think about translating these strings. The modules ought to be represented by their filename, without the extension, just as TextClass's are.
The changes that accomplish this part are in ModuleList.{h,cpp}, configure.py, and the *.module files themselves. This is a format change, and the lyx2lyx is in those files.
By itself, that change would not be major, except for the fact that we do not want the module to be represented in the UI by its filename---e.g., theorems-std---but rather by a descriptive name, such as "Theorems". But that change turns out to be wholly non-trivial. The mechanism for choosing modules was the same as---indeed, was borrowed from---that in GuiCitation: You get a list of modules, and choosing them involves moving strings from one QListView to another. The models underlying these views are just QStringListModels, which means that, when you want to know what modules have been selected, you see what strings are in the "selected" QListView. But these are just the descriptive names, and we can't look up a module by its descriptive name if it's been translated. That, indeed, was the whole point of the change to the new representation.
So, we need a more complicated model underlying the QListView, one that will pair an identifying string---the filename minus the extension, in this case---with each item. This turns out not to be terribly difficult, though it took rather a while for me to understand why it's not difficult. There are two parts:
(i) GuiSelectionManger gets re-written to use any QAbstractListModel, not just a QStringListModel. This actually seems to improve the code, independently.
(ii) We then subclass QAbstractListModel to get the associated ID string, using the Qt::UserRole slot associated with each item to store its ID. This would be almost completely trivial if QAbstractListItem::itemData() included the QVariant associated with this role, but it doesn't, so there are some additional hoops through which to jump.
The new model, a GuiIdListModel, is defined in the files by that name. The changes in GuiSelectionManger.{h,cpp} make it more abstract; the changes in GuiDocument.{h,cpp} adapt it to the new framework.
I've also updated the module documenation to accord with this change.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22501 a592a061-630c-0410-9148-cb99ea01b6c8
2008-01-12 04:28:12 +00:00
if ( ! isModuleAvailable ( modName ) ) {
if ( ! desc . empty ( ) )
desc + = " \n " ;
2008-10-16 17:29:01 +00:00
desc + = _ ( " WARNING: Some required packages are unavailable! " ) ;
This is the last of a series of patches that merges the layout modules development in personal/branches/rgheck back into the tree.
Design goal: Allow the use of layout "modules", which are to LaTeX packages as layout files are to LaTeX document classes. Thus, one could have a module that defined certain character styles, environments, commands, or what have you, and include it in various documents, each of which uses a different document class, without having to modify the layout files themselves. For example, a theorems.module could be used with article.layout to provide support for theorem-type environments, without having to modify article.layout itself, and the same module could be used with book.layout, etc.
This patch adds the GUI for managing modules.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20282 a592a061-630c-0410-9148-cb99ea01b6c8
2007-09-15 01:55:09 +00:00
}
This commit changes the way individual LyXModule's are represented, both internally and in the .lyx files. The earlier version represented them by their `descriptive name', e.g., "Endnote" or "Theorems (AMS)", these being the same names used in the UI. This was a mistake, as becomes readily apparent when one starts to think about translating these strings. The modules ought to be represented by their filename, without the extension, just as TextClass's are.
The changes that accomplish this part are in ModuleList.{h,cpp}, configure.py, and the *.module files themselves. This is a format change, and the lyx2lyx is in those files.
By itself, that change would not be major, except for the fact that we do not want the module to be represented in the UI by its filename---e.g., theorems-std---but rather by a descriptive name, such as "Theorems". But that change turns out to be wholly non-trivial. The mechanism for choosing modules was the same as---indeed, was borrowed from---that in GuiCitation: You get a list of modules, and choosing them involves moving strings from one QListView to another. The models underlying these views are just QStringListModels, which means that, when you want to know what modules have been selected, you see what strings are in the "selected" QListView. But these are just the descriptive names, and we can't look up a module by its descriptive name if it's been translated. That, indeed, was the whole point of the change to the new representation.
So, we need a more complicated model underlying the QListView, one that will pair an identifying string---the filename minus the extension, in this case---with each item. This turns out not to be terribly difficult, though it took rather a while for me to understand why it's not difficult. There are two parts:
(i) GuiSelectionManger gets re-written to use any QAbstractListModel, not just a QStringListModel. This actually seems to improve the code, independently.
(ii) We then subclass QAbstractListModel to get the associated ID string, using the Qt::UserRole slot associated with each item to store its ID. This would be almost completely trivial if QAbstractListItem::itemData() included the QVariant associated with this role, but it doesn't, so there are some additional hoops through which to jump.
The new model, a GuiIdListModel, is defined in the files by that name. The changes in GuiSelectionManger.{h,cpp} make it more abstract; the changes in GuiDocument.{h,cpp} adapt it to the new framework.
I've also updated the module documenation to accord with this change.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22501 a592a061-630c-0410-9148-cb99ea01b6c8
2008-01-12 04:28:12 +00:00
2008-10-19 01:21:59 +00:00
modulesModule - > infoML - > document ( ) - > setPlainText ( toqstr ( desc ) ) ;
This is the last of a series of patches that merges the layout modules development in personal/branches/rgheck back into the tree.
Design goal: Allow the use of layout "modules", which are to LaTeX packages as layout files are to LaTeX document classes. Thus, one could have a module that defined certain character styles, environments, commands, or what have you, and include it in various documents, each of which uses a different document class, without having to modify the layout files themselves. For example, a theorems.module could be used with article.layout to provide support for theorem-type environments, without having to modify article.layout itself, and the same module could be used with book.layout, etc.
This patch adds the GUI for managing modules.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20282 a592a061-630c-0410-9148-cb99ea01b6c8
2007-09-15 01:55:09 +00:00
}
2007-10-06 22:43:21 +00:00
void GuiDocument : : updateNumbering ( )
2007-04-24 19:37:34 +00:00
{
2008-10-12 15:34:08 +00:00
DocumentClass const & tclass = documentClass ( ) ;
2007-04-24 19:37:34 +00:00
numberingModule - > tocTW - > setUpdatesEnabled ( false ) ;
numberingModule - > tocTW - > clear ( ) ;
int const depth = numberingModule - > depthSL - > value ( ) ;
int const toc = numberingModule - > tocSL - > value ( ) ;
QString const no = qt_ ( " No " ) ;
QString const yes = qt_ ( " Yes " ) ;
QTreeWidgetItem * item = 0 ;
2008-03-06 05:59:21 +00:00
DocumentClass : : const_iterator lit = tclass . begin ( ) ;
DocumentClass : : const_iterator len = tclass . end ( ) ;
for ( ; lit ! = len ; + + lit ) {
2008-03-06 20:01:30 +00:00
int const toclevel = lit - > toclevel ;
if ( toclevel ! = Layout : : NOT_IN_TOC & & lit - > labeltype = = LABEL_COUNTER ) {
2007-04-24 19:37:34 +00:00
item = new QTreeWidgetItem ( numberingModule - > tocTW ) ;
2008-03-06 20:01:30 +00:00
item - > setText ( 0 , toqstr ( translateIfPossible ( lit - > name ( ) ) ) ) ;
2007-04-24 19:37:34 +00:00
item - > setText ( 1 , ( toclevel < = depth ) ? yes : no ) ;
item - > setText ( 2 , ( toclevel < = toc ) ? yes : no ) ;
}
}
numberingModule - > tocTW - > setUpdatesEnabled ( true ) ;
numberingModule - > tocTW - > update ( ) ;
}
2007-09-20 22:31:18 +00:00
2009-04-10 11:06:53 +00:00
void GuiDocument : : updateDefaultFormat ( )
{
2010-02-01 14:44:12 +00:00
if ( ! bufferview ( ) )
return ;
2009-04-10 11:06:53 +00:00
// make a copy in order to consider unapplied changes
2011-05-13 22:26:35 +00:00
BufferParams param_copy = buffer ( ) . params ( ) ;
param_copy . useNonTeXFonts = fontModule - > osFontsCB - > isChecked ( ) ;
int const idx = latexModule - > classCO - > currentIndex ( ) ;
2009-04-10 11:06:53 +00:00
if ( idx > = 0 ) {
2012-10-09 05:22:48 +00:00
string const classname = fromqstr ( latexModule - > classCO - > getData ( idx ) ) ;
2011-05-13 22:26:35 +00:00
param_copy . setBaseClass ( classname ) ;
param_copy . makeDocumentClass ( ) ;
2009-04-10 11:06:53 +00:00
}
outputModule - > defaultFormatCO - > blockSignals ( true ) ;
outputModule - > defaultFormatCO - > clear ( ) ;
outputModule - > defaultFormatCO - > addItem ( qt_ ( " Default " ) ,
QVariant ( QString ( " default " ) ) ) ;
typedef vector < Format const * > Formats ;
2011-05-13 22:26:35 +00:00
Formats formats = param_copy . exportableFormats ( true ) ;
2009-04-10 11:06:53 +00:00
Formats : : const_iterator cit = formats . begin ( ) ;
Formats : : const_iterator end = formats . end ( ) ;
for ( ; cit ! = end ; + + cit )
outputModule - > defaultFormatCO - > addItem ( qt_ ( ( * cit ) - > prettyname ( ) ) ,
QVariant ( toqstr ( ( * cit ) - > name ( ) ) ) ) ;
outputModule - > defaultFormatCO - > blockSignals ( false ) ;
}
2010-01-07 10:01:26 +00:00
bool GuiDocument : : isChildIncluded ( string const & child )
{
if ( includeonlys_ . empty ( ) )
return false ;
return ( std : : find ( includeonlys_ . begin ( ) ,
includeonlys_ . end ( ) , child ) ! = includeonlys_ . end ( ) ) ;
}
2008-10-20 21:00:33 +00:00
void GuiDocument : : applyView ( )
2007-04-24 19:37:34 +00:00
{
// preamble
2008-10-20 21:00:33 +00:00
preambleModule - > apply ( bp_ ) ;
A UI for document-local layout information. LyX has supported this for a
while, but without any UI for it. (There has been local layout in the
Customization manual for a long time, in fact.)
Yes, this is an advanced feature. But, absent a layout editor, it is the
one thing that will make it easier, and possible, for "normal users" to
experiment with layout without having to go through reconfiguration,
etc, etc. To keep too many people from shooting themselves, we validate
the layout information before allowing the user to apply it.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@35061 a592a061-630c-0410-9148-cb99ea01b6c8
2010-08-05 22:47:42 +00:00
localLayout - > apply ( bp_ ) ;
2007-04-24 19:37:34 +00:00
2009-08-14 00:52:33 +00:00
// date
bp_ . suppress_date = latexModule - > suppressDateCB - > isChecked ( ) ;
2010-10-13 12:36:53 +00:00
bp_ . use_refstyle = latexModule - > refstyleCB - > isChecked ( ) ;
2009-08-14 00:52:33 +00:00
2007-04-24 19:37:34 +00:00
// biblio
2012-01-09 13:16:38 +00:00
if ( biblioModule - > citeNatbibRB - > isChecked ( ) )
2012-03-01 00:41:30 +00:00
bp_ . setCiteEngine ( " natbib " ) ;
2012-01-09 13:16:38 +00:00
else if ( biblioModule - > citeJurabibRB - > isChecked ( ) )
2012-03-01 00:41:30 +00:00
bp_ . setCiteEngine ( " jurabib " ) ;
else
bp_ . setCiteEngine ( " basic " ) ;
2007-04-24 19:37:34 +00:00
2012-01-09 13:16:38 +00:00
if ( biblioModule - > citeStyleCO - > currentIndex ( ) )
bp_ . setCiteEngineType ( ENGINE_TYPE_NUMERICAL ) ;
else
bp_ . setCiteEngineType ( ENGINE_TYPE_AUTHORYEAR ) ;
2008-10-20 21:00:33 +00:00
bp_ . use_bibtopic =
2007-04-24 19:37:34 +00:00
biblioModule - > bibtopicCB - > isChecked ( ) ;
2011-12-12 14:45:30 +00:00
bp_ . biblio_style = fromqstr ( biblioModule - > bibtexStyleLE - > text ( ) ) ;
2009-05-22 07:20:00 +00:00
string const bibtex_command =
fromqstr ( biblioModule - > bibtexCO - > itemData (
biblioModule - > bibtexCO - > currentIndex ( ) ) . toString ( ) ) ;
2009-05-28 00:25:40 +00:00
string const bibtex_options =
2011-09-24 16:39:20 +00:00
fromqstr ( biblioModule - > bibtexOptionsLE - > text ( ) ) ;
2011-02-04 07:37:12 +00:00
if ( bibtex_command = = " default " | | bibtex_options . empty ( ) )
2009-05-22 07:20:00 +00:00
bp_ . bibtex_command = bibtex_command ;
else
2009-05-28 00:25:40 +00:00
bp_ . bibtex_command = bibtex_command + " " + bibtex_options ;
2009-05-22 07:20:00 +00:00
2011-12-12 16:38:04 +00:00
if ( biblioChanged_ ) {
buffer ( ) . invalidateBibinfoCache ( ) ;
buffer ( ) . removeBiblioTempFiles ( ) ;
}
2009-04-16 07:29:01 +00:00
// Indices
indicesModule - > apply ( bp_ ) ;
2007-04-24 19:37:34 +00:00
// language & quotes
2007-09-19 12:29:08 +00:00
if ( langModule - > defaultencodingRB - > isChecked ( ) ) {
2008-10-20 21:00:33 +00:00
bp_ . inputenc = " auto " ;
2007-04-24 19:37:34 +00:00
} else {
int i = langModule - > encodingCO - > currentIndex ( ) ;
if ( i = = 0 )
2008-10-20 21:00:33 +00:00
bp_ . inputenc = " default " ;
2008-07-11 08:56:17 +00:00
else {
QString const enc_gui =
langModule - > encodingCO - > currentText ( ) ;
Encodings : : const_iterator it = encodings . begin ( ) ;
Encodings : : const_iterator const end = encodings . end ( ) ;
bool found = false ;
for ( ; it ! = end ; + + it ) {
2012-12-30 19:39:33 +00:00
if ( qt_ ( it - > guiName ( ) ) = = enc_gui & &
! it - > unsafe ( ) ) {
2008-10-20 21:00:33 +00:00
bp_ . inputenc = it - > latexName ( ) ;
2008-07-11 08:56:17 +00:00
found = true ;
break ;
}
}
if ( ! found ) {
// should not happen
lyxerr < < " GuiDocument::apply: Unknown encoding! Resetting to default " < < endl ;
2008-10-20 21:00:33 +00:00
bp_ . inputenc = " default " ;
2008-07-11 08:56:17 +00:00
}
}
2007-04-24 19:37:34 +00:00
}
2012-07-01 09:27:42 +00:00
bp_ . quotes_language = ( InsetQuotes : : QuoteLanguage ) langModule - > quoteStyleCO - > itemData (
langModule - > quoteStyleCO - > currentIndex ( ) ) . toInt ( ) ;
2007-04-24 19:37:34 +00:00
2008-05-08 09:18:45 +00:00
QString const lang = langModule - > languageCO - > itemData (
langModule - > languageCO - > currentIndex ( ) ) . toString ( ) ;
2009-11-07 12:50:30 +00:00
bp_ . language = lyx : : languages . getLanguage ( fromqstr ( lang ) ) ;
2011-12-03 22:15:11 +00:00
2011-02-03 14:17:31 +00:00
QString const pack = langModule - > languagePackageCO - > itemData (
langModule - > languagePackageCO - > currentIndex ( ) ) . toString ( ) ;
if ( pack = = " custom " )
bp_ . lang_package =
2011-09-24 16:39:20 +00:00
fromqstr ( langModule - > languagePackageLE - > text ( ) ) ;
2011-02-03 14:17:31 +00:00
else
bp_ . lang_package = fromqstr ( pack ) ;
2007-04-24 19:37:34 +00:00
2010-04-02 22:11:50 +00:00
//color
bp_ . backgroundcolor = set_backgroundcolor ;
2010-04-05 20:31:10 +00:00
bp_ . isbackgroundcolor = is_backgroundcolor ;
2010-04-02 23:39:36 +00:00
bp_ . fontcolor = set_fontcolor ;
bp_ . isfontcolor = is_fontcolor ;
2010-04-02 22:11:50 +00:00
bp_ . notefontcolor = set_notefontcolor ;
2010-04-08 00:14:08 +00:00
bp_ . boxbgcolor = set_boxbgcolor ;
2010-04-02 22:11:50 +00:00
2007-04-24 19:37:34 +00:00
// numbering
2008-10-20 21:00:33 +00:00
if ( bp_ . documentClass ( ) . hasTocLevels ( ) ) {
bp_ . tocdepth = numberingModule - > tocSL - > value ( ) ;
bp_ . secnumdepth = numberingModule - > depthSL - > value ( ) ;
2007-04-24 19:37:34 +00:00
}
// bullets
2008-10-20 21:00:33 +00:00
bp_ . user_defined_bullet ( 0 ) = bulletsModule - > bullet ( 0 ) ;
bp_ . user_defined_bullet ( 1 ) = bulletsModule - > bullet ( 1 ) ;
bp_ . user_defined_bullet ( 2 ) = bulletsModule - > bullet ( 2 ) ;
bp_ . user_defined_bullet ( 3 ) = bulletsModule - > bullet ( 3 ) ;
2007-04-24 19:37:34 +00:00
// packages
2010-11-26 18:42:53 +00:00
bp_ . graphics_driver =
2007-06-01 17:44:04 +00:00
tex_graphics [ latexModule - > psdriverCO - > currentIndex ( ) ] ;
2011-12-03 22:15:11 +00:00
2008-01-05 17:04:56 +00:00
// text layout
2008-02-28 21:04:55 +00:00
int idx = latexModule - > classCO - > currentIndex ( ) ;
if ( idx > = 0 ) {
2012-10-09 05:22:48 +00:00
string const classname = fromqstr ( latexModule - > classCO - > getData ( idx ) ) ;
2008-10-20 21:00:33 +00:00
bp_ . setBaseClass ( classname ) ;
2008-02-28 21:04:55 +00:00
}
2008-01-05 17:04:56 +00:00
This is the last of a series of patches that merges the layout modules development in personal/branches/rgheck back into the tree.
Design goal: Allow the use of layout "modules", which are to LaTeX packages as layout files are to LaTeX document classes. Thus, one could have a module that defined certain character styles, environments, commands, or what have you, and include it in various documents, each of which uses a different document class, without having to modify the layout files themselves. For example, a theorems.module could be used with article.layout to provide support for theorem-type environments, without having to modify article.layout itself, and the same module could be used with book.layout, etc.
This patch adds the GUI for managing modules.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20282 a592a061-630c-0410-9148-cb99ea01b6c8
2007-09-15 01:55:09 +00:00
// Modules
2008-10-20 21:00:33 +00:00
modulesToParams ( bp_ ) ;
This is the last of a series of patches that merges the layout modules development in personal/branches/rgheck back into the tree.
Design goal: Allow the use of layout "modules", which are to LaTeX packages as layout files are to LaTeX document classes. Thus, one could have a module that defined certain character styles, environments, commands, or what have you, and include it in various documents, each of which uses a different document class, without having to modify the layout files themselves. For example, a theorems.module could be used with article.layout to provide support for theorem-type environments, without having to modify article.layout itself, and the same module could be used with book.layout, etc.
This patch adds the GUI for managing modules.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20282 a592a061-630c-0410-9148-cb99ea01b6c8
2007-09-15 01:55:09 +00:00
2009-07-20 08:09:32 +00:00
// Math
2012-01-03 20:51:07 +00:00
vector < string > const & packages = BufferParams : : auto_packages ( ) ;
for ( size_t n = 0 ; n < packages . size ( ) ; + + n ) {
QCheckBox * autoCB = static_cast < QCheckBox * > (
mathsModule - > gridLayout - > itemAtPosition ( 2 * n , 0 ) - > widget ( ) ) ;
if ( autoCB - > isChecked ( ) )
bp_ . use_package ( packages [ n ] , BufferParams : : package_auto ) ;
else {
QCheckBox * alwaysCB = static_cast < QCheckBox * > (
mathsModule - > gridLayout - > itemAtPosition ( 2 * n + 1 , 0 ) - > widget ( ) ) ;
if ( alwaysCB - > isChecked ( ) )
bp_ . use_package ( packages [ n ] , BufferParams : : package_on ) ;
else
bp_ . use_package ( packages [ n ] , BufferParams : : package_off ) ;
}
2011-08-10 03:37:33 +00:00
}
2011-12-03 22:15:11 +00:00
2009-07-20 08:09:32 +00:00
// Page Layout
2007-06-01 17:44:04 +00:00
if ( pageLayoutModule - > pagestyleCO - > currentIndex ( ) = = 0 )
2008-10-20 21:00:33 +00:00
bp_ . pagestyle = " default " ;
2007-06-01 17:44:04 +00:00
else {
2008-09-20 12:57:12 +00:00
QString style_gui = pageLayoutModule - > pagestyleCO - > currentText ( ) ;
for ( size_t i = 0 ; i ! = pagestyles . size ( ) ; + + i )
2007-06-01 17:44:04 +00:00
if ( pagestyles [ i ] . second = = style_gui )
2008-10-20 21:00:33 +00:00
bp_ . pagestyle = pagestyles [ i ] . first ;
2007-06-01 17:44:04 +00:00
}
2007-04-24 19:37:34 +00:00
2009-07-20 08:09:32 +00:00
// Text Layout
2007-04-24 19:37:34 +00:00
switch ( textLayoutModule - > lspacingCO - > currentIndex ( ) ) {
case 0 :
2008-10-20 21:00:33 +00:00
bp_ . spacing ( ) . set ( Spacing : : Single ) ;
2007-04-24 19:37:34 +00:00
break ;
case 1 :
2008-10-20 21:00:33 +00:00
bp_ . spacing ( ) . set ( Spacing : : Onehalf ) ;
2007-04-24 19:37:34 +00:00
break ;
case 2 :
2008-10-20 21:00:33 +00:00
bp_ . spacing ( ) . set ( Spacing : : Double ) ;
2007-04-24 19:37:34 +00:00
break ;
2010-05-14 19:12:59 +00:00
case 3 : {
string s = widgetToDoubleStr ( textLayoutModule - > lspacingLE ) ;
if ( s . empty ( ) )
bp_ . spacing ( ) . set ( Spacing : : Single ) ;
else
bp_ . spacing ( ) . set ( Spacing : : Other , s ) ;
2007-04-24 19:37:34 +00:00
break ;
2010-05-14 19:12:59 +00:00
}
2007-04-24 19:37:34 +00:00
}
if ( textLayoutModule - > twoColumnCB - > isChecked ( ) )
2008-10-20 21:00:33 +00:00
bp_ . columns = 2 ;
2007-04-24 19:37:34 +00:00
else
2008-10-20 21:00:33 +00:00
bp_ . columns = 1 ;
2007-04-24 19:37:34 +00:00
2011-12-07 22:33:25 +00:00
bp_ . justification = textLayoutModule - > justCB - > isChecked ( ) ;
2009-07-19 21:13:27 +00:00
if ( textLayoutModule - > indentRB - > isChecked ( ) ) {
// if paragraphs are separated by an indentation
2008-10-20 21:00:33 +00:00
bp_ . paragraph_separation = BufferParams : : ParagraphIndentSeparation ;
2009-07-19 21:13:27 +00:00
switch ( textLayoutModule - > indentCO - > currentIndex ( ) ) {
case 0 :
bp_ . setIndentation ( HSpace ( HSpace : : DEFAULT ) ) ;
break ;
case 1 : {
HSpace indent = HSpace (
widgetsToLength ( textLayoutModule - > indentLE ,
textLayoutModule - > indentLengthCO )
) ;
bp_ . setIndentation ( indent ) ;
break ;
}
default :
// this should never happen
bp_ . setIndentation ( HSpace ( HSpace : : DEFAULT ) ) ;
break ;
}
} else {
// if paragraphs are separated by a skip
2008-10-20 21:00:33 +00:00
bp_ . paragraph_separation = BufferParams : : ParagraphSkipSeparation ;
2009-07-19 21:13:27 +00:00
switch ( textLayoutModule - > skipCO - > currentIndex ( ) ) {
case 0 :
bp_ . setDefSkip ( VSpace ( VSpace : : SMALLSKIP ) ) ;
break ;
case 1 :
bp_ . setDefSkip ( VSpace ( VSpace : : MEDSKIP ) ) ;
break ;
case 2 :
bp_ . setDefSkip ( VSpace ( VSpace : : BIGSKIP ) ) ;
break ;
case 3 :
{
VSpace vs = VSpace (
widgetsToLength ( textLayoutModule - > skipLE ,
2007-04-24 19:37:34 +00:00
textLayoutModule - > skipLengthCO )
2009-07-19 21:13:27 +00:00
) ;
bp_ . setDefSkip ( vs ) ;
break ;
}
default :
// this should never happen
bp_ . setDefSkip ( VSpace ( VSpace : : MEDSKIP ) ) ;
break ;
}
2007-04-24 19:37:34 +00:00
}
2008-10-20 21:00:33 +00:00
bp_ . options =
2007-04-24 19:37:34 +00:00
fromqstr ( latexModule - > optionsLE - > text ( ) ) ;
2008-10-20 21:00:33 +00:00
bp_ . use_default_options =
2008-10-12 09:36:00 +00:00
latexModule - > defaultOptionsCB - > isChecked ( ) ;
2008-04-28 16:38:56 +00:00
if ( latexModule - > childDocGB - > isChecked ( ) )
2008-10-20 21:00:33 +00:00
bp_ . master =
2008-04-28 16:38:56 +00:00
fromqstr ( latexModule - > childDocLE - > text ( ) ) ;
else
2008-10-20 21:00:33 +00:00
bp_ . master = string ( ) ;
2008-04-28 16:38:56 +00:00
2010-01-07 10:01:26 +00:00
// Master/Child
bp_ . clearIncludedChildren ( ) ;
if ( masterChildModule - > includeonlyRB - > isChecked ( ) ) {
list < string > : : const_iterator it = includeonlys_ . begin ( ) ;
for ( ; it ! = includeonlys_ . end ( ) ; + + it ) {
bp_ . addIncludedChildren ( * it ) ;
}
}
2010-01-10 13:25:41 +00:00
bp_ . maintain_unincluded_children =
masterChildModule - > maintainAuxCB - > isChecked ( ) ;
2010-01-07 10:01:26 +00:00
2009-07-20 08:09:32 +00:00
// Float Placement
2008-10-20 21:00:33 +00:00
bp_ . float_placement = floatModule - > get ( ) ;
2007-04-24 19:37:34 +00:00
2009-07-20 08:09:32 +00:00
// Listings
// text should have passed validation
bp_ . listings_params =
InsetListingsParams ( fromqstr ( listingsModule - > listingsED - > toPlainText ( ) ) ) . params ( ) ;
2009-04-10 11:06:53 +00:00
// output
2010-11-26 18:42:53 +00:00
bp_ . default_output_format = fromqstr ( outputModule - > defaultFormatCO - > itemData (
2009-04-10 11:06:53 +00:00
outputModule - > defaultFormatCO - > currentIndex ( ) ) . toString ( ) ) ;
2010-11-26 09:42:03 +00:00
bool const nontexfonts = fontModule - > osFontsCB - > isChecked ( ) ;
bp_ . useNonTeXFonts = nontexfonts ;
2007-04-24 19:37:34 +00:00
2010-05-25 11:36:00 +00:00
bp_ . output_sync = outputModule - > outputsyncCB - > isChecked ( ) ;
2011-12-06 22:17:26 +00:00
2010-05-25 11:36:00 +00:00
bp_ . output_sync_macro = fromqstr ( outputModule - > synccustomCB - > currentText ( ) ) ;
2010-04-21 15:20:31 +00:00
int mathfmt = outputModule - > mathoutCB - > currentIndex ( ) ;
if ( mathfmt = = - 1 )
mathfmt = 0 ;
BufferParams : : MathOutput const mo =
static_cast < BufferParams : : MathOutput > ( mathfmt ) ;
bp_ . html_math_output = mo ;
bp_ . html_be_strict = outputModule - > strictCB - > isChecked ( ) ;
2011-12-06 22:17:26 +00:00
bp_ . html_css_as_file = outputModule - > cssCB - > isChecked ( ) ;
2010-04-21 15:20:31 +00:00
bp_ . html_math_img_scale = outputModule - > mathimgSB - > value ( ) ;
2009-04-10 11:06:53 +00:00
// fonts
2011-04-08 20:37:17 +00:00
bp_ . fonts_roman =
fromqstr ( fontModule - > fontsRomanCO - >
itemData ( fontModule - > fontsRomanCO - > currentIndex ( ) ) . toString ( ) ) ;
bp_ . fonts_sans =
fromqstr ( fontModule - > fontsSansCO - >
itemData ( fontModule - > fontsSansCO - > currentIndex ( ) ) . toString ( ) ) ;
bp_ . fonts_typewriter =
fromqstr ( fontModule - > fontsTypewriterCO - >
itemData ( fontModule - > fontsTypewriterCO - > currentIndex ( ) ) . toString ( ) ) ;
2007-04-24 19:37:34 +00:00
2012-09-22 15:44:00 +00:00
bp_ . fonts_math =
fromqstr ( fontModule - > fontsMathCO - >
itemData ( fontModule - > fontsMathCO - > currentIndex ( ) ) . toString ( ) ) ;
2012-08-16 11:23:39 +00:00
QString const fontenc =
fontModule - > fontencCO - > itemData ( fontModule - > fontencCO - > currentIndex ( ) ) . toString ( ) ;
if ( fontenc = = " custom " )
2009-11-29 14:43:00 +00:00
bp_ . fontenc = fromqstr ( fontModule - > fontencLE - > text ( ) ) ;
2012-08-16 11:23:39 +00:00
else
bp_ . fontenc = fromqstr ( fontenc ) ;
2009-11-29 14:43:00 +00:00
2010-11-26 18:32:29 +00:00
bp_ . fonts_cjk =
2008-06-05 06:18:34 +00:00
fromqstr ( fontModule - > cjkFontLE - > text ( ) ) ;
2010-11-26 18:32:29 +00:00
bp_ . fonts_sans_scale = fontModule - > scaleSansSB - > value ( ) ;
2007-04-24 19:37:34 +00:00
2010-11-26 18:32:29 +00:00
bp_ . fonts_typewriter_scale = fontModule - > scaleTypewriterSB - > value ( ) ;
2007-04-24 19:37:34 +00:00
2010-11-26 18:32:29 +00:00
bp_ . fonts_expert_sc = fontModule - > fontScCB - > isChecked ( ) ;
2007-04-24 19:37:34 +00:00
2010-11-26 18:32:29 +00:00
bp_ . fonts_old_figures = fontModule - > fontOsfCB - > isChecked ( ) ;
2007-04-24 19:37:34 +00:00
2010-11-26 09:42:03 +00:00
if ( nontexfonts )
2010-11-26 18:32:29 +00:00
bp_ . fonts_default_family = " default " ;
2009-04-07 08:39:56 +00:00
else
2010-11-26 18:32:29 +00:00
bp_ . fonts_default_family = GuiDocument : : fontfamilies [
2009-04-07 08:39:56 +00:00
fontModule - > fontsDefaultCO - > currentIndex ( ) ] ;
2007-04-24 19:37:34 +00:00
if ( fontModule - > fontsizeCO - > currentIndex ( ) = = 0 )
2008-10-20 21:00:33 +00:00
bp_ . fontsize = " default " ;
2007-04-24 19:37:34 +00:00
else
2008-10-20 21:00:33 +00:00
bp_ . fontsize =
2007-04-24 19:37:34 +00:00
fromqstr ( fontModule - > fontsizeCO - > currentText ( ) ) ;
// paper
2008-10-20 21:00:33 +00:00
bp_ . papersize = PAPER_SIZE (
2007-04-24 19:37:34 +00:00
pageLayoutModule - > papersizeCO - > currentIndex ( ) ) ;
2008-10-20 21:00:33 +00:00
bp_ . paperwidth = widgetsToLength ( pageLayoutModule - > paperwidthLE ,
2007-04-24 19:37:34 +00:00
pageLayoutModule - > paperwidthUnitCO ) ;
2008-10-20 21:00:33 +00:00
bp_ . paperheight = widgetsToLength ( pageLayoutModule - > paperheightLE ,
2007-04-24 19:37:34 +00:00
pageLayoutModule - > paperheightUnitCO ) ;
if ( pageLayoutModule - > facingPagesCB - > isChecked ( ) )
2008-10-20 21:00:33 +00:00
bp_ . sides = TwoSides ;
2007-04-24 19:37:34 +00:00
else
2008-10-20 21:00:33 +00:00
bp_ . sides = OneSide ;
2007-04-24 19:37:34 +00:00
if ( pageLayoutModule - > landscapeRB - > isChecked ( ) )
2008-10-20 21:00:33 +00:00
bp_ . orientation = ORIENTATION_LANDSCAPE ;
2007-04-24 19:37:34 +00:00
else
2008-10-20 21:00:33 +00:00
bp_ . orientation = ORIENTATION_PORTRAIT ;
2007-04-24 19:37:34 +00:00
// margins
2010-05-18 02:56:36 +00:00
bp_ . use_geometry = ! marginsModule - > marginCB - > isChecked ( ) ;
2007-04-24 19:37:34 +00:00
2008-03-08 07:59:47 +00:00
Ui : : MarginsUi const * m = marginsModule ;
2007-04-24 19:37:34 +00:00
2008-10-20 21:00:33 +00:00
bp_ . leftmargin = widgetsToLength ( m - > innerLE , m - > innerUnit ) ;
bp_ . topmargin = widgetsToLength ( m - > topLE , m - > topUnit ) ;
bp_ . rightmargin = widgetsToLength ( m - > outerLE , m - > outerUnit ) ;
bp_ . bottommargin = widgetsToLength ( m - > bottomLE , m - > bottomUnit ) ;
bp_ . headheight = widgetsToLength ( m - > headheightLE , m - > headheightUnit ) ;
bp_ . headsep = widgetsToLength ( m - > headsepLE , m - > headsepUnit ) ;
bp_ . footskip = widgetsToLength ( m - > footskipLE , m - > footskipUnit ) ;
bp_ . columnsep = widgetsToLength ( m - > columnsepLE , m - > columnsepUnit ) ;
2007-04-24 19:37:34 +00:00
2009-07-11 10:53:29 +00:00
// branches
2008-10-20 21:00:33 +00:00
branchesModule - > apply ( bp_ ) ;
2007-09-20 22:31:18 +00:00
// PDF support
2008-10-20 21:00:33 +00:00
PDFOptions & pdf = bp_ . pdfoptions ( ) ;
2007-09-22 22:20:15 +00:00
pdf . use_hyperref = pdfSupportModule - > use_hyperrefGB - > isChecked ( ) ;
2007-09-21 01:00:31 +00:00
pdf . title = fromqstr ( pdfSupportModule - > titleLE - > text ( ) ) ;
pdf . author = fromqstr ( pdfSupportModule - > authorLE - > text ( ) ) ;
pdf . subject = fromqstr ( pdfSupportModule - > subjectLE - > text ( ) ) ;
pdf . keywords = fromqstr ( pdfSupportModule - > keywordsLE - > text ( ) ) ;
pdf . bookmarks = pdfSupportModule - > bookmarksGB - > isChecked ( ) ;
pdf . bookmarksnumbered = pdfSupportModule - > bookmarksnumberedCB - > isChecked ( ) ;
pdf . bookmarksopen = pdfSupportModule - > bookmarksopenGB - > isChecked ( ) ;
2007-09-22 22:20:15 +00:00
pdf . bookmarksopenlevel = pdfSupportModule - > bookmarksopenlevelSB - > value ( ) ;
2007-09-20 22:31:18 +00:00
2007-09-21 01:00:31 +00:00
pdf . breaklinks = pdfSupportModule - > breaklinksCB - > isChecked ( ) ;
pdf . pdfborder = pdfSupportModule - > pdfborderCB - > isChecked ( ) ;
2007-10-10 00:34:23 +00:00
pdf . pdfusetitle = pdfSupportModule - > pdfusetitleCB - > isChecked ( ) ;
2007-09-21 01:00:31 +00:00
pdf . colorlinks = pdfSupportModule - > colorlinksCB - > isChecked ( ) ;
2008-10-13 16:01:02 +00:00
pdf . backref =
backref_opts [ pdfSupportModule - > backrefCO - > currentIndex ( ) ] ;
2007-09-20 22:31:18 +00:00
if ( pdfSupportModule - > fullscreenCB - > isChecked ( ) )
2007-09-21 01:00:31 +00:00
pdf . pagemode = pdf . pagemode_fullscreen ;
2007-09-22 22:20:15 +00:00
else
pdf . pagemode . clear ( ) ;
2008-03-05 01:14:15 +00:00
pdf . quoted_options = pdf . quoted_options_check (
fromqstr ( pdfSupportModule - > optionsLE - > text ( ) ) ) ;
2007-04-24 19:37:34 +00:00
}
2008-10-14 16:59:28 +00:00
void GuiDocument : : paramsToDialog ( )
2007-04-24 19:37:34 +00:00
{
// set the default unit
2011-10-27 11:49:15 +00:00
Length : : UNIT const default_unit = Length : : defaultUnit ( ) ;
2007-04-24 19:37:34 +00:00
// preamble
2008-10-14 16:59:28 +00:00
preambleModule - > update ( bp_ , id ( ) ) ;
A UI for document-local layout information. LyX has supported this for a
while, but without any UI for it. (There has been local layout in the
Customization manual for a long time, in fact.)
Yes, this is an advanced feature. But, absent a layout editor, it is the
one thing that will make it easier, and possible, for "normal users" to
experiment with layout without having to go through reconfiguration,
etc, etc. To keep too many people from shooting themselves, we validate
the layout information before allowing the user to apply it.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@35061 a592a061-630c-0410-9148-cb99ea01b6c8
2010-08-05 22:47:42 +00:00
localLayout - > update ( bp_ , id ( ) ) ;
2007-04-24 19:37:34 +00:00
2009-08-14 00:52:33 +00:00
// date
latexModule - > suppressDateCB - > setChecked ( bp_ . suppress_date ) ;
2010-10-13 12:36:53 +00:00
latexModule - > refstyleCB - > setChecked ( bp_ . use_refstyle ) ;
2009-08-14 00:52:33 +00:00
2007-04-24 19:37:34 +00:00
// biblio
2012-03-01 00:41:30 +00:00
string const cite_engine = bp_ . citeEngine ( ) . list ( ) . front ( ) ;
2007-04-24 19:37:34 +00:00
biblioModule - > citeDefaultRB - > setChecked (
2012-03-01 00:41:30 +00:00
cite_engine = = " basic " ) ;
biblioModule - > citeJurabibRB - > setChecked (
cite_engine = = " jurabib " ) ;
2007-04-24 19:37:34 +00:00
biblioModule - > citeNatbibRB - > setChecked (
2012-03-01 00:41:30 +00:00
cite_engine = = " natbib " ) ;
2007-04-24 19:37:34 +00:00
biblioModule - > citeStyleCO - > setCurrentIndex (
2012-01-09 13:16:38 +00:00
bp_ . citeEngineType ( ) = = ENGINE_TYPE_NUMERICAL ) ;
2007-04-24 19:37:34 +00:00
2012-03-01 00:41:30 +00:00
updateEngineType ( documentClass ( ) . opt_enginetype ( ) ,
bp_ . citeEngineType ( ) ) ;
2007-04-24 19:37:34 +00:00
biblioModule - > bibtopicCB - > setChecked (
2008-10-14 16:59:28 +00:00
bp_ . use_bibtopic ) ;
2007-04-24 19:37:34 +00:00
2011-12-12 14:45:30 +00:00
biblioModule - > bibtexStyleLE - > setText ( toqstr ( bp_ . biblio_style ) ) ;
2009-05-22 07:20:00 +00:00
string command ;
string options =
split ( bp_ . bibtex_command , command , ' ' ) ;
int const bpos = biblioModule - > bibtexCO - > findData ( toqstr ( command ) ) ;
if ( bpos ! = - 1 ) {
biblioModule - > bibtexCO - > setCurrentIndex ( bpos ) ;
2011-09-24 16:39:20 +00:00
biblioModule - > bibtexOptionsLE - > setText ( toqstr ( options ) . trimmed ( ) ) ;
2009-05-22 07:20:00 +00:00
} else {
2011-02-04 07:37:12 +00:00
// We reset to default if we do not know the specified compiler
// This is for security reasons
2011-02-03 15:03:38 +00:00
biblioModule - > bibtexCO - > setCurrentIndex (
2011-02-04 07:37:12 +00:00
biblioModule - > bibtexCO - > findData ( toqstr ( " default " ) ) ) ;
2011-09-24 16:39:20 +00:00
biblioModule - > bibtexOptionsLE - > clear ( ) ;
2009-05-22 07:20:00 +00:00
}
2011-09-24 16:39:20 +00:00
biblioModule - > bibtexOptionsLE - > setEnabled (
2009-05-22 07:20:00 +00:00
biblioModule - > bibtexCO - > currentIndex ( ) ! = 0 ) ;
2011-12-13 12:50:16 +00:00
biblioChanged_ = false ;
2009-04-16 07:29:01 +00:00
// indices
indicesModule - > update ( bp_ ) ;
2007-04-24 19:37:34 +00:00
// language & quotes
2008-05-08 09:18:45 +00:00
int const pos = langModule - > languageCO - > findData ( toqstr (
2008-10-14 16:59:28 +00:00
bp_ . language - > lang ( ) ) ) ;
2007-04-24 19:37:34 +00:00
langModule - > languageCO - > setCurrentIndex ( pos ) ;
langModule - > quoteStyleCO - > setCurrentIndex (
2008-10-14 16:59:28 +00:00
bp_ . quotes_language ) ;
2007-04-24 19:37:34 +00:00
2007-09-19 12:29:08 +00:00
bool default_enc = true ;
2008-10-14 16:59:28 +00:00
if ( bp_ . inputenc ! = " auto " ) {
2007-09-19 12:29:08 +00:00
default_enc = false ;
2008-10-14 16:59:28 +00:00
if ( bp_ . inputenc = = " default " ) {
2007-04-24 19:37:34 +00:00
langModule - > encodingCO - > setCurrentIndex ( 0 ) ;
} else {
2008-07-11 08:56:17 +00:00
string enc_gui ;
Encodings : : const_iterator it = encodings . begin ( ) ;
Encodings : : const_iterator const end = encodings . end ( ) ;
for ( ; it ! = end ; + + it ) {
2012-12-30 19:39:33 +00:00
if ( it - > latexName ( ) = = bp_ . inputenc & &
! it - > unsafe ( ) ) {
2008-07-11 08:56:17 +00:00
enc_gui = it - > guiName ( ) ;
break ;
}
}
2007-04-24 19:37:34 +00:00
int const i = langModule - > encodingCO - > findText (
2008-07-11 08:56:17 +00:00
qt_ ( enc_gui ) ) ;
2007-04-24 19:37:34 +00:00
if ( i > = 0 )
langModule - > encodingCO - > setCurrentIndex ( i ) ;
else
// unknown encoding. Set to default.
2007-09-19 12:29:08 +00:00
default_enc = true ;
2007-04-24 19:37:34 +00:00
}
}
2007-09-19 12:29:08 +00:00
langModule - > defaultencodingRB - > setChecked ( default_enc ) ;
langModule - > otherencodingRB - > setChecked ( ! default_enc ) ;
2007-04-24 19:37:34 +00:00
2011-02-03 14:17:31 +00:00
int const p = langModule - > languagePackageCO - > findData ( toqstr ( bp_ . lang_package ) ) ;
if ( p = = - 1 ) {
langModule - > languagePackageCO - > setCurrentIndex (
langModule - > languagePackageCO - > findData ( " custom " ) ) ;
2011-09-24 16:39:20 +00:00
langModule - > languagePackageLE - > setText ( toqstr ( bp_ . lang_package ) ) ;
2011-02-03 14:17:31 +00:00
} else {
langModule - > languagePackageCO - > setCurrentIndex ( p ) ;
2011-09-24 16:39:20 +00:00
langModule - > languagePackageLE - > clear ( ) ;
2011-02-03 14:17:31 +00:00
}
2010-04-02 22:11:50 +00:00
//color
2010-04-02 23:39:36 +00:00
if ( bp_ . isfontcolor ) {
colorModule - > fontColorPB - > setStyleSheet (
colorButtonStyleSheet ( rgb2qcolor ( bp_ . fontcolor ) ) ) ;
}
set_fontcolor = bp_ . fontcolor ;
is_fontcolor = bp_ . isfontcolor ;
2010-04-02 22:11:50 +00:00
colorModule - > noteFontColorPB - > setStyleSheet (
colorButtonStyleSheet ( rgb2qcolor ( bp_ . notefontcolor ) ) ) ;
set_notefontcolor = bp_ . notefontcolor ;
2010-04-02 23:39:36 +00:00
2010-04-05 20:31:10 +00:00
if ( bp_ . isbackgroundcolor ) {
colorModule - > backgroundPB - > setStyleSheet (
colorButtonStyleSheet ( rgb2qcolor ( bp_ . backgroundcolor ) ) ) ;
}
2010-04-02 22:11:50 +00:00
set_backgroundcolor = bp_ . backgroundcolor ;
2010-04-05 20:31:10 +00:00
is_backgroundcolor = bp_ . isbackgroundcolor ;
2010-04-02 22:11:50 +00:00
2010-04-08 00:14:08 +00:00
colorModule - > boxBackgroundPB - > setStyleSheet (
colorButtonStyleSheet ( rgb2qcolor ( bp_ . boxbgcolor ) ) ) ;
set_boxbgcolor = bp_ . boxbgcolor ;
2007-04-24 19:37:34 +00:00
// numbering
2008-02-28 21:04:55 +00:00
int const min_toclevel = documentClass ( ) . min_toclevel ( ) ;
int const max_toclevel = documentClass ( ) . max_toclevel ( ) ;
if ( documentClass ( ) . hasTocLevels ( ) ) {
2007-04-24 19:37:34 +00:00
numberingModule - > setEnabled ( true ) ;
numberingModule - > depthSL - > setMinimum ( min_toclevel - 1 ) ;
numberingModule - > depthSL - > setMaximum ( max_toclevel ) ;
2008-10-14 16:59:28 +00:00
numberingModule - > depthSL - > setValue ( bp_ . secnumdepth ) ;
2007-04-24 19:37:34 +00:00
numberingModule - > tocSL - > setMaximum ( min_toclevel - 1 ) ;
numberingModule - > tocSL - > setMaximum ( max_toclevel ) ;
2008-10-14 16:59:28 +00:00
numberingModule - > tocSL - > setValue ( bp_ . tocdepth ) ;
2007-04-24 19:37:34 +00:00
updateNumbering ( ) ;
} else {
numberingModule - > setEnabled ( false ) ;
numberingModule - > tocTW - > clear ( ) ;
}
// bullets
2008-10-14 16:59:28 +00:00
bulletsModule - > setBullet ( 0 , bp_ . user_defined_bullet ( 0 ) ) ;
bulletsModule - > setBullet ( 1 , bp_ . user_defined_bullet ( 1 ) ) ;
bulletsModule - > setBullet ( 2 , bp_ . user_defined_bullet ( 2 ) ) ;
bulletsModule - > setBullet ( 3 , bp_ . user_defined_bullet ( 3 ) ) ;
2007-04-24 19:37:34 +00:00
bulletsModule - > init ( ) ;
// packages
2010-11-26 18:42:53 +00:00
int nitem = findToken ( tex_graphics , bp_ . graphics_driver ) ;
2007-06-01 17:44:04 +00:00
if ( nitem > = 0 )
latexModule - > psdriverCO - > setCurrentIndex ( nitem ) ;
This is the last of a series of patches that merges the layout modules development in personal/branches/rgheck back into the tree.
Design goal: Allow the use of layout "modules", which are to LaTeX packages as layout files are to LaTeX document classes. Thus, one could have a module that defined certain character styles, environments, commands, or what have you, and include it in various documents, each of which uses a different document class, without having to modify the layout files themselves. For example, a theorems.module could be used with article.layout to provide support for theorem-type environments, without having to modify article.layout itself, and the same module could be used with book.layout, etc.
This patch adds the GUI for managing modules.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20282 a592a061-630c-0410-9148-cb99ea01b6c8
2007-09-15 01:55:09 +00:00
updateModuleInfo ( ) ;
2011-12-03 22:15:11 +00:00
2012-01-03 20:51:07 +00:00
vector < string > const & packages = BufferParams : : auto_packages ( ) ;
for ( size_t n = 0 ; n < packages . size ( ) ; + + n ) {
QCheckBox * alwaysCB = static_cast < QCheckBox * > (
mathsModule - > gridLayout - > itemAtPosition ( 2 * n + 1 , 0 ) - > widget ( ) ) ;
alwaysCB - > setChecked ( bp_ . use_package ( packages [ n ] ) = = BufferParams : : package_on ) ;
QCheckBox * autoCB = static_cast < QCheckBox * > (
mathsModule - > gridLayout - > itemAtPosition ( 2 * n , 0 ) - > widget ( ) ) ;
autoCB - > setChecked ( bp_ . use_package ( packages [ n ] ) = = BufferParams : : package_auto ) ;
}
2011-08-10 03:37:33 +00:00
2008-10-14 16:59:28 +00:00
switch ( bp_ . spacing ( ) . getSpace ( ) ) {
2007-04-24 19:37:34 +00:00
case Spacing : : Other : nitem = 3 ; break ;
case Spacing : : Double : nitem = 2 ; break ;
case Spacing : : Onehalf : nitem = 1 ; break ;
case Spacing : : Default : case Spacing : : Single : nitem = 0 ; break ;
}
// text layout
2008-10-14 16:59:28 +00:00
string const & layoutID = bp_ . baseClassID ( ) ;
2008-03-01 22:08:16 +00:00
setLayoutComboByIDString ( layoutID ) ;
2008-02-28 21:04:55 +00:00
updatePagestyle ( documentClass ( ) . opt_pagestyle ( ) ,
2008-10-14 16:59:28 +00:00
bp_ . pagestyle ) ;
2007-04-24 19:37:34 +00:00
textLayoutModule - > lspacingCO - > setCurrentIndex ( nitem ) ;
2008-10-14 16:59:28 +00:00
if ( bp_ . spacing ( ) . getSpace ( ) = = Spacing : : Other ) {
2009-07-12 15:44:26 +00:00
doubleToWidget ( textLayoutModule - > lspacingLE ,
bp_ . spacing ( ) . getValueAsString ( ) ) ;
2007-04-24 19:37:34 +00:00
}
setLSpacing ( nitem ) ;
2009-07-19 21:13:27 +00:00
if ( bp_ . paragraph_separation = = BufferParams : : ParagraphIndentSeparation ) {
2007-04-24 19:37:34 +00:00
textLayoutModule - > indentRB - > setChecked ( true ) ;
2009-07-19 21:13:27 +00:00
string indentation = bp_ . getIndentation ( ) . asLyXCommand ( ) ;
int indent = 0 ;
2009-07-20 01:34:09 +00:00
if ( indentation ! = " default " ) {
2009-07-19 21:13:27 +00:00
lengthToWidgets ( textLayoutModule - > indentLE ,
textLayoutModule - > indentLengthCO ,
2011-10-27 11:49:15 +00:00
indentation , default_unit ) ;
2009-07-19 21:13:27 +00:00
indent = 1 ;
}
textLayoutModule - > indentCO - > setCurrentIndex ( indent ) ;
setIndent ( indent ) ;
} else {
2007-04-24 19:37:34 +00:00
textLayoutModule - > skipRB - > setChecked ( true ) ;
2009-07-19 21:13:27 +00:00
int skip = 0 ;
switch ( bp_ . getDefSkip ( ) . kind ( ) ) {
case VSpace : : SMALLSKIP :
skip = 0 ;
break ;
case VSpace : : MEDSKIP :
skip = 1 ;
break ;
case VSpace : : BIGSKIP :
skip = 2 ;
break ;
case VSpace : : LENGTH :
{
skip = 3 ;
string const length = bp_ . getDefSkip ( ) . asLyXCommand ( ) ;
lengthToWidgets ( textLayoutModule - > skipLE ,
textLayoutModule - > skipLengthCO ,
2011-10-27 11:49:15 +00:00
length , default_unit ) ;
2009-07-19 21:13:27 +00:00
break ;
}
default :
skip = 0 ;
break ;
}
textLayoutModule - > skipCO - > setCurrentIndex ( skip ) ;
setSkip ( skip ) ;
2007-04-24 19:37:34 +00:00
}
textLayoutModule - > twoColumnCB - > setChecked (
2008-10-14 16:59:28 +00:00
bp_ . columns = = 2 ) ;
2011-12-07 22:33:25 +00:00
textLayoutModule - > justCB - > setChecked ( bp_ . justification ) ;
2007-05-28 22:27:45 +00:00
2008-10-14 16:59:28 +00:00
if ( ! bp_ . options . empty ( ) ) {
2007-04-24 19:37:34 +00:00
latexModule - > optionsLE - > setText (
2008-10-14 16:59:28 +00:00
toqstr ( bp_ . options ) ) ;
2007-04-24 19:37:34 +00:00
} else {
2007-09-05 20:33:29 +00:00
latexModule - > optionsLE - > setText ( QString ( ) ) ;
2007-04-24 19:37:34 +00:00
}
2008-10-14 17:35:49 +00:00
// latex
2008-10-12 09:36:00 +00:00
latexModule - > defaultOptionsCB - > setChecked (
2008-10-14 17:35:49 +00:00
bp_ . use_default_options ) ;
2008-10-23 00:27:03 +00:00
updateSelectedModules ( ) ;
selectionManager - > updateProvidedModules (
bp_ . baseClass ( ) - > providedModules ( ) ) ;
selectionManager - > updateExcludedModules (
bp_ . baseClass ( ) - > excludedModules ( ) ) ;
2008-10-12 09:36:00 +00:00
if ( ! documentClass ( ) . options ( ) . empty ( ) ) {
latexModule - > defaultOptionsLE - > setText (
toqstr ( documentClass ( ) . options ( ) ) ) ;
} else {
latexModule - > defaultOptionsLE - > setText (
toqstr ( _ ( " [No options predefined] " ) ) ) ;
}
latexModule - > defaultOptionsLE - > setEnabled (
2008-10-14 16:59:28 +00:00
bp_ . use_default_options
2008-10-12 09:36:00 +00:00
& & ! documentClass ( ) . options ( ) . empty ( ) ) ;
latexModule - > defaultOptionsCB - > setEnabled (
! documentClass ( ) . options ( ) . empty ( ) ) ;
2008-10-14 16:59:28 +00:00
if ( ! bp_ . master . empty ( ) ) {
2008-04-28 16:38:56 +00:00
latexModule - > childDocGB - > setChecked ( true ) ;
latexModule - > childDocLE - > setText (
2008-10-14 16:59:28 +00:00
toqstr ( bp_ . master ) ) ;
2008-04-28 16:38:56 +00:00
} else {
latexModule - > childDocLE - > setText ( QString ( ) ) ;
latexModule - > childDocGB - > setChecked ( false ) ;
}
2010-01-07 10:01:26 +00:00
// Master/Child
2010-10-13 12:43:13 +00:00
if ( ! bufferview ( ) | | ! buffer ( ) . hasChildren ( ) ) {
2010-01-10 13:25:41 +00:00
masterChildModule - > childrenTW - > clear ( ) ;
2010-01-07 10:01:26 +00:00
includeonlys_ . clear ( ) ;
2010-01-10 14:46:39 +00:00
docPS - > showPanel ( qt_ ( " Child Documents " ) , false ) ;
if ( docPS - > isCurrentPanel ( qt_ ( " Child Documents " ) ) )
docPS - > setCurrentPanel ( qt_ ( " Document Class " ) ) ;
2010-01-07 10:01:26 +00:00
} else {
2010-01-10 14:46:39 +00:00
docPS - > showPanel ( qt_ ( " Child Documents " ) , true ) ;
2010-01-07 10:01:26 +00:00
masterChildModule - > setEnabled ( true ) ;
includeonlys_ = bp_ . getIncludedChildren ( ) ;
updateIncludeonlys ( ) ;
}
2010-01-10 13:25:41 +00:00
masterChildModule - > maintainAuxCB - > setChecked (
bp_ . maintain_unincluded_children ) ;
2010-01-07 10:01:26 +00:00
2009-07-20 08:09:32 +00:00
// Float Settings
2008-10-14 16:59:28 +00:00
floatModule - > set ( bp_ . float_placement ) ;
2007-04-24 19:37:34 +00:00
2009-07-20 08:09:32 +00:00
// ListingsSettings
// break listings_params to multiple lines
string lstparams =
InsetListingsParams ( bp_ . listings_params ) . separatedParams ( ) ;
listingsModule - > listingsED - > setPlainText ( toqstr ( lstparams ) ) ;
2012-01-31 11:30:52 +00:00
// Fonts
2011-02-09 08:23:11 +00:00
bool const os_fonts_available =
bp_ . baseClass ( ) - > outputType ( ) = = lyx : : LATEX
& & LaTeXFeatures : : isAvailable ( " fontspec " ) ;
fontModule - > osFontsCB - > setEnabled ( os_fonts_available ) ;
2010-11-26 09:42:03 +00:00
fontModule - > osFontsCB - > setChecked (
2011-02-09 08:23:11 +00:00
os_fonts_available & & bp_ . useNonTeXFonts ) ;
2008-02-28 21:04:55 +00:00
updateFontsize ( documentClass ( ) . opt_fontsize ( ) ,
2008-10-14 16:59:28 +00:00
bp_ . fontsize ) ;
2007-04-24 19:37:34 +00:00
2011-04-08 20:37:17 +00:00
QString font = toqstr ( bp_ . fonts_roman ) ;
int rpos = fontModule - > fontsRomanCO - > findData ( font ) ;
if ( rpos = = - 1 ) {
rpos = fontModule - > fontsRomanCO - > count ( ) ;
fontModule - > fontsRomanCO - > addItem ( font + qt_ ( " (not installed) " ) , font ) ;
}
fontModule - > fontsRomanCO - > setCurrentIndex ( rpos ) ;
font = toqstr ( bp_ . fonts_sans ) ;
int spos = fontModule - > fontsSansCO - > findData ( font ) ;
if ( spos = = - 1 ) {
spos = fontModule - > fontsSansCO - > count ( ) ;
fontModule - > fontsSansCO - > addItem ( font + qt_ ( " (not installed) " ) , font ) ;
}
fontModule - > fontsSansCO - > setCurrentIndex ( spos ) ;
font = toqstr ( bp_ . fonts_typewriter ) ;
int tpos = fontModule - > fontsTypewriterCO - > findData ( font ) ;
if ( tpos = = - 1 ) {
tpos = fontModule - > fontsTypewriterCO - > count ( ) ;
fontModule - > fontsTypewriterCO - > addItem ( font + qt_ ( " (not installed) " ) , font ) ;
}
fontModule - > fontsTypewriterCO - > setCurrentIndex ( tpos ) ;
2012-09-22 15:44:00 +00:00
font = toqstr ( bp_ . fonts_math ) ;
int mpos = fontModule - > fontsMathCO - > findData ( font ) ;
if ( mpos = = - 1 ) {
mpos = fontModule - > fontsMathCO - > count ( ) ;
fontModule - > fontsMathCO - > addItem ( font + qt_ ( " (not installed) " ) , font ) ;
}
fontModule - > fontsMathCO - > setCurrentIndex ( mpos ) ;
2011-02-09 08:23:11 +00:00
if ( bp_ . useNonTeXFonts & & os_fonts_available ) {
2009-11-29 14:43:00 +00:00
fontModule - > fontencLA - > setEnabled ( false ) ;
fontModule - > fontencCO - > setEnabled ( false ) ;
fontModule - > fontencLE - > setEnabled ( false ) ;
2009-04-06 06:58:30 +00:00
} else {
2009-11-29 14:43:00 +00:00
fontModule - > fontencLA - > setEnabled ( true ) ;
fontModule - > fontencCO - > setEnabled ( true ) ;
fontModule - > fontencLE - > setEnabled ( true ) ;
2011-04-08 20:37:17 +00:00
romanChanged ( rpos ) ;
sansChanged ( spos ) ;
ttChanged ( tpos ) ;
2007-04-24 19:37:34 +00:00
}
2010-11-26 18:32:29 +00:00
if ( ! bp_ . fonts_cjk . empty ( ) )
2008-06-05 06:18:34 +00:00
fontModule - > cjkFontLE - > setText (
2010-11-26 18:32:29 +00:00
toqstr ( bp_ . fonts_cjk ) ) ;
2008-06-05 06:18:34 +00:00
else
fontModule - > cjkFontLE - > setText ( QString ( ) ) ;
2010-11-26 18:32:29 +00:00
fontModule - > fontScCB - > setChecked ( bp_ . fonts_expert_sc ) ;
fontModule - > fontOsfCB - > setChecked ( bp_ . fonts_old_figures ) ;
fontModule - > scaleSansSB - > setValue ( bp_ . fonts_sans_scale ) ;
fontModule - > scaleTypewriterSB - > setValue ( bp_ . fonts_typewriter_scale ) ;
2011-12-03 22:15:11 +00:00
2010-11-26 18:32:29 +00:00
int nn = findToken ( GuiDocument : : fontfamilies , bp_ . fonts_default_family ) ;
2009-04-06 06:58:30 +00:00
if ( nn > = 0 )
fontModule - > fontsDefaultCO - > setCurrentIndex ( nn ) ;
2007-04-24 19:37:34 +00:00
2012-08-16 11:23:39 +00:00
if ( bp_ . fontenc = = " global " | | bp_ . fontenc = = " default " ) {
fontModule - > fontencCO - > setCurrentIndex (
fontModule - > fontencCO - > findData ( toqstr ( bp_ . fontenc ) ) ) ;
2010-06-25 03:33:15 +00:00
fontModule - > fontencLE - > setEnabled ( false ) ;
} else {
2009-11-29 14:43:00 +00:00
fontModule - > fontencCO - > setCurrentIndex ( 1 ) ;
fontModule - > fontencLE - > setText ( toqstr ( bp_ . fontenc ) ) ;
}
2012-01-31 11:30:52 +00:00
// Output
// This must be set _after_ fonts since updateDefaultFormat()
// checks osFontsCB settings.
// update combobox with formats
updateDefaultFormat ( ) ;
int index = outputModule - > defaultFormatCO - > findData ( toqstr (
bp_ . default_output_format ) ) ;
// set to default if format is not found
if ( index = = - 1 )
index = 0 ;
outputModule - > defaultFormatCO - > setCurrentIndex ( index ) ;
outputModule - > outputsyncCB - > setChecked ( bp_ . output_sync ) ;
outputModule - > synccustomCB - > setEditText ( toqstr ( bp_ . output_sync_macro ) ) ;
outputModule - > mathimgSB - > setValue ( bp_ . html_math_img_scale ) ;
outputModule - > mathoutCB - > setCurrentIndex ( bp_ . html_math_output ) ;
outputModule - > strictCB - > setChecked ( bp_ . html_be_strict ) ;
outputModule - > cssCB - > setChecked ( bp_ . html_css_as_file ) ;
2007-04-24 19:37:34 +00:00
// paper
2009-03-28 10:48:16 +00:00
bool const extern_geometry =
documentClass ( ) . provides ( " geometry " ) ;
2008-10-14 16:59:28 +00:00
int const psize = bp_ . papersize ;
2007-04-24 19:37:34 +00:00
pageLayoutModule - > papersizeCO - > setCurrentIndex ( psize ) ;
2009-07-16 08:39:22 +00:00
setCustomPapersize ( ! extern_geometry & & psize = = 1 ) ;
2009-03-28 10:48:16 +00:00
pageLayoutModule - > papersizeCO - > setEnabled ( ! extern_geometry ) ;
2007-04-24 19:37:34 +00:00
bool const landscape =
2008-10-14 16:59:28 +00:00
bp_ . orientation = = ORIENTATION_LANDSCAPE ;
2007-04-24 19:37:34 +00:00
pageLayoutModule - > landscapeRB - > setChecked ( landscape ) ;
pageLayoutModule - > portraitRB - > setChecked ( ! landscape ) ;
2009-03-28 10:48:16 +00:00
pageLayoutModule - > landscapeRB - > setEnabled ( ! extern_geometry ) ;
pageLayoutModule - > portraitRB - > setEnabled ( ! extern_geometry ) ;
2007-04-24 19:37:34 +00:00
pageLayoutModule - > facingPagesCB - > setChecked (
2008-10-14 16:59:28 +00:00
bp_ . sides = = TwoSides ) ;
2007-04-24 19:37:34 +00:00
lengthToWidgets ( pageLayoutModule - > paperwidthLE ,
2011-10-27 11:49:15 +00:00
pageLayoutModule - > paperwidthUnitCO , bp_ . paperwidth , default_unit ) ;
2007-04-24 19:37:34 +00:00
lengthToWidgets ( pageLayoutModule - > paperheightLE ,
2011-10-27 11:49:15 +00:00
pageLayoutModule - > paperheightUnitCO , bp_ . paperheight , default_unit ) ;
2007-04-24 19:37:34 +00:00
// margins
Ui : : MarginsUi * m = marginsModule ;
2010-05-18 02:56:36 +00:00
setMargins ( ) ;
2007-04-24 19:37:34 +00:00
lengthToWidgets ( m - > topLE , m - > topUnit ,
2011-10-27 11:49:15 +00:00
bp_ . topmargin , default_unit ) ;
2007-04-24 19:37:34 +00:00
lengthToWidgets ( m - > bottomLE , m - > bottomUnit ,
2011-10-27 11:49:15 +00:00
bp_ . bottommargin , default_unit ) ;
2007-04-24 19:37:34 +00:00
lengthToWidgets ( m - > innerLE , m - > innerUnit ,
2011-10-27 11:49:15 +00:00
bp_ . leftmargin , default_unit ) ;
2007-04-24 19:37:34 +00:00
lengthToWidgets ( m - > outerLE , m - > outerUnit ,
2011-10-27 11:49:15 +00:00
bp_ . rightmargin , default_unit ) ;
2007-04-24 19:37:34 +00:00
lengthToWidgets ( m - > headheightLE , m - > headheightUnit ,
2011-10-27 11:49:15 +00:00
bp_ . headheight , default_unit ) ;
2007-04-24 19:37:34 +00:00
lengthToWidgets ( m - > headsepLE , m - > headsepUnit ,
2011-10-27 11:49:15 +00:00
bp_ . headsep , default_unit ) ;
2007-04-24 19:37:34 +00:00
lengthToWidgets ( m - > footskipLE , m - > footskipUnit ,
2011-10-27 11:49:15 +00:00
bp_ . footskip , default_unit ) ;
2007-04-24 19:37:34 +00:00
2008-02-19 05:24:48 +00:00
lengthToWidgets ( m - > columnsepLE , m - > columnsepUnit ,
2011-10-27 11:49:15 +00:00
bp_ . columnsep , default_unit ) ;
2008-02-19 05:24:48 +00:00
2009-07-09 09:48:34 +00:00
// branches
updateUnknownBranches ( ) ;
2008-10-14 16:59:28 +00:00
branchesModule - > update ( bp_ ) ;
2007-09-20 22:31:18 +00:00
// PDF support
2008-10-14 16:59:28 +00:00
PDFOptions const & pdf = bp_ . pdfoptions ( ) ;
2007-09-22 22:20:15 +00:00
pdfSupportModule - > use_hyperrefGB - > setChecked ( pdf . use_hyperref ) ;
2011-12-07 21:14:41 +00:00
if ( bp_ . documentClass ( ) . provides ( " hyperref " ) )
pdfSupportModule - > use_hyperrefGB - > setTitle ( qt_ ( " C&ustomize Hyperref Options " ) ) ;
else
pdfSupportModule - > use_hyperrefGB - > setTitle ( qt_ ( " &Use Hyperref Support " ) ) ;
2007-09-21 01:00:31 +00:00
pdfSupportModule - > titleLE - > setText ( toqstr ( pdf . title ) ) ;
pdfSupportModule - > authorLE - > setText ( toqstr ( pdf . author ) ) ;
pdfSupportModule - > subjectLE - > setText ( toqstr ( pdf . subject ) ) ;
pdfSupportModule - > keywordsLE - > setText ( toqstr ( pdf . keywords ) ) ;
2007-09-20 22:31:18 +00:00
2007-09-21 01:00:31 +00:00
pdfSupportModule - > bookmarksGB - > setChecked ( pdf . bookmarks ) ;
pdfSupportModule - > bookmarksnumberedCB - > setChecked ( pdf . bookmarksnumbered ) ;
pdfSupportModule - > bookmarksopenGB - > setChecked ( pdf . bookmarksopen ) ;
2007-09-20 22:31:18 +00:00
2007-09-22 22:20:15 +00:00
pdfSupportModule - > bookmarksopenlevelSB - > setValue ( pdf . bookmarksopenlevel ) ;
2007-09-20 22:31:18 +00:00
2007-09-21 01:00:31 +00:00
pdfSupportModule - > breaklinksCB - > setChecked ( pdf . breaklinks ) ;
pdfSupportModule - > pdfborderCB - > setChecked ( pdf . pdfborder ) ;
2007-10-10 00:34:23 +00:00
pdfSupportModule - > pdfusetitleCB - > setChecked ( pdf . pdfusetitle ) ;
2007-09-21 01:00:31 +00:00
pdfSupportModule - > colorlinksCB - > setChecked ( pdf . colorlinks ) ;
2008-10-13 16:01:02 +00:00
2009-04-06 06:58:30 +00:00
nn = findToken ( backref_opts , pdf . backref ) ;
if ( nn > = 0 )
pdfSupportModule - > backrefCO - > setCurrentIndex ( nn ) ;
2008-10-13 16:01:02 +00:00
2007-09-20 22:31:18 +00:00
pdfSupportModule - > fullscreenCB - > setChecked
2007-09-21 01:00:31 +00:00
( pdf . pagemode = = pdf . pagemode_fullscreen ) ;
2007-09-20 22:31:18 +00:00
pdfSupportModule - > optionsLE - > setText (
2007-09-21 01:00:31 +00:00
toqstr ( pdf . quoted_options ) ) ;
2009-02-22 23:02:35 +00:00
// Make sure that the bc is in the INITIAL state
if ( bc ( ) . policy ( ) . buttonStatus ( ButtonPolicy : : RESTORE ) )
bc ( ) . restore ( ) ;
2009-07-11 10:31:32 +00:00
// clear changed branches cache
changedBranches_ . clear ( ) ;
2007-04-24 19:37:34 +00:00
}
2007-10-06 22:43:21 +00:00
void GuiDocument : : saveDocDefault ( )
2006-03-05 17:24:44 +00:00
{
// we have to apply the params first
2007-09-03 20:28:26 +00:00
applyView ( ) ;
2007-10-06 22:43:21 +00:00
saveAsDefault ( ) ;
2006-03-05 17:24:44 +00:00
}
2011-12-03 22:15:11 +00:00
void GuiDocument : : updateAvailableModules ( )
This commit changes the way individual LyXModule's are represented, both internally and in the .lyx files. The earlier version represented them by their `descriptive name', e.g., "Endnote" or "Theorems (AMS)", these being the same names used in the UI. This was a mistake, as becomes readily apparent when one starts to think about translating these strings. The modules ought to be represented by their filename, without the extension, just as TextClass's are.
The changes that accomplish this part are in ModuleList.{h,cpp}, configure.py, and the *.module files themselves. This is a format change, and the lyx2lyx is in those files.
By itself, that change would not be major, except for the fact that we do not want the module to be represented in the UI by its filename---e.g., theorems-std---but rather by a descriptive name, such as "Theorems". But that change turns out to be wholly non-trivial. The mechanism for choosing modules was the same as---indeed, was borrowed from---that in GuiCitation: You get a list of modules, and choosing them involves moving strings from one QListView to another. The models underlying these views are just QStringListModels, which means that, when you want to know what modules have been selected, you see what strings are in the "selected" QListView. But these are just the descriptive names, and we can't look up a module by its descriptive name if it's been translated. That, indeed, was the whole point of the change to the new representation.
So, we need a more complicated model underlying the QListView, one that will pair an identifying string---the filename minus the extension, in this case---with each item. This turns out not to be terribly difficult, though it took rather a while for me to understand why it's not difficult. There are two parts:
(i) GuiSelectionManger gets re-written to use any QAbstractListModel, not just a QStringListModel. This actually seems to improve the code, independently.
(ii) We then subclass QAbstractListModel to get the associated ID string, using the Qt::UserRole slot associated with each item to store its ID. This would be almost completely trivial if QAbstractListItem::itemData() included the QVariant associated with this role, but it doesn't, so there are some additional hoops through which to jump.
The new model, a GuiIdListModel, is defined in the files by that name. The changes in GuiSelectionManger.{h,cpp} make it more abstract; the changes in GuiDocument.{h,cpp} adapt it to the new framework.
I've also updated the module documenation to accord with this change.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22501 a592a061-630c-0410-9148-cb99ea01b6c8
2008-01-12 04:28:12 +00:00
{
2008-02-28 21:04:55 +00:00
modules_av_model_ . clear ( ) ;
2008-10-14 14:04:21 +00:00
list < modInfoStruct > const & modInfoList = getModuleInfo ( ) ;
list < modInfoStruct > : : const_iterator mit = modInfoList . begin ( ) ;
list < modInfoStruct > : : const_iterator men = modInfoList . end ( ) ;
for ( int i = 0 ; mit ! = men ; + + mit , + + i )
2011-12-03 22:15:11 +00:00
modules_av_model_ . insertRow ( i , mit - > name , mit - > id ,
2008-10-14 14:04:21 +00:00
mit - > description ) ;
This commit changes the way individual LyXModule's are represented, both internally and in the .lyx files. The earlier version represented them by their `descriptive name', e.g., "Endnote" or "Theorems (AMS)", these being the same names used in the UI. This was a mistake, as becomes readily apparent when one starts to think about translating these strings. The modules ought to be represented by their filename, without the extension, just as TextClass's are.
The changes that accomplish this part are in ModuleList.{h,cpp}, configure.py, and the *.module files themselves. This is a format change, and the lyx2lyx is in those files.
By itself, that change would not be major, except for the fact that we do not want the module to be represented in the UI by its filename---e.g., theorems-std---but rather by a descriptive name, such as "Theorems". But that change turns out to be wholly non-trivial. The mechanism for choosing modules was the same as---indeed, was borrowed from---that in GuiCitation: You get a list of modules, and choosing them involves moving strings from one QListView to another. The models underlying these views are just QStringListModels, which means that, when you want to know what modules have been selected, you see what strings are in the "selected" QListView. But these are just the descriptive names, and we can't look up a module by its descriptive name if it's been translated. That, indeed, was the whole point of the change to the new representation.
So, we need a more complicated model underlying the QListView, one that will pair an identifying string---the filename minus the extension, in this case---with each item. This turns out not to be terribly difficult, though it took rather a while for me to understand why it's not difficult. There are two parts:
(i) GuiSelectionManger gets re-written to use any QAbstractListModel, not just a QStringListModel. This actually seems to improve the code, independently.
(ii) We then subclass QAbstractListModel to get the associated ID string, using the Qt::UserRole slot associated with each item to store its ID. This would be almost completely trivial if QAbstractListItem::itemData() included the QVariant associated with this role, but it doesn't, so there are some additional hoops through which to jump.
The new model, a GuiIdListModel, is defined in the files by that name. The changes in GuiSelectionManger.{h,cpp} make it more abstract; the changes in GuiDocument.{h,cpp} adapt it to the new framework.
I've also updated the module documenation to accord with this change.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22501 a592a061-630c-0410-9148-cb99ea01b6c8
2008-01-12 04:28:12 +00:00
}
2011-12-03 22:15:11 +00:00
void GuiDocument : : updateSelectedModules ( )
This is the last of a series of patches that merges the layout modules development in personal/branches/rgheck back into the tree.
Design goal: Allow the use of layout "modules", which are to LaTeX packages as layout files are to LaTeX document classes. Thus, one could have a module that defined certain character styles, environments, commands, or what have you, and include it in various documents, each of which uses a different document class, without having to modify the layout files themselves. For example, a theorems.module could be used with article.layout to provide support for theorem-type environments, without having to modify article.layout itself, and the same module could be used with book.layout, etc.
This patch adds the GUI for managing modules.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20282 a592a061-630c-0410-9148-cb99ea01b6c8
2007-09-15 01:55:09 +00:00
{
2008-02-28 21:04:55 +00:00
modules_sel_model_ . clear ( ) ;
2008-10-14 14:04:21 +00:00
list < modInfoStruct > const selModList = getSelectedModules ( ) ;
list < modInfoStruct > : : const_iterator mit = selModList . begin ( ) ;
list < modInfoStruct > : : const_iterator men = selModList . end ( ) ;
for ( int i = 0 ; mit ! = men ; + + mit , + + i )
2011-12-03 22:15:11 +00:00
modules_sel_model_ . insertRow ( i , mit - > name , mit - > id ,
2008-10-14 14:04:21 +00:00
mit - > description ) ;
This commit changes the way individual LyXModule's are represented, both internally and in the .lyx files. The earlier version represented them by their `descriptive name', e.g., "Endnote" or "Theorems (AMS)", these being the same names used in the UI. This was a mistake, as becomes readily apparent when one starts to think about translating these strings. The modules ought to be represented by their filename, without the extension, just as TextClass's are.
The changes that accomplish this part are in ModuleList.{h,cpp}, configure.py, and the *.module files themselves. This is a format change, and the lyx2lyx is in those files.
By itself, that change would not be major, except for the fact that we do not want the module to be represented in the UI by its filename---e.g., theorems-std---but rather by a descriptive name, such as "Theorems". But that change turns out to be wholly non-trivial. The mechanism for choosing modules was the same as---indeed, was borrowed from---that in GuiCitation: You get a list of modules, and choosing them involves moving strings from one QListView to another. The models underlying these views are just QStringListModels, which means that, when you want to know what modules have been selected, you see what strings are in the "selected" QListView. But these are just the descriptive names, and we can't look up a module by its descriptive name if it's been translated. That, indeed, was the whole point of the change to the new representation.
So, we need a more complicated model underlying the QListView, one that will pair an identifying string---the filename minus the extension, in this case---with each item. This turns out not to be terribly difficult, though it took rather a while for me to understand why it's not difficult. There are two parts:
(i) GuiSelectionManger gets re-written to use any QAbstractListModel, not just a QStringListModel. This actually seems to improve the code, independently.
(ii) We then subclass QAbstractListModel to get the associated ID string, using the Qt::UserRole slot associated with each item to store its ID. This would be almost completely trivial if QAbstractListItem::itemData() included the QVariant associated with this role, but it doesn't, so there are some additional hoops through which to jump.
The new model, a GuiIdListModel, is defined in the files by that name. The changes in GuiSelectionManger.{h,cpp} make it more abstract; the changes in GuiDocument.{h,cpp} adapt it to the new framework.
I've also updated the module documenation to accord with this change.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22501 a592a061-630c-0410-9148-cb99ea01b6c8
2008-01-12 04:28:12 +00:00
}
2010-01-07 10:01:26 +00:00
void GuiDocument : : updateIncludeonlys ( )
{
masterChildModule - > childrenTW - > clear ( ) ;
QString const no = qt_ ( " No " ) ;
QString const yes = qt_ ( " Yes " ) ;
if ( includeonlys_ . empty ( ) ) {
masterChildModule - > includeallRB - > setChecked ( true ) ;
masterChildModule - > childrenTW - > setEnabled ( false ) ;
2010-01-10 13:25:41 +00:00
masterChildModule - > maintainAuxCB - > setEnabled ( false ) ;
2010-01-07 10:01:26 +00:00
} else {
masterChildModule - > includeonlyRB - > setChecked ( true ) ;
masterChildModule - > childrenTW - > setEnabled ( true ) ;
2010-01-10 13:25:41 +00:00
masterChildModule - > maintainAuxCB - > setEnabled ( true ) ;
2010-01-07 10:01:26 +00:00
}
QTreeWidgetItem * item = 0 ;
2010-09-29 13:05:57 +00:00
ListOfBuffers children = buffer ( ) . getChildren ( ) ;
2010-09-29 11:55:10 +00:00
ListOfBuffers : : const_iterator it = children . begin ( ) ;
ListOfBuffers : : const_iterator end = children . end ( ) ;
2010-01-07 10:01:26 +00:00
bool has_unincluded = false ;
bool all_unincluded = true ;
for ( ; it ! = end ; + + it ) {
item = new QTreeWidgetItem ( masterChildModule - > childrenTW ) ;
// FIXME Unicode
string const name =
2010-04-21 01:19:09 +00:00
to_utf8 ( makeRelPath ( from_utf8 ( ( * it ) - > fileName ( ) . absFileName ( ) ) ,
2010-01-07 10:01:26 +00:00
from_utf8 ( buffer ( ) . filePath ( ) ) ) ) ;
item - > setText ( 0 , toqstr ( name ) ) ;
item - > setText ( 1 , isChildIncluded ( name ) ? yes : no ) ;
if ( ! isChildIncluded ( name ) )
has_unincluded = true ;
else
all_unincluded = false ;
}
// Both if all childs are included and if none is included
// is equal to "include all" (i.e., ommit \includeonly).
// Thus, reset the GUI.
if ( ! has_unincluded | | all_unincluded ) {
masterChildModule - > includeallRB - > setChecked ( true ) ;
masterChildModule - > childrenTW - > setEnabled ( false ) ;
includeonlys_ . clear ( ) ;
}
// If all are included, we need to update again.
if ( ! has_unincluded )
updateIncludeonlys ( ) ;
}
This commit changes the way individual LyXModule's are represented, both internally and in the .lyx files. The earlier version represented them by their `descriptive name', e.g., "Endnote" or "Theorems (AMS)", these being the same names used in the UI. This was a mistake, as becomes readily apparent when one starts to think about translating these strings. The modules ought to be represented by their filename, without the extension, just as TextClass's are.
The changes that accomplish this part are in ModuleList.{h,cpp}, configure.py, and the *.module files themselves. This is a format change, and the lyx2lyx is in those files.
By itself, that change would not be major, except for the fact that we do not want the module to be represented in the UI by its filename---e.g., theorems-std---but rather by a descriptive name, such as "Theorems". But that change turns out to be wholly non-trivial. The mechanism for choosing modules was the same as---indeed, was borrowed from---that in GuiCitation: You get a list of modules, and choosing them involves moving strings from one QListView to another. The models underlying these views are just QStringListModels, which means that, when you want to know what modules have been selected, you see what strings are in the "selected" QListView. But these are just the descriptive names, and we can't look up a module by its descriptive name if it's been translated. That, indeed, was the whole point of the change to the new representation.
So, we need a more complicated model underlying the QListView, one that will pair an identifying string---the filename minus the extension, in this case---with each item. This turns out not to be terribly difficult, though it took rather a while for me to understand why it's not difficult. There are two parts:
(i) GuiSelectionManger gets re-written to use any QAbstractListModel, not just a QStringListModel. This actually seems to improve the code, independently.
(ii) We then subclass QAbstractListModel to get the associated ID string, using the Qt::UserRole slot associated with each item to store its ID. This would be almost completely trivial if QAbstractListItem::itemData() included the QVariant associated with this role, but it doesn't, so there are some additional hoops through which to jump.
The new model, a GuiIdListModel, is defined in the files by that name. The changes in GuiSelectionManger.{h,cpp} make it more abstract; the changes in GuiDocument.{h,cpp} adapt it to the new framework.
I've also updated the module documenation to accord with this change.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22501 a592a061-630c-0410-9148-cb99ea01b6c8
2008-01-12 04:28:12 +00:00
void GuiDocument : : updateContents ( )
{
2008-05-15 08:41:17 +00:00
// Nothing to do here as the document settings is not cursor dependant.
return ;
2008-01-15 10:38:19 +00:00
}
2007-10-06 22:43:21 +00:00
void GuiDocument : : useClassDefaults ( )
2006-03-05 17:24:44 +00:00
{
2008-01-15 10:38:19 +00:00
if ( applyPB - > isEnabled ( ) ) {
int const ret = Alert : : prompt ( _ ( " Unapplied changes " ) ,
2008-03-09 16:29:01 +00:00
_ ( " Some changes in the dialog were not yet applied. \n "
2008-01-15 10:38:19 +00:00
" If you do not apply now, they will be lost after this action. " ) ,
1 , 1 , _ ( " &Apply " ) , _ ( " &Dismiss " ) ) ;
if ( ret = = 0 )
applyView ( ) ;
}
2008-02-28 21:04:55 +00:00
int idx = latexModule - > classCO - > currentIndex ( ) ;
2012-10-09 05:22:48 +00:00
string const classname = fromqstr ( latexModule - > classCO - > getData ( idx ) ) ;
2008-02-28 21:04:55 +00:00
if ( ! bp_ . setBaseClass ( classname ) ) {
Alert : : error ( _ ( " Error " ) , _ ( " Unable to set document class. " ) ) ;
return ;
}
2007-10-06 22:43:21 +00:00
bp_ . useClassDefaults ( ) ;
2008-10-14 16:59:28 +00:00
paramsToDialog ( ) ;
2006-03-05 17:24:44 +00:00
}
2007-07-27 18:17:00 +00:00
2008-10-14 14:04:21 +00:00
void GuiDocument : : setLayoutComboByIDString ( string const & idString )
2008-03-01 22:08:16 +00:00
{
2012-10-09 05:22:48 +00:00
if ( ! latexModule - > classCO - > set ( toqstr ( idString ) ) )
2011-12-03 22:15:11 +00:00
Alert : : warning ( _ ( " Can't set layout! " ) ,
2008-03-01 22:08:16 +00:00
bformat ( _ ( " Unable to set layout for ID: %1$s " ) , from_utf8 ( idString ) ) ) ;
}
2007-10-06 22:43:21 +00:00
bool GuiDocument : : isValid ( )
2007-07-27 18:17:00 +00:00
{
2011-12-03 22:15:11 +00:00
return
A UI for document-local layout information. LyX has supported this for a
while, but without any UI for it. (There has been local layout in the
Customization manual for a long time, in fact.)
Yes, this is an advanced feature. But, absent a layout editor, it is the
one thing that will make it easier, and possible, for "normal users" to
experiment with layout without having to go through reconfiguration,
etc, etc. To keep too many people from shooting themselves, we validate
the layout information before allowing the user to apply it.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@35061 a592a061-630c-0410-9148-cb99ea01b6c8
2010-08-05 22:47:42 +00:00
validateListingsParameters ( ) . isEmpty ( ) & &
localLayout - > isValid ( ) & &
(
// if we're asking for skips between paragraphs
! textLayoutModule - > skipRB - > isChecked ( ) | |
// then either we haven't chosen custom
2011-12-03 22:15:11 +00:00
textLayoutModule - > skipCO - > currentIndex ( ) ! = 3 | |
A UI for document-local layout information. LyX has supported this for a
while, but without any UI for it. (There has been local layout in the
Customization manual for a long time, in fact.)
Yes, this is an advanced feature. But, absent a layout editor, it is the
one thing that will make it easier, and possible, for "normal users" to
experiment with layout without having to go through reconfiguration,
etc, etc. To keep too many people from shooting themselves, we validate
the layout information before allowing the user to apply it.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@35061 a592a061-630c-0410-9148-cb99ea01b6c8
2010-08-05 22:47:42 +00:00
// or else a length has been given
! textLayoutModule - > skipLE - > text ( ) . isEmpty ( )
2011-12-03 22:15:11 +00:00
) & &
A UI for document-local layout information. LyX has supported this for a
while, but without any UI for it. (There has been local layout in the
Customization manual for a long time, in fact.)
Yes, this is an advanced feature. But, absent a layout editor, it is the
one thing that will make it easier, and possible, for "normal users" to
experiment with layout without having to go through reconfiguration,
etc, etc. To keep too many people from shooting themselves, we validate
the layout information before allowing the user to apply it.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@35061 a592a061-630c-0410-9148-cb99ea01b6c8
2010-08-05 22:47:42 +00:00
(
// if we're asking for indentation
2011-12-03 22:15:11 +00:00
! textLayoutModule - > indentRB - > isChecked ( ) | |
A UI for document-local layout information. LyX has supported this for a
while, but without any UI for it. (There has been local layout in the
Customization manual for a long time, in fact.)
Yes, this is an advanced feature. But, absent a layout editor, it is the
one thing that will make it easier, and possible, for "normal users" to
experiment with layout without having to go through reconfiguration,
etc, etc. To keep too many people from shooting themselves, we validate
the layout information before allowing the user to apply it.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@35061 a592a061-630c-0410-9148-cb99ea01b6c8
2010-08-05 22:47:42 +00:00
// then either we haven't chosen custom
2011-12-03 22:15:11 +00:00
textLayoutModule - > indentCO - > currentIndex ( ) ! = 1 | |
A UI for document-local layout information. LyX has supported this for a
while, but without any UI for it. (There has been local layout in the
Customization manual for a long time, in fact.)
Yes, this is an advanced feature. But, absent a layout editor, it is the
one thing that will make it easier, and possible, for "normal users" to
experiment with layout without having to go through reconfiguration,
etc, etc. To keep too many people from shooting themselves, we validate
the layout information before allowing the user to apply it.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@35061 a592a061-630c-0410-9148-cb99ea01b6c8
2010-08-05 22:47:42 +00:00
// or else a length has been given
! textLayoutModule - > indentLE - > text ( ) . isEmpty ( )
) ;
2007-07-27 18:17:00 +00:00
}
2007-10-06 22:43:21 +00:00
char const * const GuiDocument : : fontfamilies [ 5 ] = {
" default " , " rmdefault " , " sfdefault " , " ttdefault " , " "
} ;
char const * GuiDocument : : fontfamilies_gui [ 5 ] = {
N_ ( " Default " ) , N_ ( " Roman " ) , N_ ( " Sans Serif " ) , N_ ( " Typewriter " ) , " "
} ;
bool GuiDocument : : initialiseParams ( string const & )
{
2008-09-29 10:52:17 +00:00
BufferView const * view = bufferview ( ) ;
2008-05-15 08:41:17 +00:00
if ( ! view ) {
bp_ = BufferParams ( ) ;
2008-10-14 16:59:28 +00:00
paramsToDialog ( ) ;
2008-05-15 08:41:17 +00:00
return true ;
}
bp_ = view - > buffer ( ) . params ( ) ;
This commit changes the way individual LyXModule's are represented, both internally and in the .lyx files. The earlier version represented them by their `descriptive name', e.g., "Endnote" or "Theorems (AMS)", these being the same names used in the UI. This was a mistake, as becomes readily apparent when one starts to think about translating these strings. The modules ought to be represented by their filename, without the extension, just as TextClass's are.
The changes that accomplish this part are in ModuleList.{h,cpp}, configure.py, and the *.module files themselves. This is a format change, and the lyx2lyx is in those files.
By itself, that change would not be major, except for the fact that we do not want the module to be represented in the UI by its filename---e.g., theorems-std---but rather by a descriptive name, such as "Theorems". But that change turns out to be wholly non-trivial. The mechanism for choosing modules was the same as---indeed, was borrowed from---that in GuiCitation: You get a list of modules, and choosing them involves moving strings from one QListView to another. The models underlying these views are just QStringListModels, which means that, when you want to know what modules have been selected, you see what strings are in the "selected" QListView. But these are just the descriptive names, and we can't look up a module by its descriptive name if it's been translated. That, indeed, was the whole point of the change to the new representation.
So, we need a more complicated model underlying the QListView, one that will pair an identifying string---the filename minus the extension, in this case---with each item. This turns out not to be terribly difficult, though it took rather a while for me to understand why it's not difficult. There are two parts:
(i) GuiSelectionManger gets re-written to use any QAbstractListModel, not just a QStringListModel. This actually seems to improve the code, independently.
(ii) We then subclass QAbstractListModel to get the associated ID string, using the Qt::UserRole slot associated with each item to store its ID. This would be almost completely trivial if QAbstractListItem::itemData() included the QVariant associated with this role, but it doesn't, so there are some additional hoops through which to jump.
The new model, a GuiIdListModel, is defined in the files by that name. The changes in GuiSelectionManger.{h,cpp} make it more abstract; the changes in GuiDocument.{h,cpp} adapt it to the new framework.
I've also updated the module documenation to accord with this change.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22501 a592a061-630c-0410-9148-cb99ea01b6c8
2008-01-12 04:28:12 +00:00
loadModuleInfo ( ) ;
2008-05-15 08:41:17 +00:00
updateAvailableModules ( ) ;
//FIXME It'd be nice to make sure here that the selected
//modules are consistent: That required modules are actually
//selected, and that we don't have conflicts. If so, we could
//at least pop up a warning.
2008-10-14 16:59:28 +00:00
paramsToDialog ( ) ;
2007-10-06 22:43:21 +00:00
return true ;
}
void GuiDocument : : clearParams ( )
{
bp_ = BufferParams ( ) ;
}
BufferId GuiDocument : : id ( ) const
{
2008-05-15 08:41:17 +00:00
BufferView const * const view = bufferview ( ) ;
return view ? & view - > buffer ( ) : 0 ;
2007-10-06 22:43:21 +00:00
}
2008-10-14 14:04:21 +00:00
list < GuiDocument : : modInfoStruct > const & GuiDocument : : getModuleInfo ( )
2007-10-06 22:43:21 +00:00
{
return moduleNames_ ;
}
2011-12-03 22:15:11 +00:00
list < GuiDocument : : modInfoStruct > const
2009-02-12 15:07:22 +00:00
GuiDocument : : makeModuleInfo ( LayoutModuleList const & mods )
2007-10-06 22:43:21 +00:00
{
2009-02-12 15:07:22 +00:00
LayoutModuleList : : const_iterator it = mods . begin ( ) ;
LayoutModuleList : : const_iterator end = mods . end ( ) ;
2008-10-14 14:04:21 +00:00
list < modInfoStruct > mInfo ;
This commit changes the way individual LyXModule's are represented, both internally and in the .lyx files. The earlier version represented them by their `descriptive name', e.g., "Endnote" or "Theorems (AMS)", these being the same names used in the UI. This was a mistake, as becomes readily apparent when one starts to think about translating these strings. The modules ought to be represented by their filename, without the extension, just as TextClass's are.
The changes that accomplish this part are in ModuleList.{h,cpp}, configure.py, and the *.module files themselves. This is a format change, and the lyx2lyx is in those files.
By itself, that change would not be major, except for the fact that we do not want the module to be represented in the UI by its filename---e.g., theorems-std---but rather by a descriptive name, such as "Theorems". But that change turns out to be wholly non-trivial. The mechanism for choosing modules was the same as---indeed, was borrowed from---that in GuiCitation: You get a list of modules, and choosing them involves moving strings from one QListView to another. The models underlying these views are just QStringListModels, which means that, when you want to know what modules have been selected, you see what strings are in the "selected" QListView. But these are just the descriptive names, and we can't look up a module by its descriptive name if it's been translated. That, indeed, was the whole point of the change to the new representation.
So, we need a more complicated model underlying the QListView, one that will pair an identifying string---the filename minus the extension, in this case---with each item. This turns out not to be terribly difficult, though it took rather a while for me to understand why it's not difficult. There are two parts:
(i) GuiSelectionManger gets re-written to use any QAbstractListModel, not just a QStringListModel. This actually seems to improve the code, independently.
(ii) We then subclass QAbstractListModel to get the associated ID string, using the Qt::UserRole slot associated with each item to store its ID. This would be almost completely trivial if QAbstractListItem::itemData() included the QVariant associated with this role, but it doesn't, so there are some additional hoops through which to jump.
The new model, a GuiIdListModel, is defined in the files by that name. The changes in GuiSelectionManger.{h,cpp} make it more abstract; the changes in GuiDocument.{h,cpp} adapt it to the new framework.
I've also updated the module documenation to accord with this change.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22501 a592a061-630c-0410-9148-cb99ea01b6c8
2008-01-12 04:28:12 +00:00
for ( ; it ! = end ; + + it ) {
modInfoStruct m ;
m . id = * it ;
2009-08-14 15:46:10 +00:00
LyXModule const * const mod = theModuleList [ * it ] ;
This commit changes the way individual LyXModule's are represented, both internally and in the .lyx files. The earlier version represented them by their `descriptive name', e.g., "Endnote" or "Theorems (AMS)", these being the same names used in the UI. This was a mistake, as becomes readily apparent when one starts to think about translating these strings. The modules ought to be represented by their filename, without the extension, just as TextClass's are.
The changes that accomplish this part are in ModuleList.{h,cpp}, configure.py, and the *.module files themselves. This is a format change, and the lyx2lyx is in those files.
By itself, that change would not be major, except for the fact that we do not want the module to be represented in the UI by its filename---e.g., theorems-std---but rather by a descriptive name, such as "Theorems". But that change turns out to be wholly non-trivial. The mechanism for choosing modules was the same as---indeed, was borrowed from---that in GuiCitation: You get a list of modules, and choosing them involves moving strings from one QListView to another. The models underlying these views are just QStringListModels, which means that, when you want to know what modules have been selected, you see what strings are in the "selected" QListView. But these are just the descriptive names, and we can't look up a module by its descriptive name if it's been translated. That, indeed, was the whole point of the change to the new representation.
So, we need a more complicated model underlying the QListView, one that will pair an identifying string---the filename minus the extension, in this case---with each item. This turns out not to be terribly difficult, though it took rather a while for me to understand why it's not difficult. There are two parts:
(i) GuiSelectionManger gets re-written to use any QAbstractListModel, not just a QStringListModel. This actually seems to improve the code, independently.
(ii) We then subclass QAbstractListModel to get the associated ID string, using the Qt::UserRole slot associated with each item to store its ID. This would be almost completely trivial if QAbstractListItem::itemData() included the QVariant associated with this role, but it doesn't, so there are some additional hoops through which to jump.
The new model, a GuiIdListModel, is defined in the files by that name. The changes in GuiSelectionManger.{h,cpp} make it more abstract; the changes in GuiDocument.{h,cpp} adapt it to the new framework.
I've also updated the module documenation to accord with this change.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22501 a592a061-630c-0410-9148-cb99ea01b6c8
2008-01-12 04:28:12 +00:00
if ( mod )
2008-11-04 15:44:02 +00:00
// FIXME Unicode
2008-11-04 15:38:37 +00:00
m . name = toqstr ( translateIfPossible ( from_utf8 ( mod - > getName ( ) ) ) ) ;
2011-12-03 22:15:11 +00:00
else
2008-04-17 03:27:20 +00:00
m . name = toqstr ( * it ) + toqstr ( " ( " ) + qt_ ( " Not Found " ) + toqstr ( " ) " ) ;
This commit changes the way individual LyXModule's are represented, both internally and in the .lyx files. The earlier version represented them by their `descriptive name', e.g., "Endnote" or "Theorems (AMS)", these being the same names used in the UI. This was a mistake, as becomes readily apparent when one starts to think about translating these strings. The modules ought to be represented by their filename, without the extension, just as TextClass's are.
The changes that accomplish this part are in ModuleList.{h,cpp}, configure.py, and the *.module files themselves. This is a format change, and the lyx2lyx is in those files.
By itself, that change would not be major, except for the fact that we do not want the module to be represented in the UI by its filename---e.g., theorems-std---but rather by a descriptive name, such as "Theorems". But that change turns out to be wholly non-trivial. The mechanism for choosing modules was the same as---indeed, was borrowed from---that in GuiCitation: You get a list of modules, and choosing them involves moving strings from one QListView to another. The models underlying these views are just QStringListModels, which means that, when you want to know what modules have been selected, you see what strings are in the "selected" QListView. But these are just the descriptive names, and we can't look up a module by its descriptive name if it's been translated. That, indeed, was the whole point of the change to the new representation.
So, we need a more complicated model underlying the QListView, one that will pair an identifying string---the filename minus the extension, in this case---with each item. This turns out not to be terribly difficult, though it took rather a while for me to understand why it's not difficult. There are two parts:
(i) GuiSelectionManger gets re-written to use any QAbstractListModel, not just a QStringListModel. This actually seems to improve the code, independently.
(ii) We then subclass QAbstractListModel to get the associated ID string, using the Qt::UserRole slot associated with each item to store its ID. This would be almost completely trivial if QAbstractListItem::itemData() included the QVariant associated with this role, but it doesn't, so there are some additional hoops through which to jump.
The new model, a GuiIdListModel, is defined in the files by that name. The changes in GuiSelectionManger.{h,cpp} make it more abstract; the changes in GuiDocument.{h,cpp} adapt it to the new framework.
I've also updated the module documenation to accord with this change.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22501 a592a061-630c-0410-9148-cb99ea01b6c8
2008-01-12 04:28:12 +00:00
mInfo . push_back ( m ) ;
}
return mInfo ;
2007-10-06 22:43:21 +00:00
}
2008-10-23 00:27:03 +00:00
list < GuiDocument : : modInfoStruct > const GuiDocument : : getSelectedModules ( )
{
return makeModuleInfo ( params ( ) . getModules ( ) ) ;
}
list < GuiDocument : : modInfoStruct > const GuiDocument : : getProvidedModules ( )
{
return makeModuleInfo ( params ( ) . baseClass ( ) - > providedModules ( ) ) ;
}
2008-02-28 21:04:55 +00:00
DocumentClass const & GuiDocument : : documentClass ( ) const
2007-10-06 22:43:21 +00:00
{
2008-02-28 21:04:55 +00:00
return bp_ . documentClass ( ) ;
2007-10-06 22:43:21 +00:00
}
2007-10-09 21:21:01 +00:00
static void dispatch_bufferparams ( Dialog const & dialog ,
2008-03-15 01:20:36 +00:00
BufferParams const & bp , FuncCode lfun )
2007-10-06 22:43:21 +00:00
{
ostringstream ss ;
ss < < " \\ begin_header \n " ;
bp . writeFile ( ss ) ;
ss < < " \\ end_header \n " ;
2007-10-09 21:21:01 +00:00
dialog . dispatch ( FuncRequest ( lfun , ss . str ( ) ) ) ;
2007-10-06 22:43:21 +00:00
}
void GuiDocument : : dispatchParams ( )
{
// This must come first so that a language change is correctly noticed
setLanguage ( ) ;
// Apply the BufferParams. Note that this will set the base class
// and then update the buffer's layout.
dispatch_bufferparams ( * this , params ( ) , LFUN_BUFFER_PARAMS_APPLY ) ;
2008-04-28 16:38:56 +00:00
if ( ! params ( ) . master . empty ( ) ) {
FileName const master_file = support : : makeAbsPath ( params ( ) . master ,
support : : onlyPath ( buffer ( ) . absFileName ( ) ) ) ;
2010-04-21 01:19:31 +00:00
if ( isLyXFileName ( master_file . absFileName ( ) ) ) {
2008-04-28 16:38:56 +00:00
Buffer * master = checkAndLoadLyXFile ( master_file ) ;
2009-01-08 07:59:37 +00:00
if ( master ) {
if ( master - > isChild ( const_cast < Buffer * > ( & buffer ( ) ) ) )
const_cast < Buffer & > ( buffer ( ) ) . setParent ( master ) ;
else
2011-12-03 22:15:11 +00:00
Alert : : warning ( _ ( " Assigned master does not include this file " ) ,
2009-01-08 07:59:37 +00:00
bformat ( _ ( " You must include this file in the document \n "
" '%1$s' in order to use the master document \n "
" feature. " ) , from_utf8 ( params ( ) . master ) ) ) ;
} else
2011-12-03 22:15:11 +00:00
Alert : : warning ( _ ( " Could not load master " ) ,
2009-01-08 08:00:37 +00:00
bformat ( _ ( " The master document '%1$s' \n "
2009-01-08 07:59:37 +00:00
" could not be loaded. " ) ,
from_utf8 ( params ( ) . master ) ) ) ;
2008-04-28 16:38:56 +00:00
}
}
2007-10-06 22:43:21 +00:00
// Generate the colours requested by each new branch.
BranchList & branchlist = params ( ) . branchlist ( ) ;
if ( ! branchlist . empty ( ) ) {
BranchList : : const_iterator it = branchlist . begin ( ) ;
BranchList : : const_iterator const end = branchlist . end ( ) ;
for ( ; it ! = end ; + + it ) {
2008-09-21 19:27:20 +00:00
docstring const & current_branch = it - > branch ( ) ;
2007-10-06 22:43:21 +00:00
Branch const * branch = branchlist . find ( current_branch ) ;
2008-09-21 19:27:20 +00:00
string const x11hexname = X11hexname ( branch - > color ( ) ) ;
2007-10-06 22:43:21 +00:00
// display the new color
docstring const str = current_branch + ' ' + from_ascii ( x11hexname ) ;
dispatch ( FuncRequest ( LFUN_SET_COLOR , str ) ) ;
}
// Open insets of selected branches, close deselected ones
2010-04-08 12:39:41 +00:00
dispatch ( FuncRequest ( LFUN_INSET_FORALL ,
" Branch inset-toggle assign " ) ) ;
2007-10-06 22:43:21 +00:00
}
2009-07-11 10:53:29 +00:00
// rename branches in the document
executeBranchRenaming ( ) ;
// and clear changed branches cache
changedBranches_ . clear ( ) ;
2011-12-03 22:15:11 +00:00
2009-04-16 07:29:01 +00:00
// Generate the colours requested by indices.
IndicesList & indiceslist = params ( ) . indiceslist ( ) ;
if ( ! indiceslist . empty ( ) ) {
IndicesList : : const_iterator it = indiceslist . begin ( ) ;
IndicesList : : const_iterator const end = indiceslist . end ( ) ;
for ( ; it ! = end ; + + it ) {
2009-07-13 06:46:52 +00:00
docstring const & current_index = it - > shortcut ( ) ;
Index const * index = indiceslist . findShortcut ( current_index ) ;
2009-04-16 07:29:01 +00:00
string const x11hexname = X11hexname ( index - > color ( ) ) ;
// display the new color
docstring const str = current_index + ' ' + from_ascii ( x11hexname ) ;
dispatch ( FuncRequest ( LFUN_SET_COLOR , str ) ) ;
}
}
2010-10-14 15:04:57 +00:00
// FIXME LFUN
// If we used an LFUN, we would not need these two lines:
2008-09-29 10:52:17 +00:00
BufferView * bv = const_cast < BufferView * > ( bufferview ( ) ) ;
bv - > processUpdateFlags ( Update : : Force | Update : : FitCursor ) ;
2007-10-06 22:43:21 +00:00
}
void GuiDocument : : setLanguage ( ) const
{
Language const * const newL = bp_ . language ;
if ( buffer ( ) . params ( ) . language = = newL )
return ;
string const & lang_name = newL - > lang ( ) ;
dispatch ( FuncRequest ( LFUN_BUFFER_LANGUAGE , lang_name ) ) ;
}
void GuiDocument : : saveAsDefault ( ) const
{
dispatch_bufferparams ( * this , params ( ) , LFUN_BUFFER_SAVE_AS_DEFAULT ) ;
}
2012-08-16 11:23:39 +00:00
bool GuiDocument : : providesOSF ( QString const & font ) const
2007-10-06 22:43:21 +00:00
{
2010-11-26 09:42:03 +00:00
if ( fontModule - > osFontsCB - > isChecked ( ) )
2009-04-10 14:39:22 +00:00
// FIXME: we should check if the fonts really
// have OSF support. But how?
return true ;
2012-09-22 08:59:53 +00:00
return theLaTeXFonts ( ) . getLaTeXFont (
2012-09-22 15:44:00 +00:00
qstring_to_ucs4 ( font ) ) . providesOSF ( ot1 ( ) ,
completeFontset ( ) ,
noMathFont ( ) ) ;
2007-10-06 22:43:21 +00:00
}
2012-08-16 11:23:39 +00:00
bool GuiDocument : : providesSC ( QString const & font ) const
2007-10-06 22:43:21 +00:00
{
2010-11-26 09:42:03 +00:00
if ( fontModule - > osFontsCB - > isChecked ( ) )
2009-04-10 14:39:22 +00:00
return false ;
2012-09-22 08:59:53 +00:00
return theLaTeXFonts ( ) . getLaTeXFont (
2012-09-22 15:44:00 +00:00
qstring_to_ucs4 ( font ) ) . providesSC ( ot1 ( ) ,
completeFontset ( ) ,
noMathFont ( ) ) ;
2007-10-06 22:43:21 +00:00
}
2012-08-16 11:23:39 +00:00
bool GuiDocument : : providesScale ( QString const & font ) const
2007-10-06 22:43:21 +00:00
{
2010-11-26 09:42:03 +00:00
if ( fontModule - > osFontsCB - > isChecked ( ) )
2009-04-10 14:39:22 +00:00
return true ;
2012-09-22 08:59:53 +00:00
return theLaTeXFonts ( ) . getLaTeXFont (
2012-09-22 15:44:00 +00:00
qstring_to_ucs4 ( font ) ) . providesScale ( ot1 ( ) ,
completeFontset ( ) ,
noMathFont ( ) ) ;
}
bool GuiDocument : : providesNoMath ( QString const & font ) const
{
if ( fontModule - > osFontsCB - > isChecked ( ) )
return false ;
return theLaTeXFonts ( ) . getLaTeXFont (
qstring_to_ucs4 ( font ) ) . providesNoMath ( ot1 ( ) ,
completeFontset ( ) ) ;
2007-10-06 22:43:21 +00:00
}
This commit changes the way individual LyXModule's are represented, both internally and in the .lyx files. The earlier version represented them by their `descriptive name', e.g., "Endnote" or "Theorems (AMS)", these being the same names used in the UI. This was a mistake, as becomes readily apparent when one starts to think about translating these strings. The modules ought to be represented by their filename, without the extension, just as TextClass's are.
The changes that accomplish this part are in ModuleList.{h,cpp}, configure.py, and the *.module files themselves. This is a format change, and the lyx2lyx is in those files.
By itself, that change would not be major, except for the fact that we do not want the module to be represented in the UI by its filename---e.g., theorems-std---but rather by a descriptive name, such as "Theorems". But that change turns out to be wholly non-trivial. The mechanism for choosing modules was the same as---indeed, was borrowed from---that in GuiCitation: You get a list of modules, and choosing them involves moving strings from one QListView to another. The models underlying these views are just QStringListModels, which means that, when you want to know what modules have been selected, you see what strings are in the "selected" QListView. But these are just the descriptive names, and we can't look up a module by its descriptive name if it's been translated. That, indeed, was the whole point of the change to the new representation.
So, we need a more complicated model underlying the QListView, one that will pair an identifying string---the filename minus the extension, in this case---with each item. This turns out not to be terribly difficult, though it took rather a while for me to understand why it's not difficult. There are two parts:
(i) GuiSelectionManger gets re-written to use any QAbstractListModel, not just a QStringListModel. This actually seems to improve the code, independently.
(ii) We then subclass QAbstractListModel to get the associated ID string, using the Qt::UserRole slot associated with each item to store its ID. This would be almost completely trivial if QAbstractListItem::itemData() included the QVariant associated with this role, but it doesn't, so there are some additional hoops through which to jump.
The new model, a GuiIdListModel, is defined in the files by that name. The changes in GuiSelectionManger.{h,cpp} make it more abstract; the changes in GuiDocument.{h,cpp} adapt it to the new framework.
I've also updated the module documenation to accord with this change.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22501 a592a061-630c-0410-9148-cb99ea01b6c8
2008-01-12 04:28:12 +00:00
void GuiDocument : : loadModuleInfo ( )
2007-10-06 22:43:21 +00:00
{
moduleNames_ . clear ( ) ;
2009-08-14 15:37:34 +00:00
LyXModuleList : : const_iterator it = theModuleList . begin ( ) ;
LyXModuleList : : const_iterator end = theModuleList . end ( ) ;
This commit changes the way individual LyXModule's are represented, both internally and in the .lyx files. The earlier version represented them by their `descriptive name', e.g., "Endnote" or "Theorems (AMS)", these being the same names used in the UI. This was a mistake, as becomes readily apparent when one starts to think about translating these strings. The modules ought to be represented by their filename, without the extension, just as TextClass's are.
The changes that accomplish this part are in ModuleList.{h,cpp}, configure.py, and the *.module files themselves. This is a format change, and the lyx2lyx is in those files.
By itself, that change would not be major, except for the fact that we do not want the module to be represented in the UI by its filename---e.g., theorems-std---but rather by a descriptive name, such as "Theorems". But that change turns out to be wholly non-trivial. The mechanism for choosing modules was the same as---indeed, was borrowed from---that in GuiCitation: You get a list of modules, and choosing them involves moving strings from one QListView to another. The models underlying these views are just QStringListModels, which means that, when you want to know what modules have been selected, you see what strings are in the "selected" QListView. But these are just the descriptive names, and we can't look up a module by its descriptive name if it's been translated. That, indeed, was the whole point of the change to the new representation.
So, we need a more complicated model underlying the QListView, one that will pair an identifying string---the filename minus the extension, in this case---with each item. This turns out not to be terribly difficult, though it took rather a while for me to understand why it's not difficult. There are two parts:
(i) GuiSelectionManger gets re-written to use any QAbstractListModel, not just a QStringListModel. This actually seems to improve the code, independently.
(ii) We then subclass QAbstractListModel to get the associated ID string, using the Qt::UserRole slot associated with each item to store its ID. This would be almost completely trivial if QAbstractListItem::itemData() included the QVariant associated with this role, but it doesn't, so there are some additional hoops through which to jump.
The new model, a GuiIdListModel, is defined in the files by that name. The changes in GuiSelectionManger.{h,cpp} make it more abstract; the changes in GuiDocument.{h,cpp} adapt it to the new framework.
I've also updated the module documenation to accord with this change.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22501 a592a061-630c-0410-9148-cb99ea01b6c8
2008-01-12 04:28:12 +00:00
for ( ; it ! = end ; + + it ) {
modInfoStruct m ;
m . id = it - > getID ( ) ;
2008-11-04 15:44:02 +00:00
// FIXME Unicode
2008-11-04 15:38:37 +00:00
m . name = toqstr ( translateIfPossible ( from_utf8 ( it - > getName ( ) ) ) ) ;
2008-04-17 03:27:20 +00:00
// this is supposed to give us the first sentence of the description
2008-11-04 15:44:02 +00:00
// FIXME Unicode
QString desc =
toqstr ( translateIfPossible ( from_utf8 ( it - > getDescription ( ) ) ) ) ;
2008-04-17 03:27:20 +00:00
int const pos = desc . indexOf ( " . " ) ;
if ( pos > 0 )
desc . truncate ( pos + 1 ) ;
m . description = desc ;
2012-03-08 16:43:05 +00:00
if ( it - > category ( ) . substr ( 0 , 8 ) ! = " Citation " )
moduleNames_ . push_back ( m ) ;
This commit changes the way individual LyXModule's are represented, both internally and in the .lyx files. The earlier version represented them by their `descriptive name', e.g., "Endnote" or "Theorems (AMS)", these being the same names used in the UI. This was a mistake, as becomes readily apparent when one starts to think about translating these strings. The modules ought to be represented by their filename, without the extension, just as TextClass's are.
The changes that accomplish this part are in ModuleList.{h,cpp}, configure.py, and the *.module files themselves. This is a format change, and the lyx2lyx is in those files.
By itself, that change would not be major, except for the fact that we do not want the module to be represented in the UI by its filename---e.g., theorems-std---but rather by a descriptive name, such as "Theorems". But that change turns out to be wholly non-trivial. The mechanism for choosing modules was the same as---indeed, was borrowed from---that in GuiCitation: You get a list of modules, and choosing them involves moving strings from one QListView to another. The models underlying these views are just QStringListModels, which means that, when you want to know what modules have been selected, you see what strings are in the "selected" QListView. But these are just the descriptive names, and we can't look up a module by its descriptive name if it's been translated. That, indeed, was the whole point of the change to the new representation.
So, we need a more complicated model underlying the QListView, one that will pair an identifying string---the filename minus the extension, in this case---with each item. This turns out not to be terribly difficult, though it took rather a while for me to understand why it's not difficult. There are two parts:
(i) GuiSelectionManger gets re-written to use any QAbstractListModel, not just a QStringListModel. This actually seems to improve the code, independently.
(ii) We then subclass QAbstractListModel to get the associated ID string, using the Qt::UserRole slot associated with each item to store its ID. This would be almost completely trivial if QAbstractListItem::itemData() included the QVariant associated with this role, but it doesn't, so there are some additional hoops through which to jump.
The new model, a GuiIdListModel, is defined in the files by that name. The changes in GuiSelectionManger.{h,cpp} make it more abstract; the changes in GuiDocument.{h,cpp} adapt it to the new framework.
I've also updated the module documenation to accord with this change.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22501 a592a061-630c-0410-9148-cb99ea01b6c8
2008-01-12 04:28:12 +00:00
}
2007-10-06 22:43:21 +00:00
}
2009-07-09 09:48:34 +00:00
void GuiDocument : : updateUnknownBranches ( )
{
2010-02-01 14:44:12 +00:00
if ( ! bufferview ( ) )
return ;
2009-07-09 09:48:34 +00:00
list < docstring > used_branches ;
buffer ( ) . getUsedBranches ( used_branches ) ;
list < docstring > : : const_iterator it = used_branches . begin ( ) ;
QStringList unknown_branches ;
2009-07-09 11:16:27 +00:00
for ( ; it ! = used_branches . end ( ) ; + + it ) {
2009-07-09 09:48:34 +00:00
if ( ! buffer ( ) . params ( ) . branchlist ( ) . find ( * it ) )
unknown_branches . append ( toqstr ( * it ) ) ;
}
branchesModule - > setUnknownBranches ( unknown_branches ) ;
}
2009-07-10 06:49:51 +00:00
void GuiDocument : : branchesRename ( docstring const & oldname , docstring const & newname )
{
2009-07-11 09:37:28 +00:00
map < docstring , docstring > : : iterator it = changedBranches_ . begin ( ) ;
for ( ; it ! = changedBranches_ . end ( ) ; + + it ) {
if ( it - > second = = oldname ) {
// branch has already been renamed
it - > second = newname ;
return ;
}
}
// store new name
changedBranches_ [ oldname ] = newname ;
}
void GuiDocument : : executeBranchRenaming ( ) const
{
map < docstring , docstring > : : const_iterator it = changedBranches_ . begin ( ) ;
for ( ; it ! = changedBranches_ . end ( ) ; + + it ) {
docstring const arg = ' " ' + it - > first + ' " ' + " " + ' " ' + it - > second + ' " ' ;
dispatch ( FuncRequest ( LFUN_BRANCHES_RENAME , arg ) ) ;
}
2009-07-10 06:49:51 +00:00
}
2007-11-23 09:44:02 +00:00
Dialog * createGuiDocument ( GuiView & lv ) { return new GuiDocument ( lv ) ; }
2007-10-06 22:43:21 +00:00
2006-03-05 17:24:44 +00:00
} // namespace frontend
} // namespace lyx
2007-04-24 19:37:34 +00:00
2008-11-14 14:28:50 +00:00
# include "moc_GuiDocument.cpp"