HPP += DockView.h
HPP += EmptyTable.h
HPP += FloatPlacement.h
+HPP += GuiAbout.h
HPP += GuiApplication.h
+HPP += GuiBibitem.h
+HPP += GuiBibtex.h
+HPP += GuiBox.h
+HPP += GuiBranches.h
+HPP += GuiBranch.h
+HPP += GuiChanges.h
+HPP += GuiCharacter.h
+HPP += GuiCitationDialog.h
+HPP += GuiCitation.h
HPP += GuiClipboard.h
+HPP += GuiCommandBuffer.h
+HPP += GuiCommandEdit.h
+HPP += GuiDelimiterDialog.h
+HPP += GuiDialogView.h
+HPP += GuiDocument.h
+HPP += GuiErrorList.h
+HPP += GuiERT.h
+HPP += GuiExternal.h
+HPP += GuiFloatDialog.h
+HPP += GuiFloat.h
+HPP += GuiFontExample.h
HPP += GuiFontLoader.h
HPP += GuiFontMetrics.h
+HPP += GuiGraphicsDialog.h
+HPP += GuiGraphics.h
+HPP += GuiGraphicsUi.h
+HPP += GuiImage.h
HPP += GuiImplementation.h
+HPP += GuiInclude.h
+HPP += GuiIndex.h
+HPP += GuiKeySymbol.h
+HPP += GuiListings.h
+HPP += GuiLog.h
+HPP += GuiMathMatrixDialog.h
+HPP += GuiMenubar.h
+HPP += GuiNomencl.h
+HPP += GuiNote.h
+HPP += GuiPainter.h
+HPP += GuiParagraph.h
+HPP += GuiPopupMenu.h
+HPP += GuiPrefs.h
+HPP += GuiPrintDialog.h
+HPP += GuiPrint.h
+HPP += GuiRef.h
+HPP += GuiSearch.h
HPP += GuiSelection.h
+HPP += GuiSendto.h
+HPP += GuiSetBorder.h
+HPP += GuiShowFile.h
+HPP += GuiSpellchecker.h
+HPP += Guit2BC.h
+HPP += GuiTabularCreate.h
+HPP += GuiTabular.h
+HPP += GuiTexinfo.h
+HPP += GuiThesaurus.h
+HPP += GuiToc.h
+HPP += GuiToolbar.h
+HPP += GuiURLDialog.h
HPP += GuiView.h
+HPP += GuiViewSource.h
+HPP += GuiVSpace.h
HPP += GuiWorkArea.h
+HPP += GuiWrap.h
HPP += IconPalette.h
HPP += InsertTableWidget.h
HPP += LengthCombo.h
HPP += LyXFileDialog.h
HPP += PanelStack.h
HPP += pch.h
-HPP += QAbout.h
-HPP += QBibitem.h
-HPP += QBibtex.h
-HPP += QBox.h
-HPP += QBranches.h
-HPP += QBranch.h
-HPP += QChanges.h
-HPP += QCharacter.h
-HPP += QCitationDialog.h
-HPP += QCitation.h
-HPP += QCommandBuffer.h
-HPP += QCommandEdit.h
-HPP += QDelimiterDialog.h
-HPP += QDialogView.h
-HPP += QDocument.h
-HPP += QErrorList.h
-HPP += QERT.h
-HPP += QExternal.h
-HPP += QFloatDialog.h
-HPP += QFloat.h
-HPP += QFontExample.h
-HPP += QGraphicsDialog.h
-HPP += QGraphics.h
-HPP += QGraphicsUi.h
-HPP += QInclude.h
-HPP += QIndex.h
-HPP += QKeySymbol.h
-HPP += QLImage.h
-HPP += QListings.h
HPP += qlkey.h
-HPP += QLMenubar.h
-HPP += QLog.h
-HPP += QLPainter.h
-HPP += QLPopupMenu.h
-HPP += QLPrintDialog.h
-HPP += QLToolbar.h
-HPP += QMathMatrixDialog.h
-HPP += QNomencl.h
-HPP += QNote.h
-HPP += QParagraph.h
-HPP += QPrefs.h
-HPP += QPrint.h
-HPP += QRef.h
-HPP += QSearch.h
-HPP += QSendto.h
-HPP += QSetBorder.h
-HPP += QShowFile.h
-HPP += QSpellchecker.h
-HPP += Qt2BC.h
-HPP += QTabularCreate.h
-HPP += QTabular.h
-HPP += QTexinfo.h
HPP += qt_helpers.h
-HPP += QThesaurus.h
-HPP += QToc.h
-HPP += QURLDialog.h
-HPP += QViewSource.h
-HPP += QVSpace.h
-HPP += QWrap.h
HPP += socket_callback.h
HPP += TocModel.h
HPP += TocWidget.h
CPP += EmptyTable.cpp
CPP += FileDialog.cpp
CPP += FloatPlacement.cpp
+CPP += GuiAbout.cpp
CPP += GuiApplication.cpp
+CPP += GuiBibitem.cpp
+CPP += GuiBibtex.cpp
+CPP += GuiBox.cpp
+CPP += GuiBranch.cpp
+CPP += GuiBranches.cpp
+CPP += GuiChanges.cpp
+CPP += GuiCharacter.cpp
+CPP += GuiCitation.cpp
+CPP += GuiCitationDialog.cpp
CPP += GuiClipboard.cpp
+CPP += GuiCommandBuffer.cpp
+CPP += GuiCommandEdit.cpp
+CPP += GuiDelimiterDialog.cpp
+CPP += GuiDialogView.cpp
+CPP += GuiDocument.cpp
+CPP += GuiErrorList.cpp
+CPP += GuiERT.cpp
+CPP += GuiExternal.cpp
+CPP += GuiFloat.cpp
+CPP += GuiFloatDialog.cpp
+CPP += GuiFontExample.cpp
CPP += GuiFontLoader.cpp
CPP += GuiFontMetrics.cpp
+CPP += GuiGraphics.cpp
+CPP += GuiGraphicsDialog.cpp
+CPP += GuiImage.cpp
CPP += GuiImplementation.cpp
+CPP += GuiInclude.cpp
+CPP += GuiIndex.cpp
+CPP += GuiKeySymbol.cpp
+CPP += GuiListings.cpp
+CPP += GuiLog.cpp
+CPP += GuiMathMatrixDialog.cpp
+CPP += GuiMenubar.cpp
+CPP += GuiNomencl.cpp
+CPP += GuiNote.cpp
+CPP += GuiPainter.cpp
+CPP += GuiParagraph.cpp
+CPP += GuiPopupMenu.cpp
+CPP += GuiPrefs.cpp
+CPP += GuiPrint.cpp
+CPP += GuiPrintDialog.cpp
+CPP += GuiRef.cpp
+CPP += GuiSearch.cpp
CPP += GuiSelection.cpp
+CPP += GuiSendto.cpp
+CPP += GuiSetBorder.cpp
+CPP += GuiShowFile.cpp
+CPP += GuiSpellchecker.cpp
+CPP += Guit2BC.cpp
+CPP += GuiTabular.cpp
+CPP += GuiTabularCreate.cpp
+CPP += GuiTexinfo.cpp
+CPP += GuiThesaurus.cpp
+CPP += GuiToc.cpp
+CPP += GuiToolbar.cpp
+CPP += GuiURLDialog.cpp
CPP += GuiView.cpp
+CPP += GuiViewSource.cpp
+CPP += GuiVSpace.cpp
CPP += GuiWorkArea.cpp
+CPP += GuiWrap.cpp
CPP += IconPalette.cpp
CPP += InsertTableWidget.cpp
CPP += KeySymbol.cpp
CPP += LengthCombo.cpp
CPP += LyXFileDialog.cpp
CPP += PanelStack.cpp
-CPP += QAbout.cpp
-CPP += QBibitem.cpp
-CPP += QBibtex.cpp
-CPP += QBox.cpp
-CPP += QBranch.cpp
-CPP += QBranches.cpp
-CPP += QChanges.cpp
-CPP += QCharacter.cpp
-CPP += QCitation.cpp
-CPP += QCitationDialog.cpp
-CPP += QCommandBuffer.cpp
-CPP += QCommandEdit.cpp
-CPP += QDelimiterDialog.cpp
-CPP += QDialogView.cpp
-CPP += QDocument.cpp
-CPP += QErrorList.cpp
-CPP += QERT.cpp
-CPP += QExternal.cpp
-CPP += QFloat.cpp
-CPP += QFloatDialog.cpp
-CPP += QFontExample.cpp
-CPP += QGraphics.cpp
-CPP += QGraphicsDialog.cpp
-CPP += QInclude.cpp
-CPP += QIndex.cpp
-CPP += QKeySymbol.cpp
-CPP += QLImage.cpp
-CPP += QListings.cpp
-CPP += QLMenubar.cpp
-CPP += QLog.cpp
-CPP += QLPainter.cpp
-CPP += QLPopupMenu.cpp
-CPP += QLPrintDialog.cpp
-CPP += QLToolbar.cpp
-CPP += QMathMatrixDialog.cpp
-CPP += QNomencl.cpp
-CPP += QNote.cpp
-CPP += QParagraph.cpp
-CPP += QPrefs.cpp
-CPP += QPrint.cpp
-CPP += QRef.cpp
-CPP += QSearch.cpp
-CPP += QSendto.cpp
-CPP += QSetBorder.cpp
-CPP += QShowFile.cpp
-CPP += QSpellchecker.cpp
-CPP += Qt2BC.cpp
-CPP += QTabular.cpp
-CPP += QTabularCreate.cpp
-CPP += QTexinfo.cpp
CPP += qt_helpers.cpp
-CPP += QThesaurus.cpp
-CPP += QToc.cpp
-CPP += QURLDialog.cpp
-CPP += QViewSource.cpp
-CPP += QVSpace.cpp
-CPP += QWrap.cpp
CPP += socket_callback.cpp
CPP += TocModel.cpp
CPP += TocWidget.cpp
DockView.h
EmptyTable.h
FloatPlacement.h
+ GuiAbout.h
GuiApplication.h
+ GuiBibitem.h
+ GuiBibtex.h
+ GuiBox.h
+ GuiBranches.h
+ GuiBranch.h
+ GuiChanges.h
+ GuiCharacter.h
+ GuiCharacter.h
+ GuiCitationDialog.h
+ GuiCitation.h
GuiClipboard.h
+ GuiCommandBuffer.h
+ GuiCommandEdit.h
+ GuiDelimiterDialog.h
+ GuiDialogView.h
+ GuiDocument.h
+ GuiErrorList.h
+ GuiERT.h
+ GuiExternal.h
+ GuiFloatDialog.h
+ GuiFloat.h
+ GuiFontExample.h
GuiFontLoader.h
+ GuiGraphicsDialog.h
+ GuiGraphics.h
+ GuiGraphicsUi.h
+ GuiImage.h
GuiImplementation.h
+ GuiInclude.h
+ GuiIndex.h
+ GuiKeySymbol.h
+ GuiListings.h
+ GuiLog.h
+ GuiMathMatrixDialog.h
+ GuiMenubar.h
+ GuiNomencl.h
+ GuiNote.h
+ GuiPainter.h
+ GuiParagraph.h
+ GuiPopupMenu.h
+ GuiPrefs.h
+ GuiPrintDialog.h
+ GuiPrint.h
+ GuiRef.h
+ GuiSearch.h
GuiSelection.h
+ GuiSelectionManager.h
+ GuiSendto.h
+ GuiSetBorder.h
+ GuiShowFile.h
+ GuiSpellchecker.h
+ GuiTabularCreate.h
+ GuiTabular.h
+ GuiTexinfo.h
+ GuiThesaurus.h
+ GuiToc.h
+ GuiToolbar.h
+ GuiURLDialog.h
GuiView.h
+ GuiViewSource.h
+ GuiVSpace.h
GuiWorkArea.h
+ GuiWrap.h
IconPalette.h
InsertTableWidget.h
LengthCombo.h
LyXFileDialog.h
PanelStack.h
- QAbout.h
- QBibitem.h
- QBibtex.h
- QBox.h
- QBranch.h
- QBranches.h
- QChanges.h
- QCharacter.h
- QCharacter.h
- QCitation.h
- QCitationDialog.h
- QCommandBuffer.h
- QCommandEdit.h
- QDelimiterDialog.h
- QDialogView.h
- QDocument.h
- QERT.h
- QErrorList.h
- QExternal.h
- QFloat.h
- QFloatDialog.h
- QFontExample.h
- QGraphics.h
- QGraphicsDialog.h
- QGraphicsUi.h
- QInclude.h
- QIndex.h
- QKeySymbol.h
- QListings.h
- QLImage.h
- QLMenubar.h
- QLPainter.h
- QLPopupMenu.h
- QLPrintDialog.h
- QLToolbar.h
- QLog.h
- QMathMatrixDialog.h
- QNomencl.h
- QNote.h
- QParagraph.h
- QPrefs.h
- QPrint.h
- QRef.h
- QSearch.h
- QSelectionManager.h
- QSendto.h
- QSetBorder.h
- QShowFile.h
- QSpellchecker.h
- QTabular.h
- QTabularCreate.h
- QTexinfo.h
- QThesaurus.h
- QToc.h
- QURLDialog.h
- QVSpace.h
- QViewSource.h
- QWrap.h
Qt2BC.h
TocModel.h
TocWidget.h
EmptyTable.cpp
FileDialog.cpp
FloatPlacement.cpp
+ GuiAbout.cpp
GuiApplication.cpp
+ GuiBibitem.cpp
+ GuiBibtex.cpp
+ GuiBox.cpp
+ GuiBranch.cpp
+ GuiBranches.cpp
+ GuiChanges.cpp
+ GuiCharacter.cpp
+ GuiCitation.cpp
+ GuiCitationDialog.cpp
GuiClipboard.cpp
+ GuiCommandBuffer.cpp
+ GuiCommandEdit.cpp
+ GuiDelimiterDialog.cpp
+ GuiDialogView.cpp
+ GuiDocument.cpp
+ GuiErrorList.cpp
+ GuiERT.cpp
+ GuiExternal.cpp
+ GuiFloat.cpp
+ GuiFloatDialog.cpp
+ GuiFontExample.cpp
GuiFontLoader.cpp
GuiFontMetrics.cpp
+ GuiGraphics.cpp
+ GuiGraphicsDialog.cpp
+ GuiImage.cpp
GuiImplementation.cpp
+ GuiInclude.cpp
+ GuiIndex.cpp
+ GuiKeySymbol.cpp
+ GuiListings.cpp
+ GuiLog.cpp
+ GuiMathMatrixDialog.cpp
+ GuiMenubar.cpp
+ GuiNomencl.cpp
+ GuiNote.cpp
+ GuiPainter.cpp
+ GuiParagraph.cpp
+ GuiPopupMenu.cpp
+ GuiPrefs.cpp
+ GuiPrint.cpp
+ GuiPrintDialog.cpp
+ GuiRef.cpp
+ GuiSearch.cpp
GuiSelection.cpp
+ GuiSelectionManager.cpp
+ GuiSendto.cpp
+ GuiSetBorder.cpp
+ GuiShowFile.cpp
+ GuiSpellchecker.cpp
+ GuiTabular.cpp
+ GuiTabularCreate.cpp
+ GuiTexinfo.cpp
+ GuiThesaurus.cpp
+ GuiToc.cpp
+ GuiToolbar.cpp
+ GuiURLDialog.cpp
GuiView.cpp
+ GuiViewSource.cpp
+ GuiVSpace.cpp
GuiWorkArea.cpp
+ GuiWrap.cpp
IconPalette.cpp
InsertTableWidget.cpp
KeySymbol.cpp
LengthCombo.cpp
LyXFileDialog.cpp
PanelStack.cpp
- QAbout.cpp
- QBibitem.cpp
- QBibtex.cpp
- QBox.cpp
- QBranch.cpp
- QBranches.cpp
- QChanges.cpp
- QCharacter.cpp
- QCitation.cpp
- QCitationDialog.cpp
- QCommandBuffer.cpp
- QCommandEdit.cpp
- QDelimiterDialog.cpp
- QDialogView.cpp
- QDocument.cpp
- QERT.cpp
- QErrorList.cpp
- QExternal.cpp
- QFloat.cpp
- QFloatDialog.cpp
- QFontExample.cpp
- QGraphics.cpp
- QGraphicsDialog.cpp
- QInclude.cpp
- QIndex.cpp
- QKeySymbol.cpp
- QListings.cpp
- QLImage.cpp
- QLMenubar.cpp
- QLPainter.cpp
- QLPopupMenu.cpp
- QLPrintDialog.cpp
- QLToolbar.cpp
- QLog.cpp
- QMathMatrixDialog.cpp
- QNomencl.cpp
- QNote.cpp
- QParagraph.cpp
- QPrefs.cpp
- QPrint.cpp
- QRef.cpp
- QSearch.cpp
- QSelectionManager.cpp
- QSendto.cpp
- QSetBorder.cpp
- QShowFile.cpp
- QSpellchecker.cpp
- QTabular.cpp
- QTabularCreate.cpp
- QTexinfo.cpp
- QThesaurus.cpp
- QToc.cpp
- QURLDialog.cpp
- QVSpace.cpp
- QViewSource.cpp
- QWrap.cpp
Qt2BC.cpp
TocModel.cpp
TocWidget.cpp
namespace frontend {
-Action::Action(GuiView & lyxView, docstring const & text,
+Action::Action(GuiViewBase & lyxView, docstring const & text,
FuncRequest const & func, docstring const & tooltip)
: QAction(&lyxView), func_(func), lyxView_(lyxView)
{
update();
}
-Action::Action(GuiView & lyxView, string const & icon, docstring const & text,
+Action::Action(GuiViewBase & lyxView, string const & icon, docstring const & text,
FuncRequest const & func, docstring const & tooltip)
: QAction(&lyxView), func_(func), lyxView_(lyxView)
{
namespace lyx {
namespace frontend {
-class GuiView;
+class GuiViewBase;
/**
* Action - Qt interface with LyX' FuncRequest.
Q_OBJECT
public:
- Action(GuiView & lyxView, docstring const & text,
+ Action(GuiViewBase & lyxView, docstring const & text,
FuncRequest const & func, docstring const & tooltip = docstring());
- Action(GuiView & lyxView, std::string const & icon, docstring const & text,
+ Action(GuiViewBase & lyxView, std::string const & icon, docstring const & text,
FuncRequest const & func, docstring const & tooltip = docstring());
void update();
private:
FuncRequest const & func_ ;
- GuiView & lyxView_;
+ GuiViewBase & lyxView_;
};
* QGraphicsDialog.C (c-tor): add a PathValidator of the filename
widget.
- * QInclude.C (build_dialog, update_contents):
- * QIncludeDialog.C (c-tor): add a PathValidator of the filenameED
+ * GuiInclude.C (build_dialog, update_contents):
+ * GuiIncludeDialog.C (c-tor): add a PathValidator of the filenameED
widget.
2005-05-09 Michael Schmitt <michael.schmitt@teststep.org>
2004-07-24 Lars Gullik Bjønnes <larsbj@gullik.net>
* QPrefs.C, QMathMatrixDialog.C:
- * QLog.C, QAbout.C: change "support/std_sstream.h" to <sstream>
+ * GuiLog.C, QAbout.C: change "support/std_sstream.h" to <sstream>
2004-07-22 Lars Gullik Bjønnes <larsbj@gullik.net>
* QExternalDialog.C (browseClicked):
* QGraphicsDialog.C (browse_clicked):
- * QInclude.C (browse):
+ * GuiInclude.C (browse):
changes doe to the name change controller().Browse() to
controller().browse().
2003-12-05 Angus Leeming <leeming@lyx.org>
- * QLog.C: much simplified, thanks to the more powerful interface
+ * GuiLog.C: much simplified, thanks to the more powerful interface
of ControlLog.
* Dialogs.C: no need anymore to build a separate VCLog dialog.
2003-09-19 Angus Leeming <leeming@lyx.org>
- * QInclude.C: changes dues to the changed storage in InsetInclude,
+ * GuiInclude.C: changes dues to the changed storage in InsetInclude,
from an InsetInclude::params to an InsetCommandParams.
2003-09-18 Angus Leeming <leeming@lyx.org>
- * QInclude.C (apply): No need to set InsetInclude::Params::flag;
+ * GuiInclude.C (apply): No need to set InsetInclude::Params::flag;
the variable has been removed. Instead, set the command name directly.
2003-09-18 Angus Leeming <leeming@lyx.org>
* QGraphics.C:
* QLMenubar.C:
* QLPopupMenu.C:
- * QLog.C:
+ * GuiLog.C:
* QMathDialog.C:
* QParagraphDialog.C:
* QPrefsDialog.C:
* QExternal.C:
* QFloat.C:
* QGraphics.C:
- * QInclude.C:
- * QLog.C:
+ * GuiInclude.C:
+ * GuiLog.C:
* QMinipage.C:
* QParagraph.C:
* QRef.C:
2003-04-07 John Levon <levon@movementarian.org>
- * ui/QIncludeDialogBase.ui: make "Show preview"
+ * ui/GuiIncludeDialogBase.ui: make "Show preview"
call change_adaptor()
2003-04-07 John Levon <levon@movementarian.org>
* Dialogs3.C: add these dialogs.
- * QLog.[Ch]:
+ * GuiLog.[Ch]:
* QShowFile.[Ch]:
* QVCLog.[Ch]: changes to use the new Dialog-based scheme.
2003-03-05 Angus Leeming <leeming@lyx.org>
- * QInclude.[Ch]: changes to use the new Dialog-based scheme.
+ * GuiInclude.[Ch]: changes to use the new Dialog-based scheme.
* Dialogs.C:
* Dialogs2.C:
* QDocument.C: rename "Xxxskip" to "XxxSkip"
* QGraphicsDialog.C:
- * QLog.C: Make output messages identical to other messages
+ * GuiLog.C: Make output messages identical to other messages
* ui/*.ui: In strings, remove space in front of colon
("... :" => "...:") for harmonization with xforms labels
2002-12-03 John Levon <levon@movementarian.org>
- * QIncludeDialog.C: another fix
+ * GuiIncludeDialog.C: another fix
2002-12-03 John Levon <levon@movementarian.org>
- * ui/QIncludeDialog.ui:
- * QInclude.C: support preview()
+ * ui/GuiIncludeDialog.ui:
+ * GuiInclude.C: support preview()
2002-12-01 Lars Gullik Bjønnes <larsbj@gullik.net>
2002-11-07 John Levon <levon@movementarian.org>
- * ui/QIncludeDialog.ui:
- * QInclude.C: fix setting of combobox
+ * ui/GuiIncludeDialog.ui:
+ * GuiInclude.C: fix setting of combobox
2002-11-07 John Levon <levon@movementarian.org>
* QLyXKeySym.C (operator=): out of class version.
- * QLog.C (update_contents): use a simpler and faster way to fill
+ * GuiLog.C (update_contents): use a simpler and faster way to fill
the log dialog.
* QLPopupMenu.C (getLabel): use subst directly on mi.label()
(lines): put int i inside for scope
(fillPolygon): put j insize for scope
- * QInclude.C (update_contents): local ref to params
+ * GuiInclude.C (update_contents): local ref to params
(apply): ditto
* QGraphics.C (update_contents): initialize item to 0
* QExternalDialog.C:
* QGraphicsDialog.h:
* QGraphicsDialog.C:
- * QIncludeDialog.h:
- * QIncludeDialog.C:
+ * GuiIncludeDialog.h:
+ * GuiIncludeDialog.C:
* QIndexDialog.h:
* QIndexDialog.C:
* QSearchDialog.h:
2002-09-10 John Levon <levon@movementarian.org>
- * ui/QIncludeDialog.ui:
- * QInclude.h:
- * QInclude.C: remove don't typeset
+ * ui/GuiIncludeDialog.ui:
+ * GuiInclude.h:
+ * GuiInclude.C: remove don't typeset
* Dialogs2.C: add empty showWrap
* iconpalette.C (resizeEvent): compile fix.
- * QInclude.C (update_contents): remove lyxerr call.
+ * GuiInclude.C (update_contents): remove lyxerr call.
2002-09-08 John Levon <levon@movementarian.org>
2002-08-29 John Levon <levon@movementarian.org>
- * QInclude.C: remove some wrong code removed from xforms
+ * GuiInclude.C: remove some wrong code removed from xforms
2002-08-29 John Levon <levon@movementarian.org>
* QExternal.[Ch]:
* QFloat.[Ch]:
* QGraphics.[Ch]:
- * QInclude.[Ch]:
+ * GuiInclude.[Ch]:
* QIndex.[Ch]:
- * QLog.[Ch]:
+ * GuiLog.[Ch]:
* QMinipage.[Ch]:
* QParagraph.[Ch]:
* QPreamble.[Ch]:
* ui/QRefDialog.ui: document combo
* QRef.C: idem
- * QInclude.C: new layout
- * ui/QIncludeDialog.ui: new layout
+ * GuiInclude.C: new layout
+ * ui/GuiIncludeDialog.ui: new layout
* ui/QCitationDialog.ui: new layout
2001-08-31 Edwin Leuven <leuven@fee.uva.nl>
* ui/QGraphicsDialog.ui : minor layout tweak
- * ui/QIncludeDialog.ui : idem
+ * ui/GuiIncludeDialog.ui : idem
* ui/QMinipageDialog.ui: idem
* ui/QURLDialog.ui: idem
was failing with "incomplete type is not allowed" in instantiation
of boost::scoped_ptr<QDocumentDialog> dialog_.
- * QLog.C: added a couple of using std::xyz directives.
+ * GuiLog.C: added a couple of using std::xyz directives.
* QPreambleDialog.C: added a using std::getline directive.
2001-08-29 John Levon <moz@compsoc.man.ac.uk>
- * QLog.[Ch]:
- * QLogDialog.[Ch]:
- * ui/QLogDialog.ui:
+ * GuiLog.[Ch]:
+ * GuiLogDialog.[Ch]:
+ * ui/GuiLogDialog.ui:
* QVCLog.[Ch]:
* QVCLogDialog.[Ch]:
* ui/QVCLogDialog.ui:
* QThesaurus.C: clear selection on update
- * QInclude.[Ch]:
+ * GuiInclude.[Ch]:
* QincludeDialog.[Ch]:
* ui/QincludeDialog.ui:
* Makefile.am:
#include "ButtonController.h"
#include "DockView.h"
#include "GuiView.h"
-#include "QAbout.h"
-#include "QBibitem.h"
-#include "QBibtex.h"
-#include "QBox.h"
-#include "QBranch.h"
-#include "QChanges.h"
-#include "QCharacter.h"
-#include "QCitation.h"
-#include "QCitationDialog.h"
-#include "QDelimiterDialog.h"
-#include "QDocument.h"
-#include "QErrorList.h"
-#include "QERT.h"
-#include "QExternal.h"
-#include "QFloat.h"
-#include "QGraphics.h"
-#include "QInclude.h"
-#include "QIndex.h"
-#include "QMathMatrixDialog.h"
-#include "QNomencl.h"
-#include "QListings.h"
-#include "QLog.h"
-#include "QViewSource.h"
-#include "QNote.h"
-#include "QParagraph.h"
-#include "QPrefs.h"
-#include "QPrint.h"
-#include "QRef.h"
-#include "QSearch.h"
-#include "QSendto.h"
-#include "QShowFile.h"
-#include "QSpellchecker.h"
-#include "QTabular.h"
-#include "QTabularCreate.h"
-#include "QTexinfo.h"
-#include "QToc.h"
+#include "GuiAbout.h"
+#include "GuiBibitem.h"
+#include "GuiBibtex.h"
+#include "GuiBox.h"
+#include "GuiBranch.h"
+#include "GuiChanges.h"
+#include "GuiCharacter.h"
+#include "GuiCitation.h"
+#include "GuiCitationDialog.h"
+#include "GuiDelimiterDialog.h"
+#include "GuiDocument.h"
+#include "GuiErrorList.h"
+#include "GuiERT.h"
+#include "GuiExternal.h"
+#include "GuiFloat.h"
+#include "GuiGraphics.h"
+#include "GuiInclude.h"
+#include "GuiIndex.h"
+#include "GuiMathMatrixDialog.h"
+#include "GuiNomencl.h"
+#include "GuiListings.h"
+#include "GuiLog.h"
+#include "GuiViewSource.h"
+#include "GuiNote.h"
+#include "GuiParagraph.h"
+#include "GuiPrefs.h"
+#include "GuiPrint.h"
+#include "GuiRef.h"
+#include "GuiSearch.h"
+#include "GuiSendto.h"
+#include "GuiShowFile.h"
+#include "GuiSpellchecker.h"
+#include "GuiTabular.h"
+#include "GuiTabularCreate.h"
+#include "GuiTexinfo.h"
+#include "GuiToc.h"
#include "TocWidget.h"
#include "UrlView.h"
-#include "QVSpace.h"
-#include "QWrap.h"
+#include "GuiVSpace.h"
+#include "GuiWrap.h"
#ifdef HAVE_LIBAIKSAURUS
#include "ControlThesaurus.h"
-#include "QThesaurus.h"
+#include "GuiThesaurus.h"
#endif
#include "qt_helpers.h"
if (name == "aboutlyx") {
dialog->setController(new ControlAboutlyx(*dialog));
- dialog->setView(new QAbout(*dialog));
+ dialog->setView(new GuiAbout(*dialog));
dialog->bc().bp(new OkCancelPolicy);
} else if (name == "bibitem") {
dialog->setController(new ControlCommand(*dialog, name, name));
- dialog->setView(new QBibitem(*dialog));
+ dialog->setView(new GuiBibitem(*dialog));
dialog->bc().bp(new OkCancelReadOnlyPolicy);
} else if (name == "bibtex") {
dialog->setController(new ControlBibtex(*dialog));
- dialog->setView(new QBibtex(*dialog));
+ dialog->setView(new GuiBibtex(*dialog));
dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
} else if (name == "box") {
dialog->setController(new ControlBox(*dialog));
- dialog->setView(new QBox(*dialog));
+ dialog->setView(new GuiBox(*dialog));
dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
} else if (name == "branch") {
dialog->setController(new ControlBranch(*dialog));
- dialog->setView(new QBranch(*dialog));
+ dialog->setView(new GuiBranch(*dialog));
dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
} else if (name == "changes") {
dialog->setController(new ControlChanges(*dialog));
- dialog->setView(new QChanges(*dialog));
+ dialog->setView(new GuiChanges(*dialog));
dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
} else if (name == "character") {
dialog->setController(new ControlCharacter(*dialog));
- dialog->setView(new QCharacter(*dialog));
+ dialog->setView(new GuiCharacter(*dialog));
dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
} else if (name == "citation") {
- QCitation * ci = new QCitation(*dialog);
+ GuiCitation * ci = new GuiCitation(*dialog);
dialog->setController(ci);
- dialog->setView(new QCitationDialog(*dialog, ci));
+ dialog->setView(new GuiCitationDialog(*dialog, ci));
dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
} else if (name == "document") {
dialog->setController(new ControlDocument(*dialog));
- dialog->setView(new QDocument(*dialog));
+ dialog->setView(new GuiDocument(*dialog));
dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
} else if (name == "errorlist") {
dialog->setController(new ControlErrorList(*dialog));
- dialog->setView(new QErrorList(*dialog));
+ dialog->setView(new GuiErrorList(*dialog));
dialog->bc().bp(new OkCancelPolicy);
} else if (name == "ert") {
dialog->setController(new ControlERT(*dialog));
- dialog->setView(new QERT(*dialog));
+ dialog->setView(new GuiERT(*dialog));
dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
} else if (name == "external") {
dialog->setController(new ControlExternal(*dialog));
- dialog->setView(new QExternal(*dialog));
+ dialog->setView(new GuiExternal(*dialog));
dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
} else if (name == "file") {
dialog->setController(new ControlShowFile(*dialog));
- dialog->setView(new QShowFile(*dialog));
+ dialog->setView(new GuiShowFile(*dialog));
dialog->bc().bp(new OkCancelPolicy);
} else if (name == "findreplace") {
dialog->setController(new ControlSearch(*dialog));
- dialog->setView(new QSearch(*dialog));
+ dialog->setView(new GuiSearch(*dialog));
dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
} else if (name == "float") {
dialog->setController(new ControlFloat(*dialog));
- dialog->setView(new QFloat(*dialog));
+ dialog->setView(new GuiFloat(*dialog));
dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
} else if (name == "graphics") {
dialog->setController(new ControlGraphics(*dialog));
- dialog->setView(new QGraphics(*dialog));
+ dialog->setView(new GuiGraphics(*dialog));
dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
} else if (name == "include") {
dialog->setController(new ControlInclude(*dialog));
- dialog->setView(new QInclude(*dialog));
+ dialog->setView(new GuiInclude(*dialog));
dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
} else if (name == "index") {
dialog->setController(new ControlCommand(*dialog, name, name));
- dialog->setView(new QIndex(*dialog,
+ dialog->setView(new GuiIndex(*dialog,
_("Index Entry"),
qt_("&Keyword:")));
dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
} else if (name == "nomenclature") {
dialog->setController(new ControlCommand(*dialog, name, name));
- dialog->setView(new QNomencl(*dialog, _("Nomenclature Entry")));
+ dialog->setView(new GuiNomencl(*dialog, _("Nomenclature Entry")));
dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
} else if (name == "label") {
dialog->setController(new ControlCommand(*dialog, name, name));
- dialog->setView(new QIndex(*dialog,
+ dialog->setView(new GuiIndex(*dialog,
_("Label"),
qt_("&Label:")));
dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
} else if (name == "log") {
dialog->setController(new ControlLog(*dialog));
- dialog->setView(new QLog(*dialog));
+ dialog->setView(new GuiLog(*dialog));
dialog->bc().bp(new OkCancelPolicy);
} else if (name == "view-source") {
- QViewSource * qvs = new QViewSource(*dialog);
+ GuiViewSource * qvs = new GuiViewSource(*dialog);
dialog->setController(qvs);
- GuiView & gui_view = static_cast<GuiView &>(lyxview_);
- dialog->setView(new DockView<QViewSource, QViewSourceDialog>(
+ GuiViewBase & gui_view = static_cast<GuiViewBase &>(lyxview_);
+ dialog->setView(new DockView<GuiViewSource, GuiViewSourceDialog>(
*dialog, qvs, &gui_view, _("LaTeX Source"), Qt::BottomDockWidgetArea));
dialog->bc().bp(new OkCancelPolicy);
} else if (name == "mathdelimiter") {
dialog->setController(new ControlMath(*dialog));
- dialog->setView(new QMathDelimiter(*dialog));
+ dialog->setView(new GuiMathDelimiter(*dialog));
dialog->bc().bp(new IgnorantPolicy);
} else if (name == "mathmatrix") {
dialog->setController(new ControlMath(*dialog));
- dialog->setView(new QMathMatrix(*dialog));
+ dialog->setView(new GuiMathMatrix(*dialog));
dialog->bc().bp(new IgnorantPolicy);
} else if (name == "note") {
dialog->setController(new ControlNote(*dialog));
- dialog->setView(new QNote(*dialog));
+ dialog->setView(new GuiNote(*dialog));
dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
} else if (name == "paragraph") {
dialog->setController(new ControlParagraph(*dialog));
- dialog->setView(new QParagraph(*dialog));
+ dialog->setView(new GuiParagraph(*dialog));
dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
} else if (name == "prefs") {
dialog->setController(new ControlPrefs(*dialog));
- dialog->setView(new QPrefs(*dialog));
+ dialog->setView(new GuiPrefs(*dialog));
dialog->bc().bp(new PreferencesPolicy);
} else if (name == "print") {
dialog->setController(new ControlPrint(*dialog));
- dialog->setView(new QPrint(*dialog));
+ dialog->setView(new GuiPrint(*dialog));
dialog->bc().bp(new OkApplyCancelPolicy);
} else if (name == "ref") {
// full qualification because qt4 has also a ControlRef type
dialog->setController(new ControlRef(*dialog));
- dialog->setView(new QRef(*dialog));
+ dialog->setView(new GuiRef(*dialog));
dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
} else if (name == "sendto") {
dialog->setController(new ControlSendto(*dialog));
- dialog->setView(new QSendto(*dialog));
+ dialog->setView(new GuiSendto(*dialog));
dialog->bc().bp(new OkApplyCancelPolicy);
} else if (name == "spellchecker") {
dialog->setController(new ControlSpellchecker(*dialog));
- dialog->setView(new QSpellchecker(*dialog));
+ dialog->setView(new GuiSpellchecker(*dialog));
dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
} else if (name == "tabular") {
dialog->setController(new ControlTabular(*dialog));
- dialog->setView(new QTabular(*dialog));
+ dialog->setView(new GuiTabular(*dialog));
dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
} else if (name == "tabularcreate") {
dialog->setController(new ControlTabularCreate(*dialog));
- dialog->setView(new QTabularCreate(*dialog));
+ dialog->setView(new GuiTabularCreate(*dialog));
dialog->bc().bp(new IgnorantPolicy);
} else if (name == "texinfo") {
dialog->setController(new ControlTexinfo(*dialog));
- dialog->setView(new QTexinfo(*dialog));
+ dialog->setView(new GuiTexinfo(*dialog));
dialog->bc().bp(new OkCancelPolicy);
#ifdef HAVE_LIBAIKSAURUS
} else if (name == "thesaurus") {
dialog->setController(new ControlThesaurus(*dialog));
- dialog->setView(new QThesaurus(*dialog));
+ dialog->setView(new GuiThesaurus(*dialog));
dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
#endif
} else if (name == "toc") {
- GuiView & gui_view = static_cast<GuiView &>(lyxview_);
- QToc * qtoc = new QToc(*dialog, &gui_view);
+ GuiViewBase & gui_view = static_cast<GuiViewBase &>(lyxview_);
+ GuiToc * qtoc = new GuiToc(*dialog, &gui_view);
dialog->setController(qtoc);
#ifdef Q_WS_MACX
// On Mac show as a drawer at the right
- dialog->setView(new DockView<QToc, TocWidget>(
+ dialog->setView(new DockView<GuiToc, TocWidget>(
*dialog, qtoc, &gui_view, _("Outline"), Qt::RightDockWidgetArea, Qt::Drawer));
#else
- dialog->setView(new DockView<QToc, TocWidget>(
+ dialog->setView(new DockView<GuiToc, TocWidget>(
*dialog, qtoc, &gui_view, _("Outline")));
#endif
dialog->bc().bp(new OkCancelPolicy);
dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
} else if (name == "vspace") {
dialog->setController(new ControlVSpace(*dialog));
- dialog->setView(new QVSpace(*dialog));
+ dialog->setView(new GuiVSpace(*dialog));
dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
} else if (name == "wrap") {
dialog->setController(new ControlWrap(*dialog));
- dialog->setView(new QWrap(*dialog));
+ dialog->setView(new GuiWrap(*dialog));
dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
} else if (name == "listings") {
dialog->setController(new ControlListings(*dialog));
- dialog->setView(new QListings(*dialog));
+ dialog->setView(new GuiListings(*dialog));
dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
}
--- /dev/null
+/**
+ * \file GuiAbout.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Kalle Dalheimer
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "GuiAbout.h"
+#include "Qt2BC.h"
+#include "qt_helpers.h"
+
+#include "controllers/ButtonController.h"
+#include "controllers/ControlAboutlyx.h"
+
+#include "support/lstrings.h"
+
+#include <sstream>
+
+#include <QLabel>
+#include <QPushButton>
+#include <QTextCodec>
+#include <QTextBrowser>
+
+using lyx::support::prefixIs;
+
+using std::getline;
+
+using std::istringstream;
+using std::ostringstream;
+using std::string;
+
+namespace lyx {
+namespace frontend {
+
+
+typedef QController<ControlAboutlyx, GuiView<GuiAboutDialog> > AboutBase;
+
+GuiAbout::GuiAbout(Dialog & parent)
+ : AboutBase(parent, _("About LyX"))
+{
+}
+
+
+void GuiAbout::build_dialog()
+{
+ dialog_.reset(new GuiAboutDialog);
+ connect(dialog_.get()->closePB, SIGNAL(clicked()),
+ this, SLOT(slotClose()));
+
+ dialog_->copyrightTB->setPlainText(toqstr(controller().getCopyright()));
+ dialog_->copyrightTB->append("");
+ dialog_->copyrightTB->append(toqstr(controller().getLicense()));
+ dialog_->copyrightTB->append("");
+ dialog_->copyrightTB->append(toqstr(controller().getDisclaimer()));
+
+ dialog_->versionLA->setText(toqstr(controller().getVersion()));
+
+ // The code below should depend on a autoconf test. (Lgb)
+#if 1
+ // There are a lot of buggy stringstream implementations..., but the
+ // code below will work on all of them (I hope). The drawback with
+ // this solutions os the extra copying. (Lgb)
+
+ ostringstream in;
+ controller().getCredits(in);
+
+ istringstream ss(in.str());
+
+ string s;
+ ostringstream out;
+
+ while (getline(ss, s)) {
+ if (prefixIs(s, "@b"))
+ out << "<b>" << s.substr(2) << "</b>";
+ else if (prefixIs(s, "@i"))
+ out << "<i>" << s.substr(2) << "</i>";
+ else
+ out << s;
+ out << "<br>";
+ }
+#else
+ // Good stringstream implementations can handle this. It avoids
+ // some copying, and should thus be faster and use less memory. (Lgb)
+ // I'll make this the default for a short while to see if anyone
+ // see the error...
+ stringstream in;
+ controller().getCredits(in);
+ in.seekg(0);
+ string s;
+ ostringstream out;
+
+ while (getline(in, s)) {
+ if (prefixIs(s, "@b"))
+ out << "<b>" << s.substr(2) << "</b>";
+ else if (prefixIs(s, "@i"))
+ out << "<i>" << s.substr(2) << "</i>";
+ else
+ out << s;
+ out << "<br>";
+ }
+#endif
+
+ dialog_->creditsTB->setHtml(toqstr(out.str()));
+
+ // try to resize to a good size
+ dialog_->copyrightTB->hide();
+ dialog_->setMinimumSize(dialog_->copyrightTB->sizeHint());
+ dialog_->copyrightTB->show();
+ dialog_->setMinimumSize(dialog_->sizeHint());
+
+ // Manage the cancel/close button
+ bcview().setCancel(dialog_->closePB);
+ bc().refresh();
+}
+
+} // namespace frontend
+} // namespace lyx
+
+#include "GuiAbout_moc.cpp"
--- /dev/null
+// -*- C++ -*-
+/**
+ * \file GuiAbout.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Kalle Dalheimer
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#ifndef FORMABOUT_H
+#define FORMABOUT_H
+
+#include "GuiDialogView.h"
+#include "ui_AboutUi.h"
+#include <QDialog>
+
+namespace lyx {
+namespace frontend {
+
+class ControlAboutlyx;
+
+class GuiAboutDialog : public QDialog, public Ui::AboutUi {
+ Q_OBJECT
+public:
+ GuiAboutDialog(QWidget * parent = 0)
+ : QDialog(parent)
+ {
+ setupUi(this);
+ connect(closePB, SIGNAL(clicked()), this, SLOT(reject()));
+ }
+};
+
+
+class GuiAbout
+ : public QController<ControlAboutlyx, GuiView<GuiAboutDialog> >
+{
+public:
+ GuiAbout(Dialog &);
+private:
+ /// not needed
+ virtual void apply() {}
+ /// not needed
+ virtual void update_contents() {}
+ // build the dialog
+ virtual void build_dialog();
+};
+
+} // namespace frontend
+} // namespace lyx
+
+#endif // FORMABOUT_H
#include "GuiApplication.h"
#include "qt_helpers.h"
-#include "QLImage.h"
+#include "GuiImage.h"
#include "socket_callback.h"
#include "frontends/LyXView.h"
--- /dev/null
+/**
+ * \file GuiBibitem.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author John Levon
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "GuiBibitem.h"
+#include "Qt2BC.h"
+#include "qt_helpers.h"
+
+#include "controllers/ControlCommand.h"
+
+#include <QLineEdit>
+#include <QPushButton>
+
+
+namespace lyx {
+namespace frontend {
+
+/////////////////////////////////////////////////////////////////////
+//
+// QBibItemDialog
+//
+/////////////////////////////////////////////////////////////////////
+
+GuiBibitemDialog::GuiBibitemDialog(GuiBibitem * form)
+ : form_(form)
+{
+ setupUi(this);
+ connect(okPB, SIGNAL(clicked()), form, SLOT(slotOK()));
+ connect(closePB, SIGNAL(clicked()), form, SLOT(slotClose()));
+
+ connect(keyED, SIGNAL(textChanged(const QString &)),
+ this, SLOT(change_adaptor()));
+ connect(labelED, SIGNAL(textChanged(const QString &)),
+ this, SLOT(change_adaptor()));
+}
+
+
+void GuiBibitemDialog::change_adaptor()
+{
+ form_->changed();
+}
+
+
+void GuiBibitemDialog::closeEvent(QCloseEvent *e)
+{
+ form_->slotWMHide();
+ e->accept();
+}
+
+
+/////////////////////////////////////////////////////////////////////
+//
+// QBibItem
+//
+/////////////////////////////////////////////////////////////////////
+
+typedef QController<ControlCommand, GuiView<GuiBibitemDialog> > BibItemBase;
+
+
+GuiBibitem::GuiBibitem(Dialog & parent)
+ : BibItemBase(parent, _("Bibliography Entry Settings"))
+{
+}
+
+
+void GuiBibitem::build_dialog()
+{
+ dialog_.reset(new GuiBibitemDialog(this));
+
+ bcview().setOK(dialog_->okPB);
+ bcview().setCancel(dialog_->closePB);
+ bcview().addReadOnly(dialog_->keyED);
+ bcview().addReadOnly(dialog_->labelED);
+}
+
+
+void GuiBibitem::update_contents()
+{
+ dialog_->keyED->setText(toqstr(controller().params()["key"]));
+ dialog_->labelED->setText(toqstr(controller().params()["label"]));
+}
+
+
+void GuiBibitem::apply()
+{
+ controller().params()["key"] = qstring_to_ucs4(dialog_->keyED->text());
+ controller().params()["label"] = qstring_to_ucs4(dialog_->labelED->text());
+}
+
+
+bool GuiBibitem::isValid()
+{
+ return !dialog_->keyED->text().isEmpty();
+}
+
+} // namespace frontend
+} // namespace lyx
+
+#include "GuiBibitem_moc.cpp"
--- /dev/null
+// -*- C++ -*-
+/**
+ * \file GuiBibitem.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author John Levon
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#ifndef QBIBITEM_CONTROLLER_H
+#define QBIBITEM_CONTROLLER_H
+
+#include "GuiDialogView.h"
+
+#include "ui_BibitemUi.h"
+
+#include <QDialog>
+#include <QCloseEvent>
+
+
+namespace lyx {
+namespace frontend {
+
+class GuiBibitem;
+
+class GuiBibitemDialog : public QDialog, public Ui::BibitemUi {
+ Q_OBJECT
+public:
+
+ GuiBibitemDialog(GuiBibitem * form);
+protected Q_SLOTS:
+ virtual void change_adaptor();
+protected:
+ virtual void closeEvent(QCloseEvent * e);
+private:
+ GuiBibitem * form_;
+};
+
+
+class ControlCommand;
+
+class GuiBibitem
+ : public QController<ControlCommand, GuiView<GuiBibitemDialog> >
+{
+public:
+ friend class GuiBibitemDialog;
+
+ GuiBibitem(Dialog &);
+
+protected:
+ virtual bool isValid();
+private:
+ /// Apply changes
+ virtual void apply();
+ /// update
+ virtual void update_contents();
+ /// build the dialog
+ virtual void build_dialog();
+};
+
+} // namespace frontend
+} // namespace lyx
+
+#endif // QBIBITEM_H
--- /dev/null
+/**
+ * \file GuiBibtex.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author John Levon
+ * \author Herbert Voß
+ * \author Jürgen Spitzmüller
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "GuiBibtex.h"
+
+#include "ui_BibtexAddUi.h"
+#include "Qt2BC.h"
+#include "qt_helpers.h"
+#include "Validator.h"
+#include "LyXRC.h"
+#include "CheckedLineEdit.h"
+
+#include "controllers/ControlBibtex.h"
+#include "controllers/ButtonPolicy.h"
+
+#include "controllers/ControlBibtex.h"
+
+#include "support/filetools.h" // changeExtension
+#include "support/lstrings.h"
+
+#include <QPushButton>
+#include <QListWidget>
+#include <QCheckBox>
+#include <QCloseEvent>
+#include <QLineEdit>
+
+using lyx::support::changeExtension;
+using lyx::support::split;
+using lyx::support::trim;
+
+using std::vector;
+using std::string;
+
+#include "debug.h"
+#include "support/filetools.h"
+#include "support/lstrings.h"
+
+
+namespace lyx {
+namespace frontend {
+
+
+/////////////////////////////////////////////////////////////////////
+//
+// GuiBibtexDialog
+//
+/////////////////////////////////////////////////////////////////////
+
+GuiBibtexDialog::GuiBibtexDialog(GuiBibtex * form)
+ : form_(form)
+{
+ setupUi(this);
+ QDialog::setModal(true);
+
+ connect(okPB, SIGNAL(clicked()),
+ form, SLOT(slotOK()));
+ connect(closePB, SIGNAL(clicked()),
+ form, SLOT(slotClose()));
+ connect(stylePB, SIGNAL(clicked()),
+ this, SLOT(browsePressed()));
+ connect(deletePB, SIGNAL(clicked()),
+ this, SLOT(deletePressed()));
+ connect(styleCB, SIGNAL(editTextChanged (const QString &)),
+ this, SLOT(change_adaptor()));
+ connect(databaseLW, SIGNAL(itemSelectionChanged()),
+ this, SLOT(databaseChanged()));
+ connect(bibtocCB, SIGNAL(clicked()),
+ this, SLOT(change_adaptor()));
+ connect(btPrintCO, SIGNAL(activated(int)),
+ this, SLOT(change_adaptor()));
+ connect(addBibPB, SIGNAL(clicked()),
+ this, SLOT(addPressed()));
+
+ add_ = new UiDialog<Ui::BibtexAddUi>(this, true);
+
+ Qt2BC * bcview = new Qt2BC(add_bc_);
+ add_bc_.view(bcview);
+ add_bc_.bp(new OkCancelPolicy);
+
+ bcview->setOK(add_->addPB);
+ bcview->setCancel(add_->closePB);
+
+ addCheckedLineEdit(add_bc_.view(), add_->bibED, 0);
+
+ connect(add_->bibED, SIGNAL(textChanged(const QString &)),
+ this, SLOT(bibEDChanged()));
+ connect(add_->addPB, SIGNAL(clicked()),
+ this, SLOT(addDatabase()));
+ connect(add_->addPB, SIGNAL(clicked()),
+ add_, SLOT(accept()));
+ connect(add_->bibLW, SIGNAL(itemActivated(QListWidgetItem *)),
+ this, SLOT(addDatabase()));
+ connect(add_->bibLW, SIGNAL(itemActivated(QListWidgetItem *)),
+ add_, SLOT(accept()));
+ connect(add_->bibLW, SIGNAL(itemSelectionChanged()),
+ this, SLOT(availableChanged()));
+ connect(add_->browsePB, SIGNAL(clicked()),
+ this, SLOT(browseBibPressed()));
+ connect(add_->closePB, SIGNAL(clicked()),
+ add_, SLOT(reject()));
+
+}
+
+
+void GuiBibtexDialog::bibEDChanged()
+{
+ // Indicate to the button controller that the contents have
+ // changed. The actual test of validity is carried out by
+ // the checkedLineEdit.
+ add_bc_.valid(true);
+}
+
+
+void GuiBibtexDialog::change_adaptor()
+{
+ form_->changed();
+}
+
+
+void GuiBibtexDialog::browsePressed()
+{
+ docstring const file = form_->controller().browseBst(docstring());
+
+ if (!file.empty()) {
+ // FIXME UNICODE
+ docstring const filen = from_utf8(changeExtension(to_utf8(file), ""));
+ bool present = false;
+ unsigned int pres = 0;
+
+ for (int i = 0; i != styleCB->count(); ++i) {
+ if (qstring_to_ucs4(styleCB->itemText(i)) == filen) {
+ present = true;
+ pres = i;
+ }
+ }
+
+ if (!present)
+ styleCB->insertItem(0, toqstr(filen));
+
+ styleCB->setCurrentIndex(pres);
+ form_->changed();
+ }
+}
+
+
+void GuiBibtexDialog::browseBibPressed()
+{
+ docstring const file = trim(form_->controller().browseBib(docstring()));
+
+ if (!file.empty()) {
+ // FIXME UNICODE
+ QString const f = toqstr(changeExtension(to_utf8(file), ""));
+ bool present = false;
+
+ for (int i = 0; i < add_->bibLW->count(); ++i) {
+ if (add_->bibLW->item(i)->text() == f)
+ present = true;
+ }
+
+ if (!present) {
+ add_->bibLW->addItem(f);
+ form_->changed();
+ }
+
+ add_->bibED->setText(f);
+ }
+}
+
+
+void GuiBibtexDialog::addPressed()
+{
+ add_bc_.valid(false);
+ add_->exec();
+}
+
+
+void GuiBibtexDialog::addDatabase()
+{
+ int const sel = add_->bibLW->currentRow();
+ docstring const file = trim(qstring_to_ucs4(add_->bibED->text()));
+
+ if (sel < 0 && file.empty())
+ return;
+
+ // Add the selected browser_bib keys to browser_database
+ // multiple selections are possible
+ for (int i = 0; i != add_->bibLW->count(); ++i) {
+ QListWidgetItem * const item = add_->bibLW->item(i);
+ if (add_->bibLW->isItemSelected(item)) {
+ add_->bibLW->setItemSelected(item, false);
+ QList<QListWidgetItem *> matches =
+ databaseLW->findItems(item->text(), Qt::MatchExactly);
+ if (matches.empty())
+ databaseLW->addItem(item->text());
+ }
+ }
+
+ if (!file.empty()) {
+ add_->bibED->clear();
+ QString const f = toqstr(from_utf8(changeExtension(to_utf8(file), "")));
+ QList<QListWidgetItem *> matches =
+ databaseLW->findItems(f, Qt::MatchExactly);
+ if (matches.empty())
+ databaseLW->addItem(f);
+ }
+
+ form_->changed();
+}
+
+
+void GuiBibtexDialog::deletePressed()
+{
+ databaseLW->takeItem(databaseLW->currentRow());
+ form_->changed();
+}
+
+
+
+void GuiBibtexDialog::databaseChanged()
+{
+ deletePB->setEnabled(!form_->readOnly() && databaseLW->currentRow() != -1);
+}
+
+
+void GuiBibtexDialog::availableChanged()
+{
+ add_bc_.valid(true);
+}
+
+
+void GuiBibtexDialog::closeEvent(QCloseEvent *e)
+{
+ form_->slotWMHide();
+ e->accept();
+}
+
+
+/////////////////////////////////////////////////////////////////////
+//
+// QBibTex
+//
+/////////////////////////////////////////////////////////////////////
+
+
+typedef QController<ControlBibtex, GuiView<GuiBibtexDialog> > BibtexBase;
+
+GuiBibtex::GuiBibtex(Dialog & parent)
+ : BibtexBase(parent, _("BibTeX Bibliography"))
+{
+}
+
+
+void GuiBibtex::build_dialog()
+{
+ dialog_.reset(new GuiBibtexDialog(this));
+
+ bcview().setOK(dialog_->okPB);
+ bcview().setCancel(dialog_->closePB);
+ bcview().addReadOnly(dialog_->databaseLW);
+ bcview().addReadOnly(dialog_->stylePB);
+ bcview().addReadOnly(dialog_->styleCB);
+ bcview().addReadOnly(dialog_->bibtocCB);
+ bcview().addReadOnly(dialog_->addBibPB);
+ bcview().addReadOnly(dialog_->deletePB);
+}
+
+
+void GuiBibtex::update_contents()
+{
+ bool bibtopic = controller().usingBibtopic();
+
+ dialog_->databaseLW->clear();
+
+ docstring bibs(controller().params()["bibfiles"]);
+ docstring bib;
+
+ while (!bibs.empty()) {
+ bibs = split(bibs, bib, ',');
+ bib = trim(bib);
+ if (!bib.empty())
+ dialog_->databaseLW->addItem(toqstr(bib));
+ }
+
+ dialog_->add_->bibLW->clear();
+
+ vector<string> bib_str;
+ controller().getBibFiles(bib_str);
+ for (vector<string>::const_iterator it = bib_str.begin();
+ it != bib_str.end(); ++it) {
+ string bibItem(changeExtension(*it, ""));
+ dialog_->add_->bibLW->addItem(toqstr(bibItem));
+ }
+
+ string bibstyle(controller().getStylefile());
+
+ dialog_->bibtocCB->setChecked(controller().bibtotoc() && !bibtopic);
+ dialog_->bibtocCB->setEnabled(!bibtopic);
+
+ docstring btprint(controller().params()["btprint"]);
+ int btp = 0;
+ if (btprint == "btPrintNotCited")
+ btp = 1;
+ else if (btprint == "btPrintAll")
+ btp = 2;
+
+ dialog_->btPrintCO->setCurrentIndex(btp);
+ dialog_->btPrintCO->setEnabled(bibtopic);
+
+ dialog_->styleCB->clear();
+
+ int item_nr(-1);
+
+ vector<string> str;
+ controller().getBibStyles(str);
+ for (vector<string>::const_iterator it = str.begin();
+ it != str.end(); ++it) {
+ string item(changeExtension(*it, ""));
+ if (item == bibstyle)
+ item_nr = int(it - str.begin());
+ dialog_->styleCB->addItem(toqstr(item));
+ }
+
+ if (item_nr == -1 && !bibstyle.empty()) {
+ dialog_->styleCB->addItem(toqstr(bibstyle));
+ item_nr = dialog_->styleCB->count() - 1;
+ }
+
+ if (item_nr != -1)
+ dialog_->styleCB->setCurrentIndex(item_nr);
+ else
+ dialog_->styleCB->clearEditText();
+}
+
+
+void GuiBibtex::apply()
+{
+ docstring dbs(qstring_to_ucs4(dialog_->databaseLW->item(0)->text()));
+
+ unsigned int maxCount = dialog_->databaseLW->count();
+ for (unsigned int i = 1; i < maxCount; i++) {
+ dbs += ',';
+ dbs += qstring_to_ucs4(dialog_->databaseLW->item(i)->text());
+ }
+
+ controller().params()["bibfiles"] = dbs;
+
+ docstring const bibstyle(qstring_to_ucs4(dialog_->styleCB->currentText()));
+ bool const bibtotoc(dialog_->bibtocCB->isChecked());
+
+ if (bibtotoc && (!bibstyle.empty())) {
+ // both bibtotoc and style
+ controller().params()["options"] = "bibtotoc," + bibstyle;
+ } else if (bibtotoc) {
+ // bibtotoc and no style
+ controller().params()["options"] = from_ascii("bibtotoc");
+ } else {
+ // only style. An empty one is valid, because some
+ // documentclasses have an own \bibliographystyle{}
+ // command!
+ controller().params()["options"] = bibstyle;
+ }
+
+ // bibtopic allows three kinds of sections:
+ // 1. sections that include all cited references of the database(s)
+ // 2. sections that include all uncited references of the database(s)
+ // 3. sections that include all references of the database(s), cited or not
+ int btp = dialog_->btPrintCO->currentIndex();
+
+ switch (btp) {
+ case 0:
+ controller().params()["btprint"] = from_ascii("btPrintCited");
+ break;
+ case 1:
+ controller().params()["btprint"] = from_ascii("btPrintNotCited");
+ break;
+ case 2:
+ controller().params()["btprint"] = from_ascii("btPrintAll");
+ break;
+ }
+
+ if (!controller().usingBibtopic())
+ controller().params()["btprint"] = docstring();
+}
+
+
+bool GuiBibtex::isValid()
+{
+ return dialog_->databaseLW->count() != 0;
+}
+
+} // namespace frontend
+} // namespace lyx
+
+#include "GuiBibtex_moc.cpp"
--- /dev/null
+// -*- C++ -*-
+/**
+ * \file GuiBibtex.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author John Levon
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#ifndef QBIBTEX_H
+#define QBIBTEX_H
+
+#include "GuiDialogView.h"
+
+#include "ui_BibtexUi.h"
+#include "ui_BibtexAddUi.h"
+
+#include "ButtonController.h"
+
+#include <QCloseEvent>
+#include <QDialog>
+
+namespace lyx {
+namespace frontend {
+
+class GuiBibtex;
+
+template<class UI>
+class UiDialog : public QDialog, public UI
+{
+public:
+ UiDialog(QWidget * parent=0, bool modal=false, Qt::WFlags f=0)
+ : QDialog(parent, f)
+ {
+ UI::setupUi(this);
+ QDialog::setModal(modal);
+ }
+};
+
+
+class GuiBibtexDialog : public QDialog, public Ui::BibtexUi {
+ Q_OBJECT
+
+public:
+ GuiBibtexDialog(GuiBibtex * form);
+
+ UiDialog<Ui::BibtexAddUi> * add_;
+
+protected Q_SLOTS:
+ virtual void change_adaptor();
+ virtual void browsePressed();
+ virtual void browseBibPressed();
+ virtual void addPressed();
+ virtual void addDatabase();
+ virtual void deletePressed();
+ virtual void databaseChanged();
+ virtual void availableChanged();
+ void bibEDChanged();
+
+protected:
+ virtual void closeEvent(QCloseEvent * e);
+
+private:
+ GuiBibtex * form_;
+ ButtonController add_bc_;
+};
+
+
+class ControlBibtex;
+
+class GuiBibtex
+ : public QController<ControlBibtex, GuiView<GuiBibtexDialog> >
+{
+public:
+ friend class GuiBibtexDialog;
+
+ GuiBibtex(Dialog &);
+protected:
+ virtual bool isValid();
+private:
+ /// Apply changes
+ virtual void apply();
+ /// update
+ virtual void update_contents();
+ /// build the dialog
+ virtual void build_dialog();
+};
+
+} // namespace frontend
+} // namespace lyx
+
+#endif // QBIBTEX_H
--- /dev/null
+/**
+ * \file GuiBox.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Jürgen Vigna (Minipage stuff)
+ * \author Martin Vermeer
+ * \author Jürgen Spitzmüller
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "GuiBox.h"
+
+#include "CheckedLineEdit.h"
+#include "LengthCombo.h"
+#include "qt_helpers.h"
+#include "Qt2BC.h"
+#include "lengthcommon.h"
+#include "LyXRC.h" // to set the default length values
+#include "Validator.h"
+
+#include "controllers/ControlBox.h"
+#include "controllers/frontend_helpers.h"
+
+#include "insets/InsetBox.h"
+
+#include "support/lstrings.h"
+
+#include <QPushButton>
+#include <QLineEdit>
+#include <QCloseEvent>
+
+
+using lyx::support::getStringFromVector;
+using lyx::support::isStrDbl;
+using lyx::support::subst;
+using std::string;
+
+
+namespace lyx {
+namespace frontend {
+
+//////////////////////////////////////////////////////////////////
+//
+// GuiBoxDialog
+//
+//////////////////////////////////////////////////////////////////
+
+GuiBoxDialog::GuiBoxDialog(GuiBox * form)
+ : form_(form)
+{
+ setupUi(this);
+ connect(restorePB, SIGNAL(clicked()), form, SLOT(slotRestore()));
+ connect(okPB, SIGNAL(clicked()), form, SLOT(slotOK()));
+ connect(applyPB, SIGNAL(clicked()), form, SLOT(slotApply()));
+ connect(closePB, SIGNAL(clicked()), form, SLOT(slotClose()));
+
+ connect(widthED, SIGNAL(textChanged(const QString &)),
+ this, SLOT(change_adaptor()));
+ connect(widthUnitsLC, SIGNAL(selectionChanged(lyx::Length::UNIT)),
+ this, SLOT(change_adaptor()));
+ connect(valignCO, SIGNAL(highlighted(const QString &)),
+ this, SLOT(change_adaptor()));
+ connect(heightED, SIGNAL(textChanged(const QString &)),
+ this, SLOT(change_adaptor()));
+ connect(heightUnitsLC, SIGNAL(selectionChanged(lyx::Length::UNIT) ),
+ this, SLOT(change_adaptor()));
+ connect(restorePB, SIGNAL(clicked()), this, SLOT(restoreClicked()));
+ connect(typeCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
+ connect(typeCO, SIGNAL(activated(int)), this, SLOT(typeChanged(int)));
+ connect(halignCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
+ connect(ialignCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
+ connect(innerBoxCO, SIGNAL(activated(const QString&)),
+ this, SLOT(innerBoxChanged(const QString &)));
+ connect(innerBoxCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
+
+ heightED->setValidator(unsignedLengthValidator(heightED));
+ widthED->setValidator(unsignedLengthValidator(widthED));
+}
+
+
+void GuiBoxDialog::closeEvent(QCloseEvent * e)
+{
+ form_->slotWMHide();
+ e->accept();
+}
+
+
+void GuiBoxDialog::change_adaptor()
+{
+ form_->changed();
+}
+
+
+void GuiBoxDialog::innerBoxChanged(const QString & str)
+{
+ bool const ibox = (str != qt_("None"));
+ valignCO->setEnabled(ibox);
+ ialignCO->setEnabled(ibox);
+ halignCO->setEnabled(!ibox);
+ heightED->setEnabled(ibox);
+ heightUnitsLC->setEnabled(ibox);
+ form_->setSpecial(ibox);
+}
+
+
+void GuiBoxDialog::typeChanged(int index)
+{
+ bool const frameless = (index == 0);
+ if (frameless) {
+ valignCO->setEnabled(true);
+ ialignCO->setEnabled(true);
+ halignCO->setEnabled(false);
+ heightED->setEnabled(true);
+ heightUnitsLC->setEnabled(true);
+ form_->setSpecial(true);
+ }
+ int itype = innerBoxCO->currentIndex();
+ form_->setInnerType(frameless, itype);
+}
+
+
+void GuiBoxDialog::restoreClicked()
+{
+ form_->setInnerType(true, 2);
+ widthED->setText("100");
+ widthUnitsLC->setCurrentItem(Length::PCW);
+ heightED->setText("1");
+ for (int j = 0; j < heightUnitsLC->count(); j++) {
+ if (heightUnitsLC->itemText(j) == qt_("Total Height"))
+ heightUnitsLC->setCurrentItem(j);
+ }
+}
+
+
+//////////////////////////////////////////////////////////////////
+//
+// GuiBox
+//
+//////////////////////////////////////////////////////////////////
+
+typedef QController<ControlBox, GuiView<GuiBoxDialog> > box_base_class;
+
+GuiBox::GuiBox(Dialog & parent)
+ : box_base_class(parent, _("Box Settings"))
+{}
+
+
+void GuiBox::build_dialog()
+{
+ dialog_.reset(new GuiBoxDialog(this));
+
+ // fill the box type choice
+ box_gui_tokens(ids_, gui_names_);
+ for (unsigned int i = 0; i < gui_names_.size(); ++i)
+ dialog_->typeCO->addItem(toqstr(gui_names_[i]));
+
+ // add the special units to the height choice
+ // width needs different handling
+ box_gui_tokens_special_length(ids_spec_, gui_names_spec_);
+ for (unsigned int i = 1; i < gui_names_spec_.size(); ++i)
+ dialog_->heightUnitsLC->addItem(toqstr(gui_names_spec_[i]));
+
+ bcview().addReadOnly(dialog_->typeCO);
+ bcview().addReadOnly(dialog_->innerBoxCO);
+ bcview().addReadOnly(dialog_->valignCO);
+ bcview().addReadOnly(dialog_->ialignCO);
+ bcview().addReadOnly(dialog_->halignCO);
+ bcview().addReadOnly(dialog_->widthED);
+ bcview().addReadOnly(dialog_->heightED);
+ bcview().addReadOnly(dialog_->widthUnitsLC);
+ bcview().addReadOnly(dialog_->heightUnitsLC);
+
+ bcview().setRestore(dialog_->restorePB);
+ bcview().setOK(dialog_->okPB);
+ bcview().setApply(dialog_->applyPB);
+ bcview().setCancel(dialog_->closePB);
+
+ // initialize the length validator
+ addCheckedLineEdit(bcview(), dialog_->widthED, dialog_->widthLA);
+ addCheckedLineEdit(bcview(), dialog_->heightED, dialog_->heightLA);
+}
+
+
+void GuiBox::update_contents()
+{
+ string type(controller().params().type);
+ for (unsigned int i = 0; i < gui_names_.size(); ++i) {
+ if (type == ids_[i])
+ dialog_->typeCO->setCurrentIndex(i);
+ }
+
+ // default: minipage
+ unsigned int inner_type = 2;
+ if (!controller().params().inner_box)
+ // none
+ inner_type = 0;
+ if (controller().params().use_parbox)
+ // parbox
+ inner_type = 1;
+ bool frameless = (controller().params().type == "Frameless");
+ setInnerType(frameless, inner_type);
+
+ char c = controller().params().pos;
+ dialog_->valignCO->setCurrentIndex(string("tcb").find(c, 0));
+ c = controller().params().inner_pos;
+ dialog_->ialignCO->setCurrentIndex(string("tcbs").find(c, 0));
+ c = controller().params().hor_pos;
+ dialog_->halignCO->setCurrentIndex(string("lcrs").find(c, 0));
+
+ bool ibox = controller().params().inner_box;
+ dialog_->valignCO->setEnabled(ibox);
+ dialog_->ialignCO->setEnabled(ibox);
+ dialog_->halignCO->setEnabled(!ibox);
+ setSpecial(ibox);
+
+ Length::UNIT default_unit =
+ (lyxrc.default_papersize > 3) ? Length::CM : Length::IN;
+
+ lengthToWidgets(dialog_->widthED, dialog_->widthUnitsLC,
+ (controller().params().width).asString(), default_unit);
+
+ string const special(controller().params().special);
+ if (!special.empty() && special != "none") {
+ QString spc;
+ for (unsigned int i = 0; i < gui_names_spec_.size(); i++) {
+ if (special == ids_spec_[i])
+ spc = toqstr(gui_names_spec_[i].c_str());
+ }
+ for (int j = 0; j < dialog_->widthUnitsLC->count(); j++) {
+ if (dialog_->widthUnitsLC->itemText(j) == spc)
+ dialog_->widthUnitsLC->setCurrentIndex(j);
+ }
+ }
+
+ lengthToWidgets(dialog_->heightED, dialog_->heightUnitsLC,
+ (controller().params().height).asString(), default_unit);
+
+ string const height_special(controller().params().height_special);
+ if (!height_special.empty() && height_special != "none") {
+ QString hspc;
+ for (unsigned int i = 0; i < gui_names_spec_.size(); i++) {
+ if (height_special == ids_spec_[i]) {
+ hspc = toqstr(gui_names_spec_[i].c_str());
+ }
+ }
+ for (int j = 0; j < dialog_->heightUnitsLC->count(); j++) {
+ if (dialog_->heightUnitsLC->itemText(j) == hspc) {
+ dialog_->heightUnitsLC->setCurrentIndex(j);
+ }
+ }
+ }
+
+ dialog_->heightED->setEnabled(ibox);
+ dialog_->heightUnitsLC->setEnabled(ibox);
+}
+
+
+void GuiBox::apply()
+{
+ controller().params().type =
+ ids_[dialog_->typeCO->currentIndex()];
+
+ controller().params().inner_box =
+ dialog_->innerBoxCO->currentText() != qt_("None");
+ controller().params().use_parbox =
+ dialog_->innerBoxCO->currentText() == qt_("Parbox");
+
+ controller().params().pos =
+ "tcb"[dialog_->valignCO->currentIndex()];
+ controller().params().inner_pos =
+ "tcbs"[dialog_->ialignCO->currentIndex()];
+ controller().params().hor_pos =
+ "lcrs"[dialog_->halignCO->currentIndex()];
+
+ int i = 0;
+ bool spec = false;
+ QString special = dialog_->widthUnitsLC->currentText();
+ QString value = dialog_->widthED->text();
+ if (special == qt_("Height")) {
+ i = 1;
+ spec = true;
+ } else if (special == qt_("Depth")) {
+ i = 2;
+ spec = true;
+ } else if (special == qt_("Total Height")) {
+ i = 3;
+ spec = true;
+ } else if (special == qt_("Width")) {
+ i = 4;
+ spec = true;
+ }
+ // the user might insert a non-special value in the line edit
+ if (isValidLength(fromqstr(value))) {
+ i = 0;
+ spec = false;
+ }
+ controller().params().special = ids_spec_[i];
+
+ string width;
+ if (spec) {
+ width = fromqstr(value);
+ // beware: bogosity! the unit is simply ignored in this case
+ width += "in";
+ } else
+ width = widgetsToLength(dialog_->widthED, dialog_->widthUnitsLC);
+
+ controller().params().width = Length(width);
+
+ i = 0;
+ spec = false;
+ special = dialog_->heightUnitsLC->currentText();
+ value = dialog_->heightED->text();
+ if (special == qt_("Height")) {
+ i = 1;
+ spec = true;
+ } else if (special == qt_("Depth")) {
+ i = 2;
+ spec = true;
+ } else if (special == qt_("Total Height")) {
+ i = 3;
+ spec = true;
+ } else if (special == qt_("Width")) {
+ i = 4;
+ spec = true;
+ }
+ // the user might insert a non-special value in the line edit
+ if (isValidLength(fromqstr(value))) {
+ i = 0;
+ spec = false;
+ }
+ controller().params().height_special = ids_spec_[i];
+
+ string height;
+ if (spec && !isValidLength(fromqstr(dialog_->heightED->text()))) {
+ height = fromqstr(value);
+ // beware: bogosity! the unit is simply ignored in this case
+ height += "in";
+ } else
+ height = widgetsToLength(dialog_->heightED, dialog_->heightUnitsLC);
+
+ controller().params().height = Length(height);
+}
+
+
+void GuiBox::setSpecial(bool ibox)
+{
+ box_gui_tokens_special_length(ids_spec_, gui_names_spec_);
+ // check if the widget contains the special units
+ int count = dialog_->widthUnitsLC->count();
+ bool has_special = false;
+ for (int i = 0; i < count; i++)
+ if (dialog_->widthUnitsLC->itemText(i).contains(qt_("Total Height")) > 0)
+ has_special = true;
+ // insert 'em if needed...
+ if (!ibox && !has_special) {
+ for (unsigned int i = 1; i < gui_names_spec_.size(); i++)
+ dialog_->widthUnitsLC->addItem(toqstr(gui_names_spec_[i]));
+ // ... or remove 'em if needed
+ } else if (ibox && has_special) {
+ dialog_->widthUnitsLC->clear();
+ for (int i = 0; i < num_units; i++)
+ dialog_->widthUnitsLC->addItem(qt_(unit_name_gui[i]));
+ }
+}
+
+
+void GuiBox::setInnerType(bool frameless, int i)
+{
+ // with "frameless" boxes, inner box is mandatory (i.e. is the actual box)
+ // we have to remove "none" then and adjust the combo
+ if (frameless) {
+ dialog_->innerBoxCO->clear();
+ dialog_->innerBoxCO->addItem(qt_("Parbox"));
+ dialog_->innerBoxCO->addItem(qt_("Minipage"));
+ dialog_->innerBoxCO->setCurrentIndex(i - 1);
+ } else {
+ if (dialog_->innerBoxCO->count() == 2)
+ i += 1;
+ dialog_->innerBoxCO->clear();
+ dialog_->innerBoxCO->addItem(qt_("None"));
+ dialog_->innerBoxCO->addItem(qt_("Parbox"));
+ dialog_->innerBoxCO->addItem(qt_("Minipage"));
+ dialog_->innerBoxCO->setCurrentIndex(i);
+ }
+}
+
+} // namespace frontend
+} // namespace lyx
+
+
+#include "GuiBox_moc.cpp"
--- /dev/null
+// -*- C++ -*-
+/**
+ * \file GuiBox.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Jürgen Spitzmüller
+ * \ author Martin Vermeer
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#ifndef QBOX_H
+#define QBOX_H
+
+#include "GuiDialogView.h"
+
+#include "ui_BoxUi.h"
+
+#include <QCloseEvent>
+#include <QDialog>
+
+#include <vector>
+
+
+namespace lyx {
+namespace frontend {
+
+class ControlBox;
+class GuiBox;
+
+class GuiBoxDialog : public QDialog, public Ui::BoxUi {
+ Q_OBJECT
+public:
+ GuiBoxDialog(GuiBox * form);
+protected Q_SLOTS:
+ virtual void change_adaptor();
+ virtual void innerBoxChanged(const QString &);
+ virtual void typeChanged(int);
+ virtual void restoreClicked();
+protected:
+ virtual void closeEvent(QCloseEvent * e);
+private:
+ GuiBox * form_;
+};
+
+
+///
+class GuiBox
+ : public QController<ControlBox, GuiView<GuiBoxDialog> >
+{
+public:
+ ///
+ friend class GuiBoxDialog;
+ ///
+ GuiBox(Dialog &);
+ /// add and remove special lengths
+ void setSpecial(bool ibox);
+ /// only show valid inner box items
+ void setInnerType(bool frameless, int i);
+private:
+ /// Apply changes
+ virtual void apply();
+ /// update
+ virtual void update_contents();
+ /// build the dialog
+ virtual void build_dialog();
+ ///
+ std::vector<std::string> ids_;
+ ///
+ std::vector<docstring> gui_names_;
+ ///
+ std::vector<std::string> ids_spec_;
+ ///
+ std::vector<docstring> gui_names_spec_;
+};
+
+} // namespace frontend
+} // namespace lyx
+
+#endif // QBOX_H
--- /dev/null
+/**
+ * \file GuiBranch.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Jürgen Spitzmüller
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "GuiBranch.h"
+#include "Qt2BC.h"
+#include "qt_helpers.h"
+
+#include "BranchList.h"
+
+#include "controllers/ControlBranch.h"
+
+#include "insets/InsetBranch.h"
+
+#include <QPushButton>
+#include <QCloseEvent>
+
+namespace lyx {
+namespace frontend {
+
+/////////////////////////////////////////////////////////////////////
+//
+// GuiBranchDialog
+//
+/////////////////////////////////////////////////////////////////////
+
+GuiBranchDialog::GuiBranchDialog(GuiBranch * form)
+ : form_(form)
+{
+ setupUi(this);
+ connect(okPB, SIGNAL(clicked()),
+ form, SLOT(slotOK()));
+ connect(closePB, SIGNAL(clicked()),
+ form, SLOT(slotClose()));
+ connect(branchCO, SIGNAL( activated(int) ),
+ this, SLOT( change_adaptor() ) );
+}
+
+
+void GuiBranchDialog::closeEvent(QCloseEvent * e)
+{
+ form_->slotWMHide();
+ e->accept();
+}
+
+
+void GuiBranchDialog::change_adaptor()
+{
+ form_->changed();
+}
+
+
+/////////////////////////////////////////////////////////////////////
+//
+// GuiBranch
+//
+/////////////////////////////////////////////////////////////////////
+
+typedef QController<ControlBranch, GuiView<GuiBranchDialog> > branch_base_class;
+
+
+GuiBranch::GuiBranch(Dialog & parent)
+ : branch_base_class(parent, _("Branch Settings"))
+{}
+
+
+void GuiBranch::build_dialog()
+{
+ dialog_.reset(new GuiBranchDialog(this));
+
+ bcview().setOK(dialog_->okPB);
+ bcview().setCancel(dialog_->closePB);
+}
+
+
+void GuiBranch::update_contents()
+{
+ typedef BranchList::const_iterator const_iterator;
+
+ BranchList const & branchlist = controller().branchlist();
+ docstring const cur_branch = controller().params().branch;
+
+ dialog_->branchCO->clear();
+
+ const_iterator const begin = branchlist.begin();
+ const_iterator const end = branchlist.end();
+ int id = 0;
+ int count = 0;
+ for (const_iterator it = begin; it != end; ++it, ++count) {
+ docstring const & branch = it->getBranch();
+ dialog_->branchCO->addItem(toqstr(branch));
+
+ if (cur_branch == branch)
+ id = count;
+ }
+ dialog_->branchCO->setCurrentIndex(id);
+}
+
+
+void GuiBranch::apply()
+{
+ docstring const type = qstring_to_ucs4(dialog_->branchCO->currentText());
+ controller().params().branch = type;
+}
+
+} // namespace frontend
+} // namespace lyx
+
+#include "GuiBranch_moc.cpp"
--- /dev/null
+// -*- C++ -*-
+/**
+ * \file GuiBranch.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Jürgen Spitzmüller
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#ifndef QBRANCH_H
+#define QBRANCH_H
+
+#include "GuiDialogView.h"
+#include "ui_BranchUi.h"
+
+#include <QCloseEvent>
+#include <QDialog>
+
+namespace lyx {
+namespace frontend {
+
+class GuiBranch;
+
+class GuiBranchDialog : public QDialog, public Ui::BranchUi {
+ Q_OBJECT
+public:
+ GuiBranchDialog(GuiBranch * form);
+protected Q_SLOTS:
+ virtual void change_adaptor();
+protected:
+ virtual void closeEvent(QCloseEvent * e);
+private:
+ GuiBranch * form_;
+};
+
+class ControlBranch;
+
+/** This class provides a QT implementation of the Branch Dialog.
+ */
+class GuiBranch : public QController<ControlBranch, GuiView<GuiBranchDialog> >
+{
+public:
+ friend class GuiBranchDialog;
+
+ /// Constructor
+ GuiBranch(Dialog &);
+private:
+ /// Apply changes
+ virtual void apply();
+ /// Build the dialog
+ virtual void build_dialog();
+ /// Update dialog before showing it
+ virtual void update_contents();
+};
+
+} // namespace frontend
+} // namespace lyx
+
+#endif // QBRANCH_H
--- /dev/null
+/**
+ * \file GuiBranches.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Edwin Leuven
+ * \author Abdelrazak Younes
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "GuiBranches.h"
+
+#include "GuiApplication.h"
+#include "Validator.h"
+#include "qt_helpers.h"
+
+#include "BufferParams.h"
+#include "controllers/ControlDocument.h"
+
+#include "support/lstrings.h"
+
+#include <QTreeWidget>
+#include <QTreeWidgetItem>
+#include <QPixmap>
+#include <QIcon>
+#include <QColor>
+#include <QColorDialog>
+
+
+namespace lyx {
+namespace frontend {
+
+
+GuiBranches::GuiBranches(QWidget * parent, Qt::WFlags f)
+ : QWidget(parent, f)
+{
+ setupUi(this);
+ branchesTW->setColumnCount(3);
+ branchesTW->headerItem()->setText(0, qt_("Branch"));
+ branchesTW->headerItem()->setText(1, qt_("Activated"));
+ branchesTW->headerItem()->setText(2, qt_("Color"));
+ branchesTW->setSortingEnabled(true);
+}
+
+void GuiBranches::update(BufferParams const & params)
+{
+ branchlist_ = params.branchlist();
+ update();
+}
+
+void GuiBranches::update()
+{
+ // store the selected branch
+ QTreeWidgetItem * item = branchesTW->currentItem();
+ QString sel_branch;
+ if (item != 0)
+ sel_branch = item->text(0);
+
+ branchesTW->clear();
+
+ BranchList::const_iterator it = branchlist_.begin();
+ BranchList::const_iterator const end = branchlist_.end();
+ for (; it != end; ++it) {
+ QTreeWidgetItem * newItem =
+ new QTreeWidgetItem(branchesTW);
+
+ QString const bname = toqstr(it->getBranch());
+ newItem->setText(0, bname);
+
+ QString const sel = it->getSelected() ? qt_("Yes") : qt_("No");
+ newItem->setText(1, sel);
+
+ QColor const itemcolor = rgb2qcolor(it->getColor());
+ if (itemcolor.isValid()) {
+ QPixmap coloritem(30, 10);
+ coloritem.fill(itemcolor);
+ newItem->setIcon(2, QIcon(coloritem));
+ }
+ // restore selected branch
+ if (bname == sel_branch) {
+ branchesTW->setCurrentItem(newItem);
+ branchesTW->setItemSelected(newItem, true);
+ }
+ }
+ // emit signal
+ changed();
+}
+
+void GuiBranches::apply(BufferParams & params) const
+{
+ params.branchlist() = branchlist_;
+}
+
+void GuiBranches::on_addBranchPB_pressed()
+{
+ QString const new_branch = newBranchLE->text();
+ if (!new_branch.isEmpty()) {
+ branchlist_.add(qstring_to_ucs4(new_branch));
+ newBranchLE->clear();
+ update();
+ }
+}
+
+
+void GuiBranches::on_removePB_pressed()
+{
+ QTreeWidgetItem * selItem =
+ branchesTW->currentItem();
+ QString sel_branch;
+ if (selItem != 0)
+ sel_branch = selItem->text(0);
+ if (!sel_branch.isEmpty()) {
+ branchlist_.remove(qstring_to_ucs4(sel_branch));
+ newBranchLE->clear();
+ update();
+ }
+}
+
+
+void GuiBranches::on_activatePB_pressed()
+{
+ toggleBranch(branchesTW->currentItem());
+}
+
+
+void GuiBranches::on_branchesTW_itemDoubleClicked(QTreeWidgetItem * item, int col)
+{
+ if (col < 2)
+ toggleBranch(item);
+ else
+ toggleColor(item);
+}
+
+
+void GuiBranches::toggleBranch(QTreeWidgetItem * item)
+{
+ if (item == 0)
+ return;
+
+ QString sel_branch = item->text(0);
+ if (!sel_branch.isEmpty()) {
+ bool const selected = item->text(1) == qt_("Yes");
+ Branch * branch = branchlist_.find(qstring_to_ucs4(sel_branch));
+ if (branch && branch->setSelected(!selected)) {
+ newBranchLE->clear();
+ update();
+ }
+ }
+}
+
+
+void GuiBranches::on_colorPB_clicked()
+{
+ toggleColor(branchesTW->currentItem());
+}
+
+
+void GuiBranches::toggleColor(QTreeWidgetItem * item)
+{
+ if (item == 0)
+ return;
+
+ QString sel_branch = item->text(0);
+ if (!sel_branch.isEmpty()) {
+ docstring current_branch = qstring_to_ucs4(sel_branch);
+ Branch * branch =
+ branchlist_.find(current_branch);
+ if (!branch)
+ return;
+
+ QColor const initial = rgb2qcolor(branch->getColor());
+ QColor ncol(QColorDialog::getColor(initial, qApp->focusWidget()));
+ if (ncol.isValid()){
+ // add the color to the branchlist
+ branch->setColor(fromqstr(ncol.name()));
+ newBranchLE->clear();
+ update();
+ }
+ }
+}
+
+} // namespace frontend
+} // namespace lyx
+
+#include "GuiBranches_moc.cpp"
--- /dev/null
+// -*- C++ -*-
+/**
+ * \file GuiBranches.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Edwin Leuven
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#ifndef QBRANCHES_H
+#define QBRANCHES_H
+
+#include "ui_BranchesUi.h"
+#include "GuiDocument.h"
+#include "BranchList.h"
+
+#include <QWidget>
+
+#include <vector>
+#include <string>
+
+
+class QTreeWidgetItem;
+
+namespace lyx {
+
+class BufferParams;
+
+namespace frontend {
+
+
+class GuiBranches: public QWidget, public Ui::BranchesUi
+{
+ Q_OBJECT
+public:
+ GuiBranches(QWidget * parent=0, Qt::WFlags f=0);
+
+ void update(BufferParams const & params);
+ void apply(BufferParams & params) const;
+
+Q_SIGNALS:
+ void changed();
+
+protected:
+ void toggleBranch(QTreeWidgetItem *);
+ void toggleColor(QTreeWidgetItem *);
+ void update();
+
+protected Q_SLOTS:
+ void on_addBranchPB_pressed();
+ void on_removePB_pressed();
+ void on_activatePB_pressed();
+ void on_branchesTW_itemDoubleClicked(QTreeWidgetItem *, int);
+ void on_colorPB_clicked();
+
+private:
+
+ /// Contains all legal branches for this doc
+ BranchList branchlist_;
+
+};
+
+} // namespace frontend
+} // namespace lyx
+
+#endif // DOCUMENTDIALOG_H
--- /dev/null
+/**
+ * \file GuiChanges.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author John Levon
+ * \author Michael Gerz
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "GuiChanges.h"
+#include "Qt2BC.h"
+#include "qt_helpers.h"
+
+#include "support/lstrings.h"
+
+#include "controllers/ControlChanges.h"
+
+#include <QPushButton>
+#include <QCloseEvent>
+#include <QTextBrowser>
+
+using lyx::support::bformat;
+
+
+namespace lyx {
+namespace frontend {
+
+/////////////////////////////////////////////////////////////////////
+//
+// GuiChangesDialog
+//
+/////////////////////////////////////////////////////////////////////
+
+GuiChangesDialog::GuiChangesDialog(GuiChanges * form)
+ : form_(form)
+{
+ setupUi(this);
+ connect(closePB, SIGNAL(clicked()), form, SLOT(slotClose()));
+ connect(nextPB, SIGNAL(clicked()), this, SLOT(nextPressed()));
+ connect(rejectPB, SIGNAL(clicked()), this, SLOT(rejectPressed()));
+ connect(acceptPB, SIGNAL(clicked()), this, SLOT(acceptPressed()));
+}
+
+
+void GuiChangesDialog::nextPressed()
+{
+ form_->next();
+}
+
+
+void GuiChangesDialog::acceptPressed()
+{
+ form_->accept();
+}
+
+
+void GuiChangesDialog::rejectPressed()
+{
+ form_->reject();
+}
+
+
+void GuiChangesDialog::closeEvent(QCloseEvent *e)
+{
+ form_->slotWMHide();
+ e->accept();
+}
+
+
+
+/////////////////////////////////////////////////////////////////////
+//
+// GuiChanges
+//
+/////////////////////////////////////////////////////////////////////
+
+typedef QController<ControlChanges, GuiView<GuiChangesDialog> > ChangesBase;
+
+
+GuiChanges::GuiChanges(Dialog & parent)
+ : ChangesBase(parent, _("Merge Changes"))
+{
+}
+
+
+void GuiChanges::build_dialog()
+{
+ dialog_.reset(new GuiChangesDialog(this));
+
+ bcview().setCancel(dialog_->closePB);
+ bcview().addReadOnly(dialog_->acceptPB);
+ bcview().addReadOnly(dialog_->rejectPB);
+}
+
+
+void GuiChanges::update_contents()
+{
+ docstring text;
+ docstring author = controller().getChangeAuthor();
+ docstring date = controller().getChangeDate();
+
+ if (!author.empty())
+ text += bformat(_("Change by %1$s\n\n"), author);
+ if (!date.empty())
+ text += bformat(_("Change made at %1$s\n"), date);
+
+ dialog_->changeTB->setPlainText(toqstr(text));
+}
+
+
+void GuiChanges::next()
+{
+ controller().next();
+}
+
+
+void GuiChanges::accept()
+{
+ controller().accept();
+}
+
+
+void GuiChanges::reject()
+{
+ controller().reject();
+}
+
+} // namespace frontend
+} // namespace lyx
+
+#include "GuiChanges_moc.cpp"
--- /dev/null
+// -*- C++ -*-
+/**
+ * \file GuiChanges.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author John Levon
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#ifndef QCHANGES_H
+#define QCHANGES_H
+
+#include "GuiDialogView.h"
+#include "ui_ChangesUi.h"
+#include <QCloseEvent>
+#include <QDialog>
+
+namespace lyx {
+namespace frontend {
+
+class GuiChanges;
+
+class GuiChangesDialog : public QDialog, public Ui::ChangesUi {
+ Q_OBJECT
+public:
+
+ GuiChangesDialog(GuiChanges * form);
+
+protected Q_SLOTS:
+
+ virtual void nextPressed();
+ virtual void acceptPressed();
+ virtual void rejectPressed();
+
+protected:
+ virtual void closeEvent(QCloseEvent * e);
+
+private:
+ GuiChanges * form_;
+};
+
+class ControlChanges;
+
+class GuiChanges
+ : public QController<ControlChanges, GuiView<GuiChangesDialog> >
+{
+public:
+ friend class GuiChangesDialog;
+
+ GuiChanges(Dialog &);
+
+ void accept();
+
+ void reject();
+
+ void next();
+
+private:
+ /// Apply changes
+ virtual void apply() {};
+ /// update
+ virtual void update_contents();
+ /// build the dialog
+ virtual void build_dialog();
+};
+
+} // namespace frontend
+} // namespace lyx
+
+#endif // QCHANGES_H
--- /dev/null
+/**
+ * \file GuiCharacter.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Edwin Leuven
+ * \author John Levon
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "GuiCharacter.h"
+#include "ControlCharacter.h"
+#include "Qt2BC.h"
+#include "qt_helpers.h"
+
+#include "Color.h"
+
+
+#include <QCloseEvent>
+
+using std::vector;
+
+namespace lyx {
+namespace frontend {
+
+/////////////////////////////////////////////////////////////////////
+//
+// GuiCharacterDialog
+//
+/////////////////////////////////////////////////////////////////////
+
+GuiCharacterDialog::GuiCharacterDialog(GuiCharacter * form)
+ : form_(form)
+{
+ setupUi(this);
+ connect(okPB, SIGNAL(clicked()), form_, SLOT(slotOK()));
+ connect(applyPB, SIGNAL(clicked()), form_, SLOT(slotApply()));
+ connect(closePB, SIGNAL(clicked()), form_, SLOT(slotClose()));
+
+ connect(miscCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
+ connect(sizeCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
+ connect(familyCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
+ connect(seriesCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
+ connect(shapeCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
+ connect(colorCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
+ connect(langCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
+ connect(toggleallCB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
+}
+
+
+void GuiCharacterDialog::change_adaptor()
+{
+ form_->changed();
+
+ if (!autoapplyCB->isChecked())
+ return;
+
+ // to be really good here, we should set the combos to the values of
+ // the current text, and make it appear as "no change" if the values
+ // stay the same between applys. Might be difficult though wrt to a
+ // moved cursor - jbl
+ form_->slotApply();
+ familyCO->setCurrentIndex(0);
+ seriesCO->setCurrentIndex(0);
+ sizeCO->setCurrentIndex(0);
+ shapeCO->setCurrentIndex(0);
+ miscCO->setCurrentIndex(0);
+ langCO->setCurrentIndex(0);
+ colorCO->setCurrentIndex(0);
+}
+
+
+void GuiCharacterDialog::closeEvent(QCloseEvent * e)
+{
+ form_->slotWMHide();
+ e->accept();
+}
+
+
+/////////////////////////////////////////////////////////////////////
+//
+// GuiCharacter
+//
+/////////////////////////////////////////////////////////////////////
+
+typedef QController<ControlCharacter, GuiView<GuiCharacterDialog> > CharacterBase;
+
+GuiCharacter::GuiCharacter(Dialog & parent)
+ : CharacterBase(parent, _("Text Style"))
+{
+}
+
+
+void GuiCharacter::build_dialog()
+{
+ dialog_.reset(new GuiCharacterDialog(this));
+
+ family = getFamilyData();
+ series = getSeriesData();
+ shape = getShapeData();
+ size = getSizeData();
+ bar = getBarData();
+ color = getColorData();
+ language = getLanguageData(true);
+
+ for (vector<FamilyPair>::const_iterator cit = family.begin();
+ cit != family.end(); ++cit) {
+ dialog_->familyCO->addItem(toqstr(cit->first));
+ }
+
+ for (vector<SeriesPair>::const_iterator cit = series.begin();
+ cit != series.end(); ++cit) {
+ dialog_->seriesCO->addItem(toqstr(cit->first));
+ }
+ for (vector<ShapePair>::const_iterator cit = shape.begin();
+ cit != shape.end(); ++cit) {
+ dialog_->shapeCO->addItem(toqstr(cit->first));
+ }
+ for (vector<SizePair>::const_iterator cit = size.begin();
+ cit != size.end(); ++cit) {
+ dialog_->sizeCO->addItem(toqstr(cit->first));
+ }
+ for (vector<BarPair>::const_iterator cit = bar.begin();
+ cit != bar.end(); ++cit) {
+ dialog_->miscCO->addItem(toqstr(cit->first));
+ }
+ for (vector<ColorPair>::const_iterator cit = color.begin();
+ cit != color.end(); ++cit) {
+ dialog_->colorCO->addItem(toqstr(cit->first));
+ }
+ for (vector<LanguagePair>::const_iterator cit = language.begin();
+ cit != language.end(); ++cit) {
+ dialog_->langCO->addItem(toqstr(cit->first));
+ }
+
+ bcview().setOK(dialog_->okPB);
+ bcview().setApply(dialog_->applyPB);
+ bcview().setCancel(dialog_->closePB);
+ bcview().addReadOnly(dialog_->familyCO);
+ bcview().addReadOnly(dialog_->seriesCO);
+ bcview().addReadOnly(dialog_->sizeCO);
+ bcview().addReadOnly(dialog_->shapeCO);
+ bcview().addReadOnly(dialog_->miscCO);
+ bcview().addReadOnly(dialog_->langCO);
+ bcview().addReadOnly(dialog_->colorCO);
+ bcview().addReadOnly(dialog_->toggleallCB);
+ bcview().addReadOnly(dialog_->autoapplyCB);
+
+// FIXME: hack to work around resizing bug in Qt >= 4.2
+// bug verified with Qt 4.2.{0-3} (JSpitzm)
+#if QT_VERSION >= 0x040200
+ // qt resizes the comboboxes only after show(), so ...
+ dialog_->show();
+#endif
+}
+
+
+namespace {
+
+template<class A, class B>
+int findPos2nd(vector<std::pair<A,B> > const & vec, B const & val)
+{
+ typedef typename vector<std::pair<A, B> >::const_iterator
+ const_iterator;
+
+ const_iterator cit = vec.begin();
+ for (; cit != vec.end(); ++cit) {
+ if (cit->second == val)
+ return int(cit - vec.begin());
+ }
+ return 0;
+}
+
+} // namespace anon
+
+
+void GuiCharacter::update_contents()
+{
+ ControlCharacter const & ctrl = controller();
+
+ dialog_->familyCO->setCurrentIndex(findPos2nd(family,
+ ctrl.getFamily()));
+ dialog_->seriesCO->setCurrentIndex(findPos2nd(series,
+ ctrl.getSeries()));
+ dialog_->shapeCO->setCurrentIndex(findPos2nd(shape, ctrl.getShape()));
+ dialog_->sizeCO->setCurrentIndex(findPos2nd(size, ctrl.getSize()));
+ dialog_->miscCO->setCurrentIndex(findPos2nd(bar, ctrl.getBar()));
+ dialog_->colorCO->setCurrentIndex(findPos2nd(color, ctrl.getColor()));
+ dialog_->langCO->setCurrentIndex(findPos2nd(language,
+ ctrl.getLanguage()));
+
+ dialog_->toggleallCB->setChecked(ctrl.getToggleAll());
+}
+
+
+void GuiCharacter::apply()
+{
+ ControlCharacter & ctrl = controller();
+
+ ctrl.setFamily(family[dialog_->familyCO->currentIndex()].second);
+ ctrl.setSeries(series[dialog_->seriesCO->currentIndex()].second);
+ ctrl.setShape(shape[dialog_->shapeCO->currentIndex()].second);
+ ctrl.setSize(size[dialog_->sizeCO->currentIndex()].second);
+ ctrl.setBar(bar[dialog_->miscCO->currentIndex()].second);
+ ctrl.setColor(color[dialog_->colorCO->currentIndex()].second);
+ ctrl.setLanguage(language[dialog_->langCO->currentIndex()].second);
+
+ ctrl.setToggleAll(dialog_->toggleallCB->isChecked());
+}
+
+} // namespace frontend
+} // namespace lyx
+
+#include "GuiCharacter_moc.cpp"
--- /dev/null
+// -*- C++ -*-
+/**
+ * \file GuiCharacter.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Edwin Leuven
+ * \author John Levon
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#ifndef QCHARACTER_H_CONTROLLER
+#define QCHARACTER_H_CONTROLLER
+
+#include "GuiDialogView.h"
+#include "ui_CharacterUi.h"
+#include <QDialog>
+
+#include "controllers/frontend_helpers.h"
+
+#include <vector>
+
+namespace lyx {
+
+class Font;
+
+namespace frontend {
+
+class GuiCharacter;
+
+class GuiCharacterDialog : public QDialog, public Ui::CharacterUi {
+ Q_OBJECT
+public:
+ GuiCharacterDialog(GuiCharacter * form);
+protected:
+ void closeEvent(QCloseEvent * e);
+private:
+ GuiCharacter * form_;
+protected Q_SLOTS:
+ void change_adaptor();
+};
+
+
+class ControlCharacter;
+
+class GuiCharacter
+ : public QController<ControlCharacter, GuiView<GuiCharacterDialog> >
+{
+public:
+ friend class GuiCharacterDialog;
+
+ GuiCharacter(Dialog &);
+private:
+ /// Apply changes
+ virtual void apply();
+ /// update
+ virtual void update_contents();
+ /// build the dialog
+ virtual void build_dialog();
+
+ std::vector<FamilyPair> family;
+ std::vector<SeriesPair> series;
+ std::vector<ShapePair> shape;
+ std::vector<SizePair> size;
+ std::vector<BarPair> bar;
+ std::vector<ColorPair> color;
+ std::vector<LanguagePair> language;
+};
+
+} // namespace frontend
+} // namespace lyx
+
+#endif // QCHARACTER_H
--- /dev/null
+/**
+ * \file GuiCitation.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Angus Leeming
+ * \author Kalle Dalheimer
+ * \author Abdelrazak Younes
+ * \author Richard Heck (adapted to QSelectionManager)
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "GuiCitation.h"
+
+#include "qt_helpers.h"
+
+#include "support/lstrings.h"
+#include "support/docstring.h"
+
+#include "debug.h"
+
+#include <vector>
+#include <string>
+
+using std::vector;
+using std::string;
+
+
+template<typename String> static QStringList to_qstring_list(vector<String> const & v)
+{
+ QStringList qlist;
+
+ for (size_t i = 0; i != v.size(); ++i) {
+ if (v[i].empty())
+ continue;
+ qlist.append(lyx::toqstr(v[i]));
+ }
+ return qlist;
+}
+
+
+static vector<lyx::docstring> const to_docstring_vector(QStringList const & qlist)
+{
+ vector<lyx::docstring> v;
+ for (int i = 0; i != qlist.size(); ++i) {
+ if (qlist[i].isEmpty())
+ continue;
+ v.push_back(lyx::qstring_to_ucs4(qlist[i]));
+ }
+ return v;
+}
+
+
+namespace lyx {
+namespace frontend {
+
+
+GuiCitation::GuiCitation(Dialog & parent)
+ : ControlCitation(parent)
+{
+}
+
+
+void GuiCitation::apply(int const choice, bool const full, bool const force,
+ QString before, QString after)
+{
+ if (cited_keys_.isEmpty())
+ return;
+
+ vector<biblio::CiteStyle> const & styles =
+ ControlCitation::getCiteStyles();
+
+ string const command =
+ biblio::CitationStyle(styles[choice], full, force)
+ .asLatexStr();
+
+ params().setCmdName(command);
+ params()["key"] = qstring_to_ucs4(cited_keys_.join(","));
+ params()["before"] = qstring_to_ucs4(before);
+ params()["after"] = qstring_to_ucs4(after);
+ dispatchParams();
+}
+
+
+void GuiCitation::clearSelection()
+{
+ cited_keys_.clear();
+ selected_model_.setStringList(cited_keys_);
+}
+
+
+QString GuiCitation::textBefore()
+{
+ return toqstr(params()["before"]);
+}
+
+
+QString GuiCitation::textAfter()
+{
+ return toqstr(params()["after"]);
+}
+
+
+bool GuiCitation::initialiseParams(std::string const & data)
+{
+ if (!ControlCitation::initialiseParams(data))
+ return false;
+ init();
+ return true;
+}
+
+
+void GuiCitation::init()
+{
+ // Make the list of all available bibliography keys
+ all_keys_ = to_qstring_list(availableKeys());
+ available_model_.setStringList(all_keys_);
+
+ // Ditto for the keys cited in this inset
+ QString str = toqstr(params()["key"]);
+ if (str.isEmpty())
+ cited_keys_.clear();
+ else
+ cited_keys_ = str.split(",");
+ selected_model_.setStringList(cited_keys_);
+}
+
+
+void GuiCitation::findKey(QString const & str, bool only_keys,
+ docstring field, docstring entryType,
+ bool case_sensitive, bool reg_exp, bool reset)
+{
+ // Used for optimisation: store last searched string.
+ static QString last_searched_string;
+ // Used to disable the above optimisation.
+ static bool last_case_sensitive;
+ static bool last_reg_exp;
+ // Reset last_searched_string in case of changed option.
+ if (last_case_sensitive != case_sensitive
+ || last_reg_exp != reg_exp) {
+ LYXERR(Debug::GUI) << "GuiCitation::findKey: optimisation disabled!" << std::endl;
+ last_searched_string.clear();
+ }
+ // save option for next search.
+ last_case_sensitive = case_sensitive;
+ last_reg_exp = reg_exp;
+
+ Qt::CaseSensitivity qtcase = case_sensitive?
+ Qt::CaseSensitive: Qt::CaseInsensitive;
+ QStringList keys;
+ // If new string (str) contains the last searched one...
+ if (!reset &&
+ !last_searched_string.isEmpty() &&
+ str.size() > 1 &&
+ str.contains(last_searched_string, qtcase))
+ // ... then only search within already found list.
+ keys = available_model_.stringList();
+ else
+ // ... else search all keys.
+ keys = all_keys_;
+ // save searched string for next search.
+ last_searched_string = str;
+
+ QStringList result;
+
+ //First, filter by entryType, which will be faster than
+ //what follows, so we may get to do that on less.
+ vector<docstring> keyVector = to_docstring_vector(keys);
+ filterByEntryType(keyVector, entryType);
+
+ if (str.isEmpty())
+ result = to_qstring_list(keyVector);
+ else
+ result = to_qstring_list(searchKeys(keyVector, only_keys,
+ qstring_to_ucs4(str), field, case_sensitive, reg_exp));
+
+ available_model_.setStringList(result);
+}
+
+
+QStringList GuiCitation::getFieldsAsQStringList() {
+ return to_qstring_list(availableFields());
+}
+
+
+QStringList GuiCitation::getEntriesAsQStringList() {
+ return to_qstring_list(availableEntries());
+}
+
+
+QStringList GuiCitation::citationStyles(int sel)
+{
+ docstring const key = qstring_to_ucs4(cited_keys_[sel]);
+ return to_qstring_list(getCiteStrings(key));
+}
+
+
+QString GuiCitation::getKeyInfo(QString const & sel)
+{
+ return toqstr(getInfo(qstring_to_ucs4(sel)));
+}
+
+void GuiCitation::setCitedKeys()
+{
+ cited_keys_ = selected_model_.stringList();
+}
+
+
+} // namespace frontend
+} // namespace lyx
--- /dev/null
+// -*- C++ -*-
+/**
+ * \file GuiCitation.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Angus Leeming
+ * \author Kalle Dalheimer
+ * \author Abdelrazak Younes
+ * \author Richard Heck (adapted to QSelectionManager)
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#ifndef QCITATION_H
+#define QCITATION_H
+
+#include "frontends/controllers/ControlCitation.h"
+#include "support/docstring.h"
+
+#include <QStringList>
+#include <QStringListModel>
+
+namespace lyx {
+namespace frontend {
+
+class GuiCitation : public ControlCitation
+{
+public:
+ ///
+ GuiCitation(Dialog &);
+ virtual ~GuiCitation() {}
+ virtual bool initialiseParams(std::string const & data);
+
+ ///
+ void init();
+
+ /// Available keys
+ QStringListModel * available() { return &available_model_; }
+
+ /// Selected keys
+ QStringListModel * selected() { return &selected_model_; }
+
+ /// Text before cite
+ QString textBefore();
+
+ /// Text after cite
+ QString textAfter();
+
+ /// Get key description
+ QString getKeyInfo(QString const &);
+
+ /// Clear selected keys
+ void clearSelection();
+
+ /// Return a list of available fields
+ QStringList getFieldsAsQStringList();
+
+ /// Return a list of available fields
+ QStringList getEntriesAsQStringList();
+
+ /// Find keys containing a string.
+ void findKey(
+ QString const & str, //< string expression
+ bool only_keys, //< set to true if only keys shall be searched.
+ docstring field, //<field to search, empty for all fields
+ docstring entryType, //<entry type to display, empty for all
+ bool case_sensitive, //< set to true for case sensitive search.
+ bool reg_exp, //< set to true if \c str is a regular expression.
+ bool reset = false //< whether to reset and search all keys
+ );
+
+ /// List of example cite strings
+ QStringList citationStyles(int);
+
+ /// Set the Params variable for the Controller.
+ virtual void apply(int const choice, bool const full, bool const force,
+ QString before, QString after);
+
+ void setCitedKeys();
+
+private:
+ /// available keys.
+ QStringListModel available_model_;
+
+ /// selected keys.
+ QStringListModel selected_model_;
+
+ /// All keys.
+ QStringList all_keys_;
+
+ /// Cited keys.
+ QStringList cited_keys_;
+};
+
+
+} // namespace frontend
+} // namespace lyx
+
+#endif // QCITATION_H
--- /dev/null
+/**
+ * \file GuiCitationDialog.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Kalle Dalheimer
+ * \author John Levon
+ * \author Jürgen Spitzmüller
+ * \author Abdelrazak Younes
+ * \author Richard Heck
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "GuiCitationDialog.h"
+
+#include "GuiCitation.h"
+
+#include "frontends/controllers/frontend_helpers.h"
+#include "frontends/controllers/ControlCitation.h"
+#include "qt_helpers.h"
+
+#include "support/docstring.h"
+
+#include "debug.h"
+#include "gettext.h"
+
+#include <algorithm>
+#include <vector>
+#include <string>
+
+#include <QCloseEvent>
+#include <QKeyEvent>
+
+#undef KeyPress
+
+using std::vector;
+using std::string;
+
+namespace lyx {
+namespace frontend {
+
+
+GuiCitationDialog::GuiCitationDialog(Dialog & dialog, GuiCitation * form)
+ : Dialog::View(dialog, _("Citation")), form_(form)
+{
+ setupUi(this);
+
+ setWindowTitle(toqstr("LyX: " + getTitle()));
+
+ connect(citationStyleCO, SIGNAL(activated(int)),
+ this, SLOT(changed()));
+ connect(fulllistCB, SIGNAL(clicked()),
+ this, SLOT(changed()));
+ connect(forceuppercaseCB, SIGNAL(clicked()),
+ this, SLOT(changed()));
+ connect(textBeforeED, SIGNAL(textChanged(const QString&)),
+ this, SLOT(changed()));
+ connect(textAfterED, SIGNAL(textChanged(const QString&)),
+ this, SLOT(changed()));
+ connect(clearPB, SIGNAL(clicked()),
+ findLE, SLOT(clear()));
+ connect(this, SIGNAL(rejected()), this, SLOT(cleanUp()));
+
+ selectionManager =
+ new GuiSelectionManager(availableLV, selectedLV,
+ addPB, deletePB, upPB, downPB,
+ form_->available(), form_->selected());
+ connect(selectionManager, SIGNAL(selectionChanged()),
+ this, SLOT(setCitedKeys()));
+ connect(selectionManager, SIGNAL(updateHook()),
+ this, SLOT(updateDialog()));
+ connect(selectionManager, SIGNAL(okHook()),
+ this, SLOT(on_okPB_clicked()));
+
+}
+
+
+GuiCitationDialog::~GuiCitationDialog()
+{}
+
+
+void GuiCitationDialog::cleanUp()
+{
+ form_->clearSelection();
+ form_->clearParams();
+ close();
+}
+
+
+void GuiCitationDialog::closeEvent(QCloseEvent * e)
+{
+ form_->clearSelection();
+ form_->clearParams();
+ e->accept();
+}
+
+
+void GuiCitationDialog::apply()
+{
+ int const choice = std::max(0, citationStyleCO->currentIndex());
+ style_ = choice;
+ bool const full = fulllistCB->isChecked();
+ bool const force = forceuppercaseCB->isChecked();
+
+ QString const before = textBeforeED->text();
+ QString const after = textAfterED->text();
+
+ form_->apply(choice, full, force, before, after);
+}
+
+
+void GuiCitationDialog::hide()
+{
+ form_->clearParams();
+ accept();
+}
+
+
+void GuiCitationDialog::show()
+{
+ findLE->clear();
+ availableLV->setFocus();
+ QDialog::show();
+ raise();
+ activateWindow();
+}
+
+
+bool GuiCitationDialog::isVisible() const
+{
+ return QDialog::isVisible();
+}
+
+
+void GuiCitationDialog::on_okPB_clicked()
+{
+ apply();
+ form_->clearSelection();
+ hide();
+}
+
+
+void GuiCitationDialog::on_cancelPB_clicked()
+{
+ form_->clearSelection();
+ hide();
+}
+
+
+void GuiCitationDialog::on_applyPB_clicked()
+{
+ apply();
+}
+
+
+void GuiCitationDialog::on_restorePB_clicked()
+{
+ form_->init();
+ update();
+}
+
+
+void GuiCitationDialog::update()
+{
+ fillFields();
+ fillEntries();
+ updateDialog();
+}
+
+
+//The main point of separating this out is that the fill*() methods
+//called in update() do not need to be called for INTERNAL updates,
+//such as when addPB is pressed, as the list of fields, entries, etc,
+//will not have changed. At the moment, however, the division between
+//fillStyles() and updateStyles() doesn't lend itself to dividing the
+//two methods, though they should be divisible.
+void GuiCitationDialog::updateDialog()
+{
+ if (selectionManager->selectedFocused()) {
+ if (selectedLV->selectionModel()->selectedIndexes().isEmpty())
+ updateInfo(availableLV->currentIndex());
+ else
+ updateInfo(selectedLV->currentIndex());
+ } else {
+ if (availableLV->selectionModel()->selectedIndexes().isEmpty())
+ updateInfo(QModelIndex());
+ else
+ updateInfo(availableLV->currentIndex());
+ }
+ setButtons();
+
+ textBeforeED->setText(form_->textBefore());
+ textAfterED->setText(form_->textAfter());
+ fillStyles();
+ updateStyle();
+}
+
+
+void GuiCitationDialog::updateStyle()
+{
+ biblio::CiteEngine const engine = form_->getEngine();
+ bool const natbib_engine =
+ engine == biblio::ENGINE_NATBIB_AUTHORYEAR ||
+ engine == biblio::ENGINE_NATBIB_NUMERICAL;
+ bool const basic_engine = engine == biblio::ENGINE_BASIC;
+
+ bool const haveSelection =
+ selectedLV->model()->rowCount() > 0;
+ fulllistCB->setEnabled(natbib_engine && haveSelection);
+ forceuppercaseCB->setEnabled(natbib_engine && haveSelection);
+ textBeforeED->setEnabled(!basic_engine && haveSelection);
+ textBeforeLA->setEnabled(!basic_engine && haveSelection);
+ textAfterED->setEnabled(haveSelection);
+ textAfterLA->setEnabled(haveSelection);
+ citationStyleCO->setEnabled(!basic_engine && haveSelection);
+ citationStyleLA->setEnabled(!basic_engine && haveSelection);
+
+ string const & command = form_->params().getCmdName();
+
+ // Find the style of the citekeys
+ vector<biblio::CiteStyle> const & styles =
+ ControlCitation::getCiteStyles();
+ biblio::CitationStyle const cs(command);
+
+ vector<biblio::CiteStyle>::const_iterator cit =
+ std::find(styles.begin(), styles.end(), cs.style);
+
+ // restore the latest natbib style
+ if (style_ >= 0 && style_ < citationStyleCO->count())
+ citationStyleCO->setCurrentIndex(style_);
+ else
+ citationStyleCO->setCurrentIndex(0);
+
+ if (cit != styles.end()) {
+ int const i = int(cit - styles.begin());
+ citationStyleCO->setCurrentIndex(i);
+ fulllistCB->setChecked(cs.full);
+ forceuppercaseCB->setChecked(cs.forceUCase);
+ } else {
+ fulllistCB->setChecked(false);
+ forceuppercaseCB->setChecked(false);
+ }
+}
+
+
+//This one needs to be called whenever citationStyleCO needs
+//to be updated---and this would be on anything that changes the
+//selection in selectedLV, or on a general update.
+void GuiCitationDialog::fillStyles()
+{
+ int const oldIndex = citationStyleCO->currentIndex();
+
+ citationStyleCO->clear();
+
+ QStringList selected_keys = form_->selected()->stringList();
+ if (selected_keys.empty()) {
+ citationStyleCO->setEnabled(false);
+ citationStyleLA->setEnabled(false);
+ return;
+ }
+
+ int curr = selectedLV->model()->rowCount() - 1;
+ if (curr < 0)
+ return;
+
+ if (!selectedLV->selectionModel()->selectedIndexes().empty())
+ curr = selectedLV->selectionModel()->selectedIndexes()[0].row();
+
+ QStringList sty = form_->citationStyles(curr);
+
+ bool const basic_engine =
+ (form_->getEngine() == biblio::ENGINE_BASIC);
+
+ citationStyleCO->setEnabled(!sty.isEmpty() && !basic_engine);
+ citationStyleLA->setEnabled(!sty.isEmpty() && !basic_engine);
+
+ if (sty.isEmpty() || basic_engine)
+ return;
+
+ citationStyleCO->insertItems(0, sty);
+
+ if (oldIndex != -1 && oldIndex < citationStyleCO->count())
+ citationStyleCO->setCurrentIndex(oldIndex);
+}
+
+
+void GuiCitationDialog::fillFields()
+{
+ fieldsCO->blockSignals(true);
+ int const oldIndex = fieldsCO->currentIndex();
+ fieldsCO->clear();
+ QStringList const & fields = form_->getFieldsAsQStringList();
+ fieldsCO->insertItem(0, qt_("All Fields"));
+ fieldsCO->insertItem(1, qt_("Keys"));
+ fieldsCO->insertItems(2, fields);
+ if (oldIndex != -1 && oldIndex < fieldsCO->count())
+ fieldsCO->setCurrentIndex(oldIndex);
+ fieldsCO->blockSignals(false);
+}
+
+
+void GuiCitationDialog::fillEntries()
+{
+ entriesCO->blockSignals(true);
+ int const oldIndex = entriesCO->currentIndex();
+ entriesCO->clear();
+ QStringList const & entries = form_->getEntriesAsQStringList();
+ entriesCO->insertItem(0, qt_("All Entry Types"));
+ entriesCO->insertItems(1, entries);
+ if (oldIndex != -1 && oldIndex < entriesCO->count())
+ entriesCO->setCurrentIndex(oldIndex);
+ entriesCO->blockSignals(false);
+}
+
+
+bool GuiCitationDialog::isSelected(const QModelIndex & idx)
+{
+ QString const str = idx.data().toString();
+ return form_->selected()->stringList().contains(str);
+}
+
+
+void GuiCitationDialog::setButtons()
+{
+ selectionManager->update();
+ int const srows = selectedLV->model()->rowCount();
+ applyPB->setEnabled(srows > 0);
+ okPB->setEnabled(srows > 0);
+}
+
+
+void GuiCitationDialog::updateInfo(QModelIndex const & idx)
+{
+ if (idx.isValid()) {
+ QString const keytxt = form_->getKeyInfo(idx.data().toString());
+ infoML->document()->setPlainText(keytxt);
+ } else
+ infoML->document()->clear();
+}
+
+
+void GuiCitationDialog::setCitedKeys()
+{
+ form_->setCitedKeys();
+}
+
+
+void GuiCitationDialog::findText(QString const & text, bool reset)
+{
+ //"All Fields" and "Keys" are the first two
+ int index = fieldsCO->currentIndex() - 2;
+ vector<docstring> const & fields = form_->availableFields();
+ docstring field;
+
+ if (index <= -1 || index >= int(fields.size()))
+ //either "All Fields" or "Keys" or an invalid value
+ field = from_ascii("");
+ else
+ field = fields[index];
+
+ //Was it "Keys"?
+ bool const onlyKeys = index == -1;
+
+ //"All Entry Types" is first.
+ index = entriesCO->currentIndex() - 1;
+ vector<docstring> const & entries = form_->availableEntries();
+ docstring entryType;
+ if (index < 0 || index >= int(entries.size()))
+ entryType = from_ascii("");
+ else
+ entryType = entries[index];
+
+ bool const case_sentitive = caseCB->checkState();
+ bool const reg_exp = regexCB->checkState();
+ form_->findKey(text, onlyKeys, field, entryType,
+ case_sentitive, reg_exp, reset);
+ //FIXME
+ //It'd be nice to save and restore the current selection in
+ //availableLV. Currently, we get an automatic reset, since the
+ //model is reset.
+
+ updateDialog();
+}
+
+
+void GuiCitationDialog::on_fieldsCO_currentIndexChanged(int /*index*/)
+{
+ findText(findLE->text(), true);
+}
+
+
+void GuiCitationDialog::on_entriesCO_currentIndexChanged(int /*index*/)
+{
+ findText(findLE->text(), true);
+}
+
+
+void GuiCitationDialog::on_findLE_textChanged(const QString & text)
+{
+ clearPB->setDisabled(text.isEmpty());
+ if (text.isEmpty())
+ findLE->setFocus();
+ findText(text);
+}
+
+
+void GuiCitationDialog::on_caseCB_stateChanged(int)
+{
+ findText(findLE->text());
+}
+
+
+void GuiCitationDialog::on_regexCB_stateChanged(int)
+{
+ findText(findLE->text());
+}
+
+
+void GuiCitationDialog::changed()
+{
+ fillStyles();
+ setButtons();
+}
+
+
+} // namespace frontend
+} // namespace lyx
+
+#include "GuiCitationDialog_moc.cpp"
--- /dev/null
+// -*- C++ -*-
+/**
+ * \file GuiCitationDialog.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Kalle Dalheimer
+ * \author Abdelrazak Younes
+ * \author Richard Heck
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#ifndef QCITATIONDIALOG_H
+#define QCITATIONDIALOG_H
+
+#include "Dialog.h"
+#include "GuiSelectionManager.h"
+#include "ui_CitationUi.h"
+
+#include <QCloseEvent>
+#include <QKeyEvent>
+#include <QStringList>
+#include <QStringListModel>
+
+namespace lyx {
+namespace frontend {
+
+class GuiCitation;
+
+class GuiCitationDialog : public QDialog,
+ public Ui::CitationUi, public Dialog::View
+{
+ Q_OBJECT
+
+public:
+ GuiCitationDialog(Dialog &, GuiCitation * form );
+
+ virtual ~GuiCitationDialog();
+
+ virtual void apply();
+
+ /// Hide the dialog from sight
+ void hide();
+
+ /// Redraw the dialog (e.g. if the colors have been remapped).
+ void redraw() {}
+
+ /// Create the dialog if necessary, update it and display it.
+ void show();
+
+ /// \return true if the dialog is visible.
+ bool isVisible() const;
+
+public Q_SLOTS:
+ /// Update the display of the dialog whilst it is still visible.
+ void update();
+
+protected:
+ void closeEvent (QCloseEvent * e);
+ /// prepares a call to GuiCitation::searchKeys when we
+ /// are ready to search the BibTeX entries
+ void findText(QString const & text, bool reset = false);
+ /// check whether key is already selected
+ bool isSelected(const QModelIndex &);
+ /// update the display of BibTeX information
+ void updateInfo(QModelIndex const &);
+
+protected Q_SLOTS:
+ void cleanUp();
+ void on_okPB_clicked();
+ void on_cancelPB_clicked();
+ void on_restorePB_clicked();
+ void on_applyPB_clicked();
+ void on_findLE_textChanged(const QString & text);
+ void on_fieldsCO_currentIndexChanged(int index);
+ void on_entriesCO_currentIndexChanged(int index);
+ void on_caseCB_stateChanged(int);
+ void on_regexCB_stateChanged(int);
+ virtual void changed();
+ ///
+ void setCitedKeys();
+ /// performs a limited update, suitable for internal call
+ void updateDialog();
+
+private:
+ /// enable/disable buttons
+ void setButtons();
+ /// fill the styles combo
+ void fillStyles();
+ /// fill the fields combo
+ void fillFields();
+ /// fill the entries combo
+ void fillEntries();
+ /// set the styles combo
+ void updateStyle();
+ /// last used citation style
+ int style_;
+
+ GuiCitation * form_;
+
+ GuiSelectionManager * selectionManager;
+};
+
+} // namespace frontend
+} // namespace lyx
+
+#endif // QCITATIOINDIALOG_H
--- /dev/null
+/**
+ * \file GuiCommandBuffer.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author John Levon
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+// Qt defines a macro 'signals' that clashes with a boost namespace.
+// All is well if the namespace is visible first.
+#include "GuiView.h"
+
+#include "GuiCommandBuffer.h"
+#include "GuiCommandEdit.h"
+#include "qt_helpers.h"
+
+#include "support/filetools.h"
+
+#include <QHBoxLayout>
+#include <QKeyEvent>
+#include <QLayout>
+#include <QListWidget>
+#include <QMouseEvent>
+#include <QPixmap>
+#include <QPushButton>
+#include <QToolTip>
+#include <QVBoxLayout>
+
+using lyx::support::libFileSearch;
+
+using std::vector;
+using std::string;
+
+namespace lyx {
+namespace frontend {
+
+namespace {
+
+class QTempListBox : public QListWidget {
+public:
+ QTempListBox() {
+ //setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
+ setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+ setWindowModality(Qt::WindowModal);
+ setWindowFlags(Qt::Popup);
+ setAttribute(Qt::WA_DeleteOnClose);
+ }
+protected:
+ void mouseReleaseEvent(QMouseEvent * ev) {
+ if (ev->x() < 0 || ev->y() < 0
+ || ev->x() > width() || ev->y() > height()) {
+ hide();
+ } else {
+ // emit signal
+ itemPressed(currentItem());
+ }
+ }
+
+ void keyPressEvent(QKeyEvent * ev) {
+ if (ev->key() == Qt::Key_Escape) {
+ hide();
+ return;
+ } else if (ev->key() == Qt::Key_Return || ev->key() == Qt::Key_Space) {
+ // emit signal
+ itemPressed(currentItem());
+ } else
+ QListWidget::keyPressEvent(ev);
+ }
+};
+
+} // end of anon
+
+
+GuiCommandBuffer::GuiCommandBuffer(GuiViewBase * view)
+ : view_(view), controller_(*view)
+{
+ QPixmap qpup(toqstr(libFileSearch("images", "up", "png").absFilename()));
+ QPixmap qpdown(toqstr(libFileSearch("images", "down", "png").absFilename()));
+
+ QVBoxLayout * top = new QVBoxLayout(this);
+ QHBoxLayout * layout = new QHBoxLayout(0);
+
+ QPushButton * up = new QPushButton(qpup, "", this);
+ up->setMaximumSize(24, 24);
+ up->setToolTip(qt_("Previous command"));
+ connect(up, SIGNAL(clicked()), this, SLOT(up()));
+ QPushButton * down = new QPushButton(qpdown, "", this);
+ down->setToolTip(qt_("Next command"));
+ down->setMaximumSize(24, 24);
+ connect(down, SIGNAL(clicked()), this, SLOT(down()));
+
+ edit_ = new GuiCommandEdit(this);
+ edit_->setMinimumSize(edit_->sizeHint());
+ edit_->setFocusPolicy(Qt::ClickFocus);
+
+ connect(edit_, SIGNAL(escapePressed()), this, SLOT(cancel()));
+ connect(edit_, SIGNAL(returnPressed()), this, SLOT(dispatch()));
+ connect(edit_, SIGNAL(tabPressed()), this, SLOT(complete()));
+ connect(edit_, SIGNAL(upPressed()), this, SLOT(up()));
+ connect(edit_, SIGNAL(downPressed()), this, SLOT(down()));
+ connect(edit_, SIGNAL(hidePressed()), this, SLOT(hideParent()));
+
+ layout->addWidget(up, 0);
+ layout->addWidget(down, 0);
+ layout->addWidget(edit_, 10);
+ layout->setMargin(0);
+ top->addLayout(layout);
+ top->setMargin(0);
+ setFocusProxy(edit_);
+}
+
+
+void GuiCommandBuffer::cancel()
+{
+ view_->setFocus();
+ edit_->setText(QString());
+}
+
+
+void GuiCommandBuffer::dispatch()
+{
+ controller_.dispatch(fromqstr(edit_->text()));
+ view_->setFocus();
+ edit_->setText(QString());
+ edit_->clearFocus();
+}
+
+
+void GuiCommandBuffer::complete()
+{
+ string const input = fromqstr(edit_->text());
+ string new_input;
+ vector<string> comp = controller_.completions(input, new_input);
+
+ if (comp.empty() && new_input == input) {
+ // show_info_suffix(qt_("[no match]"), input);
+ return;
+ }
+
+ if (comp.empty()) {
+ edit_->setText(toqstr(new_input));
+ // show_info_suffix(("[only completion]"), new_input + ' ');
+ return;
+ }
+
+ edit_->setText(toqstr(new_input));
+
+ QTempListBox * list = new QTempListBox;
+
+ // For some reason the scrollview's contents are larger
+ // than the number of actual items...
+ vector<string>::const_iterator cit = comp.begin();
+ vector<string>::const_iterator end = comp.end();
+ for (; cit != end; ++cit)
+ list->addItem(toqstr(*cit));
+
+ list->resize(list->sizeHint());
+ QPoint const pos = edit_->mapToGlobal(QPoint(0, 0));
+
+ int const y = std::max(0, pos.y() - list->height());
+
+ list->move(pos.x(), y);
+
+ connect(list, SIGNAL(itemPressed(QListWidgetItem *)),
+ this, SLOT(complete_selected(QListWidgetItem *)));
+ connect(list, SIGNAL(itemActivated(QListWidgetItem *)),
+ this, SLOT(complete_selected(QListWidgetItem *)));
+
+ list->show();
+ list->setFocus();
+}
+
+
+void GuiCommandBuffer::complete_selected(QListWidgetItem * item)
+{
+ QWidget const * widget = static_cast<QWidget const *>(sender());
+ const_cast<QWidget *>(widget)->hide();
+ edit_->setText(item->text() + ' ');
+ edit_->activateWindow();
+ edit_->setFocus();
+}
+
+
+void GuiCommandBuffer::up()
+{
+ string const input = fromqstr(edit_->text());
+ string const h = controller_.historyUp();
+
+ if (h.empty()) {
+ // show_info_suffix(qt_("[Beginning of history]"), input);
+ } else {
+ edit_->setText(toqstr(h));
+ }
+}
+
+
+void GuiCommandBuffer::down()
+{
+ string const input = fromqstr(edit_->text());
+ string const h = controller_.historyDown();
+
+ if (h.empty()) {
+ // show_info_suffix(qt_("[End of history]"), input);
+ } else {
+ edit_->setText(toqstr(h));
+ }
+}
+
+
+void GuiCommandBuffer::hideParent()
+{
+ view_->setFocus();
+ edit_->setText(QString());
+ edit_->clearFocus();
+ controller_.hide();
+}
+
+
+#if 0
+void XMiniBuffer::show_info_suffix(string const & suffix, string const & input)
+{
+ stored_input_ = input;
+ info_suffix_shown_ = true;
+ set_input(input + ' ' + suffix);
+ suffix_timer_->start();
+}
+
+
+void XMiniBuffer::suffix_timeout()
+{
+ info_suffix_shown_ = false;
+ set_input(stored_input_);
+}
+
+#endif
+
+} // namespace frontend
+} // namespace lyx
+
+#include "GuiCommandBuffer_moc.cpp"
--- /dev/null
+// -*- C++ -*-
+/**
+ * \file GuiCommandBuffer.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author John Levon
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#ifndef QCOMMANDBUFFER_H
+#define QCOMMANDBUFFER_H
+
+#include "controllers/ControlCommandBuffer.h"
+
+#include <QWidget>
+
+class QListWidgetItem;
+
+namespace lyx {
+namespace frontend {
+
+class GuiCommandEdit;
+class GuiView;
+
+class GuiCommandBuffer : public QWidget {
+ Q_OBJECT
+public:
+ GuiCommandBuffer(GuiViewBase * view);
+
+public Q_SLOTS:
+ /// cancel command compose
+ void cancel();
+ /// dispatch a command
+ void dispatch();
+ /// tab-complete
+ void complete();
+ /// select-complete
+ void complete_selected(QListWidgetItem *);
+ /// up
+ void up();
+ /// down
+ void down();
+ /// leave and hide the command buffer
+ void hideParent();
+private:
+ /// owning view
+ GuiViewBase * view_;
+
+ /// controller
+ ControlCommandBuffer controller_;
+
+ /// command widget
+ GuiCommandEdit * edit_;
+};
+
+} // namespace frontend
+} // namespace lyx
+
+#endif // QCOMMANDBUFFER_H
--- /dev/null
+/**
+ * \file GuiCommandEdit.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author John Levon
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "GuiCommandEdit.h"
+
+#include <QKeyEvent>
+#include <QEvent>
+
+#undef KeyPress
+
+namespace lyx {
+namespace frontend {
+
+GuiCommandEdit::GuiCommandEdit(QWidget * parent)
+ : QLineEdit(parent)
+{
+ setFocusPolicy(Qt::ClickFocus);
+}
+
+
+void GuiCommandEdit::keyPressEvent(QKeyEvent * e)
+{
+ switch (e->key()) {
+ case Qt::Key_Escape:
+ // emit signal
+ escapePressed();
+ break;
+
+ case Qt::Key_Up:
+ // emit signal
+ upPressed();
+ break;
+
+ case Qt::Key_Down:
+ // emit signal
+ downPressed();
+ break;
+
+ case Qt::Key_X:
+ if (e->modifiers() == Qt::AltModifier
+ || e->modifiers() == Qt::MetaModifier) {
+ // emit signal
+ hidePressed();
+ break;
+ }
+
+ default:
+ QLineEdit::keyPressEvent(e);
+ break;
+ }
+}
+
+
+bool GuiCommandEdit::event(QEvent * e)
+{
+ if (e->type() != QEvent::KeyPress)
+ return QLineEdit::event(e);
+
+ QKeyEvent * ev = (QKeyEvent *)e;
+
+ if (ev->key() != Qt::Key_Tab)
+ return QLineEdit::event(e);
+
+ // emit signal
+ tabPressed();
+ return true;
+}
+
+} // namespace frontend
+} // namespace lyx
+
+#include "GuiCommandEdit_moc.cpp"
--- /dev/null
+// -*- C++ -*-
+/**
+ * \file GuiCommandEdit.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author John Levon
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#ifndef QCOMMANDEDIT_H
+#define QCOMMANDEDIT_H
+
+#include <QLineEdit>
+#include <QKeyEvent>
+#include <QEvent>
+
+namespace lyx {
+namespace frontend {
+
+class GuiCommandEdit : public QLineEdit {
+ Q_OBJECT
+public:
+ GuiCommandEdit(QWidget * parent);
+Q_SIGNALS:
+ /// cancel
+ void escapePressed();
+ /// up history
+ void upPressed();
+ /// down history
+ void downPressed();
+ /// complete
+ void tabPressed();
+ /// leave and hide command buffer
+ void hidePressed();
+
+protected:
+ ///
+ virtual bool event(QEvent * e);
+ ///
+ virtual void keyPressEvent(QKeyEvent * e);
+};
+
+} // namespace frontend
+} // namespace lyx
+
+#endif // QCOMMANDEDIT_H
--- /dev/null
+/**
+ * \file GuiDelimiterDialog.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author John Levon
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "GuiDelimiterDialog.h"
+
+#include "GuiApplication.h"
+#include "GuiView.h"
+
+
+#include "qt_helpers.h"
+#include "controllers/ControlMath.h"
+
+#include "gettext.h"
+
+#include <QPixmap>
+#include <QCheckBox>
+#include <QListWidgetItem>
+
+#include <sstream>
+
+// Set to zero if unicode symbols are preferred.
+#define USE_PIXMAP 1
+
+using std::string;
+
+namespace lyx {
+namespace frontend {
+
+namespace {
+
+QString const bigleft[] = {"", "bigl", "Bigl", "biggl", "Biggl"};
+
+
+QString const bigright[] = {"", "bigr", "Bigr", "biggr", "Biggr"};
+
+
+char const * const biggui[] = {N_("big[[delimiter size]]"), N_("Big[[delimiter size]]"),
+ N_("bigg[[delimiter size]]"), N_("Bigg[[delimiter size]]"), ""};
+
+
+// FIXME: It might be better to fix the big delim LFUN to not require
+// additional '\' prefix.
+QString fix_name(QString const & str, bool big)
+{
+ if (str.isEmpty())
+ return ".";
+ if (!big || str == "(" || str == ")" || str == "[" || str == "]"
+ || str == "|" || str == "/")
+ return str;
+
+ return "\\" + str;
+}
+
+} // namespace anon
+
+
+typedef QController<ControlMath, GuiView<GuiDelimiterDialog> > delimiter_base;
+
+GuiMathDelimiter::GuiMathDelimiter(Dialog & parent)
+ : delimiter_base(parent, _("Math Delimiter"))
+{}
+
+
+void GuiMathDelimiter::build_dialog()
+{
+ dialog_.reset(new GuiDelimiterDialog(this,
+ static_cast<GuiViewBase *>(controller().view())));
+}
+
+
+char_type GuiDelimiterDialog::doMatch(char_type const symbol) const
+{
+ string const & str = form_->controller().texName(symbol);
+ string match;
+ if (str == "(") match = ")";
+ else if (str == ")") match = "(";
+ else if (str == "[") match = "]";
+ else if (str == "]") match = "[";
+ else if (str == "{") match = "}";
+ else if (str == "}") match = "{";
+ else if (str == "l") match = "r";
+ else if (str == "rceil") match = "lceil";
+ else if (str == "lceil") match = "rceil";
+ else if (str == "rfloor") match = "lfloor";
+ else if (str == "lfloor") match = "rfloor";
+ else if (str == "rangle") match = "langle";
+ else if (str == "langle") match = "rangle";
+ else if (str == "backslash") match = "/";
+ else if (str == "/") match = "backslash";
+ else return symbol;
+
+ return form_->controller().mathSymbol(match).unicode;
+}
+
+
+GuiDelimiterDialog::GuiDelimiterDialog(GuiMathDelimiter * form, QWidget * parent)
+ : QDialog(parent), form_(form)
+{
+ setupUi(this);
+
+ connect(closePB, SIGNAL(clicked()), this, SLOT(accept()));
+
+ setWindowTitle(qt_("LyX: Delimiters"));
+ setFocusProxy(leftLW);
+
+ leftLW->setViewMode(QListView::IconMode);
+ rightLW->setViewMode(QListView::IconMode);
+
+ typedef std::map<char_type, QListWidgetItem *> ListItems;
+ ListItems list_items;
+ // The last element is the empty one.
+ int const end = nr_latex_delimiters - 1;
+ for (int i = 0; i < end; ++i) {
+ string const delim = latex_delimiters[i];
+ MathSymbol const & ms = form_->controller().mathSymbol(delim);
+ QString symbol(ms.fontcode?
+ QChar(ms.fontcode) : toqstr(docstring(1, ms.unicode)));
+ QListWidgetItem * lwi = new QListWidgetItem(symbol);
+ lwi->setToolTip(toqstr(delim));
+ Font lyxfont;
+ lyxfont.setFamily(ms.fontfamily);
+ QFont const & symbol_font = guiApp->guiFontLoader().get(lyxfont);
+ lwi->setFont(symbol_font);
+ list_items[ms.unicode] = lwi;
+ leftLW->addItem(lwi);
+ }
+
+ for (int i = 0; i != leftLW->count(); ++i) {
+ MathSymbol const & ms = form_->controller().mathSymbol(
+ fromqstr(leftLW->item(i)->toolTip()));
+ rightLW->addItem(list_items[doMatch(ms.unicode)]->clone());
+ }
+
+ // The last element is the empty one.
+ leftLW->addItem(qt_("(None)"));
+ rightLW->addItem(qt_("(None)"));
+
+ sizeCO->addItem(qt_("Variable"));
+
+ for (int i = 0; *biggui[i]; ++i)
+ sizeCO->addItem(qt_(biggui[i]));
+
+ on_leftLW_currentRowChanged(0);
+}
+
+
+void GuiDelimiterDialog::updateTeXCode(int size)
+{
+ bool const bigsize = size != 0;
+
+ QString left_str = fix_name(leftLW->currentItem()->toolTip(), bigsize);
+ QString right_str = fix_name(rightLW->currentItem()->toolTip(), bigsize);
+
+ if (!bigsize)
+ tex_code_ = left_str + ' ' + right_str;
+ else {
+ tex_code_ = bigleft[size] + ' '
+ + left_str + ' '
+ + bigright[size] + ' '
+ + right_str;
+ }
+
+ // Generate TeX-code for GUI display.
+ // FIXME: Instead of reconstructing the TeX code it would be nice to
+ // FIXME: retrieve the LateX code directly from mathed.
+ // In all cases, we want the '\' prefix if needed, so we pass 'true'
+ // to fix_name.
+ left_str = fix_name(leftLW->currentItem()->toolTip(), true);
+ right_str = fix_name(rightLW->currentItem()->toolTip(), true);
+ QString code_str;
+ if (!bigsize)
+ code_str = "\\left" + left_str + " \\right" + right_str;
+ else {
+ // There should be nothing in the TeX-code when the delimiter is "None".
+ if (left_str != ".")
+ code_str = "\\" + bigleft[size] + left_str + ' ';
+ if (right_str != ".")
+ code_str += "\\" + bigright[size] + right_str;
+ }
+
+ texCodeL->setText(qt_("TeX Code: ") + code_str);
+}
+
+
+void GuiDelimiterDialog::on_insertPB_clicked()
+{
+ if (sizeCO->currentIndex() == 0)
+ form_->controller().dispatchDelim(fromqstr(tex_code_));
+ else {
+ QString command = '"' + tex_code_ + '"';
+ command.replace(' ', "\" \"");
+ form_->controller().dispatchBigDelim(fromqstr(command));
+ }
+ }
+
+
+void GuiDelimiterDialog::on_sizeCO_activated(int index)
+{
+ updateTeXCode(index);
+}
+
+
+void GuiDelimiterDialog::on_leftLW_itemActivated(QListWidgetItem *)
+{
+ on_insertPB_clicked();
+ accept();
+}
+
+
+void GuiDelimiterDialog::on_rightLW_itemActivated(QListWidgetItem *)
+{
+ on_insertPB_clicked();
+ accept();
+}
+
+
+void GuiDelimiterDialog::on_leftLW_currentRowChanged(int item)
+{
+ if (matchCB->isChecked())
+ rightLW->setCurrentRow(item);
+
+ updateTeXCode(sizeCO->currentIndex());
+}
+
+
+void GuiDelimiterDialog::on_rightLW_currentRowChanged(int item)
+{
+ if (matchCB->isChecked())
+ leftLW->setCurrentRow(item);
+
+ updateTeXCode(sizeCO->currentIndex());
+}
+
+
+void GuiDelimiterDialog::on_matchCB_stateChanged(int state)
+{
+ if (state == Qt::Checked)
+ on_leftLW_currentRowChanged(leftLW->currentRow());
+
+ updateTeXCode(sizeCO->currentIndex());
+}
+
+
+} // namespace frontend
+} // namespace lyx
+
+#include "GuiDelimiterDialog_moc.cpp"
--- /dev/null
+// -*- C++ -*-
+/**
+ * \file GuiDelimiterDialog.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author John Levon
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#ifndef QDELIMITERDIALOG_H
+#define QDELIMITERDIALOG_H
+
+#include "GuiDialogView.h"
+
+#include "ui_DelimiterUi.h"
+
+#include <string>
+
+class QListWidgetItem;
+
+namespace lyx {
+namespace frontend {
+
+class ControlMath;
+class GuiMathDelimiter;
+
+class GuiDelimiterDialog : public QDialog, public Ui::DelimiterUi {
+ Q_OBJECT
+public:
+ GuiDelimiterDialog(GuiMathDelimiter * form, QWidget * parent);
+public Q_SLOTS:
+ void on_leftLW_itemActivated(QListWidgetItem *);
+ void on_rightLW_itemActivated(QListWidgetItem *);
+ void on_leftLW_currentRowChanged(int);
+ void on_rightLW_currentRowChanged(int);
+ void on_matchCB_stateChanged(int);
+ void on_insertPB_clicked();
+ void on_sizeCO_activated(int);
+private:
+ ///
+ char_type doMatch(char_type const symbol) const;
+ ///
+ void updateTeXCode(int size);
+ /// owning form
+ GuiMathDelimiter * form_;
+ /// TeX code that will be inserted.
+ QString tex_code_;
+};
+
+
+class GuiMathDelimiter : public QController<ControlMath, GuiView<GuiDelimiterDialog> > {
+public:
+ friend class GuiDelimiterDialog;
+
+ GuiMathDelimiter(Dialog &);
+
+private:
+ virtual void apply() {}
+ virtual void update_contents() {}
+ /// Build the dialog.
+ virtual void build_dialog();
+};
+
+
+} // namespace frontend
+} // namespace lyx
+
+#endif // QDELIMITERDIALOG_H
--- /dev/null
+/**
+ * \file GuiDialogView.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Angus Leeming
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "GuiDialogView.h"
+#include "Qt2BC.h"
+#include "qt_helpers.h"
+
+#include "controllers/ButtonController.h"
+
+
+namespace lyx {
+namespace frontend {
+
+GuiDialogView::GuiDialogView(Dialog & parent, docstring const & t)
+ : Dialog::View(parent,t), updating_(false)
+{}
+
+
+Qt2BC & GuiDialogView::bcview()
+{
+ return static_cast<Qt2BC &>(dialog().bc().view());
+}
+
+
+bool GuiDialogView::isVisible() const
+{
+ return form() && form()->isVisible();
+}
+
+
+bool GuiDialogView::readOnly() const
+{
+ return kernel().isBufferReadonly();
+}
+
+
+void GuiDialogView::show()
+{
+ if (!form()) {
+ build();
+ }
+
+ QSize const sizeHint = form()->sizeHint();
+ if (sizeHint.height() >= 0 && sizeHint.width() >= 0)
+ form()->setMinimumSize(sizeHint);
+
+ update(); // make sure its up-to-date
+ if (dialog().controller().exitEarly())
+ return;
+
+ form()->setWindowTitle(toqstr("LyX: " + getTitle()));
+
+ if (form()->isVisible()) {
+ form()->raise();
+ form()->activateWindow();
+ form()->setFocus();
+ } else {
+ form()->show();
+ form()->setFocus();
+ }
+}
+
+
+void GuiDialogView::hide()
+{
+ if (form() && form()->isVisible())
+ form()->hide();
+}
+
+
+bool GuiDialogView::isValid()
+{
+ return true;
+}
+
+
+void GuiDialogView::changed()
+{
+ if (updating_)
+ return;
+ bc().valid(isValid());
+}
+
+
+void GuiDialogView::slotWMHide()
+{
+ dialog().CancelButton();
+}
+
+
+void GuiDialogView::slotApply()
+{
+ dialog().ApplyButton();
+}
+
+
+void GuiDialogView::slotOK()
+{
+ dialog().OKButton();
+}
+
+
+void GuiDialogView::slotClose()
+{
+ dialog().CancelButton();
+}
+
+
+void GuiDialogView::slotRestore()
+{
+ dialog().RestoreButton();
+}
+
+} // namespace frontend
+} // namespace lyx
+
+#include "GuiDialogView_moc.cpp"
--- /dev/null
+// -*- C++ -*-
+/**
+ * \file GuiDialogView.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Angus Leeming
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#ifndef QDIALOGVIEW_H
+#define QDIALOGVIEW_H
+
+#include "Dialog.h"
+
+#include <boost/scoped_ptr.hpp>
+
+#include <QApplication>
+#include <QWidget>
+#include <QObject>
+
+namespace lyx {
+namespace frontend {
+
+class Qt2BC;
+
+/** This class is an Qt2 GUI base class.
+ */
+class GuiDialogView : public QObject, public Dialog::View {
+ Q_OBJECT
+public:
+ ///
+ GuiDialogView(Dialog &, docstring const &);
+ ///
+ virtual ~GuiDialogView() {}
+ ///
+ bool readOnly() const;
+
+ /// the dialog has changed contents
+ virtual void changed();
+
+ ///
+ Qt2BC & bcview();
+
+protected:
+ /// build the actual dialog
+ virtual void build_dialog() = 0;
+ ///
+ virtual void build() = 0;
+ /// Hide the dialog.
+ virtual void hide();
+ /// Create the dialog if necessary, update it and display it.
+ virtual void show();
+ /// update the dialog's contents
+ virtual void update_contents() = 0;
+ ///
+ virtual bool isVisible() const;
+
+ /// is the dialog currently valid ?
+ virtual bool isValid();
+
+ /// are we updating ?
+ bool updating_;
+
+public Q_SLOTS:
+ // dialog closed from WM
+ void slotWMHide();
+
+ // Restore button clicked
+ void slotRestore();
+
+ // OK button clicked
+ void slotOK();
+
+ // Apply button clicked
+ void slotApply();
+
+ // Close button clicked
+ void slotClose();
+private:
+ /// Pointer to the actual instantiation of the Qt dialog
+ virtual QWidget * form() const = 0;
+};
+
+
+template <class GUIDialog>
+class GuiView : public GuiDialogView {
+protected:
+ GuiView(Dialog & p, docstring const & t)
+ : GuiDialogView(p, t)
+ {}
+
+ virtual ~GuiView() {}
+
+ /// update the dialog
+ virtual void update() {
+ dialog_->setUpdatesEnabled(false);
+
+ // protect the BC from unwarranted state transitions
+ updating_ = true;
+ update_contents();
+ updating_ = false;
+
+ dialog_->setUpdatesEnabled(true);
+ dialog_->update();
+ }
+
+ /// Build the dialog
+ virtual void build() {
+ // protect the BC from unwarranted state transitions
+ updating_ = true;
+ build_dialog();
+ updating_ = false;
+ }
+
+ /// Pointer to the actual instantiation of the Qt dialog
+ virtual GUIDialog * form() const { return dialog_.get(); }
+
+ /// Real GUI implementation.
+ boost::scoped_ptr<GUIDialog> dialog_;
+};
+
+
+template <class Controller, class Base>
+class QController: public Base
+{
+protected:
+ ///
+ QController(Dialog & p, docstring const & t): Base(p, t)
+ {}
+public:
+ /// The parent controller
+ Controller & controller()
+ { return static_cast<Controller &>(this->getController()); }
+
+ /// The parent controller
+ Controller const & controller() const
+ { return static_cast<Controller const &>(this->getController()); }
+};
+
+} // namespace frontend
+} // namespace lyx
+
+#endif // QDIALOGVIEW_H
--- /dev/null
+/**
+ * \file GuiDocument.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Edwin Leuven
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "GuiDocument.h"
+
+#include "CheckedLineEdit.h"
+#include "FloatPlacement.h"
+#include "LengthCombo.h"
+#include "PanelStack.h"
+#include "Qt2BC.h"
+#include "qt_helpers.h"
+#include "Validator.h"
+
+// For the Branches module
+#include "GuiBranches.h"
+
+#include "GuiViewSource.h" // For latexHighlighter use in the preamble.
+
+#include "controllers/ControlDocument.h"
+
+#include "BufferParams.h"
+#include "Encoding.h"
+#include "gettext.h"
+#include "frontend_helpers.h" // getSecond()
+#include "Language.h"
+#include "LyXRC.h" // defaultUnit
+#include "TextClassList.h"
+#include "Spacing.h"
+
+#include "insets/InsetListingsParams.h"
+#include "controllers/ControlDocument.h"
+
+#include "support/lstrings.h"
+
+#include <QCloseEvent>
+#include <QScrollBar>
+#include <QTextCursor>
+
+#include <map>
+
+using lyx::support::token;
+using lyx::support::bformat;
+using lyx::support::findToken;
+using lyx::support::getVectorFromString;
+
+using std::distance;
+using std::make_pair;
+using std::pair;
+using std::vector;
+using std::string;
+
+
+char const * const tex_graphics[] = {"default", "dvips", "dvitops", "emtex",
+ "ln", "oztex", "textures", "none", ""
+};
+
+
+char const * const tex_graphics_gui[] = {N_("Default"), "Dvips", "DVItoPS", "EmTeX",
+ "LN", "OzTeX", "Textures", N_("None"), ""
+};
+
+
+char const * const tex_fonts_roman[] = {"default", "cmr", "lmodern", "ae", "times", "palatino",
+ "charter", "newcent", "bookman", "utopia", "beraserif", "ccfonts", "chancery", ""
+};
+
+
+char const * tex_fonts_roman_gui[] = { N_("Default"), N_("Computer Modern Roman"), N_("Latin Modern Roman"),
+ N_("AE (Almost European)"), N_("Times Roman"), N_("Palatino"), N_("Bitstream Charter"),
+ N_("New Century Schoolbook"), N_("Bookman"), N_("Utopia"), N_("Bera Serif"),
+ N_("Concrete Roman"), N_("Zapf Chancery"), ""
+};
+
+
+char const * const tex_fonts_sans[] = {"default", "cmss", "lmss", "helvet", "avant", "berasans", "cmbr", ""
+};
+
+
+char const * tex_fonts_sans_gui[] = { N_("Default"), N_("Computer Modern Sans"), N_("Latin Modern Sans"),
+ N_("Helvetica"), N_("Avant Garde"), N_("Bera Sans"), N_("CM Bright"), ""
+};
+
+
+char const * const tex_fonts_monospaced[] = {"default", "cmtt", "lmtt", "courier", "beramono",
+ "luximono", "cmtl", ""
+};
+
+
+char const * tex_fonts_monospaced_gui[] = { N_("Default"), N_("Computer Modern Typewriter"),
+ N_("Latin Modern Typewriter"), N_("Courier"), N_("Bera Mono"), N_("LuxiMono"),
+ N_("CM Typewriter Light"), ""
+};
+
+
+vector<pair<string, lyx::docstring> > pagestyles;
+
+
+namespace lyx {
+namespace frontend {
+
+/////////////////////////////////////////////////////////////////////
+//
+// PreambleModule
+//
+/////////////////////////////////////////////////////////////////////
+
+PreambleModule::PreambleModule(): current_id_(0)
+{
+ // This is not a memory leak. The object will be destroyed
+ // with this.
+ (void) new LaTeXHighlighter(preambleTE->document());
+ setFocusProxy(preambleTE);
+ connect(preambleTE, SIGNAL(textChanged()), this, SIGNAL(changed()));
+}
+
+
+void PreambleModule::update(BufferParams const & params, BufferId id)
+{
+ QString preamble = toqstr(params.preamble);
+ // Nothing to do if the params and preamble are unchanged.
+ if (id == current_id_
+ && preamble == preambleTE->document()->toPlainText())
+ return;
+
+ QTextCursor cur = preambleTE->textCursor();
+ // Save the coords before switching to the new one.
+ preamble_coords_[current_id_] =
+ 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.
+ preamble_coords_[current_id_] = make_pair(0,0);
+ 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();
+ preamble_coords_[current_id_] =
+ make_pair(cur.position(), preambleTE->verticalScrollBar()->value());
+ e->accept();
+}
+
+
+/////////////////////////////////////////////////////////////////////
+//
+// DocumentDialog
+//
+/////////////////////////////////////////////////////////////////////
+
+GuiDocumentDialog::GuiDocumentDialog(GuiDocument * form)
+ : form_(form),
+ lang_(getSecond(getLanguageData(false)))
+{
+ setupUi(this);
+
+ connect(okPB, SIGNAL(clicked()), form, SLOT(slotOK()));
+ connect(applyPB, SIGNAL(clicked()), form, SLOT(slotApply()));
+ connect(closePB, SIGNAL(clicked()), form, SLOT(slotClose()));
+ connect(restorePB, SIGNAL(clicked()), form, SLOT(slotRestore()));
+
+ connect(savePB, SIGNAL(clicked()), this, SLOT(saveDefaultClicked()));
+ connect(defaultPB, SIGNAL(clicked()), this, SLOT(useDefaultsClicked()));
+
+ // Manage the restore, ok, apply, restore and cancel/close buttons
+ form_->bcview().setOK(okPB);
+ form_->bcview().setApply(applyPB);
+ form_->bcview().setCancel(closePB);
+ form_->bcview().setRestore(restorePB);
+
+
+ textLayoutModule = new UiWidget<Ui::TextLayoutUi>;
+ // text layout
+ connect(textLayoutModule->lspacingCO, SIGNAL(activated(int)),
+ this, SLOT(change_adaptor()));
+ connect(textLayoutModule->lspacingCO, SIGNAL(activated(int)),
+ this, SLOT(setLSpacing(int)));
+ connect(textLayoutModule->lspacingLE, SIGNAL(textChanged(const QString&)),
+ this, SLOT(change_adaptor()));
+ connect(textLayoutModule->skipRB, SIGNAL(clicked()),
+ this, SLOT(change_adaptor()));
+ connect(textLayoutModule->indentRB, SIGNAL(clicked()),
+ this, SLOT(change_adaptor()));
+ connect(textLayoutModule->skipCO, SIGNAL(activated(int)),
+ this, SLOT(change_adaptor()));
+ connect(textLayoutModule->skipLE, SIGNAL(textChanged(const QString &)),
+ this, SLOT(change_adaptor()));
+ connect(textLayoutModule->skipLengthCO, SIGNAL(activated(int)),
+ this, SLOT(change_adaptor()));
+ connect(textLayoutModule->skipCO, SIGNAL(activated(int)),
+ this, SLOT(setSkip(int)));
+ connect(textLayoutModule->skipRB, SIGNAL(toggled(bool)),
+ this, SLOT(enableSkip(bool)));
+ connect(textLayoutModule->twoColumnCB, SIGNAL(clicked()),
+ this, SLOT(change_adaptor()));
+ connect(textLayoutModule->listingsED, SIGNAL(textChanged()),
+ this, SLOT(change_adaptor()));
+ connect(textLayoutModule->bypassCB, SIGNAL(clicked()),
+ this, SLOT(change_adaptor()));
+ connect(textLayoutModule->bypassCB, SIGNAL(clicked()),
+ this, SLOT(set_listings_msg()));
+ connect(textLayoutModule->listingsED, SIGNAL(textChanged()),
+ this, SLOT(set_listings_msg()));
+ textLayoutModule->listingsTB->setPlainText(
+ qt_("Input listings parameters on the right. Enter ? for a list of parameters."));
+ textLayoutModule->lspacingLE->setValidator(new QDoubleValidator(
+ textLayoutModule->lspacingLE));
+ textLayoutModule->skipLE->setValidator(unsignedLengthValidator(
+ textLayoutModule->skipLE));
+
+ textLayoutModule->skipCO->addItem(qt_("SmallSkip"));
+ textLayoutModule->skipCO->addItem(qt_("MedSkip"));
+ textLayoutModule->skipCO->addItem(qt_("BigSkip"));
+ textLayoutModule->skipCO->addItem(qt_("Length"));
+ // remove the %-items from the unit choice
+ textLayoutModule->skipLengthCO->noPercents();
+ 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
+ addCheckedLineEdit(form_->bcview(), textLayoutModule->skipLE);
+
+ fontModule = new UiWidget<Ui::FontUi>;
+ // fonts
+ 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)));
+ connect(fontModule->fontsDefaultCO, SIGNAL(activated(int)),
+ this, SLOT(change_adaptor()));
+ connect(fontModule->fontsizeCO, SIGNAL(activated(int)),
+ this, SLOT(change_adaptor()));
+ 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()));
+
+ for (int n = 0; tex_fonts_roman[n][0]; ++n) {
+ QString font = qt_(tex_fonts_roman_gui[n]);
+ if (!form_->controller().isFontAvailable(tex_fonts_roman[n]))
+ font += qt_(" (not installed)");
+ fontModule->fontsRomanCO->addItem(font);
+ }
+ for (int n = 0; tex_fonts_sans[n][0]; ++n) {
+ QString font = qt_(tex_fonts_sans_gui[n]);
+ if (!form_->controller().isFontAvailable(tex_fonts_sans[n]))
+ font += qt_(" (not installed)");
+ fontModule->fontsSansCO->addItem(font);
+ }
+ for (int n = 0; tex_fonts_monospaced[n][0]; ++n) {
+ QString font = qt_(tex_fonts_monospaced_gui[n]);
+ if (!form_->controller().isFontAvailable(tex_fonts_monospaced[n]))
+ font += qt_(" (not installed)");
+ fontModule->fontsTypewriterCO->addItem(font);
+ }
+
+ fontModule->fontsizeCO->addItem(qt_("Default"));
+ fontModule->fontsizeCO->addItem(qt_("10"));
+ fontModule->fontsizeCO->addItem(qt_("11"));
+ fontModule->fontsizeCO->addItem(qt_("12"));
+
+ for (int n = 0; ControlDocument::fontfamilies_gui[n][0]; ++n)
+ fontModule->fontsDefaultCO->addItem(
+ qt_(ControlDocument::fontfamilies_gui[n]));
+
+
+ pageLayoutModule = new UiWidget<Ui::PageLayoutUi>;
+ // page layout
+ connect(pageLayoutModule->papersizeCO, SIGNAL(activated(int)),
+ this, SLOT(setCustomPapersize(int)));
+ connect(pageLayoutModule->papersizeCO, SIGNAL(activated(int)),
+ this, SLOT(setCustomPapersize(int)));
+ connect(pageLayoutModule->portraitRB, SIGNAL(clicked()),
+ this, SLOT(portraitChanged()));
+ 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()));
+
+ pageLayoutModule->pagestyleCO->addItem(qt_("Default"));
+ pageLayoutModule->pagestyleCO->addItem(qt_("empty"));
+ pageLayoutModule->pagestyleCO->addItem(qt_("plain"));
+ pageLayoutModule->pagestyleCO->addItem(qt_("headings"));
+ pageLayoutModule->pagestyleCO->addItem(qt_("fancy"));
+ addCheckedLineEdit(form_->bcview(), pageLayoutModule->paperheightLE,
+ pageLayoutModule->paperheightL);
+ addCheckedLineEdit(form_->bcview(), pageLayoutModule->paperwidthLE,
+ pageLayoutModule->paperwidthL);
+
+ // paper
+ 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"));
+ cb->addItem(qt_("A3"));
+ cb->addItem(qt_("A4"));
+ cb->addItem(qt_("A5"));
+ cb->addItem(qt_("B3"));
+ cb->addItem(qt_("B4"));
+ cb->addItem(qt_("B5"));
+ // 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));
+
+
+
+
+ marginsModule = new UiWidget<Ui::MarginsUi>;
+ // margins
+ connect(marginsModule->marginCB, SIGNAL(toggled(bool)),
+ this, SLOT(setCustomMargins(bool)));
+ connect(marginsModule->marginCB, SIGNAL(clicked()),
+ this, SLOT(change_adaptor()));
+ connect(marginsModule->topLE, SIGNAL(textChanged(const QString &)),
+ this, SLOT(change_adaptor()));
+ connect(marginsModule->topUnit, SIGNAL(activated(int)),
+ this, SLOT(change_adaptor()));
+ connect(marginsModule->bottomLE, SIGNAL(textChanged(const QString &)),
+ this, SLOT(change_adaptor()));
+ connect(marginsModule->bottomUnit, SIGNAL(activated(int)),
+ this, SLOT(change_adaptor()));
+ connect(marginsModule->innerLE, SIGNAL(textChanged(const QString &)),
+ this, SLOT(change_adaptor()));
+ connect(marginsModule->innerUnit, SIGNAL(activated(int)),
+ this, SLOT(change_adaptor()));
+ connect(marginsModule->outerLE, SIGNAL(textChanged(const QString &)),
+ this, SLOT(change_adaptor()));
+ connect(marginsModule->outerUnit, SIGNAL(activated(int)),
+ this, SLOT(change_adaptor()));
+ connect(marginsModule->headheightLE, SIGNAL(textChanged(const QString &)),
+ this, SLOT(change_adaptor()));
+ connect(marginsModule->headheightUnit, SIGNAL(activated(int)),
+ this, SLOT(change_adaptor()));
+ connect(marginsModule->headsepLE, SIGNAL(textChanged(const QString &)),
+ this, SLOT(change_adaptor()));
+ connect(marginsModule->headsepUnit, SIGNAL(activated(int)),
+ this, SLOT(change_adaptor()));
+ connect(marginsModule->footskipLE, SIGNAL(textChanged(const QString&)),
+ this, SLOT(change_adaptor()));
+ connect(marginsModule->footskipUnit, SIGNAL(activated(int)),
+ this, SLOT(change_adaptor()));
+ 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));
+
+ addCheckedLineEdit(form_->bcview(), marginsModule->topLE,
+ marginsModule->topL);
+ addCheckedLineEdit(form_->bcview(), marginsModule->bottomLE,
+ marginsModule->bottomL);
+ addCheckedLineEdit(form_->bcview(), marginsModule->innerLE,
+ marginsModule->innerL);
+ addCheckedLineEdit(form_->bcview(), marginsModule->outerLE,
+ marginsModule->outerL);
+ addCheckedLineEdit(form_->bcview(), marginsModule->headsepLE,
+ marginsModule->headsepL);
+ addCheckedLineEdit(form_->bcview(), marginsModule->headheightLE,
+ marginsModule->headheightL);
+ addCheckedLineEdit(form_->bcview(), marginsModule->footskipLE,
+ marginsModule->footskipL);
+
+
+ langModule = new UiWidget<Ui::LanguageUi>;
+ connect(langModule->defaultencodingCB, SIGNAL(toggled(bool)),
+ langModule->encodingL, SLOT(setDisabled(bool)));
+ connect(langModule->defaultencodingCB, SIGNAL(toggled(bool)),
+ langModule->encodingCO, SLOT(setDisabled(bool)));
+ // language & quote
+ connect(langModule->languageCO, SIGNAL(activated(int)),
+ this, SLOT(change_adaptor()));
+ connect(langModule->defaultencodingCB, SIGNAL(clicked()),
+ this, SLOT(change_adaptor()));
+ connect(langModule->encodingCO, SIGNAL(activated(int)),
+ this, SLOT(change_adaptor()));
+ connect(langModule->quoteStyleCO, SIGNAL(activated(int)),
+ this, SLOT(change_adaptor()));
+ // language & quotes
+ vector<LanguagePair> const langs = getLanguageData(false);
+ vector<LanguagePair>::const_iterator lit = langs.begin();
+ vector<LanguagePair>::const_iterator lend = langs.end();
+ for (; lit != lend; ++lit) {
+ langModule->languageCO->addItem(
+ toqstr(lit->first));
+ }
+
+ // Always put the default encoding in the first position.
+ // It is special because the displayed text is translated.
+ langModule->encodingCO->addItem(qt_("LaTeX default"));
+ Encodings::const_iterator it = encodings.begin();
+ Encodings::const_iterator const end = encodings.end();
+ for (; it != end; ++it)
+ langModule->encodingCO->addItem(toqstr(it->latexName()));
+
+ langModule->quoteStyleCO->addItem(qt_("``text''"));
+ langModule->quoteStyleCO->addItem(qt_("''text''"));
+ langModule->quoteStyleCO->addItem(qt_(",,text``"));
+ langModule->quoteStyleCO->addItem(qt_(",,text''"));
+ langModule->quoteStyleCO->addItem(qt_("<<text>>"));
+ langModule->quoteStyleCO->addItem(qt_(">>text<<"));
+
+
+
+ numberingModule = new UiWidget<Ui::NumberingUi>;
+ // numbering
+ 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()));
+ 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"));
+
+
+ biblioModule = new UiWidget<Ui::BiblioUi>;
+ connect(biblioModule->citeNatbibRB, SIGNAL(toggled(bool)),
+ biblioModule->citationStyleL, SLOT(setEnabled(bool)));
+ connect(biblioModule->citeNatbibRB, SIGNAL(toggled(bool)),
+ biblioModule->citeStyleCO, SLOT(setEnabled(bool)));
+ // biblio
+ connect(biblioModule->citeDefaultRB, SIGNAL(clicked()),
+ this, SLOT(change_adaptor()));
+ connect(biblioModule->citeNatbibRB, SIGNAL(clicked()),
+ this, SLOT(change_adaptor()));
+ connect(biblioModule->citeStyleCO, SIGNAL(activated(int)),
+ this, SLOT(change_adaptor()));
+ connect(biblioModule->citeJurabibRB, SIGNAL(clicked()),
+ this, SLOT(change_adaptor()));
+ connect(biblioModule->bibtopicCB, SIGNAL(clicked()),
+ this, SLOT(change_adaptor()));
+ // biblio
+ biblioModule->citeStyleCO->addItem(qt_("Author-year"));
+ biblioModule->citeStyleCO->addItem(qt_("Numerical"));
+ biblioModule->citeStyleCO->setCurrentIndex(0);
+
+
+
+ mathsModule = new UiWidget<Ui::MathsUi>;
+ connect(mathsModule->amsautoCB, SIGNAL(toggled(bool)),
+ mathsModule->amsCB, SLOT(setDisabled(bool)));
+ connect(mathsModule->esintautoCB, SIGNAL(toggled(bool)),
+ mathsModule->esintCB, SLOT(setDisabled(bool)));
+ // maths
+ connect(mathsModule->amsCB, SIGNAL(clicked()),
+ this, SLOT(change_adaptor()));
+ connect(mathsModule->amsautoCB, SIGNAL(clicked()),
+ this, SLOT(change_adaptor()));
+ connect(mathsModule->esintCB, SIGNAL(clicked()),
+ this, SLOT(change_adaptor()));
+ connect(mathsModule->esintautoCB, SIGNAL(clicked()),
+ this, SLOT(change_adaptor()));
+
+ latexModule = new UiWidget<Ui::LaTeXUi>;
+ // latex class
+ connect(latexModule->classCO, SIGNAL(activated(int)),
+ this, SLOT(change_adaptor()));
+ connect(latexModule->optionsLE, SIGNAL(textChanged(const QString &)),
+ this, SLOT(change_adaptor()));
+ connect(latexModule->psdriverCO, SIGNAL(activated(int)),
+ this, SLOT(change_adaptor()));
+ connect(latexModule->classCO, SIGNAL(activated(int)),
+ this, SLOT(classChanged()));
+ // packages
+ for (int n = 0; tex_graphics[n][0]; ++n) {
+ QString enc = qt_(tex_graphics_gui[n]);
+ latexModule->psdriverCO->addItem(enc);
+ }
+ // latex
+ for (TextClassList::const_iterator cit = textclasslist.begin();
+ cit != textclasslist.end(); ++cit) {
+ if (cit->isTeXClassAvailable()) {
+ latexModule->classCO->addItem(toqstr(cit->description()));
+ } else {
+ docstring item =
+ bformat(_("Unavailable: %1$s"), from_utf8(cit->description()));
+ latexModule->classCO->addItem(toqstr(item));
+ }
+ }
+
+ // branches
+ branchesModule = new GuiBranches;
+ connect(branchesModule, SIGNAL(changed()),
+ this, SLOT(change_adaptor()));
+
+ // preamble
+ preambleModule = new PreambleModule;
+ connect(preambleModule, SIGNAL(changed()),
+ this, SLOT(change_adaptor()));
+
+ // bullets
+ bulletsModule = new BulletsModule;
+ connect(bulletsModule, SIGNAL(changed()),
+ this, SLOT(change_adaptor()));
+
+
+ // float
+ floatModule = new FloatPlacement;
+ connect(floatModule, SIGNAL(changed()),
+ this, SLOT(change_adaptor()));
+
+ docPS->addPanel(latexModule, _("Document Class"));
+ docPS->addPanel(fontModule, _("Fonts"));
+ docPS->addPanel(textLayoutModule, _("Text Layout"));
+ docPS->addPanel(pageLayoutModule, _("Page Layout"));
+ docPS->addPanel(marginsModule, _("Page Margins"));
+ docPS->addPanel(langModule, _("Language"));
+ docPS->addPanel(numberingModule, _("Numbering & TOC"));
+ docPS->addPanel(biblioModule, _("Bibliography"));
+ docPS->addPanel(mathsModule, _("Math Options"));
+ docPS->addPanel(floatModule, _("Float Placement"));
+ docPS->addPanel(bulletsModule, _("Bullets"));
+ docPS->addPanel(branchesModule, _("Branches"));
+ docPS->addPanel(preambleModule, _("LaTeX Preamble"));
+ docPS->setCurrentPanel(_("Document Class"));
+// 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
+}
+
+
+void GuiDocumentDialog::showPreamble()
+{
+ docPS->setCurrentPanel(_("LaTeX Preamble"));
+}
+
+
+void GuiDocumentDialog::saveDefaultClicked()
+{
+ form_->saveDocDefault();
+}
+
+
+void GuiDocumentDialog::useDefaultsClicked()
+{
+ form_->useClassDefaults();
+}
+
+
+void GuiDocumentDialog::change_adaptor()
+{
+ form_->changed();
+}
+
+
+docstring GuiDocumentDialog::validate_listings_params()
+{
+ // use a cache here to avoid repeated validation
+ // of the same parameters
+ static string param_cache = string();
+ static docstring msg_cache = docstring();
+
+ if (textLayoutModule->bypassCB->isChecked())
+ return docstring();
+
+ string params = fromqstr(textLayoutModule->listingsED->toPlainText());
+ if (params != param_cache) {
+ param_cache = params;
+ msg_cache = InsetListingsParams(params).validate();
+ }
+ return msg_cache;
+}
+
+
+void GuiDocumentDialog::set_listings_msg()
+{
+ static bool isOK = true;
+ docstring msg = validate_listings_params();
+ if (msg.empty()) {
+ if (isOK)
+ return;
+ isOK = true;
+ // listingsTB->setTextColor("black");
+ textLayoutModule->listingsTB->setPlainText(
+ qt_("Input listings parameters on the right. Enter ? for a list of parameters."));
+ } else {
+ isOK = false;
+ // listingsTB->setTextColor("red");
+ textLayoutModule->listingsTB->setPlainText(toqstr(msg));
+ }
+}
+
+
+void GuiDocumentDialog::closeEvent(QCloseEvent * e)
+{
+ form_->slotWMHide();
+ e->accept();
+}
+
+
+void GuiDocumentDialog::setLSpacing(int item)
+{
+ textLayoutModule->lspacingLE->setEnabled(item == 3);
+}
+
+
+void GuiDocumentDialog::setSkip(int item)
+{
+ bool const enable = (item == 3);
+ textLayoutModule->skipLE->setEnabled(enable);
+ textLayoutModule->skipLengthCO->setEnabled(enable);
+}
+
+
+void GuiDocumentDialog::enableSkip(bool skip)
+{
+ textLayoutModule->skipCO->setEnabled(skip);
+ textLayoutModule->skipLE->setEnabled(skip);
+ textLayoutModule->skipLengthCO->setEnabled(skip);
+ if (skip)
+ setSkip(textLayoutModule->skipCO->currentIndex());
+}
+
+void GuiDocumentDialog::portraitChanged()
+{
+ setMargins(pageLayoutModule->papersizeCO->currentIndex());
+}
+
+void GuiDocumentDialog::setMargins(bool custom)
+{
+ marginsModule->marginCB->setChecked(custom);
+ setCustomMargins(custom);
+}
+
+
+void GuiDocumentDialog::setCustomPapersize(int papersize)
+{
+ bool const custom = (papersize == 1);
+
+ 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);
+}
+
+
+void GuiDocumentDialog::setCustomMargins(bool custom)
+{
+ 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);
+}
+
+
+void GuiDocumentDialog::updateFontsize(string const & items, string const & sel)
+{
+ fontModule->fontsizeCO->clear();
+ fontModule->fontsizeCO->addItem(qt_("Default"));
+
+ 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;
+ }
+ }
+}
+
+
+void GuiDocumentDialog::romanChanged(int item)
+{
+ string const font = tex_fonts_roman[item];
+
+ fontModule->fontScCB->setEnabled(
+ form_->controller().providesSC(font));
+ fontModule->fontOsfCB->setEnabled(
+ form_->controller().providesOSF(font));
+}
+
+
+void GuiDocumentDialog::sansChanged(int item)
+{
+ string const font = tex_fonts_sans[item];
+ bool scaleable = form_->controller().providesScale(font);
+ fontModule->scaleSansSB->setEnabled(scaleable);
+ fontModule->scaleSansLA->setEnabled(scaleable);
+}
+
+
+void GuiDocumentDialog::ttChanged(int item)
+{
+ string const font = tex_fonts_monospaced[item];
+ bool scaleable = form_->controller().providesScale(font);
+ fontModule->scaleTypewriterSB->setEnabled(scaleable);
+ fontModule->scaleTypewriterLA->setEnabled(scaleable);
+}
+
+
+void GuiDocumentDialog::updatePagestyle(string const & items, string const & sel)
+{
+ pagestyles.clear();
+ pageLayoutModule->pagestyleCO->clear();
+ pageLayoutModule->pagestyleCO->addItem(qt_("Default"));
+
+ for (int n = 0; !token(items,'|',n).empty(); ++n) {
+ string style = token(items, '|', n);
+ docstring style_gui = _(style);
+ pagestyles.push_back(pair<string, docstring>(style, style_gui));
+ pageLayoutModule->pagestyleCO->addItem(toqstr(style_gui));
+ }
+
+ if (sel == "default") {
+ pageLayoutModule->pagestyleCO->setCurrentIndex(0);
+ return;
+ }
+
+ int n = 0;
+
+ for (size_t i = 0; i < pagestyles.size(); ++i)
+ if (pagestyles[i].first == sel)
+ n = pageLayoutModule->pagestyleCO->findText(
+ toqstr(pagestyles[i].second));
+
+ if (n > 0)
+ pageLayoutModule->pagestyleCO->setCurrentIndex(n);
+}
+
+
+void GuiDocumentDialog::classChanged()
+{
+ ControlDocument & cntrl = form_->controller();
+ BufferParams & params = cntrl.params();
+
+ textclass_type const tc = latexModule->classCO->currentIndex();
+
+ if (form_->controller().loadTextclass(tc)) {
+ params.setJustBaseClass(tc);
+ if (lyxrc.auto_reset_options)
+ params.useClassDefaults();
+ form_->update_contents();
+ } else {
+ latexModule->classCO->setCurrentIndex(params.getBaseClass());
+ }
+}
+
+
+void GuiDocumentDialog::updateNumbering()
+{
+ TextClass const & tclass =
+ form_->controller().params().getTextClass();
+
+ 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");
+ TextClass::const_iterator end = tclass.end();
+ TextClass::const_iterator cit = tclass.begin();
+ QTreeWidgetItem * item = 0;
+ for ( ; cit != end ; ++cit) {
+ int const toclevel = (*cit)->toclevel;
+ if (toclevel != Layout::NOT_IN_TOC
+ && (*cit)->labeltype == LABEL_COUNTER) {
+ item = new QTreeWidgetItem(numberingModule->tocTW);
+ item->setText(0, toqstr(translateIfPossible((*cit)->name())));
+ item->setText(1, (toclevel <= depth) ? yes : no);
+ item->setText(2, (toclevel <= toc) ? yes : no);
+ }
+ }
+
+ numberingModule->tocTW->setUpdatesEnabled(true);
+ numberingModule->tocTW->update();
+}
+
+void GuiDocumentDialog::apply(BufferParams & params)
+{
+ // preamble
+ preambleModule->apply(params);
+
+ // biblio
+ params.setCiteEngine(biblio::ENGINE_BASIC);
+
+ if (biblioModule->citeNatbibRB->isChecked()) {
+ bool const use_numerical_citations =
+ biblioModule->citeStyleCO->currentIndex();
+ if (use_numerical_citations)
+ params.setCiteEngine(biblio::ENGINE_NATBIB_NUMERICAL);
+ else
+ params.setCiteEngine(biblio::ENGINE_NATBIB_AUTHORYEAR);
+
+ } else if (biblioModule->citeJurabibRB->isChecked())
+ params.setCiteEngine(biblio::ENGINE_JURABIB);
+
+ params.use_bibtopic =
+ biblioModule->bibtopicCB->isChecked();
+
+ // language & quotes
+ if (langModule->defaultencodingCB->isChecked()) {
+ params.inputenc = "auto";
+ } else {
+ int i = langModule->encodingCO->currentIndex();
+ if (i == 0)
+ params.inputenc = "default";
+ else
+ params.inputenc =
+ fromqstr(langModule->encodingCO->currentText());
+ }
+
+ InsetQuotes::quote_language lga = InsetQuotes::EnglishQ;
+ switch (langModule->quoteStyleCO->currentIndex()) {
+ case 0:
+ lga = InsetQuotes::EnglishQ;
+ break;
+ case 1:
+ lga = InsetQuotes::SwedishQ;
+ break;
+ case 2:
+ lga = InsetQuotes::GermanQ;
+ break;
+ case 3:
+ lga = InsetQuotes::PolishQ;
+ break;
+ case 4:
+ lga = InsetQuotes::FrenchQ;
+ break;
+ case 5:
+ lga = InsetQuotes::DanishQ;
+ break;
+ }
+ params.quotes_language = lga;
+
+ int const pos = langModule->languageCO->currentIndex();
+ params.language = lyx::languages.getLanguage(lang_[pos]);
+
+ // numbering
+ if (params.getTextClass().hasTocLevels()) {
+ params.tocdepth = numberingModule->tocSL->value();
+ params.secnumdepth = numberingModule->depthSL->value();
+ }
+
+ // bullets
+ params.user_defined_bullet(0) = bulletsModule->getBullet(0);
+ params.user_defined_bullet(1) = bulletsModule->getBullet(1);
+ params.user_defined_bullet(2) = bulletsModule->getBullet(2);
+ params.user_defined_bullet(3) = bulletsModule->getBullet(3);
+
+ // packages
+ params.graphicsDriver =
+ tex_graphics[latexModule->psdriverCO->currentIndex()];
+
+ if (mathsModule->amsautoCB->isChecked()) {
+ params.use_amsmath = BufferParams::package_auto;
+ } else {
+ if (mathsModule->amsCB->isChecked())
+ params.use_amsmath = BufferParams::package_on;
+ else
+ params.use_amsmath = BufferParams::package_off;
+ }
+
+ if (mathsModule->esintautoCB->isChecked())
+ params.use_esint = BufferParams::package_auto;
+ else {
+ if (mathsModule->esintCB->isChecked())
+ params.use_esint = BufferParams::package_on;
+ else
+ params.use_esint = BufferParams::package_off;
+ }
+
+ // text layout
+ params.setJustBaseClass(latexModule->classCO->currentIndex());
+
+ if (pageLayoutModule->pagestyleCO->currentIndex() == 0)
+ params.pagestyle = "default";
+ else {
+ docstring style_gui =
+ qstring_to_ucs4(pageLayoutModule->pagestyleCO->currentText());
+ for (size_t i = 0; i < pagestyles.size(); ++i)
+ if (pagestyles[i].second == style_gui)
+ params.pagestyle = pagestyles[i].first;
+ }
+
+ switch (textLayoutModule->lspacingCO->currentIndex()) {
+ case 0:
+ params.spacing().set(Spacing::Single);
+ break;
+ case 1:
+ params.spacing().set(Spacing::Onehalf);
+ break;
+ case 2:
+ params.spacing().set(Spacing::Double);
+ break;
+ case 3:
+ params.spacing().set(Spacing::Other,
+ fromqstr(textLayoutModule->lspacingLE->text()));
+ break;
+ }
+
+ if (textLayoutModule->twoColumnCB->isChecked())
+ params.columns = 2;
+ else
+ params.columns = 1;
+
+ // text should have passed validation
+ params.listings_params =
+ InsetListingsParams(fromqstr(textLayoutModule->listingsED->toPlainText())).params();
+
+ if (textLayoutModule->indentRB->isChecked())
+ params.paragraph_separation = BufferParams::PARSEP_INDENT;
+ else
+ params.paragraph_separation = BufferParams::PARSEP_SKIP;
+
+ switch (textLayoutModule->skipCO->currentIndex()) {
+ case 0:
+ params.setDefSkip(VSpace(VSpace::SMALLSKIP));
+ break;
+ case 1:
+ params.setDefSkip(VSpace(VSpace::MEDSKIP));
+ break;
+ case 2:
+ params.setDefSkip(VSpace(VSpace::BIGSKIP));
+ break;
+ case 3:
+ {
+ VSpace vs = VSpace(
+ widgetsToLength(textLayoutModule->skipLE,
+ textLayoutModule->skipLengthCO)
+ );
+ params.setDefSkip(vs);
+ break;
+ }
+ default:
+ // DocumentDefskipCB assures that this never happens
+ // so Assert then !!! - jbl
+ params.setDefSkip(VSpace(VSpace::MEDSKIP));
+ break;
+ }
+
+ params.options =
+ fromqstr(latexModule->optionsLE->text());
+
+ params.float_placement = floatModule->get();
+
+ // fonts
+ params.fontsRoman =
+ tex_fonts_roman[fontModule->fontsRomanCO->currentIndex()];
+
+ params.fontsSans =
+ tex_fonts_sans[fontModule->fontsSansCO->currentIndex()];
+
+ params.fontsTypewriter =
+ tex_fonts_monospaced[fontModule->fontsTypewriterCO->currentIndex()];
+
+ params.fontsSansScale = fontModule->scaleSansSB->value();
+
+ params.fontsTypewriterScale = fontModule->scaleTypewriterSB->value();
+
+ params.fontsSC = fontModule->fontScCB->isChecked();
+
+ params.fontsOSF = fontModule->fontOsfCB->isChecked();
+
+ params.fontsDefaultFamily = ControlDocument::fontfamilies[
+ fontModule->fontsDefaultCO->currentIndex()];
+
+ if (fontModule->fontsizeCO->currentIndex() == 0)
+ params.fontsize = "default";
+ else
+ params.fontsize =
+ fromqstr(fontModule->fontsizeCO->currentText());
+
+ // paper
+ params.papersize = PAPER_SIZE(
+ pageLayoutModule->papersizeCO->currentIndex());
+
+ // custom, A3, B3 and B4 paper sizes need geometry
+ int psize = pageLayoutModule->papersizeCO->currentIndex();
+ bool geom_papersize = (psize == 1 || psize == 5 || psize == 8 || psize == 9);
+
+ params.paperwidth = widgetsToLength(pageLayoutModule->paperwidthLE,
+ pageLayoutModule->paperwidthUnitCO);
+
+ params.paperheight = widgetsToLength(pageLayoutModule->paperheightLE,
+ pageLayoutModule->paperheightUnitCO);
+
+ if (pageLayoutModule->facingPagesCB->isChecked())
+ params.sides = TextClass::TwoSides;
+ else
+ params.sides = TextClass::OneSide;
+
+ if (pageLayoutModule->landscapeRB->isChecked())
+ params.orientation = ORIENTATION_LANDSCAPE;
+ else
+ params.orientation = ORIENTATION_PORTRAIT;
+
+ // margins
+ params.use_geometry =
+ (!marginsModule->marginCB->isChecked()
+ || geom_papersize);
+
+ Ui::MarginsUi const * m(marginsModule);
+
+ params.leftmargin = widgetsToLength(m->innerLE, m->innerUnit);
+
+ params.topmargin = widgetsToLength(m->topLE, m->topUnit);
+
+ params.rightmargin = widgetsToLength(m->outerLE, m->outerUnit);
+
+ params.bottommargin = widgetsToLength(m->bottomLE, m->bottomUnit);
+
+ params.headheight = widgetsToLength(m->headheightLE, m->headheightUnit);
+
+ params.headsep = widgetsToLength(m->headsepLE, m->headsepUnit);
+
+ params.footskip = widgetsToLength(m->footskipLE, m->footskipUnit);
+
+ branchesModule->apply(params);
+}
+
+namespace {
+
+/** Return the position of val in the vector if found.
+ If not found, return 0.
+ */
+template<class A>
+typename std::vector<A>::size_type
+findPos(std::vector<A> const & vec, A const & val)
+{
+ typename std::vector<A>::const_iterator it =
+ std::find(vec.begin(), vec.end(), val);
+ if (it == vec.end())
+ return 0;
+ return distance(vec.begin(), it);
+}
+
+} // namespace anom
+
+
+void GuiDocumentDialog::updateParams(BufferParams const & params)
+{
+ // set the default unit
+ // FIXME: move to controller
+ Length::UNIT defaultUnit = Length::CM;
+ switch (lyxrc.default_papersize) {
+ case PAPER_DEFAULT: break;
+
+ case PAPER_USLETTER:
+ case PAPER_USLEGAL:
+ case PAPER_USEXECUTIVE:
+ defaultUnit = Length::IN;
+ break;
+
+ case PAPER_A3:
+ case PAPER_A4:
+ case PAPER_A5:
+ case PAPER_B3:
+ case PAPER_B4:
+ case PAPER_B5:
+ defaultUnit = Length::CM;
+ break;
+ case PAPER_CUSTOM:
+ break;
+ }
+
+ // preamble
+ preambleModule->update(params, form_->controller().id());
+
+ // biblio
+ biblioModule->citeDefaultRB->setChecked(
+ params.getEngine() == biblio::ENGINE_BASIC);
+
+ biblioModule->citeNatbibRB->setChecked(
+ params.getEngine() == biblio::ENGINE_NATBIB_NUMERICAL ||
+ params.getEngine() == biblio::ENGINE_NATBIB_AUTHORYEAR);
+
+ biblioModule->citeStyleCO->setCurrentIndex(
+ params.getEngine() == biblio::ENGINE_NATBIB_NUMERICAL);
+
+ biblioModule->citeJurabibRB->setChecked(
+ params.getEngine() == biblio::ENGINE_JURABIB);
+
+ biblioModule->bibtopicCB->setChecked(
+ params.use_bibtopic);
+
+ // language & quotes
+ int const pos = int(findPos(lang_,
+ params.language->lang()));
+ langModule->languageCO->setCurrentIndex(pos);
+
+ langModule->quoteStyleCO->setCurrentIndex(
+ params.quotes_language);
+
+ langModule->defaultencodingCB->setChecked(true);
+
+ if (params.inputenc != "auto") {
+ langModule->defaultencodingCB->setChecked(false);
+ if (params.inputenc == "default") {
+ langModule->encodingCO->setCurrentIndex(0);
+ } else {
+ int const i = langModule->encodingCO->findText(
+ toqstr(params.inputenc));
+ if (i >= 0)
+ langModule->encodingCO->setCurrentIndex(i);
+ else
+ // unknown encoding. Set to default.
+ langModule->defaultencodingCB->setChecked(true);
+ }
+ }
+
+ // numbering
+ int const min_toclevel = form_->controller().textClass().min_toclevel();
+ int const max_toclevel = form_->controller().textClass().max_toclevel();
+ if (form_->controller().textClass().hasTocLevels()) {
+ numberingModule->setEnabled(true);
+ numberingModule->depthSL->setMinimum(min_toclevel - 1);
+ numberingModule->depthSL->setMaximum(max_toclevel);
+ numberingModule->depthSL->setValue(params.secnumdepth);
+ numberingModule->tocSL->setMaximum(min_toclevel - 1);
+ numberingModule->tocSL->setMaximum(max_toclevel);
+ numberingModule->tocSL->setValue(params.tocdepth);
+ updateNumbering();
+ } else {
+ numberingModule->setEnabled(false);
+ numberingModule->tocTW->clear();
+ }
+
+ // bullets
+ bulletsModule->setBullet(0, params.user_defined_bullet(0));
+ bulletsModule->setBullet(1, params.user_defined_bullet(1));
+ bulletsModule->setBullet(2, params.user_defined_bullet(2));
+ bulletsModule->setBullet(3, params.user_defined_bullet(3));
+ bulletsModule->init();
+
+ // packages
+ int nitem = findToken(tex_graphics, params.graphicsDriver);
+ if (nitem >= 0)
+ latexModule->psdriverCO->setCurrentIndex(nitem);
+
+ mathsModule->amsCB->setChecked(
+ params.use_amsmath == BufferParams::package_on);
+ mathsModule->amsautoCB->setChecked(
+ params.use_amsmath == BufferParams::package_auto);
+
+ mathsModule->esintCB->setChecked(
+ params.use_esint == BufferParams::package_on);
+ mathsModule->esintautoCB->setChecked(
+ params.use_esint == BufferParams::package_auto);
+
+ switch (params.spacing().getSpace()) {
+ 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
+ latexModule->classCO->setCurrentIndex(params.getBaseClass());
+
+ updatePagestyle(form_->controller().textClass().opt_pagestyle(),
+ params.pagestyle);
+
+ textLayoutModule->lspacingCO->setCurrentIndex(nitem);
+ if (params.spacing().getSpace() == Spacing::Other) {
+ textLayoutModule->lspacingLE->setText(
+ toqstr(params.spacing().getValueAsString()));
+ }
+ setLSpacing(nitem);
+
+ if (params.paragraph_separation
+ == BufferParams::PARSEP_INDENT) {
+ textLayoutModule->indentRB->setChecked(true);
+ } else {
+ textLayoutModule->skipRB->setChecked(true);
+ }
+
+ int skip = 0;
+ switch (params.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 = params.getDefSkip().asLyXCommand();
+ lengthToWidgets(textLayoutModule->skipLE,
+ textLayoutModule->skipLengthCO,
+ length, defaultUnit);
+ break;
+ }
+ default:
+ skip = 0;
+ break;
+ }
+ textLayoutModule->skipCO->setCurrentIndex(skip);
+ setSkip(skip);
+
+ textLayoutModule->twoColumnCB->setChecked(
+ params.columns == 2);
+
+ // break listings_params to multiple lines
+ string lstparams =
+ InsetListingsParams(params.listings_params).separatedParams();
+ textLayoutModule->listingsED->setPlainText(toqstr(lstparams));
+
+ if (!params.options.empty()) {
+ latexModule->optionsLE->setText(
+ toqstr(params.options));
+ } else {
+ latexModule->optionsLE->setText("");
+ }
+
+ floatModule->set(params.float_placement);
+
+ //fonts
+ updateFontsize(form_->controller().textClass().opt_fontsize(),
+ params.fontsize);
+
+ int n = findToken(tex_fonts_roman, params.fontsRoman);
+ if (n >= 0) {
+ fontModule->fontsRomanCO->setCurrentIndex(n);
+ romanChanged(n);
+ }
+
+ n = findToken(tex_fonts_sans, params.fontsSans);
+ if (n >= 0) {
+ fontModule->fontsSansCO->setCurrentIndex(n);
+ sansChanged(n);
+ }
+
+ n = findToken(tex_fonts_monospaced, params.fontsTypewriter);
+ if (n >= 0) {
+ fontModule->fontsTypewriterCO->setCurrentIndex(n);
+ ttChanged(n);
+ }
+
+ fontModule->fontScCB->setChecked(params.fontsSC);
+ fontModule->fontOsfCB->setChecked(params.fontsOSF);
+ fontModule->scaleSansSB->setValue(params.fontsSansScale);
+ fontModule->scaleTypewriterSB->setValue(params.fontsTypewriterScale);
+ n = findToken(ControlDocument::fontfamilies, params.fontsDefaultFamily);
+ if (n >= 0)
+ fontModule->fontsDefaultCO->setCurrentIndex(n);
+
+ // paper
+ int const psize = params.papersize;
+ pageLayoutModule->papersizeCO->setCurrentIndex(psize);
+ setCustomPapersize(psize);
+
+ bool const landscape =
+ params.orientation == ORIENTATION_LANDSCAPE;
+ pageLayoutModule->landscapeRB->setChecked(landscape);
+ pageLayoutModule->portraitRB->setChecked(!landscape);
+
+ pageLayoutModule->facingPagesCB->setChecked(
+ params.sides == TextClass::TwoSides);
+
+
+ lengthToWidgets(pageLayoutModule->paperwidthLE,
+ pageLayoutModule->paperwidthUnitCO, params.paperwidth, defaultUnit);
+
+ lengthToWidgets(pageLayoutModule->paperheightLE,
+ pageLayoutModule->paperheightUnitCO, params.paperheight, defaultUnit);
+
+ // margins
+ Ui::MarginsUi * m = marginsModule;
+
+ setMargins(!params.use_geometry);
+
+ lengthToWidgets(m->topLE, m->topUnit,
+ params.topmargin, defaultUnit);
+
+ lengthToWidgets(m->bottomLE, m->bottomUnit,
+ params.bottommargin, defaultUnit);
+
+ lengthToWidgets(m->innerLE, m->innerUnit,
+ params.leftmargin, defaultUnit);
+
+ lengthToWidgets(m->outerLE, m->outerUnit,
+ params.rightmargin, defaultUnit);
+
+ lengthToWidgets(m->headheightLE, m->headheightUnit,
+ params.headheight, defaultUnit);
+
+ lengthToWidgets(m->headsepLE, m->headsepUnit,
+ params.headsep, defaultUnit);
+
+ lengthToWidgets(m->footskipLE, m->footskipUnit,
+ params.footskip, defaultUnit);
+
+ branchesModule->update(params);
+}
+
+
+/////////////////////////////////////////////////////////////////////
+//
+// Document
+//
+/////////////////////////////////////////////////////////////////////
+
+typedef QController<ControlDocument, GuiView<GuiDocumentDialog> >
+ DocumentBase;
+
+
+GuiDocument::GuiDocument(Dialog & parent)
+ : DocumentBase(parent, _("Document Settings"))
+{}
+
+
+void GuiDocument::build_dialog()
+{
+ dialog_.reset(new GuiDocumentDialog(this));
+}
+
+
+void GuiDocument::showPreamble()
+{
+ dialog_->showPreamble();
+}
+
+
+void GuiDocument::apply()
+{
+ if (!dialog_.get())
+ return;
+
+ dialog_->apply(controller().params());
+}
+
+
+void GuiDocument::update_contents()
+{
+ if (!dialog_.get())
+ return;
+
+ dialog_->updateParams(controller().params());
+}
+
+void GuiDocument::saveDocDefault()
+{
+ // we have to apply the params first
+ apply();
+ controller().saveAsDefault();
+}
+
+
+void GuiDocument::useClassDefaults()
+{
+ BufferParams & params = controller().params();
+
+ params.setJustBaseClass(dialog_->latexModule->classCO->currentIndex());
+
+ params.useClassDefaults();
+ update_contents();
+}
+
+
+bool GuiDocument::isValid()
+{
+ return dialog_->validate_listings_params().empty();
+}
+
+
+} // namespace frontend
+} // namespace lyx
+
+#include "GuiDocument_moc.cpp"
--- /dev/null
+// -*- C++ -*-
+/**
+ * \file GuiDocument.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Edwin Leuven
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#ifndef QDOCUMENT_H
+#define QDOCUMENT_H
+
+#include "GuiDialogView.h"
+#include "BulletsModule.h"
+
+#include "ui_DocumentUi.h"
+#include "ui_FontUi.h"
+#include "ui_TextLayoutUi.h"
+#include "ui_MathsUi.h"
+#include "ui_LaTeXUi.h"
+#include "ui_PageLayoutUi.h"
+#include "ui_LanguageUi.h"
+#include "ui_BiblioUi.h"
+#include "ui_NumberingUi.h"
+#include "ui_MarginsUi.h"
+
+// For the Preamble module
+#include "ui_PreambleUi.h"
+
+#include <QCloseEvent>
+#include <QDialog>
+
+#include <vector>
+#include <string>
+
+class FloatPlacement;
+
+template<class UI>
+class UiWidget: public QWidget, public UI
+{
+public:
+ UiWidget(QWidget * parent = 0) : QWidget(parent)
+ {
+ UI::setupUi(this);
+ }
+};
+
+namespace lyx {
+namespace frontend {
+
+class GuiBranches;
+class GuiDocument;
+class PreambleModule;
+
+class GuiDocumentDialog : public QDialog, public Ui::DocumentUi {
+ Q_OBJECT
+public:
+ friend class GuiDocument;
+
+ GuiDocumentDialog(GuiDocument *);
+
+ void updateParams(BufferParams const & params);
+ void apply(BufferParams & params);
+
+ void updateFontsize(std::string const &, std::string const &);
+ void updatePagestyle(std::string const &, std::string const &);
+
+ void showPreamble();
+ /// validate listings parameters and return an error message, if any
+ docstring validate_listings_params();
+
+public Q_SLOTS:
+ void updateNumbering();
+ void change_adaptor();
+ void set_listings_msg();
+ void saveDefaultClicked();
+ void useDefaultsClicked();
+
+protected Q_SLOTS:
+ void setLSpacing(int);
+ void setMargins(bool);
+ void setCustomPapersize(int);
+ void setCustomMargins(bool);
+ void romanChanged(int);
+ void sansChanged(int);
+ void ttChanged(int);
+ void setSkip(int);
+ void enableSkip(bool);
+ void portraitChanged();
+ void classChanged();
+
+protected:
+ void closeEvent(QCloseEvent * e);
+
+private:
+
+ UiWidget<Ui::TextLayoutUi> *textLayoutModule;
+ UiWidget<Ui::FontUi> *fontModule;
+ UiWidget<Ui::PageLayoutUi> *pageLayoutModule;
+ UiWidget<Ui::MarginsUi> *marginsModule;
+ UiWidget<Ui::LanguageUi> *langModule;
+ UiWidget<Ui::NumberingUi> *numberingModule;
+ UiWidget<Ui::BiblioUi> *biblioModule;
+ UiWidget<Ui::MathsUi> *mathsModule;
+ UiWidget<Ui::LaTeXUi> *latexModule;
+ PreambleModule *preambleModule;
+
+ GuiBranches *branchesModule;
+
+ BulletsModule * bulletsModule;
+ FloatPlacement * floatModule;
+
+ GuiDocument * form_;
+
+ /// FIXME
+ std::vector<std::string> lang_;
+};
+
+
+class ControlDocument;
+
+class GuiDocument
+ : public QController<ControlDocument, GuiView<GuiDocumentDialog> >
+{
+public:
+
+ friend class GuiDocumentDialog;
+
+ GuiDocument(Dialog &);
+
+ void showPreamble();
+
+private:
+ /// Apply changes
+ void apply();
+ /// update
+ void update_contents();
+ /// build the dialog
+ void build_dialog();
+ /// save as default template
+ void saveDocDefault();
+ /// reset to default params
+ void useClassDefaults();
+protected:
+ /// return false if validate_listings_params returns error
+ virtual bool isValid();
+};
+
+
+typedef void const * BufferId;
+
+
+class PreambleModule : public UiWidget<Ui::PreambleUi>
+{
+ Q_OBJECT
+public:
+ PreambleModule();
+ void update(BufferParams const & params, BufferId id);
+ void apply(BufferParams & params);
+
+Q_SIGNALS:
+ /// signal that something's changed in the Widget.
+ void changed();
+
+protected:
+ void closeEvent(QCloseEvent *);
+ void on_preambleTE_textChanged() { changed(); }
+
+private:
+ typedef std::map<BufferId, std::pair<int,int> > Coords;
+ Coords preamble_coords_;
+ BufferId current_id_;
+};
+
+
+
+} // namespace frontend
+} // namespace lyx
+
+#endif // QDOCUMENT_H
--- /dev/null
+/**
+ * \file GuiERT.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author John Levon
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "GuiERT.h"
+#include "Qt2BC.h"
+
+#include "controllers/ControlERT.h"
+
+#include <QRadioButton>
+#include <QPushButton>
+#include <QCloseEvent>
+
+
+namespace lyx {
+namespace frontend {
+
+/////////////////////////////////////////////////////////////////////
+//
+// GuiERTDialog
+//
+/////////////////////////////////////////////////////////////////////
+
+
+GuiERTDialog::GuiERTDialog(GuiERT * form)
+ : form_(form)
+{
+ setupUi(this);
+ connect(okPB, SIGNAL(clicked()), form, SLOT(slotOK()));
+ connect(closePB, SIGNAL(clicked()), form, SLOT(slotClose()));
+ connect(collapsedRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
+ connect(openRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
+}
+
+
+void GuiERTDialog::closeEvent(QCloseEvent * e)
+{
+ form_->slotWMHide();
+ e->accept();
+}
+
+
+void GuiERTDialog::change_adaptor()
+{
+ form_->changed();
+}
+
+
+/////////////////////////////////////////////////////////////////////
+//
+// GuiERT
+//
+/////////////////////////////////////////////////////////////////////
+
+typedef QController<ControlERT, GuiView<GuiERTDialog> > ERTBase;
+
+
+GuiERT::GuiERT(Dialog & parent)
+ : ERTBase(parent, _("TeX Code Settings"))
+{
+}
+
+
+void GuiERT::build_dialog()
+{
+ dialog_.reset(new GuiERTDialog(this));
+
+ bcview().setOK(dialog_->okPB);
+ bcview().setCancel(dialog_->closePB);
+}
+
+
+void GuiERT::apply()
+{
+ if (dialog_->openRB->isChecked())
+ controller().setStatus(Inset::Open);
+ else
+ controller().setStatus(Inset::Collapsed);
+}
+
+
+void GuiERT::update_contents()
+{
+ QRadioButton * rb = 0;
+
+ switch (controller().status()) {
+ case InsetERT::Open: rb = dialog_->openRB; break;
+ case InsetERT::Collapsed: rb = dialog_->collapsedRB; break;
+ }
+
+ rb->setChecked(true);
+}
+
+} // namespace frontend
+} // namespace lyx
+
+#include "GuiERT_moc.cpp"
--- /dev/null
+// -*- C++ -*-
+/**
+ * \file GuiERT.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author John Levon
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#ifndef GuiERT_H
+#define GuiERT_H
+
+#include "GuiDialogView.h"
+#include "ui_ERTUi.h"
+
+#include <QCloseEvent>
+#include <QDialog>
+
+namespace lyx {
+namespace frontend {
+
+class GuiERT;
+
+class GuiERTDialog : public QDialog, public Ui::ERTUi {
+ Q_OBJECT
+public:
+ GuiERTDialog(GuiERT * form);
+protected Q_SLOTS:
+ virtual void change_adaptor();
+protected:
+ virtual void closeEvent(QCloseEvent * e);
+private:
+ GuiERT * form_;
+};
+
+
+
+class ControlERT;
+
+class GuiERT : public QController<ControlERT, GuiView<GuiERTDialog> >
+{
+public:
+ friend class GuiERTDialog;
+
+ GuiERT(Dialog &);
+private:
+ /// Apply changes
+ virtual void apply();
+ /// update
+ virtual void update_contents();
+ /// build the dialog
+ virtual void build_dialog();
+};
+
+} // namespace frontend
+} // namespace lyx
+
+#endif // GuiERT_H
--- /dev/null
+/**
+ * \file GuiErrorList.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Alfredo Braunstein
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "GuiErrorList.h"
+#include "Qt2BC.h"
+#include "qt_helpers.h"
+
+#include "controllers/ControlErrorList.h"
+
+#include <QListWidget>
+#include <QTextBrowser>
+#include <QPushButton>
+#include <QCloseEvent>
+
+namespace lyx {
+namespace frontend {
+
+/////////////////////////////////////////////////////////////////////
+//
+// GuiErrorListDialog
+//
+/////////////////////////////////////////////////////////////////////
+
+GuiErrorListDialog::GuiErrorListDialog(GuiErrorList * form)
+ : form_(form)
+{
+ setupUi(this);
+ connect(closePB, SIGNAL(clicked()),
+ form, SLOT(slotClose()));
+ connect(errorsLW, SIGNAL( itemActivated(QListWidgetItem *)),
+ form, SLOT(slotClose()));
+ connect( errorsLW, SIGNAL( itemClicked(QListWidgetItem *)),
+ this, SLOT(select_adaptor(QListWidgetItem *)));
+}
+
+
+void GuiErrorListDialog::select_adaptor(QListWidgetItem * item)
+{
+ form_->select(item);
+}
+
+
+void GuiErrorListDialog::closeEvent(QCloseEvent * e)
+{
+ form_->slotWMHide();
+ e->accept();
+}
+
+
+void GuiErrorListDialog::showEvent(QShowEvent *e)
+{
+ errorsLW->setCurrentRow(0);
+ form_->select(errorsLW->item(0));
+ e->accept();
+}
+
+
+/////////////////////////////////////////////////////////////////////
+//
+// GuiErrorList
+//
+/////////////////////////////////////////////////////////////////////
+
+
+typedef QController<ControlErrorList, GuiView<GuiErrorListDialog> >
+ ErrorListBase;
+
+GuiErrorList::GuiErrorList(Dialog & parent)
+ : ErrorListBase(parent, docstring())
+{}
+
+
+void GuiErrorList::build_dialog()
+{
+ dialog_.reset(new GuiErrorListDialog(this));
+ bcview().setCancel(dialog_->closePB);
+}
+
+
+void GuiErrorList::select(QListWidgetItem * wi)
+{
+ int const item = dialog_->errorsLW->row(wi);
+ controller().goTo(item);
+ dialog_->descriptionTB->setPlainText(toqstr(controller().errorList()[item].description));
+}
+
+
+void GuiErrorList::update_contents()
+{
+ setTitle(from_utf8(controller().name()));
+ dialog_->errorsLW->clear();
+ dialog_->descriptionTB->setPlainText(QString());
+
+ ErrorList::const_iterator it = controller().errorList().begin();
+ ErrorList::const_iterator end = controller().errorList().end();
+ for(; it != end; ++it) {
+ dialog_->errorsLW->addItem(toqstr(it->error));
+ }
+}
+
+} // namespace frontend
+} // namespace lyx
+
+
+#include "GuiErrorList_moc.cpp"
--- /dev/null
+// -*- C++ -*-
+/**
+ * \file GuiErrorList.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Alfredo Braunstein
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#ifndef QERRORLIST_H
+#define QERRORLIST_H
+
+#include "GuiDialogView.h"
+#include "ui_ErrorListUi.h"
+
+#include <QDialog>
+
+class QListWidgetItem;
+class QCloseEvent;
+class QShowEvent;
+
+namespace lyx {
+namespace frontend {
+
+class GuiErrorList;
+
+class GuiErrorListDialog : public QDialog, public Ui::ErrorListUi {
+ Q_OBJECT
+public:
+ GuiErrorListDialog(GuiErrorList * form);
+
+public Q_SLOTS:
+ void select_adaptor(QListWidgetItem *);
+protected:
+ void closeEvent(QCloseEvent *);
+ void showEvent(QShowEvent *);
+private:
+ GuiErrorList * form_;
+};
+
+
+class ControlErrorList;
+
+class GuiErrorList :
+ public QController<ControlErrorList, GuiView<GuiErrorListDialog> >
+{
+public:
+ friend class GuiErrorListDialog;
+
+ GuiErrorList(Dialog &);
+private:
+ /// select an entry
+ void select(QListWidgetItem *);
+ /// required apply
+ virtual void apply() {}
+ /// build dialog
+ virtual void build_dialog();
+ /// update contents
+ virtual void update_contents();
+};
+
+} // namespace frontend
+} // namespace lyx
+
+#endif // QERRORLIST_H
--- /dev/null
+/**
+ * \file GuiExternal.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author John Levon
+ * \author Angus Leeming
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+// Qt defines a macro 'signals' that clashes with a boost namespace.
+// All is well if the namespace is visible first.
+#include "lengthcommon.h"
+#include "LyXRC.h"
+
+#include "controllers/ControlExternal.h"
+#include "controllers/ButtonController.h"
+
+#include "insets/ExternalTemplate.h"
+#include "insets/InsetExternal.h"
+
+#include "support/lstrings.h"
+#include "support/convert.h"
+#include "support/os.h"
+#include "support/lyxlib.h"
+
+#include "GuiExternal.h"
+#include "Qt2BC.h"
+
+#include "CheckedLineEdit.h"
+#include "LengthCombo.h"
+#include "qt_helpers.h"
+#include "Validator.h"
+
+#include <QLineEdit>
+#include <QPushButton>
+#include <QCheckBox>
+#include <QTabWidget>
+#include <QTextBrowser>
+
+namespace external = lyx::external;
+
+using lyx::support::isStrDbl;
+using lyx::support::token;
+using lyx::support::trim;
+using lyx::support::float_equal;
+
+using lyx::support::os::internal_path;
+
+using std::string;
+using std::vector;
+using std::find;
+
+
+namespace lyx {
+namespace frontend {
+
+/////////////////////////////////////////////////////////////////////
+//
+// GuiExternalDialog
+//
+/////////////////////////////////////////////////////////////////////
+
+
+GuiExternalDialog::GuiExternalDialog(GuiExternal * form)
+ : form_(form)
+{
+ setupUi(this);
+ connect(okPB, SIGNAL(clicked()), form, SLOT(slotOK()));
+ connect(applyPB, SIGNAL(clicked()), form, SLOT(slotApply()));
+ connect(closePB, SIGNAL(clicked()), form, SLOT(slotClose()));
+
+ connect(displayCB, SIGNAL(toggled(bool)),
+ showCO, SLOT(setEnabled(bool)));
+ connect(displayCB, SIGNAL(toggled(bool)),
+ displayscaleED, SLOT(setEnabled(bool)));
+ connect(showCO, SIGNAL(activated(const QString&)),
+ this, SLOT(change_adaptor()));
+ connect(originCO, SIGNAL(activated(int)),
+ this, SLOT(change_adaptor()));
+ connect(aspectratioCB, SIGNAL(stateChanged(int)),
+ this, SLOT(change_adaptor()));
+ connect(browsePB, SIGNAL(clicked()),
+ this, SLOT(browseClicked()));
+ connect(editPB, SIGNAL(clicked()),
+ this, SLOT(editClicked()));
+ connect(externalCO, SIGNAL(activated(const QString &)),
+ this, SLOT(templateChanged()));
+ connect(extraED, SIGNAL(textChanged(const QString &)),
+ this, SLOT(extraChanged(const QString&)));
+ connect(extraFormatCO, SIGNAL(activated(const QString &)),
+ this, SLOT(formatChanged(const QString&)));
+ connect(widthUnitCO, SIGNAL(activated(int)),
+ this, SLOT(widthUnitChanged()));
+ connect(heightUnitCO, SIGNAL(selectionChanged(lyx::Length::UNIT)),
+ this, SLOT(change_adaptor()));
+ connect(displayCB, SIGNAL(stateChanged(int)),
+ this, SLOT(change_adaptor()));
+ connect(displayscaleED, SIGNAL(textChanged(const QString &)),
+ this, SLOT(change_adaptor()));
+ connect(angleED, SIGNAL(textChanged(const QString &)),
+ this, SLOT(change_adaptor()));
+ connect(widthED, SIGNAL(textChanged(const QString &)),
+ this, SLOT(sizeChanged()));
+ connect(heightED, SIGNAL(textChanged(const QString &)),
+ this, SLOT(sizeChanged()));
+ connect(fileED, SIGNAL(textChanged(const QString &)),
+ this, SLOT(change_adaptor()));
+ connect(clipCB, SIGNAL(stateChanged(int)),
+ this, SLOT(change_adaptor()));
+ connect(getbbPB, SIGNAL(clicked()), this, SLOT(getbbClicked()));
+ connect(xrED, SIGNAL(textChanged(const QString &)), this, SLOT(bbChanged()));
+ connect(ytED, SIGNAL(textChanged(const QString &)), this, SLOT(bbChanged()));
+ connect(xlED, SIGNAL(textChanged(const QString &)), this, SLOT(bbChanged()));
+ connect(ybED, SIGNAL(textChanged(const QString &)), this, SLOT(bbChanged()));
+ connect(draftCB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
+
+ QIntValidator * validator = new QIntValidator(displayscaleED);
+ validator->setBottom(1);
+ displayscaleED->setValidator(validator);
+
+ angleED->setValidator(new QDoubleValidator(-360, 360, 2, angleED));
+
+ xlED->setValidator(new QIntValidator(xlED));
+ ybED->setValidator(new QIntValidator(ybED));
+ xrED->setValidator(new QIntValidator(xrED));
+ ytED->setValidator(new QIntValidator(ytED));
+
+ widthED->setValidator(unsignedLengthValidator(widthED));
+ heightED->setValidator(unsignedLengthValidator(heightED));
+
+ setFocusProxy(fileED);
+}
+
+
+void GuiExternalDialog::show()
+{
+ QDialog::show();
+}
+
+
+
+bool GuiExternalDialog::activateAspectratio() const
+{
+ if (widthUnitCO->currentIndex() == 0)
+ return false;
+
+ string const wstr = fromqstr(widthED->text());
+ if (wstr.empty())
+ return false;
+ bool const wIsDbl = isStrDbl(wstr);
+ if (wIsDbl && float_equal(convert<double>(wstr), 0.0, 0.05))
+ return false;
+ Length l;
+ if (!wIsDbl && (!isValidLength(wstr, &l) || l.zero()))
+ return false;
+
+ string const hstr = fromqstr(heightED->text());
+ if (hstr.empty())
+ return false;
+ bool const hIsDbl = isStrDbl(hstr);
+ if (hIsDbl && float_equal(convert<double>(hstr), 0.0, 0.05))
+ return false;
+ if (!hIsDbl && (!isValidLength(hstr, &l) || l.zero()))
+ return false;
+
+ return true;
+}
+
+
+void GuiExternalDialog::bbChanged()
+{
+ form_->controller().bbChanged(true);
+ form_->changed();
+}
+
+
+void GuiExternalDialog::browseClicked()
+{
+ int const choice = externalCO->currentIndex();
+ docstring const template_name =
+ from_utf8(form_->controller().getTemplate(choice).lyxName);
+ docstring const str =
+ form_->controller().browse(qstring_to_ucs4(fileED->text()),
+ template_name);
+ if(!str.empty()) {
+ fileED->setText(toqstr(str));
+ form_->changed();
+ }
+}
+
+
+void GuiExternalDialog::change_adaptor()
+{
+ form_->changed();
+}
+
+
+void GuiExternalDialog::closeEvent(QCloseEvent * e)
+{
+ form_->slotWMHide();
+ e->accept();
+}
+
+
+void GuiExternalDialog::editClicked()
+{
+ form_->controller().editExternal();
+}
+
+
+
+void GuiExternalDialog::extraChanged(const QString& text)
+{
+ std::string const format = fromqstr(extraFormatCO->currentText());
+ form_->extra_[format] = text;
+ form_->changed();
+}
+
+
+void GuiExternalDialog::formatChanged(const QString& format)
+{
+ extraED->setText(form_->extra_[fromqstr(format)]);
+}
+
+
+void GuiExternalDialog::getbbClicked()
+{
+ form_->getBB();
+}
+
+
+void GuiExternalDialog::sizeChanged()
+{
+ aspectratioCB->setEnabled(activateAspectratio());
+ form_->changed();
+}
+
+
+void GuiExternalDialog::templateChanged()
+{
+ form_->updateTemplate();
+ form_->changed();
+}
+
+
+void GuiExternalDialog::widthUnitChanged()
+{
+ bool useHeight = (widthUnitCO->currentIndex() > 0);
+
+ if (useHeight)
+ widthED->setValidator(unsignedLengthValidator(widthED));
+ else
+ widthED->setValidator(new QDoubleValidator(0, 1000, 2, widthED));
+
+ heightED->setEnabled(useHeight);
+ heightUnitCO->setEnabled(useHeight);
+ form_->changed();
+}
+
+
+/////////////////////////////////////////////////////////////////////
+//
+// GuiExternal
+//
+/////////////////////////////////////////////////////////////////////
+
+namespace {
+
+Length::UNIT defaultUnit()
+{
+ Length::UNIT default_unit = Length::CM;
+ switch (lyxrc.default_papersize) {
+ case PAPER_USLETTER:
+ case PAPER_USLEGAL:
+ case PAPER_USEXECUTIVE:
+ default_unit = Length::IN;
+ break;
+ default:
+ break;
+ }
+ return default_unit;
+}
+
+
+void setDisplay(QCheckBox & displayCB, QComboBox & showCO, QLineEdit & scaleED,
+ external::DisplayType display, unsigned int scale,
+ bool read_only)
+{
+ int item = 0;
+ switch (display) {
+ case external::DefaultDisplay:
+ item = 0;
+ break;
+ case external::MonochromeDisplay:
+ item = 1;
+ break;
+ case external::GrayscaleDisplay:
+ item = 2;
+ break;
+ case external::ColorDisplay:
+ item = 3;
+ break;
+ case external::PreviewDisplay:
+ item = 4;
+ break;
+ case external::NoDisplay:
+ item = 0;
+ break;
+ }
+
+ showCO.setCurrentIndex(item);
+ bool const no_display = display == external::NoDisplay;
+ showCO.setEnabled(!no_display && !read_only);
+ displayCB.setChecked(!no_display);
+ scaleED.setEnabled(!no_display && !read_only);
+ scaleED.setText(toqstr(convert<string>(scale)));
+}
+
+
+void getDisplay(external::DisplayType & display,
+ unsigned int & scale,
+ QCheckBox const & displayCB,
+ QComboBox const & showCO,
+ QLineEdit const & scaleED)
+{
+ switch (showCO.currentIndex()) {
+ case 0:
+ display = external::DefaultDisplay;
+ break;
+ case 1:
+ display = external::MonochromeDisplay;
+ break;
+ case 2:
+ display = external::GrayscaleDisplay;
+ break;
+ case 3:
+ display = external::ColorDisplay;
+ break;
+ case 4:
+ display = external::PreviewDisplay;
+ break;
+ }
+
+ if (!displayCB.isChecked())
+ display = external::NoDisplay;
+
+ scale = convert<int>(fromqstr(scaleED.text()));
+}
+
+
+void setRotation(QLineEdit & angleED, QComboBox & originCO,
+ external::RotationData const & data)
+{
+ originCO.setCurrentIndex(int(data.origin()));
+ angleED.setText(toqstr(data.angle));
+}
+
+
+void getRotation(external::RotationData & data,
+ QLineEdit const & angleED, QComboBox const & originCO)
+{
+ typedef external::RotationData::OriginType OriginType;
+
+ data.origin(static_cast<OriginType>(originCO.currentIndex()));
+ data.angle = fromqstr(angleED.text());
+}
+
+
+void setSize(QLineEdit & widthED, QComboBox & widthUnitCO,
+ QLineEdit & heightED, LengthCombo & heightUnitCO,
+ QCheckBox & aspectratioCB,
+ external::ResizeData const & data)
+{
+ bool using_scale = data.usingScale();
+ std::string scale = data.scale;
+ if (data.no_resize()) {
+ // Everything is zero, so default to this!
+ using_scale = true;
+ scale = "100";
+ }
+
+ if (using_scale) {
+ widthED.setText(toqstr(scale));
+ widthUnitCO.setCurrentIndex(0);
+ } else {
+ widthED.setText(toqstr(convert<string>(data.width.value())));
+ // Because 'Scale' is position 0...
+ // Note also that width cannot be zero here, so
+ // we don't need to worry about the default unit.
+ widthUnitCO.setCurrentIndex(data.width.unit() + 1);
+ }
+
+ string const h = data.height.zero() ? string() : data.height.asString();
+ Length::UNIT default_unit = data.width.zero() ?
+ defaultUnit() : data.width.unit();
+ lengthToWidgets(&heightED, &heightUnitCO, h, default_unit);
+
+ heightED.setEnabled(!using_scale);
+ heightUnitCO.setEnabled(!using_scale);
+
+ aspectratioCB.setChecked(data.keepAspectRatio);
+
+ bool const disable_aspectRatio = using_scale ||
+ data.width.zero() || data.height.zero();
+ aspectratioCB.setEnabled(!disable_aspectRatio);
+}
+
+
+void getSize(external::ResizeData & data,
+ QLineEdit const & widthED, QComboBox const & widthUnitCO,
+ QLineEdit const & heightED, LengthCombo const & heightUnitCO,
+ QCheckBox const & aspectratioCB)
+{
+ string const width = fromqstr(widthED.text());
+
+ if (widthUnitCO.currentIndex() > 0) {
+ // Subtract one, because scale is 0.
+ int const unit = widthUnitCO.currentIndex() - 1;
+
+ Length w;
+ if (isValidLength(width, &w))
+ data.width = w;
+ else if (isStrDbl(width))
+ data.width = Length(convert<double>(width),
+ static_cast<Length::UNIT>(unit));
+ else
+ data.width = Length();
+
+ data.scale = string();
+
+ } else {
+ // scaling instead of a width
+ data.scale = width;
+ data.width = Length();
+ }
+
+ data.height = Length(widgetsToLength(&heightED, &heightUnitCO));
+
+ data.keepAspectRatio = aspectratioCB.isChecked();
+}
+
+
+void setCrop(QCheckBox & clipCB,
+ QLineEdit & xlED, QLineEdit & ybED,
+ QLineEdit & xrED, QLineEdit & ytED,
+ external::ClipData const & data)
+{
+ clipCB.setChecked(data.clip);
+ graphics::BoundingBox const & bbox = data.bbox;
+ xlED.setText(toqstr(convert<string>(bbox.xl)));
+ ybED.setText(toqstr(convert<string>(bbox.yb)));
+ xrED.setText(toqstr(convert<string>(bbox.xr)));
+ ytED.setText(toqstr(convert<string>(bbox.yt)));
+}
+
+
+void getCrop(external::ClipData & data,
+ QCheckBox const & clipCB,
+ QLineEdit const & xlED, QLineEdit const & ybED,
+ QLineEdit const & xrED, QLineEdit const & ytED,
+ bool bb_changed)
+{
+ data.clip = clipCB.isChecked();
+
+ if (!bb_changed)
+ return;
+
+ data.bbox.xl = convert<int>(fromqstr(xlED.text()));
+ data.bbox.yb = convert<int>(fromqstr(ybED.text()));
+ data.bbox.xr = convert<int>(fromqstr(xrED.text()));
+ data.bbox.yt = convert<int>(fromqstr(ytED.text()));
+}
+
+
+void getExtra(external::ExtraData & data,
+ GuiExternal::MapType const & extra)
+{
+ typedef GuiExternal::MapType MapType;
+ MapType::const_iterator it = extra.begin();
+ MapType::const_iterator const end = extra.end();
+ for (; it != end; ++it)
+ data.set(it->first, trim(fromqstr(it->second)));
+}
+
+} // namespace anon
+
+
+typedef QController<ControlExternal, GuiView<GuiExternalDialog> >
+ ExternalBase;
+
+GuiExternal::GuiExternal(Dialog & parent)
+ : ExternalBase(parent, _("External Material"))
+{}
+
+
+void GuiExternal::build_dialog()
+{
+ dialog_.reset(new GuiExternalDialog(this));
+
+ bcview().setOK(dialog_->okPB);
+ bcview().setApply(dialog_->applyPB);
+ bcview().setCancel(dialog_->closePB);
+
+ bcview().addReadOnly(dialog_->fileED);
+ bcview().addReadOnly(dialog_->browsePB);
+ bcview().addReadOnly(dialog_->editPB);
+ bcview().addReadOnly(dialog_->externalCO);
+ bcview().addReadOnly(dialog_->draftCB);
+ bcview().addReadOnly(dialog_->displayscaleED);
+ bcview().addReadOnly(dialog_->showCO);
+ bcview().addReadOnly(dialog_->displayCB);
+ bcview().addReadOnly(dialog_->angleED);
+ bcview().addReadOnly(dialog_->originCO);
+ bcview().addReadOnly(dialog_->heightUnitCO);
+ bcview().addReadOnly(dialog_->heightED);
+ bcview().addReadOnly(dialog_->aspectratioCB);
+ bcview().addReadOnly(dialog_->widthUnitCO);
+ bcview().addReadOnly(dialog_->widthED);
+ bcview().addReadOnly(dialog_->clipCB);
+ bcview().addReadOnly(dialog_->getbbPB);
+ bcview().addReadOnly(dialog_->ytED);
+ bcview().addReadOnly(dialog_->xlED);
+ bcview().addReadOnly(dialog_->xrED);
+ bcview().addReadOnly(dialog_->ybED);
+ bcview().addReadOnly(dialog_->extraFormatCO);
+ bcview().addReadOnly(dialog_->extraED);
+
+ addCheckedLineEdit(bcview(), dialog_->angleED, dialog_->angleLA);
+ addCheckedLineEdit(bcview(), dialog_->displayscaleED, dialog_->scaleLA);
+ addCheckedLineEdit(bcview(), dialog_->heightED, dialog_->heightLA);
+ addCheckedLineEdit(bcview(), dialog_->widthED, dialog_->widthLA);
+ addCheckedLineEdit(bcview(), dialog_->xlED, dialog_->lbLA);
+ addCheckedLineEdit(bcview(), dialog_->ybED, dialog_->lbLA);
+ addCheckedLineEdit(bcview(), dialog_->xrED, dialog_->rtLA);
+ addCheckedLineEdit(bcview(), dialog_->ytED, dialog_->rtLA);
+ addCheckedLineEdit(bcview(), dialog_->fileED, dialog_->fileLA);
+
+ std::vector<string> templates(controller().getTemplates());
+
+ for (std::vector<string>::const_iterator cit = templates.begin();
+ cit != templates.end(); ++cit) {
+ dialog_->externalCO->addItem(qt_(*cit));
+ }
+
+ // Fill the origins combo
+ typedef vector<external::RotationDataType> Origins;
+ Origins const & all_origins = external::all_origins();
+ for (Origins::size_type i = 0; i != all_origins.size(); ++i)
+ dialog_->originCO->addItem(toqstr(external::origin_gui_str(i)));
+
+ // Fill the width combo
+ dialog_->widthUnitCO->addItem(qt_("Scale%"));
+ for (int i = 0; i < num_units; i++)
+ dialog_->widthUnitCO->addItem(qt_(unit_name_gui[i]));
+}
+
+
+void GuiExternal::update_contents()
+{
+ dialog_->tab->setCurrentIndex(0);
+ InsetExternalParams const & params = controller().params();
+
+ string const name =
+ params.filename.outputFilename(kernel().bufferFilepath());
+ dialog_->fileED->setText(toqstr(name));
+
+ dialog_->externalCO->setCurrentIndex(
+ controller().getTemplateNumber(params.templatename()));
+ updateTemplate();
+
+ dialog_->draftCB->setChecked(params.draft);
+
+ setDisplay(*dialog_->displayCB, *dialog_->showCO,
+ *dialog_->displayscaleED,
+ params.display, params.lyxscale, readOnly());
+
+ setRotation(*dialog_->angleED, *dialog_->originCO, params.rotationdata);
+
+ setSize(*dialog_->widthED, *dialog_->widthUnitCO,
+ *dialog_->heightED, *dialog_->heightUnitCO,
+ *dialog_->aspectratioCB,
+ params.resizedata);
+
+ setCrop(*dialog_->clipCB,
+ *dialog_->xlED, *dialog_->ybED,
+ *dialog_->xrED, *dialog_->ytED,
+ params.clipdata);
+ controller().bbChanged(!params.clipdata.bbox.empty());
+
+ isValid();
+}
+
+
+void GuiExternal::updateTemplate()
+{
+ external::Template templ =
+ controller().getTemplate(dialog_->externalCO->currentIndex());
+ dialog_->externalTB->setPlainText(qt_(templ.helpText));
+
+ // Ascertain which (if any) transformations the template supports
+ // and disable tabs hosting unsupported transforms.
+ typedef vector<external::TransformID> TransformIDs;
+ TransformIDs const transformIds = templ.transformIds;
+ TransformIDs::const_iterator tr_begin = transformIds.begin();
+ TransformIDs::const_iterator const tr_end = transformIds.end();
+
+ bool found = find(tr_begin, tr_end, external::Rotate) != tr_end;
+ dialog_->tab->setTabEnabled(
+ dialog_->tab->indexOf(dialog_->rotatetab), found);
+ found = find(tr_begin, tr_end, external::Resize) != tr_end;
+ dialog_->tab->setTabEnabled(
+ dialog_->tab->indexOf(dialog_->scaletab), found);
+
+ found = find(tr_begin, tr_end, external::Clip) != tr_end;
+ dialog_->tab->setTabEnabled(
+ dialog_->tab->indexOf(dialog_->croptab), found);
+
+ found = find(tr_begin, tr_end, external::Extra) != tr_end;
+ dialog_->tab->setTabEnabled(
+ dialog_->tab->indexOf(dialog_->optionstab), found);
+
+ if (!found)
+ return;
+
+ // Ascertain whether the template has any formats supporting
+ // the 'Extra' option
+ QLineEdit * const extraED = dialog_->extraED;
+ QComboBox * const extraCB = dialog_->extraFormatCO;
+
+ extra_.clear();
+ extraED->clear();
+ extraCB->clear();
+
+ external::Template::Formats::const_iterator it = templ.formats.begin();
+ external::Template::Formats::const_iterator end = templ.formats.end();
+ for (; it != end; ++it) {
+ if (it->second.option_transformers.find(external::Extra) ==
+ it->second.option_transformers.end())
+ continue;
+ string const format = it->first;
+ string const opt = controller().params().extradata.get(format);
+ extraCB->addItem(toqstr(format));
+ extra_[format] = toqstr(opt);
+ }
+
+ bool const enabled = extraCB->count() > 0;
+
+ dialog_->tab->setTabEnabled(
+ dialog_->tab->indexOf(dialog_->optionstab), enabled);
+ extraED->setEnabled(enabled && !kernel().isBufferReadonly());
+ extraCB->setEnabled(enabled);
+
+ if (enabled) {
+ extraCB->setCurrentIndex(0);
+ extraED->setText(extra_[fromqstr(extraCB->currentText())]);
+ }
+}
+
+
+void GuiExternal::apply()
+{
+ InsetExternalParams params = controller().params();
+
+ params.filename.set(internal_path(fromqstr(dialog_->fileED->text())),
+ kernel().bufferFilepath());
+
+ params.settemplate(controller().getTemplate(
+ dialog_->externalCO->currentIndex()).lyxName);
+
+ params.draft = dialog_->draftCB->isChecked();
+
+ getDisplay(params.display, params.lyxscale,
+ *dialog_->displayCB, *dialog_->showCO,
+ *dialog_->displayscaleED);
+
+ if (dialog_->tab->isTabEnabled(
+ dialog_->tab->indexOf(dialog_->rotatetab)))
+ getRotation(params.rotationdata,
+ *dialog_->angleED, *dialog_->originCO);
+
+ if (dialog_->tab->isTabEnabled(
+ dialog_->tab->indexOf(dialog_->scaletab)))
+ getSize(params.resizedata,
+ *dialog_->widthED, *dialog_->widthUnitCO,
+ *dialog_->heightED, *dialog_->heightUnitCO,
+ *dialog_->aspectratioCB);
+
+ if (dialog_->tab->isTabEnabled(
+ dialog_->tab->indexOf(dialog_->croptab)))
+ getCrop(params.clipdata,
+ *dialog_->clipCB,
+ *dialog_->xlED, *dialog_->ybED,
+ *dialog_->xrED, *dialog_->ytED,
+ controller().bbChanged());
+
+ if (dialog_->tab->isTabEnabled(
+ dialog_->tab->indexOf(dialog_->optionstab)))
+ getExtra(params.extradata, extra_);
+
+ controller().setParams(params);
+}
+
+
+void GuiExternal::getBB()
+{
+ dialog_->xlED->setText("0");
+ dialog_->ybED->setText("0");
+ dialog_->xrED->setText("0");
+ dialog_->ytED->setText("0");
+
+ string const filename = fromqstr(dialog_->fileED->text());
+ if (filename.empty())
+ return;
+
+ string const bb = controller().readBB(filename);
+ if (bb.empty())
+ return;
+
+ dialog_->xlED->setText(toqstr(token(bb, ' ', 0)));
+ dialog_->ybED->setText(toqstr(token(bb, ' ', 1)));
+ dialog_->xrED->setText(toqstr(token(bb, ' ', 2)));
+ dialog_->ytED->setText(toqstr(token(bb, ' ', 3)));
+
+ controller().bbChanged(false);
+}
+
+} // namespace frontend
+} // namespace lyx
+
+#include "GuiExternal_moc.cpp"
--- /dev/null
+// -*- C++ -*-
+/**
+ * \file GuiExternal.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author John Levon
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#ifndef QEXTERNAL_H
+#define QEXTERNAL_H
+
+#include "GuiDialogView.h"
+
+#include "ui_ExternalUi.h"
+
+#include <QCloseEvent>
+#include <QDialog>
+
+#include <map>
+
+namespace lyx {
+namespace frontend {
+
+class GuiExternal;
+
+class GuiExternalDialog : public QDialog, public Ui::ExternalUi {
+ Q_OBJECT
+public:
+ GuiExternalDialog(GuiExternal * form);
+
+ virtual void show();
+protected Q_SLOTS:
+ virtual void bbChanged();
+ virtual void browseClicked();
+ virtual void change_adaptor();
+ virtual void editClicked();
+ virtual void extraChanged(const QString&);
+ virtual void formatChanged(const QString&);
+ virtual void getbbClicked();
+ virtual void sizeChanged();
+ virtual void templateChanged();
+ virtual void widthUnitChanged();
+
+protected:
+ virtual void closeEvent(QCloseEvent * e);
+private:
+ bool activateAspectratio() const;
+ GuiExternal * form_;
+};
+
+
+class ControlExternal;
+
+class GuiExternal
+ : public QController<ControlExternal, GuiView<GuiExternalDialog> >
+{
+public:
+ friend class GuiExternalDialog;
+
+ GuiExternal(Dialog &);
+
+ typedef std::map<std::string, QString> MapType;
+
+private:
+ /// Apply changes
+ virtual void apply();
+ /// update
+ virtual void update_contents();
+ /// build the dialog
+ virtual void build_dialog();
+
+ /// Helper function called when the template is changed.
+ void updateTemplate();
+ /// get bounding box from file
+ void getBB();
+
+ MapType extra_;
+};
+
+} // namespace frontend
+} // namespace lyx
+
+#endif // QEXTERNAL_H
--- /dev/null
+/**
+ * \file GuiFloat.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Edwin Leuven
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "GuiFloat.h"
+#include "GuiFloatDialog.h"
+#include "Qt2BC.h"
+#include "FloatPlacement.h"
+
+#include "controllers/ControlFloat.h"
+
+#include "insets/InsetFloat.h"
+
+#include <QPushButton>
+
+namespace lyx {
+namespace frontend {
+
+typedef QController<ControlFloat, GuiView<GuiFloatDialog> > float_base_class;
+
+
+GuiFloat::GuiFloat(Dialog & parent)
+ : float_base_class(parent, _("Float Settings"))
+{
+}
+
+
+void GuiFloat::build_dialog()
+{
+ dialog_.reset(new GuiFloatDialog(this));
+
+ bcview().setCancel(dialog_->closePB);
+ bcview().setApply(dialog_->applyPB);
+ bcview().setOK(dialog_->okPB);
+ bcview().setRestore(dialog_->restorePB);
+
+ bcview().addReadOnly(dialog_->floatFP);
+}
+
+
+void GuiFloat::update_contents()
+{
+ dialog_->floatFP->set(controller().params());
+}
+
+
+void GuiFloat::apply()
+{
+ InsetFloatParams & params = controller().params();
+
+ params.placement = dialog_->floatFP->get(params.wide, params.sideways);
+}
+
+} // namespace frontend
+} // namespace lyx
--- /dev/null
+// -*- C++ -*-
+/**
+ * \file GuiFloat.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Edwin Leuven
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#ifndef QFLOAT_H
+#define QFLOAT_H
+
+#include "GuiDialogView.h"
+#include "GuiFloatDialog.h"
+
+namespace lyx {
+namespace frontend {
+
+
+class ControlFloat;
+
+///
+class GuiFloat : public QController<ControlFloat, GuiView<GuiFloatDialog> > {
+public:
+ ///
+ friend class GuiFloatDialog;
+ ///
+ GuiFloat(Dialog &);
+private:
+ /// Apply changes
+ virtual void apply();
+ /// update
+ virtual void update_contents();
+ /// build the dialog
+ virtual void build_dialog();
+};
+
+} // namespace frontend
+} // namespace lyx
+
+#endif // QFLOAT_H
--- /dev/null
+/**
+ * \file GuiFloatDialog.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Edwin Leuven
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "GuiFloatDialog.h"
+#include "GuiFloat.h"
+
+#include <QCloseEvent>
+#include <QPushButton>
+
+#include "FloatPlacement.h"
+
+
+
+namespace lyx {
+namespace frontend {
+
+GuiFloatDialog::GuiFloatDialog(GuiFloat * form)
+ : form_(form)
+{
+ setupUi(this);
+ connect(restorePB, SIGNAL(clicked()),
+ form, SLOT(slotRestore()));
+ connect(okPB, SIGNAL(clicked()),
+ form, SLOT(slotOK()));
+ connect(applyPB, SIGNAL(clicked()),
+ form, SLOT(slotApply()));
+ connect(closePB, SIGNAL(clicked()),
+ form, SLOT(slotClose()));
+
+ // enable span columns checkbox
+ floatFP->useWide();
+
+ // enable sideways checkbox
+ floatFP->useSideways();
+
+ connect(floatFP, SIGNAL(changed()),
+ this, SLOT(change_adaptor()));
+}
+
+
+void GuiFloatDialog::change_adaptor()
+{
+ form_->changed();
+}
+
+
+void GuiFloatDialog::closeEvent(QCloseEvent * e)
+{
+ form_->slotWMHide();
+ e->accept();
+}
+
+} // namespace frontend
+} // namespace lyx
+
+#include "GuiFloatDialog_moc.cpp"
--- /dev/null
+// -*- C++ -*-
+/**
+ * \file GuiFloatDialog.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Edwin Leuven
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#ifndef QFLOATDIALOG_H
+#define QFLOATDIALOG_H
+
+#include "ui_FloatUi.h"
+
+#include <QCloseEvent>
+#include <QDialog>
+
+namespace lyx {
+namespace frontend {
+
+class GuiFloat;
+
+class GuiFloatDialog : public QDialog, public Ui::FloatUi {
+ Q_OBJECT
+public:
+ GuiFloatDialog(GuiFloat * form);
+
+protected Q_SLOTS:
+ virtual void change_adaptor();
+
+protected:
+ virtual void closeEvent(QCloseEvent * e);
+
+private:
+ GuiFloat * form_;
+};
+
+} // namespace frontend
+} // namespace lyx
+
+#endif // QFLOATDIALOG_H
--- /dev/null
+/**
+ * \file GuiFontExample.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author John Levon
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "GuiFontExample.h"
+
+#include <QPainter>
+#include <QPaintEvent>
+
+
+//namespace lyx {
+
+void GuiFontExample::set(QFont const & font, QString const & text)
+{
+ font_ = font;
+ text_ = text;
+ update();
+}
+
+
+QSize GuiFontExample::sizeHint() const
+{
+ QFontMetrics m(font_);
+ return QSize(m.width(text_) + 10, m.ascent() + m.descent() + 6);
+}
+
+
+void GuiFontExample::paintEvent(QPaintEvent *)
+{
+ QPainter p;
+ QFontMetrics m(font_);
+
+ p.begin(this);
+ p.setFont(font_);
+ p.drawRect(0, 0, width() - 1, height() - 1);
+ p.drawText(5, 3 + m.ascent(), text_);
+ p.end();
+}
+
+
+//} // namespace lyx
--- /dev/null
+// -*- C++ -*-
+/**
+ * \file GuiFontExample.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author John Levon
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#ifndef QT_QFONTEXAMPLE_H
+#define QT_QFONTEXAMPLE_H
+
+#include <QWidget>
+#include <QFont>
+#include <QString>
+
+class QPaintEvent;
+
+
+//namespace lyx {
+
+class GuiFontExample : public QWidget {
+
+public:
+ GuiFontExample(QWidget * parent)
+ : QWidget(parent) {}
+
+ void set(QFont const & font, QString const & text);
+
+ virtual QSize sizeHint() const;
+
+protected:
+ virtual void paintEvent(QPaintEvent * p);
+
+private:
+ QFont font_;
+ QString text_;
+};
+
+
+//} // namespace lyx
+
+#endif
--- /dev/null
+/**
+ * \file GuiGraphics.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author John Levon
+ * \author Edwin Leuven
+ * \author Herbert Voß
+ * \author Richard Heck
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "GuiGraphics.h"
+
+#include "CheckedLineEdit.h"
+#include "LengthCombo.h"
+#include "GuiGraphicsDialog.h"
+#include "Qt2BC.h"
+#include "qt_helpers.h"
+
+#include "lengthcommon.h"
+#include "LyXRC.h"
+
+#include "controllers/ControlGraphics.h"
+#include "controllers/frontend_helpers.h"
+
+#include "insets/InsetGraphicsParams.h"
+
+#include "support/convert.h"
+#include "support/lstrings.h"
+#include "support/lyxlib.h"
+#include "support/os.h"
+
+#include <QLineEdit>
+#include <QPushButton>
+#include <QCheckBox>
+#include <QLabel>
+
+#include <cmath>
+
+using lyx::support::float_equal;
+using lyx::support::token;
+
+using lyx::support::os::internal_path;
+
+#ifndef CXX_GLOBAL_CSTD
+using std::floor;
+#endif
+
+using std::vector;
+using std::string;
+
+namespace lyx {
+namespace frontend {
+
+typedef QController<ControlGraphics, GuiView<GuiGraphicsDialog> > graphics_base_class;
+
+GuiGraphics::GuiGraphics(Dialog & parent)
+ : graphics_base_class(parent, _("Graphics"))
+{
+}
+
+
+void GuiGraphics::build_dialog()
+{
+ dialog_.reset(new GuiGraphicsDialog(this));
+
+ bcview().setOK(dialog_->okPB);
+ bcview().setApply(dialog_->applyPB);
+ bcview().setRestore(dialog_->restorePB);
+ bcview().setCancel(dialog_->closePB);
+
+ bcview().addReadOnly(dialog_->latexoptions);
+ bcview().addReadOnly(dialog_->subfigure);
+ bcview().addReadOnly(dialog_->filenameL);
+ bcview().addReadOnly(dialog_->filename);
+ bcview().addReadOnly(dialog_->browsePB);
+ bcview().addReadOnly(dialog_->unzipCB);
+ bcview().addReadOnly(dialog_->bbFrame);
+ bcview().addReadOnly(dialog_->draftCB);
+ bcview().addReadOnly(dialog_->clip);
+ bcview().addReadOnly(dialog_->unzipCB);
+ bcview().addReadOnly(dialog_->displayGB);
+ bcview().addReadOnly(dialog_->sizeGB);
+ bcview().addReadOnly(dialog_->rotationGB);
+ bcview().addReadOnly(dialog_->latexoptions);
+ bcview().addReadOnly(dialog_->getPB);
+ bcview().addReadOnly(dialog_->rotateOrderCB);
+
+ // initialize the length validator
+ addCheckedLineEdit(bcview(), dialog_->Scale, dialog_->scaleCB);
+ addCheckedLineEdit(bcview(), dialog_->Width, dialog_->WidthCB);
+ addCheckedLineEdit(bcview(), dialog_->Height, dialog_->HeightCB);
+ addCheckedLineEdit(bcview(), dialog_->displayscale, dialog_->scaleLA);
+ addCheckedLineEdit(bcview(), dialog_->angle, dialog_->angleL);
+ addCheckedLineEdit(bcview(), dialog_->lbX, dialog_->xL);
+ addCheckedLineEdit(bcview(), dialog_->lbY, dialog_->yL);
+ addCheckedLineEdit(bcview(), dialog_->rtX, dialog_->xL_2);
+ addCheckedLineEdit(bcview(), dialog_->rtY, dialog_->yL_2);
+ addCheckedLineEdit(bcview(), dialog_->filename, dialog_->filenameL);
+}
+
+
+namespace {
+
+// returns the number of the string s in the vector v
+int getItemNo(vector<string> v, string const & s) {
+ vector<string>::const_iterator cit =
+ find(v.begin(), v.end(), s);
+ return (cit != v.end()) ? int(cit - v.begin()) : 0;
+}
+
+}
+
+
+void GuiGraphics::update_contents()
+{
+ // clear and fill in the comboboxes
+ vector<string> const bb_units = frontend::getBBUnits();
+ dialog_->lbXunit->clear();
+ dialog_->lbYunit->clear();
+ dialog_->rtXunit->clear();
+ dialog_->rtYunit->clear();
+ for (vector<string>::const_iterator it = bb_units.begin();
+ it != bb_units.end(); ++it) {
+ dialog_->lbXunit->addItem(toqstr(*it));
+ dialog_->lbYunit->addItem(toqstr(*it));
+ dialog_->rtXunit->addItem(toqstr(*it));
+ dialog_->rtYunit->addItem(toqstr(*it));
+ }
+
+ InsetGraphicsParams & igp = controller().params();
+
+ // set the right default unit
+ Length::UNIT unitDefault = Length::CM;
+ switch (lyxrc.default_papersize) {
+ case PAPER_USLETTER:
+ case PAPER_USLEGAL:
+ case PAPER_USEXECUTIVE:
+ unitDefault = Length::IN;
+ break;
+ default:
+ break;
+ }
+
+ string const name =
+ igp.filename.outputFilename(kernel().bufferFilepath());
+ dialog_->filename->setText(toqstr(name));
+
+ // set the bounding box values
+ if (igp.bb.empty()) {
+ string const bb = controller().readBB(igp.filename.absFilename());
+ // the values from the file always have the bigpoint-unit bp
+ dialog_->lbX->setText(toqstr(token(bb, ' ', 0)));
+ dialog_->lbY->setText(toqstr(token(bb, ' ', 1)));
+ dialog_->rtX->setText(toqstr(token(bb, ' ', 2)));
+ dialog_->rtY->setText(toqstr(token(bb, ' ', 3)));
+ dialog_->lbXunit->setCurrentIndex(0);
+ dialog_->lbYunit->setCurrentIndex(0);
+ dialog_->rtXunit->setCurrentIndex(0);
+ dialog_->rtYunit->setCurrentIndex(0);
+ controller().bbChanged = false;
+ } else {
+ // get the values from the inset
+ Length anyLength;
+ string const xl(token(igp.bb, ' ', 0));
+ string const yl(token(igp.bb, ' ', 1));
+ string const xr(token(igp.bb, ' ', 2));
+ string const yr(token(igp.bb, ' ', 3));
+ if (isValidLength(xl, &anyLength)) {
+ dialog_->lbX->setText(toqstr(convert<string>(anyLength.value())));
+ string const unit(unit_name[anyLength.unit()]);
+ dialog_->lbXunit->setCurrentIndex(getItemNo(bb_units, unit));
+ } else {
+ dialog_->lbX->setText(toqstr(xl));
+ }
+ if (isValidLength(yl, &anyLength)) {
+ dialog_->lbY->setText(toqstr(convert<string>(anyLength.value())));
+ string const unit(unit_name[anyLength.unit()]);
+ dialog_->lbYunit->setCurrentIndex(getItemNo(bb_units, unit));
+ } else {
+ dialog_->lbY->setText(toqstr(xl));
+ }
+ if (isValidLength(xr, &anyLength)) {
+ dialog_->rtX->setText(toqstr(convert<string>(anyLength.value())));
+ string const unit(unit_name[anyLength.unit()]);
+ dialog_->rtXunit->setCurrentIndex(getItemNo(bb_units, unit));
+ } else {
+ dialog_->rtX->setText(toqstr(xl));
+ }
+ if (isValidLength(yr, &anyLength)) {
+ dialog_->rtY->setText(toqstr(convert<string>(anyLength.value())));
+ string const unit(unit_name[anyLength.unit()]);
+ dialog_->rtYunit->setCurrentIndex(getItemNo(bb_units, unit));
+ } else {
+ dialog_->rtY->setText(toqstr(xl));
+ }
+ controller().bbChanged = true;
+ }
+
+ // Update the draft and clip mode
+ dialog_->draftCB->setChecked(igp.draft);
+ dialog_->clip->setChecked(igp.clip);
+ dialog_->unzipCB->setChecked(igp.noUnzip);
+
+ // Update the subcaption check button and input field
+ dialog_->subfigure->setChecked(igp.subcaption);
+ dialog_->subcaption->setText(toqstr(igp.subcaptionText));
+
+ int item = 0;
+ switch (igp.display) {
+ case graphics::DefaultDisplay: item = 0; break;
+ case graphics::MonochromeDisplay: item = 1; break;
+ case graphics::GrayscaleDisplay: item = 2; break;
+ case graphics::ColorDisplay: item = 3; break;
+ case graphics::NoDisplay: item = 0; break;
+ }
+ dialog_->showCB->setCurrentIndex(item);
+ dialog_->displayscale->setText(toqstr(convert<string>(igp.lyxscale)));
+ dialog_->displayGB->setChecked(igp.display != graphics::NoDisplay);
+
+ // the output section (width/height)
+
+ dialog_->Scale->setText(toqstr(igp.scale));
+ //igp.scale defaults to 100, so we treat it as empty
+ bool const scaleChecked = !igp.scale.empty() && igp.scale != "100";
+ dialog_->scaleCB->blockSignals(true);
+ dialog_->scaleCB->setChecked(scaleChecked);
+ dialog_->scaleCB->blockSignals(false);
+ dialog_->Scale->setEnabled(scaleChecked);
+
+ lengthAutoToWidgets(dialog_->Width, dialog_->widthUnit, igp.width,
+ unitDefault);
+ bool const widthChecked = !dialog_->Width->text().isEmpty() &&
+ dialog_->Width->text() != "auto";
+ dialog_->WidthCB->blockSignals(true);
+ dialog_->WidthCB->setChecked(widthChecked);
+ dialog_->WidthCB->blockSignals(false);
+ dialog_->Width->setEnabled(widthChecked);
+ dialog_->widthUnit->setEnabled(widthChecked);
+
+ lengthAutoToWidgets(dialog_->Height, dialog_->heightUnit, igp.height,
+ unitDefault);
+ bool const heightChecked = !dialog_->Height->text().isEmpty()
+ && dialog_->Height->text() != "auto";
+ dialog_->HeightCB->blockSignals(true);
+ dialog_->HeightCB->setChecked(heightChecked);
+ dialog_->HeightCB->blockSignals(false);
+ dialog_->Height->setEnabled(heightChecked);
+ dialog_->heightUnit->setEnabled(heightChecked);
+
+ dialog_->scaleCB->setEnabled(!widthChecked && !heightChecked);
+ dialog_->WidthCB->setEnabled(!scaleChecked);
+ dialog_->HeightCB->setEnabled(!scaleChecked);
+ dialog_->aspectratio->setEnabled(widthChecked && heightChecked);
+
+ dialog_->setAutoText();
+
+ dialog_->angle->setText(toqstr(igp.rotateAngle));
+ dialog_->rotateOrderCB->setChecked(igp.scaleBeforeRotation);
+
+ dialog_->rotateOrderCB->setEnabled((widthChecked ||
+ heightChecked ||
+ scaleChecked) &&
+ (igp.rotateAngle != "0"));
+
+ dialog_->origin->clear();
+
+ vector<RotationOriginPair> origindata = getRotationOriginData();
+ vector<docstring> const origin_lang = getFirst(origindata);
+ GuiGraphics::origin_ltx = getSecond(origindata);
+
+ for (vector<docstring>::const_iterator it = origin_lang.begin();
+ it != origin_lang.end(); ++it)
+ dialog_->origin->addItem(toqstr(*it));
+
+ if (!igp.rotateOrigin.empty())
+ dialog_->origin->setCurrentIndex(
+ getItemNo(origin_ltx, igp.rotateOrigin));
+ else
+ dialog_->origin->setCurrentIndex(0);
+
+ // disable edit button when no filename is present
+ dialog_->editPB->setDisabled(dialog_->filename->text().isEmpty());
+
+ //// latex section
+ dialog_->latexoptions->setText(toqstr(igp.special));
+}
+
+
+void GuiGraphics::apply()
+{
+ InsetGraphicsParams & igp = controller().params();
+
+ igp.filename.set(internal_path(fromqstr(dialog_->filename->text())),
+ kernel().bufferFilepath());
+
+ // the bb section
+ igp.bb.erase();
+ if (controller().bbChanged) {
+ string bb;
+ string lbX(fromqstr(dialog_->lbX->text()));
+ string lbY(fromqstr(dialog_->lbY->text()));
+ string rtX(fromqstr(dialog_->rtX->text()));
+ string rtY(fromqstr(dialog_->rtY->text()));
+ int bb_sum =
+ convert<int>(lbX) + convert<int>(lbY) +
+ convert<int>(rtX) + convert<int>(rtX);
+ if (bb_sum) {
+ if (lbX.empty())
+ bb = "0 ";
+ else
+ bb = lbX + fromqstr(dialog_->lbXunit->currentText()) + ' ';
+ if (lbY.empty())
+ bb += "0 ";
+ else
+ bb += (lbY + fromqstr(dialog_->lbYunit->currentText()) + ' ');
+ if (rtX.empty())
+ bb += "0 ";
+ else
+ bb += (rtX + fromqstr(dialog_->rtXunit->currentText()) + ' ');
+ if (rtY.empty())
+ bb += '0';
+ else
+ bb += (rtY + fromqstr(dialog_->rtYunit->currentText()));
+ igp.bb = bb;
+ }
+ }
+
+ igp.draft = dialog_->draftCB->isChecked();
+ igp.clip = dialog_->clip->isChecked();
+ igp.subcaption = dialog_->subfigure->isChecked();
+ igp.subcaptionText = fromqstr(dialog_->subcaption->text());
+
+ switch (dialog_->showCB->currentIndex()) {
+ case 0: igp.display = graphics::DefaultDisplay; break;
+ case 1: igp.display = graphics::MonochromeDisplay; break;
+ case 2: igp.display = graphics::GrayscaleDisplay; break;
+ case 3: igp.display = graphics::ColorDisplay; break;
+ default:;
+ }
+
+ if (!dialog_->displayGB->isChecked())
+ igp.display = graphics::NoDisplay;
+
+ //the graphics section
+ if (dialog_->scaleCB->isChecked() && !dialog_->Scale->text().isEmpty()) {
+ igp.scale = fromqstr(dialog_->Scale->text());
+ igp.width = Length("0pt");
+ igp.height = Length("0pt");
+ igp.keepAspectRatio = false;
+ } else {
+ igp.scale = string();
+ igp.width = dialog_->WidthCB->isChecked() ?
+ //Note that this works even if dialog_->Width is "auto", since in
+ //that case we get "0pt".
+ Length(widgetsToLength(dialog_->Width, dialog_->widthUnit)):
+ Length("0pt");
+ igp.height = dialog_->HeightCB->isChecked() ?
+ Length(widgetsToLength(dialog_->Height, dialog_->heightUnit)) :
+ Length("0pt");
+ igp.keepAspectRatio = dialog_->aspectratio->isEnabled() &&
+ dialog_->aspectratio->isChecked() &&
+ igp.width.value() > 0 && igp.height.value() > 0;
+ }
+
+ igp.noUnzip = dialog_->unzipCB->isChecked();
+
+ igp.lyxscale = convert<int>(fromqstr(dialog_->displayscale->text()));
+
+ igp.rotateAngle = fromqstr(dialog_->angle->text());
+
+ double rotAngle = convert<double>(igp.rotateAngle);
+ if (std::abs(rotAngle) > 360.0) {
+ rotAngle -= 360.0 * floor(rotAngle / 360.0);
+ igp.rotateAngle = convert<string>(rotAngle);
+ }
+
+ // save the latex name for the origin. If it is the default
+ // then origin_ltx returns ""
+ igp.rotateOrigin =
+ GuiGraphics::origin_ltx[dialog_->origin->currentIndex()];
+
+ igp.scaleBeforeRotation = dialog_->rotateOrderCB->isChecked();
+
+ // more latex options
+ igp.special = fromqstr(dialog_->latexoptions->text());
+}
+
+
+void GuiGraphics::getBB()
+{
+ string const filename(fromqstr(dialog_->filename->text()));
+ if (!filename.empty()) {
+ string const bb(controller().readBB(filename));
+ if (!bb.empty()) {
+ dialog_->lbX->setText(toqstr(token(bb, ' ', 0)));
+ dialog_->lbY->setText(toqstr(token(bb, ' ', 1)));
+ dialog_->rtX->setText(toqstr(token(bb, ' ', 2)));
+ dialog_->rtY->setText(toqstr(token(bb, ' ', 3)));
+ // the default units for the bb values when reading
+ // it from the file
+ dialog_->lbXunit->setCurrentIndex(0);
+ dialog_->lbYunit->setCurrentIndex(0);
+ dialog_->rtXunit->setCurrentIndex(0);
+ dialog_->rtYunit->setCurrentIndex(0);
+ }
+ controller().bbChanged = false;
+ }
+}
+
+
+bool GuiGraphics::isValid()
+{
+ return !dialog_->filename->text().isEmpty();
+}
+
+} // namespace frontend
+} // namespace lyx
--- /dev/null
+// -*- C++ -*-
+/**
+ * \file GuiGraphics.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author John Levon
+ * \author Herbert Voß
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#ifndef QGRAPHICS_H
+#define QGRAPHICS_H
+
+#include "GuiDialogView.h"
+#include "GuiGraphicsDialog.h"
+
+#include <vector>
+
+namespace lyx {
+namespace frontend {
+
+class ControlGraphics;
+
+///
+class GuiGraphics
+ : public QController<ControlGraphics, GuiView<GuiGraphicsDialog> >
+{
+public:
+ ///
+ friend class GuiGraphicsDialog;
+ ///
+ GuiGraphics(Dialog &);
+protected:
+ virtual bool isValid();
+private:
+ /// Apply changes
+ virtual void apply();
+ /// update
+ virtual void update_contents();
+ /// build the dialog
+ virtual void build_dialog();
+ /// get bounding box from file
+ void getBB();
+
+ /// Store the LaTeX names for the rotation origins.
+ std::vector<std::string> origin_ltx;
+
+};
+
+} // namespace frontend
+} // namespace lyx
+
+#endif // QGRAPHICS_H
--- /dev/null
+/**
+ * \file GuiGraphicsDialog.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author John Levon
+ * \author Herbert Voß
+ * \author Abdelrazak Younes
+ * \author Richard Heck
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "GuiGraphicsDialog.h"
+#include "GuiGraphics.h"
+
+#include "LengthCombo.h"
+#include "Validator.h"
+#include "qt_helpers.h"
+
+#include "debug.h"
+
+#include "controllers/ControlGraphics.h"
+
+#include "insets/InsetGraphicsParams.h"
+
+#include <QCloseEvent>
+#include <QPushButton>
+#include <QLineEdit>
+#include <QValidator>
+
+
+using std::string;
+
+namespace lyx {
+namespace frontend {
+
+
+GuiGraphicsDialog::GuiGraphicsDialog(GuiGraphics * form)
+ : form_(form)
+{
+ setupUi(this);
+ //main buttons
+ connect(okPB, SIGNAL(clicked()),
+ form, SLOT(slotOK()));
+ connect(applyPB, SIGNAL(clicked()),
+ form, SLOT(slotApply()));
+ connect(closePB, SIGNAL(clicked()),
+ form, SLOT(slotClose()));
+ connect(restorePB, SIGNAL(clicked()),
+ form, SLOT(slotRestore()));
+
+ //graphics pane
+ connect(filename, SIGNAL(textChanged(const QString &)),
+ this, SLOT(change_adaptor()));
+ connect(WidthCB, SIGNAL( clicked()),
+ this, SLOT(change_adaptor()));
+ connect(HeightCB, SIGNAL( clicked()),
+ this, SLOT(change_adaptor()));
+ connect(Width, SIGNAL(textChanged(const QString &)),
+ this, SLOT(change_adaptor()));
+ connect(Height, SIGNAL(textChanged(const QString &)),
+ this, SLOT(change_adaptor()));
+ connect(heightUnit, SIGNAL(selectionChanged(lyx::Length::UNIT)),
+ this, SLOT(change_adaptor()));
+ connect(widthUnit, SIGNAL(selectionChanged(lyx::Length::UNIT)),
+ this, SLOT(change_adaptor()));
+ connect(aspectratio, SIGNAL(stateChanged(int)),
+ this, SLOT(change_adaptor()));
+ connect(angle, SIGNAL(textChanged(const QString &)),
+ this, SLOT(change_adaptor()));
+ connect(origin, SIGNAL(activated(int)),
+ this, SLOT(change_adaptor()));
+ connect(scaleCB, SIGNAL(clicked()),
+ this, SLOT(change_adaptor()));
+ connect(Scale, SIGNAL(textChanged(const QString &)),
+ this, SLOT(change_adaptor()));
+ connect(rotateOrderCB, SIGNAL(clicked()),
+ this, SLOT(change_adaptor()));
+
+ filename->setValidator(new PathValidator(true, filename));
+ setFocusProxy(filename);
+
+ QDoubleValidator * scaleValidator = new DoubleAutoValidator(Scale);
+ scaleValidator->setBottom(0);
+ scaleValidator->setDecimals(256); //I guess that will do
+ Scale->setValidator(scaleValidator);
+ Height->setValidator(unsignedLengthAutoValidator(Height));
+ Width->setValidator(unsignedLengthAutoValidator(Width));
+ angle->setValidator(new QDoubleValidator(-360, 360, 2, angle));
+
+ //clipping pane
+ connect(clip, SIGNAL(stateChanged(int)),
+ this, SLOT(change_adaptor()));
+ connect(lbY, SIGNAL(textChanged(const QString&)),
+ this, SLOT(change_bb()));
+ connect(lbYunit, SIGNAL(activated(int)),
+ this, SLOT(change_bb()));
+ connect(rtY, SIGNAL(textChanged(const QString&)),
+ this, SLOT(change_bb()));
+ connect(rtYunit, SIGNAL(activated(int)),
+ this, SLOT(change_bb()));
+ connect(lbX, SIGNAL(textChanged(const QString&)),
+ this, SLOT(change_bb()));
+ connect(lbXunit, SIGNAL(activated(int)),
+ this, SLOT(change_bb()));
+ connect(rtX, SIGNAL(textChanged(const QString&)),
+ this, SLOT(change_bb()));
+ connect(rtXunit, SIGNAL(activated(int)),
+ this, SLOT(change_bb()));
+ connect(getPB, SIGNAL(clicked()),
+ this, SLOT(change_adaptor()));
+
+ lbX->setValidator(new QDoubleValidator(lbX));
+ lbY->setValidator(new QDoubleValidator(lbY));
+ rtX->setValidator(new QDoubleValidator(rtX));
+ rtY->setValidator(new QDoubleValidator(rtY));
+
+ //extra options pane
+ connect(latexoptions, SIGNAL(textChanged(const QString&)),
+ this, SLOT(change_adaptor()));
+ connect(draftCB, SIGNAL(stateChanged(int)),
+ this, SLOT(change_adaptor()));
+ connect(unzipCB, SIGNAL(stateChanged(int)),
+ this, SLOT(change_adaptor()));
+ // FIXME: we should connect to clicked() when we move to Qt 4.2 because
+ // the toggled(bool) signal is also trigged when we update the widgets
+ // (rgh-4/07) this isn't as much or a problem as it was, because we're now
+ // using blockSignals() to keep from triggering that signal when we call
+ // setChecked(). Note, too, that clicked() would get called whenever it
+ // is clicked, even right clicked (I think), not just whenever it is
+ // toggled.
+ connect(subfigure, SIGNAL(toggled(bool)),
+ this, SLOT(change_adaptor()));
+ connect(subcaption, SIGNAL(textChanged(const QString&)),
+ this, SLOT(change_adaptor()));
+ connect(displayGB, SIGNAL(toggled(bool)),
+ this, SLOT(change_adaptor()));
+ connect(showCB, SIGNAL(currentIndexChanged(int)),
+ this, SLOT(change_adaptor()));
+ connect(displayscale, SIGNAL(textChanged(const QString&)),
+ this, SLOT(change_adaptor()));
+ displayscale->setValidator(new QIntValidator(displayscale));
+}
+
+
+void GuiGraphicsDialog::show()
+{
+ QDialog::show();
+}
+
+
+void GuiGraphicsDialog::change_adaptor()
+{
+ form_->changed();
+}
+
+
+void GuiGraphicsDialog::change_bb()
+{
+ form_->controller().bbChanged = true;
+ LYXERR(Debug::GRAPHICS)
+ << "[controller().bb_Changed set to true]\n";
+ form_->changed();
+}
+
+
+void GuiGraphicsDialog::closeEvent(QCloseEvent * e)
+{
+ form_->slotWMHide();
+ e->accept();
+}
+
+
+void GuiGraphicsDialog::on_browsePB_clicked()
+{
+ docstring const str =
+ form_->controller().browse(qstring_to_ucs4(filename->text()));
+ if(!str.empty()){
+ filename->setText(toqstr(str));
+ form_->changed();
+ }
+}
+
+
+void GuiGraphicsDialog::on_getPB_clicked()
+{
+ form_->getBB();
+}
+
+
+void GuiGraphicsDialog::on_editPB_clicked()
+{
+ form_->controller().editGraphics();
+}
+
+
+void GuiGraphicsDialog::on_filename_textChanged(const QString & filename)
+{
+ editPB->setDisabled(filename.isEmpty());
+}
+
+
+void GuiGraphicsDialog::setAutoText()
+{
+ if (scaleCB->isChecked()) return;
+ if (!Scale->isEnabled() && Scale->text() != "100")
+ Scale->setText(QString("auto"));
+
+ setAutoTextCB(WidthCB, Width, widthUnit);
+ setAutoTextCB(HeightCB, Height, heightUnit);
+}
+
+
+void GuiGraphicsDialog::on_scaleCB_toggled(bool setScale)
+{
+ Scale->setEnabled(setScale);
+ if (setScale) {
+ Scale->setText("100");
+ Scale->setFocus(Qt::OtherFocusReason);
+ }
+
+ WidthCB->setDisabled(setScale);
+ WidthCB->blockSignals(true);
+ WidthCB->setChecked(false);
+ WidthCB->blockSignals(false);
+ Width->setEnabled(false);
+ widthUnit->setEnabled(false);
+
+ HeightCB->setDisabled(setScale);
+ HeightCB->blockSignals(true);
+ HeightCB->setChecked(false);
+ HeightCB->blockSignals(false);
+ Height->setEnabled(false);
+ heightUnit->setEnabled(false);
+
+ aspectratio->setDisabled(true);
+ aspectratio->setChecked(true);
+
+ rotateOrderCB->setEnabled((WidthCB->isChecked() ||
+ HeightCB->isChecked() ||
+ scaleCB->isChecked()) &&
+ (angle->text() != "0"));
+
+ setAutoText();
+}
+
+void GuiGraphicsDialog::on_WidthCB_toggled(bool setWidth)
+{
+ Width->setEnabled(setWidth);
+ widthUnit->setEnabled(setWidth);
+ if (setWidth)
+ Width->setFocus(Qt::OtherFocusReason);
+
+ bool const setHeight = HeightCB->isChecked();
+ aspectratio->setEnabled(setWidth && setHeight);
+ aspectratio->blockSignals(true);
+ aspectratio->setChecked(!(setWidth && setHeight));
+ aspectratio->blockSignals(false);
+
+ scaleCB->setEnabled(!setWidth && !setHeight);
+ //already will be unchecked, so don't need to do that
+ Scale->setEnabled((!setWidth && !setHeight) //=scaleCB->isEnabled()
+ && scaleCB->isChecked()); //should be false, but let's check
+ rotateOrderCB->setEnabled((setWidth || setHeight ||
+ scaleCB->isChecked()) &&
+ (angle->text() != "0"));
+
+ setAutoText();
+}
+
+void GuiGraphicsDialog::on_HeightCB_toggled(bool setHeight)
+{
+ Height->setEnabled(setHeight);
+ heightUnit->setEnabled(setHeight);
+ if (setHeight)
+ Height->setFocus(Qt::OtherFocusReason);
+
+ bool const setWidth = WidthCB->isChecked();
+ aspectratio->setEnabled(setWidth && setHeight);
+ aspectratio->blockSignals(true);
+ aspectratio->setChecked(!(setWidth && setHeight));
+ aspectratio->blockSignals(false);
+
+ scaleCB->setEnabled(!setWidth && !setHeight);
+ //already unchecked
+ Scale->setEnabled((!setWidth && !setHeight) //=scaleCB->isEnabled()
+ && scaleCB->isChecked()); //should be false
+ rotateOrderCB->setEnabled((setWidth || setHeight ||
+ scaleCB->isChecked()) &&
+ (angle->text() != "0"));
+
+ setAutoText();
+}
+
+
+void GuiGraphicsDialog::on_angle_textChanged(const QString & filename)
+{
+ rotateOrderCB->setEnabled((WidthCB->isChecked() ||
+ HeightCB->isChecked() ||
+ scaleCB->isChecked()) &&
+ (filename != "0"));
+}
+
+
+} // namespace frontend
+} // namespace lyx
+
+#include "GuiGraphicsDialog_moc.cpp"
--- /dev/null
+// -*- C++ -*-
+/**
+ * \file GuiGraphicsDialog.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author John Levon
+ * \author Herbert Voß
+ * \author Richard Heck
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#ifndef QGRAPHICSDIALOG_H
+#define QGRAPHICSDIALOG_H
+
+#include "ui_GraphicsUi.h"
+
+#include <QCloseEvent>
+#include <QDialog>
+#include <QString>
+
+namespace lyx {
+namespace frontend {
+
+class GuiGraphics;
+
+class GuiGraphicsDialog : public QDialog, public Ui::GraphicsUi {
+ Q_OBJECT
+public:
+ GuiGraphicsDialog(GuiGraphics * form);
+ virtual void setAutoText();
+ virtual void show();
+protected Q_SLOTS:
+ virtual void change_adaptor();
+ virtual void change_bb();
+ virtual void on_browsePB_clicked();
+ virtual void on_getPB_clicked();
+ virtual void on_editPB_clicked();
+ virtual void on_filename_textChanged(const QString &);
+ virtual void on_scaleCB_toggled(bool);
+ virtual void on_WidthCB_toggled(bool);
+ virtual void on_HeightCB_toggled(bool);
+ virtual void on_angle_textChanged(const QString &);
+protected:
+ virtual void closeEvent(QCloseEvent * e);
+private:
+ GuiGraphics * form_;
+};
+
+} // namespace frontend
+} // namespace lyx
+
+#endif // QGRAPHICSDIALOG_H
--- /dev/null
+/**
+ * \file GuiImage.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Angus Leeming
+ * \author John Levon
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "GuiImage.h"
+#include "qt_helpers.h"
+
+#include "debug.h"
+#include "Format.h"
+
+#include "graphics/GraphicsParams.h"
+
+#include "support/FileName.h"
+#include "support/lstrings.h" // ascii_lowercase
+
+#include <QPainter>
+#include <QPictureIO>
+#include <QPicture>
+#include <QImage>
+#include <QImageReader>
+
+#include <boost/bind.hpp>
+#include <boost/tuple/tuple.hpp>
+
+using lyx::support::ascii_lowercase;
+
+using boost::bind;
+
+using std::endl;
+using std::equal_to;
+using std::find_if;
+using std::string;
+
+QPictureIO StaticPicture;
+
+namespace lyx {
+namespace graphics {
+
+/// Access to this class is through this static method.
+Image::ImagePtr QLImage::newImage()
+{
+ ImagePtr ptr;
+ ptr.reset(new QLImage);
+ return ptr;
+}
+
+
+/// Return the list of loadable formats.
+Image::FormatList QLImage::loadableFormats()
+{
+ static FormatList fmts;
+
+ if (!fmts.empty())
+ return fmts;
+
+ // The formats recognised by LyX
+ Formats::const_iterator begin = formats.begin();
+ Formats::const_iterator end = formats.end();
+
+
+// LYXERR(Debug::GRAPHICS)
+// << "D:/msys/home/yns/src/lyx-devel/lib/images/banner.png mis of format: "
+// << fromqstr(Pic.pictureFormat("D:/msys/home/yns/src/lyx-devel/lib/images/banner.png"))
+// << endl;
+// if (Pic.pictureFormat("D:/msys/home/yns/src/lyx-devel/lib/images/banner.png"))
+// LYXERR(Debug::GRAPHICS)
+// << "pictureFormat not returned NULL\n" << endl;
+// << "Supported formats are: " << Pic.inputFormats() << endl;
+
+ QList<QByteArray> qt_formats = QImageReader::supportedImageFormats ();
+
+ LYXERR(Debug::GRAPHICS)
+ << "\nThe image loader can load the following directly:\n";
+
+ if (qt_formats.empty())
+ LYXERR(Debug::GRAPHICS)
+ << "\nQt4 Problem: No Format available!" << endl;
+
+ for (QList<QByteArray>::const_iterator it =qt_formats.begin(); it != qt_formats.end(); ++it) {
+
+ LYXERR(Debug::GRAPHICS) << (const char *) *it << ", ";
+
+ string ext = ascii_lowercase((const char *) *it);
+
+ // special case
+ if (ext == "jpeg")
+ ext = "jpg";
+
+ Formats::const_iterator fit =
+ find_if(begin, end,
+ bind(equal_to<string>(),
+ bind(&Format::extension, _1),
+ ext));
+ if (fit != end)
+ fmts.push_back(fit->name());
+ }
+
+ if (lyxerr.debugging()) {
+ LYXERR(Debug::GRAPHICS)
+ << "\nOf these, LyX recognises the following formats:\n";
+
+ FormatList::const_iterator fbegin = fmts.begin();
+ FormatList::const_iterator fend = fmts.end();
+ for (FormatList::const_iterator fit = fbegin; fit != fend; ++fit) {
+ if (fit != fbegin)
+ LYXERR(Debug::GRAPHICS) << ", ";
+ LYXERR(Debug::GRAPHICS) << *fit;
+ }
+ LYXERR(Debug::GRAPHICS) << '\n' << endl;
+ }
+
+ return fmts;
+}
+
+
+QLImage::QLImage()
+ : Image()
+{
+}
+
+
+QLImage::QLImage(QLImage const & other)
+ : Image(other), original_(other.original_),
+ transformed_(other.transformed_),
+ transformed_pixmap_(other.transformed_pixmap_)
+{}
+
+
+Image * QLImage::clone_impl() const
+{
+ return new QLImage(*this);
+}
+
+
+unsigned int QLImage::getWidth_impl() const
+{
+ return transformed_.width();
+}
+
+
+unsigned int QLImage::getHeight_impl() const
+{
+ return transformed_.height();
+}
+
+
+void QLImage::load_impl(support::FileName const & filename)
+{
+ if (!original_.isNull()) {
+ LYXERR(Debug::GRAPHICS)
+ << "Image is loaded already!" << endl;
+ finishedLoading(false);
+ return;
+ }
+
+ if (!original_.load(toqstr(filename.absFilename()))) {
+ LYXERR(Debug::GRAPHICS)
+ << "Unable to open image" << endl;
+ finishedLoading(false);
+ return;
+ }
+ transformed_ = original_;
+ finishedLoading(true);
+}
+
+
+namespace {
+
+// This code is taken from KImageEffect::toGray
+QImage & toGray(QImage & img)
+{
+ if (img.width() == 0 || img.height() == 0)
+ return img;
+
+ int const pixels = img.depth() > 8 ?
+ img.width() * img.height() : img.numColors();
+
+ unsigned int *data = img.depth() > 8 ?
+ reinterpret_cast<unsigned int *>(img.bits()) :
+ reinterpret_cast<unsigned int *>(&img.colorTable()[0]);
+
+ for(int i = 0; i < pixels; ++i){
+ int const val = qGray(data[i]);
+ data[i] = qRgba(val, val, val, qAlpha(data[i]));
+ }
+ return img;
+}
+
+} // namespace anon
+
+
+bool QLImage::setPixmap_impl(Params const & params)
+{
+ if (original_.isNull() || params.display == NoDisplay)
+ return false;
+
+ switch (params.display) {
+ case GrayscaleDisplay: {
+ toGray(transformed_);
+ break;
+ }
+
+ case MonochromeDisplay: {
+ transformed_.convertToFormat(transformed_.format(), Qt::MonoOnly);
+ break;
+ }
+
+ default:
+ break;
+ }
+
+ transformed_pixmap_ = QPixmap::fromImage(transformed_);
+ return true;
+}
+
+
+void QLImage::clip_impl(Params const & params)
+{
+ if (transformed_.isNull())
+ return;
+
+ if (params.bb.empty())
+ // No clipping is necessary.
+ return;
+
+ int const new_width = params.bb.xr - params.bb.xl;
+ int const new_height = params.bb.yt - params.bb.yb;
+
+ // No need to check if the width, height are > 0 because the
+ // Bounding Box would be empty() in this case.
+ if (new_width > original_.width() || new_height > original_.height()) {
+ // Bounds are invalid.
+ return;
+ }
+
+ if (new_width == original_.width() && new_height == original_.height())
+ return;
+
+ int const xoffset_l = params.bb.xl;
+ int const yoffset_t = (original_.height() > int(params.bb.yt) ?
+ original_.height() - params.bb.yt : 0);
+
+ transformed_ = original_.copy(xoffset_l, yoffset_t,
+ new_width, new_height);
+}
+
+
+void QLImage::rotate_impl(Params const & params)
+{
+ if (transformed_.isNull())
+ return;
+
+ if (!params.angle)
+ return;
+
+ QMatrix m;
+ m.rotate(-params.angle);
+
+ transformed_ = transformed_.transformed(m);
+}
+
+
+void QLImage::scale_impl(Params const & params)
+{
+ if (transformed_.isNull())
+ return;
+
+ unsigned int width;
+ unsigned int height;
+ boost::tie(width, height) = getScaledDimensions(params);
+
+ if (width == getWidth() && height == getHeight())
+ return;
+
+ QMatrix m;
+ m.scale(double(width) / getWidth(), double(height) / getHeight());
+ transformed_ = transformed_.transformed(m);
+}
+
+} // namespace graphics
+} // lyx
--- /dev/null
+// -*- C++ -*-
+/**
+ * \file GuiImage.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Angus Leeming
+ * \author John Levon
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#ifndef QLIMAGE_H
+#define QLIMAGE_H
+
+
+#include "graphics/GraphicsImage.h"
+
+#include <qimage.h>
+//Added by qt3to4:
+#include <QPixmap>
+
+namespace lyx {
+namespace graphics {
+
+class QLImage : public Image {
+public:
+ /// Access to this class is through this static method.
+ static ImagePtr newImage();
+
+ /// Return the list of loadable formats.
+ static FormatList loadableFormats();
+
+ /// Retrieve the buffered pixmap.
+ QPixmap const & qpixmap() const { return transformed_pixmap_; }
+
+ /// Retrieve the buffered pixmap.
+ QImage const & qimage() const { return transformed_; }
+
+private:
+ /// Create a copy
+ virtual Image * clone_impl() const;
+ /// Get the image width
+ virtual unsigned int getWidth_impl() const;
+ /// Get the image height
+ virtual unsigned int getHeight_impl() const;
+ // FIXME Is the image drawable ?
+ virtual bool isDrawable_impl() const { return true; }
+ /**
+ * Load the image file into memory.
+ * The process is asynchronous, so this method starts the loading.
+ * When finished, the Image::finishedLoading signal is emitted.
+ */
+ virtual void load_impl(support::FileName const & filename);
+ /**
+ * Finishes the process of modifying transformed_, using
+ * \c params to decide on color, grayscale etc.
+ * \returns true if successful.
+ */
+ virtual bool setPixmap_impl(Params const & params);
+ /// Clip the image using params.
+ virtual void clip_impl(Params const & params);
+ /// Rotate the image using params.
+ virtual void rotate_impl(Params const & params);
+ /// Scale the image using params.
+ virtual void scale_impl(Params const & params);
+
+ /// Access to the class is through newImage() and clone.
+ QLImage();
+ ///
+ QLImage(QLImage const &);
+
+ /// The original loaded image.
+ QImage original_;
+
+ /// The transformed image for display.
+ QImage transformed_;
+ /// Buffer the pixmap itself
+ QPixmap transformed_pixmap_;
+};
+
+} // namespace graphics
+} // namespace lyx
+
+#endif // QLIMAGE_H
int id = 0;
while (views_.find(id) != views_.end())
id++;
- views_.insert(std::pair<int, GuiView *>(id, new GuiView(id)));
+ views_.insert(std::pair<int, GuiViewBase *>(id, new GuiViewBase(id)));
updateIds(views_, view_ids_);
return *views_[id];
}
BOOST_ASSERT(views_.find(id) != views_.end());
BOOST_ASSERT(views_[id]);
- std::map<int, GuiView *>::iterator it;
+ std::map<int, GuiViewBase *>::iterator it;
for (it = views_.begin(); it != views_.end(); ++it) {
if (it->first == id) {
views_.erase(id);
return true;
}
- std::map<int, GuiView*> const cmap = views_;
- std::map<int, GuiView*>::const_iterator it;
+ std::map<int, GuiViewBase*> const cmap = views_;
+ std::map<int, GuiViewBase*>::const_iterator it;
for (it = cmap.begin(); it != cmap.end(); ++it)
{
// TODO: return false when close event was ignored
namespace lyx {
namespace frontend {
-class GuiView;
+class GuiViewBase;
class LyXView;
/**
* The GuiImplementation class is the interface to all Qt4 components.
*/
-class GuiImplementation: public QObject, public Gui
+class GuiImplementation : public QObject, public Gui
{
Q_OBJECT
* object is handled by Qt when the view is closed
* \sa Qt::WA_DeleteOnClose attribute.
*/
- std::map<int, GuiView *> views_;
+ std::map<int, GuiViewBase *> views_;
};
} // namespace frontend
--- /dev/null
+/**
+ * \file GuiInclude.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author John Levon
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "support/os.h"
+#include "support/lstrings.h"
+
+#include "GuiInclude.h"
+
+#include "CheckedLineEdit.h"
+#include "Qt2BC.h"
+#include "qt_helpers.h"
+
+#include "LyXRC.h"
+
+#include "insets/InsetListingsParams.h"
+#include "controllers/ControlInclude.h"
+
+#include <QPushButton>
+#include <QCheckBox>
+#include <QCloseEvent>
+#include <QLineEdit>
+
+using std::string;
+using std::vector;
+
+using lyx::support::os::internal_path;
+using lyx::support::prefixIs;
+using lyx::support::getStringFromVector;
+using lyx::support::getVectorFromString;
+
+namespace lyx {
+namespace frontend {
+
+/////////////////////////////////////////////////////////////////////
+//
+// GuiIncludeDialog
+//
+/////////////////////////////////////////////////////////////////////
+
+GuiIncludeDialog::GuiIncludeDialog(GuiInclude * form)
+ : form_(form)
+{
+ setupUi(this);
+ connect(okPB, SIGNAL(clicked()), form, SLOT(slotOK()));
+ connect(closePB, SIGNAL(clicked()), form, SLOT(slotClose()));
+
+ connect(visiblespaceCB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
+ connect(filenameED, SIGNAL(textChanged(const QString &)),
+ this, SLOT(change_adaptor()));
+ connect(editPB, SIGNAL(clicked()), this, SLOT(editClicked()));
+ connect(browsePB, SIGNAL(clicked()), this, SLOT(browseClicked()));
+ connect(typeCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
+ connect(typeCO, SIGNAL(activated(int)), this, SLOT(typeChanged(int)));
+ connect(previewCB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
+ connect(captionLE, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
+ connect(labelLE, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
+ connect(listingsED, SIGNAL(textChanged()), this, SLOT(change_adaptor()));
+ connect(listingsED, SIGNAL(textChanged()), this, SLOT(set_listings_msg()));
+ connect(bypassCB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
+ connect(bypassCB, SIGNAL(clicked()), this, SLOT(set_listings_msg()));
+
+ setFocusProxy(filenameED);
+}
+
+
+void GuiIncludeDialog::show()
+{
+ QDialog::show();
+}
+
+
+void GuiIncludeDialog::change_adaptor()
+{
+ form_->changed();
+}
+
+
+docstring GuiIncludeDialog::validate_listings_params()
+{
+ // use a cache here to avoid repeated validation
+ // of the same parameters
+ static string param_cache = string();
+ static docstring msg_cache = docstring();
+
+ if (typeCO->currentIndex() != 3 || bypassCB->isChecked())
+ return docstring();
+
+ string params = fromqstr(listingsED->toPlainText());
+ if (params != param_cache) {
+ param_cache = params;
+ msg_cache = InsetListingsParams(params).validate();
+ }
+ return msg_cache;
+}
+
+
+void GuiIncludeDialog::set_listings_msg()
+{
+ static bool isOK = true;
+ docstring msg = validate_listings_params();
+ if (msg.empty()) {
+ if (isOK)
+ return;
+ isOK = true;
+ listingsTB->setPlainText(
+ qt_("Input listing parameters on the right. Enter ? for a list of parameters."));
+ } else {
+ isOK = false;
+ listingsTB->setPlainText(toqstr(msg));
+ }
+}
+
+
+void GuiIncludeDialog::closeEvent(QCloseEvent * e)
+{
+ form_->slotWMHide();
+ e->accept();
+}
+
+
+void GuiIncludeDialog::typeChanged(int v)
+{
+ switch (v) {
+ //case Include
+ case 0:
+ visiblespaceCB->setEnabled(false);
+ visiblespaceCB->setChecked(false);
+ previewCB->setEnabled(false);
+ previewCB->setChecked(false);
+ listingsGB->setEnabled(false);
+ break;
+ //case Input
+ case 1:
+ visiblespaceCB->setEnabled(false);
+ visiblespaceCB->setChecked(false);
+ previewCB->setEnabled(true);
+ listingsGB->setEnabled(false);
+ break;
+ //case listings
+ case 3:
+ visiblespaceCB->setEnabled(false);
+ visiblespaceCB->setChecked(false);
+ previewCB->setEnabled(false);
+ previewCB->setChecked(false);
+ listingsGB->setEnabled(true);
+ break;
+ //case Verbatim
+ default:
+ visiblespaceCB->setEnabled(true);
+ previewCB->setEnabled(false);
+ previewCB->setChecked(false);
+ listingsGB->setEnabled(false);
+ break;
+ }
+ //see this thread
+ // http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg118471.html
+ //for the reason this is here.
+ okPB->setDefault(true);
+}
+
+
+void GuiIncludeDialog::editClicked()
+{
+ form_->edit();
+}
+
+
+void GuiIncludeDialog::browseClicked()
+{
+ form_->browse();
+}
+
+
+/////////////////////////////////////////////////////////////////////
+//
+// GuiInclude
+//
+/////////////////////////////////////////////////////////////////////
+
+
+typedef QController<ControlInclude, GuiView<GuiIncludeDialog> > IncludeBase;
+
+
+GuiInclude::GuiInclude(Dialog & parent)
+ : IncludeBase(parent, _("Child Document"))
+{}
+
+
+void GuiInclude::build_dialog()
+{
+ dialog_.reset(new GuiIncludeDialog(this));
+
+ bcview().setOK(dialog_->okPB);
+ bcview().setCancel(dialog_->closePB);
+ bcview().addReadOnly(dialog_->filenameED);
+ bcview().addReadOnly(dialog_->browsePB);
+ bcview().addReadOnly(dialog_->visiblespaceCB);
+ bcview().addReadOnly(dialog_->typeCO);
+ bcview().addReadOnly(dialog_->listingsED);
+
+ addCheckedLineEdit(bcview(), dialog_->filenameED, dialog_->filenameLA);
+}
+
+
+void GuiInclude::update_contents()
+{
+ InsetCommandParams const & params = controller().params();
+
+ dialog_->filenameED->setText(toqstr(params["filename"]));
+
+ dialog_->visiblespaceCB->setChecked(false);
+ dialog_->visiblespaceCB->setEnabled(false);
+ dialog_->previewCB->setChecked(false);
+ dialog_->previewCB->setEnabled(false);
+ dialog_->listingsGB->setEnabled(false);
+ dialog_->captionLE->clear();
+ dialog_->labelLE->clear();
+ dialog_->listingsED->clear();
+ dialog_->listingsTB->setPlainText(
+ qt_("Input listing parameters on the right. Enter ? for a list of parameters."));
+
+ string cmdname = controller().params().getCmdName();
+ if (cmdname != "include" &&
+ cmdname != "verbatiminput" &&
+ cmdname != "verbatiminput*" &&
+ cmdname != "lstinputlisting")
+ cmdname = "input";
+
+ if (cmdname == "include") {
+ dialog_->typeCO->setCurrentIndex(0);
+
+ } else if (cmdname == "input") {
+ dialog_->typeCO->setCurrentIndex(1);
+ dialog_->previewCB->setEnabled(true);
+ dialog_->previewCB->setChecked(params.preview());
+
+ } else if (cmdname == "verbatiminput*") {
+ dialog_->typeCO->setCurrentIndex(2);
+ dialog_->visiblespaceCB->setEnabled(true);
+ dialog_->visiblespaceCB->setChecked(true);
+
+ } else if (cmdname == "verbatiminput") {
+ dialog_->typeCO->setCurrentIndex(2);
+ dialog_->visiblespaceCB->setEnabled(true);
+
+ } else if (cmdname == "lstinputlisting") {
+ dialog_->typeCO->setCurrentIndex(3);
+ dialog_->listingsGB->setEnabled(true);
+ dialog_->listingsED->setEnabled(true);
+ InsetListingsParams par(params.getOptions());
+ // extract caption and label and put them into their respective editboxes
+ vector<string> pars = getVectorFromString(par.separatedParams(), "\n");
+ for (vector<string>::iterator it = pars.begin();
+ it != pars.end(); ++it) {
+ if (prefixIs(*it, "caption=")) {
+ string cap = it->substr(8);
+ if (cap[0] == '{' && cap[cap.size()-1] == '}') {
+ dialog_->captionLE->setText(toqstr(cap.substr(1, cap.size()-2)));
+ *it = "";
+ }
+ } else if (prefixIs(*it, "label=")) {
+ string lbl = it->substr(6);
+ if (lbl[0] == '{' && lbl[lbl.size()-1] == '}') {
+ dialog_->labelLE->setText(toqstr(lbl.substr(1, lbl.size()-2)));
+ *it = "";
+ }
+ }
+ }
+ // the rest is put to the extra edit box.
+ string extra = getStringFromVector(pars);
+ dialog_->listingsED->setPlainText(toqstr(InsetListingsParams(extra).separatedParams()));
+ }
+}
+
+
+void GuiInclude::apply()
+{
+ InsetCommandParams params = controller().params();
+
+ params["filename"] = from_utf8(internal_path(fromqstr(dialog_->filenameED->text())));
+ params.preview(dialog_->previewCB->isChecked());
+
+ int const item = dialog_->typeCO->currentIndex();
+ if (item == 0) {
+ params.setCmdName("include");
+ } else if (item == 1) {
+ params.setCmdName("input");
+ } else if (item == 3) {
+ params.setCmdName("lstinputlisting");
+ // the parameter string should have passed validation
+ InsetListingsParams par(fromqstr(dialog_->listingsED->toPlainText()));
+ string caption = fromqstr(dialog_->captionLE->text());
+ string label = fromqstr(dialog_->labelLE->text());
+ if (!caption.empty())
+ par.addParam("caption", "{" + caption + "}");
+ if (!label.empty())
+ par.addParam("label", "{" + label + "}");
+ params.setOptions(par.params());
+ } else {
+ if (dialog_->visiblespaceCB->isChecked())
+ params.setCmdName("verbatiminput*");
+ else
+ params.setCmdName("verbatiminput");
+ }
+ controller().setParams(params);
+}
+
+
+void GuiInclude::browse()
+{
+ ControlInclude::Type type;
+
+ int const item = dialog_->typeCO->currentIndex();
+ if (item == 0)
+ type = ControlInclude::INCLUDE;
+ else if (item == 1)
+ type = ControlInclude::INPUT;
+ else if (item == 2)
+ type = ControlInclude::VERBATIM;
+ else
+ type = ControlInclude::LISTINGS;
+
+ docstring const & name =
+ controller().browse(qstring_to_ucs4(dialog_->filenameED->text()), type);
+ if (!name.empty())
+ dialog_->filenameED->setText(toqstr(name));
+}
+
+
+void GuiInclude::edit()
+{
+ if (isValid()) {
+ string const file = fromqstr(dialog_->filenameED->text());
+ slotOK();
+ controller().edit(file);
+ }
+}
+
+
+bool GuiInclude::isValid()
+{
+ return !dialog_->filenameED->text().isEmpty() &&
+ dialog_->validate_listings_params().empty();
+}
+
+} // namespace frontend
+} // namespace lyx
+
+#include "GuiInclude_moc.cpp"
--- /dev/null
+// -*- C++ -*-
+/**
+ * \file GuiInclude.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author John Levon
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#ifndef QINCLUDE_H
+#define QINCLUDE_H
+
+#include "GuiDialogView.h"
+
+#include "ui_IncludeUi.h"
+
+#include <QDialog>
+
+namespace lyx {
+namespace frontend {
+
+class GuiInclude;
+
+class GuiIncludeDialog : public QDialog, public Ui::IncludeUi {
+ Q_OBJECT
+public:
+ GuiIncludeDialog(GuiInclude * form);
+
+ void updateLists();
+
+ virtual void show();
+ /// validate listings parameters and return an error message, if any
+ docstring validate_listings_params();
+protected Q_SLOTS:
+ virtual void change_adaptor();
+ virtual void editClicked();
+ virtual void browseClicked();
+ virtual void typeChanged(int v);
+ /// AFAIK, QValidator only works for QLineEdit so
+ /// I have to validate listingsED (QTextEdit) manually.
+ /// This function displays a hint or error message returned by
+ /// validate_listings_params
+ void set_listings_msg();
+protected:
+ virtual void closeEvent(QCloseEvent * e);
+private:
+ GuiInclude * form_;
+};
+
+
+class ControlInclude;
+
+///
+class GuiInclude : public QController<ControlInclude, GuiView<GuiIncludeDialog> >
+{
+public:
+ ///
+ friend class GuiIncludeDialog;
+ ///
+ GuiInclude(Dialog &);
+protected:
+ virtual bool isValid();
+private:
+ /// Apply changes
+ virtual void apply();
+ /// update
+ virtual void update_contents();
+ /// build the dialog
+ virtual void build_dialog();
+
+ /// edit the child document, .lyx file will be opened in lyx
+ /// other formats will be edited by external applications.
+ void edit();
+
+ /// browse for a file
+ void browse();
+};
+
+} // namespace frontend
+} // namespace lyx
+
+#endif // QINCLUDE_H
--- /dev/null
+/**
+ * \file GuiIndex.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author John Levon
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "debug.h"
+#include "ControlCommand.h"
+#include "qt_helpers.h"
+
+#include "GuiIndex.h"
+#include "Qt2BC.h"
+#include "ButtonController.h"
+
+#include <QLabel>
+#include <QPushButton>
+#include <QLineEdit>
+#include <QWhatsThis>
+#include <QCloseEvent>
+
+
+using std::string;
+
+/////////////////////////////////////////////////////////////////////
+//
+// GuiIndexDialog
+//
+/////////////////////////////////////////////////////////////////////
+
+namespace lyx {
+namespace frontend {
+
+GuiIndexDialog::GuiIndexDialog(GuiIndex * form)
+ : form_(form)
+{
+ setupUi(this);
+
+ connect(okPB, SIGNAL(clicked()), form, SLOT(slotOK()));
+ connect(closePB, SIGNAL(clicked()), form, SLOT(slotClose()));
+ connect( keywordED, SIGNAL(textChanged(const QString &)),
+ this, SLOT(change_adaptor()));
+
+ setFocusProxy(keywordED);
+
+ keywordED->setWhatsThis( qt_(
+ "The format of the entry in the index.\n"
+ "\n"
+ "An entry can be specified as a sub-entry of\n"
+ "another with \"!\":\n"
+ "\n"
+ "cars!mileage\n"
+ "\n"
+ "You can cross-refer to another entry like so:\n"
+ "\n"
+ "cars!mileage|see{economy}\n"
+ "\n"
+ "For further details refer to the local LaTeX\n"
+ "documentation.\n")
+ );
+}
+
+
+void GuiIndexDialog::change_adaptor()
+{
+ form_->changed();
+}
+
+
+void GuiIndexDialog::reject()
+{
+ form_->slotClose();
+}
+
+
+void GuiIndexDialog::closeEvent(QCloseEvent * e)
+{
+ form_->slotWMHide();
+ e->accept();
+}
+
+
+/////////////////////////////////////////////////////////////////////
+//
+// GuiIndex
+//
+/////////////////////////////////////////////////////////////////////
+
+
+typedef QController<ControlCommand, GuiView<GuiIndexDialog> > IndexBase;
+
+GuiIndex::GuiIndex(Dialog & parent, docstring const & title, QString const & label)
+ : IndexBase(parent, title), label_(label)
+{
+}
+
+
+void GuiIndex::build_dialog()
+{
+ dialog_.reset(new GuiIndexDialog(this));
+
+ dialog_->keywordLA->setText(label_);
+
+ bcview().setOK(dialog_->okPB);
+ bcview().setCancel(dialog_->closePB);
+ bcview().addReadOnly(dialog_->keywordED);
+}
+
+
+void GuiIndex::update_contents()
+{
+ docstring const contents = controller().params()["name"];
+ dialog_->keywordED->setText(toqstr(contents));
+
+ bc().valid(!contents.empty());
+}
+
+
+void GuiIndex::apply()
+{
+ controller().params()["name"] = qstring_to_ucs4(dialog_->keywordED->text());
+}
+
+
+bool GuiIndex::isValid()
+{
+ return !dialog_->keywordED->text().isEmpty();
+}
+
+} // namespace frontend
+} // namespace lyx
+
+#include "GuiIndex_moc.cpp"
--- /dev/null
+// -*- C++ -*-
+/**
+ * \file GuiIndex.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author John Levon
+ * \author Kalle Dalheimer
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#ifndef QINDEX_H
+#define QINDEX_H
+
+#include "GuiDialogView.h"
+#include "ui_IndexUi.h"
+
+#include <QDialog>
+#include <QCloseEvent>
+
+namespace lyx {
+namespace frontend {
+
+class GuiIndex;
+
+class GuiIndexDialog : public QDialog, public Ui::IndexUi {
+ Q_OBJECT
+public:
+ GuiIndexDialog(GuiIndex * form);
+
+protected Q_SLOTS:
+ virtual void change_adaptor();
+ virtual void reject();
+protected:
+ virtual void closeEvent(QCloseEvent * e);
+private:
+ GuiIndex * form_;
+};
+
+
+class ControlCommand;
+
+class GuiIndex :
+ public QController<ControlCommand, GuiView<GuiIndexDialog> >
+{
+public:
+ friend class GuiIndexDialog;
+
+ GuiIndex(Dialog &, docstring const & title, QString const & label);
+protected:
+ virtual bool isValid();
+private:
+ /// Apply changes
+ virtual void apply();
+ /// update
+ virtual void update_contents();
+ /// build the dialog
+ virtual void build_dialog();
+
+ ///
+ QString const label_;
+};
+
+} // namespace frontend
+} // namespace lyx
+
+#endif // QINDEX_H
--- /dev/null
+/**
+ * \file qt4/KeySymbolFactory.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Asger & Jürgen
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "frontends/KeySymbol.h"
+
+#include "GuiKeySymbol.h"
+
+#include "qlkey.h"
+#include "qt_helpers.h"
+
+#include "debug.h"
+
+#include "support/lstrings.h"
+#include "support/environment.h"
+#include "support/unicode.h"
+
+#include "Encoding.h"
+#include "Language.h"
+
+#include <QKeyEvent>
+#include <QKeySequence>
+#include <QEvent>
+#include <QTextCodec>
+
+#include <map>
+
+
+namespace lyx {
+
+using std::endl;
+using std::string;
+using std::map;
+using lyx::support::contains;
+using lyx::support::getEnv;
+
+
+KeySymbol * createKeySymbol()
+{
+ return new GuiKeySymbol;
+}
+
+
+static char const encode(string const & encoding, QString const & str)
+{
+ typedef map<string, QTextCodec *> EncodingMap;
+ EncodingMap encoding_map;
+
+ QTextCodec * codec = 0;
+
+ EncodingMap::const_iterator cit = encoding_map.find(encoding);
+ if (cit == encoding_map.end()) {
+ LYXERR(Debug::KEY) << "Unrecognised encoding '" << encoding
+ << "'." << endl;
+ codec = encoding_map.find("")->second;
+ } else {
+ codec = cit->second;
+ }
+
+ if (!codec) {
+ LYXERR(Debug::KEY) << "No codec for encoding '" << encoding
+ << "' found." << endl;
+ return 0;
+ }
+
+ LYXERR(Debug::KEY) << "Using codec " << fromqstr(codec->name()) << endl;
+
+ if (!codec->canEncode(str)) {
+ LYXERR(Debug::KEY) << "Oof. Can't encode the text !" << endl;
+ return 0;
+ }
+
+ return codec->fromUnicode(str).data()[0];
+}
+
+
+GuiKeySymbol::GuiKeySymbol()
+ : KeySymbol(), key_(0)
+{
+}
+
+
+void GuiKeySymbol::set(QKeyEvent * ev)
+{
+ key_ = ev->key();
+ if (ev->text().isNull()) {
+ LYXERR(Debug::KEY) << "keyevent has isNull() text !" << endl;
+ text_ = "";
+ return;
+ }
+ text_ = ev->text();
+ LYXERR(Debug::KEY) << "Setting key to " << key_ << ", " << fromqstr(text_) << endl;
+}
+
+
+void GuiKeySymbol::init(string const & symbolname)
+{
+ key_ = string_to_qkey(symbolname);
+ text_ = toqstr(symbolname);
+ LYXERR(Debug::KEY) << "Init key to " << key_ << ", " << fromqstr(text_) << endl;
+}
+
+
+bool GuiKeySymbol::isOK() const
+{
+ bool const ok(!(text_.isEmpty() && key_ == Qt::Key_unknown));
+ LYXERR(Debug::KEY) << "isOK is " << ok << endl;
+ return ok;
+}
+
+
+bool GuiKeySymbol::isModifier() const
+{
+ bool const mod(q_is_modifier(key_));
+ LYXERR(Debug::KEY) << "isMod is " << mod << endl;
+ return mod;
+}
+
+
+string GuiKeySymbol::getSymbolName() const
+{
+ string sym(qkey_to_string(key_));
+
+ // e.g. A-Za-z, and others
+ if (sym.empty())
+ sym = fromqstr(text_);
+
+ return sym;
+}
+
+
+char_type GuiKeySymbol::getUCSEncoded() const
+{
+ if (text_.isEmpty())
+ return 0;
+
+ // UTF16 has a maximum of two characters.
+ BOOST_ASSERT(text_.size() <= 2);
+
+ if (lyxerr.debugging() && text_.size() > 1) {
+ // We don't know yet how well support the full ucs4 range.
+ LYXERR(Debug::KEY) << "GuiKeySymbol::getUCSEncoded()" << endl;
+ for (int i = 0; i < text_.size(); ++i) {
+ LYXERR(Debug::KEY) << "char " << i << ": "
+ << text_[i].unicode() << endl;
+ }
+ }
+
+ // Only one UCS4 character at the end.
+ docstring ucs4_text = qstring_to_ucs4(text_);
+ return ucs4_text[0];
+}
+
+
+docstring const GuiKeySymbol::print(key_modifier::state mod, bool forgui) const
+{
+ int tmpkey = key_;
+
+ if (mod & key_modifier::shift)
+ tmpkey += Qt::SHIFT;
+ if (mod & key_modifier::ctrl)
+ tmpkey += Qt::CTRL;
+ if (mod & key_modifier::alt)
+ tmpkey += Qt::ALT;
+
+ QKeySequence seq(tmpkey);
+
+ return qstring_to_ucs4(seq.toString(forgui ? QKeySequence::NativeText
+ : QKeySequence::PortableText));
+}
+
+
+bool GuiKeySymbol::isText() const
+{
+ if (text_.isEmpty()) {
+ LYXERR(Debug::KEY) << "text_ empty, isText() == false" << endl;
+ return false;
+ }
+
+ return true;
+}
+
+
+bool GuiKeySymbol::operator==(KeySymbol const & ks) const
+{
+ GuiKeySymbol const & qks = static_cast<GuiKeySymbol const &>(ks);
+
+ // we do not have enough info for a fair comparison, so return
+ // false. This works out OK because unknown text from Qt will
+ // get inserted anyway after the isText() check
+ if (key_ == Qt::Key_unknown || qks.key_ == Qt::Key_unknown)
+ return false;
+
+ return key_ == qks.key_;
+}
+
+
+key_modifier::state q_key_state(Qt::KeyboardModifiers state)
+{
+ key_modifier::state k = key_modifier::none;
+ if (state & Qt::ControlModifier)
+ k |= key_modifier::ctrl;
+ if (state & Qt::ShiftModifier)
+ k |= key_modifier::shift;
+ if (state & Qt::AltModifier || state & Qt::MetaModifier)
+ k |= key_modifier::alt;
+ return k;
+}
+
+} // namespace lyx
--- /dev/null
+// -*- C++ -*-
+/**
+ * \file GuiKeySymbol.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Asger and Jürgen
+ * \author John Levon
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#ifndef QLYXKEYSYM_H
+#define QLYXKEYSYM_H
+
+#include "frontends/KeySymbol.h"
+
+#include <QString>
+#include <QKeyEvent>
+
+
+class QKeyEvent;
+
+namespace lyx {
+
+/**
+ * Qt-specific key press.
+ *
+ * This is some really sick stuff.
+ */
+class GuiKeySymbol : public KeySymbol {
+public:
+ GuiKeySymbol();
+
+ virtual ~GuiKeySymbol() {}
+
+ /// .
+ /// inlined out because of profiling results under linux when
+ /// opening a document.
+ inline bool operator==(KeySymbol const& ks) const;
+
+ /// delayed constructor
+ void set(QKeyEvent * ev);
+
+ /// set from a LyX symbolic name
+ virtual void init(std::string const & symbolname);
+
+ /// Is this a valid key?
+ virtual bool isOK() const;
+
+ /// Is this a modifier key only?
+ virtual bool isModifier() const;
+
+ /// return the LyX symbolic name
+ virtual std::string getSymbolName() const;
+
+ /// Is this normal insertable text ? (last ditch attempt only)
+ virtual bool isText() const;
+
+ /**
+ * Return the value of the keysym into the UCS-4 encoding.
+ * This converts the KeySymbol to a 32-bit encoded character.
+ */
+ virtual char_type getUCSEncoded() const;
+
+ /**
+ * Return a human-readable version of a key+modifier pair.
+ * This will be the GUI version (translated and with special
+ * characters for Mac OS X) when \c forgui is true.
+ */
+ virtual docstring const print(key_modifier::state mod, bool forgui) const;
+
+ ///
+ int key() const { return key_; }
+
+private:
+ /// the Qt sym value
+ int key_;
+ /// the event string value
+ QString text_;
+};
+
+/// return the LyX key state from Qt's
+key_modifier::state q_key_state(Qt::KeyboardModifiers state);
+
+} // namespace lyx
+
+#endif // QLYXKEYSYM_H
--- /dev/null
+/**
+ * \file GuiListings.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Bo Peng
+ * \author Jürgen Spitzmüller
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "GuiListings.h"
+#include "Qt2BC.h"
+#include "qt_helpers.h"
+#include "controllers/ControlListings.h"
+#include "insets/InsetListingsParams.h"
+#include "debug.h"
+
+#include "support/convert.h"
+#include "support/lstrings.h"
+
+#include <QLineEdit>
+#include <QCloseEvent>
+#include <QPushButton>
+#include <QValidator>
+#include <QRegExpValidator>
+
+
+using std::string;
+using std::vector;
+using lyx::support::findToken;
+using lyx::support::getVectorFromString;
+using lyx::support::getStringFromVector;
+using lyx::support::prefixIs;
+using lyx::support::suffixIs;
+using lyx::support::contains;
+
+namespace lyx {
+namespace frontend {
+
+/////////////////////////////////////////////////////////////////////
+//
+// GuiListingsDialog
+//
+/////////////////////////////////////////////////////////////////////
+
+
+char const * languages[] =
+{ "no language", "ABAP", "ACSL", "Ada", "ALGOL", "Assembler", "Awk", "bash", "Basic", "C",
+ "C++", "Caml", "Clean", "Cobol", "Comal 80", "command.com", "Comsol", "csh", "Delphi",
+ "Eiffel", "Elan", "Euphoria", "Fortran", "Gnuplot", "Haskell", "HTML", "IDL", "inform",
+ "Java", "JVMIS", "ksh", "Lingo", "Lisp", "Logo", "make", "Mathematica", "Matlab", "Mercury",
+ "MetaPost", "Miranda", "ML", "Modula-2", "MuPAD", "NASTRAN", "Oberon-2", "OCL", "Octave",
+ "Oz", "Pascal", "Perl", "PHP", "PL/I", "Plasm", "PostScript", "POV", "Prolog", "Promela",
+ "PSTricks", "Python", "R", "Reduce", "Rexx", "RSL", "Ruby", "S", "SAS", "Scilab", "sh",
+ "SHELXL", "Simula", "tcl", "SPARQL", "SQL", "tcl", "TeX", "VBScript", "Verilog", "VHDL",
+ "VRML", "XML", "XSLT", "" };
+
+
+char const * languages_gui[] =
+{ N_("No language"), "ABAP", "ACSL", "Ada", "ALGOL", "Assembler", "Awk", "bash", "Basic",
+ "C", "C++", "Caml", "Clean", "Cobol", "Comal 80", "command.com", "Comsol", "csh", "Delphi",
+ "Eiffel", "Elan", "Euphoria", "Fortran", "Gnuplot", "Haskell", "HTML", "IDL", "inform",
+ "Java", "JVMIS", "ksh", "Lingo", "Lisp", "Logo", "make", "Mathematica", "Matlab", "Mercury",
+ "MetaPost", "Miranda", "ML", "Modula-2", "MuPAD", "NASTRAN", "Oberon-2", "OCL", "Octave",
+ "Oz", "Pascal", "Perl", "PHP", "PL/I", "Plasm", "PostScript", "POV", "Prolog", "Promela",
+ "PSTricks", "Python", "R", "Reduce", "Rexx", "RSL", "Ruby", "S", "SAS", "Scilab", "sh",
+ "SHELXL", "Simula", "tcl", "SPARQL", "SQL", "tcl", "TeX", "VBScript", "Verilog", "VHDL",
+ "VRML", "XML", "XSLT", "" };
+
+
+struct dialect_info {
+ /// the dialect
+ char const * dialect;
+ /// the associated language
+ char const * language;
+ /// representation of the dialect in the gui
+ char const * gui;
+ /// is this the default dialect?
+ bool is_default;
+};
+
+
+dialect_info const dialects[] = {
+ { "R/2 4.3", "ABAP", "R/2 4.3", false },
+ { "R/2 5.0", "ABAP", "R/2 5.0", false },
+ { "R/3 3.1", "ABAP", "R/3 3.1", false },
+ { "R/3 4.6C", "ABAP", "R/3 4.6C", false },
+ { "R/3 6.10", "ABAP", "R/3 6.10", true },
+ { "2005", "Ada", "2005", true },
+ { "83", "Ada", "83", false },
+ { "95", "Ada", "95", false },
+ { "60", "Algol", "60", false },
+ { "68", "Algol", "68", true },
+ { "Motorola68k", "Assembler", "Motorola 68xxx", false },
+ { "x86masm", "Assembler", "x86 (MASM)", false },
+ { "gnu", "Awk", "gnu", true },
+ { "POSIX", "Awk", "POSIX", false },
+ { "Visual", "Basic", "Visual", false },
+ { "ANSI", "C", "ANSI", true },
+ { "Handel", "C", "Handel", false },
+ { "Objective", "C", "Objective", false },
+ { "Sharp", "C", "Sharp", false },
+ { "ANSI", "C++", "ANSI", false },
+ { "GNU", "C++", "GNU", false },
+ { "ISO", "C++", "ISO", true },
+ { "Visual", "C++", "Visual", false },
+ { "light", "Caml", "light", true },
+ { "Objective", "Caml", "Objective", false },
+ { "1974", "Cobol", "1974", false },
+ { "1985", "Cobol", "1985", true },
+ { "ibm", "Cobol", "IBM", false },
+ { "WinXP", "command.com", "Windows XP", true },
+ { "77", "Fortran", "77", false },
+ { "90", "Fortran", "90", false },
+ { "95", "Fortran", "95", true },
+ { "CORBA", "IDL", "CORBA", false },
+ { "AspectJ", "Java", "Aspect J", false },
+ { "Auto", "Lisp", "Auto", false },
+ { "gnu", "make", "gnu", false },
+ { "1.0", "Mathematica", "1.0", false },
+ { "3.0", "Mathematica", "3.0", false },
+ { "5.2", "Mathematica", "5.2", true },
+ { "decorative", "OCL", "decorative", false },
+ { "OMG", "OCL", "OMG", true },
+ { "Borland6", "Pascal", "Borland 6", false },
+ { "Standard", "Pascal", "Standard", true },
+ { "XSC", "Pascal", "XSC", false },
+ { "PLUS", "S", "PLUS", false },
+ { "67", "Simula", "67", true },
+ { "CII", "Simula", "CII", false },
+ { "DEC", "Simula", "DEC", false },
+ { "IBM", "Simula", "IBM", false },
+ { "tk", "tcl", "tk", false },
+ { "AlLaTeX", "TeX", "AlLaTeX", false },
+ { "common", "TeX", "common", false },
+ { "LaTeX", "TeX", "LaTeX", false },
+ { "plain", "TeX", "plain", true },
+ { "primitive", "TeX", "primitive", false },
+ { "AMS", "VHDL", "AMS", false },
+ { "97", "VRML", "97", true }
+};
+
+
+size_t const nr_dialects = sizeof(dialects) / sizeof(dialect_info);
+
+
+char const * font_sizes[] =
+{ "default", "tiny", "scriptsize", "footnotesize", "small", "normalsize", "large",
+ "Large", "" };
+
+char const * font_sizes_gui[] =
+{ N_("Default"), N_("Tiny"), N_("Smallest"), N_("Smaller"), N_("Small"), N_("Normal"),
+ N_("Large"), N_("Larger"), "" };
+
+char const * font_styles[] =
+{ "default", "rmfamily", "ttfamily", "sffamily", "" };
+
+char const * font_styles_gui[] =
+{ N_("Default"), N_("Roman"), N_("Typewriter"), N_("Sans Serif"), "" };
+
+
+
+GuiListingsDialog::GuiListingsDialog(GuiListings * form)
+ : form_(form)
+{
+ setupUi(this);
+
+ connect(okPB, SIGNAL(clicked()), form, SLOT(slotOK()));
+ connect(applyPB, SIGNAL(clicked()), form_, SLOT(slotApply()));
+ connect(closePB, SIGNAL(clicked()), form, SLOT(slotClose()));
+
+ connect(languageCO, SIGNAL(currentIndexChanged(int)), this, SLOT(change_adaptor()));
+ connect(dialectCO, SIGNAL(currentIndexChanged(int)), this, SLOT(change_adaptor()));
+ connect(inlineCB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
+ connect(floatCB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
+ connect(placementLE, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
+ connect(numberSideCO, SIGNAL(currentIndexChanged(int)), this, SLOT(change_adaptor()));
+ connect(numberStepLE, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
+ connect(numberFontSizeCO, SIGNAL(currentIndexChanged(int)), this, SLOT(change_adaptor()));
+ connect(firstlineLE, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
+ connect(lastlineLE, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
+ connect(fontsizeCO, SIGNAL(currentIndexChanged(int)), this, SLOT(change_adaptor()));
+ connect(fontstyleCO, SIGNAL(currentIndexChanged(int)), this, SLOT(change_adaptor()));
+ connect(breaklinesCB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
+ connect(spaceCB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
+ connect(spaceInStringCB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
+ connect(extendedcharsCB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
+
+ connect(listingsED, SIGNAL(textChanged()), this, SLOT(change_adaptor()));
+ connect(listingsED, SIGNAL(textChanged()), this, SLOT(set_listings_msg()));
+ connect(bypassCB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
+ connect(bypassCB, SIGNAL(clicked()), this, SLOT(set_listings_msg()));
+
+ for (int n = 0; languages[n][0]; ++n)
+ languageCO->addItem(qt_(languages_gui[n]));
+
+ for (int n = 0; font_styles[n][0]; ++n)
+ fontstyleCO->addItem(qt_(font_styles_gui[n]));
+
+ for (int n = 0; font_sizes[n][0]; ++n) {
+ QString font = qt_(font_sizes_gui[n]);
+ fontsizeCO->addItem(font);
+ numberFontSizeCO->addItem(font);
+ }
+
+ // set validators
+ numberStepLE->setValidator(new QIntValidator(0, 1000000, this));
+ firstlineLE->setValidator(new QIntValidator(0, 1000000, this));
+ lastlineLE->setValidator(new QIntValidator(0, 1000000, this));
+ placementLE->setValidator(new QRegExpValidator(QRegExp("[\\*tbph]*"), this));
+}
+
+
+void GuiListingsDialog::closeEvent(QCloseEvent * e)
+{
+ form_->slotWMHide();
+ e->accept();
+}
+
+
+void GuiListingsDialog::change_adaptor()
+{
+ form_->changed();
+}
+
+
+string GuiListingsDialog::construct_params()
+{
+ string language = languages[languageCO->currentIndex()];
+ string dialect;
+ string const dialect_gui = fromqstr(dialectCO->currentText());
+ if (dialectCO->currentIndex() > 0) {
+ for (size_t i = 0; i < nr_dialects; ++i) {
+ if (dialect_gui == dialects[i].gui
+ && dialects[i].language == language
+ && !dialects[i].is_default) {
+ dialect = dialects[i].dialect;
+ break;
+ }
+ }
+ }
+
+ bool float_ = floatCB->isChecked();
+ string placement;
+ if (placementLE->isEnabled())
+ placement = fromqstr(placementLE->text());
+
+ string numberSide;
+ switch (numberSideCO->currentIndex()) {
+ case 0:
+ numberSide = "none";
+ break;
+ case 1:
+ numberSide = "left";
+ break;
+ case 2:
+ numberSide = "right";
+ break;
+ default:
+ numberSide = "none";
+ break;
+ }
+ string stepnumber = fromqstr(numberStepLE->text());
+ string numberfontsize = font_sizes[numberFontSizeCO->currentIndex()];
+ string firstline = fromqstr(firstlineLE->text());
+ string lastline = fromqstr(lastlineLE->text());
+
+ string fontsize = font_sizes[fontsizeCO->currentIndex()];
+ string fontstyle = font_styles[fontstyleCO->currentIndex()];
+ string basicstyle;
+ if (fontsize != "default")
+ basicstyle = "\\" + fontsize;
+ if (fontstyle != "default")
+ basicstyle += "\\" + fontstyle;
+ bool breakline = breaklinesCB->isChecked();
+ bool space = spaceCB->isChecked();
+ bool spaceInString = spaceInStringCB->isChecked();
+ bool extendedchars = extendedcharsCB->isChecked();
+ string extra = fromqstr(listingsED->toPlainText());
+
+ // compose a string
+ InsetListingsParams par;
+ if (language != "no language" && !contains(extra, "language=")) {
+ if (dialect.empty())
+ par.addParam("language", language);
+ else
+ par.addParam("language", "{[" + dialect + "]" + language + "}");
+ }
+ // this dialog uses float=placement instead of float,floatplacement=placement
+ // because float accepts *tbph and floatplacement accepts bph.
+ // our placement textedit is actually for the float parameter
+ if (float_)
+ par.addParam("float", placement);
+ if (numberSide != "none")
+ par.addParam("numbers", numberSide);
+ if (numberfontsize != "default" && numberSide != "none")
+ par.addParam("numberstyle", "\\" + numberfontsize);
+ if (!stepnumber.empty() && numberSide != "none")
+ par.addParam("stepnumber", stepnumber);
+ if (!firstline.empty())
+ par.addParam("firstline", firstline);
+ if (!lastline.empty())
+ par.addParam("lastline", lastline);
+ if (!basicstyle.empty())
+ par.addParam("basicstyle", basicstyle);
+ if (breakline)
+ par.addParam("breaklines", "true");
+ if (space)
+ par.addParam("showspaces", "true");
+ if (!spaceInString)
+ par.addParam("showstringspaces", "false");
+ if (extendedchars)
+ par.addParam("extendedchars", "true");
+ par.addParams(extra);
+ return par.params();
+}
+
+
+docstring GuiListingsDialog::validate_listings_params()
+{
+ // use a cache here to avoid repeated validation
+ // of the same parameters
+ static string param_cache = string();
+ static docstring msg_cache = docstring();
+
+ if (bypassCB->isChecked())
+ return docstring();
+
+ string params = construct_params();
+ if (params != param_cache) {
+ param_cache = params;
+ msg_cache = InsetListingsParams(params).validate();
+ }
+ return msg_cache;
+}
+
+
+void GuiListingsDialog::set_listings_msg()
+{
+ static bool isOK = true;
+ docstring msg = validate_listings_params();
+ if (msg.empty()) {
+ if (isOK)
+ return;
+ isOK = true;
+ listingsTB->setPlainText(
+ qt_("Input listing parameters on the right. Enter ? for a list of parameters."));
+ } else {
+ isOK = false;
+ listingsTB->setPlainText(toqstr(msg));
+ }
+}
+
+
+void GuiListingsDialog::on_floatCB_stateChanged(int state)
+{
+ if (state == Qt::Checked) {
+ inlineCB->setChecked(false);
+ placementLE->setEnabled(true);
+ } else
+ placementLE->setEnabled(false);
+}
+
+
+void GuiListingsDialog::on_inlineCB_stateChanged(int state)
+{
+ if (state == Qt::Checked) {
+ floatCB->setChecked(false);
+ placementLE->setEnabled(false);
+ }
+}
+
+
+void GuiListingsDialog::on_numberSideCO_currentIndexChanged(int index)
+{
+ numberStepLE->setEnabled(index > 0);
+ numberFontSizeCO->setEnabled(index > 0);
+}
+
+
+void GuiListingsDialog::on_languageCO_currentIndexChanged(int index)
+{
+ dialectCO->clear();
+ // 0 is "no dialect"
+ int default_dialect = 0;
+ dialectCO->addItem(qt_("No dialect"));
+ string const language = languages[index];
+
+ for (size_t i = 0; i < nr_dialects; ++i) {
+ if (language == dialects[i].language) {
+ dialectCO->addItem(qt_(dialects[i].gui));
+ if (dialects[i].is_default)
+ default_dialect =
+ dialectCO->findText(qt_(dialects[i].gui));
+ }
+ }
+ dialectCO->setCurrentIndex(default_dialect);
+ dialectCO->setEnabled(dialectCO->count() > 1);
+}
+
+
+/////////////////////////////////////////////////////////////////////
+//
+// GuiListings
+//
+/////////////////////////////////////////////////////////////////////
+
+typedef QController<ControlListings, GuiView<GuiListingsDialog> > listings_wrap_base_class;
+
+GuiListings::GuiListings(Dialog & parent)
+ : listings_wrap_base_class(parent, _("Program Listing Settings"))
+{
+}
+
+
+void GuiListings::build_dialog()
+{
+ dialog_.reset(new GuiListingsDialog(this));
+
+ bcview().setOK(dialog_->okPB);
+ bcview().setApply(dialog_->applyPB);
+ bcview().setCancel(dialog_->closePB);
+ dialog_->listingsTB->setPlainText(
+ qt_("Input listing parameters on the right. Enter ? for a list of parameters."));
+
+ update_contents();
+}
+
+
+void GuiListings::apply()
+{
+ InsetListingsParams & params = controller().params();
+ params.setInline(dialog_->inlineCB->isChecked());
+ params.setParams(dialog_->construct_params());
+ controller().setParams(params);
+}
+
+
+namespace {
+
+string plainParam(std::string const & par)
+{
+ // remove enclosing braces
+ if (prefixIs(par, "{") && suffixIs(par, "}"))
+ return par.substr(1, par.size() - 2);
+ return par;
+}
+
+} //namespace anon
+
+
+void GuiListings::update_contents()
+{
+ // set default values
+ dialog_->listingsTB->setPlainText(
+ qt_("Input listing parameters on the right. Enter ? for a list of parameters."));
+ dialog_->languageCO->setCurrentIndex(findToken(languages, "no language"));
+ dialog_->dialectCO->setCurrentIndex(0);
+ dialog_->floatCB->setChecked(false);
+ dialog_->placementLE->clear();
+ dialog_->numberSideCO->setCurrentIndex(0);
+ dialog_->numberStepLE->clear();
+ dialog_->numberFontSizeCO->setCurrentIndex(findToken(font_sizes, "default"));
+ dialog_->firstlineLE->clear();
+ dialog_->lastlineLE->clear();
+ dialog_->fontstyleCO->setCurrentIndex(findToken(font_styles, "default"));
+ dialog_->fontsizeCO->setCurrentIndex(findToken(font_sizes, "default"));
+ dialog_->breaklinesCB->setChecked(false);
+ dialog_->spaceCB->setChecked(false);
+ dialog_->spaceInStringCB->setChecked(true);
+ dialog_->extendedcharsCB->setChecked(false);
+
+ // set values from param string
+ InsetListingsParams & params = controller().params();
+ dialog_->inlineCB->setChecked(params.isInline());
+ if (params.isInline()) {
+ dialog_->floatCB->setChecked(false);
+ dialog_->placementLE->setEnabled(false);
+ }
+ // break other parameters and set values
+ vector<string> pars = getVectorFromString(params.separatedParams(), "\n");
+ // process each of them
+ for (vector<string>::iterator it = pars.begin();
+ it != pars.end(); ++it) {
+ if (prefixIs(*it, "language=")) {
+ string arg = plainParam(it->substr(9));
+ // has dialect?
+ string language;
+ string dialect;
+ bool in_gui = false;
+ if (prefixIs(arg, "[") && contains(arg, "]")) {
+ string::size_type end_dialect = arg.find("]");
+ dialect = arg.substr(1, end_dialect - 1);
+ language = arg.substr(end_dialect + 1);
+ } else
+ language = arg;
+ int n = findToken(languages, language);
+ if (n >= 0) {
+ dialog_->languageCO->setCurrentIndex(n);
+ in_gui = true;
+ }
+ // on_languageCO_currentIndexChanged should have set dialects
+ if (!dialect.empty()) {
+ string dialect_gui;
+ for (size_t i = 0; i < nr_dialects; ++i) {
+ if (dialect == dialects[i].dialect
+ && dialects[i].language == language) {
+ dialect_gui = dialects[i].gui;
+ break;
+ }
+ }
+ n = dialog_->dialectCO->findText(qt_(dialect_gui));
+ if (n >= 0)
+ dialog_->dialectCO->setCurrentIndex(n);
+ else
+ in_gui = false;
+ }
+ if (in_gui)
+ *it = "";
+ dialog_->languageCO->setEnabled(in_gui);
+ dialog_->dialectCO->setEnabled(
+ in_gui && dialog_->dialectCO->count() > 1);
+ } else if (prefixIs(*it, "float")) {
+ dialog_->floatCB->setChecked(true);
+ dialog_->inlineCB->setChecked(false);
+ dialog_->placementLE->setEnabled(true);
+ if (prefixIs(*it, "float="))
+ dialog_->placementLE->setText(
+ toqstr(plainParam(it->substr(6))));
+ *it = "";
+ } else if (prefixIs(*it, "numbers=")) {
+ string s = plainParam(it->substr(8));
+ int n = 0;
+ if (s == "left")
+ n = 1;
+ else if (s == "right")
+ n = 2;
+ dialog_->numberSideCO->setCurrentIndex(n);
+ *it = "";
+ } else if (prefixIs(*it, "stepnumber=")) {
+ dialog_->numberStepLE->setText(
+ toqstr(plainParam(it->substr(11))));
+ *it = "";
+ } else if (prefixIs(*it, "numberstyle=")) {
+ string par = plainParam(it->substr(12));
+ int n = findToken(font_sizes, par.substr(1));
+ if (n >= 0)
+ dialog_->numberFontSizeCO->setCurrentIndex(n);
+ *it = "";
+ } else if (prefixIs(*it, "firstline=")) {
+ dialog_->firstlineLE->setText(
+ toqstr(plainParam(it->substr(10))));
+ *it = "";
+ } else if (prefixIs(*it, "lastline=")) {
+ dialog_->lastlineLE->setText(
+ toqstr(plainParam(it->substr(9))));
+ *it = "";
+ } else if (prefixIs(*it, "basicstyle=")) {
+ string style;
+ string size;
+ for (int n = 0; font_styles[n][0]; ++n) {
+ string const s = font_styles[n];
+ if (contains(*it, "\\" + s)) {
+ style = "\\" + s;
+ break;
+ }
+ }
+ for (int n = 0; font_sizes[n][0]; ++n) {
+ string const s = font_sizes[n];
+ if (contains(*it, "\\" + s)) {
+ size = "\\" + s;
+ break;
+ }
+ }
+ if (plainParam(it->substr(11)) == style + size
+ || plainParam(it->substr(11)) == size + style) {
+ if (!style.empty()) {
+ int n = findToken(font_styles, style.substr(1));
+ if (n >= 0)
+ dialog_->fontstyleCO->setCurrentIndex(n);
+ }
+ if (!size.empty()) {
+ int n = findToken(font_sizes, size.substr(1));
+ if (n >= 0)
+ dialog_->fontsizeCO->setCurrentIndex(n);
+ }
+ *it = "";
+ }
+ } else if (prefixIs(*it, "breaklines=")) {
+ dialog_->breaklinesCB->setChecked(contains(*it, "true"));
+ *it = "";
+ } else if (prefixIs(*it, "showspaces=")) {
+ dialog_->spaceCB->setChecked(contains(*it, "true"));
+ *it = "";
+ } else if (prefixIs(*it, "showstringspaces=")) {
+ dialog_->spaceInStringCB->setChecked(contains(*it, "true"));
+ *it = "";
+ } else if (prefixIs(*it, "extendedchars=")) {
+ dialog_->extendedcharsCB->setChecked(contains(*it, "true"));
+ *it = "";
+ }
+ }
+
+ dialog_->numberStepLE->setEnabled(dialog_->numberSideCO->currentIndex() > 0);
+ dialog_->numberFontSizeCO->setEnabled(dialog_->numberSideCO->currentIndex() > 0);
+ // parameters that can be handled by widgets are cleared
+ // the rest is put to the extra edit box.
+ string extra = getStringFromVector(pars);
+ dialog_->listingsED->setPlainText(toqstr(InsetListingsParams(extra).separatedParams()));
+}
+
+
+bool GuiListings::isValid()
+{
+ return dialog_->validate_listings_params().empty();
+}
+
+
+} // namespace frontend
+} // namespace lyx
+
+
+#include "GuiListings_moc.cpp"
--- /dev/null
+// -*- C++ -*-
+/**
+ * \file QListings.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Bo Peng
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#ifndef QLISTINGS_H
+#define QLISTINGS_H
+
+#include "GuiDialogView.h"
+#include "ui_ListingsUi.h"
+
+#include <QDialog>
+#include <QCloseEvent>
+
+namespace lyx {
+namespace frontend {
+
+class GuiListings;
+
+class GuiListingsDialog : public QDialog, public Ui::ListingsUi {
+ Q_OBJECT
+public:
+ GuiListingsDialog(GuiListings * form);
+ /// get values from all the widgets and form a string
+ std::string construct_params();
+ /// validate listings parameters and return an error message, if any
+ docstring validate_listings_params();
+protected Q_SLOTS:
+ virtual void change_adaptor();
+ /// AFAIK, QValidator only works for QLineEdit so
+ /// I have to validate listingsED (QTextEdit) manually.
+ /// This function displays a hint or error message returned by
+ /// validate_listings_params
+ void set_listings_msg();
+ /// turn off inline when float is clicked
+ void on_floatCB_stateChanged(int state);
+ /// turn off float when inline is clicked
+ void on_inlineCB_stateChanged(int state);
+ /// turn off numbering options when none is selected
+ void on_numberSideCO_currentIndexChanged(int);
+ /// show dialect when language is chosen
+ void on_languageCO_currentIndexChanged(int);
+protected:
+ virtual void closeEvent(QCloseEvent * e);
+private:
+ GuiListings * form_;
+};
+
+
+class ControlListings;
+
+class GuiListings : public QController<ControlListings, GuiView<GuiListingsDialog> > {
+public:
+ friend class GuiListingsDialog;
+
+ GuiListings(Dialog &);
+private:
+ /// Apply changes
+ virtual void apply();
+ /// update
+ virtual void update_contents();
+ /// build the dialog
+ virtual void build_dialog();
+protected:
+ /// return false if validate_listings_params returns error
+ virtual bool isValid();
+};
+
+} // namespace frontend
+} // namespace lyx
+
+#endif // QLISTINGS_H
--- /dev/null
+/**
+ * \file GuiLog.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author John Levon
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "GuiLog.h"
+#include "qt_helpers.h"
+
+#include "frontends/Application.h"
+
+#include "controllers/ControlLog.h"
+
+#include <sstream>
+
+#include <QTextBrowser>
+#include <QPushButton>
+
+namespace lyx {
+namespace frontend {
+
+/////////////////////////////////////////////////////////////////////
+//
+// GuiLogDialog
+//
+/////////////////////////////////////////////////////////////////////
+
+
+GuiLogDialog::GuiLogDialog(GuiLog * form)
+ : form_(form)
+{
+ setupUi(this);
+
+ connect(closePB, SIGNAL(clicked()),
+ form, SLOT(slotClose()));
+ connect( updatePB, SIGNAL( clicked() ),
+ this, SLOT( updateClicked() ) );
+}
+
+
+void GuiLogDialog::closeEvent(QCloseEvent * e)
+{
+ form_->slotWMHide();
+ e->accept();
+}
+
+
+void GuiLogDialog::updateClicked()
+{
+ form_->update_contents();
+}
+
+
+/////////////////////////////////////////////////////////////////////
+//
+// LogHighlighter
+//
+/////////////////////////////////////////////////////////////////////
+
+LogHighlighter::LogHighlighter(QTextDocument * parent)
+ : QSyntaxHighlighter(parent)
+{
+ infoFormat.setForeground(Qt::darkGray);
+ warningFormat.setForeground(Qt::darkBlue);
+ errorFormat.setForeground(Qt::red);
+}
+
+
+void LogHighlighter::highlightBlock(QString const & text)
+{
+ // Info
+ QRegExp exprInfo("^(Document Class:|LaTeX Font Info:|File:|Package:|Language:|Underfull|Overfull|\\(|\\\\).*$");
+ int index = text.indexOf(exprInfo);
+ while (index >= 0) {
+ int length = exprInfo.matchedLength();
+ setFormat(index, length, infoFormat);
+ index = text.indexOf(exprInfo, index + length);
+ }
+ // LaTeX Warning:
+ QRegExp exprWarning("^LaTeX Warning.*$");
+ index = text.indexOf(exprWarning);
+ while (index >= 0) {
+ int length = exprWarning.matchedLength();
+ setFormat(index, length, warningFormat);
+ index = text.indexOf(exprWarning, index + length);
+ }
+ // ! error
+ QRegExp exprError("^!.*$");
+ index = text.indexOf(exprError);
+ while (index >= 0) {
+ int length = exprError.matchedLength();
+ setFormat(index, length, errorFormat);
+ index = text.indexOf(exprError, index + length);
+ }
+}
+
+
+/////////////////////////////////////////////////////////////////////
+//
+// GuiLog
+//
+/////////////////////////////////////////////////////////////////////
+
+typedef QController<ControlLog, GuiView<GuiLogDialog> > LogBase;
+
+GuiLog::GuiLog(Dialog & parent)
+ : LogBase(parent, docstring())
+{}
+
+
+void GuiLog::build_dialog()
+{
+ dialog_.reset(new GuiLogDialog(this));
+ // set syntax highlighting
+ highlighter = new LogHighlighter(dialog_->logTB->document());
+ //
+ dialog_->logTB->setReadOnly(true);
+ QFont font(toqstr(theApp()->typewriterFontName()));
+ font.setKerning(false);
+ font.setFixedPitch(true);
+ font.setStyleHint(QFont::TypeWriter);
+ dialog_->logTB->setFont(font);
+}
+
+
+void GuiLog::update_contents()
+{
+ setTitle(controller().title());
+
+ std::ostringstream ss;
+ controller().getContents(ss);
+
+ dialog_->logTB->setPlainText(toqstr(ss.str()));
+}
+
+} // namespace frontend
+} // namespace lyx
+
+#include "GuiLog_moc.cpp"
--- /dev/null
+// -*- C++ -*-
+/**
+ * \file GuiLog.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author John Levon
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#ifndef GUILOG_H
+#define GUILOG_H
+
+#include "GuiDialogView.h"
+
+
+#include "ui_LogUi.h"
+
+#include <QDialog>
+#include <QCloseEvent>
+#include <QSyntaxHighlighter>
+
+namespace lyx {
+namespace frontend {
+
+class GuiLog;
+
+class GuiLogDialog : public QDialog, public Ui::LogUi {
+ Q_OBJECT
+public:
+ GuiLogDialog(GuiLog * form);
+protected Q_SLOTS:
+ virtual void updateClicked();
+protected:
+ virtual void closeEvent(QCloseEvent * e);
+private:
+ GuiLog * form_;
+};
+
+
+class ControlLog;
+class LogHighlighter;
+
+///
+class GuiLog
+ : public QController<ControlLog, GuiView<GuiLogDialog> >
+{
+public:
+ ///
+ friend class GuiLogDialog;
+ ///
+ GuiLog(Dialog &);
+private:
+ /// Apply changes
+ virtual void apply() {}
+ /// update
+ virtual void update_contents();
+ /// build the dialog
+ virtual void build_dialog();
+ /// log syntax highlighter
+ LogHighlighter * highlighter;
+};
+
+
+///
+class LogHighlighter : public QSyntaxHighlighter
+{
+public:
+ LogHighlighter(QTextDocument * parent);
+
+protected:
+ void highlightBlock(QString const & text);
+
+private:
+ QTextCharFormat infoFormat;
+ QTextCharFormat warningFormat;
+ QTextCharFormat errorFormat;
+};
+
+
+} // namespace frontend
+} // namespace lyx
+
+#endif // QLOG_H
--- /dev/null
+/**
+ * \file GuiMathMatrixDialog.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Jürgen Spitzmüller
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "GuiMathMatrixDialog.h"
+
+#include "EmptyTable.h"
+#include "qt_helpers.h"
+
+#include "controllers/ControlMath.h"
+
+#include <sstream>
+
+#include <qlineedit.h>
+#include <qpushbutton.h>
+#include <qspinbox.h>
+
+#include "gettext.h"
+
+using std::ostringstream;
+using std::string;
+
+namespace lyx {
+namespace frontend {
+
+namespace {
+
+char h_align_str[80] = "c";
+char v_align_c[] = "tcb";
+
+} // namespace anon
+
+
+typedef QController<ControlMath, GuiView<GuiMathMatrixDialog> > matrix_base;
+
+
+GuiMathMatrix::GuiMathMatrix(Dialog & parent)
+ : matrix_base(parent, _("Math Matrix"))
+{}
+
+
+void GuiMathMatrix::build_dialog()
+{
+ dialog_.reset(new GuiMathMatrixDialog(this));
+}
+
+
+GuiMathMatrixDialog::GuiMathMatrixDialog(GuiMathMatrix * form)
+ : form_(form)
+{
+ setupUi(this);
+
+ setWindowTitle(qt_("LyX: Insert Matrix"));
+
+ table->setMinimumSize(100, 100);
+ rowsSB->setValue(5);
+ columnsSB->setValue(5);
+ valignCO->setCurrentIndex(1);
+
+ connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
+ connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
+
+ connect(table, SIGNAL(rowsChanged(int)),
+ rowsSB, SLOT(setValue(int)));
+ connect(table, SIGNAL(colsChanged(int)),
+ columnsSB, SLOT(setValue(int)));
+ connect(rowsSB, SIGNAL(valueChanged(int)),
+ table, SLOT(setNumberRows(int)));
+ connect(columnsSB, SIGNAL(valueChanged(int)),
+ table, SLOT(setNumberColumns(int)));
+ connect(rowsSB, SIGNAL(valueChanged(int)),
+ this, SLOT(rowsChanged(int)));
+ connect(columnsSB, SIGNAL(valueChanged(int)),
+ this, SLOT(columnsChanged(int)) );
+ connect(valignCO, SIGNAL(highlighted(const QString&)),
+ this, SLOT(change_adaptor()));
+ connect(halignED, SIGNAL(textChanged(const QString&)),
+ this, SLOT(change_adaptor()));
+}
+
+
+void GuiMathMatrixDialog::columnsChanged(int)
+{
+ int const nx = int(columnsSB->value());
+ for (int i = 0; i < nx; ++i)
+ h_align_str[i] = 'c';
+
+ h_align_str[nx] = '\0';
+ halignED->setText(h_align_str);
+}
+
+
+void GuiMathMatrixDialog::rowsChanged(int)
+{
+}
+
+
+void GuiMathMatrixDialog::change_adaptor()
+{
+ // FIXME: We need a filter for the halign input
+}
+
+
+void GuiMathMatrixDialog::slotOK()
+{
+ char const c = v_align_c[valignCO->currentIndex()];
+ string const sh = fromqstr(halignED->text());
+ int const nx = int(columnsSB->value());
+ int const ny = int(rowsSB->value());
+
+ ostringstream os;
+ os << nx << ' ' << ny << ' ' << c << ' ' << sh;
+ form_->controller().dispatchMatrix(os.str().c_str());
+
+ // close the dialog
+ close();
+}
+
+
+void GuiMathMatrixDialog::slotClose()
+{
+ close();
+}
+
+} // namespace frontend
+} // namespace lyx
+
+#include "GuiMathMatrixDialog_moc.cpp"
--- /dev/null
+// -*- C++ -*-
+/**
+ * \file GuiMathMatrixDialog.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author John Levon
+ * \author Edwin Leuven
+ * \author Jürgen Spitzmüller
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#ifndef QMATHMATRIXDIALOG_H
+#define QMATHMATRIXDIALOG_H
+
+#include "GuiDialogView.h"
+
+#include "ui_MathMatrixUi.h"
+
+#include <QDialog>
+
+namespace lyx {
+namespace frontend {
+
+class GuiMathMatrix;
+class ControlMath;
+
+
+class GuiMathMatrixDialog : public QDialog, public Ui::MathMatrixUi {
+ Q_OBJECT
+public:
+ GuiMathMatrixDialog(GuiMathMatrix * form);
+public Q_SLOTS:
+ void slotOK();
+ void slotClose();
+protected Q_SLOTS:
+ virtual void columnsChanged(int);
+ virtual void rowsChanged(int);
+ virtual void change_adaptor();
+private:
+ GuiMathMatrix * form_;
+};
+
+
+class GuiMathMatrix : public QController<ControlMath, GuiView<GuiMathMatrixDialog> > {
+public:
+ friend class GuiMathMatrixDialog;
+
+ GuiMathMatrix(Dialog &);
+
+private:
+ virtual void apply() {}
+ virtual void update_contents() {}
+ /// Build the dialog.
+ virtual void build_dialog();
+};
+
+
+} // namespace frontend
+} // namespace lyx
+
+#endif // QMATHMATRIXDIALOG_H
--- /dev/null
+/**
+ * \file qt4/GuiMenubar.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author John Levon
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+// Qt defines a macro 'signals' that clashes with a boost namespace.
+// All is well if the namespace is visible first.
+#include "GuiView.h"
+
+#include "Action.h"
+#include "GuiMenubar.h"
+#include "GuiPopupMenu.h"
+
+#include "qt_helpers.h"
+#include "support/lstrings.h"
+
+#include "MenuBackend.h"
+
+#include "debug.h"
+
+#include <QCursor>
+#include <QMenuBar>
+
+using std::pair;
+using std::string;
+using std::endl;
+
+namespace lyx {
+namespace frontend {
+
+// MacOSX specific stuff is at the end.
+
+GuiMenubar::GuiMenubar(LyXView * view, MenuBackend & mbe)
+ : owner_(static_cast<GuiViewBase*>(view)), menubackend_(mbe)
+{
+ macxMenuBarInit();
+
+ LYXERR(Debug::GUI) << "populating menu bar" << to_utf8(menubackend_.getMenubar().name()) << endl;
+
+ if (menubackend_.getMenubar().size() == 0) {
+ LYXERR(Debug::GUI) << "\tERROR: empty menu bar"
+ << to_utf8(menubackend_.getMenubar().name()) << endl;
+ return;
+ // continue;
+ }
+ else {
+ LYXERR(Debug::GUI) << "menu bar entries "
+ << menubackend_.getMenubar().size();
+ }
+
+ Menu menu;
+ menubackend_.expand(menubackend_.getMenubar(), menu, owner_->buffer());
+
+ Menu::const_iterator m = menu.begin();
+ Menu::const_iterator end = menu.end();
+
+ for (; m != end; ++m) {
+
+ if (m->kind() != MenuItem::Submenu) {
+ LYXERR(Debug::GUI) << "\tERROR: not a submenu "
+ << to_utf8(m->label()) << endl;
+ continue;
+ }
+
+ LYXERR(Debug::GUI) << "menu bar item " << to_utf8(m->label())
+ << " is a submenu named " << to_utf8(m->submenuname()) << endl;
+
+ docstring name = m->submenuname();
+ if (!menubackend_.hasMenu(name)) {
+ LYXERR(Debug::GUI) << "\tERROR: " << to_utf8(name)
+ << " submenu has no menu!" << endl;
+ continue;
+ }
+
+ Menu menu;
+ menubackend_.expand(menubackend_.getMenubar(), menu, owner_->buffer());
+
+ GuiPopupMenu * qMenu = new GuiPopupMenu(this, *m, true);
+ owner_->menuBar()->addMenu(qMenu);
+
+ pair<NameMap::iterator, bool> I = name_map_.insert(make_pair(name, qMenu));
+ if (!I.second) {
+ LYXERR(Debug::GUI) << "\tERROR: " << to_utf8(name)
+ << " submenu is already there!" << endl;
+ }
+/*
+ QObject::connect(qMenu, SIGNAL(aboutToShow()), this, SLOT(update()));
+ QObject::connect(qMenu, SIGNAL(triggered(QAction *)), this, SLOT(update()));
+ QObject::connect(qMenu->menuAction(), SIGNAL(triggered()), this, SLOT(update()));
+*/
+ }
+ //QObject::connect(owner_->menuBar(), SIGNAL(triggered()), this, SLOT(update()));
+}
+
+void GuiMenubar::openByName(docstring const & name)
+{
+ NameMap::const_iterator const cit = name_map_.find(name);
+ if (cit == name_map_.end())
+ return;
+
+ // I (Abdel) don't understand this comment:
+ // this will have to do I'm afraid.
+ cit->second->exec(QCursor::pos());
+}
+
+
+/// Some special Qt/Mac support hacks
+
+/*
+ Here is what the Qt documentation says about how a menubar is chosen:
+
+ 1) If the window has a QMenuBar then it is used. 2) If the window
+ is a modal then its menubar is used. If no menubar is specified
+ then a default menubar is used (as documented below) 3) If the
+ window has no parent then the default menubar is used (as
+ documented below).
+
+ The above 3 steps are applied all the way up the parent window
+ chain until one of the above are satisifed. If all else fails a
+ default menubar will be created, the default menubar on Qt/Mac is
+ an empty menubar, however you can create a different default
+ menubar by creating a parentless QMenuBar, the first one created
+ will thus be designated the default menubar, and will be used
+ whenever a default menubar is needed.
+
+ Thus, for Qt/Mac, we add the menus to a free standing menubar, so
+ that this menubar will be used also when one of LyX' dialogs has
+ focus. (JMarc)
+*/
+QMenuBar * GuiMenubar::menuBar() const
+{
+#ifdef Q_WS_MACX
+ return mac_menubar_.get();
+#else
+ return owner_->menuBar();
+#endif
+}
+
+#ifdef Q_WS_MACX
+extern void qt_mac_set_menubar_merge(bool b);
+#endif
+
+void GuiMenubar::macxMenuBarInit()
+{
+#ifdef Q_WS_MACX
+ mac_menubar_.reset(new QMenuBar);
+
+# if QT_VERSION >= 0x040200
+ /* Since Qt 4.2, the qt/mac menu code has special code for
+ specifying the role of a menu entry. However, it does not
+ work very well with our scheme of creating menus on demand,
+ and therefore we need to put these entries in a special
+ invisible menu. (JMarc)
+ */
+
+ /* The entries of our special mac menu. If we add support for
+ * special entries in MenuBackend, we could imagine something
+ * like
+ * SpecialItem About " "About LyX" "dialog-show aboutlyx"
+ * and therefore avoid hardcoding. I am not sure it is worth
+ * the hassle, though. (JMarc)
+ */
+ struct MacMenuEntry {
+ kb_action action;
+ char const * arg;
+ char const * label;
+ QAction::MenuRole role;
+ };
+
+ MacMenuEntry entries[] = {
+ {LFUN_DIALOG_SHOW, "aboutlyx", "About LyX",
+ QAction::AboutRole},
+ {LFUN_DIALOG_SHOW, "prefs", "Preferences",
+ QAction::PreferencesRole},
+ {LFUN_RECONFIGURE, "", "Reconfigure",
+ QAction::ApplicationSpecificRole},
+ {LFUN_LYX_QUIT, "", "Quit LyX", QAction::QuitRole}
+ };
+ const size_t num_entries = sizeof(entries) / sizeof(MacMenuEntry);
+
+ // the special menu for MenuBackend.
+ Menu special;
+ for (size_t i = 0 ; i < num_entries ; ++i) {
+ FuncRequest const func(entries[i].action,
+ from_utf8(entries[i].arg));
+ special.add(MenuItem(MenuItem::Command,
+ from_utf8(entries[i].label),
+ func));
+ }
+ menubackend_.specialMenu(special);
+
+ // add the entries to a QMenu that will eventually be empty
+ // and therefore invisible.
+ QMenu * qMenu = owner_->menuBar()->addMenu("special");
+
+ // we do not use 'special' because it is a temporary variable,
+ // whereas MenuBackend::specialMenu points to a persistent
+ // copy.
+ Menu::const_iterator cit = menubackend_.specialMenu().begin();
+ Menu::const_iterator end = menubackend_.specialMenu().end();
+ for (size_t i = 0 ; cit != end ; ++cit, ++i) {
+ Action * action = new Action(*owner_, cit->label(),
+ cit->func());
+ action->setMenuRole(entries[i].role);
+ qMenu->addAction(action);
+
+ }
+# else
+ qt_mac_set_menubar_merge(false);
+# endif // QT_VERSION >= 0x040200
+#endif // Q_WS_MACX
+}
+
+} // namespace frontend
+} // namespace lyx
+
+#include "GuiMenubar_moc.cpp"
--- /dev/null
+// -*- C++ -*-
+/**
+ * \file qt4/GuiMenubar.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Lars Gullik Bjønnes
+ * \author John Levon
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#ifndef QLMENUBAR_H
+#define QLMENUBAR_H
+
+#include "GuiPopupMenu.h"
+
+#include <map>
+#include <boost/scoped_ptr.hpp>
+
+#include <QObject>
+#include <QMenuBar>
+
+namespace lyx {
+
+class MenuBackend;
+class Menu;
+class MenuItem;
+
+namespace frontend {
+
+class GuiViewBase;
+class LyXView;
+
+class GuiMenubar : public QObject {
+ Q_OBJECT
+public:
+ GuiMenubar(LyXView *, MenuBackend &);
+
+ /// opens a top-level submenu given its name
+ void openByName(docstring const &);
+
+ /// return the owning view
+ GuiViewBase * view() { return owner_; }
+
+ /// return the menu controller
+ MenuBackend const & backend() { return menubackend_; }
+
+ /// The QMenuBar used by LyX
+ QMenuBar * menuBar() const;
+
+ /// update the state of the menuitems - not needed
+ void update();
+
+private:
+ /// Initialize specific MACOS X menubar
+ void macxMenuBarInit();
+
+ /// owning view
+ GuiViewBase * owner_;
+
+ /// menu controller
+ MenuBackend & menubackend_;
+
+ typedef std::map<docstring, GuiPopupMenu *> NameMap;
+
+ /// name to menu for openByName
+ NameMap name_map_;
+
+ /// MACOS X special menubar.
+ boost::scoped_ptr<QMenuBar> mac_menubar_;
+};
+
+} // namespace frontend
+} // namespace lyx
+
+#endif // QLMENUBAR_H
--- /dev/null
+/**
+ * \file GuiNomencl.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author John Levon
+ * \author O. U. Baran
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "debug.h"
+#include "ControlCommand.h"
+#include "qt_helpers.h"
+
+#include "GuiNomencl.h"
+#include "Qt2BC.h"
+#include "ButtonController.h"
+#include <QLabel>
+#include <QLineEdit>
+#include <QPushButton>
+#include <QTextEdit>
+#include <QWhatsThis>
+#include <QCloseEvent>
+
+using std::string;
+
+namespace lyx {
+namespace frontend {
+
+/////////////////////////////////////////////////////////////////////
+//
+// GuiNomenclDialog
+//
+/////////////////////////////////////////////////////////////////////
+
+GuiNomenclDialog::GuiNomenclDialog(GuiNomencl * form)
+ : form_(form)
+{
+ setupUi(this);
+
+ connect(okPB, SIGNAL(clicked()), form, SLOT(slotOK()));
+ connect(closePB, SIGNAL(clicked()), form, SLOT(slotClose()));
+ connect(symbolED, SIGNAL(textChanged(const QString&)),
+ this, SLOT(change_adaptor()));
+ connect(descriptionTE, SIGNAL(textChanged()),
+ this, SLOT(change_adaptor()));
+
+ setFocusProxy(descriptionTE);
+}
+
+
+void GuiNomenclDialog::show()
+{
+ QDialog::show();
+}
+
+
+void GuiNomenclDialog::change_adaptor()
+{
+ form_->changed();
+}
+
+
+void GuiNomenclDialog::reject()
+{
+ form_->slotClose();
+}
+
+
+void GuiNomenclDialog::closeEvent(QCloseEvent * e)
+{
+ form_->slotWMHide();
+ e->accept();
+}
+
+
+/////////////////////////////////////////////////////////////////////
+//
+// GuiNomencl
+//
+/////////////////////////////////////////////////////////////////////
+
+
+typedef QController<ControlCommand, GuiView<GuiNomenclDialog> > NomenBase;
+
+
+GuiNomencl::GuiNomencl(Dialog & parent, docstring const & title)
+ : NomenBase(parent, title)
+{
+}
+
+
+void GuiNomencl::build_dialog()
+{
+ dialog_.reset(new GuiNomenclDialog(this));
+
+ bcview().setOK(dialog_->okPB);
+ bcview().setCancel(dialog_->closePB);
+ bcview().addReadOnly(dialog_->symbolED);
+ bcview().addReadOnly(dialog_->descriptionTE);
+ bcview().addReadOnly(dialog_->prefixED);
+}
+
+
+void GuiNomencl::update_contents()
+{
+ dialog_->prefixED->setText(toqstr(controller().params()["prefix"]));
+ dialog_->symbolED->setText(toqstr(controller().params()["symbol"]));
+ QString description = toqstr(controller().params()["description"]);
+ description.replace("\\\\","\n");
+ dialog_->descriptionTE->setPlainText(description);
+
+ bc().valid(isValid());
+}
+
+
+void GuiNomencl::apply()
+{
+ controller().params()["prefix"] = qstring_to_ucs4(dialog_->prefixED->text());
+ controller().params()["symbol"] = qstring_to_ucs4(dialog_->symbolED->text());
+ QString description = dialog_->descriptionTE->toPlainText();
+ description.replace('\n',"\\\\");
+ controller().params()["description"] = qstring_to_ucs4(description);
+}
+
+
+bool GuiNomencl::isValid()
+{
+ QString const description = dialog_->descriptionTE->toPlainText();
+ return !dialog_->symbolED->text().isEmpty() && !description.isEmpty();
+}
+
+} // namespace frontend
+} // namespace lyx
+
+#include "GuiNomencl_moc.cpp"
--- /dev/null
+// -*- C++ -*-
+/**
+ * \file GuiNomencl.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author John Levon
+ * \author Kalle Dalheimer
+ * \author O. U. Baran
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#ifndef QNOMENCL_H
+#define QNOMENCL_H
+
+#include "GuiDialogView.h"
+#include "ui_NomenclUi.h"
+
+#include <QDialog>
+
+class QCloseEvent;
+
+
+namespace lyx {
+namespace frontend {
+
+class GuiNomencl;
+
+class GuiNomenclDialog : public QDialog, public Ui::NomenclUi {
+ Q_OBJECT
+public:
+ GuiNomenclDialog(GuiNomencl * form);
+ virtual void show();
+protected Q_SLOTS:
+ virtual void change_adaptor();
+ virtual void reject();
+protected:
+ virtual void closeEvent(QCloseEvent * e);
+private:
+ GuiNomencl * form_;
+};
+
+
+class ControlCommand;
+
+class GuiNomencl :
+ public QController<ControlCommand, GuiView<GuiNomenclDialog> >
+{
+public:
+ friend class GuiNomenclDialog;
+
+ GuiNomencl(Dialog &, docstring const & title);
+protected:
+ virtual bool isValid();
+private:
+ /// Apply changes
+ virtual void apply();
+ /// update
+ virtual void update_contents();
+ /// build the dialog
+ virtual void build_dialog();
+};
+
+} // namespace frontend
+} // namespace lyx
+
+#endif // QNOMENCL_H
--- /dev/null
+/**
+ * \file GuiNote.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Jürgen Spitzmüller
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "GuiNote.h"
+#include "Qt2BC.h"
+
+#include "controllers/ControlNote.h"
+
+#include "insets/InsetNote.h"
+
+#include <QCloseEvent>
+
+namespace lyx {
+namespace frontend {
+
+/////////////////////////////////////////////////////////////////////
+//
+// GuiNoteDialog
+//
+/////////////////////////////////////////////////////////////////////
+
+GuiNoteDialog::GuiNoteDialog(GuiNote * form)
+ : form_(form)
+{
+ setupUi(this);
+
+ connect(okPB, SIGNAL(clicked()), form, SLOT(slotOK()));
+ connect(closePB, SIGNAL(clicked()), form, SLOT(slotClose()));
+
+ connect(noteRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
+ connect(greyedoutRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
+ connect(commentRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
+ connect(framedRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
+ connect(shadedRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
+}
+
+
+void GuiNoteDialog::closeEvent(QCloseEvent * e)
+{
+ form_->slotWMHide();
+ e->accept();
+}
+
+
+void GuiNoteDialog::change_adaptor()
+{
+ form_->changed();
+}
+
+
+/////////////////////////////////////////////////////////////////////
+//
+// GuiNote
+//
+/////////////////////////////////////////////////////////////////////
+
+typedef QController<ControlNote, GuiView<GuiNoteDialog> > NoteBase;
+
+
+GuiNote::GuiNote(Dialog & parent)
+ : NoteBase(parent, _("Note Settings"))
+{}
+
+
+void GuiNote::build_dialog()
+{
+ dialog_.reset(new GuiNoteDialog(this));
+
+ bcview().setOK(dialog_->okPB);
+ bcview().setCancel(dialog_->closePB);
+}
+
+
+void GuiNote::update_contents()
+{
+ QRadioButton * rb = 0;
+
+ switch (controller().params().type) {
+ case InsetNoteParams::Note:
+ rb = dialog_->noteRB;
+ break;
+ case InsetNoteParams::Comment:
+ rb = dialog_->commentRB;
+ break;
+ case InsetNoteParams::Greyedout:
+ rb = dialog_->greyedoutRB;
+ break;
+ case InsetNoteParams::Framed:
+ rb = dialog_->framedRB;
+ break;
+ case InsetNoteParams::Shaded:
+ rb = dialog_->shadedRB;
+ break;
+ }
+
+ rb->setChecked(true);
+}
+
+
+void GuiNote::apply()
+{
+ InsetNoteParams::Type type;
+
+ if (dialog_->greyedoutRB->isChecked())
+ type = InsetNoteParams::Greyedout;
+ else if (dialog_->commentRB->isChecked())
+ type = InsetNoteParams::Comment;
+ else if (dialog_->framedRB->isChecked())
+ type = InsetNoteParams::Framed;
+ else if (dialog_->shadedRB->isChecked())
+ type = InsetNoteParams::Shaded;
+ else
+ type = InsetNoteParams::Note;
+
+ controller().params().type = type;
+}
+
+} // namespace frontend
+} // namespace lyx
+
+#include "GuiNote_moc.cpp"
--- /dev/null
+// -*- C++ -*-
+/**
+ * \file GuiNote.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Jürgen Spitzmüller
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#ifndef QNOTE_H
+#define QNOTE_H
+
+#include "GuiDialogView.h"
+#include "ui_NoteUi.h"
+
+#include <QDialog>
+class QCloseEvent;
+
+namespace lyx {
+namespace frontend {
+
+class GuiNote;
+
+class GuiNoteDialog : public QDialog, public Ui::NoteUi {
+ Q_OBJECT
+public:
+ GuiNoteDialog(GuiNote * form);
+protected Q_SLOTS:
+ virtual void change_adaptor();
+protected:
+ virtual void closeEvent(QCloseEvent * e);
+private:
+ GuiNote * form_;
+};
+
+
+class ControlNote;
+
+/** This class provides a QT implementation of the Note Dialog.
+ */
+class GuiNote : public QController<ControlNote, GuiView<GuiNoteDialog> >
+{
+public:
+ friend class GuiNoteDialog;
+
+ /// Constructor
+ GuiNote(Dialog &);
+private:
+ /// Apply changes
+ virtual void apply();
+ /// Build the dialog
+ virtual void build_dialog();
+ /// Update dialog before showing it
+ virtual void update_contents();
+};
+
+} // namespace frontend
+} // namespace lyx
+
+#endif // QNOTE_H
--- /dev/null
+/**
+ * \file GuiPainter.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author John Levon
+ * \author Abdelrazak Younes
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "GuiPainter.h"
+
+#include "GuiApplication.h"
+#include "GuiFontMetrics.h"
+#include "GuiImage.h"
+
+#include "GuiApplication.h"
+#include "qt_helpers.h"
+
+#include "debug.h"
+#include "Language.h"
+#include "Color.h"
+
+#include "support/unicode.h"
+
+#include <QPixmapCache>
+#include <QTextLayout>
+
+// Set USE_PIXMAP_CACHE to 1 for enabling the use of a Pixmap cache when
+// drawing text. This is especially useful for older PPC/Mac systems.
+#if (QT_VERSION < 0x040200) || defined(Q_WS_X11)
+#define USE_PIXMAP_CACHE 0
+#else
+#define USE_PIXMAP_CACHE 1
+#endif
+
+using std::endl;
+using std::string;
+
+namespace lyx {
+namespace frontend {
+
+namespace {
+
+bool const usePixmapCache = USE_PIXMAP_CACHE;
+
+QString generateStringSignature(QString const & str, Font const & f)
+{
+ QString sig = str;
+ sig.append(QChar(static_cast<short>(f.family())));
+ sig.append(QChar(static_cast<short>(f.series())));
+ sig.append(QChar(static_cast<short>(f.realShape())));
+ sig.append(QChar(static_cast<short>(f.size())));
+ sig.append(QChar(static_cast<short>(f.color())));
+ return sig;
+}
+
+} // anon namespace
+
+QLPainter::QLPainter(QPaintDevice * device)
+ : QPainter(device), Painter()
+{
+ // new QPainter has default QPen:
+ current_color_ = Color::black;
+ current_ls_ = line_solid;
+ current_lw_ = line_thin;
+}
+
+
+QLPainter::~QLPainter()
+{
+ QPainter::end();
+ //lyxerr << "QLPainter::end()" << endl;
+}
+
+
+void QLPainter::setQPainterPen(Color_color col,
+ Painter::line_style ls, Painter::line_width lw)
+{
+ if (col == current_color_ && ls == current_ls_ && lw == current_lw_)
+ return;
+
+ current_color_ = col;
+ current_ls_ = ls;
+ current_lw_ = lw;
+
+ QPen pen = QPainter::pen();
+
+ pen.setColor(guiApp->colorCache().get(col));
+
+ switch (ls) {
+ case line_solid: pen.setStyle(Qt::SolidLine); break;
+ case line_onoffdash: pen.setStyle(Qt::DotLine); break;
+ }
+
+ switch (lw) {
+ case line_thin: pen.setWidth(0); break;
+ case line_thick: pen.setWidth(3); break;
+ }
+
+ setPen(pen);
+}
+
+
+void QLPainter::point(int x, int y, Color_color col)
+{
+ if (!isDrawingEnabled())
+ return;
+
+ setQPainterPen(col);
+ drawPoint(x, y);
+}
+
+
+void QLPainter::line(int x1, int y1, int x2, int y2,
+ Color_color col,
+ line_style ls,
+ line_width lw)
+{
+ if (!isDrawingEnabled())
+ return;
+
+ setQPainterPen(col, ls, lw);
+ bool const do_antialiasing = renderHints() & TextAntialiasing
+ && x1 != x2 && y1 != y2;
+ setRenderHint(Antialiasing, do_antialiasing);
+ drawLine(x1, y1, x2, y2);
+ setRenderHint(Antialiasing, false);
+}
+
+
+void QLPainter::lines(int const * xp, int const * yp, int np,
+ Color_color col,
+ line_style ls,
+ line_width lw)
+{
+ if (!isDrawingEnabled())
+ return;
+
+ // double the size if needed
+ static QVector<QPoint> points(32);
+ if (np > points.size())
+ points.resize(2 * np);
+
+ bool antialias = false;
+ for (int i = 0; i < np; ++i) {
+ points[i].setX(xp[i]);
+ points[i].setY(yp[i]);
+ if (i != 0)
+ antialias |= xp[i-1] != xp[i] && yp[i-1] != yp[i];
+ }
+ setQPainterPen(col, ls, lw);
+ bool const text_is_antialiased = renderHints() & TextAntialiasing;
+ setRenderHint(Antialiasing, antialias && text_is_antialiased);
+ drawPolyline(points.data(), np);
+ setRenderHint(Antialiasing, false);
+}
+
+
+void QLPainter::rectangle(int x, int y, int w, int h,
+ Color_color col,
+ line_style ls,
+ line_width lw)
+{
+ if (!isDrawingEnabled())
+ return;
+
+ setQPainterPen(col, ls, lw);
+ drawRect(x, y, w, h);
+}
+
+
+void QLPainter::fillRectangle(int x, int y, int w, int h, Color_color col)
+{
+ fillRect(x, y, w, h, guiApp->colorCache().get(col));
+}
+
+
+void QLPainter::arc(int x, int y, unsigned int w, unsigned int h,
+ int a1, int a2, Color_color col)
+{
+ if (!isDrawingEnabled())
+ return;
+
+ // LyX usings 1/64ths degree, Qt usings 1/16th
+ setQPainterPen(col);
+ bool const do_antialiasing = renderHints() & TextAntialiasing;
+ setRenderHint(Antialiasing, do_antialiasing);
+ drawArc(x, y, w, h, a1 / 4, a2 / 4);
+ setRenderHint(Antialiasing, false);
+}
+
+
+void QLPainter::image(int x, int y, int w, int h, graphics::Image const & i)
+{
+ graphics::QLImage const & qlimage =
+ static_cast<graphics::QLImage const &>(i);
+
+ fillRectangle(x, y, w, h, Color::graphicsbg);
+
+ if (!isDrawingEnabled())
+ return;
+
+ drawImage(x, y, qlimage.qimage(), 0, 0, w, h);
+}
+
+
+int QLPainter::text(int x, int y, char_type c, Font const & f)
+{
+ docstring s(1, c);
+ return text(x, y, s, f);
+}
+
+
+int QLPainter::smallCapsText(int x, int y,
+ QString const & s, Font const & f)
+{
+ Font smallfont(f);
+ smallfont.decSize().decSize().setShape(Font::UP_SHAPE);
+
+ QFont const & qfont = guiApp->guiFontLoader().get(f);
+ QFont const & qsmallfont = guiApp->guiFontLoader().get(smallfont);
+
+ setQPainterPen(f.realColor());
+ int textwidth = 0;
+ size_t const ls = s.length();
+ for (unsigned int i = 0; i < ls; ++i) {
+ QChar const c = s[i].toUpper();
+ if (c != s.at(i)) {
+ setFont(qsmallfont);
+ } else {
+ setFont(qfont);
+ }
+ if (isDrawingEnabled())
+ drawText(x + textwidth, y, c);
+ textwidth += fontMetrics().width(c);
+ }
+ return textwidth;
+}
+
+
+int QLPainter::text(int x, int y, docstring const & s,
+ Font const & f)
+{
+ /* Caution: The following ucs4 to QString conversions work for symbol fonts
+ only because they are no real conversions but simple casts in reality.
+ When we want to draw a symbol or calculate the metrics we pass the position
+ of the symbol in the font (as given in lib/symbols) as a char_type to the
+ frontend. This is just wrong, because the symbol is no UCS4 character at
+ all. You can think of this number as the code point of the symbol in a
+ custom symbol encoding. It works because this char_type is lateron again
+ interpreted as a position in the font again.
+ The correct solution would be to have extra functions for symbols, but that
+ would require to duplicate a lot of frontend and mathed support code.
+ */
+ QString str = toqstr(s);
+
+#if 0
+ // HACK: QT3 refuses to show single compose characters
+ // Still needed with Qt4?
+ if (ls == 1 && str[0].unicode() >= 0x05b0 && str[0].unicode() <= 0x05c2)
+ str = ' ' + str;
+#endif
+
+ QLFontInfo & fi = guiApp->guiFontLoader().fontinfo(f);
+
+ int textwidth;
+
+ if (f.realShape() == Font::SMALLCAPS_SHAPE) {
+ textwidth = smallCapsText(x, y, str, f);
+ if (f.underbar() == Font::ON)
+ underline(f, x, y, textwidth);
+ return textwidth;
+ }
+
+ // Here we use the font width cache instead of
+ // textwidth = fontMetrics().width(str);
+ // because the above is awfully expensive on MacOSX
+ textwidth = fi.metrics->width(s);
+ if (f.underbar() == Font::ON)
+ underline(f, x, y, textwidth);
+
+ if (!isDrawingEnabled())
+ return textwidth;
+
+ // Qt4 does not display a glyph whose codepoint is the
+ // same as that of a soft-hyphen (0x00ad), unless it
+ // occurs at a line-break. As a kludge, we force Qt to
+ // render this glyph using a one-column line.
+ if (s.size() == 1 && str[0].unicode() == 0x00ad) {
+ setQPainterPen(f.realColor());
+ QTextLayout adsymbol(str);
+ adsymbol.setFont(fi.font);
+ adsymbol.beginLayout();
+ QTextLine line = adsymbol.createLine();
+ line.setNumColumns(1);
+ line.setPosition(QPointF(0, -line.ascent()));
+ adsymbol.endLayout();
+ line.draw(this, QPointF(x, y));
+ return textwidth;
+ }
+
+ if (!usePixmapCache) {
+ // don't use the pixmap cache,
+ // draw directly onto the painting device
+ setQPainterPen(f.realColor());
+ if (font() != fi.font)
+ setFont(fi.font);
+ // We need to draw the text as LTR as we use our own bidi code.
+ setLayoutDirection(Qt::LeftToRight);
+ // We need to draw the text as LTR as we use our own bidi code.
+ setLayoutDirection(Qt::LeftToRight);
+ drawText(x, y, str);
+ LYXERR(Debug::PAINTING) << "draw " << std::string(str.toUtf8())
+ << " at " << x << "," << y << std::endl;
+ return textwidth;
+ }
+
+ QPixmap pm;
+ QString key = generateStringSignature(str, f);
+ // Warning: Left bearing is in general negative! Only the case
+ // where left bearing is negative is of interest WRT the the
+ // pixmap width and the text x-position.
+ // Only the left bearing of the first character is important
+ // as we always write from left to right, even for
+ // right-to-left languages.
+ int const lb = std::min(fi.metrics->lbearing(s[0]), 0);
+ int const mA = fi.metrics->maxAscent();
+ if (!QPixmapCache::find(key, pm)) {
+ // Only the right bearing of the last character is
+ // important as we always write from left to right,
+ // even for right-to-left languages.
+ int const rb = fi.metrics->rbearing(s[s.size()-1]);
+ int const w = textwidth + rb - lb;
+ int const mD = fi.metrics->maxDescent();
+ int const h = mA + mD;
+ pm = QPixmap(w, h);
+ pm.fill(Qt::transparent);
+ QLPainter p(&pm);
+ p.setQPainterPen(f.realColor());
+ if (p.font() != fi.font)
+ p.setFont(fi.font);
+ // We need to draw the text as LTR as we use our own bidi code.
+ p.setLayoutDirection(Qt::LeftToRight);
+ p.drawText(-lb, mA, str);
+ QPixmapCache::insert(key, pm);
+ LYXERR(Debug::PAINTING) << "h=" << h << " mA=" << mA << " mD=" << mD
+ << " w=" << w << " lb=" << lb << " tw=" << textwidth
+ << " rb=" << rb << endl;
+ }
+ // Draw the cached pixmap.
+ drawPixmap(x + lb, y - mA, pm);
+
+ return textwidth;
+}
+
+
+} // namespace frontend
+} // namespace lyx
--- /dev/null
+// -*- C++ -*-
+/**
+ * \file GuiPainter.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author John Levon
+ * \author Abdelrazak Younes
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#ifndef QLPAINTER_H
+#define QLPAINTER_H
+
+#include "frontends/Painter.h"
+
+#include "Color.h"
+
+#include <QPainter>
+
+class QString;
+
+namespace lyx {
+
+class Font;
+
+namespace frontend {
+
+/**
+ * QLPainter - a painter implementation for Qt4
+ */
+class QLPainter : public QPainter, public Painter {
+public:
+ QLPainter(QPaintDevice *);
+ virtual ~QLPainter();
+
+ /// draw a line from point to point
+ virtual void line(
+ int x1, int y1,
+ int x2, int y2,
+ Color_color,
+ line_style = line_solid,
+ line_width = line_thin);
+
+ /**
+ * lines - draw a set of lines
+ * @param xp array of points' x co-ords
+ * @param yp array of points' y co-ords
+ * @param np size of the points array
+ */
+ virtual void lines(
+ int const * xp,
+ int const * yp,
+ int np,
+ Color_color,
+ line_style = line_solid,
+ line_width = line_thin);
+
+ /// draw a rectangle
+ virtual void rectangle(
+ int x, int y,
+ int w, int h,
+ Color_color,
+ line_style = line_solid,
+ line_width = line_thin);
+
+ /// draw a filled rectangle
+ virtual void fillRectangle(
+ int x, int y,
+ int w, int h,
+ Color_color);
+
+ /// draw an arc
+ virtual void arc(
+ int x, int y,
+ unsigned int w, unsigned int h,
+ int a1, int a2,
+ Color_color);
+
+ /// draw a pixel
+ virtual void point(
+ int x, int y,
+ Color_color);
+
+ /// draw an image from the image cache
+ virtual void image(int x, int y,
+ int w, int h,
+ lyx::graphics::Image const & image);
+
+ /// draw a string at position x, y (y is the baseline)
+ virtual int text(int x, int y,
+ docstring const & str, Font const & f);
+
+ /// draw a char at position x, y (y is the baseline)
+ virtual int text(int x, int y, char_type c, Font const & f);
+
+private:
+ /// draw small caps text
+ /**
+ \return width of the drawn text.
+ */
+ int smallCapsText(int x, int y,
+ QString const & str, Font const & f);
+
+ /// set pen parameters
+ void setQPainterPen(Color_color col,
+ line_style ls = line_solid,
+ line_width lw = line_thin);
+
+ Color::color current_color_;
+ Painter::line_style current_ls_;
+ Painter::line_width current_lw_;
+};
+
+} // namespace frontend
+} // namespace lyx
+
+#endif // QLPAINTER_H
--- /dev/null
+/**
+ * \file GuiParagraph.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Edwin Leuven
+ * \author Richard Heck
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "GuiParagraph.h"
+#include "Qt2BC.h"
+#include "qt_helpers.h"
+
+#include "debug.h"
+#include "ParagraphParameters.h"
+#include "Spacing.h"
+
+#include "controllers/ControlParagraph.h"
+#include "controllers/frontend_helpers.h"
+
+#include <QCheckBox>
+#include <QLineEdit>
+#include <QPushButton>
+
+using std::string;
+using std::endl;
+
+/////////////////////////////////////////////////////////////////////
+//
+// GuiParagraphDialog
+//
+/////////////////////////////////////////////////////////////////////
+
+
+#include <boost/current_function.hpp>
+
+namespace lyx {
+namespace frontend {
+
+GuiParagraphDialog::GuiParagraphDialog(GuiParagraph * form)
+ : form_(form)
+{
+ setupUi(this);
+
+ connect(okPB, SIGNAL(clicked()), form_, SLOT(slotOK()));
+ connect(applyPB, SIGNAL(clicked()), form_, SLOT(slotApply()));
+ connect(closePB, SIGNAL(clicked()), form_, SLOT(slotClose()));
+ connect(restorePB, SIGNAL(clicked()), form_, SLOT(slotRestore()));
+ connect(alignDefaultRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
+ connect(alignJustRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
+ connect(alignLeftRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
+ connect(alignRightRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
+ connect(alignCenterRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
+ connect(linespacing, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
+ connect(linespacing, SIGNAL(activated(int)),
+ this, SLOT(enableLinespacingValue(int)));
+ connect(linespacingValue, SIGNAL(textChanged(const QString &)),
+ this, SLOT(change_adaptor()));
+ connect(indentCB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
+ connect(labelWidth, SIGNAL(textChanged(const QString &)),
+ this, SLOT(change_adaptor()));
+
+ linespacingValue->setValidator(new QDoubleValidator(linespacingValue));
+
+ labelWidth->setWhatsThis( qt_(
+ "As described in the User Guide, the width of"
+ " this text determines the width of the label part"
+ " of each item in environments like List and"
+ " Description.\n"
+ "\n"
+ " Normally, you won't need to set this,"
+ " since the largest label width of all the"
+ " items is used."
+ ));
+
+ radioMap[LYX_ALIGN_LAYOUT] = alignDefaultRB;
+ radioMap[LYX_ALIGN_BLOCK] = alignJustRB;
+ radioMap[LYX_ALIGN_LEFT] = alignLeftRB;
+ radioMap[LYX_ALIGN_RIGHT] = alignRightRB;
+ radioMap[LYX_ALIGN_CENTER] = alignCenterRB;
+
+ labelMap[LYX_ALIGN_LAYOUT] = _("Use Paragraph's Default Alignment");
+ labelMap[LYX_ALIGN_BLOCK] = _("Justified");
+ labelMap[LYX_ALIGN_LEFT] = _("Left");
+ labelMap[LYX_ALIGN_RIGHT] = _("Right");
+ labelMap[LYX_ALIGN_CENTER] = _("Center");
+}
+
+
+void GuiParagraphDialog::closeEvent(QCloseEvent * e)
+{
+ form_->slotWMHide();
+ e->accept();
+}
+
+
+void GuiParagraphDialog::change_adaptor()
+{
+ form_->changed();
+}
+
+
+void GuiParagraphDialog::enableLinespacingValue(int)
+{
+ bool const enable = linespacing->currentIndex() == 4;
+ linespacingValue->setEnabled(enable);
+}
+
+
+void GuiParagraphDialog::checkAlignmentRadioButtons() {
+ LyXAlignment const alignPossible = form_->controller().alignPossible();
+
+ QPRadioMap::iterator it = radioMap.begin();
+ for (; it != radioMap.end(); ++it) {
+ LyXAlignment const align = it->first;
+ it->second->setEnabled(align & alignPossible);
+ }
+ docstring label = labelMap[LYX_ALIGN_LAYOUT];
+ if (!form_->controller().haveMulitParSelection())
+ label += (" (" + labelMap[form_->controller().alignDefault()] + ")");
+ alignDefaultRB->setText(toqstr(label));
+}
+
+
+void GuiParagraphDialog::alignmentToRadioButtons(LyXAlignment align)
+{
+ QPRadioMap::const_iterator it = radioMap.begin();
+ for (;it != radioMap.end(); ++it) {
+ if (align == it->first) {
+ it->second->blockSignals(true);
+ it->second->setChecked(true);
+ it->second->blockSignals(false);
+ return;
+ }
+ }
+
+ lyxerr << BOOST_CURRENT_FUNCTION << "Unknown alignment "
+ << align << std::endl;
+}
+
+
+LyXAlignment GuiParagraphDialog::getAlignmentFromDialog()
+{
+ LyXAlignment alignment = LYX_ALIGN_NONE;
+ QPRadioMap::const_iterator it = radioMap.begin();
+ for (; it != radioMap.end(); ++it) {
+ if (it->second->isChecked()) {
+ alignment = it->first;
+ break;
+ }
+ }
+ return alignment;
+}
+
+
+/////////////////////////////////////////////////////////////////////
+//
+// GuiParagraph
+//
+/////////////////////////////////////////////////////////////////////
+
+typedef QController<ControlParagraph, GuiView<GuiParagraphDialog> >
+ ParagraphBase;
+
+
+GuiParagraph::GuiParagraph(Dialog & parent)
+ : ParagraphBase(parent, _("Paragraph Settings"))
+{}
+
+
+void GuiParagraph::build_dialog()
+{
+ // the dialog
+ dialog_.reset(new GuiParagraphDialog(this));
+
+ // Manage the ok, apply, restore and cancel/close buttons
+ bcview().setOK(dialog_->okPB);
+ bcview().setApply(dialog_->applyPB);
+ bcview().setCancel(dialog_->closePB);
+ bcview().setRestore(dialog_->restorePB);
+}
+
+
+void GuiParagraph::apply()
+{
+ ParagraphParameters & params = controller().params();
+
+ params.align(dialog_->getAlignmentFromDialog());
+
+ // get spacing
+ Spacing::Space linespacing = Spacing::Default;
+ string other;
+ switch (dialog_->linespacing->currentIndex()) {
+ case 0:
+ linespacing = Spacing::Default;
+ break;
+ case 1:
+ linespacing = Spacing::Single;
+ break;
+ case 2:
+ linespacing = Spacing::Onehalf;
+ break;
+ case 3:
+ linespacing = Spacing::Double;
+ break;
+ case 4:
+ linespacing = Spacing::Other;
+ other = fromqstr(dialog_->linespacingValue->text());
+ break;
+ }
+
+ Spacing const spacing(linespacing, other);
+ params.spacing(spacing);
+
+ // label width
+ params.labelWidthString(qstring_to_ucs4(dialog_->labelWidth->text()));
+ // indendation
+ params.noindent(!dialog_->indentCB->isChecked());
+}
+
+
+void GuiParagraph::update_contents()
+{
+ ParagraphParameters const & params = controller().params();
+
+ // label width
+ docstring const & labelwidth = params.labelWidthString();
+ // FIXME We should not compare translated strings
+ if (labelwidth != _("Senseless with this layout!")) {
+ dialog_->labelwidthGB->setEnabled(true);
+ dialog_->labelWidth->setText(toqstr(labelwidth));
+ } else {
+ dialog_->labelwidthGB->setEnabled(false);
+ dialog_->labelWidth->setText("");
+ }
+
+ // alignment
+ dialog_->checkAlignmentRadioButtons();
+ dialog_->alignmentToRadioButtons(params.align());
+
+ //indentation
+ bool const canindent = controller().canIndent();
+ dialog_->indentCB->setEnabled(canindent);
+ dialog_->indentCB->setChecked(canindent && !params.noindent());
+
+ // linespacing
+ int linespacing;
+ Spacing const & space = params.spacing();
+ switch (space.getSpace()) {
+ case Spacing::Single:
+ linespacing = 1;
+ break;
+ case Spacing::Onehalf:
+ linespacing = 2;
+ break;
+ case Spacing::Double:
+ linespacing = 3;
+ break;
+ case Spacing::Other:
+ linespacing = 4;
+ break;
+ default:
+ linespacing = 0;
+ break;
+ }
+ dialog_->linespacing->setCurrentIndex(linespacing);
+ if (space.getSpace() == Spacing::Other) {
+ dialog_->linespacingValue->setText(toqstr(space.getValueAsString()));
+ dialog_->linespacingValue->setEnabled(true);
+ } else {
+ dialog_->linespacingValue->setText("");
+ dialog_->linespacingValue->setEnabled(false);
+ }
+}
+
+} // namespace frontend
+} // namespace lyx
+
+#include "GuiParagraph_moc.cpp"
--- /dev/null
+// -*- C++ -*-
+/**
+ * \file GuiParagraph.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Edwin Leuven
+ * \author John Levon
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#ifndef QPARAGRAPH_H
+#define QPARAGRAPH_H
+
+#include "GuiDialogView.h"
+
+#include "Layout.h"
+#include "ui_ParagraphUi.h"
+
+#include <QDialog>
+#include <QCloseEvent>
+
+#include <map>
+
+namespace lyx {
+namespace frontend {
+
+class GuiParagraph;
+
+class GuiParagraphDialog : public QDialog, public Ui::ParagraphUi {
+ Q_OBJECT
+public:
+ GuiParagraphDialog(GuiParagraph * form);
+ ///
+ void checkAlignmentRadioButtons();
+ ///
+ void alignmentToRadioButtons(LyXAlignment align = LYX_ALIGN_LAYOUT);
+ ///
+ LyXAlignment getAlignmentFromDialog();
+protected:
+ void closeEvent (QCloseEvent * e);
+private:
+ GuiParagraph * form_;
+ typedef std::map<LyXAlignment, QRadioButton *> QPRadioMap;
+ QPRadioMap radioMap;
+ typedef std::map<LyXAlignment, docstring> QPAlignmentLabels;
+ QPAlignmentLabels labelMap;
+
+protected Q_SLOTS:
+ ///
+ void change_adaptor();
+ ///
+ void enableLinespacingValue(int);
+};
+
+
+class ControlParagraph;
+
+class GuiParagraph
+ : public QController<ControlParagraph, GuiView<GuiParagraphDialog> >
+{
+public:
+ friend class GuiParagraphDialog;
+
+ GuiParagraph(Dialog &);
+private:
+ /// Apply changes
+ virtual void apply();
+ /// update
+ virtual void update_contents();
+ /// build the dialog
+ virtual void build_dialog();
+};
+
+} // namespace frontend
+} // namespace lyx
+
+#endif // QPARAGRAPH_H
--- /dev/null
+/**
+ * \file GuiPopupMenu.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author John Levon
+ * \author Abdelrazak Younes
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include <boost/current_function.hpp>
+
+// Qt defines a macro 'signals' that clashes with a boost namespace.
+// All is well if the namespace is visible first.
+#include "GuiView.h"
+
+#include "Action.h"
+#include "GuiPopupMenu.h"
+#include "GuiMenubar.h"
+#include "qt_helpers.h"
+#include "MenuBackend.h"
+
+#include "support/lstrings.h"
+#include "debug.h"
+
+
+using std::make_pair;
+using std::string;
+using std::pair;
+using std::endl;
+
+
+namespace lyx {
+namespace frontend {
+
+GuiPopupMenu::GuiPopupMenu(GuiMenubar * owner,
+ MenuItem const & mi, bool topLevelMenu)
+ : owner_(owner)
+{
+ name_ = mi.submenuname();
+
+ setTitle(toqstr(getLabel(mi)));
+
+ if (topLevelMenu)
+ connect(this, SIGNAL(aboutToShow()), this, SLOT(update()));
+}
+
+
+void GuiPopupMenu::update()
+{
+ LYXERR(Debug::GUI) << BOOST_CURRENT_FUNCTION << endl;
+ LYXERR(Debug::GUI) << "\tTriggered menu: " << to_utf8(name_) << endl;
+
+ clear();
+
+ if (name_.empty())
+ return;
+
+ // Here, We make sure that theLyXFunc points to the correct LyXView.
+ theLyXFunc().setLyXView(owner_->view());
+
+ Menu const & fromLyxMenu = owner_->backend().getMenu(name_);
+ owner_->backend().expand(fromLyxMenu, topLevelMenu_, owner_->view()->buffer());
+
+ if (!owner_->backend().hasMenu(topLevelMenu_.name())) {
+ LYXERR(Debug::GUI) << "\tWARNING: menu seems empty"
+ << to_utf8(topLevelMenu_.name()) << endl;
+ }
+ populate(this, &topLevelMenu_);
+}
+
+
+void GuiPopupMenu::populate(QMenu * qMenu, Menu * menu)
+{
+ LYXERR(Debug::GUI) << "populating menu " << to_utf8(menu->name()) ;
+ if (menu->size() == 0) {
+ LYXERR(Debug::GUI) << "\tERROR: empty menu "
+ << to_utf8(menu->name()) << endl;
+ return;
+ }
+ else {
+ LYXERR(Debug::GUI) << " ***** menu entries " << menu->size() << endl;
+ }
+
+ Menu::const_iterator m = menu->begin();
+ Menu::const_iterator end = menu->end();
+
+ for (; m != end; ++m) {
+
+ if (m->kind() == MenuItem::Separator) {
+
+ qMenu->addSeparator();
+ LYXERR(Debug::GUI) << "adding Menubar Separator" << endl;
+
+ } else if (m->kind() == MenuItem::Submenu) {
+
+ LYXERR(Debug::GUI) << "** creating New Sub-Menu "
+ << to_utf8(getLabel(*m)) << endl;
+ QMenu * subMenu = qMenu->addMenu(toqstr(getLabel(*m)));
+ populate(subMenu, m->submenu());
+
+ } else { // we have a MenuItem::Command
+
+ LYXERR(Debug::GUI) << "creating Menu Item "
+ << to_utf8(m->label()) << endl;
+
+ docstring label = getLabel(*m);
+ addBinding(label, *m);
+
+ Action * action = new Action(*(owner_->view()),
+ label, m->func());
+ qMenu->addAction(action);
+ }
+ }
+}
+
+
+docstring const GuiPopupMenu::getLabel(MenuItem const & mi)
+{
+ docstring const shortcut = mi.shortcut();
+ docstring label = support::subst(mi.label(),
+ from_ascii("&"), from_ascii("&&"));
+
+ if (!shortcut.empty()) {
+ docstring::size_type pos = label.find(shortcut);
+ if (pos != docstring::npos)
+ label.insert(pos, 1, char_type('&'));
+ }
+
+ return label;
+}
+
+
+void GuiPopupMenu::addBinding(docstring & label, MenuItem const & mi)
+{
+#ifdef Q_WS_MACX
+ docstring const binding = mi.binding(false);
+#else
+ docstring const binding = mi.binding(true);
+#endif
+ if (!binding.empty())
+ label += '\t' + binding;
+}
+
+
+} // namespace frontend
+} // namespace lyx
+
+#include "GuiPopupMenu_moc.cpp"
--- /dev/null
+// -*- C++ -*-
+/**
+ * \file GuiPopupMenu.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author John Levon
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#ifndef QLPOPUPMENU_H
+#define QLPOPUPMENU_H
+
+#include <QMenu>
+
+#include "FuncRequest.h"
+#include "MenuBackend.h"
+
+namespace lyx {
+namespace frontend {
+
+class GuiMenubar;
+
+/// a submenu
+class GuiPopupMenu : public QMenu {
+ Q_OBJECT
+public:
+
+ GuiPopupMenu(GuiMenubar * owner, MenuItem const & mi, bool topLevelMenu=false);
+
+ /// populates the menu or one of its submenu
+ /// This is used as a recursive function
+ void populate(QMenu* qMenu, Menu * menu);
+
+public Q_SLOTS:
+ /// populate the toplevel menu and all children
+ void update();
+
+private:
+
+ /// our owning menubar
+ GuiMenubar * owner_;
+
+ /// the name of this menu
+ docstring name_;
+
+private:
+ /// Get a Menu item label from the menu backend
+ docstring const getLabel(MenuItem const & mi);
+
+ /// add binding keys a the menu item label.
+ void addBinding(docstring & label, MenuItem const & mi);
+
+ /// Top Level Menu
+ Menu topLevelMenu_;
+};
+
+} // namespace frontend
+} // namespace lyx
+
+#endif // QLPOPUPMENU_H
--- /dev/null
+/**
+ * \file GuiPrefs.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author John Levon
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "GuiPrefs.h"
+
+#include "Qt2BC.h"
+#include "qt_helpers.h"
+#include "GuiApplication.h"
+
+#include "ConverterCache.h"
+#include "Session.h"
+#include "debug.h"
+#include "Color.h"
+#include "Font.h"
+#include "PanelStack.h"
+#include "GuiFontExample.h"
+#include "gettext.h"
+
+#include "support/lstrings.h"
+#include "support/os.h"
+
+#include "controllers/ControlPrefs.h"
+#include "controllers/frontend_helpers.h"
+
+#include "frontends/alert.h"
+#include "frontends/Application.h"
+
+#include <QCheckBox>
+#include <QColorDialog>
+#include <QFontDatabase>
+#include <QLineEdit>
+#include <QPushButton>
+#include <QSpinBox>
+#include <QString>
+#include <QValidator>
+#include <QCloseEvent>
+
+#include <boost/tuple/tuple.hpp>
+#include <iomanip>
+#include <sstream>
+
+using namespace Ui;
+
+using lyx::support::compare_ascii_no_case;
+using lyx::support::os::external_path;
+using lyx::support::os::external_path_list;
+using lyx::support::os::internal_path;
+using lyx::support::os::internal_path_list;
+
+using std::endl;
+using std::string;
+using std::pair;
+using std::vector;
+
+
+namespace lyx {
+namespace frontend {
+
+/////////////////////////////////////////////////////////////////////
+//
+// Helpers
+//
+/////////////////////////////////////////////////////////////////////
+
+// FIXME: move to frontend_helpers.h
+
+template<class A>
+static size_t findPos_helper(std::vector<A> const & vec, A const & val)
+{
+ typedef typename std::vector<A>::const_iterator Cit;
+
+ Cit it = std::find(vec.begin(), vec.end(), val);
+ if (it == vec.end())
+ return 0;
+ return std::distance(vec.begin(), it);
+}
+
+
+static void setComboxFont(QComboBox * cb, string const & family,
+ string const & foundry)
+{
+ string const name = makeFontName(family, foundry);
+ for (int i = 0; i < cb->count(); ++i) {
+ if (fromqstr(cb->itemText(i)) == name) {
+ cb->setCurrentIndex(i);
+ return;
+ }
+ }
+
+ // Try matching without foundry name
+
+ // We count in reverse in order to prefer the Xft foundry
+ for (int i = cb->count() - 1; i >= 0; --i) {
+ pair<string, string> tmp = parseFontName(fromqstr(cb->itemText(i)));
+ if (compare_ascii_no_case(tmp.first, family) == 0) {
+ cb->setCurrentIndex(i);
+ return;
+ }
+ }
+
+ // family alone can contain e.g. "Helvetica [Adobe]"
+ pair<string, string> tmpfam = parseFontName(family);
+
+ // We count in reverse in order to prefer the Xft foundry
+ for (int i = cb->count() - 1; i >= 0; --i) {
+ pair<string, string> tmp = parseFontName(fromqstr(cb->itemText(i)));
+ if (compare_ascii_no_case(tmp.first, tmpfam.first) == 0) {
+ cb->setCurrentIndex(i);
+ return;
+ }
+ }
+
+ // Bleh, default fonts, and the names couldn't be found. Hack
+ // for bug 1063.
+
+ QFont font;
+ font.setKerning(false);
+
+ if (family == theApp()->romanFontName()) {
+ font.setStyleHint(QFont::Serif);
+ font.setFamily(family.c_str());
+ } else if (family == theApp()->sansFontName()) {
+ font.setStyleHint(QFont::SansSerif);
+ font.setFamily(family.c_str());
+ } else if (family == theApp()->typewriterFontName()) {
+ font.setStyleHint(QFont::TypeWriter);
+ font.setFamily(family.c_str());
+ } else {
+ lyxerr << "FAILED to find the default font: '"
+ << foundry << "', '" << family << '\''<< endl;
+ return;
+ }
+
+ QFontInfo info(font);
+ pair<string, string> tmp = parseFontName(fromqstr(info.family()));
+ string const & default_font_name = tmp.first;
+ lyxerr << "Apparent font is " << default_font_name << endl;
+
+ for (int i = 0; i < cb->count(); ++i) {
+ lyxerr << "Looking at " << fromqstr(cb->itemText(i)) << endl;
+ if (compare_ascii_no_case(fromqstr(cb->itemText(i)),
+ default_font_name) == 0) {
+ cb->setCurrentIndex(i);
+ return;
+ }
+ }
+
+ lyxerr << "FAILED to find the font: '"
+ << foundry << "', '" << family << '\'' <<endl;
+}
+
+
+/////////////////////////////////////////////////////////////////////
+//
+// PrefPlaintext
+//
+/////////////////////////////////////////////////////////////////////
+
+PrefPlaintext::PrefPlaintext(QWidget * parent)
+ : PrefModule(_("Plain text"), 0, parent)
+{
+ setupUi(this);
+ connect(plaintextLinelengthSB, SIGNAL(valueChanged(int)),
+ this, SIGNAL(changed()));
+ connect(plaintextRoffED, SIGNAL(textChanged(const QString&)),
+ this, SIGNAL(changed()));
+}
+
+
+void PrefPlaintext::apply(LyXRC & rc) const
+{
+ rc.plaintext_linelen = plaintextLinelengthSB->value();
+ rc.plaintext_roff_command = fromqstr(plaintextRoffED->text());
+}
+
+
+void PrefPlaintext::update(LyXRC const & rc)
+{
+ plaintextLinelengthSB->setValue(rc.plaintext_linelen);
+ plaintextRoffED->setText(toqstr(rc.plaintext_roff_command));
+}
+
+
+/////////////////////////////////////////////////////////////////////
+//
+// PrefDate
+//
+/////////////////////////////////////////////////////////////////////
+
+PrefDate::PrefDate(QWidget * parent)
+ : PrefModule(_("Date format"), 0, parent)
+{
+ setupUi(this);
+ connect(DateED, SIGNAL(textChanged(const QString &)),
+ this, SIGNAL(changed()));
+}
+
+
+void PrefDate::apply(LyXRC & rc) const
+{
+ rc.date_insert_format = fromqstr(DateED->text());
+}
+
+
+void PrefDate::update(LyXRC const & rc)
+{
+ DateED->setText(toqstr(rc.date_insert_format));
+}
+
+
+/////////////////////////////////////////////////////////////////////
+//
+// PrefKeyboard
+//
+/////////////////////////////////////////////////////////////////////
+
+PrefKeyboard::PrefKeyboard(GuiPrefs * form, QWidget * parent)
+ : PrefModule(_("Keyboard"), form, parent)
+{
+ setupUi(this);
+
+ connect(keymapCB, SIGNAL(clicked()),
+ this, SIGNAL(changed()));
+ connect(firstKeymapED, SIGNAL(textChanged(const QString&)),
+ this, SIGNAL(changed()));
+ connect(secondKeymapED, SIGNAL(textChanged(const QString&)),
+ this, SIGNAL(changed()));
+}
+
+
+void PrefKeyboard::apply(LyXRC & rc) const
+{
+ // FIXME: can derive CB from the two EDs
+ rc.use_kbmap = keymapCB->isChecked();
+ rc.primary_kbmap = internal_path(fromqstr(firstKeymapED->text()));
+ rc.secondary_kbmap = internal_path(fromqstr(secondKeymapED->text()));
+}
+
+
+void PrefKeyboard::update(LyXRC const & rc)
+{
+ // FIXME: can derive CB from the two EDs
+ keymapCB->setChecked(rc.use_kbmap);
+ firstKeymapED->setText(toqstr(external_path(rc.primary_kbmap)));
+ secondKeymapED->setText(toqstr(external_path(rc.secondary_kbmap)));
+}
+
+
+QString PrefKeyboard::testKeymap(QString keymap)
+{
+ return toqstr(form_->controller().browsekbmap(from_utf8(internal_path(fromqstr(keymap)))));
+}
+
+
+void PrefKeyboard::on_firstKeymapPB_clicked(bool)
+{
+ QString const file = testKeymap(firstKeymapED->text());
+ if (!file.isEmpty())
+ firstKeymapED->setText(file);
+}
+
+
+void PrefKeyboard::on_secondKeymapPB_clicked(bool)
+{
+ QString const file = testKeymap(secondKeymapED->text());
+ if (!file.isEmpty())
+ secondKeymapED->setText(file);
+}
+
+
+void PrefKeyboard::on_keymapCB_toggled(bool keymap)
+{
+ firstKeymapLA->setEnabled(keymap);
+ secondKeymapLA->setEnabled(keymap);
+ firstKeymapED->setEnabled(keymap);
+ secondKeymapED->setEnabled(keymap);
+ firstKeymapPB->setEnabled(keymap);
+ secondKeymapPB->setEnabled(keymap);
+}
+
+
+/////////////////////////////////////////////////////////////////////
+//
+// PrefLatex
+//
+/////////////////////////////////////////////////////////////////////
+
+PrefLatex::PrefLatex(GuiPrefs * form, QWidget * parent)
+ : PrefModule(_("LaTeX"), form, parent)
+{
+ setupUi(this);
+ connect(latexEncodingED, SIGNAL(textChanged(const QString&)),
+ this, SIGNAL(changed()));
+ connect(latexChecktexED, SIGNAL(textChanged(const QString&)),
+ this, SIGNAL(changed()));
+ connect(latexBibtexED, SIGNAL(textChanged(const QString&)),
+ this, SIGNAL(changed()));
+ connect(latexIndexED, SIGNAL(textChanged(const QString&)),
+ this, SIGNAL(changed()));
+ connect(latexAutoresetCB, SIGNAL(clicked()),
+ this, SIGNAL(changed()));
+ connect(latexDviPaperED, SIGNAL(textChanged(const QString&)),
+ this, SIGNAL(changed()));
+ connect(latexPaperSizeCO, SIGNAL(activated(int)),
+ this, SIGNAL(changed()));
+}
+
+
+void PrefLatex::apply(LyXRC & rc) const
+{
+ rc.fontenc = fromqstr(latexEncodingED->text());
+ rc.chktex_command = fromqstr(latexChecktexED->text());
+ rc.bibtex_command = fromqstr(latexBibtexED->text());
+ rc.index_command = fromqstr(latexIndexED->text());
+ rc.auto_reset_options = latexAutoresetCB->isChecked();
+ rc.view_dvi_paper_option = fromqstr(latexDviPaperED->text());
+ rc.default_papersize =
+ form_->controller().toPaperSize(latexPaperSizeCO->currentIndex());
+}
+
+
+void PrefLatex::update(LyXRC const & rc)
+{
+ latexEncodingED->setText(toqstr(rc.fontenc));
+ latexChecktexED->setText(toqstr(rc.chktex_command));
+ latexBibtexED->setText(toqstr(rc.bibtex_command));
+ latexIndexED->setText(toqstr(rc.index_command));
+ latexAutoresetCB->setChecked(rc.auto_reset_options);
+ latexDviPaperED->setText(toqstr(rc.view_dvi_paper_option));
+ latexPaperSizeCO->setCurrentIndex(
+ form_->controller().fromPaperSize(rc.default_papersize));
+}
+
+
+/////////////////////////////////////////////////////////////////////
+//
+// PrefScreenFonts
+//
+/////////////////////////////////////////////////////////////////////
+
+PrefScreenFonts::PrefScreenFonts(GuiPrefs * form, QWidget * parent)
+ : PrefModule(_("Screen fonts"), form, parent)
+{
+ setupUi(this);
+
+ connect(screenRomanCO, SIGNAL(activated(const QString&)),
+ this, SLOT(select_roman(const QString&)));
+ connect(screenSansCO, SIGNAL(activated(const QString&)),
+ this, SLOT(select_sans(const QString&)));
+ connect(screenTypewriterCO, SIGNAL(activated(const QString&)),
+ this, SLOT(select_typewriter(const QString&)));
+
+ QFontDatabase fontdb;
+ QStringList families(fontdb.families());
+ for (QStringList::Iterator it = families.begin(); it != families.end(); ++it) {
+ screenRomanCO->addItem(*it);
+ screenSansCO->addItem(*it);
+ screenTypewriterCO->addItem(*it);
+ }
+ connect(screenRomanCO, SIGNAL(activated(const QString&)),
+ this, SIGNAL(changed()));
+ connect(screenSansCO, SIGNAL(activated(const QString&)),
+ this, SIGNAL(changed()));
+ connect(screenTypewriterCO, SIGNAL(activated(const QString&)),
+ this, SIGNAL(changed()));
+ connect(screenZoomSB, SIGNAL(valueChanged(int)),
+ this, SIGNAL(changed()));
+ connect(screenDpiSB, SIGNAL(valueChanged(int)),
+ this, SIGNAL(changed()));
+ connect(screenTinyED, SIGNAL(textChanged(const QString&)),
+ this, SIGNAL(changed()));
+ connect(screenSmallestED, SIGNAL(textChanged(const QString&)),
+ this, SIGNAL(changed()));
+ connect(screenSmallerED, SIGNAL(textChanged(const QString&)),
+ this, SIGNAL(changed()));
+ connect(screenSmallED, SIGNAL(textChanged(const QString&)),
+ this, SIGNAL(changed()));
+ connect(screenNormalED, SIGNAL(textChanged(const QString&)),
+ this, SIGNAL(changed()));
+ connect(screenLargeED, SIGNAL(textChanged(const QString&)),
+ this, SIGNAL(changed()));
+ connect(screenLargerED, SIGNAL(textChanged(const QString&)),
+ this, SIGNAL(changed()));
+ connect(screenLargestED, SIGNAL(textChanged(const QString&)),
+ this, SIGNAL(changed()));
+ connect(screenHugeED, SIGNAL(textChanged(const QString&)),
+ this, SIGNAL(changed()));
+ connect(screenHugerED, SIGNAL(textChanged(const QString&)),
+ this, SIGNAL(changed()));
+
+ screenTinyED->setValidator(new QDoubleValidator(
+ screenTinyED));
+ screenSmallestED->setValidator(new QDoubleValidator(
+ screenSmallestED));
+ screenSmallerED->setValidator(new QDoubleValidator(
+ screenSmallerED));
+ screenSmallED->setValidator(new QDoubleValidator(
+ screenSmallED));
+ screenNormalED->setValidator(new QDoubleValidator(
+ screenNormalED));
+ screenLargeED->setValidator(new QDoubleValidator(
+ screenLargeED));
+ screenLargerED->setValidator(new QDoubleValidator(
+ screenLargerED));
+ screenLargestED->setValidator(new QDoubleValidator(
+ screenLargestED));
+ screenHugeED->setValidator(new QDoubleValidator(
+ screenHugeED));
+ screenHugerED->setValidator(new QDoubleValidator(
+ screenHugerED));
+}
+
+
+void PrefScreenFonts::apply(LyXRC & rc) const
+{
+ LyXRC const oldrc(rc);
+
+ boost::tie(rc.roman_font_name, rc.roman_font_foundry)
+ = parseFontName(fromqstr(screenRomanCO->currentText()));
+ boost::tie(rc.sans_font_name, rc.sans_font_foundry) =
+ parseFontName(fromqstr(screenSansCO->currentText()));
+ boost::tie(rc.typewriter_font_name, rc.typewriter_font_foundry) =
+ parseFontName(fromqstr(screenTypewriterCO->currentText()));
+
+ rc.zoom = screenZoomSB->value();
+ rc.dpi = screenDpiSB->value();
+ rc.font_sizes[Font::SIZE_TINY] = fromqstr(screenTinyED->text());
+ rc.font_sizes[Font::SIZE_SCRIPT] = fromqstr(screenSmallestED->text());
+ rc.font_sizes[Font::SIZE_FOOTNOTE] = fromqstr(screenSmallerED->text());
+ rc.font_sizes[Font::SIZE_SMALL] = fromqstr(screenSmallED->text());
+ rc.font_sizes[Font::SIZE_NORMAL] = fromqstr(screenNormalED->text());
+ rc.font_sizes[Font::SIZE_LARGE] = fromqstr(screenLargeED->text());
+ rc.font_sizes[Font::SIZE_LARGER] = fromqstr(screenLargerED->text());
+ rc.font_sizes[Font::SIZE_LARGEST] = fromqstr(screenLargestED->text());
+ rc.font_sizes[Font::SIZE_HUGE] = fromqstr(screenHugeED->text());
+ rc.font_sizes[Font::SIZE_HUGER] = fromqstr(screenHugerED->text());
+
+ if (rc.font_sizes != oldrc.font_sizes
+ || rc.roman_font_name != oldrc.roman_font_name
+ || rc.sans_font_name != oldrc.sans_font_name
+ || rc.typewriter_font_name != oldrc.typewriter_font_name
+ || rc.zoom != oldrc.zoom || rc.dpi != oldrc.dpi) {
+ form_->controller().updateScreenFonts();
+ }
+}
+
+
+void PrefScreenFonts::update(LyXRC const & rc)
+{
+ setComboxFont(screenRomanCO, rc.roman_font_name,
+ rc.roman_font_foundry);
+ setComboxFont(screenSansCO, rc.sans_font_name,
+ rc.sans_font_foundry);
+ setComboxFont(screenTypewriterCO, rc.typewriter_font_name,
+ rc.typewriter_font_foundry);
+
+ select_roman(screenRomanCO->currentText());
+ select_sans(screenSansCO->currentText());
+ select_typewriter(screenTypewriterCO->currentText());
+
+ screenZoomSB->setValue(rc.zoom);
+ screenDpiSB->setValue(rc.dpi);
+ screenTinyED->setText(toqstr(rc.font_sizes[Font::SIZE_TINY]));
+ screenSmallestED->setText(toqstr(rc.font_sizes[Font::SIZE_SCRIPT]));
+ screenSmallerED->setText(toqstr(rc.font_sizes[Font::SIZE_FOOTNOTE]));
+ screenSmallED->setText(toqstr(rc.font_sizes[Font::SIZE_SMALL]));
+ screenNormalED->setText(toqstr(rc.font_sizes[Font::SIZE_NORMAL]));
+ screenLargeED->setText(toqstr(rc.font_sizes[Font::SIZE_LARGE]));
+ screenLargerED->setText(toqstr(rc.font_sizes[Font::SIZE_LARGER]));
+ screenLargestED->setText(toqstr(rc.font_sizes[Font::SIZE_LARGEST]));
+ screenHugeED->setText(toqstr(rc.font_sizes[Font::SIZE_HUGE]));
+ screenHugerED->setText(toqstr(rc.font_sizes[Font::SIZE_HUGER]));
+}
+
+void PrefScreenFonts::select_roman(const QString& name)
+{
+ screenRomanFE->set(QFont(name), name);
+}
+
+
+void PrefScreenFonts::select_sans(const QString& name)
+{
+ screenSansFE->set(QFont(name), name);
+}
+
+
+void PrefScreenFonts::select_typewriter(const QString& name)
+{
+ screenTypewriterFE->set(QFont(name), name);
+}
+
+
+/////////////////////////////////////////////////////////////////////
+//
+// PrefColors
+//
+/////////////////////////////////////////////////////////////////////
+
+PrefColors::PrefColors(GuiPrefs * form, QWidget * parent)
+ : PrefModule( _("Colors"), form, parent)
+{
+ setupUi(this);
+
+ // FIXME: all of this initialization should be put into the controller.
+ // See http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg113301.html
+ // for some discussion of why that is not trivial.
+ QPixmap icon(32, 32);
+ for (int i = 0; i < Color::ignore; ++i) {
+ Color::color lc = static_cast<Color::color>(i);
+ if (lc == Color::none
+ || lc == Color::black
+ || lc == Color::white
+ || lc == Color::red
+ || lc == Color::green
+ || lc == Color::blue
+ || lc == Color::cyan
+ || lc == Color::magenta
+ || lc == Color::yellow
+ || lc == Color::inherit
+ || lc == Color::ignore) continue;
+
+ lcolors_.push_back(lc);
+ }
+ lcolors_ = frontend::getSortedColors(lcolors_);
+ vector<Color_color>::const_iterator cit = lcolors_.begin();
+ vector<Color_color>::const_iterator const end = lcolors_.end();
+ for (; cit != end; ++cit)
+ {
+ // This is not a memory leak:
+ /*QListWidgetItem * newItem =*/ new QListWidgetItem(QIcon(icon),
+ toqstr(lcolor.getGUIName(*cit)), lyxObjectsLW);
+ }
+ curcolors_.resize(lcolors_.size());
+ newcolors_.resize(lcolors_.size());
+ // End initialization
+
+ connect(colorChangePB, SIGNAL(clicked()),
+ this, SLOT(change_color()));
+ connect(lyxObjectsLW, SIGNAL(itemSelectionChanged()),
+ this, SLOT(change_lyxObjects_selection()));
+ connect(lyxObjectsLW, SIGNAL(itemActivated(QListWidgetItem*)),
+ this, SLOT(change_color()));
+}
+
+
+void PrefColors::apply(LyXRC & /*rc*/) const
+{
+ for (unsigned int i = 0; i < lcolors_.size(); ++i) {
+ if (curcolors_[i] != newcolors_[i]) {
+ form_->controller().setColor(lcolors_[i], fromqstr(newcolors_[i]));
+ }
+ }
+}
+
+
+void PrefColors::update(LyXRC const & /*rc*/)
+{
+ for (unsigned int i = 0; i < lcolors_.size(); ++i) {
+ QColor color = QColor(guiApp->colorCache().get(lcolors_[i]));
+ QPixmap coloritem(32, 32);
+ coloritem.fill(color);
+ lyxObjectsLW->item(i)->setIcon(QIcon(coloritem));
+ newcolors_[i] = curcolors_[i] = color.name();
+ }
+ change_lyxObjects_selection();
+}
+
+void PrefColors::change_color()
+{
+ int const row = lyxObjectsLW->currentRow();
+
+ // just to be sure
+ if (row < 0) return;
+
+ QString const color = newcolors_[row];
+ QColor c(QColorDialog::getColor(QColor(color), qApp->focusWidget()));
+
+ if (c.isValid() && c.name() != color) {
+ newcolors_[row] = c.name();
+ QPixmap coloritem(32, 32);
+ coloritem.fill(c);
+ lyxObjectsLW->currentItem()->setIcon(QIcon(coloritem));
+ // emit signal
+ changed();
+ }
+}
+
+void PrefColors::change_lyxObjects_selection()
+{
+ colorChangePB->setDisabled(lyxObjectsLW->currentRow() < 0);
+}
+
+
+/////////////////////////////////////////////////////////////////////
+//
+// PrefCygwinPath
+//
+/////////////////////////////////////////////////////////////////////
+
+PrefCygwinPath::PrefCygwinPath(QWidget * parent)
+ : PrefModule(_("Paths"), 0, parent)
+{
+ setupUi(this);
+ connect(pathCB, SIGNAL(clicked()), this, SIGNAL(changed()));
+}
+
+
+void PrefCygwinPath::apply(LyXRC & rc) const
+{
+ rc.windows_style_tex_paths = pathCB->isChecked();
+}
+
+
+void PrefCygwinPath::update(LyXRC const & rc)
+{
+ pathCB->setChecked(rc.windows_style_tex_paths);
+}
+
+
+/////////////////////////////////////////////////////////////////////
+//
+// PrefDisplay
+//
+/////////////////////////////////////////////////////////////////////
+
+PrefDisplay::PrefDisplay(QWidget * parent)
+ : PrefModule(_("Graphics"), 0, parent)
+{
+ setupUi(this);
+ connect(instantPreviewCO, SIGNAL(activated(int)),
+ this, SIGNAL(changed()));
+ connect(displayGraphicsCO, SIGNAL(activated(int)),
+ this, SIGNAL(changed()));
+}
+
+
+void PrefDisplay::apply(LyXRC & rc) const
+{
+ switch (instantPreviewCO->currentIndex()) {
+ case 0: rc.preview = LyXRC::PREVIEW_OFF; break;
+ case 1: rc.preview = LyXRC::PREVIEW_NO_MATH; break;
+ case 2: rc.preview = LyXRC::PREVIEW_ON; break;
+ }
+
+ lyx::graphics::DisplayType dtype;
+ switch (displayGraphicsCO->currentIndex()) {
+ case 3: dtype = lyx::graphics::NoDisplay; break;
+ case 2: dtype = lyx::graphics::ColorDisplay; break;
+ case 1: dtype = lyx::graphics::GrayscaleDisplay; break;
+ case 0: dtype = lyx::graphics::MonochromeDisplay; break;
+ default: dtype = lyx::graphics::GrayscaleDisplay;
+ }
+ rc.display_graphics = dtype;
+
+ // FIXME!! The graphics cache no longer has a changeDisplay method.
+#if 0
+ if (old_value != rc.display_graphics) {
+ lyx::graphics::GCache & gc = lyx::graphics::GCache::get();
+ gc.changeDisplay();
+ }
+#endif
+}
+
+
+void PrefDisplay::update(LyXRC const & rc)
+{
+ switch (rc.preview) {
+ case LyXRC::PREVIEW_OFF:
+ instantPreviewCO->setCurrentIndex(0);
+ break;
+ case LyXRC::PREVIEW_NO_MATH :
+ instantPreviewCO->setCurrentIndex(1);
+ break;
+ case LyXRC::PREVIEW_ON :
+ instantPreviewCO->setCurrentIndex(2);
+ break;
+ }
+
+ int item = 2;
+ switch (rc.display_graphics) {
+ case lyx::graphics::NoDisplay: item = 3; break;
+ case lyx::graphics::ColorDisplay: item = 2; break;
+ case lyx::graphics::GrayscaleDisplay: item = 1; break;
+ case lyx::graphics::MonochromeDisplay: item = 0; break;
+ default: break;
+ }
+ displayGraphicsCO->setCurrentIndex(item);
+}
+
+
+/////////////////////////////////////////////////////////////////////
+//
+// PrefPaths
+//
+/////////////////////////////////////////////////////////////////////
+
+PrefPaths::PrefPaths(GuiPrefs * form, QWidget * parent)
+ : PrefModule(_("Paths"), form, parent)
+{
+ setupUi(this);
+ connect(templateDirPB, SIGNAL(clicked()), this, SLOT(select_templatedir()));
+ connect(tempDirPB, SIGNAL(clicked()), this, SLOT(select_tempdir()));
+ connect(backupDirPB, SIGNAL(clicked()), this, SLOT(select_backupdir()));
+ connect(workingDirPB, SIGNAL(clicked()), this, SLOT(select_workingdir()));
+ connect(lyxserverDirPB, SIGNAL(clicked()), this, SLOT(select_lyxpipe()));
+ connect(workingDirED, SIGNAL(textChanged(const QString&)),
+ this, SIGNAL(changed()));
+ connect(templateDirED, SIGNAL(textChanged(const QString&)),
+ this, SIGNAL(changed()));
+ connect(backupDirED, SIGNAL(textChanged(const QString&)),
+ this, SIGNAL(changed()));
+ connect(tempDirED, SIGNAL(textChanged(const QString&)),
+ this, SIGNAL(changed()));
+ connect(lyxserverDirED, SIGNAL(textChanged(const QString&)),
+ this, SIGNAL(changed()));
+ connect(pathPrefixED, SIGNAL(textChanged(const QString&)),
+ this, SIGNAL(changed()));
+}
+
+
+void PrefPaths::apply(LyXRC & rc) const
+{
+ rc.document_path = internal_path(fromqstr(workingDirED->text()));
+ rc.template_path = internal_path(fromqstr(templateDirED->text()));
+ rc.backupdir_path = internal_path(fromqstr(backupDirED->text()));
+ rc.tempdir_path = internal_path(fromqstr(tempDirED->text()));
+ rc.path_prefix = internal_path_list(fromqstr(pathPrefixED->text()));
+ // FIXME: should be a checkbox only
+ rc.lyxpipes = internal_path(fromqstr(lyxserverDirED->text()));
+}
+
+
+void PrefPaths::update(LyXRC const & rc)
+{
+ workingDirED->setText(toqstr(external_path(rc.document_path)));
+ templateDirED->setText(toqstr(external_path(rc.template_path)));
+ backupDirED->setText(toqstr(external_path(rc.backupdir_path)));
+ tempDirED->setText(toqstr(external_path(rc.tempdir_path)));
+ pathPrefixED->setText(toqstr(external_path_list(rc.path_prefix)));
+ // FIXME: should be a checkbox only
+ lyxserverDirED->setText(toqstr(external_path(rc.lyxpipes)));
+}
+
+
+void PrefPaths::select_templatedir()
+{
+ docstring file(form_->controller().browsedir(
+ from_utf8(internal_path(fromqstr(templateDirED->text()))),
+ _("Select a document templates directory")));
+ if (!file.empty())
+ templateDirED->setText(toqstr(file));
+}
+
+
+void PrefPaths::select_tempdir()
+{
+ docstring file(form_->controller().browsedir(
+ from_utf8(internal_path(fromqstr(tempDirED->text()))),
+ _("Select a temporary directory")));
+ if (!file.empty())
+ tempDirED->setText(toqstr(file));
+}
+
+
+void PrefPaths::select_backupdir()
+{
+ docstring file(form_->controller().browsedir(
+ from_utf8(internal_path(fromqstr(backupDirED->text()))),
+ _("Select a backups directory")));
+ if (!file.empty())
+ backupDirED->setText(toqstr(file));
+}
+
+
+void PrefPaths::select_workingdir()
+{
+ docstring file(form_->controller().browsedir(
+ from_utf8(internal_path(fromqstr(workingDirED->text()))),
+ _("Select a document directory")));
+ if (!file.empty())
+ workingDirED->setText(toqstr(file));
+}
+
+
+void PrefPaths::select_lyxpipe()
+{
+ docstring file(form_->controller().browse(
+ from_utf8(internal_path(fromqstr(lyxserverDirED->text()))),
+ _("Give a filename for the LyX server pipe")));
+ if (!file.empty())
+ lyxserverDirED->setText(toqstr(file));
+}
+
+
+/////////////////////////////////////////////////////////////////////
+//
+// PrefSpellchecker
+//
+/////////////////////////////////////////////////////////////////////
+
+PrefSpellchecker::PrefSpellchecker(GuiPrefs * form, QWidget * parent)
+ : PrefModule(_("Spellchecker"), form, parent)
+{
+ setupUi(this);
+
+ connect(persDictionaryPB, SIGNAL(clicked()), this, SLOT(select_dict()));
+#if defined (USE_ISPELL)
+ connect(spellCommandCO, SIGNAL(activated(int)),
+ this, SIGNAL(changed()));
+#else
+ spellCommandCO->setEnabled(false);
+#endif
+ connect(altLanguageED, SIGNAL(textChanged(const QString&)),
+ this, SIGNAL(changed()));
+ connect(escapeCharactersED, SIGNAL(textChanged(const QString&)),
+ this, SIGNAL(changed()));
+ connect(persDictionaryED, SIGNAL(textChanged(const QString&)),
+ this, SIGNAL(changed()));
+ connect(compoundWordCB, SIGNAL(clicked()),
+ this, SIGNAL(changed()));
+ connect(inputEncodingCB, SIGNAL(clicked()),
+ this, SIGNAL(changed()));
+
+ spellCommandCO->addItem(qt_("ispell"));
+ spellCommandCO->addItem(qt_("aspell"));
+ spellCommandCO->addItem(qt_("hspell"));
+#ifdef USE_PSPELL
+ spellCommandCO->addItem(qt_("pspell (library)"));
+#else
+#ifdef USE_ASPELL
+ spellCommandCO->addItem(qt_("aspell (library)"));
+#endif
+#endif
+}
+
+
+void PrefSpellchecker::apply(LyXRC & rc) const
+{
+ switch (spellCommandCO->currentIndex()) {
+ case 0:
+ case 1:
+ case 2:
+ rc.use_spell_lib = false;
+ rc.isp_command = fromqstr(spellCommandCO->currentText());
+ break;
+ case 3:
+ rc.use_spell_lib = true;
+ break;
+ }
+
+ // FIXME: remove isp_use_alt_lang
+ rc.isp_alt_lang = fromqstr(altLanguageED->text());
+ rc.isp_use_alt_lang = !rc.isp_alt_lang.empty();
+ // FIXME: remove isp_use_esc_chars
+ rc.isp_esc_chars = fromqstr(escapeCharactersED->text());
+ rc.isp_use_esc_chars = !rc.isp_esc_chars.empty();
+ // FIXME: remove isp_use_pers_dict
+ rc.isp_pers_dict = internal_path(fromqstr(persDictionaryED->text()));
+ rc.isp_use_pers_dict = !rc.isp_pers_dict.empty();
+ rc.isp_accept_compound = compoundWordCB->isChecked();
+ rc.isp_use_input_encoding = inputEncodingCB->isChecked();
+}
+
+
+void PrefSpellchecker::update(LyXRC const & rc)
+{
+ spellCommandCO->setCurrentIndex(0);
+
+ if (rc.isp_command == "ispell") {
+ spellCommandCO->setCurrentIndex(0);
+ } else if (rc.isp_command == "aspell") {
+ spellCommandCO->setCurrentIndex(1);
+ } else if (rc.isp_command == "hspell") {
+ spellCommandCO->setCurrentIndex(2);
+ }
+
+ if (rc.use_spell_lib) {
+#if defined(USE_ASPELL) || defined(USE_PSPELL)
+ spellCommandCO->setCurrentIndex(3);
+#endif
+ }
+
+ // FIXME: remove isp_use_alt_lang
+ altLanguageED->setText(toqstr(rc.isp_alt_lang));
+ // FIXME: remove isp_use_esc_chars
+ escapeCharactersED->setText(toqstr(rc.isp_esc_chars));
+ // FIXME: remove isp_use_pers_dict
+ persDictionaryED->setText(toqstr(external_path(rc.isp_pers_dict)));
+ compoundWordCB->setChecked(rc.isp_accept_compound);
+ inputEncodingCB->setChecked(rc.isp_use_input_encoding);
+}
+
+
+void PrefSpellchecker::select_dict()
+{
+ docstring file(form_->controller().browsedict(
+ from_utf8(internal_path(fromqstr(persDictionaryED->text())))));
+ if (!file.empty())
+ persDictionaryED->setText(toqstr(file));
+}
+
+
+
+/////////////////////////////////////////////////////////////////////
+//
+// PrefConverters
+//
+/////////////////////////////////////////////////////////////////////
+
+
+PrefConverters::PrefConverters(GuiPrefs * form, QWidget * parent)
+ : PrefModule(_("Converters"), form, parent)
+{
+ setupUi(this);
+
+ connect(converterNewPB, SIGNAL(clicked()),
+ this, SLOT(update_converter()));
+ connect(converterRemovePB, SIGNAL(clicked()),
+ this, SLOT(remove_converter()));
+ connect(converterModifyPB, SIGNAL(clicked()),
+ this, SLOT(update_converter()));
+ connect(convertersLW, SIGNAL(currentRowChanged(int)),
+ this, SLOT(switch_converter()));
+ connect(converterFromCO, SIGNAL(activated(const QString&)),
+ this, SLOT(converter_changed()));
+ connect(converterToCO, SIGNAL(activated(const QString&)),
+ this, SLOT(converter_changed()));
+ connect(converterED, SIGNAL(textChanged(const QString&)),
+ this, SLOT(converter_changed()));
+ connect(converterFlagED, SIGNAL(textChanged(const QString&)),
+ this, SLOT(converter_changed()));
+ connect(converterNewPB, SIGNAL(clicked()),
+ this, SIGNAL(changed()));
+ connect(converterRemovePB, SIGNAL(clicked()),
+ this, SIGNAL(changed()));
+ connect(converterModifyPB, SIGNAL(clicked()),
+ this, SIGNAL(changed()));
+ connect(maxAgeLE, SIGNAL(textChanged(const QString&)),
+ this, SIGNAL(changed()));
+
+ maxAgeLE->setValidator(new QDoubleValidator(maxAgeLE));
+ converterDefGB->setFocusProxy(convertersLW);
+}
+
+
+void PrefConverters::apply(LyXRC & rc) const
+{
+ rc.use_converter_cache = cacheCB->isChecked();
+ rc.converter_cache_maxage = int(maxAgeLE->text().toDouble() * 86400.0);
+}
+
+
+void PrefConverters::update(LyXRC const & rc)
+{
+ cacheCB->setChecked(rc.use_converter_cache);
+ QString max_age;
+ max_age.setNum(double(rc.converter_cache_maxage) / 86400.0, 'g', 6);
+ maxAgeLE->setText(max_age);
+ updateGui();
+}
+
+
+void PrefConverters::updateGui()
+{
+ // save current selection
+ QString current = converterFromCO->currentText()
+ + " -> " + converterToCO->currentText();
+
+ converterFromCO->clear();
+ converterToCO->clear();
+
+ Formats::const_iterator cit = form_->formats().begin();
+ Formats::const_iterator end = form_->formats().end();
+ for (; cit != end; ++cit) {
+ converterFromCO->addItem(toqstr(cit->prettyname()));
+ converterToCO->addItem(toqstr(cit->prettyname()));
+ }
+
+ // currentRowChanged(int) is also triggered when updating the listwidget
+ // block signals to avoid unnecessary calls to switch_converter()
+ convertersLW->blockSignals(true);
+ convertersLW->clear();
+
+ Converters::const_iterator ccit = form_->converters().begin();
+ Converters::const_iterator cend = form_->converters().end();
+ for (; ccit != cend; ++ccit) {
+ std::string const name =
+ ccit->From->prettyname() + " -> " + ccit->To->prettyname();
+ int type = form_->converters().getNumber(ccit->From->name(), ccit->To->name());
+ new QListWidgetItem(toqstr(name), convertersLW, type);
+ }
+ convertersLW->sortItems(Qt::AscendingOrder);
+ convertersLW->blockSignals(false);
+
+ // restore selection
+ if (!current.isEmpty()) {
+ QList<QListWidgetItem *> const item =
+ convertersLW->findItems(current, Qt::MatchExactly);
+ if (item.size()>0)
+ convertersLW->setCurrentItem(item.at(0));
+ }
+
+ // select first element if restoring failed
+ if (convertersLW->currentRow() == -1)
+ convertersLW->setCurrentRow(0);
+
+ updateButtons();
+}
+
+
+void PrefConverters::switch_converter()
+{
+ int const cnr = convertersLW->currentItem()->type();
+ Converter const & c(form_->converters().get(cnr));
+ converterFromCO->setCurrentIndex(form_->formats().getNumber(c.from));
+ converterToCO->setCurrentIndex(form_->formats().getNumber(c.to));
+ converterED->setText(toqstr(c.command));
+ converterFlagED->setText(toqstr(c.flags));
+
+ updateButtons();
+}
+
+
+void PrefConverters::converter_changed()
+{
+ updateButtons();
+}
+
+
+void PrefConverters::updateButtons()
+{
+ Format const & from(form_->formats().get(converterFromCO->currentIndex()));
+ Format const & to(form_->formats().get(converterToCO->currentIndex()));
+ int const sel = form_->converters().getNumber(from.name(), to.name());
+ bool const known = !(sel < 0);
+ bool const valid = !(converterED->text().isEmpty()
+ || from.name() == to.name());
+
+ int const cnr = convertersLW->currentItem()->type();
+ Converter const & c(form_->converters().get(cnr));
+ string const old_command = c.command;
+ string const old_flag = c.flags;
+ string const new_command(fromqstr(converterED->text()));
+ string const new_flag(fromqstr(converterFlagED->text()));
+
+ bool modified = ((old_command != new_command) || (old_flag != new_flag));
+
+ converterModifyPB->setEnabled(valid && known && modified);
+ converterNewPB->setEnabled(valid && !known);
+ converterRemovePB->setEnabled(known);
+
+ maxAgeLE->setEnabled(cacheCB->isChecked());
+ maxAgeLA->setEnabled(cacheCB->isChecked());
+}
+
+
+// FIXME: user must
+// specify unique from/to or it doesn't appear. This is really bad UI
+// this is why we can use the same function for both new and modify
+void PrefConverters::update_converter()
+{
+ Format const & from(form_->formats().get(converterFromCO->currentIndex()));
+ Format const & to(form_->formats().get(converterToCO->currentIndex()));
+ string const flags = fromqstr(converterFlagED->text());
+ string const command = fromqstr(converterED->text());
+
+ Converter const * old = form_->converters().getConverter(from.name(), to.name());
+ form_->converters().add(from.name(), to.name(), command, flags);
+ if (!old) {
+ form_->converters().updateLast(form_->formats());
+ }
+
+ updateGui();
+
+ // Remove all files created by this converter from the cache, since
+ // the modified converter might create different files.
+ ConverterCache::get().remove_all(from.name(), to.name());
+}
+
+
+void PrefConverters::remove_converter()
+{
+ Format const & from(form_->formats().get(converterFromCO->currentIndex()));
+ Format const & to(form_->formats().get(converterToCO->currentIndex()));
+ form_->converters().erase(from.name(), to.name());
+
+ updateGui();
+
+ // Remove all files created by this converter from the cache, since
+ // a possible new converter might create different files.
+ ConverterCache::get().remove_all(from.name(), to.name());
+}
+
+
+void PrefConverters::on_cacheCB_stateChanged(int state)
+{
+ maxAgeLE->setEnabled(state == Qt::Checked);
+ maxAgeLA->setEnabled(state == Qt::Checked);
+ changed();
+}
+
+
+/////////////////////////////////////////////////////////////////////
+//
+// PrefCopiers
+//
+/////////////////////////////////////////////////////////////////////
+
+PrefCopiers::PrefCopiers(GuiPrefs * form, QWidget * parent)
+ : PrefModule(_("Copiers"), form, parent)
+{
+ setupUi(this);
+
+ connect(copierNewPB, SIGNAL(clicked()), this, SLOT(new_copier()));
+ connect(copierRemovePB, SIGNAL(clicked()), this, SLOT(remove_copier()));
+ connect(copierModifyPB, SIGNAL(clicked()), this, SLOT(modify_copier()));
+ connect(AllCopiersLW, SIGNAL(currentRowChanged(int)),
+ this, SLOT(switch_copierLB(int)));
+ connect(copierFormatCO, SIGNAL(activated(int)),
+ this, SLOT(switch_copierCO(int)));
+ connect(copierNewPB, SIGNAL(clicked()),
+ this, SIGNAL(changed()));
+ connect(copierRemovePB, SIGNAL(clicked()),
+ this, SIGNAL(changed()));
+ connect(copierModifyPB, SIGNAL(clicked()),
+ this, SIGNAL(changed()));
+ connect(copierFormatCO, SIGNAL(activated(const QString &)),
+ this, SLOT(copiers_changed()));
+ connect(copierED, SIGNAL(textChanged(const QString &)),
+ this, SLOT(copiers_changed()));
+}
+
+
+void PrefCopiers::apply(LyXRC & /*rc*/) const
+{
+}
+
+
+void PrefCopiers::update(LyXRC const & /*rc*/)
+{
+ update();
+}
+
+
+void PrefCopiers::update()
+{
+ // The choice widget
+ // save current selection
+ QString current = copierFormatCO->currentText();
+ copierFormatCO->clear();
+
+ for (Formats::const_iterator it = form_->formats().begin(),
+ end = form_->formats().end();
+ it != end; ++it) {
+ copierFormatCO->addItem(toqstr(it->prettyname()));
+ }
+
+ // The browser widget
+ AllCopiersLW->clear();
+
+ for (Movers::const_iterator it = form_->movers().begin(),
+ end = form_->movers().end();
+ it != end; ++it) {
+ std::string const & command = it->second.command();
+ if (command.empty())
+ continue;
+ QString const pretty = toqstr(form_->formats().prettyName(it->first));
+ AllCopiersLW->addItem(pretty);
+ }
+ AllCopiersLW->sortItems(Qt::AscendingOrder);
+
+ // restore selection
+ if (!current.isEmpty()) {
+ QList<QListWidgetItem *> item =
+ AllCopiersLW->findItems(current, Qt::MatchExactly);
+ if (item.size()>0)
+ AllCopiersLW->setCurrentItem(item.at(0));
+ }
+ // select first element if restoring failed
+ if (AllCopiersLW->currentRow() == -1)
+ AllCopiersLW->setCurrentRow(0);
+}
+
+
+namespace {
+
+class SamePrettyName {
+public:
+ SamePrettyName(string const & n) : pretty_name_(n) {}
+
+ bool operator()(Format const & fmt) const {
+ return fmt.prettyname() == pretty_name_;
+ }
+
+private:
+ string const pretty_name_;
+};
+
+
+Format const * getFormat(std::string const & prettyname)
+{
+ Formats::const_iterator it = formats.begin();
+ Formats::const_iterator const end = formats.end();
+ it = std::find_if(it, end, SamePrettyName(prettyname));
+ return it == end ? 0 : &*it;
+}
+
+} // namespace anon
+
+
+void PrefCopiers::switch_copierLB(int row)
+{
+ if (row < 0)
+ return;
+
+ // FIXME UNICODE?
+ std::string const browser_text =
+ fromqstr(AllCopiersLW->currentItem()->text());
+ Format const * fmt = getFormat(browser_text);
+ if (fmt == 0)
+ return;
+
+ QString const gui_name = toqstr(fmt->prettyname());
+ QString const command = toqstr(form_->movers().command(fmt->name()));
+
+ copierED->clear();
+ int const combo_size = copierFormatCO->count();
+ for (int i = 0; i < combo_size; ++i) {
+ QString const text = copierFormatCO->itemText(i);
+ if (text == gui_name) {
+ copierFormatCO->setCurrentIndex(i);
+ copierED->setText(command);
+ break;
+ }
+ }
+ updateButtons();
+}
+
+
+void PrefCopiers::switch_copierCO(int row)
+{
+ if (row<0)
+ return;
+
+ std::string const combo_text =
+ fromqstr(copierFormatCO->currentText());
+ Format const * fmt = getFormat(combo_text);
+ if (fmt == 0)
+ return;
+
+ QString const command = toqstr(form_->movers().command(fmt->name()));
+ copierED->setText(command);
+
+ QListWidgetItem * const index = AllCopiersLW->currentItem();
+ if (index >= 0)
+ AllCopiersLW->setItemSelected(index, false);
+
+ QString const gui_name = toqstr(fmt->prettyname());
+ int const browser_size = AllCopiersLW->count();
+ for (int i = 0; i < browser_size; ++i) {
+ QString const text = AllCopiersLW->item(i)->text();
+ if (text == gui_name) {
+ QListWidgetItem * item = AllCopiersLW->item(i);
+ AllCopiersLW->setItemSelected(item, true);
+ break;
+ }
+ }
+}
+
+
+void PrefCopiers::copiers_changed()
+{
+ updateButtons();
+}
+
+
+void PrefCopiers::updateButtons()
+{
+ QString selected = copierFormatCO->currentText();
+
+ bool known = false;
+ for (int i = 0; i < AllCopiersLW->count(); ++i) {
+ if (AllCopiersLW->item(i)->text() == selected)
+ known = true;
+ }
+
+ bool const valid = !copierED->text().isEmpty();
+
+ Format const * fmt = getFormat(fromqstr(selected));
+ string const old_command = form_->movers().command(fmt->name());
+ string const new_command(fromqstr(copierED->text()));
+
+ bool modified = (old_command != new_command);
+
+ copierModifyPB->setEnabled(valid && known && modified);
+ copierNewPB->setEnabled(valid && !known);
+ copierRemovePB->setEnabled(known);
+}
+
+
+void PrefCopiers::new_copier()
+{
+ std::string const combo_text =
+ fromqstr(copierFormatCO->currentText());
+ Format const * fmt = getFormat(combo_text);
+ if (fmt == 0)
+ return;
+
+ string const command = fromqstr(copierED->text());
+ if (command.empty())
+ return;
+
+ form_->movers().set(fmt->name(), command);
+
+ update();
+ int const last = AllCopiersLW->count() - 1;
+ AllCopiersLW->setCurrentRow(last);
+
+ updateButtons();
+}
+
+
+void PrefCopiers::modify_copier()
+{
+ std::string const combo_text =
+ fromqstr(copierFormatCO->currentText());
+ Format const * fmt = getFormat(combo_text);
+ if (fmt == 0)
+ return;
+
+ string const command = fromqstr(copierED->text());
+ form_->movers().set(fmt->name(), command);
+
+ update();
+ updateButtons();
+}
+
+
+void PrefCopiers::remove_copier()
+{
+ std::string const combo_text =
+ fromqstr(copierFormatCO->currentText());
+ Format const * fmt = getFormat(combo_text);
+ if (fmt == 0)
+ return;
+
+ string const & fmt_name = fmt->name();
+ form_->movers().set(fmt_name, string());
+
+ update();
+ updateButtons();
+}
+
+
+
+/////////////////////////////////////////////////////////////////////
+//
+// PrefFileformats
+//
+/////////////////////////////////////////////////////////////////////
+
+PrefFileformats::PrefFileformats(GuiPrefs * form, QWidget * parent)
+ : PrefModule(_("File formats"), form, parent)
+{
+ setupUi(this);
+
+ connect(formatNewPB, SIGNAL(clicked()),
+ this, SLOT(new_format()));
+ connect(formatRemovePB, SIGNAL(clicked()),
+ this, SLOT(remove_format()));
+ connect(formatModifyPB, SIGNAL(clicked()),
+ this, SLOT(modify_format()));
+ connect(formatsLW, SIGNAL(currentRowChanged(int)),
+ this, SLOT(switch_format(int)));
+ connect(formatED, SIGNAL(textChanged(const QString&)),
+ this, SLOT(fileformat_changed()));
+ connect(guiNameED, SIGNAL(textChanged(const QString&)),
+ this, SLOT(fileformat_changed()));
+ connect(shortcutED, SIGNAL(textChanged(const QString&)),
+ this, SLOT(fileformat_changed()));
+ connect(extensionED, SIGNAL(textChanged(const QString&)),
+ this, SLOT(fileformat_changed()));
+ connect(viewerED, SIGNAL(textChanged(const QString&)),
+ this, SLOT(fileformat_changed()));
+ connect(editorED, SIGNAL(textChanged(const QString&)),
+ this, SLOT(fileformat_changed()));
+ connect(documentCB, SIGNAL(clicked()),
+ this, SLOT(fileformat_changed()));
+ connect(vectorCB, SIGNAL(clicked()),
+ this, SLOT(fileformat_changed()));
+ connect(formatNewPB, SIGNAL(clicked()),
+ this, SIGNAL(changed()));
+ connect(formatRemovePB, SIGNAL(clicked()),
+ this, SIGNAL(changed()));
+ connect(formatModifyPB, SIGNAL(clicked()),
+ this, SIGNAL(changed()));
+}
+
+
+void PrefFileformats::apply(LyXRC & /*rc*/) const
+{
+}
+
+
+void PrefFileformats::update(LyXRC const & /*rc*/)
+{
+ update();
+}
+
+
+void PrefFileformats::update()
+{
+ // save current selection
+ QString current = guiNameED->text();
+
+ // update listwidget with formats
+ formatsLW->blockSignals(true);
+ formatsLW->clear();
+ Formats::const_iterator cit = form_->formats().begin();
+ Formats::const_iterator end = form_->formats().end();
+ for (; cit != end; ++cit) {
+ new QListWidgetItem(toqstr(cit->prettyname()),
+ formatsLW,
+ form_->formats().getNumber(cit->name()) );
+ }
+ formatsLW->sortItems(Qt::AscendingOrder);
+ formatsLW->blockSignals(false);
+
+ // restore selection
+ if (!current.isEmpty()) {
+ QList<QListWidgetItem *> item = formatsLW->findItems(current, Qt::MatchExactly);
+ if (item.size()>0)
+ formatsLW->setCurrentItem(item.at(0));
+ }
+ // select first element if restoring failed
+ if (formatsLW->currentRow() == -1)
+ formatsLW->setCurrentRow(0);
+}
+
+
+void PrefFileformats::switch_format(int nr)
+{
+ int const ftype = formatsLW->item(nr)->type();
+ Format const f = form_->formats().get(ftype);
+
+ formatED->setText(toqstr(f.name()));
+ guiNameED->setText(toqstr(f.prettyname()));
+ extensionED->setText(toqstr(f.extension()));
+ shortcutED->setText(toqstr(f.shortcut()));
+ viewerED->setText(toqstr(f.viewer()));
+ editorED->setText(toqstr(f.editor()));
+ documentCB->setChecked((f.documentFormat()));
+ vectorCB->setChecked((f.vectorFormat()));
+
+ updateButtons();
+}
+
+
+void PrefFileformats::fileformat_changed()
+{
+ updateButtons();
+}
+
+
+void PrefFileformats::updateButtons()
+{
+ QString const format = formatED->text();
+ QString const gui_name = guiNameED->text();
+ int const sel = form_->formats().getNumber(fromqstr(format));
+ bool gui_name_known = false;
+ int where = sel;
+ for (int i = 0; i < formatsLW->count(); ++i) {
+ if (formatsLW->item(i)->text() == gui_name) {
+ gui_name_known = true;
+ where = formatsLW->item(i)->type();
+ }
+ }
+
+ // assure that a gui name cannot be chosen twice
+ bool const known_otherwise = gui_name_known && (where != sel);
+
+ bool const known = !(sel < 0);
+ bool const valid = (!formatED->text().isEmpty()
+ && !guiNameED->text().isEmpty());
+
+ int const ftype = formatsLW->currentItem()->type();
+ Format const & f(form_->formats().get(ftype));
+ string const old_pretty(f.prettyname());
+ string const old_shortcut(f.shortcut());
+ string const old_extension(f.extension());
+ string const old_viewer(f.viewer());
+ string const old_editor(f.editor());
+ bool const old_document(f.documentFormat());
+ bool const old_vector(f.vectorFormat());
+
+ string const new_pretty(fromqstr(gui_name));
+ string const new_shortcut(fromqstr(shortcutED->text()));
+ string const new_extension(fromqstr(extensionED->text()));
+ string const new_viewer(fromqstr(viewerED->text()));
+ string const new_editor(fromqstr(editorED->text()));
+ bool const new_document(documentCB->isChecked());
+ bool const new_vector(vectorCB->isChecked());
+
+ bool modified = ((old_pretty != new_pretty) || (old_shortcut != new_shortcut)
+ || (old_extension != new_extension) || (old_viewer != new_viewer)
+ || old_editor != new_editor || old_document != new_document
+ || old_vector != new_vector);
+
+ formatModifyPB->setEnabled(valid && known && modified && !known_otherwise);
+ formatNewPB->setEnabled(valid && !known && !gui_name_known);
+ formatRemovePB->setEnabled(known);
+}
+
+
+void PrefFileformats::new_format()
+{
+ string const name = fromqstr(formatED->text());
+ string const prettyname = fromqstr(guiNameED->text());
+ string const extension = fromqstr(extensionED->text());
+ string const shortcut = fromqstr(shortcutED->text());
+ string const viewer = fromqstr(viewerED->text());
+ string const editor = fromqstr(editorED->text());
+ int flags = Format::none;
+ if (documentCB->isChecked())
+ flags |= Format::document;
+ if (vectorCB->isChecked())
+ flags |= Format::vector;
+
+ form_->formats().add(name, extension, prettyname, shortcut, viewer,
+ editor, flags);
+ form_->formats().sort();
+ form_->converters().update(form_->formats());
+
+ update();
+ updateButtons();
+ formatsChanged();
+}
+
+
+void PrefFileformats::modify_format()
+{
+ int const current_item = formatsLW->currentItem()->type();
+ Format const & oldformat = form_->formats().get(current_item);
+ form_->formats().erase(oldformat.name());
+
+ new_format();
+}
+
+
+void PrefFileformats::remove_format()
+{
+ int const nr = formatsLW->currentItem()->type();
+ string const current_text = form_->formats().get(nr).name();
+ if (form_->converters().formatIsUsed(current_text)) {
+ Alert::error(_("Format in use"),
+ _("Cannot remove a Format used by a Converter. "
+ "Remove the converter first."));
+ return;
+ }
+
+ form_->formats().erase(current_text);
+ form_->converters().update(form_->formats());
+
+ update();
+ updateButtons();
+ formatsChanged();
+}
+
+
+/////////////////////////////////////////////////////////////////////
+//
+// PrefLanguage
+//
+/////////////////////////////////////////////////////////////////////
+
+PrefLanguage::PrefLanguage(QWidget * parent)
+ : PrefModule(_("Language"), 0, parent)
+{
+ setupUi(this);
+
+ connect(rtlCB, SIGNAL(clicked()),
+ this, SIGNAL(changed()));
+ connect(markForeignCB, SIGNAL(clicked()),
+ this, SIGNAL(changed()));
+ connect(autoBeginCB, SIGNAL(clicked()),
+ this, SIGNAL(changed()));
+ connect(autoEndCB, SIGNAL(clicked()),
+ this, SIGNAL(changed()));
+ connect(useBabelCB, SIGNAL(clicked()),
+ this, SIGNAL(changed()));
+ connect(globalCB, SIGNAL(clicked()),
+ this, SIGNAL(changed()));
+ connect(languagePackageED, SIGNAL(textChanged(const QString&)),
+ this, SIGNAL(changed()));
+ connect(startCommandED, SIGNAL(textChanged(const QString&)),
+ this, SIGNAL(changed()));
+ connect(endCommandED, SIGNAL(textChanged(const QString&)),
+ this, SIGNAL(changed()));
+ connect(defaultLanguageCO, SIGNAL(activated(int)),
+ this, SIGNAL(changed()));
+
+ defaultLanguageCO->clear();
+
+ // store the lang identifiers for later
+ std::vector<LanguagePair> const langs = frontend::getLanguageData(false);
+ lang_ = getSecond(langs);
+
+ std::vector<LanguagePair>::const_iterator lit = langs.begin();
+ std::vector<LanguagePair>::const_iterator lend = langs.end();
+ for (; lit != lend; ++lit) {
+ defaultLanguageCO->addItem(toqstr(lit->first));
+ }
+}
+
+
+void PrefLanguage::apply(LyXRC & rc) const
+{
+ // FIXME: remove rtl_support bool
+ rc.rtl_support = rtlCB->isChecked();
+ rc.mark_foreign_language = markForeignCB->isChecked();
+ rc.language_auto_begin = autoBeginCB->isChecked();
+ rc.language_auto_end = autoEndCB->isChecked();
+ rc.language_use_babel = useBabelCB->isChecked();
+ rc.language_global_options = globalCB->isChecked();
+ rc.language_package = fromqstr(languagePackageED->text());
+ rc.language_command_begin = fromqstr(startCommandED->text());
+ rc.language_command_end = fromqstr(endCommandED->text());
+ rc.default_language = lang_[defaultLanguageCO->currentIndex()];
+}
+
+
+void PrefLanguage::update(LyXRC const & rc)
+{
+ // FIXME: remove rtl_support bool
+ rtlCB->setChecked(rc.rtl_support);
+ markForeignCB->setChecked(rc.mark_foreign_language);
+ autoBeginCB->setChecked(rc.language_auto_begin);
+ autoEndCB->setChecked(rc.language_auto_end);
+ useBabelCB->setChecked(rc.language_use_babel);
+ globalCB->setChecked(rc.language_global_options);
+ languagePackageED->setText(toqstr(rc.language_package));
+ startCommandED->setText(toqstr(rc.language_command_begin));
+ endCommandED->setText(toqstr(rc.language_command_end));
+
+ int const pos = int(findPos_helper(lang_, rc.default_language));
+ defaultLanguageCO->setCurrentIndex(pos);
+}
+
+
+/////////////////////////////////////////////////////////////////////
+//
+// PrefPrinter
+//
+/////////////////////////////////////////////////////////////////////
+
+PrefPrinter::PrefPrinter(QWidget * parent)
+ : PrefModule(_("Printer"), 0, parent)
+{
+ setupUi(this);
+
+ connect(printerAdaptCB, SIGNAL(clicked()),
+ this, SIGNAL(changed()));
+ connect(printerCommandED, SIGNAL(textChanged(const QString&)),
+ this, SIGNAL(changed()));
+ connect(printerNameED, SIGNAL(textChanged(const QString&)),
+ this, SIGNAL(changed()));
+ connect(printerPageRangeED, SIGNAL(textChanged(const QString&)),
+ this, SIGNAL(changed()));
+ connect(printerCopiesED, SIGNAL(textChanged(const QString&)),
+ this, SIGNAL(changed()));
+ connect(printerReverseED, SIGNAL(textChanged(const QString&)),
+ this, SIGNAL(changed()));
+ connect(printerToPrinterED, SIGNAL(textChanged(const QString&)),
+ this, SIGNAL(changed()));
+ connect(printerExtensionED, SIGNAL(textChanged(const QString&)),
+ this, SIGNAL(changed()));
+ connect(printerSpoolCommandED, SIGNAL(textChanged(const QString&)),
+ this, SIGNAL(changed()));
+ connect(printerPaperTypeED, SIGNAL(textChanged(const QString&)),
+ this, SIGNAL(changed()));
+ connect(printerEvenED, SIGNAL(textChanged(const QString&)),
+ this, SIGNAL(changed()));
+ connect(printerOddED, SIGNAL(textChanged(const QString&)),
+ this, SIGNAL(changed()));
+ connect(printerCollatedED, SIGNAL(textChanged(const QString&)),
+ this, SIGNAL(changed()));
+ connect(printerLandscapeED, SIGNAL(textChanged(const QString&)),
+ this, SIGNAL(changed()));
+ connect(printerToFileED, SIGNAL(textChanged(const QString&)),
+ this, SIGNAL(changed()));
+ connect(printerExtraED, SIGNAL(textChanged(const QString&)),
+ this, SIGNAL(changed()));
+ connect(printerSpoolPrefixED, SIGNAL(textChanged(const QString&)),
+ this, SIGNAL(changed()));
+ connect(printerPaperSizeED, SIGNAL(textChanged(const QString&)),
+ this, SIGNAL(changed()));
+}
+
+
+void PrefPrinter::apply(LyXRC & rc) const
+{
+ rc.print_adapt_output = printerAdaptCB->isChecked();
+ rc.print_command = fromqstr(printerCommandED->text());
+ rc.printer = fromqstr(printerNameED->text());
+
+ rc.print_pagerange_flag = fromqstr(printerPageRangeED->text());
+ rc.print_copies_flag = fromqstr(printerCopiesED->text());
+ rc.print_reverse_flag = fromqstr(printerReverseED->text());
+ rc.print_to_printer = fromqstr(printerToPrinterED->text());
+ rc.print_file_extension = fromqstr(printerExtensionED->text());
+ rc.print_spool_command = fromqstr(printerSpoolCommandED->text());
+ rc.print_paper_flag = fromqstr(printerPaperTypeED->text());
+ rc.print_evenpage_flag = fromqstr(printerEvenED->text());
+ rc.print_oddpage_flag = fromqstr(printerOddED->text());
+ rc.print_collcopies_flag = fromqstr(printerCollatedED->text());
+ rc.print_landscape_flag = fromqstr(printerLandscapeED->text());
+ rc.print_to_file = internal_path(fromqstr(printerToFileED->text()));
+ rc.print_extra_options = fromqstr(printerExtraED->text());
+ rc.print_spool_printerprefix = fromqstr(printerSpoolPrefixED->text());
+ rc.print_paper_dimension_flag = fromqstr(printerPaperSizeED->text());
+}
+
+
+void PrefPrinter::update(LyXRC const & rc)
+{
+ printerAdaptCB->setChecked(rc.print_adapt_output);
+ printerCommandED->setText(toqstr(rc.print_command));
+ printerNameED->setText(toqstr(rc.printer));
+
+ printerPageRangeED->setText(toqstr(rc.print_pagerange_flag));
+ printerCopiesED->setText(toqstr(rc.print_copies_flag));
+ printerReverseED->setText(toqstr(rc.print_reverse_flag));
+ printerToPrinterED->setText(toqstr(rc.print_to_printer));
+ printerExtensionED->setText(toqstr(rc.print_file_extension));
+ printerSpoolCommandED->setText(toqstr(rc.print_spool_command));
+ printerPaperTypeED->setText(toqstr(rc.print_paper_flag));
+ printerEvenED->setText(toqstr(rc.print_evenpage_flag));
+ printerOddED->setText(toqstr(rc.print_oddpage_flag));
+ printerCollatedED->setText(toqstr(rc.print_collcopies_flag));
+ printerLandscapeED->setText(toqstr(rc.print_landscape_flag));
+ printerToFileED->setText(toqstr(external_path(rc.print_to_file)));
+ printerExtraED->setText(toqstr(rc.print_extra_options));
+ printerSpoolPrefixED->setText(toqstr(rc.print_spool_printerprefix));
+ printerPaperSizeED->setText(toqstr(rc.print_paper_dimension_flag));
+}
+
+
+/////////////////////////////////////////////////////////////////////
+//
+// PrefUserInterface
+//
+/////////////////////////////////////////////////////////////////////
+
+PrefUserInterface::PrefUserInterface(GuiPrefs * form, QWidget * parent)
+ : PrefModule(_("User interface"), form, parent)
+{
+ setupUi(this);
+
+ connect(autoSaveCB, SIGNAL(toggled(bool)),
+ autoSaveLA, SLOT(setEnabled(bool)));
+ connect(autoSaveCB, SIGNAL(toggled(bool)),
+ autoSaveSB, SLOT(setEnabled(bool)));
+ connect(autoSaveCB, SIGNAL(toggled(bool)),
+ TextLabel1, SLOT(setEnabled(bool)));
+ connect(uiFilePB, SIGNAL(clicked()),
+ this, SLOT(select_ui()));
+ connect(bindFilePB, SIGNAL(clicked()),
+ this, SLOT(select_bind()));
+ connect(uiFileED, SIGNAL(textChanged(const QString &)),
+ this, SIGNAL(changed()));
+ connect(bindFileED, SIGNAL(textChanged(const QString &)),
+ this, SIGNAL(changed()));
+ connect(restoreCursorCB, SIGNAL(clicked()),
+ this, SIGNAL(changed()));
+ connect(loadSessionCB, SIGNAL(clicked()),
+ this, SIGNAL(changed()));
+ connect(loadWindowSizeCB, SIGNAL(clicked()),
+ this, SIGNAL(changed()));
+ connect(loadWindowLocationCB, SIGNAL(clicked()),
+ this, SIGNAL(changed()));
+ connect(windowWidthSB, SIGNAL(valueChanged(int)),
+ this, SIGNAL(changed()));
+ connect(windowHeightSB, SIGNAL(valueChanged(int)),
+ this, SIGNAL(changed()));
+ connect(cursorFollowsCB, SIGNAL(clicked()),
+ this, SIGNAL(changed()));
+ connect(autoSaveSB, SIGNAL(valueChanged(int)),
+ this, SIGNAL(changed()));
+ connect(autoSaveCB, SIGNAL(clicked()),
+ this, SIGNAL(changed()));
+ connect(lastfilesSB, SIGNAL(valueChanged(int)),
+ this, SIGNAL(changed()));
+ lastfilesSB->setMaximum(maxlastfiles);
+}
+
+
+void PrefUserInterface::apply(LyXRC & rc) const
+{
+ rc.ui_file = internal_path(fromqstr(uiFileED->text()));
+ rc.bind_file = internal_path(fromqstr(bindFileED->text()));
+ rc.use_lastfilepos = restoreCursorCB->isChecked();
+ rc.load_session = loadSessionCB->isChecked();
+ if (loadWindowSizeCB->isChecked()) {
+ rc.geometry_width = 0;
+ rc.geometry_height = 0;
+ } else {
+ rc.geometry_width = windowWidthSB->value();
+ rc.geometry_height = windowHeightSB->value();
+ }
+ rc.geometry_xysaved = loadWindowLocationCB->isChecked();
+ rc.cursor_follows_scrollbar = cursorFollowsCB->isChecked();
+ rc.autosave = autoSaveSB->value() * 60;
+ rc.make_backup = autoSaveCB->isChecked();
+ rc.num_lastfiles = lastfilesSB->value();
+}
+
+
+void PrefUserInterface::update(LyXRC const & rc)
+{
+ uiFileED->setText(toqstr(external_path(rc.ui_file)));
+ bindFileED->setText(toqstr(external_path(rc.bind_file)));
+ restoreCursorCB->setChecked(rc.use_lastfilepos);
+ loadSessionCB->setChecked(rc.load_session);
+ bool loadWindowSize = rc.geometry_width == 0 && rc.geometry_height == 0;
+ loadWindowSizeCB->setChecked(loadWindowSize);
+ if (!loadWindowSize) {
+ windowWidthSB->setValue(rc.geometry_width);
+ windowHeightSB->setValue(rc.geometry_height);
+ }
+ loadWindowLocationCB->setChecked(rc.geometry_xysaved);
+ cursorFollowsCB->setChecked(rc.cursor_follows_scrollbar);
+ // convert to minutes
+ int mins(rc.autosave / 60);
+ if (rc.autosave && !mins)
+ mins = 1;
+ autoSaveSB->setValue(mins);
+ autoSaveCB->setChecked(rc.make_backup);
+ lastfilesSB->setValue(rc.num_lastfiles);
+}
+
+
+
+void PrefUserInterface::select_ui()
+{
+ docstring const name =
+ from_utf8(internal_path(fromqstr(uiFileED->text())));
+ docstring file(form_->controller().browseUI(name));
+ if (!file.empty())
+ uiFileED->setText(toqstr(file));
+}
+
+
+void PrefUserInterface::select_bind()
+{
+ docstring const name =
+ from_utf8(internal_path(fromqstr(bindFileED->text())));
+ docstring file(form_->controller().browsebind(name));
+ if (!file.empty())
+ bindFileED->setText(toqstr(file));
+}
+
+
+void PrefUserInterface::on_loadWindowSizeCB_toggled(bool loadwindowsize)
+{
+ windowWidthLA->setDisabled(loadwindowsize);
+ windowHeightLA->setDisabled(loadwindowsize);
+ windowWidthSB->setDisabled(loadwindowsize);
+ windowHeightSB->setDisabled(loadwindowsize);
+}
+
+
+PrefIdentity::PrefIdentity(QWidget * parent)
+: PrefModule(_("Identity"), 0, parent)
+{
+ setupUi(this);
+
+ connect(nameED, SIGNAL(textChanged(const QString&)),
+ this, SIGNAL(changed()));
+ connect(emailED, SIGNAL(textChanged(const QString&)),
+ this, SIGNAL(changed()));
+}
+
+
+void PrefIdentity::apply(LyXRC & rc) const
+{
+ rc.user_name = fromqstr(nameED->text());
+ rc.user_email = fromqstr(emailED->text());
+}
+
+
+void PrefIdentity::update(LyXRC const & rc)
+{
+ nameED->setText(toqstr(rc.user_name));
+ emailED->setText(toqstr(rc.user_email));
+}
+
+
+
+/////////////////////////////////////////////////////////////////////
+//
+// GuiPrefsDialog
+//
+/////////////////////////////////////////////////////////////////////
+
+GuiPrefsDialog::GuiPrefsDialog(GuiPrefs * form)
+ : form_(form)
+{
+ setupUi(this);
+ QDialog::setModal(false);
+
+ connect(savePB, SIGNAL(clicked()), form, SLOT(slotOK()));
+ connect(applyPB, SIGNAL(clicked()), form, SLOT(slotApply()));
+ connect(closePB, SIGNAL(clicked()), form, SLOT(slotClose()));
+ connect(restorePB, SIGNAL(clicked()), form, SLOT(slotRestore()));
+
+ add(new PrefUserInterface(form_));
+ add(new PrefScreenFonts(form_));
+ add(new PrefColors(form_));
+ add(new PrefDisplay);
+ add(new PrefKeyboard(form_));
+
+ add(new PrefPaths(form_));
+
+ add(new PrefIdentity);
+
+ add(new PrefLanguage);
+ add(new PrefSpellchecker(form_));
+
+ add(new PrefPrinter);
+ add(new PrefDate);
+ add(new PrefPlaintext);
+ add(new PrefLatex(form_));
+
+#if defined(__CYGWIN__) || defined(_WIN32)
+ add(new PrefCygwinPath);
+#endif
+
+
+ PrefConverters * converters = new PrefConverters(form_);
+ PrefFileformats * formats = new PrefFileformats(form_);
+ connect(formats, SIGNAL(formatsChanged()),
+ converters, SLOT(updateGui()));
+ add(converters);
+ add(formats);
+
+ add(new PrefCopiers(form_));
+
+
+ prefsPS->setCurrentPanel(_("User interface"));
+// FIXME: hack to work around resizing bug in Qt >= 4.2
+// bug verified with Qt 4.2.{0-3} (JSpitzm)
+#if QT_VERSION >= 0x040200
+ prefsPS->updateGeometry();
+#endif
+
+ form_->bcview().setOK(savePB);
+ form_->bcview().setApply(applyPB);
+ form_->bcview().setCancel(closePB);
+ form_->bcview().setRestore(restorePB);
+}
+
+
+void GuiPrefsDialog::add(PrefModule * module)
+{
+ BOOST_ASSERT(module);
+
+ prefsPS->addPanel(module, module->title());
+
+ connect(module, SIGNAL(changed()), this, SLOT(change_adaptor()));
+
+ modules_.push_back(module);
+}
+
+void GuiPrefsDialog::closeEvent(QCloseEvent * e)
+{
+ form_->slotWMHide();
+ e->accept();
+}
+
+
+void GuiPrefsDialog::change_adaptor()
+{
+ form_->changed();
+}
+
+
+void GuiPrefsDialog::apply(LyXRC & rc) const
+{
+ size_t end = modules_.size();
+ for (size_t i = 0; i != end; ++i)
+ modules_[i]->apply(rc);
+}
+
+
+void GuiPrefsDialog::updateRc(LyXRC const & rc)
+{
+ size_t const end = modules_.size();
+ for (size_t i = 0; i != end; ++i)
+ modules_[i]->update(rc);
+}
+
+
+/////////////////////////////////////////////////////////////////////
+//
+// GuiPrefs
+//
+/////////////////////////////////////////////////////////////////////
+
+typedef QController<ControlPrefs, GuiView<GuiPrefsDialog> > PrefsBase;
+
+GuiPrefs::GuiPrefs(Dialog & parent)
+ : PrefsBase(parent, _("Preferences"))
+{
+}
+
+Converters & GuiPrefs::converters()
+{
+ return controller().converters();
+}
+
+Formats & GuiPrefs::formats()
+{
+ return controller().formats();
+}
+
+Movers & GuiPrefs::movers()
+{
+ return controller().movers();
+}
+
+void GuiPrefs::build_dialog()
+{
+ dialog_.reset(new GuiPrefsDialog(this));
+}
+
+void GuiPrefs::apply()
+{
+ dialog_->apply(controller().rc());
+}
+
+void GuiPrefs::update_contents()
+{
+ dialog_->updateRc(controller().rc());
+}
+
+} // namespace frontend
+} // namespace lyx
+
+#include "GuiPrefs_moc.cpp"
--- /dev/null
+// -*- C++ -*-
+/**
+ * \file GuiPrefs.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author John Levon
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#ifndef QPREFS_H
+#define QPREFS_H
+
+#include "GuiDialogView.h"
+
+#include "Color.h"
+#include "LyXRC.h"
+
+#include "ui_PrefsUi.h"
+
+#include <vector>
+
+#include <QDialog>
+#include <QCloseEvent>
+
+#include "ui_PrefPlaintextUi.h"
+#include "ui_PrefDateUi.h"
+#include "ui_PrefKeyboardUi.h"
+#include "ui_PrefLatexUi.h"
+#include "ui_PrefScreenFontsUi.h"
+#include "ui_PrefColorsUi.h"
+#include "ui_PrefCygwinPathUi.h"
+#include "ui_PrefDisplayUi.h"
+#include "ui_PrefPathsUi.h"
+#include "ui_PrefSpellcheckerUi.h"
+#include "ui_PrefConvertersUi.h"
+#include "ui_PrefCopiersUi.h"
+#include "ui_PrefFileformatsUi.h"
+#include "ui_PrefLanguageUi.h"
+#include "ui_PrefPrinterUi.h"
+#include "ui_PrefUi.h"
+#include "ui_PrefIdentityUi.h"
+
+namespace lyx {
+
+class Converters;
+class Formats;
+class Movers;
+
+namespace frontend {
+
+class GuiPrefs;
+
+class PrefModule : public QWidget
+{
+ Q_OBJECT
+public:
+ PrefModule(docstring const & t,
+ GuiPrefs * form = 0, QWidget * parent = 0)
+ : QWidget(parent), title_(t), form_(form)
+ {}
+
+ virtual void apply(LyXRC & rc) const = 0;
+ virtual void update(LyXRC const & rc) = 0;
+
+ docstring const & title() const { return title_; }
+
+protected:
+ docstring title_;
+ GuiPrefs * form_;
+
+Q_SIGNALS:
+ void changed();
+};
+
+
+class PrefPlaintext : public PrefModule, public Ui::PrefPlaintextUi
+{
+ Q_OBJECT
+public:
+ PrefPlaintext(QWidget * parent = 0);
+
+ virtual void apply(LyXRC & rc) const;
+ virtual void update(LyXRC const & rc);
+};
+
+
+class PrefDate : public PrefModule, public Ui::PrefDateUi
+{
+ Q_OBJECT
+public:
+ PrefDate(QWidget * parent = 0);
+
+ virtual void apply(LyXRC & rc) const;
+ virtual void update(LyXRC const & rc);
+};
+
+
+class PrefKeyboard : public PrefModule, public Ui::PrefKeyboardUi
+{
+ Q_OBJECT
+public:
+ PrefKeyboard(GuiPrefs * form, QWidget * parent = 0);
+
+ virtual void apply(LyXRC & rc) const;
+ virtual void update(LyXRC const & rc);
+
+private Q_SLOTS:
+ void on_firstKeymapPB_clicked(bool);
+ void on_secondKeymapPB_clicked(bool);
+ void on_keymapCB_toggled(bool);
+
+private:
+ QString testKeymap(QString keymap);
+};
+
+
+class PrefLatex : public PrefModule, public Ui::PrefLatexUi
+{
+ Q_OBJECT
+public:
+ PrefLatex(GuiPrefs * form, QWidget * parent = 0);
+
+ virtual void apply(LyXRC & rc) const;
+ virtual void update(LyXRC const & rc);
+};
+
+
+class PrefScreenFonts : public PrefModule, public Ui::PrefScreenFontsUi
+{
+ Q_OBJECT
+public:
+ PrefScreenFonts(GuiPrefs * form, QWidget * parent = 0);
+
+ virtual void apply(LyXRC & rc) const;
+ virtual void update(LyXRC const & rc);
+
+private Q_SLOTS:
+ void select_roman(const QString&);
+ void select_sans(const QString&);
+ void select_typewriter(const QString&);
+};
+
+
+class PrefColors : public PrefModule, public Ui::PrefColorsUi
+{
+ Q_OBJECT
+public:
+ PrefColors(GuiPrefs * form, QWidget * parent = 0);
+
+ void apply(LyXRC & rc) const;
+ void update(LyXRC const & rc);
+
+private Q_SLOTS:
+ void change_color();
+ void change_lyxObjects_selection();
+
+private:
+ std::vector<Color_color> lcolors_;
+ // FIXME the use of mutable here is required due to the
+ // fact that initialization is not done in the controller
+ // but in the constructor.
+ std::vector<QString> curcolors_;
+ std::vector<QString> newcolors_;
+
+};
+
+
+class PrefCygwinPath : public PrefModule, public Ui::PrefCygwinPathUi
+{
+ Q_OBJECT
+public:
+ PrefCygwinPath(QWidget * parent = 0);
+
+ void apply(LyXRC & rc) const;
+ void update(LyXRC const & rc);
+};
+
+
+class PrefDisplay : public PrefModule, public Ui::PrefDisplayUi
+{
+ Q_OBJECT
+public:
+ PrefDisplay(QWidget * parent = 0);
+
+ void apply(LyXRC & rc) const;
+ void update(LyXRC const & rc);
+};
+
+
+class PrefPaths : public PrefModule, public Ui::PrefPathsUi
+{
+ Q_OBJECT
+public:
+ PrefPaths(GuiPrefs * form, QWidget * parent = 0);
+
+ void apply(LyXRC & rc) const;
+ void update(LyXRC const & rc);
+
+private Q_SLOTS:
+ void select_templatedir();
+ void select_tempdir();
+ void select_backupdir();
+ void select_workingdir();
+ void select_lyxpipe();
+
+};
+
+
+class PrefSpellchecker : public PrefModule, public Ui::PrefSpellcheckerUi
+{
+ Q_OBJECT
+public:
+ PrefSpellchecker(GuiPrefs * form, QWidget * parent = 0);
+
+ void apply(LyXRC & rc) const;
+ void update(LyXRC const & rc);
+
+private Q_SLOTS:
+ void select_dict();
+};
+
+
+class PrefConverters : public PrefModule, public Ui::PrefConvertersUi
+{
+ Q_OBJECT
+public:
+ PrefConverters(GuiPrefs * form, QWidget * parent = 0);
+
+ void apply(LyXRC & rc) const;
+ void update(LyXRC const & rc);
+
+public Q_SLOTS:
+ void updateGui();
+
+private Q_SLOTS:
+ void update_converter();
+ void switch_converter();
+ void converter_changed();
+ void remove_converter();
+ void on_cacheCB_stateChanged(int state);
+
+private:
+ void updateButtons();
+};
+
+
+class PrefCopiers : public PrefModule, public Ui::PrefCopiersUi
+{
+ Q_OBJECT
+public:
+ PrefCopiers(GuiPrefs * form, QWidget * parent = 0);
+
+ void apply(LyXRC & rc) const;
+ void update(LyXRC const & rc);
+
+ void update();
+
+private Q_SLOTS:
+ void switch_copierLB(int nr);
+ void switch_copierCO(int nr);
+ void copiers_changed();
+ void new_copier();
+ void modify_copier();
+ void remove_copier();
+
+private:
+ void updateButtons();
+};
+
+
+class PrefFileformats : public PrefModule, public Ui::PrefFileformatsUi
+{
+ Q_OBJECT
+public:
+ PrefFileformats(GuiPrefs * form, QWidget * parent = 0);
+
+ void apply(LyXRC & rc) const;
+ void update(LyXRC const & rc);
+
+ void update();
+Q_SIGNALS:
+ void formatsChanged();
+private:
+ void updateButtons();
+
+private Q_SLOTS:
+ void switch_format(int);
+ void fileformat_changed();
+ void new_format();
+ void modify_format();
+ void remove_format();
+};
+
+
+class PrefLanguage : public PrefModule, public Ui::PrefLanguageUi
+{
+ Q_OBJECT
+public:
+ PrefLanguage(QWidget * parent = 0);
+
+ void apply(LyXRC & rc) const;
+ void update(LyXRC const & rc);
+
+private:
+ std::vector<std::string> lang_;
+};
+
+
+class PrefPrinter : public PrefModule, public Ui::PrefPrinterUi
+{
+ Q_OBJECT
+public:
+ PrefPrinter(QWidget * parent = 0);
+
+ void apply(LyXRC & rc) const;
+ void update(LyXRC const & rc);
+};
+
+
+class PrefUserInterface : public PrefModule, public Ui::PrefUi
+{
+ Q_OBJECT
+public:
+ PrefUserInterface(GuiPrefs * form, QWidget * parent = 0);
+
+ void apply(LyXRC & rc) const;
+ void update(LyXRC const & rc);
+
+public Q_SLOTS:
+ void select_ui();
+ void select_bind();
+ void on_loadWindowSizeCB_toggled(bool);
+
+};
+
+
+class PrefIdentity : public PrefModule, public Ui::PrefIdentityUi
+{
+ Q_OBJECT
+public:
+ PrefIdentity(QWidget * parent = 0);
+
+ void apply(LyXRC & rc) const;
+ void update(LyXRC const & rc);
+};
+
+///
+class GuiPrefsDialog : public QDialog, public Ui::PrefsUi
+{
+ Q_OBJECT
+public:
+ GuiPrefsDialog(GuiPrefs *);
+
+ void apply(LyXRC & rc) const;
+ void updateRc(LyXRC const & rc);
+
+public Q_SLOTS:
+ void change_adaptor();
+
+protected:
+ void closeEvent(QCloseEvent * e);
+
+private:
+ void add(PrefModule * module);
+
+private:
+ GuiPrefs * form_;
+ std::vector<PrefModule *> modules_;
+};
+
+
+class ControlPrefs;
+
+class GuiPrefs
+ : public QController<ControlPrefs, GuiView<GuiPrefsDialog> >
+{
+public:
+ GuiPrefs(Dialog &);
+
+ Converters & converters();
+ Formats & formats();
+ Movers & movers();
+
+private:
+ /// Apply changes
+ virtual void apply();
+
+ /// update (do we need this?)
+ virtual void update_contents();
+
+ /// build the dialog
+ virtual void build_dialog();
+
+};
+
+} // namespace frontend
+} // namespace lyx
+
+#endif // QPREFS_H
--- /dev/null
+/**
+ * \file GuiPrint.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author John Levon
+ * \author Edwin Leuven
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "GuiPrint.h"
+#include "GuiPrintDialog.h"
+#include "Qt2BC.h"
+#include "qt_helpers.h"
+
+#include "PrinterParams.h"
+
+#include "controllers/ControlPrint.h"
+
+#include "support/os.h"
+
+#include <QLineEdit>
+#include <QCheckBox>
+#include <QRadioButton>
+#include <QSpinBox>
+#include <QPushButton>
+
+using lyx::support::os::internal_path;
+
+namespace lyx {
+namespace frontend {
+
+typedef QController<ControlPrint, GuiView<GuiPrintDialog> > print_base_class;
+
+
+GuiPrint::GuiPrint(Dialog & parent)
+ : print_base_class(parent, _("Print Document"))
+{
+}
+
+
+void GuiPrint::build_dialog()
+{
+ dialog_.reset(new GuiPrintDialog(this));
+
+ bcview().setOK(dialog_->printPB);
+ bcview().setCancel(dialog_->closePB);
+}
+
+
+void GuiPrint::update_contents()
+{
+ PrinterParams & pp = controller().params();
+
+ // only reset params if a different buffer
+ if (!pp.file_name.empty() && pp.file_name == fromqstr(dialog_->fileED->text()))
+ return;
+
+ dialog_->printerED->setText(toqstr(pp.printer_name));
+ dialog_->fileED->setText(toqstr(pp.file_name));
+
+ dialog_->printerRB->setChecked(true);
+ if (pp.target == PrinterParams::FILE)
+ dialog_->fileRB->setChecked(true);
+
+ dialog_->reverseCB->setChecked(pp.reverse_order);
+
+ dialog_->copiesSB->setValue(pp.count_copies);
+
+ dialog_->oddCB->setChecked(pp.odd_pages);
+ dialog_->evenCB->setChecked(pp.even_pages);
+
+ dialog_->collateCB->setChecked(pp.sorted_copies);
+
+ if (pp.all_pages) {
+ dialog_->allRB->setChecked(true);
+ return;
+ }
+
+ dialog_->rangeRB->setChecked(true);
+
+ QString s;
+ s.setNum(pp.from_page);
+ dialog_->fromED->setText(s);
+ s.setNum(pp.to_page);
+ dialog_->toED->setText(s);
+}
+
+
+void GuiPrint::apply()
+{
+ PrinterParams::Target t = PrinterParams::PRINTER;
+ if (dialog_->fileRB->isChecked())
+ t = PrinterParams::FILE;
+
+ PrinterParams const pp(t,
+ fromqstr(dialog_->printerED->text()),
+ internal_path(fromqstr(dialog_->fileED->text())),
+ dialog_->allRB->isChecked(),
+ dialog_->fromED->text().toUInt(),
+ dialog_->toED->text().toUInt(),
+ dialog_->oddCB->isChecked(),
+ dialog_->evenCB->isChecked(),
+ dialog_->copiesSB->text().toUInt(),
+ dialog_->collateCB->isChecked(),
+ dialog_->reverseCB->isChecked());
+
+ controller().params() = pp;
+}
+
+} // namespace frontend
+} // namespace lyx
--- /dev/null
+// -*- C++ -*-
+/**
+ * \file GuiPrint.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author John Levon
+ * \author Edwin Leuven
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#ifndef QPRINT_H
+#define QPRINT_H
+
+#include "GuiDialogView.h"
+#include "GuiPrintDialog.h"
+
+namespace lyx {
+namespace frontend {
+
+class ControlPrint;
+
+///
+class GuiPrint
+ : public QController<ControlPrint, GuiView<GuiPrintDialog> >
+{
+public:
+ ///
+ friend class GuiPrintDialog;
+ ///
+ GuiPrint(Dialog &);
+private:
+ /// Apply changes
+ virtual void apply();
+ /// update
+ virtual void update_contents();
+ /// build the dialog
+ virtual void build_dialog();
+};
+
+} // namespace frontend
+} // namespace lyx
+
+#endif // QPRINT_H
--- /dev/null
+/**
+ * \file GuiPrintDialog.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author John Levon
+ * \author Edwin Leuven
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "controllers/ControlPrint.h"
+#include "GuiPrintDialog.h"
+#include "GuiPrint.h"
+#include "qt_helpers.h"
+
+#include <qcheckbox.h>
+#include <qlineedit.h>
+#include <qpushbutton.h>
+#include <qradiobutton.h>
+
+namespace lyx {
+namespace frontend {
+
+GuiPrintDialog::GuiPrintDialog(GuiPrint * f)
+ : form_(f)
+{
+ setupUi(this);
+
+ connect(printPB, SIGNAL(clicked()), form_, SLOT(slotOK()));
+ connect(closePB, SIGNAL(clicked()), form_, SLOT(slotClose()));
+
+ connect(copiesSB, SIGNAL(valueChanged(int)), this, SLOT(copiesChanged(int)));
+ connect(printerED, SIGNAL(textChanged(const QString&)),
+ this, SLOT(printerChanged()));
+ connect(fileED, SIGNAL(textChanged(const QString&)),
+ this, SLOT(fileChanged() ));
+ connect(browsePB, SIGNAL(clicked()), this, SLOT(browseClicked()));
+ connect(allRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
+ connect(reverseCB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
+ connect(collateCB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
+ connect(fromED, SIGNAL(textChanged(const QString&)),
+ this, SLOT(pagerangeChanged()));
+ connect(fromED, SIGNAL(textChanged(const QString&)),
+ this, SLOT(change_adaptor()));
+ connect(toED, SIGNAL(textChanged(const QString&)),
+ this, SLOT(pagerangeChanged()));
+ connect(toED, SIGNAL(textChanged(const QString&)),
+ this, SLOT(change_adaptor()));
+ connect(fileRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
+ connect(printerRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
+ connect(rangeRB, SIGNAL(toggled(bool)), fromED, SLOT(setEnabled(bool)));
+ connect(rangeRB, SIGNAL(toggled(bool)), toED, SLOT(setEnabled(bool)));
+}
+
+
+void GuiPrintDialog::change_adaptor()
+{
+ form_->changed();
+}
+
+
+void GuiPrintDialog::browseClicked()
+{
+ QString file = toqstr(form_->controller().browse(docstring()));
+ if (!file.isNull()) {
+ fileED->setText(file);
+ form_->changed();
+ }
+}
+
+
+void GuiPrintDialog::fileChanged()
+{
+ if (!fileED->text().isEmpty())
+ fileRB->setChecked(true);
+ form_->changed();
+}
+
+
+void GuiPrintDialog::copiesChanged(int i)
+{
+ collateCB->setEnabled(i != 1);
+ form_->changed();
+}
+
+
+void GuiPrintDialog::printerChanged()
+{
+ printerRB->setChecked(true);
+ form_->changed();
+}
+
+
+void GuiPrintDialog::pagerangeChanged()
+{
+ form_->changed();
+}
+
+} // namespace frontend
+} // namespace lyx
+
+#include "GuiPrintDialog_moc.cpp"
--- /dev/null
+// -*- C++ -*-
+/**
+ * \file GuiPrintDialog.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author John Levon
+ * \author Edwin Leuven
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#ifndef QLPRINTDIALOG_H
+#define QLPRINTDIALOG_H
+
+#include "ui_PrintUi.h"
+
+#include <QDialog>
+
+namespace lyx {
+namespace frontend {
+
+class GuiPrint;
+
+class GuiPrintDialog : public QDialog, public Ui::PrintUi {
+ Q_OBJECT
+public:
+ GuiPrintDialog(GuiPrint * f);
+protected Q_SLOTS:
+ virtual void change_adaptor();
+ virtual void browseClicked();
+ virtual void fileChanged();
+ virtual void copiesChanged(int);
+ virtual void printerChanged();
+ virtual void pagerangeChanged();
+private:
+ GuiPrint * form_;
+};
+
+} // namespace frontend
+} // namespace lyx
+
+#endif // QLPRINTDIALOG_H
--- /dev/null
+/**
+ * \file GuiRef.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author John Levon
+ * \author Jürgen Spitzmüller
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "GuiRef.h"
+#include "Qt2BC.h"
+#include "qt_helpers.h"
+
+#include "controllers/ButtonController.h"
+#include "controllers/ControlRef.h"
+
+#include "insets/InsetRef.h"
+
+#include <QLineEdit>
+#include <QCheckBox>
+#include <QListWidget>
+#include <QListWidgetItem>
+#include <QPushButton>
+#include <QToolTip>
+#include <QCloseEvent>
+
+
+using std::vector;
+using std::string;
+
+
+namespace lyx {
+namespace frontend {
+
+/////////////////////////////////////////////////////////////////////
+//
+// GuiRefDialog
+//
+/////////////////////////////////////////////////////////////////////
+
+GuiRefDialog::GuiRefDialog(GuiRef * form)
+ : form_(form)
+{
+ setupUi(this);
+
+ connect(okPB, SIGNAL(clicked()), form_, SLOT(slotOK()));
+ connect(applyPB, SIGNAL(clicked()), form_, SLOT(slotApply()));
+ connect(closePB, SIGNAL(clicked()), form_, SLOT(slotClose()));
+ connect(closePB, SIGNAL(clicked()), this, SLOT(reset_dialog()));
+ connect(this, SIGNAL(rejected()), this, SLOT(reset_dialog()));
+
+ connect(typeCO, SIGNAL(activated(int)),
+ this, SLOT(changed_adaptor()));
+ connect(referenceED, SIGNAL(textChanged(const QString &)),
+ this, SLOT(changed_adaptor()));
+ connect(nameED, SIGNAL(textChanged(const QString &)),
+ this, SLOT(changed_adaptor()));
+ connect(refsLW, SIGNAL(itemClicked(QListWidgetItem *)),
+ this, SLOT(refHighlighted(QListWidgetItem *)));
+ connect(refsLW, SIGNAL(itemSelectionChanged()),
+ this, SLOT(selectionChanged()));
+ connect(refsLW, SIGNAL(itemActivated(QListWidgetItem *)),
+ this, SLOT(refSelected(QListWidgetItem *)));
+ connect(sortCB, SIGNAL(clicked(bool)),
+ this, SLOT(sortToggled(bool)));
+ connect(gotoPB, SIGNAL(clicked()),
+ this, SLOT(gotoClicked()));
+ connect(updatePB, SIGNAL(clicked()),
+ this, SLOT(updateClicked()));
+ connect(bufferCO, SIGNAL(activated(int)),
+ this, SLOT(updateClicked()));
+
+ setFocusProxy(refsLW);
+}
+
+void GuiRefDialog::show()
+{
+ QDialog::show();
+}
+
+
+void GuiRefDialog::changed_adaptor()
+{
+ form_->changed();
+}
+
+
+void GuiRefDialog::gotoClicked()
+{
+ form_->gotoRef();
+}
+
+void GuiRefDialog::selectionChanged()
+{
+ if (form_->readOnly())
+ return;
+
+ QList<QListWidgetItem *> selections = refsLW->selectedItems();
+ if (selections.isEmpty())
+ return;
+ QListWidgetItem * sel = selections.first();
+ refHighlighted(sel);
+ return;
+}
+
+
+void GuiRefDialog::refHighlighted(QListWidgetItem * sel)
+{
+ if (form_->readOnly())
+ return;
+
+/* int const cur_item = refsLW->currentRow();
+ bool const cur_item_selected = cur_item >= 0 ?
+ refsLB->isSelected(cur_item) : false;*/
+ bool const cur_item_selected = refsLW->isItemSelected(sel);
+
+ if (cur_item_selected)
+ referenceED->setText(sel->text());
+
+ if (form_->at_ref_)
+ form_->gotoRef();
+ gotoPB->setEnabled(true);
+ if (form_->typeAllowed())
+ typeCO->setEnabled(true);
+ if (form_->nameAllowed())
+ nameED->setEnabled(true);
+}
+
+
+void GuiRefDialog::refSelected(QListWidgetItem * sel)
+{
+ if (form_->readOnly())
+ return;
+
+/* int const cur_item = refsLW->currentRow();
+ bool const cur_item_selected = cur_item >= 0 ?
+ refsLB->isSelected(cur_item) : false;*/
+ bool const cur_item_selected = refsLW->isItemSelected(sel);
+
+ if (cur_item_selected)
+ referenceED->setText(sel->text());
+ // <enter> or double click, inserts ref and closes dialog
+ form_->slotOK();
+}
+
+
+void GuiRefDialog::sortToggled(bool on)
+{
+ form_->sort_ = on;
+ form_->redoRefs();
+}
+
+
+void GuiRefDialog::updateClicked()
+{
+ form_->updateRefs();
+}
+
+
+void GuiRefDialog::reset_dialog() {
+ form_->at_ref_ = false;
+ form_->setGotoRef();
+}
+
+
+void GuiRefDialog::closeEvent(QCloseEvent * e)
+{
+ form_->slotWMHide();
+ reset_dialog();
+ e->accept();
+}
+
+
+/////////////////////////////////////////////////////////////////////
+//
+// GuiRef
+//
+/////////////////////////////////////////////////////////////////////
+
+// full qualification because qt4 has also a ControlRef type
+typedef QController<lyx::frontend::ControlRef, GuiView<GuiRefDialog> > RefBase;
+
+
+GuiRef::GuiRef(Dialog & parent)
+ : RefBase(parent, _("Cross-reference")),
+ sort_(false), at_ref_(false)
+{
+}
+
+
+void GuiRef::build_dialog()
+{
+ dialog_.reset(new GuiRefDialog(this));
+
+ bcview().setOK(dialog_->okPB);
+ bcview().setApply(dialog_->applyPB);
+ bcview().setCancel(dialog_->closePB);
+ bcview().addReadOnly(dialog_->refsLW);
+ bcview().addReadOnly(dialog_->sortCB);
+ bcview().addReadOnly(dialog_->nameED);
+ bcview().addReadOnly(dialog_->referenceED);
+ bcview().addReadOnly(dialog_->typeCO);
+ bcview().addReadOnly(dialog_->bufferCO);
+
+ restored_buffer_ = -1;
+}
+
+
+void GuiRef::update_contents()
+{
+ InsetCommandParams const & params = controller().params();
+
+ int orig_type = dialog_->typeCO->currentIndex();
+
+ dialog_->referenceED->setText(toqstr(params["reference"]));
+
+ dialog_->nameED->setText(toqstr(params["name"]));
+ dialog_->nameED->setReadOnly(!nameAllowed() && !readOnly());
+
+ // restore type settings for new insets
+ if (params["reference"].empty())
+ dialog_->typeCO->setCurrentIndex(orig_type);
+ else
+ dialog_->typeCO->setCurrentIndex(InsetRef::getType(params.getCmdName()));
+ dialog_->typeCO->setEnabled(typeAllowed() && !readOnly());
+ if (!typeAllowed())
+ dialog_->typeCO->setCurrentIndex(0);
+
+ dialog_->sortCB->setChecked(sort_);
+
+ // insert buffer list
+ dialog_->bufferCO->clear();
+ vector<string> const buffers = controller().getBufferList();
+ for (vector<string>::const_iterator it = buffers.begin();
+ it != buffers.end(); ++it) {
+ dialog_->bufferCO->addItem(toqstr(*it));
+ }
+ // restore the buffer combo setting for new insets
+ if (params["reference"].empty() && restored_buffer_ != -1
+ && restored_buffer_ < dialog_->bufferCO->count())
+ dialog_->bufferCO->setCurrentIndex(restored_buffer_);
+ else
+ dialog_->bufferCO->setCurrentIndex(controller().getBufferNum());
+
+ updateRefs();
+ bc().valid(false);
+}
+
+
+void GuiRef::apply()
+{
+ InsetCommandParams & params = controller().params();
+
+ last_reference_ = dialog_->referenceED->text();
+
+ params.setCmdName(InsetRef::getName(dialog_->typeCO->currentIndex()));
+ params["reference"] = qstring_to_ucs4(last_reference_);
+ params["name"] = qstring_to_ucs4(dialog_->nameED->text());
+
+ restored_buffer_ = dialog_->bufferCO->currentIndex();
+}
+
+
+bool GuiRef::nameAllowed()
+{
+ Kernel::DocType const doc_type = kernel().docType();
+ return doc_type != Kernel::LATEX &&
+ doc_type != Kernel::LITERATE;
+}
+
+
+bool GuiRef::typeAllowed()
+{
+ Kernel::DocType const doc_type = kernel().docType();
+ return doc_type != Kernel::DOCBOOK;
+}
+
+
+void GuiRef::setGoBack()
+{
+ dialog_->gotoPB->setText(qt_("&Go Back"));
+ dialog_->gotoPB->setToolTip("");
+ dialog_->gotoPB->setToolTip(qt_("Jump back"));
+}
+
+
+void GuiRef::setGotoRef()
+{
+ dialog_->gotoPB->setText(qt_("&Go to Label"));
+ dialog_->gotoPB->setToolTip("");
+ dialog_->gotoPB->setToolTip(qt_("Jump to label"));
+}
+
+
+void GuiRef::gotoRef()
+{
+ string ref(fromqstr(dialog_->referenceED->text()));
+
+ if (at_ref_) {
+ // go back
+ setGotoRef();
+ controller().gotoBookmark();
+ } else {
+ // go to the ref
+ setGoBack();
+ controller().gotoRef(ref);
+ }
+ at_ref_ = !at_ref_;
+}
+
+
+void GuiRef::redoRefs()
+{
+ // Prevent these widgets from emitting any signals whilst
+ // we modify their state.
+ dialog_->refsLW->blockSignals(true);
+ dialog_->referenceED->blockSignals(true);
+ dialog_->refsLW->setUpdatesEnabled(false);
+
+ dialog_->refsLW->clear();
+
+ // need this because Qt will send a highlight() here for
+ // the first item inserted
+ QString const oldSelection(dialog_->referenceED->text());
+
+ for (std::vector<docstring>::const_iterator iter = refs_.begin();
+ iter != refs_.end(); ++iter) {
+ dialog_->refsLW->addItem(toqstr(*iter));
+ }
+
+ if (sort_)
+ dialog_->refsLW->sortItems();
+
+ dialog_->referenceED->setText(oldSelection);
+
+ // restore the last selection or, for new insets, highlight
+ // the previous selection
+ if (!oldSelection.isEmpty() || !last_reference_.isEmpty()) {
+ bool const newInset = oldSelection.isEmpty();
+ QString textToFind = newInset ? last_reference_ : oldSelection;
+ bool foundItem = false;
+ for (int i = 0; !foundItem && i < dialog_->refsLW->count(); ++i) {
+ QListWidgetItem * item = dialog_->refsLW->item(i);
+ if (textToFind == item->text()) {
+ dialog_->refsLW->setCurrentItem(item);
+ dialog_->refsLW->setItemSelected(item, !newInset);
+ //Make sure selected item is visible
+ dialog_->refsLW->scrollToItem(item);
+ foundItem = true;
+ }
+ }
+ if (foundItem)
+ last_reference_ = textToFind;
+ else last_reference_ = "";
+ }
+ dialog_->refsLW->setUpdatesEnabled(true);
+ dialog_->refsLW->update();
+
+ // Re-activate the emission of signals by these widgets.
+ dialog_->refsLW->blockSignals(false);
+ dialog_->referenceED->blockSignals(false);
+}
+
+
+void GuiRef::updateRefs()
+{
+ refs_.clear();
+ string const name = controller().getBufferName(dialog_->bufferCO->currentIndex());
+ refs_ = controller().getLabelList(name);
+ dialog_->sortCB->setEnabled(!refs_.empty());
+ dialog_->refsLW->setEnabled(!refs_.empty());
+ dialog_->gotoPB->setEnabled(!refs_.empty());
+ redoRefs();
+}
+
+bool GuiRef::isValid()
+{
+ return !dialog_->referenceED->text().isEmpty();
+}
+
+} // namespace frontend
+} // namespace lyx
+
+#include "GuiRef_moc.cpp"
--- /dev/null
+// -*- C++ -*-
+/**
+ * \file GuiRef.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author John Levon
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#ifndef QREF_H
+#define QREF_H
+
+#include "GuiDialogView.h"
+
+#include "ui_RefUi.h"
+
+#include <QDialog>
+
+#include <vector>
+
+class QListWidgetItem;
+class QCloseEvent;
+
+namespace lyx {
+namespace frontend {
+
+class GuiRef;
+
+class GuiRefDialog : public QDialog, public Ui::RefUi {
+ Q_OBJECT
+public:
+ GuiRefDialog(GuiRef * form);
+
+ virtual void show();
+
+public Q_SLOTS:
+ void changed_adaptor();
+ void gotoClicked();
+ void refHighlighted(QListWidgetItem *);
+ void selectionChanged();
+ void refSelected(QListWidgetItem *);
+ void sortToggled(bool);
+ void updateClicked();
+
+protected Q_SLOTS:
+ void reset_dialog();
+protected:
+ void closeEvent(QCloseEvent * e);
+private:
+ GuiRef * form_;
+};
+
+
+class ControlRef;
+
+// full qualification because qt4 has also a ControlRef type
+class GuiRef
+ : public QController<lyx::frontend::ControlRef, GuiView<GuiRefDialog> >
+{
+public:
+ friend class GuiRefDialog;
+
+ GuiRef(Dialog &);
+
+protected:
+ virtual bool isValid();
+
+private:
+ /// apply changes
+ virtual void apply();
+ /// build dialog
+ virtual void build_dialog();
+ /// update dialog
+ virtual void update_contents();
+
+ /// is name allowed for this ?
+ bool nameAllowed();
+
+ /// is type allowed for this ?
+ bool typeAllowed();
+
+ /// go to current reference
+ void gotoRef();
+
+ /// set go back button
+ void setGoBack();
+
+ /// set goto ref button
+ void setGotoRef();
+
+ /// re-enter references
+ void redoRefs();
+
+ /// update references
+ void updateRefs();
+
+ /// sort or not persistent state
+ bool sort_;
+
+ /// went to a reference ?
+ bool at_ref_;
+
+ /// the last reference entered or examined
+ QString last_reference_;
+
+ /// store the buffer settings
+ int restored_buffer_;
+
+ /// the references
+ std::vector<docstring> refs_;
+};
+
+} // namespace frontend
+} // namespace lyx
+
+#endif // QREF_H
--- /dev/null
+/**
+ * \file GuiSearch.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author John Levon
+ * \author Edwin Leuven
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "GuiSearch.h"
+#include "qt_helpers.h"
+#include "Qt2BC.h"
+
+#include "controllers/ControlSearch.h"
+
+#include <QLineEdit>
+#include <QCloseEvent>
+
+using std::string;
+
+namespace lyx {
+namespace frontend {
+
+
+/////////////////////////////////////////////////////////////////////
+//
+// GuiSearchDialog
+//
+/////////////////////////////////////////////////////////////////////
+
+
+static void uniqueInsert(QComboBox * box, QString const & text)
+{
+ for (int i = 0; i < box->count(); ++i) {
+ if (box->itemText(i) == text)
+ return;
+ }
+
+ box->addItem(text);
+}
+
+
+GuiSearchDialog::GuiSearchDialog(GuiSearch * form)
+ : form_(form)
+{
+ setupUi(this);
+
+ connect(closePB, SIGNAL(clicked()), form_, SLOT(slotClose()));
+ connect(findPB, SIGNAL(clicked()), this, SLOT(findClicked()));
+ connect(replacePB, SIGNAL(clicked()), this, SLOT(replaceClicked()));
+ connect(replaceallPB, SIGNAL(clicked()), this, SLOT(replaceallClicked()));
+ connect(findCO, SIGNAL(editTextChanged(const QString &)),
+ this, SLOT(findChanged()));
+
+ setFocusProxy(findCO);
+}
+
+
+void GuiSearchDialog::show()
+{
+ QDialog::show();
+ findCO->lineEdit()->setSelection(0, findCO->lineEdit()->text().length());
+}
+
+
+void GuiSearchDialog::closeEvent(QCloseEvent * e)
+{
+ form_->slotWMHide();
+ e->accept();
+}
+
+
+void GuiSearchDialog::findChanged()
+{
+ if (findCO->currentText().isEmpty()) {
+ findPB->setEnabled(false);
+ replacePB->setEnabled(false);
+ replaceallPB->setEnabled(false);
+ } else {
+ findPB->setEnabled(true);
+ replacePB->setEnabled(!form_->readOnly());
+ replaceallPB->setEnabled(!form_->readOnly());
+ }
+}
+
+
+void GuiSearchDialog::findClicked()
+{
+ docstring const find = qstring_to_ucs4(findCO->currentText());
+ form_->find(find,
+ caseCB->isChecked(),
+ wordsCB->isChecked(),
+ backwardsCB->isChecked());
+ uniqueInsert(findCO, findCO->currentText());
+ findCO->lineEdit()->setSelection(0, findCO->lineEdit()->text().length());
+}
+
+
+void GuiSearchDialog::replaceClicked()
+{
+ docstring const find = qstring_to_ucs4(findCO->currentText());
+ docstring const replace = qstring_to_ucs4(replaceCO->currentText());
+ form_->replace(find, replace,
+ caseCB->isChecked(),
+ wordsCB->isChecked(),
+ backwardsCB->isChecked(), false);
+ uniqueInsert(findCO, findCO->currentText());
+ uniqueInsert(replaceCO, replaceCO->currentText());
+}
+
+
+void GuiSearchDialog::replaceallClicked()
+{
+ form_->replace(qstring_to_ucs4(findCO->currentText()),
+ qstring_to_ucs4(replaceCO->currentText()),
+ caseCB->isChecked(),
+ wordsCB->isChecked(),
+ false, true);
+ uniqueInsert(findCO, findCO->currentText());
+ uniqueInsert(replaceCO, replaceCO->currentText());
+}
+
+
+/////////////////////////////////////////////////////////////////////
+//
+// GuiSearch
+//
+/////////////////////////////////////////////////////////////////////
+
+
+typedef QController<ControlSearch, GuiView<GuiSearchDialog> > SearchBase;
+
+
+GuiSearch::GuiSearch(Dialog & parent)
+ : SearchBase(parent, _("Find and Replace"))
+{
+}
+
+
+void GuiSearch::build_dialog()
+{
+ dialog_.reset(new GuiSearchDialog(this));
+
+ bcview().setCancel(dialog_->closePB);
+ bcview().addReadOnly(dialog_->replaceCO);
+ bcview().addReadOnly(dialog_->replacePB);
+ bcview().addReadOnly(dialog_->replaceallPB);
+
+ dialog_->replacePB->setEnabled(false);
+ dialog_->replaceallPB->setEnabled(false);
+}
+
+
+void GuiSearch::find(docstring const & str, bool casesens,
+ bool words, bool backwards)
+{
+ controller().find(str, casesens, words, !backwards);
+}
+
+
+void GuiSearch::replace(docstring const & findstr, docstring const & replacestr,
+ bool casesens, bool words, bool backwards, bool all)
+{
+ controller().replace(findstr, replacestr, casesens, words,
+ !backwards, all);
+}
+
+} // namespace frontend
+} // namespace lyx
+
+
+#include "GuiSearch_moc.cpp"
--- /dev/null
+// -*- C++ -*-
+/**
+ * \file GuiSearch.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author John Levon
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#ifndef QSEARCH_H
+#define QSEARCH_H
+
+#include "GuiDialogView.h"
+#include "ui_SearchUi.h"
+#include <string>
+
+#include <QDialog>
+
+namespace lyx {
+namespace frontend {
+
+class ControlSearch;
+
+class GuiSearch;
+
+class GuiSearchDialog : public QDialog, public Ui::SearchUi {
+ Q_OBJECT
+public:
+ GuiSearchDialog(GuiSearch * form);
+
+ virtual void show();
+protected Q_SLOTS:
+ void findChanged();
+ void findClicked();
+ void replaceClicked();
+ void replaceallClicked();
+protected:
+ virtual void closeEvent(QCloseEvent * e);
+
+private:
+ // add a string to the combo if needed
+ void remember(std::string const & find, QComboBox & combo);
+
+ GuiSearch * form_;
+};
+
+
+class GuiSearch
+ : public QController<ControlSearch, GuiView<GuiSearchDialog> >
+{
+public:
+ ///
+ friend class GuiSearchDialog;
+ ///
+ GuiSearch(Dialog &);
+private:
+ /// Apply changes
+ virtual void apply() {}
+ /// update
+ virtual void update_contents() {}
+ /// build the dialog
+ virtual void build_dialog();
+
+ void find(docstring const & str, bool casesens,
+ bool words, bool backwards);
+
+ void replace(docstring const & findstr,
+ docstring const & replacestr,
+ bool casesens, bool words, bool backwards, bool all);
+};
+
+} // namespace frontend
+} // namespace lyx
+
+#endif // QSEARCH_H
--- /dev/null
+/**
+ * \file GuiSelectionManager.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Richard Heck
+ * \author Et Alia
+ *
+ * Some of the material in this file previously appeared in
+ * GuiCitationDialog.cpp.
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+#include "GuiSelectionManager.h"
+
+
+namespace lyx {
+namespace frontend {
+
+GuiSelectionManager::GuiSelectionManager(
+ QListView * avail,
+ QListView * sel,
+ QPushButton * add,
+ QPushButton * del,
+ QPushButton * up,
+ QPushButton * down,
+ QStringListModel * amod,
+ QStringListModel * smod)
+{
+ availableLV = avail;
+ selectedLV = sel;
+ addPB = add;
+ deletePB = del;
+ upPB = up;
+ downPB = down;
+ availableModel = amod;
+ selectedModel = smod;
+
+ selectedLV->setModel(smod);
+ availableLV->setModel(amod);
+
+ connect(availableLV->selectionModel(),
+ SIGNAL(currentChanged(const QModelIndex &, const QModelIndex &)),
+ this, SLOT(availableChanged(const QModelIndex &, const QModelIndex &)));
+ connect(selectedLV->selectionModel(),
+ SIGNAL(currentChanged(const QModelIndex &, const QModelIndex &)),
+ this, SLOT(selectedChanged(const QModelIndex &, const QModelIndex &)));
+ connect(addPB, SIGNAL(clicked()),
+ this, SLOT(addPB_clicked()));
+ connect(deletePB, SIGNAL(clicked()),
+ this, SLOT(deletePB_clicked()));
+ connect(upPB, SIGNAL(clicked()),
+ this, SLOT(upPB_clicked()));
+ connect(downPB, SIGNAL(clicked()),
+ this, SLOT(downPB_clicked()));
+ connect(availableLV, SIGNAL(clicked(const QModelIndex &)),
+ this, SLOT(availableLV_clicked(const QModelIndex &)));
+ connect(availableLV, SIGNAL(doubleClicked(const QModelIndex &)),
+ this, SLOT(availableLV_doubleClicked(const QModelIndex &)));
+ connect(selectedLV, SIGNAL(clicked(const QModelIndex &)),
+ this, SLOT(selectedLV_clicked(const QModelIndex &)));
+
+ availableLV->installEventFilter(this);
+ selectedLV->installEventFilter(this);
+}
+
+
+void GuiSelectionManager::update()
+{
+ int const arows = availableLV->model()->rowCount();
+ QModelIndexList const availSels =
+ availableLV->selectionModel()->selectedIndexes();
+ addPB->setEnabled(arows > 0 &&
+ !availSels.isEmpty() &&
+ !isSelected(availSels.first()));
+
+ int const srows = selectedLV->model()->rowCount();
+ QModelIndexList const selSels =
+ selectedLV->selectionModel()->selectedIndexes();
+ int const sel_nr = selSels.empty() ? -1 : selSels.first().row();
+ deletePB->setEnabled(sel_nr >= 0);
+ upPB->setEnabled(sel_nr > 0);
+ downPB->setEnabled(sel_nr >= 0 && sel_nr < srows - 1);
+}
+
+
+bool GuiSelectionManager::isSelected(const QModelIndex & idx)
+{
+ QString const str = idx.data().toString();
+ return selectedModel->stringList().contains(str);
+}
+
+
+void GuiSelectionManager::availableChanged(const QModelIndex & idx, const QModelIndex &)
+{
+ if (!idx.isValid())
+ return;
+
+ selectedHasFocus_ = false;
+ updateHook();
+}
+
+
+void GuiSelectionManager::selectedChanged(const QModelIndex & idx, const QModelIndex &)
+{
+ if (!idx.isValid())
+ return;
+
+ selectedHasFocus_ = true;
+ updateHook();
+}
+
+
+static QModelIndex getSelectedIndex(QListView * lv)
+{
+ QModelIndex retval = QModelIndex();
+ QModelIndexList selIdx =
+ lv->selectionModel()->selectedIndexes();
+ if (!selIdx.empty())
+ retval = selIdx.first();
+ return retval;
+}
+
+
+void GuiSelectionManager::addPB_clicked()
+{
+ QModelIndex const idxToAdd = getSelectedIndex(availableLV);
+ if (!idxToAdd.isValid())
+ return;
+ QModelIndex idx = selectedLV->currentIndex();
+
+ QStringList keys = selectedModel->stringList();
+ keys.append(idxToAdd.data().toString());
+ selectedModel->setStringList(keys);
+ selectionChanged(); //signal
+
+ if (idx.isValid())
+ selectedLV->setCurrentIndex(idx);
+ updateHook();
+}
+
+
+void GuiSelectionManager::deletePB_clicked()
+{
+ QModelIndex idx = getSelectedIndex(selectedLV);
+ if (!idx.isValid())
+ return;
+
+ QStringList keys = selectedModel->stringList();
+ keys.removeAt(idx.row());
+ selectedModel->setStringList(keys);
+ selectionChanged(); //signal
+
+ int nrows = selectedLV->model()->rowCount();
+ if (idx.row() == nrows) //was last item on list
+ idx = idx.sibling(idx.row() - 1, idx.column());
+
+ if (nrows > 1)
+ selectedLV->setCurrentIndex(idx);
+ else if (nrows == 1)
+ selectedLV->setCurrentIndex(selectedLV->model()->index(0,0));
+ selectedHasFocus_ = (nrows > 0);
+ updateHook();
+}
+
+
+void GuiSelectionManager::upPB_clicked()
+{
+ QModelIndex idx = selectedLV->currentIndex();
+
+ int const pos = idx.row();
+ QStringList keys = selectedModel->stringList();
+ keys.swap(pos, pos - 1);
+ selectedModel->setStringList(keys);
+ selectionChanged(); //signal
+
+ selectedLV->setCurrentIndex(idx.sibling(idx.row() - 1, idx.column()));
+ selectedHasFocus_ = true;
+ updateHook();
+}
+
+
+void GuiSelectionManager::downPB_clicked()
+{
+ QModelIndex idx = selectedLV->currentIndex();
+
+ int const pos = idx.row();
+ QStringList keys = selectedModel->stringList();
+ keys.swap(pos, pos + 1);
+ selectedModel->setStringList(keys);
+ selectionChanged(); //signal
+
+ selectedLV->setCurrentIndex(idx.sibling(idx.row() + 1, idx.column()));
+ selectedHasFocus_ = true;
+ updateHook();
+}
+
+
+//FIXME These slots do not really do what they need to do, since focus
+//can enter the QListView in other ways. But there are no signals sent
+//in that case. We need to reimplement focusInEvent() to capture those,
+//which means subclassing QListView. (rgh)
+void GuiSelectionManager::availableLV_clicked(const QModelIndex &)
+{
+ selectedHasFocus_ = false;
+ updateHook();
+}
+
+
+void GuiSelectionManager::availableLV_doubleClicked(const QModelIndex & idx)
+{
+ if (isSelected(idx))
+ return;
+
+ if (idx.isValid())
+ selectedHasFocus_ = false;
+ addPB_clicked();
+ //updateHook() will be emitted there
+}
+
+
+void GuiSelectionManager::selectedLV_clicked(const QModelIndex &)
+{
+ selectedHasFocus_ = true;
+ updateHook();
+}
+
+
+bool GuiSelectionManager::eventFilter(QObject * obj, QEvent * event)
+{
+ if (obj == availableLV) {
+ if (event->type() != QEvent::KeyPress)
+ return QObject::eventFilter(obj, event);
+ QKeyEvent * keyEvent = static_cast<QKeyEvent *>(event);
+ int const keyPressed = keyEvent->key();
+ Qt::KeyboardModifiers const keyModifiers = keyEvent->modifiers();
+ //Enter key without modifier will add current item.
+ //Ctrl-Enter will add it and close the dialog.
+ //This is designed to work both with the main enter key
+ //and the one on the numeric keypad.
+ if ((keyPressed == Qt::Key_Enter || keyPressed == Qt::Key_Return) &&
+ //We want one or both of Control and Keypad, and nothing else
+ //(KeypadModifier is what you get if you use the Enter key on the
+ //numeric keypad.)
+ (!keyModifiers ||
+ (keyModifiers == Qt::ControlModifier) ||
+ (keyModifiers == Qt::KeypadModifier) ||
+ (keyModifiers == (Qt::ControlModifier | Qt::KeypadModifier))
+ )
+ ) {
+ if (addPB->isEnabled()) {
+ addPB_clicked();
+ okHook(); //signal
+ }
+ event->accept();
+ return true;
+ }
+ } else if (obj == selectedLV) {
+ //Delete or backspace key will delete current item
+ //...with control modifier will clear the list
+ if (event->type() != QEvent::KeyPress)
+ return QObject::eventFilter(obj, event);
+ QKeyEvent * keyEvent = static_cast<QKeyEvent *>(event);
+ int const keyPressed = keyEvent->key();
+ Qt::KeyboardModifiers const keyModifiers = keyEvent->modifiers();
+ if (keyPressed == Qt::Key_Delete || keyPressed == Qt::Key_Backspace) {
+ if (keyModifiers == Qt::NoModifier && deletePB->isEnabled())
+ deletePB_clicked();
+ else if (keyModifiers == Qt::ControlModifier) {
+ QStringList list = selectedModel->stringList();
+ list.clear();
+ selectedModel->setStringList(list);
+ updateHook();
+ } else
+ //ignore it otherwise
+ return QObject::eventFilter(obj, event);
+ event->accept();
+ return true;
+ }
+ }
+ return QObject::eventFilter(obj, event);
+}
+
+}//namespace frontend
+}//namespace lyx
+
+#include "GuiSelectionManager_moc.cpp"
--- /dev/null
+/**
+ * \file GuiSelectionManager.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Richard Heck
+ * \author Et Alia
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#ifndef QSELECTIONMANAGER_H
+#define QSELECTIONMANAGER_H
+
+#include "Dialog.h"
+#include <QObject>
+#include <QKeyEvent>
+#include <QStringList>
+#include <QStringListModel>
+#include <QListView>
+#include <QPushButton>
+
+
+namespace lyx {
+namespace frontend {
+
+/** Class to manage a collection of widgets that allows selection
+ * of items from a list of available items. Adapted from code originally
+ * written for GuiCitationDialog.
+ * Note that this is a not a QWidget, though it could be converted to
+ * one. Rather, the managed widgets---see constructor for descripton
+ * of them---should be created independently, and then passed to the
+ * constructor.
+ */
+class GuiSelectionManager : public QObject {
+ Q_OBJECT
+
+ public:
+ ///
+ GuiSelectionManager(
+ QListView * availableLV,
+ QListView * selectedLV,
+ QPushButton * addPB,
+ QPushButton * delPB,
+ QPushButton * upPB,
+ QPushButton * downPB,
+ QStringListModel * availableModel,
+ QStringListModel * selectedModel);
+ /// Sets the state of the various push buttons, depending upon the
+ /// state of the widgets. (E.g., "delete" is enabled only if the
+ /// selection is non-empty.)
+ virtual void update();
+
+ /// Not strictly a matter of focus, which may be elsewhere, but
+ /// whether selectedLV is `more focused' than availableLV. Intended
+ /// to be used, for example, in displaying information about a
+ /// highlighted item: should it be the highlighted available item
+ /// or the highlighted selected item that is displayed?
+ bool selectedFocused() { return selectedHasFocus_; };
+
+ Q_SIGNALS:
+ ///Emitted when the list of selected items has changed.
+ void selectionChanged();
+ ///Emitted when something has changed that might lead the containing
+ ///dialog to want to update---the focused subwidget or selected item.
+ ///(Specifically, it is emitted by *_PB_clicked() and *_LV_clicked.)
+ ///NOTE: No automatic update of the button state is done here. If you
+ ///just want to do that, connect updateHook() to update(). Much of the
+ ///time, though, you will want to do a bit more processing first, so
+ ///you can connect to some other function that itself calls update().
+ void updateHook();
+ ///Emitted on Ctrl-Enter in the availableLV. Intended to be connected
+ ///to an "OK" event in the parent dialog.
+ void okHook();
+
+
+ protected:
+ ///Given a QModelIndex from availableLV, determines whether it has
+ ///been selected (i.e., is also in selectedLV).
+ bool isSelected(const QModelIndex & idx);
+
+ protected Q_SLOTS:
+ ///
+ void availableChanged(const QModelIndex & idx, const QModelIndex &);
+ ///
+ void selectedChanged(const QModelIndex & idx, const QModelIndex &);
+ ///
+ void addPB_clicked();
+ ///
+ void deletePB_clicked();
+ ///
+ void upPB_clicked();
+ ///
+ void downPB_clicked();
+ ///
+ void availableLV_clicked(const QModelIndex &);
+ ///
+ void availableLV_doubleClicked(const QModelIndex &);
+ ///
+ void selectedLV_clicked(const QModelIndex &);
+ ///
+ bool eventFilter(QObject *, QEvent *);
+
+ private:
+ QListView * availableLV;
+ QListView * selectedLV;
+ QPushButton * addPB;
+ QPushButton * deletePB;
+ QPushButton * upPB;
+ QPushButton * downPB;
+ QStringListModel * availableModel;
+ QStringListModel * selectedModel;
+ Dialog::View * dialog;
+
+ bool selectedHasFocus_;
+};
+
+} // namespace frontend
+} // namespace lyx
+
+#endif
--- /dev/null
+/**
+ * \file GuiSendto.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Jürgen Spitzmüller
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "GuiSendto.h"
+#include "Qt2BC.h"
+#include "qt_helpers.h"
+
+#include "Format.h"
+
+#include "controllers/ControlSendto.h"
+
+#include <QListWidget>
+#include <QPushButton>
+#include <QCloseEvent>
+
+using std::vector;
+using std::string;
+
+
+namespace lyx {
+namespace frontend {
+
+/////////////////////////////////////////////////////////////////////
+//
+// GuiSendtoDialog
+//
+/////////////////////////////////////////////////////////////////////
+
+GuiSendtoDialog::GuiSendtoDialog(GuiSendto * form)
+ : form_(form)
+{
+ setupUi(this);
+
+ connect(okPB, SIGNAL(clicked()),
+ form, SLOT(slotOK()));
+ connect(applyPB, SIGNAL(clicked()),
+ form, SLOT(slotApply()));
+ connect(closePB, SIGNAL(clicked()),
+ form, SLOT(slotClose()));
+
+ connect( formatLW, SIGNAL( itemClicked(QListWidgetItem *) ),
+ this, SLOT( slotFormatHighlighted(QListWidgetItem *) ) );
+ connect( formatLW, SIGNAL( itemActivated(QListWidgetItem *) ),
+ this, SLOT( slotFormatSelected(QListWidgetItem *) ) );
+ connect( formatLW, SIGNAL( itemClicked(QListWidgetItem *) ),
+ this, SLOT( changed_adaptor() ) );
+ connect( commandCO, SIGNAL( textChanged(const QString&) ),
+ this, SLOT( changed_adaptor() ) );
+}
+
+
+void GuiSendtoDialog::changed_adaptor()
+{
+ form_->changed();
+}
+
+
+void GuiSendtoDialog::closeEvent(QCloseEvent * e)
+{
+ form_->slotWMHide();
+ e->accept();
+}
+
+
+/////////////////////////////////////////////////////////////////////
+//
+// GuiSendto
+//
+/////////////////////////////////////////////////////////////////////
+
+typedef QController<ControlSendto, GuiView<GuiSendtoDialog> > SendtoBase;
+
+
+GuiSendto::GuiSendto(Dialog & parent)
+ : SendtoBase(parent, _("Send Document to Command"))
+{
+}
+
+
+void GuiSendto::build_dialog()
+{
+ dialog_.reset(new GuiSendtoDialog(this));
+
+ // Manage the ok, apply, restore and cancel/close buttons
+ bcview().setOK(dialog_->okPB);
+ bcview().setApply(dialog_->applyPB);
+ bcview().setCancel(dialog_->closePB);
+}
+
+
+void GuiSendto::update_contents()
+{
+ all_formats_ = controller().allFormats();
+
+ // Check whether the current contents of the browser will be
+ // changed by loading the contents of formats
+ vector<string> keys;
+ keys.resize(all_formats_.size());
+
+ vector<string>::iterator result = keys.begin();
+ vector<Format const *>::const_iterator it = all_formats_.begin();
+ vector<Format const *>::const_iterator end = all_formats_.end();
+ for (; it != end; ++it, ++result) {
+ *result = (*it)->prettyname();
+ }
+
+ // Reload the browser
+ dialog_->formatLW->clear();
+
+ for (vector<string>::const_iterator it = keys.begin();
+ it < keys.end(); ++it) {
+ dialog_->formatLW->addItem(toqstr(*it));
+ }
+
+ dialog_->commandCO->addItem(toqstr(controller().getCommand()));
+}
+
+
+void GuiSendto::apply()
+{
+ int const line(dialog_->formatLW->currentRow());
+
+ if (line < 0 || line > int(dialog_->formatLW->count()))
+ return;
+
+ string const cmd(fromqstr(dialog_->commandCO->currentText()));
+
+ controller().setFormat(all_formats_[line]);
+ controller().setCommand(cmd);
+}
+
+
+bool GuiSendto::isValid()
+{
+ int const line(dialog_->formatLW->currentRow());
+
+ if (line < 0 || line > int(dialog_->formatLW->count()))
+ return false;
+
+ else return dialog_->formatLW->count() != 0 &&
+ !dialog_->commandCO->currentText().isEmpty();
+}
+
+} // namespace frontend
+} // namespace lyx
+
+#include "GuiSendto_moc.cpp"
--- /dev/null
+// -*- C++ -*-
+/**
+ * \file GuiSendto.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Jürgen Spitzmüller
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#ifndef QSENDTO_H
+#define QSENDTO_H
+
+#include "GuiDialogView.h"
+#include "ui_SendtoUi.h"
+
+#include <QDialog>
+
+#include <vector>
+
+class QCloseEvent;
+class QListWidgetItem;
+
+namespace lyx {
+
+class Format;
+
+namespace frontend {
+
+class GuiSendto;
+
+class GuiSendtoDialog : public QDialog, public Ui::SendtoUi {
+ Q_OBJECT
+public:
+ GuiSendtoDialog(GuiSendto * form);
+protected Q_SLOTS:
+ virtual void changed_adaptor();
+ virtual void slotFormatHighlighted(QListWidgetItem *) {}
+ virtual void slotFormatSelected(QListWidgetItem *) {}
+protected:
+ virtual void closeEvent(QCloseEvent * e);
+private:
+ GuiSendto * form_;
+};
+
+
+class ControlSendto;
+
+/** This class provides a Qt implementation of the Custom Export Dialog.
+ */
+class GuiSendto
+ : public QController<ControlSendto, GuiView<GuiSendtoDialog> >
+{
+public:
+ ///
+ friend class GuiSendtoDialog;
+ ///
+ GuiSendto(Dialog &);
+protected:
+ virtual bool isValid();
+private:
+ /// Apply from dialog
+ virtual void apply();
+ /// Update the dialog
+ virtual void update_contents();
+ /// Build the dialog
+ virtual void build_dialog();
+ ///
+ std::vector<Format const *> all_formats_;
+};
+
+} // namespace frontend
+} // namespace lyx
+
+#endif // QSENDTO_H
--- /dev/null
+/**
+ * \file GuiSetBorder.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Edwin Leuven
+ * \author John Levon
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "GuiSetBorder.h"
+
+#include <QPainter>
+#include <QMouseEvent>
+#include <QPaintEvent>
+
+
+GuiSetBorder::GuiSetBorder(QWidget * parent, Qt::WFlags fl)
+ : QWidget(parent, fl), buffer(75, 75)
+{
+ /* length of corner line */
+ l = buffer.width() / 10;
+ /* margin */
+ m = buffer.height() / 10;
+
+ w = buffer.width();
+ h = buffer.height();
+
+ init();
+
+ setMinimumSize(w,h);
+ setMaximumSize(w,h);
+}
+
+
+void GuiSetBorder::paintEvent(QPaintEvent * e)
+{
+ QWidget::paintEvent(e);
+ QPainter painter(this);
+ painter.drawPixmap(0, 0, buffer);
+}
+
+
+void GuiSetBorder::init()
+{
+ buffer.fill();
+ QPainter paint(&buffer);
+
+ paint.setPen(Qt::black);
+
+ // FIXME: wow, readable !! :)
+
+ paint.drawLine(m + l , m, m + l, m + l);
+ paint.drawLine(w - (m + l), m, w - (m + l), m + l);
+
+ paint.drawLine(m, m + l , m + l, m + l);
+ paint.drawLine(m, h - (m + l), m + l, h - (m + l));
+
+ paint.drawLine(m + l ,h - m, m + l ,h - (m + l));
+ paint.drawLine(w - (m + l), h - m, w - (m + l), h - (m + l));
+
+ paint.drawLine(h - m, m+l, h - (m + l), m + l);
+ paint.drawLine(h - m, h - (m + l), h - (m + l),h - (m + l));
+}
+
+
+void GuiSetBorder::mousePressEvent(QMouseEvent * e)
+{
+ if (e->y() > e->x()) {
+ if (e->y() < height() - e->x()) {
+ if (left_.enabled) {
+ setLeft(!left_.set);
+ // emit signal
+ leftSet(left_.set);
+ }
+ } else {
+ if (bottom_.enabled) {
+ setBottom(!bottom_.set);
+ // emit signal
+ bottomSet(bottom_.set);
+ }
+ }
+ } else {
+ if (e->y() < height() - e->x()) {
+ if (top_.enabled) {
+ setTop(!top_.set);
+ // emit signal
+ topSet(top_.set);
+ }
+ } else {
+ if (right_.enabled) {
+ setRight(!right_.set);
+ // emit signal
+ rightSet(right_.set);
+ }
+ }
+ }
+ update();
+ // emit signal
+ clicked();
+}
+
+
+void GuiSetBorder::drawLine(QColor const & col, int x, int y, int x2, int y2)
+{
+ QPainter paint(&buffer);
+ QPen p = paint.pen();
+ p.setWidth(2);
+ p.setColor(col);
+ paint.setPen(p);
+ paint.drawLine(x, y, x2, y2);
+}
+
+
+void GuiSetBorder::drawLeft(bool draw)
+{
+ QColor col(draw ? Qt::black : Qt::white);
+ if (!left_.enabled)
+ col = QColor("grey");
+ drawLine(col, m + l, m + l + 2, m + l, h - m - l - 1);
+}
+
+
+void GuiSetBorder::drawRight(bool draw)
+{
+ QColor col(draw ? Qt::black : Qt::white);
+ if (!right_.enabled)
+ col = QColor("grey");
+ drawLine(col, h - m - l + 1, m + l + 2, h - m - l + 1, h - m - l - 1);
+}
+
+
+void GuiSetBorder::drawTop(bool draw)
+{
+ QColor col(draw ? Qt::black : Qt::white);
+ if (!top_.enabled)
+ col = QColor("grey");
+ drawLine(col, m + l + 2, m + l, w - m - l - 1, m + l);
+}
+
+
+void GuiSetBorder::drawBottom(bool draw)
+{
+ QColor col(draw ? Qt::black : Qt::white);
+ if (!bottom_.enabled)
+ col = QColor("grey");
+ drawLine(col, m + l + 2, w - m - l + 1, w - m - l - 1, w - m - l + 1);
+}
+
+
+void GuiSetBorder::setLeftEnabled(bool border)
+{
+ left_.enabled = border;
+ drawLeft(border);
+}
+
+
+void GuiSetBorder::setRightEnabled(bool border)
+{
+ right_.enabled = border;
+ drawRight(border);
+}
+
+
+void GuiSetBorder::setTopEnabled(bool border)
+{
+ top_.enabled = border;
+ drawTop(border);
+}
+
+
+void GuiSetBorder::setBottomEnabled(bool border)
+{
+ bottom_.enabled = border;
+ drawBottom(border);
+}
+
+
+void GuiSetBorder::setLeft(bool border)
+{
+ left_.set = border;
+ drawLeft(border);
+}
+
+
+void GuiSetBorder::setRight(bool border)
+{
+ right_.set = border;
+ drawRight(border);
+}
+
+
+void GuiSetBorder::setTop(bool border)
+{
+ top_.set = border;
+ drawTop(border);
+}
+
+
+void GuiSetBorder::setBottom(bool border)
+{
+ bottom_.set = border;
+ drawBottom(border);
+}
+
+
+void GuiSetBorder::setAll(bool border)
+{
+ setLeft(border);
+ setRight(border);
+ setTop(border);
+ setBottom(border);
+}
+
+
+bool GuiSetBorder::getLeft()
+{
+ return left_.set;
+}
+
+
+bool GuiSetBorder::getRight()
+{
+ return right_.set;
+}
+
+
+bool GuiSetBorder::getTop()
+{
+ return top_.set;
+}
+
+
+bool GuiSetBorder::getBottom()
+{
+ return bottom_.set;
+}
+
+#include "GuiSetBorder_moc.cpp"
--- /dev/null
+// -*- C++ -*-
+/**
+ * \file GuiSetBorder.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Edwin Leuven
+ * \author John Levon
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+#ifndef QSETBORDER_H
+#define QSETBORDER_H
+
+#include <QWidget>
+#include <QPixmap>
+
+class QColor;
+class QMouseEvent;
+class QPaintEvent;
+
+//namespace lyx {
+
+class GuiSetBorder : public QWidget
+{
+ Q_OBJECT
+public:
+ GuiSetBorder(QWidget * parent = 0, Qt::WFlags fl = 0);
+
+ bool getLeft();
+ bool getRight();
+ bool getTop();
+ bool getBottom();
+
+Q_SIGNALS:
+ void rightSet(bool);
+ void leftSet(bool);
+ void topSet(bool);
+ void bottomSet(bool);
+ void clicked();
+
+public Q_SLOTS:
+ void setLeftEnabled(bool);
+ void setRightEnabled(bool);
+ void setTopEnabled(bool);
+ void setBottomEnabled(bool);
+ void setLeft(bool);
+ void setRight(bool);
+ void setTop(bool);
+ void setBottom(bool);
+ void setAll(bool);
+
+protected:
+ void mousePressEvent(QMouseEvent * e);
+ void paintEvent(QPaintEvent * e);
+
+private:
+ void init();
+
+ void drawLine(QColor const & col, int x, int y, int x2, int y2);
+
+ void drawLeft(bool);
+ void drawRight(bool);
+ void drawTop(bool);
+ void drawBottom(bool);
+
+ class Border {
+ public:
+ Border() : set(true), enabled(true) {}
+ bool set;
+ bool enabled;
+ };
+
+ Border left_;
+ Border right_;
+ Border top_;
+ Border bottom_;
+
+ int m;
+ int l;
+ int w;
+ int h;
+
+ QPixmap buffer;
+};
+
+
+//} // namespace lyx
+
+#endif // QSETBORDER_H
--- /dev/null
+/**
+ * \file GuiShowFile.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author John Levon
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "GuiShowFile.h"
+#include "Qt2BC.h"
+#include "qt_helpers.h"
+
+#include "controllers/ControlShowFile.h"
+
+#include <QTextBrowser>
+#include <QPushButton>
+
+namespace lyx {
+namespace frontend {
+
+/////////////////////////////////////////////////////////////////////
+//
+// GuiShowFileDialog
+//
+/////////////////////////////////////////////////////////////////////
+
+GuiShowFileDialog::GuiShowFileDialog(GuiShowFile * form)
+ : form_(form)
+{
+ setupUi(this);
+ connect(closePB, SIGNAL(clicked()), form, SLOT(slotClose()));
+}
+
+
+void GuiShowFileDialog::closeEvent(QCloseEvent * e)
+{
+ form_->slotWMHide();
+ e->accept();
+}
+
+
+/////////////////////////////////////////////////////////////////////
+//
+// GuiShowFile
+//
+/////////////////////////////////////////////////////////////////////
+
+typedef QController<ControlShowFile, GuiView<GuiShowFileDialog> >
+ ShowFileBase;
+
+
+GuiShowFile::GuiShowFile(Dialog & parent)
+ : ShowFileBase(parent, _("Show File"))
+{
+}
+
+
+void GuiShowFile::build_dialog()
+{
+ dialog_.reset(new GuiShowFileDialog(this));
+
+ bcview().setCancel(dialog_->closePB);
+}
+
+
+void GuiShowFile::update_contents()
+{
+ dialog_->setWindowTitle(toqstr(controller().getFileName()));
+
+ std::string contents = controller().getFileContents();
+ if (contents.empty()) {
+ contents = "Error -> Cannot load file!";
+ }
+
+ dialog_->textTB->setPlainText(toqstr(contents));
+}
+
+} // namespace frontend
+} // namespace lyx
+
+#include "GuiShowFile_moc.cpp"
--- /dev/null
+// -*- C++ -*-
+/**
+ * \file GuiShowFile.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author John Levon
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#ifndef QSHOWFILE_H
+#define QSHOWFILE_H
+
+#include "GuiDialogView.h"
+
+#include "ui_ShowFileUi.h"
+
+#include <QDialog>
+#include <QCloseEvent>
+
+namespace lyx {
+namespace frontend {
+
+class GuiShowFile;
+
+class GuiShowFileDialog : public QDialog, public Ui::ShowFileUi {
+ Q_OBJECT
+public:
+ GuiShowFileDialog(GuiShowFile * form);
+protected:
+ virtual void closeEvent(QCloseEvent * e);
+private:
+ GuiShowFile * form_;
+};
+
+
+class ControlShowFile;
+
+class GuiShowFile
+ : public QController<ControlShowFile, GuiView<GuiShowFileDialog> >
+{
+public:
+ friend class GuiShowFileDialog;
+
+ GuiShowFile(Dialog &);
+private:
+ /// Apply changes
+ virtual void apply() {}
+ /// update
+ virtual void update_contents();
+ /// build the dialog
+ virtual void build_dialog();
+};
+
+} // namespace frontend
+} // namespace lyx
+
+#endif // QSHOWFILE_H
--- /dev/null
+/**
+ * \file GuiSpellchecker.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author John Levon
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "GuiSpellchecker.h"
+#include "Qt2BC.h"
+#include "qt_helpers.h"
+
+#include "controllers/ControlSpellchecker.h"
+
+#include <QProgressBar>
+#include <QLineEdit>
+#include <QPushButton>
+#include <QListWidget>
+#include <QListWidgetItem>
+#include <QCloseEvent>
+#include <QSyntaxHighlighter>
+#include <QTextCharFormat>
+#include <QTextDocument>
+
+
+using std::string;
+
+namespace lyx {
+namespace frontend {
+
+/////////////////////////////////////////////////////////////////////
+//
+// GuiSpellCheckerDialog
+//
+/////////////////////////////////////////////////////////////////////
+
+
+GuiSpellcheckerDialog::GuiSpellcheckerDialog(GuiSpellchecker * form)
+ : form_(form)
+{
+ setupUi(this);
+
+ connect(closePB, SIGNAL(clicked()), form, SLOT(slotClose()));
+
+ connect(replaceCO, SIGNAL(highlighted(const QString &)),
+ this, SLOT(replaceChanged(const QString &)));
+ connect(replacePB, SIGNAL(clicked()),
+ this, SLOT(replaceClicked()));
+ connect(ignorePB, SIGNAL(clicked()),
+ this, SLOT(ignoreClicked()));
+ connect(replacePB_3, SIGNAL(clicked()),
+ this, SLOT(acceptClicked()));
+ connect(addPB, SIGNAL(clicked()),
+ this, SLOT(addClicked()));
+ connect(suggestionsLW, SIGNAL(itemDoubleClicked(QListWidgetItem*)),
+ this, SLOT(replaceClicked() ) );
+ connect(suggestionsLW, SIGNAL(itemClicked(QListWidgetItem*)),
+ this, SLOT(suggestionChanged(QListWidgetItem*)));
+}
+
+
+void GuiSpellcheckerDialog::acceptClicked()
+{
+ form_->accept();
+}
+
+void GuiSpellcheckerDialog::addClicked()
+{
+ form_->add();
+}
+
+void GuiSpellcheckerDialog::replaceClicked()
+{
+ form_->replace();
+}
+
+void GuiSpellcheckerDialog::ignoreClicked()
+{
+ form_->ignore();
+}
+
+void GuiSpellcheckerDialog::suggestionChanged(QListWidgetItem * item)
+{
+ if (replaceCO->count() != 0)
+ replaceCO->setItemText(0, item->text());
+ else
+ replaceCO->addItem(item->text());
+
+ replaceCO->setCurrentIndex(0);
+}
+
+void GuiSpellcheckerDialog::replaceChanged(const QString & str)
+{
+ if (suggestionsLW->currentItem()->text() == str)
+ return;
+
+ for (int i = 0; i < suggestionsLW->count(); ++i) {
+ if (suggestionsLW->item(i)->text() == str) {
+ suggestionsLW->setCurrentRow(i);
+ break;
+ }
+ }
+}
+
+
+void GuiSpellcheckerDialog::closeEvent(QCloseEvent * e)
+{
+ form_->slotWMHide();
+ e->accept();
+}
+
+
+void GuiSpellcheckerDialog::reject()
+{
+ form_->slotWMHide();
+ QDialog::reject();
+}
+
+
+
+/////////////////////////////////////////////////////////////////////
+//
+// GuiSpellChecker
+//
+/////////////////////////////////////////////////////////////////////
+
+typedef QController<ControlSpellchecker, GuiView<GuiSpellcheckerDialog> >
+ SpellcheckerBase;
+
+GuiSpellchecker::GuiSpellchecker(Dialog & parent)
+ : SpellcheckerBase(parent, _("Spellchecker"))
+{}
+
+
+void GuiSpellchecker::build_dialog()
+{
+ dialog_.reset(new GuiSpellcheckerDialog(this));
+
+ bcview().setCancel(dialog_->closePB);
+ dialog_->wordED->setReadOnly(true);
+}
+
+
+void GuiSpellchecker::update_contents()
+{
+ if (isVisible() || controller().exitEarly())
+ controller().check();
+}
+
+
+void GuiSpellchecker::accept()
+{
+ controller().ignoreAll();
+}
+
+
+void GuiSpellchecker::add()
+{
+ controller().insert();
+}
+
+
+void GuiSpellchecker::ignore()
+{
+ controller().check();
+}
+
+
+void GuiSpellchecker::replace()
+{
+ controller().replace(qstring_to_ucs4(dialog_->replaceCO->currentText()));
+}
+
+
+void GuiSpellchecker::partialUpdate(int s)
+{
+ ControlSpellchecker::State const state =
+ static_cast<ControlSpellchecker::State>(s);
+
+ switch (state) {
+
+ case ControlSpellchecker::SPELL_PROGRESSED:
+ dialog_->spellcheckPR->setValue(controller().getProgress());
+ break;
+
+ case ControlSpellchecker::SPELL_FOUND_WORD: {
+ dialog_->wordED->setText(toqstr(controller().getWord()));
+ dialog_->suggestionsLW->clear();
+
+ docstring w;
+ while (!(w = controller().getSuggestion()).empty()) {
+ dialog_->suggestionsLW->addItem(toqstr(w));
+ }
+
+ if (dialog_->suggestionsLW->count() == 0) {
+ dialog_->suggestionChanged(new QListWidgetItem(dialog_->wordED->text()));
+ } else {
+ dialog_->suggestionChanged(dialog_->suggestionsLW->item(0));
+ }
+
+ dialog_->suggestionsLW->setCurrentRow(0);
+ }
+ break;
+
+ }
+}
+
+} // namespace frontend
+} // namespace lyx
+
+#include "GuiSpellchecker_moc.cpp"
--- /dev/null
+// -*- C++ -*-
+/**
+ * \file GuiSpellchecker.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author John Levon
+ * \author Kalle Dalheimer
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#ifndef QSPELLCHECKER_H
+#define QSPELLCHECKER_H
+
+#include "GuiDialogView.h"
+#include "ui_SpellcheckerUi.h"
+
+#include <QDialog>
+#include <QCloseEvent>
+
+class QListWidgetItem;
+
+namespace lyx {
+namespace frontend {
+
+class GuiSpellchecker;
+
+class GuiSpellcheckerDialog: public QDialog, public Ui::SpellcheckerUi {
+ Q_OBJECT
+public:
+ GuiSpellcheckerDialog(GuiSpellchecker * form);
+public Q_SLOTS:
+ virtual void suggestionChanged(QListWidgetItem *);
+
+protected Q_SLOTS:
+ virtual void acceptClicked();
+ virtual void addClicked();
+ virtual void replaceClicked();
+ virtual void ignoreClicked();
+ virtual void replaceChanged(const QString &);
+ virtual void reject();
+
+protected:
+ virtual void closeEvent(QCloseEvent * e);
+
+private:
+ GuiSpellchecker * form_;
+};
+
+
+class ControlSpellchecker;
+
+class GuiSpellchecker
+ : public QController<ControlSpellchecker, GuiView<GuiSpellcheckerDialog> >
+{
+public:
+ friend class GuiSpellcheckerDialog;
+
+ GuiSpellchecker(Dialog &);
+
+ /// update from controller
+ void partialUpdate(int id);
+private:
+ void accept();
+ void add();
+ void ignore();
+ void replace();
+
+ /// Apply changes
+ virtual void apply() {}
+ ///
+ virtual void update_contents();
+ /// build the dialog
+ virtual void build_dialog();
+};
+
+} // namespace frontend
+} // namespace lyx
+
+#endif // QSPELLCHECKER_H
--- /dev/null
+/**
+ * \file GuiTabular.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author John Levon
+ * \author Jürgen Spitzmüller
+ * \author Herbert Voß
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "CheckedLineEdit.h"
+#include "GuiTabular.h"
+#include "Qt2BC.h"
+
+#include "LengthCombo.h"
+#include "Validator.h"
+#include "qt_helpers.h"
+
+#include "controllers/ButtonController.h"
+#include "controllers/ControlTabular.h"
+
+#include "support/convert.h"
+
+#include <QCloseEvent>
+#include <QCheckBox>
+#include <QPushButton>
+#include <QRadioButton>
+#include <QLineEdit>
+
+#include "GuiSetBorder.h"
+
+using std::string;
+
+namespace lyx {
+namespace frontend {
+
+/////////////////////////////////////////////////////////////////////
+//
+// GuiTabularDialog
+//
+/////////////////////////////////////////////////////////////////////
+
+GuiTabularDialog::GuiTabularDialog(GuiTabular * form)
+ : form_(form)
+{
+ setupUi(this);
+
+ widthED->setValidator(unsignedLengthValidator(widthED));
+ topspaceED->setValidator(new LengthValidator(topspaceED));
+ bottomspaceED->setValidator(new LengthValidator(bottomspaceED));
+ interlinespaceED->setValidator(new LengthValidator(interlinespaceED));
+
+ connect(topspaceED, SIGNAL(returnPressed()),
+ this, SLOT(topspace_changed()));
+ connect(topspaceUnit, SIGNAL(selectionChanged(lyx::Length::UNIT)),
+ this, SLOT(topspace_changed()));
+ connect(topspaceCO, SIGNAL(activated(int)), this, SLOT(topspace_changed()));
+ connect(bottomspaceED, SIGNAL(returnPressed()),
+ this, SLOT(bottomspace_changed()));
+ connect(bottomspaceUnit, SIGNAL(selectionChanged(lyx::Length::UNIT)),
+ this, SLOT(bottomspace_changed()));
+ connect(bottomspaceCO, SIGNAL(activated(int)), this, SLOT(bottomspace_changed()));
+ connect(interlinespaceED, SIGNAL(returnPressed()),
+ this, SLOT(interlinespace_changed()));
+ connect(interlinespaceUnit, SIGNAL(selectionChanged(lyx::Length::UNIT)),
+ this, SLOT(interlinespace_changed()));
+ connect(interlinespaceCO, SIGNAL(activated(int)), this, SLOT(interlinespace_changed()));
+ connect(booktabsRB, SIGNAL(clicked(bool)), this, SLOT(booktabsChanged(bool)));
+ connect(borderDefaultRB, SIGNAL(clicked(bool)), this, SLOT(booktabsChanged(bool)));
+ connect(borderSetPB, SIGNAL(clicked()), this, SLOT(borderSet_clicked()));
+ connect(borderUnsetPB, SIGNAL(clicked()), this, SLOT(borderUnset_clicked()));
+ connect(longTabularCB, SIGNAL(toggled(bool)), longtableGB, SLOT(setEnabled(bool)));
+ connect(longTabularCB, SIGNAL(toggled(bool)), newpageCB, SLOT(setEnabled(bool)));
+ connect(hAlignCB, SIGNAL(activated(int)), this, SLOT(hAlign_changed(int)));
+ connect(vAlignCB, SIGNAL(activated(int)), this, SLOT(vAlign_changed(int)));
+ connect(multicolumnCB, SIGNAL(clicked()), this, SLOT(multicolumn_clicked()));
+ connect(newpageCB, SIGNAL(clicked()), this, SLOT(ltNewpage_clicked()));
+ connect(headerStatusCB, SIGNAL(clicked()), this, SLOT(ltHeaderStatus_clicked()));
+ connect(headerBorderAboveCB, SIGNAL(clicked()), this, SLOT(ltHeaderBorderAbove_clicked()));
+ connect(headerBorderBelowCB, SIGNAL(clicked()), this, SLOT(ltHeaderBorderBelow_clicked()));
+ connect(firstheaderStatusCB, SIGNAL(clicked()), this, SLOT(ltFirstHeaderStatus_clicked()));
+ connect(firstheaderBorderAboveCB, SIGNAL(clicked()), this, SLOT(ltFirstHeaderBorderAbove_clicked()));
+ connect(firstheaderBorderBelowCB, SIGNAL(clicked()), this, SLOT(ltFirstHeaderBorderBelow_clicked()));
+ connect(firstheaderNoContentsCB, SIGNAL(clicked()), this, SLOT(ltFirstHeaderEmpty_clicked()));
+ connect(footerStatusCB, SIGNAL(clicked()), this, SLOT(ltFooterStatus_clicked()));
+ connect(footerBorderAboveCB, SIGNAL(clicked()), this, SLOT(ltFooterBorderAbove_clicked()));
+ connect(footerBorderBelowCB, SIGNAL(clicked()), this, SLOT(ltFooterBorderBelow_clicked()));
+ connect(lastfooterStatusCB, SIGNAL(clicked()), this, SLOT(ltLastFooterStatus_clicked()));
+ connect(lastfooterBorderAboveCB, SIGNAL(clicked()), this, SLOT(ltLastFooterBorderAbove_clicked()));
+ connect(lastfooterBorderBelowCB, SIGNAL(clicked()), this, SLOT(ltLastFooterBorderBelow_clicked()));
+ connect(lastfooterNoContentsCB, SIGNAL(clicked()), this, SLOT(ltLastFooterEmpty_clicked()));
+ connect(specialAlignmentED, SIGNAL(returnPressed()), this, SLOT(specialAlignment_changed()));
+ connect(widthED, SIGNAL(returnPressed()), this, SLOT(width_changed()));
+ connect(widthUnit, SIGNAL(selectionChanged(lyx::Length::UNIT)), this, SLOT(width_changed()));
+ connect(closePB, SIGNAL(clicked()), this, SLOT(close_clicked()));
+ connect(borders, SIGNAL(topSet(bool)), this, SLOT(topBorder_changed()));
+ connect(borders, SIGNAL(bottomSet(bool)), this, SLOT(bottomBorder_changed()));
+ connect(borders, SIGNAL(rightSet(bool)), this, SLOT(rightBorder_changed()));
+ connect(borders, SIGNAL(leftSet(bool)), this, SLOT(leftBorder_changed()));
+ connect(rotateTabularCB, SIGNAL(clicked()), this, SLOT(rotateTabular()));
+ connect(rotateCellCB, SIGNAL(clicked()), this, SLOT(rotateCell()));
+ connect(longTabularCB, SIGNAL(clicked()), this, SLOT(longTabular()));
+}
+
+
+void GuiTabularDialog::change_adaptor()
+{
+ form_->changed();
+}
+
+
+void GuiTabularDialog::closeEvent(QCloseEvent * e)
+{
+ form_->slotWMHide();
+ e->accept();
+}
+
+
+void GuiTabularDialog::booktabsChanged(bool)
+{
+ form_->changed();
+ form_->controller().booktabs(booktabsRB->isChecked());
+ form_->update_borders();
+}
+
+
+void GuiTabularDialog::topspace_changed()
+{
+ switch(topspaceCO->currentIndex()) {
+ case 0: {
+ form_->controller().set(Tabular::SET_TOP_SPACE, "");
+ topspaceED->setEnabled(false);
+ topspaceUnit->setEnabled(false);
+ break;
+ }
+ case 1: {
+ form_->controller().set(Tabular::SET_TOP_SPACE, "default");
+ topspaceED->setEnabled(false);
+ topspaceUnit->setEnabled(false);
+ break;
+ }
+ case 2: {
+ if (!topspaceED->text().isEmpty())
+ form_->controller().set(Tabular::SET_TOP_SPACE,
+ widgetsToLength(topspaceED, topspaceUnit));
+ if (!form_->bc().bp().isReadOnly()) {
+ topspaceED->setEnabled(true);
+ topspaceUnit->setEnabled(true);
+ }
+ break;
+ }
+ }
+ form_->changed();
+}
+
+
+void GuiTabularDialog::bottomspace_changed()
+{
+ switch(bottomspaceCO->currentIndex()) {
+ case 0: {
+ form_->controller().set(Tabular::SET_BOTTOM_SPACE, "");
+ bottomspaceED->setEnabled(false);
+ bottomspaceUnit->setEnabled(false);
+ break;
+ }
+ case 1: {
+ form_->controller().set(Tabular::SET_BOTTOM_SPACE, "default");
+ bottomspaceED->setEnabled(false);
+ bottomspaceUnit->setEnabled(false);
+ break;
+ }
+ case 2: {
+ if (!bottomspaceED->text().isEmpty())
+ form_->controller().set(Tabular::SET_BOTTOM_SPACE,
+ widgetsToLength(bottomspaceED, bottomspaceUnit));
+ if (!form_->bc().bp().isReadOnly()) {
+ bottomspaceED->setEnabled(true);
+ bottomspaceUnit->setEnabled(true);
+ }
+ break;
+ }
+ }
+ form_->changed();
+}
+
+
+void GuiTabularDialog::interlinespace_changed()
+{
+ switch(interlinespaceCO->currentIndex()) {
+ case 0: {
+ form_->controller().set(Tabular::SET_INTERLINE_SPACE, "");
+ interlinespaceED->setEnabled(false);
+ interlinespaceUnit->setEnabled(false);
+ break;
+ }
+ case 1: {
+ form_->controller().set(Tabular::SET_INTERLINE_SPACE, "default");
+ interlinespaceED->setEnabled(false);
+ interlinespaceUnit->setEnabled(false);
+ break;
+ }
+ case 2: {
+ if (!interlinespaceED->text().isEmpty())
+ form_->controller().set(Tabular::SET_INTERLINE_SPACE,
+ widgetsToLength(interlinespaceED, interlinespaceUnit));
+ if (!form_->bc().bp().isReadOnly()) {
+ interlinespaceED->setEnabled(true);
+ interlinespaceUnit->setEnabled(true);
+ }
+ break;
+ }
+ }
+ form_->changed();
+}
+
+
+void GuiTabularDialog::close_clicked()
+{
+ form_->closeGUI();
+ form_->slotClose();
+}
+
+
+void GuiTabularDialog::borderSet_clicked()
+{
+ form_->controller().set(Tabular::SET_ALL_LINES);
+ form_->update_borders();
+ form_->changed();
+}
+
+
+void GuiTabularDialog::borderUnset_clicked()
+{
+ form_->controller().set(Tabular::UNSET_ALL_LINES);
+ form_->update_borders();
+ form_->changed();
+}
+
+
+void GuiTabularDialog::leftBorder_changed()
+{
+ form_->controller().toggleLeftLine();
+ form_->changed();
+}
+
+
+void GuiTabularDialog::rightBorder_changed()
+{
+ form_->controller().toggleRightLine();
+ form_->changed();
+}
+
+
+void GuiTabularDialog::topBorder_changed()
+{
+ form_->controller().toggleTopLine();
+ form_->changed();
+}
+
+
+void GuiTabularDialog::bottomBorder_changed()
+{
+ form_->controller().toggleBottomLine();
+ form_->changed();
+}
+
+
+void GuiTabularDialog::specialAlignment_changed()
+{
+ string special = fromqstr(specialAlignmentED->text());
+ form_->controller().setSpecial(special);
+ form_->changed();
+}
+
+
+void GuiTabularDialog::width_changed()
+{
+ form_->changed();
+ string const width = widgetsToLength(widthED, widthUnit);
+ form_->controller().setWidth(width);
+}
+
+
+void GuiTabularDialog::multicolumn_clicked()
+{
+ form_->controller().toggleMultiColumn();
+ form_->changed();
+}
+
+
+void GuiTabularDialog::rotateTabular()
+{
+ form_->controller().rotateTabular(rotateTabularCB->isChecked());
+ form_->changed();
+}
+
+
+void GuiTabularDialog::rotateCell()
+{
+ form_->controller().rotateCell(rotateCellCB->isChecked());
+ form_->changed();
+}
+
+
+void GuiTabularDialog::hAlign_changed(int align)
+{
+ ControlTabular::HALIGN h = ControlTabular::LEFT;
+
+ switch (align) {
+ case 0: h = ControlTabular::LEFT; break;
+ case 1: h = ControlTabular::CENTER; break;
+ case 2: h = ControlTabular::RIGHT; break;
+ case 3: h = ControlTabular::BLOCK; break;
+ }
+
+ form_->controller().halign(h);
+}
+
+
+void GuiTabularDialog::vAlign_changed(int align)
+{
+ ControlTabular::VALIGN v = ControlTabular::TOP;
+
+ switch (align) {
+ case 0: v = ControlTabular::TOP; break;
+ case 1: v = ControlTabular::MIDDLE; break;
+ case 2: v = ControlTabular::BOTTOM; break;
+ }
+
+ form_->controller().valign(v);
+}
+
+
+void GuiTabularDialog::longTabular()
+{
+ form_->controller().longTabular(longTabularCB->isChecked());
+ form_->changed();
+}
+
+
+void GuiTabularDialog::ltNewpage_clicked()
+{
+ form_->controller().set(Tabular::SET_LTNEWPAGE);
+ form_->changed();
+}
+
+
+void GuiTabularDialog::ltHeaderStatus_clicked()
+{
+ bool enable(headerStatusCB->isChecked());
+ if (enable)
+ form_->controller().set(Tabular::SET_LTHEAD, "");
+ else
+ form_->controller().set(Tabular::UNSET_LTHEAD, "");
+ headerBorderAboveCB->setEnabled(enable);
+ headerBorderBelowCB->setEnabled(enable);
+ firstheaderNoContentsCB->setEnabled(enable);
+ form_->changed();
+}
+
+
+void GuiTabularDialog::ltHeaderBorderAbove_clicked()
+{
+ if (headerBorderAboveCB->isChecked())
+ form_->controller().set(Tabular::SET_LTHEAD, "dl_above");
+ else
+ form_->controller().set(Tabular::UNSET_LTHEAD, "dl_above");
+ form_->changed();
+}
+
+
+void GuiTabularDialog::ltHeaderBorderBelow_clicked()
+{
+ if (headerBorderBelowCB->isChecked())
+ form_->controller().set(Tabular::SET_LTHEAD, "dl_below");
+ else
+ form_->controller().set(Tabular::UNSET_LTHEAD, "dl_below");
+ form_->changed();
+}
+
+
+void GuiTabularDialog::ltFirstHeaderBorderAbove_clicked()
+{
+ if (firstheaderBorderAboveCB->isChecked())
+ form_->controller().set(Tabular::SET_LTFIRSTHEAD, "dl_above");
+ else
+ form_->controller().set(Tabular::UNSET_LTFIRSTHEAD, "dl_above");
+ form_->changed();
+}
+
+
+void GuiTabularDialog::ltFirstHeaderBorderBelow_clicked()
+{
+ if (firstheaderBorderBelowCB->isChecked())
+ form_->controller().set(Tabular::SET_LTFIRSTHEAD, "dl_below");
+ else
+ form_->controller().set(Tabular::UNSET_LTFIRSTHEAD, "dl_below");
+ form_->changed();
+}
+
+
+void GuiTabularDialog::ltFirstHeaderStatus_clicked()
+{
+ bool enable(firstheaderStatusCB->isChecked());
+ if (enable)
+ form_->controller().set(Tabular::SET_LTFIRSTHEAD, "");
+ else
+ form_->controller().set(Tabular::UNSET_LTFIRSTHEAD, "");
+ firstheaderBorderAboveCB->setEnabled(enable);
+ firstheaderBorderBelowCB->setEnabled(enable);
+ form_->changed();
+}
+
+
+void GuiTabularDialog::ltFirstHeaderEmpty_clicked()
+{
+ bool enable(firstheaderNoContentsCB->isChecked());
+ if (enable)
+ form_->controller().set(Tabular::SET_LTFIRSTHEAD, "empty");
+ else
+ form_->controller().set(Tabular::UNSET_LTFIRSTHEAD, "empty");
+ firstheaderStatusCB->setEnabled(!enable);
+ firstheaderBorderAboveCB->setEnabled(!enable);
+ firstheaderBorderBelowCB->setEnabled(!enable);
+ form_->changed();
+}
+
+
+void GuiTabularDialog::ltFooterStatus_clicked()
+{
+ bool enable(footerStatusCB->isChecked());
+ if (enable)
+ form_->controller().set(Tabular::SET_LTFOOT, "");
+ else
+ form_->controller().set(Tabular::UNSET_LTFOOT, "");
+ footerBorderAboveCB->setEnabled(enable);
+ footerBorderBelowCB->setEnabled(enable);
+ lastfooterNoContentsCB->setEnabled(enable);
+ form_->changed();
+}
+
+
+void GuiTabularDialog::ltFooterBorderAbove_clicked()
+{
+ if (footerBorderAboveCB->isChecked())
+ form_->controller().set(Tabular::SET_LTFOOT, "dl_above");
+ else
+ form_->controller().set(Tabular::UNSET_LTFOOT, "dl_above");
+ form_->changed();
+}
+
+
+void GuiTabularDialog::ltFooterBorderBelow_clicked()
+{
+ if (footerBorderBelowCB->isChecked())
+ form_->controller().set(Tabular::SET_LTFOOT, "dl_below");
+ else
+ form_->controller().set(Tabular::UNSET_LTFOOT, "dl_below");
+ form_->changed();
+}
+
+
+void GuiTabularDialog::ltLastFooterStatus_clicked()
+{
+ bool enable(lastfooterStatusCB->isChecked());
+ if (enable)
+ form_->controller().set(Tabular::SET_LTLASTFOOT, "");
+ else
+ form_->controller().set(Tabular::UNSET_LTLASTFOOT, "");
+ lastfooterBorderAboveCB->setEnabled(enable);
+ lastfooterBorderBelowCB->setEnabled(enable);
+ form_->changed();
+}
+
+
+void GuiTabularDialog::ltLastFooterBorderAbove_clicked()
+{
+ if (lastfooterBorderAboveCB->isChecked())
+ form_->controller().set(Tabular::SET_LTLASTFOOT, "dl_above");
+ else
+ form_->controller().set(Tabular::UNSET_LTLASTFOOT, "dl_above");
+ form_->changed();
+}
+
+
+void GuiTabularDialog::ltLastFooterBorderBelow_clicked()
+{
+ if (lastfooterBorderBelowCB->isChecked())
+ form_->controller().set(Tabular::SET_LTLASTFOOT, "dl_below");
+ else
+ form_->controller().set(Tabular::UNSET_LTLASTFOOT, "dl_below");
+ form_->changed();
+}
+
+
+void GuiTabularDialog::ltLastFooterEmpty_clicked()
+{
+ bool enable(lastfooterNoContentsCB->isChecked());
+ if (enable)
+ form_->controller().set(Tabular::SET_LTLASTFOOT, "empty");
+ else
+ form_->controller().set(Tabular::UNSET_LTLASTFOOT, "empty");
+ lastfooterStatusCB->setEnabled(!enable);
+ lastfooterBorderAboveCB->setEnabled(!enable);
+ lastfooterBorderBelowCB->setEnabled(!enable);
+ form_->changed();
+}
+
+
+/////////////////////////////////////////////////////////////////////
+//
+// GuiTabular
+//
+/////////////////////////////////////////////////////////////////////
+
+typedef QController<ControlTabular, GuiView<GuiTabularDialog> > tabular_base_class;
+
+GuiTabular::GuiTabular(Dialog & parent)
+ : tabular_base_class(parent, _("Table Settings"))
+{
+}
+
+
+void GuiTabular::build_dialog()
+{
+ dialog_.reset(new GuiTabularDialog(this));
+
+ bcview().setCancel(dialog_->closePB);
+
+ bcview().addReadOnly(dialog_->topspaceED);
+ bcview().addReadOnly(dialog_->topspaceUnit);
+ bcview().addReadOnly(dialog_->topspaceCO);
+ bcview().addReadOnly(dialog_->bottomspaceED);
+ bcview().addReadOnly(dialog_->bottomspaceUnit);
+ bcview().addReadOnly(dialog_->bottomspaceCO);
+ bcview().addReadOnly(dialog_->interlinespaceED);
+ bcview().addReadOnly(dialog_->interlinespaceUnit);
+ bcview().addReadOnly(dialog_->interlinespaceCO);
+ bcview().addReadOnly(dialog_->borderDefaultRB);
+ bcview().addReadOnly(dialog_->booktabsRB);
+
+ bcview().addReadOnly(dialog_->multicolumnCB);
+ bcview().addReadOnly(dialog_->rotateCellCB);
+ bcview().addReadOnly(dialog_->rotateTabularCB);
+ bcview().addReadOnly(dialog_->specialAlignmentED);
+ bcview().addReadOnly(dialog_->widthED);
+ bcview().addReadOnly(dialog_->widthUnit);
+ bcview().addReadOnly(dialog_->hAlignCB);
+ bcview().addReadOnly(dialog_->vAlignCB);
+ bcview().addReadOnly(dialog_->borderSetPB);
+ bcview().addReadOnly(dialog_->borderUnsetPB);
+ bcview().addReadOnly(dialog_->borders);
+ bcview().addReadOnly(dialog_->longTabularCB);
+ bcview().addReadOnly(dialog_->headerStatusCB);
+ bcview().addReadOnly(dialog_->headerBorderAboveCB);
+ bcview().addReadOnly(dialog_->headerBorderBelowCB);
+ bcview().addReadOnly(dialog_->firstheaderStatusCB);
+ bcview().addReadOnly(dialog_->firstheaderBorderAboveCB);
+ bcview().addReadOnly(dialog_->firstheaderBorderBelowCB);
+ bcview().addReadOnly(dialog_->firstheaderNoContentsCB);
+ bcview().addReadOnly(dialog_->footerStatusCB);
+ bcview().addReadOnly(dialog_->footerBorderAboveCB);
+ bcview().addReadOnly(dialog_->footerBorderBelowCB);
+ bcview().addReadOnly(dialog_->lastfooterStatusCB);
+ bcview().addReadOnly(dialog_->lastfooterBorderAboveCB);
+ bcview().addReadOnly(dialog_->lastfooterBorderBelowCB);
+ bcview().addReadOnly(dialog_->lastfooterNoContentsCB);
+ bcview().addReadOnly(dialog_->newpageCB);
+
+ // initialize the length validator
+ addCheckedLineEdit(bcview(), dialog_->widthED,
+ dialog_->fixedWidthColLA);
+ addCheckedLineEdit(bcview(), dialog_->topspaceED,
+ dialog_->topspaceLA);
+ addCheckedLineEdit(bcview(), dialog_->bottomspaceED,
+ dialog_->bottomspaceLA);
+ addCheckedLineEdit(bcview(), dialog_->interlinespaceED,
+ dialog_->interlinespaceLA);
+}
+
+
+bool GuiTabular::isValid()
+{
+ return true;
+}
+
+
+void GuiTabular::update_borders()
+{
+ Tabular const & tabular = controller().tabular();
+ Tabular::idx_type const cell = controller().getActiveCell();
+ bool const isMulticolumnCell = tabular.isMultiColumn(cell);
+
+ if (!isMulticolumnCell) {
+ dialog_->borders->setLeftEnabled(true);
+ dialog_->borders->setRightEnabled(true);
+ dialog_->borders->setTop(tabular.topLine(cell, true));
+ dialog_->borders->setBottom(tabular.bottomLine(cell, true));
+ dialog_->borders->setLeft(tabular.leftLine(cell, true));
+ dialog_->borders->setRight(tabular.rightLine(cell, true));
+ // repaint the setborder widget
+ dialog_->borders->update();
+ return;
+ }
+
+ dialog_->borders->setTop(tabular.topLine(cell));
+ dialog_->borders->setBottom(tabular.bottomLine(cell));
+ // pay attention to left/right lines: they are only allowed
+ // to set if we are in first/last cell of row or if the left/right
+ // cell is also a multicolumn.
+ if (tabular.isFirstCellInRow(cell) || tabular.isMultiColumn(cell - 1)) {
+ dialog_->borders->setLeftEnabled(true);
+ dialog_->borders->setLeft(tabular.leftLine(cell));
+ } else {
+ dialog_->borders->setLeft(false);
+ dialog_->borders->setLeftEnabled(false);
+ }
+ if (tabular.isLastCellInRow(cell) || tabular.isMultiColumn(cell + 1)) {
+ dialog_->borders->setRightEnabled(true);
+ dialog_->borders->setRight(tabular.rightLine(cell));
+ } else {
+ dialog_->borders->setRight(false);
+ dialog_->borders->setRightEnabled(false);
+ }
+ // repaint the setborder widget
+ dialog_->borders->update();
+}
+
+
+void GuiTabular::update_contents()
+{
+ controller().initialiseParams(string());
+
+ Tabular const & tabular(controller().tabular());
+ Tabular::idx_type const cell = controller().getActiveCell();
+
+ Tabular::row_type const row(tabular.row_of_cell(cell));
+ Tabular::col_type const col(tabular.column_of_cell(cell));
+
+ dialog_->tabularRowED->setText(toqstr(convert<string>(row + 1)));
+ dialog_->tabularColumnED->setText(toqstr(convert<string>(col + 1)));
+
+ bool const multicol(tabular.isMultiColumn(cell));
+
+ dialog_->multicolumnCB->setChecked(multicol);
+
+ dialog_->rotateCellCB->setChecked(tabular.getRotateCell(cell));
+ dialog_->rotateTabularCB->setChecked(tabular.getRotateTabular());
+
+ dialog_->longTabularCB->setChecked(tabular.isLongTabular());
+
+ update_borders();
+
+ Length pwidth;
+ docstring special;
+
+ if (multicol) {
+ special = tabular.getAlignSpecial(cell, Tabular::SET_SPECIAL_MULTI);
+ pwidth = tabular.getMColumnPWidth(cell);
+ } else {
+ special = tabular.getAlignSpecial(cell, Tabular::SET_SPECIAL_COLUMN);
+ pwidth = tabular.getColumnPWidth(cell);
+ }
+
+ dialog_->specialAlignmentED->setText(toqstr(special));
+
+ bool const isReadonly = bc().bp().isReadOnly();
+ dialog_->specialAlignmentED->setEnabled(!isReadonly);
+
+ Length::UNIT default_unit = controller().useMetricUnits() ? Length::CM : Length::IN;
+
+ dialog_->borderDefaultRB->setChecked(!tabular.useBookTabs());
+ dialog_->booktabsRB->setChecked(tabular.useBookTabs());
+
+ if (tabular.row_info[row].top_space.empty()
+ && !tabular.row_info[row].top_space_default) {
+ dialog_->topspaceCO->setCurrentIndex(0);
+ } else if (tabular.row_info[row].top_space_default) {
+ dialog_->topspaceCO->setCurrentIndex(1);
+ } else {
+ dialog_->topspaceCO->setCurrentIndex(2);
+ lengthToWidgets(dialog_->topspaceED,
+ dialog_->topspaceUnit,
+ tabular.row_info[row].top_space.asString(),
+ default_unit);
+ }
+ dialog_->topspaceED->setEnabled(!isReadonly
+ && (dialog_->topspaceCO->currentIndex() == 2));
+ dialog_->topspaceUnit->setEnabled(!isReadonly
+ && (dialog_->topspaceCO->currentIndex() == 2));
+ dialog_->topspaceCO->setEnabled(!isReadonly);
+
+ if (tabular.row_info[row].bottom_space.empty()
+ && !tabular.row_info[row].bottom_space_default) {
+ dialog_->bottomspaceCO->setCurrentIndex(0);
+ } else if (tabular.row_info[row].bottom_space_default) {
+ dialog_->bottomspaceCO->setCurrentIndex(1);
+ } else {
+ dialog_->bottomspaceCO->setCurrentIndex(2);
+ lengthToWidgets(dialog_->bottomspaceED,
+ dialog_->bottomspaceUnit,
+ tabular.row_info[row].bottom_space.asString(),
+ default_unit);
+ }
+ dialog_->bottomspaceED->setEnabled(!isReadonly
+ && (dialog_->bottomspaceCO->currentIndex() == 2));
+ dialog_->bottomspaceUnit->setEnabled(!isReadonly
+ && (dialog_->bottomspaceCO->currentIndex() == 2));
+ dialog_->bottomspaceCO->setEnabled(!isReadonly);
+
+ if (tabular.row_info[row].interline_space.empty()
+ && !tabular.row_info[row].interline_space_default) {
+ dialog_->interlinespaceCO->setCurrentIndex(0);
+ } else if (tabular.row_info[row].interline_space_default) {
+ dialog_->interlinespaceCO->setCurrentIndex(1);
+ } else {
+ dialog_->interlinespaceCO->setCurrentIndex(2);
+ lengthToWidgets(dialog_->interlinespaceED,
+ dialog_->interlinespaceUnit,
+ tabular.row_info[row].interline_space.asString(),
+ default_unit);
+ }
+ dialog_->interlinespaceED->setEnabled(!isReadonly
+ && (dialog_->interlinespaceCO->currentIndex() == 2));
+ dialog_->interlinespaceUnit->setEnabled(!isReadonly
+ && (dialog_->interlinespaceCO->currentIndex() == 2));
+ dialog_->interlinespaceCO->setEnabled(!isReadonly);
+
+ string colwidth;
+ if (!pwidth.zero())
+ colwidth = pwidth.asString();
+ lengthToWidgets(dialog_->widthED, dialog_->widthUnit,
+ colwidth, default_unit);
+
+ dialog_->widthED->setEnabled(!isReadonly);
+ dialog_->widthUnit->setEnabled(!isReadonly);
+
+ dialog_->hAlignCB->clear();
+ dialog_->hAlignCB->addItem(qt_("Left"));
+ dialog_->hAlignCB->addItem(qt_("Center"));
+ dialog_->hAlignCB->addItem(qt_("Right"));
+ if (!multicol && !pwidth.zero())
+ dialog_->hAlignCB->addItem(qt_("Justified"));
+
+ int align = 0;
+ switch (tabular.getAlignment(cell)) {
+ case LYX_ALIGN_LEFT:
+ align = 0;
+ break;
+ case LYX_ALIGN_CENTER:
+ align = 1;
+ break;
+ case LYX_ALIGN_RIGHT:
+ align = 2;
+ break;
+ case LYX_ALIGN_BLOCK:
+ {
+ if (!multicol && !pwidth.zero())
+ align = 3;
+ break;
+ }
+ default:
+ align = 0;
+ break;
+ }
+ dialog_->hAlignCB->setCurrentIndex(align);
+
+ int valign = 0;
+ switch (tabular.getVAlignment(cell)) {
+ case Tabular::LYX_VALIGN_TOP:
+ valign = 0;
+ break;
+ case Tabular::LYX_VALIGN_MIDDLE:
+ valign = 1;
+ break;
+ case Tabular::LYX_VALIGN_BOTTOM:
+ valign = 2;
+ break;
+ default:
+ valign = 1;
+ break;
+ }
+ if (pwidth.zero())
+ valign = 1;
+ dialog_->vAlignCB->setCurrentIndex(valign);
+
+ dialog_->hAlignCB->setEnabled(true);
+ dialog_->vAlignCB->setEnabled(!pwidth.zero());
+
+ if (!tabular.isLongTabular()) {
+ dialog_->headerStatusCB->setChecked(false);
+ dialog_->headerBorderAboveCB->setChecked(false);
+ dialog_->headerBorderBelowCB->setChecked(false);
+ dialog_->firstheaderStatusCB->setChecked(false);
+ dialog_->firstheaderBorderAboveCB->setChecked(false);
+ dialog_->firstheaderBorderBelowCB->setChecked(false);
+ dialog_->firstheaderNoContentsCB->setChecked(false);
+ dialog_->footerStatusCB->setChecked(false);
+ dialog_->footerBorderAboveCB->setChecked(false);
+ dialog_->footerBorderBelowCB->setChecked(false);
+ dialog_->lastfooterStatusCB->setChecked(false);
+ dialog_->lastfooterBorderAboveCB->setChecked(false);
+ dialog_->lastfooterBorderBelowCB->setChecked(false);
+ dialog_->lastfooterNoContentsCB->setChecked(false);
+ dialog_->newpageCB->setChecked(false);
+ dialog_->newpageCB->setEnabled(false);
+ return;
+ }
+
+ Tabular::ltType ltt;
+ bool use_empty;
+ bool row_set = tabular.getRowOfLTHead(row, ltt);
+ dialog_->headerStatusCB->setChecked(row_set);
+ if (ltt.set) {
+ dialog_->headerBorderAboveCB->setChecked(ltt.topDL);
+ dialog_->headerBorderBelowCB->setChecked(ltt.bottomDL);
+ use_empty = true;
+ } else {
+ dialog_->headerBorderAboveCB->setChecked(false);
+ dialog_->headerBorderBelowCB->setChecked(false);
+ dialog_->headerBorderAboveCB->setEnabled(false);
+ dialog_->headerBorderBelowCB->setEnabled(false);
+ dialog_->firstheaderNoContentsCB->setChecked(false);
+ dialog_->firstheaderNoContentsCB->setEnabled(false);
+ use_empty = false;
+ }
+
+ row_set = tabular.getRowOfLTFirstHead(row, ltt);
+ dialog_->firstheaderStatusCB->setChecked(row_set);
+ if (ltt.set && (!ltt.empty || !use_empty)) {
+ dialog_->firstheaderBorderAboveCB->setChecked(ltt.topDL);
+ dialog_->firstheaderBorderBelowCB->setChecked(ltt.bottomDL);
+ } else {
+ dialog_->firstheaderBorderAboveCB->setEnabled(false);
+ dialog_->firstheaderBorderBelowCB->setEnabled(false);
+ dialog_->firstheaderBorderAboveCB->setChecked(false);
+ dialog_->firstheaderBorderBelowCB->setChecked(false);
+ if (use_empty) {
+ dialog_->firstheaderNoContentsCB->setChecked(ltt.empty);
+ if (ltt.empty)
+ dialog_->firstheaderStatusCB->setEnabled(false);
+ }
+ }
+
+ row_set = tabular.getRowOfLTFoot(row, ltt);
+ dialog_->footerStatusCB->setChecked(row_set);
+ if (ltt.set) {
+ dialog_->footerBorderAboveCB->setChecked(ltt.topDL);
+ dialog_->footerBorderBelowCB->setChecked(ltt.bottomDL);
+ use_empty = true;
+ } else {
+ dialog_->footerBorderAboveCB->setChecked(false);
+ dialog_->footerBorderBelowCB->setChecked(false);
+ dialog_->footerBorderAboveCB->setEnabled(false);
+ dialog_->footerBorderBelowCB->setEnabled(false);
+ dialog_->lastfooterNoContentsCB->setChecked(false);
+ dialog_->lastfooterNoContentsCB->setEnabled(false);
+ use_empty = false;
+ }
+
+ row_set = tabular.getRowOfLTLastFoot(row, ltt);
+ dialog_->lastfooterStatusCB->setChecked(row_set);
+ if (ltt.set && (!ltt.empty || !use_empty)) {
+ dialog_->lastfooterBorderAboveCB->setChecked(ltt.topDL);
+ dialog_->lastfooterBorderBelowCB->setChecked(ltt.bottomDL);
+ } else {
+ dialog_->lastfooterBorderAboveCB->setEnabled(false);
+ dialog_->lastfooterBorderBelowCB->setEnabled(false);
+ dialog_->lastfooterBorderAboveCB->setChecked(false);
+ dialog_->lastfooterBorderBelowCB->setChecked(false);
+ if (use_empty) {
+ dialog_->lastfooterNoContentsCB->setChecked(ltt.empty);
+ if (ltt.empty)
+ dialog_->lastfooterStatusCB->setEnabled(false);
+ }
+ }
+ dialog_->newpageCB->setChecked(tabular.getLTNewPage(row));
+}
+
+
+void GuiTabular::closeGUI()
+{
+ // ugly hack to auto-apply the stuff that hasn't been
+ // yet. don't let this continue to exist ...
+
+ // Subtle here, we must /not/ apply any changes and
+ // then refer to tabular, as it will have been freed
+ // since the changes update the actual controller().tabular()
+ Tabular const & tabular(controller().tabular());
+
+ // apply the fixed width values
+ Tabular::idx_type const cell = controller().getActiveCell();
+ bool const multicol = tabular.isMultiColumn(cell);
+ string width = widgetsToLength(dialog_->widthED, dialog_->widthUnit);
+ string width2;
+
+ Length llen = tabular.getColumnPWidth(cell);
+ Length llenMulti = tabular.getMColumnPWidth(cell);
+
+ if (multicol && !llenMulti.zero())
+ width2 = llenMulti.asString();
+ else if (!multicol && !llen.zero())
+ width2 = llen.asString();
+
+ // apply the special alignment
+ docstring const sa1 = qstring_to_ucs4(dialog_->specialAlignmentED->text());
+ docstring sa2;
+
+ if (multicol)
+ sa2 = tabular.getAlignSpecial(cell, Tabular::SET_SPECIAL_MULTI);
+ else
+ sa2 = tabular.getAlignSpecial(cell, Tabular::SET_SPECIAL_COLUMN);
+
+ if (sa1 != sa2) {
+ if (multicol)
+ controller().set(Tabular::SET_SPECIAL_MULTI, to_utf8(sa1));
+ else
+ controller().set(Tabular::SET_SPECIAL_COLUMN, to_utf8(sa1));
+ }
+
+ if (width != width2) {
+ if (multicol)
+ controller().set(Tabular::SET_MPWIDTH, width);
+ else
+ controller().set(Tabular::SET_PWIDTH, width);
+ }
+
+ /* DO WE NEED THIS?
+ switch (dialog_->topspaceCO->currentIndex()) {
+ case 0:
+ controller().set(Tabular::SET_TOP_SPACE, "");
+ break;
+ case 1:
+ controller().set(Tabular::SET_TOP_SPACE, "default");
+ break;
+ case 2:
+ controller().set(Tabular::SET_TOP_SPACE,
+ widgetsToLength(dialog_->topspaceED,
+ dialog_->topspaceUnit));
+ break;
+ }
+
+ switch (dialog_->bottomspaceCO->currentIndex()) {
+ case 0:
+ controller().set(Tabular::SET_BOTTOM_SPACE, "");
+ break;
+ case 1:
+ controller().set(Tabular::SET_BOTTOM_SPACE, "default");
+ break;
+ case 2:
+ controller().set(Tabular::SET_BOTTOM_SPACE,
+ widgetsToLength(dialog_->bottomspaceED,
+ dialog_->bottomspaceUnit));
+ break;
+ }
+
+ switch (dialog_->interlinespaceCO->currentIndex()) {
+ case 0:
+ controller().set(Tabular::SET_INTERLINE_SPACE, "");
+ break;
+ case 1:
+ controller().set(Tabular::SET_INTERLINE_SPACE, "default");
+ break;
+ case 2:
+ controller().set(Tabular::SET_INTERLINE_SPACE,
+ widgetsToLength(dialog_->interlinespaceED,
+ dialog_->interlinespaceUnit));
+ break;
+ }
+*/
+}
+
+} // namespace frontend
+} // namespace lyx
+
+#include "GuiTabular_moc.cpp"
--- /dev/null
+// -*- C++ -*-
+/**
+ * \file GuiTabular.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author John Levon
+ * \author Kalle Dalheimer
+ * \author Jürgen Spitzmüller
+ * \author Herbert Voß
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#ifndef QTABULAR_H
+#define QTABULAR_H
+
+#include "GuiDialogView.h"
+
+#include "ui_TabularUi.h"
+
+#include <QDialog>
+#include <QCloseEvent>
+
+namespace lyx {
+namespace frontend {
+
+class GuiTabular;
+
+class GuiTabularDialog : public QDialog, public Ui::TabularUi {
+ Q_OBJECT
+public:
+ GuiTabularDialog(GuiTabular * form);
+
+protected Q_SLOTS:
+ virtual void change_adaptor();
+
+ virtual void topspace_changed();
+ virtual void bottomspace_changed();
+ virtual void interlinespace_changed();
+ virtual void booktabsChanged(bool);
+ virtual void close_clicked();
+ virtual void borderSet_clicked();
+ virtual void borderUnset_clicked();
+ virtual void leftBorder_changed();
+ virtual void rightBorder_changed();
+ virtual void topBorder_changed();
+ virtual void bottomBorder_changed();
+ virtual void multicolumn_clicked();
+ virtual void rotateTabular();
+ virtual void rotateCell();
+ virtual void hAlign_changed(int align);
+ virtual void vAlign_changed(int align);
+ virtual void specialAlignment_changed();
+ virtual void width_changed();
+ virtual void longTabular();
+ virtual void ltNewpage_clicked();
+ virtual void ltHeaderStatus_clicked();
+ virtual void ltHeaderBorderAbove_clicked();
+ virtual void ltHeaderBorderBelow_clicked();
+ virtual void ltFirstHeaderStatus_clicked();
+ virtual void ltFirstHeaderBorderAbove_clicked();
+ virtual void ltFirstHeaderBorderBelow_clicked();
+ virtual void ltFirstHeaderEmpty_clicked();
+ virtual void ltFooterStatus_clicked();
+ virtual void ltFooterBorderAbove_clicked();
+ virtual void ltFooterBorderBelow_clicked();
+ virtual void ltLastFooterStatus_clicked();
+ virtual void ltLastFooterBorderAbove_clicked();
+ virtual void ltLastFooterBorderBelow_clicked();
+ virtual void ltLastFooterEmpty_clicked();
+
+protected:
+ virtual void closeEvent(QCloseEvent * e);
+
+private:
+ GuiTabular * form_;
+};
+
+
+class ControlTabular;
+
+class GuiTabular :
+ public QController<ControlTabular, GuiView<GuiTabularDialog> >
+{
+public:
+ friend class GuiTabularDialog;
+
+ GuiTabular(Dialog &);
+
+protected:
+ virtual bool isValid();
+
+private:
+ /// We can't use this ...
+ virtual void apply() {}
+ /// update borders
+ virtual void update_borders();
+ /// update
+ virtual void update_contents();
+ /// build the dialog
+ virtual void build_dialog();
+ /// save some values before closing the gui
+ virtual void closeGUI();
+};
+
+} // namespace frontend
+} // namespace lyx
+
+#endif // QTABULAR_H
--- /dev/null
+/**
+ * \file GuiTabularCreate.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author John Levon
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "GuiTabularCreate.h"
+#include "Qt2BC.h"
+#include "EmptyTable.h"
+
+#include "controllers/ControlTabularCreate.h"
+
+#include <QSpinBox>
+#include <QPushButton>
+
+namespace lyx {
+namespace frontend {
+
+/////////////////////////////////////////////////////////////////////
+//
+// GuiTabularCreateDialog
+//
+/////////////////////////////////////////////////////////////////////
+
+GuiTabularCreateDialog::GuiTabularCreateDialog(GuiTabularCreate * form)
+ : form_(form)
+{
+ setupUi(this);
+
+ rowsSB->setValue(5);
+ columnsSB->setValue(5);
+
+ connect(okPB, SIGNAL(clicked()), form_, SLOT(slotOK()));
+ connect(closePB, SIGNAL(clicked()), form_, SLOT(slotClose()));
+
+ connect(rowsSB, SIGNAL(valueChanged(int)),
+ this, SLOT(rowsChanged(int)));
+ connect(columnsSB, SIGNAL(valueChanged(int)),
+ this, SLOT(columnsChanged(int)));
+}
+
+
+void GuiTabularCreateDialog::columnsChanged(int)
+{
+ form_->changed();
+}
+
+
+void GuiTabularCreateDialog::rowsChanged(int)
+{
+ form_->changed();
+}
+
+
+/////////////////////////////////////////////////////////////////////
+//
+// GuiTabularCreate
+//
+/////////////////////////////////////////////////////////////////////
+
+typedef QController<ControlTabularCreate, GuiView<GuiTabularCreateDialog> >
+ TabularCreateBase;
+
+
+GuiTabularCreate::GuiTabularCreate(Dialog & parent)
+ : TabularCreateBase(parent, _("Insert Table"))
+{
+}
+
+
+void GuiTabularCreate::build_dialog()
+{
+ dialog_.reset(new GuiTabularCreateDialog(this));
+
+ bcview().setOK(dialog_->okPB);
+ bcview().setCancel(dialog_->closePB);
+}
+
+
+void GuiTabularCreate::apply()
+{
+ controller().params().first = dialog_->rowsSB->value();
+ controller().params().second = dialog_->columnsSB->value();
+}
+
+} // namespace frontend
+} // namespace lyx
+
+#include "GuiTabularCreate_moc.cpp"
--- /dev/null
+// -*- C++ -*-
+/**
+ * \file GuiTabularCreate.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author John Levon
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#ifndef QTABULARCREATE_H
+#define QTABULARCREATE_H
+
+#include "GuiDialogView.h"
+#include "ui_TabularCreateUi.h"
+
+#include <QDialog>
+
+namespace lyx {
+namespace frontend {
+
+class GuiTabularCreate;
+
+class GuiTabularCreateDialog : public QDialog, public Ui::TabularCreateUi {
+ Q_OBJECT
+public:
+ GuiTabularCreateDialog(GuiTabularCreate * form);
+protected Q_SLOTS:
+ virtual void columnsChanged(int);
+ virtual void rowsChanged(int);
+private:
+ GuiTabularCreate * form_;
+};
+
+
+class ControlTabularCreate;
+
+class GuiTabularCreate
+ : public QController<ControlTabularCreate, GuiView<GuiTabularCreateDialog> >
+{
+public:
+ ///
+ friend class GuiTabularCreateDialog;
+ ///
+ GuiTabularCreate(Dialog &);
+private:
+ /// Apply changes
+ virtual void apply();
+ /// update
+ virtual void update_contents() {}
+ /// build the dialog
+ virtual void build_dialog();
+};
+
+} // namespace frontend
+} // namespace lyx
+
+#endif // QTABULARCREATE_H
--- /dev/null
+/**
+ * \file GuiTexinfo.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Edwin Leuven
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "GuiTexinfo.h"
+#include "Qt2BC.h"
+#include "qt_helpers.h"
+
+#include "support/filetools.h"
+
+#include <QCheckBox>
+#include <QListWidget>
+#include <QPushButton>
+
+using std::string;
+using std::vector;
+
+namespace lyx {
+namespace frontend {
+
+/////////////////////////////////////////////////////////////////////
+//
+// GuiTexinfoDialog
+//
+/////////////////////////////////////////////////////////////////////
+
+
+GuiTexinfoDialog::GuiTexinfoDialog(GuiTexinfo * form)
+ : form_(form)
+{
+ setupUi(this);
+
+ connect(closePB, SIGNAL(clicked()), form, SLOT(slotClose()));
+
+ connect(viewPB, SIGNAL(clicked()), this, SLOT(viewClicked()));
+ connect(whatStyleCO, SIGNAL(activated(const QString &)),
+ this, SLOT(enableViewPB()));
+ connect(whatStyleCO, SIGNAL(activated(int)), this, SLOT(update()));
+ connect(pathCB, SIGNAL(stateChanged(int)), this, SLOT(update()));
+ connect(rescanPB, SIGNAL(clicked()), this, SLOT(enableViewPB()));
+ connect(rescanPB, SIGNAL(clicked()), this, SLOT(rescanClicked()));
+ connect(fileListLW, SIGNAL(itemClicked(QListWidgetItem *)),
+ this, SLOT( enableViewPB() ) );
+ connect(fileListLW, SIGNAL(itemSelectionChanged()),
+ this, SLOT(enableViewPB()));
+}
+
+
+void GuiTexinfoDialog::change_adaptor()
+{
+ form_->changed();
+}
+
+
+void GuiTexinfoDialog::closeEvent(QCloseEvent * e)
+{
+ form_->slotWMHide();
+ e->accept();
+}
+
+
+void GuiTexinfoDialog::rescanClicked()
+{
+ // build new *Files.lst
+ rescanTexStyles();
+ form_->updateStyles();
+ enableViewPB();
+}
+
+
+void GuiTexinfoDialog::viewClicked()
+{
+ size_t const fitem = fileListLW->currentRow();
+ vector<string> const & data = form_->texdata_[form_->activeStyle];
+ string file = data[fitem];
+ if (!pathCB->isChecked())
+ file = getTexFileFromList(data[fitem],
+ form_->controller().getFileType(form_->activeStyle));
+ form_->controller().viewFile(file);
+}
+
+
+void GuiTexinfoDialog::update()
+{
+ switch (whatStyleCO->currentIndex()) {
+ case 0:
+ form_->updateStyles(ControlTexinfo::cls);
+ break;
+ case 1:
+ form_->updateStyles(ControlTexinfo::sty);
+ break;
+ case 2:
+ form_->updateStyles(ControlTexinfo::bst);
+ break;
+ default:
+ break;
+ }
+
+ enableViewPB();
+}
+
+
+void GuiTexinfoDialog::enableViewPB()
+{
+ viewPB->setEnabled(fileListLW->currentRow() > -1);
+}
+
+
+
+/////////////////////////////////////////////////////////////////////
+//
+// GuiTexinfo
+//
+/////////////////////////////////////////////////////////////////////
+
+typedef QController<ControlTexinfo, GuiView<GuiTexinfoDialog> >
+ texinfo_base_class;
+
+GuiTexinfo::GuiTexinfo(Dialog & parent)
+ : texinfo_base_class(parent, _("TeX Information")),
+ warningPosted(false), activeStyle(ControlTexinfo::cls)
+{
+}
+
+
+void GuiTexinfo::build_dialog()
+{
+ dialog_.reset(new GuiTexinfoDialog(this));
+
+ updateStyles(ControlTexinfo::cls);
+
+ bcview().setCancel(dialog_->closePB);
+}
+
+
+void GuiTexinfo::updateStyles(ControlTexinfo::texFileSuffix whichStyle)
+{
+ ContentsType & data = texdata_[whichStyle];
+ bool const withFullPath = dialog_->pathCB->isChecked();
+
+ getTexFileList(whichStyle, data, withFullPath);
+
+ dialog_->fileListLW->clear();
+ ContentsType::const_iterator it = data.begin();
+ ContentsType::const_iterator end = data.end();
+ for (; it != end; ++it)
+ dialog_->fileListLW->addItem(toqstr(*it));
+
+ activeStyle = whichStyle;
+}
+
+
+void GuiTexinfo::updateStyles()
+{
+ updateStyles(activeStyle);
+}
+
+} // namespace frontend
+} // namespace lyx
+
+
+#include "GuiTexinfo_moc.cpp"
--- /dev/null
+// -*- C++ -*-
+/**
+ * \file GuiTexinfo.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Edwin Leuven
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#ifndef QTEXINFO_H
+#define QTEXINFO_H
+
+#include "GuiDialogView.h"
+
+#include "ControlTexinfo.h"
+#include "ui_TexinfoUi.h"
+
+#include <QDialog>
+#include <QCloseEvent>
+
+#include <map>
+#include <vector>
+
+namespace lyx {
+namespace frontend {
+
+class GuiTexinfo;
+
+class GuiTexinfoDialog : public QDialog, public Ui::TexinfoUi {
+ Q_OBJECT
+public:
+ GuiTexinfoDialog(GuiTexinfo * form);
+public Q_SLOTS:
+ virtual void update();
+protected Q_SLOTS:
+ virtual void change_adaptor();
+ virtual void rescanClicked();
+ virtual void viewClicked();
+ virtual void enableViewPB();
+protected:
+ virtual void closeEvent(QCloseEvent * e);
+private:
+ GuiTexinfo * form_;
+};
+
+
+///
+class GuiTexinfo
+ : public QController<ControlTexinfo, GuiView<GuiTexinfoDialog> > {
+public:
+ ///
+ friend class GuiTexinfoDialog;
+ ///
+ GuiTexinfo(Dialog &);
+private:
+ /// Apply changes
+ virtual void apply() {}
+ /// update (do we need this?)
+ virtual void update_contents() {}
+ /// build the dialog
+ virtual void build_dialog();
+ ///
+ void updateStyles(ControlTexinfo::texFileSuffix);
+ ///
+ void updateStyles();
+ ///
+ bool warningPosted;
+ ///
+ ControlTexinfo::texFileSuffix activeStyle;
+ ///
+ typedef std::vector<std::string> ContentsType;
+ std::map<ControlTexinfo::texFileSuffix, ContentsType> texdata_;
+};
+
+} // namespace frontend
+} // namespace lyx
+
+#endif // QTEXINFO_H
--- /dev/null
+/**
+ * \file GuiThesaurus.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author John Levon
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "GuiThesaurus.h"
+#include "Qt2BC.h"
+#include "qt_helpers.h"
+#include "debug.h"
+
+#include "controllers/ControlThesaurus.h"
+
+#include <QHeaderView>
+#include <QLineEdit>
+#include <QPushButton>
+#include <QTreeWidget>
+#include <QTreeWidgetItem>
+
+using std::string;
+
+namespace lyx {
+namespace frontend {
+
+/////////////////////////////////////////////////////////////////////
+//
+// QTheasurusDialog
+//
+/////////////////////////////////////////////////////////////////////
+
+GuiThesaurusDialog::GuiThesaurusDialog(GuiThesaurus * form)
+ : form_(form)
+{
+ setupUi(this);
+
+ meaningsTV->setColumnCount(1);
+ meaningsTV->header()->hide();
+
+ connect(closePB, SIGNAL(clicked()),
+ form, SLOT(slotClose()));
+ connect(replaceED, SIGNAL(returnPressed()),
+ this, SLOT(replaceClicked()));
+ connect(replaceED, SIGNAL(textChanged(const QString &)),
+ this, SLOT(change_adaptor() ) );
+ connect(entryED, SIGNAL(returnPressed()),
+ this, SLOT(entryChanged()));
+ connect(replacePB, SIGNAL(clicked()),
+ this, SLOT(replaceClicked()));
+ connect(meaningsTV, SIGNAL(itemClicked(QTreeWidgetItem *, int)),
+ this, SLOT(itemClicked(QTreeWidgetItem *, int)));
+ connect(meaningsTV, SIGNAL(itemSelectionChanged()),
+ this, SLOT(selectionChanged()));
+ connect(meaningsTV, SIGNAL(itemActivated(QTreeWidgetItem *, int)),
+ this, SLOT(selectionClicked(QTreeWidgetItem *, int)));
+}
+
+
+void GuiThesaurusDialog::change_adaptor()
+{
+ form_->changed();
+}
+
+
+void GuiThesaurusDialog::closeEvent(QCloseEvent * e)
+{
+ form_->slotWMHide();
+ e->accept();
+}
+
+
+void GuiThesaurusDialog::entryChanged()
+{
+ updateLists();
+}
+
+
+void GuiThesaurusDialog::replaceClicked()
+{
+ form_->replace();
+}
+
+
+void GuiThesaurusDialog::selectionChanged()
+{
+ int const col = meaningsTV->currentColumn();
+ if (col<0 || form_->readOnly())
+ return;
+
+ replaceED->setText(meaningsTV->currentItem()->text(col));
+ replacePB->setEnabled(true);
+ form_->changed();
+}
+
+
+void GuiThesaurusDialog::itemClicked(QTreeWidgetItem * /*item*/, int /*col*/)
+{
+ selectionChanged();
+}
+
+
+void GuiThesaurusDialog::selectionClicked(QTreeWidgetItem * item, int col)
+{
+ entryED->setText(item->text(col));
+ selectionChanged();
+ updateLists();
+}
+
+
+void GuiThesaurusDialog::updateLists()
+{
+ meaningsTV->clear();
+ meaningsTV->setUpdatesEnabled(false);
+
+ Thesaurus::Meanings meanings = form_->controller().getMeanings(qstring_to_ucs4(entryED->text()));
+
+ for (Thesaurus::Meanings::const_iterator cit = meanings.begin();
+ cit != meanings.end(); ++cit) {
+ QTreeWidgetItem * i = new QTreeWidgetItem(meaningsTV);
+ i->setText(0, toqstr(cit->first));
+ meaningsTV->expandItem(i);
+ for (std::vector<docstring>::const_iterator cit2 = cit->second.begin();
+ cit2 != cit->second.end(); ++cit2) {
+ QTreeWidgetItem * i2 = new QTreeWidgetItem(i);
+ i2->setText(0, toqstr(*cit2));
+ }
+ }
+
+ meaningsTV->setUpdatesEnabled(true);
+ meaningsTV->update();
+}
+
+
+/////////////////////////////////////////////////////////////////////
+//
+// GuiThesuarus
+//
+/////////////////////////////////////////////////////////////////////
+
+typedef QController<ControlThesaurus, GuiView<GuiThesaurusDialog> > ThesaurusBase;
+
+GuiThesaurus::GuiThesaurus(Dialog & parent)
+ : ThesaurusBase(parent, _("Thesaurus"))
+{
+}
+
+
+void GuiThesaurus::build_dialog()
+{
+ dialog_.reset(new GuiThesaurusDialog(this));
+
+ bcview().setCancel(dialog_->closePB);
+ bcview().setApply(dialog_->replacePB);
+ bcview().addReadOnly(dialog_->replaceED);
+ bcview().addReadOnly(dialog_->replacePB);
+}
+
+
+void GuiThesaurus::update_contents()
+{
+ dialog_->entryED->setText(toqstr(controller().text()));
+ dialog_->replaceED->setText("");
+ dialog_->updateLists();
+}
+
+
+void GuiThesaurus::replace()
+{
+ controller().replace(qstring_to_ucs4(dialog_->replaceED->text()));
+}
+
+} // namespace frontend
+} // namespace lyx
+
+
+#include "GuiThesaurus_moc.cpp"
--- /dev/null
+// -*- C++ -*-
+/**
+ * \file GuiThesaurus.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author John Levon
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#ifndef QTHESAURUS_H
+#define QTHESAURUS_H
+
+#include "GuiDialogView.h"
+#include "ui_ThesaurusUi.h"
+
+#include <QDialog>
+#include <QCloseEvent>
+
+
+class QTreeWidgetItem;
+
+namespace lyx {
+namespace frontend {
+
+class ControlThesaurus;
+
+class GuiThesaurus;
+
+class GuiThesaurusDialog : public QDialog, public Ui::ThesaurusUi {
+ Q_OBJECT
+public:
+ GuiThesaurusDialog(GuiThesaurus * form);
+
+ void updateLists();
+protected Q_SLOTS:
+ virtual void change_adaptor();
+ virtual void entryChanged();
+ virtual void replaceClicked();
+ virtual void selectionChanged();
+ virtual void selectionClicked(QTreeWidgetItem *, int);
+ virtual void itemClicked(QTreeWidgetItem *, int);
+protected:
+ virtual void closeEvent(QCloseEvent * e);
+private:
+ GuiThesaurus * form_;
+};
+
+
+///
+class GuiThesaurus
+ : public QController<ControlThesaurus, GuiView<GuiThesaurusDialog> >
+{
+public:
+ ///
+ friend class GuiThesaurusDialog;
+ ///
+ GuiThesaurus(Dialog &);
+private:
+ /// Apply changes
+ virtual void apply() {}
+ /// update
+ virtual void update_contents();
+ /// build the dialog
+ virtual void build_dialog();
+
+ /// replace the word
+ void replace();
+};
+
+} // namespace frontend
+} // namespace lyx
+
+#endif // QTHESAURUS_H
--- /dev/null
+/**
+ * \file GuiToc.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author John Levon
+ * \author Abdelrazak Younes
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "GuiToc.h"
+
+#include "TocModel.h"
+#include "Qt2BC.h"
+#include "qt_helpers.h"
+
+#include "debug.h"
+
+#include "controllers/ControlToc.h"
+
+#include <algorithm>
+
+using std::endl;
+
+using std::pair;
+using std::vector;
+using std::string;
+
+namespace lyx {
+namespace frontend {
+
+
+GuiToc::GuiToc(Dialog & dialog, QObject * parent)
+ : QObject(parent), ControlToc(dialog)
+{
+}
+
+
+bool GuiToc::canOutline(int type) const
+{
+ if (type < 0)
+ return false;
+
+ return ControlToc::canOutline(type);
+}
+
+
+int GuiToc::getTocDepth(int type)
+{
+ if (type < 0)
+ return 0;
+ return toc_models_[type]->modelDepth();
+}
+
+
+QStandardItemModel * GuiToc::tocModel(int type)
+{
+ if (type < 0)
+ return 0;
+
+ if (toc_models_.empty()) {
+ LYXERR(Debug::GUI) << "GuiToc::tocModel(): no types available " << endl;
+ return 0;
+ }
+
+ LYXERR(Debug::GUI)
+ << "GuiToc: type " << type
+ << " toc_models_.size() " << toc_models_.size()
+ << endl;
+
+ BOOST_ASSERT(type >= 0 && type < int(toc_models_.size()));
+ return toc_models_[type];
+}
+
+
+QModelIndex const GuiToc::getCurrentIndex(int type) const
+{
+ if (type < 0)
+ return QModelIndex();
+
+ // FIXME: The TocBackend infrastructure is not ready for LOF and LOT
+ // This is because a proper ParConstIterator is not constructed in
+ // InsetCaption::addToToc()
+ if(!canOutline(type))
+ return QModelIndex();
+
+ return toc_models_[type]->modelIndex(getCurrentTocItem(type));
+}
+
+
+void GuiToc::goTo(int type, QModelIndex const & index)
+{
+ if (type < 0 || !index.isValid()
+ || index.model() != toc_models_[type]) {
+ LYXERR(Debug::GUI)
+ << "GuiToc::goTo(): QModelIndex is invalid!"
+ << endl;
+ return;
+ }
+
+ BOOST_ASSERT(type >= 0 && type < int(toc_models_.size()));
+
+ TocIterator const it = toc_models_[type]->tocIterator(index);
+
+ LYXERR(Debug::GUI) << "GuiToc::goTo " << to_utf8(it->str()) << endl;
+
+ ControlToc::goTo(*it);
+}
+
+
+bool GuiToc::initialiseParams(std::string const & data)
+{
+ if (!ControlToc::initialiseParams(data))
+ return false;
+ update();
+ modelReset();
+ return true;
+}
+
+
+void GuiToc::update()
+{
+ toc_models_.clear();
+ TocList::const_iterator it = tocs().begin();
+ TocList::const_iterator end = tocs().end();
+ for (; it != end; ++it)
+ toc_models_.push_back(new TocModel(it->second));
+}
+
+
+} // namespace frontend
+} // namespace lyx
+
+#include "GuiToc_moc.cpp"
--- /dev/null
+// -*- C++ -*-
+/**
+ * \file GuiToc.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author John Levon
+ * \author Kalle Dalheimer
+ * \author Abdelrazak Younes
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#ifndef QTOC_H
+#define QTOC_H
+
+#include "ControlToc.h"
+
+#include <QObject>
+#include <QStandardItemModel>
+#include <QStringListModel>
+
+namespace lyx {
+namespace frontend {
+
+class ControlToc;
+class TocModel;
+
+class GuiToc : public QObject, public ControlToc
+{
+ Q_OBJECT
+public:
+
+ GuiToc(Dialog &, QObject * parent = 0);
+ virtual ~GuiToc() {}
+
+ /// \c ControlToc inherited method.
+ virtual bool initialiseParams(std::string const & data);
+ ///
+ void update();
+ ///
+ bool canOutline(int type) const;
+
+ QStandardItemModel * tocModel(int type);
+ ///
+ QModelIndex const getCurrentIndex(int type) const;
+ ///
+ void goTo(int type, QModelIndex const & index);
+ ///
+ int getType();
+ ///
+ int getTocDepth(int type);
+
+Q_SIGNALS:
+ /// Signal that the internal toc_models_ has been reset.
+ void modelReset();
+
+private:
+ ///
+ std::vector<TocModel *> toc_models_;
+};
+
+} // namespace frontend
+} // namespace lyx
+
+#endif // QTOC_H
--- /dev/null
+/**
+ * \file qt4/GuiToolbar.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Lars Gullik Bjønnes
+ * \author John Levon
+ * \author Jean-Marc Lasgouttes
+ * \author Angus Leeming
+ * \author Abdelrazak Younes
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "Buffer.h"
+#include "BufferParams.h"
+#include "debug.h"
+#include "FuncRequest.h"
+#include "FuncStatus.h"
+#include "gettext.h"
+#include "LyXFunc.h"
+#include "IconPalette.h"
+
+#include "GuiView.h"
+#include "GuiCommandBuffer.h"
+#include "GuiToolbar.h"
+#include "LyXAction.h"
+#include "Action.h"
+#include "qt_helpers.h"
+#include "InsertTableWidget.h"
+#include "support/filetools.h"
+#include "support/lstrings.h"
+#include "controllers/ControlMath.h"
+#include "ToolbarBackend.h"
+
+#include <QComboBox>
+#include <QToolBar>
+#include <QToolButton>
+#include <QAction>
+#include <QPixmap>
+
+namespace lyx {
+
+using std::string;
+using std::endl;
+using support::FileName;
+using support::libFileSearch;
+using support::subst;
+
+namespace frontend {
+
+static TextClass const & textClass(LyXView const & lv)
+{
+ return lv.buffer()->params().getTextClass();
+}
+
+
+GuiLayoutBox::GuiLayoutBox(QToolBar * toolbar, GuiViewBase & owner)
+ : owner_(owner)
+{
+ combo_ = new QComboBox;
+ combo_->setSizeAdjustPolicy(QComboBox::AdjustToContents);
+ combo_->setFocusPolicy(Qt::ClickFocus);
+ combo_->setMinimumWidth(combo_->sizeHint().width());
+ combo_->setMaxVisibleItems(100);
+
+ QObject::connect(combo_, SIGNAL(activated(const QString &)),
+ this, SLOT(selected(const QString &)));
+
+ toolbar->addWidget(combo_);
+}
+
+
+void GuiLayoutBox::set(docstring const & layout)
+{
+ TextClass const & tc = textClass(owner_);
+
+ QString const & name = toqstr(translateIfPossible(tc[layout]->name()));
+
+ int i = 0;
+ for (; i < combo_->count(); ++i) {
+ if (name == combo_->itemText(i))
+ break;
+ }
+
+ if (i == combo_->count()) {
+ lyxerr << "Trying to select non existent layout type "
+ << fromqstr(name) << endl;
+ return;
+ }
+
+ combo_->setCurrentIndex(i);
+}
+
+
+void GuiLayoutBox::update()
+{
+ TextClass const & tc = textClass(owner_);
+
+ combo_->setUpdatesEnabled(false);
+
+ combo_->clear();
+
+ TextClass::const_iterator it = tc.begin();
+ TextClass::const_iterator const end = tc.end();
+ for (; it != end; ++it) {
+ // ignore obsolete entries
+ if ((*it)->obsoleted_by().empty())
+ combo_->addItem(toqstr(translateIfPossible((*it)->name())));
+ }
+
+ // needed to recalculate size hint
+ combo_->hide();
+ combo_->setMinimumWidth(combo_->sizeHint().width());
+ combo_->show();
+
+ combo_->setUpdatesEnabled(true);
+ combo_->update();
+}
+
+
+void GuiLayoutBox::clear()
+{
+ combo_->clear();
+}
+
+
+void GuiLayoutBox::open()
+{
+ combo_->showPopup();
+}
+
+
+void GuiLayoutBox::setEnabled(bool enable)
+{
+ // Workaround for Qt bug where setEnabled(true) closes
+ // the popup
+ if (enable != combo_->isEnabled())
+ combo_->setEnabled(enable);
+}
+
+
+void GuiLayoutBox::selected(const QString & str)
+{
+ owner_.setFocus();
+
+ layoutSelected(owner_, qstring_to_ucs4(str));
+}
+
+
+GuiToolbar::GuiToolbar(ToolbarInfo const & tbinfo, GuiViewBase & owner)
+ : QToolBar(qt_(tbinfo.gui_name), &owner), command_buffer_(0), owner_(owner)
+{
+ // give visual separation between adjacent toolbars
+ addSeparator();
+
+ // TODO: save toolbar position
+ setMovable(true);
+
+ ToolbarInfo::item_iterator it = tbinfo.items.begin();
+ ToolbarInfo::item_iterator end = tbinfo.items.end();
+ for (; it != end; ++it)
+ add(*it);
+}
+
+
+void GuiToolbar::focusCommandBuffer()
+{
+ if (command_buffer_)
+ command_buffer_->setFocus();
+}
+
+
+void GuiToolbar::add(ToolbarItem const & item)
+{
+ switch (item.type_) {
+ case ToolbarItem::SEPARATOR:
+ addSeparator();
+ break;
+ case ToolbarItem::LAYOUTS:
+ layout_.reset(new GuiLayoutBox(this, owner_));
+ break;
+ case ToolbarItem::MINIBUFFER:
+ command_buffer_ = new GuiCommandBuffer(&owner_);
+ addWidget(command_buffer_);
+ /// \todo find a Qt4 equivalent to setHorizontalStretchable(true);
+ //setHorizontalStretchable(true);
+ break;
+ case ToolbarItem::TABLEINSERT: {
+ QToolButton * tb = new QToolButton;
+ tb->setCheckable(true);
+ tb->setIcon(QPixmap(toqstr(getIcon(FuncRequest(LFUN_TABULAR_INSERT)))));
+ tb->setToolTip(qt_(to_ascii(item.label_)));
+ tb->setStatusTip(qt_(to_ascii(item.label_)));
+ tb->setText(qt_(to_ascii(item.label_)));
+ InsertTableWidget * iv = new InsertTableWidget(owner_, tb);
+ connect(tb, SIGNAL(clicked(bool)), iv, SLOT(show(bool)));
+ connect(iv, SIGNAL(visible(bool)), tb, SLOT(setChecked(bool)));
+ connect(this, SIGNAL(updated()), iv, SLOT(updateParent()));
+ addWidget(tb);
+ break;
+ }
+ case ToolbarItem::ICONPALETTE: {
+ QToolButton * tb = new QToolButton(this);
+ tb->setToolTip(qt_(to_ascii(item.label_)));
+ tb->setStatusTip(qt_(to_ascii(item.label_)));
+ tb->setText(qt_(to_ascii(item.label_)));
+ connect(this, SIGNAL(iconSizeChanged(const QSize &)),
+ tb, SLOT(setIconSize(const QSize &)));
+ IconPalette * panel = new IconPalette(tb);
+ panel->setWindowTitle(qt_(to_ascii(item.label_)));
+ connect(this, SIGNAL(updated()), panel, SLOT(updateParent()));
+ ToolbarInfo const * tbinfo = toolbarbackend.getDefinedToolbarInfo(item.name_);
+ if (!tbinfo) {
+ lyxerr << "Unknown toolbar " << item.name_ << endl;
+ break;
+ }
+ ToolbarInfo::item_iterator it = tbinfo->items.begin();
+ ToolbarInfo::item_iterator const end = tbinfo->items.end();
+ for (; it != end; ++it)
+ if (!getStatus(it->func_).unknown()) {
+ Action * action = new Action(owner_,
+ getIcon(it->func_),
+ it->label_,
+ it->func_,
+ it->label_);
+ panel->addButton(action);
+ ActionVector.push_back(action);
+ // use the icon of first action for the toolbar button
+ if (it == tbinfo->items.begin())
+ tb->setIcon(QPixmap(getIcon(it->func_).c_str()));
+ }
+ tb->setCheckable(true);
+ connect(tb, SIGNAL(clicked(bool)), panel, SLOT(setVisible(bool)));
+ connect(panel, SIGNAL(visible(bool)), tb, SLOT(setChecked(bool)));
+ addWidget(tb);
+ break;
+ }
+ case ToolbarItem::POPUPMENU: {
+ QToolButton * tb = new QToolButton;
+ tb->setPopupMode(QToolButton::InstantPopup);
+ tb->setToolTip(qt_(to_ascii(item.label_)));
+ tb->setStatusTip(qt_(to_ascii(item.label_)));
+ tb->setText(qt_(to_ascii(item.label_)));
+ FileName icon_path = libFileSearch("images/math", item.name_, "png");
+ tb->setIcon(QIcon(toqstr(icon_path.absFilename())));
+ connect(this, SIGNAL(iconSizeChanged(const QSize &)),
+ tb, SLOT(setIconSize(const QSize &)));
+
+ ButtonMenu * m = new ButtonMenu(qt_(to_ascii(item.label_)), tb);
+ m->setWindowTitle(qt_(to_ascii(item.label_)));
+ m->setTearOffEnabled(true);
+ connect(this, SIGNAL(updated()), m, SLOT(updateParent()));
+ ToolbarInfo const * tbinfo = toolbarbackend.getDefinedToolbarInfo(item.name_);
+ if (!tbinfo) {
+ lyxerr << "Unknown toolbar " << item.name_ << endl;
+ break;
+ }
+ ToolbarInfo::item_iterator it = tbinfo->items.begin();
+ ToolbarInfo::item_iterator const end = tbinfo->items.end();
+ for (; it != end; ++it)
+ if (!getStatus(it->func_).unknown()) {
+ Action * action = new Action(owner_,
+ getIcon(it->func_, false),
+ it->label_,
+ it->func_,
+ it->label_);
+ m->add(action);
+ ActionVector.push_back(action);
+ }
+ tb->setMenu(m);
+ addWidget(tb);
+ break;
+ }
+ case ToolbarItem::COMMAND: {
+ if (getStatus(item.func_).unknown())
+ break;
+
+ Action * action = new Action(owner_,
+ getIcon(item.func_),
+ item.label_,
+ item.func_,
+ item.label_);
+ addAction(action);
+ ActionVector.push_back(action);
+ break;
+ }
+ default:
+ break;
+ }
+}
+
+
+void GuiToolbar::hide(bool)
+{
+ QToolBar::hide();
+}
+
+
+void GuiToolbar::show(bool)
+{
+ QToolBar::show();
+}
+
+
+bool GuiToolbar::isVisible() const
+{
+ return QToolBar::isVisible();
+}
+
+
+void GuiToolbar::saveInfo(ToolbarSection::ToolbarInfo & tbinfo)
+{
+ // if tbinfo.state == auto *do not* set on/off
+ if (tbinfo.state != ToolbarSection::ToolbarInfo::AUTO) {
+ if (GuiToolbar::isVisible())
+ tbinfo.state = ToolbarSection::ToolbarInfo::ON;
+ else
+ tbinfo.state = ToolbarSection::ToolbarInfo::OFF;
+ }
+ //
+ // no need to save it here.
+ Qt::ToolBarArea loc = owner_.toolBarArea(this);
+
+ if (loc == Qt::TopToolBarArea)
+ tbinfo.location = ToolbarSection::ToolbarInfo::TOP;
+ else if (loc == Qt::BottomToolBarArea)
+ tbinfo.location = ToolbarSection::ToolbarInfo::BOTTOM;
+ else if (loc == Qt::RightToolBarArea)
+ tbinfo.location = ToolbarSection::ToolbarInfo::RIGHT;
+ else if (loc == Qt::LeftToolBarArea)
+ tbinfo.location = ToolbarSection::ToolbarInfo::LEFT;
+ else
+ tbinfo.location = ToolbarSection::ToolbarInfo::NOTSET;
+
+ // save toolbar position. They are not used to restore toolbar position
+ // now because move(x,y) does not work for toolbar.
+ tbinfo.posx = pos().x();
+ tbinfo.posy = pos().y();
+}
+
+
+void GuiToolbar::update()
+{
+ // This is a speed bottleneck because this is called on every keypress
+ // and update calls getStatus, which copies the cursor at least two times
+ for (size_t i = 0; i < ActionVector.size(); ++i)
+ ActionVector[i]->update();
+
+ // emit signal
+ updated();
+}
+
+
+string const getIcon(FuncRequest const & f, bool unknown)
+{
+ using frontend::find_png;
+
+ string fullname;
+
+ switch (f.action) {
+ case LFUN_MATH_INSERT:
+ if (!f.argument().empty())
+ fullname = find_png(to_utf8(f.argument()).substr(1));
+ break;
+ case LFUN_MATH_DELIM:
+ case LFUN_MATH_BIGDELIM:
+ fullname = find_png(to_utf8(f.argument()));
+ break;
+ default:
+ string const name = lyxaction.getActionName(f.action);
+ string png_name = name;
+
+ if (!f.argument().empty())
+ png_name = subst(name + ' ' + to_utf8(f.argument()), ' ', '_');
+
+ fullname = libFileSearch("images", png_name, "png").absFilename();
+
+ if (fullname.empty()) {
+ // try without the argument
+ fullname = libFileSearch("images", name, "png").absFilename();
+ }
+ }
+
+ if (!fullname.empty()) {
+ LYXERR(Debug::GUI) << "Full icon name is `"
+ << fullname << '\'' << endl;
+ return fullname;
+ }
+
+ LYXERR(Debug::GUI) << "Cannot find icon for command \""
+ << lyxaction.getActionName(f.action)
+ << '(' << to_utf8(f.argument()) << ")\"" << endl;
+ if (unknown)
+ return libFileSearch("images", "unknown", "png").absFilename();
+ else
+ return string();
+}
+
+
+} // namespace frontend
+} // namespace lyx
+
+#include "GuiToolbar_moc.cpp"
--- /dev/null
+// -*- C++ -*-
+/**
+ * \file GuiToolbar.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Lars Gullik Bjønnes
+ * \author John Levon
+ * \author Jean-Marc Lasgouttes
+ * \author Angus Leeming
+ * \author Abdelrazak Younes
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#ifndef QLTOOLBAR_H
+#define QLTOOLBAR_H
+
+#include "frontends/Toolbars.h"
+#include "Session.h"
+
+#include <QToolBar>
+
+#include <boost/scoped_ptr.hpp>
+
+#include <vector>
+
+class QComboBox;
+
+namespace lyx {
+
+class FuncRequest;
+
+namespace frontend {
+
+class GuiCommandBuffer;
+class GuiLayoutBox;
+class GuiViewBase;
+class Action;
+
+
+class GuiLayoutBox : public QObject, public LayoutBox {
+ Q_OBJECT
+public:
+ GuiLayoutBox(QToolBar *, GuiViewBase &);
+
+ /// select the right layout in the combox.
+ void set(docstring const & layout);
+ /// Populate the layout combox.
+ void update();
+ /// Erase the layout list.
+ void clear();
+ /// Display the layout list.
+ void open();
+ ///
+ void setEnabled(bool);
+
+private Q_SLOTS:
+ void selected(const QString & str);
+
+private:
+ QComboBox * combo_;
+ GuiViewBase & owner_;
+};
+
+
+class GuiToolbar : public QToolBar, public Toolbar {
+ Q_OBJECT
+public:
+ GuiToolbar(ToolbarInfo const &, GuiViewBase &);
+
+ //~GuiToolbar();
+
+ void add(ToolbarItem const & item);
+ void hide(bool);
+ void show(bool);
+ bool isVisible() const;
+ void saveInfo(ToolbarSection::ToolbarInfo & info);
+ void update();
+ LayoutBox * layout() const { return layout_.get(); }
+ ///
+ void focusCommandBuffer();
+
+Q_SIGNALS:
+ void updated();
+
+private:
+ GuiCommandBuffer * command_buffer_;
+
+ std::vector<Action *> ActionVector;
+ GuiViewBase & owner_;
+
+ boost::scoped_ptr<GuiLayoutBox> layout_;
+};
+
+/// return a full path of an XPM for the given action
+std::string const getIcon(FuncRequest const & f, bool unknown = true);
+
+} // namespace frontend
+} // namespace lyx
+
+#endif // NOT QLTOOLBAR_H
--- /dev/null
+/**
+ * \file GuiURLDialog.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author John Levon
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "GuiURLDialog.h"
+#include "UrlView.h"
+
+#include <QLineEdit>
+#include <QPushButton>
+#include <QCloseEvent>
+
+namespace lyx {
+namespace frontend {
+
+GuiURLDialog::GuiURLDialog(UrlView * form)
+ : form_(form)
+{
+ setupUi(this);
+
+ connect(okPB, SIGNAL(clicked()), form_, SLOT(slotOK()));
+ connect(closePB, SIGNAL(clicked()), form_, SLOT(slotClose()));
+ connect(urlED, SIGNAL(textChanged(const QString &)),
+ this, SLOT(changed_adaptor()));
+ connect(hyperlinkCB, SIGNAL(clicked()),
+ this, SLOT(changed_adaptor()));
+ connect(nameED, SIGNAL(textChanged(const QString &)),
+ this, SLOT(changed_adaptor()));
+
+ setFocusProxy(urlED);
+}
+
+
+void GuiURLDialog::changed_adaptor()
+{
+ form_->changed();
+}
+
+
+void GuiURLDialog::closeEvent(QCloseEvent * e)
+{
+ form_->slotWMHide();
+ e->accept();
+}
+
+} // namespace frontend
+} // namespace lyx
+
+#include "GuiURLDialog_moc.cpp"
--- /dev/null
+// -*- C++ -*-
+/**
+ * \file GuiURLDialog.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author John Levon
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#ifndef GUIURLDIALOG_H
+#define GUIURLDIALOG_H
+
+#include "ui_URLUi.h"
+
+#include <QDialog>
+#include <QCloseEvent>
+
+namespace lyx {
+namespace frontend {
+
+class UrlView;
+
+class GuiURLDialog : public QDialog, public Ui::URLUi {
+ Q_OBJECT
+public:
+ GuiURLDialog(UrlView * form);
+public Q_SLOTS:
+ void changed_adaptor();
+protected:
+ void closeEvent(QCloseEvent *);
+private:
+ UrlView * form_;
+};
+
+} // namespace frontend
+} // namespace lyx
+
+#endif // GUIURLDIALOG_H
--- /dev/null
+/**
+ * \file GuiVSpace.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author André Pönitz
+ * \author Jürgen Vigna
+ * \author Rob Lahaye
+ * \author Angus Leeming
+ * \author Edwin Leuven
+ * \author Jürgen Spitzmüller
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "GuiVSpace.h"
+#include "Qt2BC.h"
+
+#include "CheckedLineEdit.h"
+#include "LengthCombo.h"
+#include "qt_helpers.h"
+#include "Validator.h"
+
+#include "LyXRC.h" // to set the default length values
+#include "Spacing.h"
+#include "VSpace.h"
+
+#include "controllers/ControlVSpace.h"
+#include "controllers/frontend_helpers.h"
+
+#include "support/lstrings.h"
+
+#include <QCheckBox>
+#include <QCloseEvent>
+#include <QLineEdit>
+#include <QPushButton>
+#include <QValidator>
+
+
+using std::string;
+
+namespace lyx {
+namespace frontend {
+
+
+/////////////////////////////////////////////////////////////////////
+//
+// GuiVSpaceDialog
+//
+/////////////////////////////////////////////////////////////////////
+
+
+GuiVSpaceDialog::GuiVSpaceDialog(GuiVSpace * form)
+ : form_(form)
+{
+ setupUi(this);
+
+ connect(okPB, SIGNAL(clicked()), form_, SLOT(slotOK()));
+ connect(applyPB, SIGNAL(clicked()), form_, SLOT(slotApply()));
+ connect(closePB, SIGNAL(clicked()), form_, SLOT(slotClose()));
+
+ connect(spacingCO, SIGNAL(highlighted(const QString &)),
+ this, SLOT(change_adaptor()));
+ connect(valueLE, SIGNAL(textChanged(const QString &)),
+ this, SLOT(change_adaptor()));
+ connect(spacingCO, SIGNAL(activated(int)),
+ this, SLOT(enableCustom(int)));
+ connect(keepCB, SIGNAL(clicked()),
+ this, SLOT(change_adaptor()));
+ connect(unitCO, SIGNAL(selectionChanged(lyx::Length::UNIT)),
+ this, SLOT(change_adaptor()));
+
+ valueLE->setValidator(unsignedLengthValidator(valueLE));
+}
+
+
+void GuiVSpaceDialog::closeEvent(QCloseEvent * e)
+{
+ form_->slotWMHide();
+ e->accept();
+}
+
+
+void GuiVSpaceDialog::change_adaptor()
+{
+ form_->changed();
+}
+
+
+void GuiVSpaceDialog::enableCustom(int selection)
+{
+ bool const enable = selection == 5;
+ valueLE->setEnabled(enable);
+ unitCO->setEnabled(enable);
+}
+
+
+/////////////////////////////////////////////////////////////////////
+//
+// GuiVSpace
+//
+/////////////////////////////////////////////////////////////////////
+
+static void setWidgetsFromVSpace(VSpace const & space,
+ QComboBox * spacing,
+ QLineEdit * value,
+ LengthCombo * unit,
+ QCheckBox * keep)
+{
+ int item = 0;
+ switch (space.kind()) {
+ case VSpace::DEFSKIP:
+ item = 0;
+ break;
+ case VSpace::SMALLSKIP:
+ item = 1;
+ break;
+ case VSpace::MEDSKIP:
+ item = 2;
+ break;
+ case VSpace::BIGSKIP:
+ item = 3;
+ break;
+ case VSpace::VFILL:
+ item = 4;
+ break;
+ case VSpace::LENGTH:
+ item = 5;
+ break;
+ }
+ spacing->setCurrentIndex(item);
+ keep->setChecked(space.keep());
+
+ Length::UNIT default_unit =
+ (lyxrc.default_papersize > 3) ? Length::CM : Length::IN;
+ bool const custom_vspace = space.kind() == VSpace::LENGTH;
+ if (custom_vspace) {
+ value->setEnabled(true);
+ unit->setEnabled(true);
+ string length = space.length().asString();
+ lengthToWidgets(value, unit, length, default_unit);
+ } else {
+ lengthToWidgets(value, unit, "", default_unit);
+ value->setEnabled(false);
+ unit->setEnabled(false);
+ }
+}
+
+
+static VSpace setVSpaceFromWidgets(int spacing,
+ QLineEdit * value,
+ LengthCombo * unit,
+ bool keep)
+{
+ VSpace space;
+
+ switch (spacing) {
+ case 0:
+ space = VSpace(VSpace::DEFSKIP);
+ break;
+ case 1:
+ space = VSpace(VSpace::SMALLSKIP);
+ break;
+ case 2:
+ space = VSpace(VSpace::MEDSKIP);
+ break;
+ case 3:
+ space = VSpace(VSpace::BIGSKIP);
+ break;
+ case 4:
+ space = VSpace(VSpace::VFILL);
+ break;
+ case 5:
+ space = VSpace(GlueLength(widgetsToLength(value, unit)));
+ break;
+ }
+
+ space.setKeep(keep);
+ return space;
+}
+
+
+typedef QController<ControlVSpace, GuiView<GuiVSpaceDialog> > VSpaceBase;
+
+GuiVSpace::GuiVSpace(Dialog & parent)
+ : VSpaceBase(parent, _("Vertical Space Settings"))
+{}
+
+
+void GuiVSpace::build_dialog()
+{
+ // the tabbed folder
+ dialog_.reset(new GuiVSpaceDialog(this));
+
+ // Manage the ok, apply, restore and cancel/close buttons
+ bcview().setOK(dialog_->okPB);
+ bcview().setApply(dialog_->applyPB);
+ bcview().setCancel(dialog_->closePB);
+
+ // disable for read-only documents
+ bcview().addReadOnly(dialog_->spacingCO);
+ bcview().addReadOnly(dialog_->valueLE);
+ bcview().addReadOnly(dialog_->unitCO);
+ bcview().addReadOnly(dialog_->keepCB);
+
+ // initialize the length validator
+ addCheckedLineEdit(bcview(), dialog_->valueLE, dialog_->valueL);
+
+ // remove the %-items from the unit choice
+ dialog_->unitCO->noPercents();
+}
+
+
+void GuiVSpace::apply()
+{
+ // spacing
+ // If a vspace choice is "Length" but there's no text in
+ // the input field, do not insert a vspace at all.
+ if (dialog_->spacingCO->currentIndex() == 5
+ && dialog_->valueLE->text().isEmpty())
+ return;
+
+ VSpace const space =
+ setVSpaceFromWidgets(dialog_->spacingCO->currentIndex(),
+ dialog_->valueLE,
+ dialog_->unitCO,
+ dialog_->keepCB->isChecked());
+
+ controller().params() = space;
+}
+
+
+void GuiVSpace::update_contents()
+{
+ setWidgetsFromVSpace(controller().params(),
+ dialog_->spacingCO,
+ dialog_->valueLE,
+ dialog_->unitCO,
+ dialog_->keepCB);
+}
+
+} // namespace frontend
+} // namespace lyx
+
+
+#include "GuiVSpace_moc.cpp"
--- /dev/null
+// -*- C++ -*-
+/**
+ * \file GuiVSpace.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author André Pönitz
+ * \author Angus Leeming
+ * \author Jürgen Spitzmüller
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#ifndef QVSPACE_H
+#define QVSPACE_H
+
+#include "GuiDialogView.h"
+
+#include "ui_VSpaceUi.h"
+
+#include <QDialog>
+
+class QCloseEvent;
+
+namespace lyx {
+namespace frontend {
+
+class ControlVSpace;
+
+class GuiVSpace;
+
+
+class GuiVSpaceDialog : public QDialog, public Ui::VSpaceUi {
+ Q_OBJECT
+
+public:
+ GuiVSpaceDialog(GuiVSpace * form);
+
+public Q_SLOTS:
+ void change_adaptor();
+
+protected Q_SLOTS:
+ void closeEvent(QCloseEvent *);
+ void enableCustom(int);
+
+private:
+ GuiVSpace * form_;
+};
+
+
+
+class GuiVSpace
+ : public QController<ControlVSpace, GuiView<GuiVSpaceDialog> >
+{
+public:
+ ///
+ friend class GuiVSpaceDialog;
+ ///
+ GuiVSpace(Dialog &);
+private:
+ /// Build the dialog
+ virtual void build_dialog();
+ /// Apply from dialog
+ virtual void apply();
+ /// Update the dialog
+ virtual void update_contents();
+};
+
+} // namespace frontend
+} // namespace lyx
+
+#endif //QVSPACE_H
#include "GuiImplementation.h"
#include "GuiWorkArea.h"
-#include "QKeySymbol.h"
-#include "QLMenubar.h"
-#include "QLToolbar.h"
+#include "GuiKeySymbol.h"
+#include "GuiMenubar.h"
+#include "GuiToolbar.h"
#include "qt_helpers.h"
#include "frontends/Application.h"
int const statusbar_timer_value = 3000;
-class BackgroundWidget: public QWidget
+class BackgroundWidget : public QWidget
{
public:
BackgroundWidget(QString const & file, QString const & text)
pain.drawText(260, 270, text);
}
- void paintEvent(QPaintEvent * ev)
+ void paintEvent(QPaintEvent *)
{
if (!splash_)
return;
};
-class TabWidget: public QTabWidget {
+class TabWidget : public QTabWidget {
public:
void showBar(bool show) { tabBar()->setVisible(show); }
};
} // namespace anon
-struct GuiView::GuiViewPrivate
+struct GuiViewBase::GuiViewPrivate
{
string cur_title;
QStackedWidget * stack_widget_;
BackgroundWidget * bg_widget_;
/// view's menubar
- QLMenubar * menubar_;
+ GuiMenubar * menubar_;
- GuiViewPrivate() : posx_offset(0), posy_offset(0)
- {}
+ GuiViewPrivate() : posx_offset(0), posy_offset(0) {}
unsigned int smallIconSize;
unsigned int normalIconSize;
// static needed by "New Window"
static unsigned int lastIconSize;
- QMenu* toolBarPopup(GuiView *parent)
+ QMenu * toolBarPopup(GuiViewBase * parent)
{
// FIXME: translation
- QMenu* menu = new QMenu(parent);
- QActionGroup *iconSizeGroup = new QActionGroup(parent);
+ QMenu * menu = new QMenu(parent);
+ QActionGroup * iconSizeGroup = new QActionGroup(parent);
- QAction *smallIcons = new QAction(iconSizeGroup);
+ QAction * smallIcons = new QAction(iconSizeGroup);
smallIcons->setText(qt_("Small-sized icons"));
smallIcons->setCheckable(true);
QObject::connect(smallIcons, SIGNAL(triggered()), parent, SLOT(smallSizedIcons()));
menu->addAction(smallIcons);
- QAction *normalIcons = new QAction(iconSizeGroup);
+ QAction * normalIcons = new QAction(iconSizeGroup);
normalIcons->setText(qt_("Normal-sized icons"));
normalIcons->setCheckable(true);
QObject::connect(normalIcons, SIGNAL(triggered()), parent, SLOT(normalSizedIcons()));
menu->addAction(normalIcons);
- QAction *bigIcons = new QAction(iconSizeGroup);
+ QAction * bigIcons = new QAction(iconSizeGroup);
bigIcons->setText(qt_("Big-sized icons"));
bigIcons->setCheckable(true);
QObject::connect(bigIcons, SIGNAL(triggered()), parent, SLOT(bigSizedIcons()));
};
-unsigned int GuiView::GuiViewPrivate::lastIconSize = 0;
+unsigned int GuiViewBase::GuiViewPrivate::lastIconSize = 0;
-GuiView::GuiView(int id)
+GuiViewBase::GuiViewBase(int id)
: QMainWindow(), LyXView(id), quitting_by_menu_(false),
d(*new GuiViewPrivate)
{
}
-GuiView::~GuiView()
+GuiViewBase::~GuiViewBase()
{
delete d.menubar_;
delete &d;
}
-void GuiView::close()
+void GuiViewBase::close()
{
quitting_by_menu_ = true;
QMainWindow::close();
}
-void GuiView::setFocus()
+void GuiViewBase::setFocus()
{
if (d.tab_widget_->count())
d.tab_widget_->currentWidget()->setFocus();
}
-QMenu* GuiView::createPopupMenu()
+QMenu* GuiViewBase::createPopupMenu()
{
return d.toolBarPopup(this);
}
-void GuiView::init()
+void GuiViewBase::init()
{
- d.menubar_ = new QLMenubar(this, menubackend);
+ d.menubar_ = new GuiMenubar(this, menubackend);
toolbars_->init();
}
-void GuiView::closeEvent(QCloseEvent * close_event)
+void GuiViewBase::closeEvent(QCloseEvent * close_event)
{
// we may have been called through the close window button
// which bypasses the LFUN machinery.
}
-void GuiView::dragEnterEvent(QDragEnterEvent * event)
+void GuiViewBase::dragEnterEvent(QDragEnterEvent * event)
{
if (event->mimeData()->hasUrls())
event->accept();
}
-void GuiView::dropEvent(QDropEvent* event)
+void GuiViewBase::dropEvent(QDropEvent* event)
{
QList<QUrl> files = event->mimeData()->urls();
if (files.isEmpty())
LYXERR(Debug::GUI) << BOOST_CURRENT_FUNCTION
<< " got URLs!" << endl;
- for (int i = 0; i!=files.size(); ++i) {
+ for (int i = 0; i != files.size(); ++i) {
string const file = support::os::internal_path(fromqstr(
files.at(i).toLocalFile()));
if (!file.empty())
}
-void GuiView::saveGeometry()
+void GuiViewBase::saveGeometry()
{
static bool done = false;
if (done)
// http://www.trolltech.com/developer/task-tracker/index_html?id=119684+&method=entry
// Then also the moveEvent, resizeEvent, and the
// code for floatingGeometry_ can be removed;
- // adjust GuiView::setGeometry()
+ // adjust GuiViewBase::setGeometry()
QRect normal_geometry;
int maximized;
}
-void GuiView::setGeometry(unsigned int width,
+void GuiViewBase::setGeometry(unsigned int width,
unsigned int height,
int posx, int posy,
int maximized,
}
-void GuiView::setWindowTitle(docstring const & t, docstring const & it)
+void GuiViewBase::setWindowTitle(docstring const & t, docstring const & it)
{
QString title = windowTitle();
QString new_title = toqstr(t);
}
-void GuiView::message(docstring const & str)
+void GuiViewBase::message(docstring const & str)
{
statusBar()->showMessage(toqstr(str));
statusbar_timer_.stop();
}
-void GuiView::clearMessage()
+void GuiViewBase::clearMessage()
{
update_view_state_qt();
}
-void GuiView::setIconSize(unsigned int size)
+void GuiViewBase::setIconSize(unsigned int size)
{
d.lastIconSize = size;
QMainWindow::setIconSize(QSize(size, size));
}
-void GuiView::smallSizedIcons()
+void GuiViewBase::smallSizedIcons()
{
setIconSize(d.smallIconSize);
}
-void GuiView::normalSizedIcons()
+void GuiViewBase::normalSizedIcons()
{
setIconSize(d.normalIconSize);
}
-void GuiView::bigSizedIcons()
+void GuiViewBase::bigSizedIcons()
{
setIconSize(d.bigIconSize);
}
-void GuiView::update_view_state_qt()
+void GuiViewBase::update_view_state_qt()
{
if (!hasFocus())
return;
}
-void GuiView::closeCurrentTab()
+void GuiViewBase::closeCurrentTab()
{
dispatch(FuncRequest(LFUN_BUFFER_CLOSE));
}
-void GuiView::currentTabChanged(int i)
+void GuiViewBase::currentTabChanged(int i)
{
disconnectBuffer();
disconnectBufferView();
}
-void GuiView::updateStatusBar()
+void GuiViewBase::updateStatusBar()
{
// let the user see the explicit message
if (statusbar_timer_.isActive())
}
-void GuiView::activated(FuncRequest const & func)
+void GuiViewBase::activated(FuncRequest const & func)
{
dispatch(func);
}
-bool GuiView::hasFocus() const
+bool GuiViewBase::hasFocus() const
{
return qApp->activeWindow() == this;
}
-QRect GuiView::updateFloatingGeometry()
+QRect GuiViewBase::updateFloatingGeometry()
{
QDesktopWidget& dw = *qApp->desktop();
QRect desk = dw.availableGeometry(dw.primaryScreen());
}
-void GuiView::resizeEvent(QResizeEvent *)
+void GuiViewBase::resizeEvent(QResizeEvent *)
{
updateFloatingGeometry();
}
-void GuiView::moveEvent(QMoveEvent *)
+void GuiViewBase::moveEvent(QMoveEvent *)
{
updateFloatingGeometry();
}
-bool GuiView::event(QEvent * e)
+bool GuiViewBase::event(QEvent * e)
{
switch (e->type())
{
QKeyEvent * ke = static_cast<QKeyEvent*>(e);
if (d.tab_widget_->count() == 0) {
theLyXFunc().setLyXView(this);
- boost::shared_ptr<QKeySymbol> sym(new QKeySymbol);
+ boost::shared_ptr<GuiKeySymbol> sym(new GuiKeySymbol);
sym->set(ke);
theLyXFunc().processKeySym(sym, q_key_state(ke->modifiers()));
e->accept();
return true;
}
if (ke->key() == Qt::Key_Tab || ke->key() == Qt::Key_Backtab) {
- boost::shared_ptr<QKeySymbol> sym(new QKeySymbol);
+ boost::shared_ptr<GuiKeySymbol> sym(new GuiKeySymbol);
sym->set(ke);
currentWorkArea()->processKeySym(sym, key_modifier::none);
e->accept();
}
-bool GuiView::focusNextPrevChild(bool /*next*/)
+bool GuiViewBase::focusNextPrevChild(bool /*next*/)
{
setFocus();
return true;
}
-void GuiView::show()
+void GuiViewBase::show()
{
QMainWindow::setWindowTitle(qt_("LyX"));
QMainWindow::show();
}
-void GuiView::busy(bool yes)
+void GuiViewBase::busy(bool yes)
{
if (d.tab_widget_->count()) {
GuiWorkArea * wa = dynamic_cast<GuiWorkArea *>(d.tab_widget_->currentWidget());
}
-Toolbars::ToolbarPtr GuiView::makeToolbar(ToolbarInfo const & tbinfo, bool newline)
+Toolbars::ToolbarPtr GuiViewBase::makeToolbar(ToolbarInfo const & tbinfo, bool newline)
{
- QLToolbar * Tb = new QLToolbar(tbinfo, *this);
+ GuiToolbar * toolBar = new GuiToolbar(tbinfo, *this);
if (tbinfo.flags & ToolbarInfo::TOP) {
if (newline)
addToolBarBreak(Qt::TopToolBarArea);
- addToolBar(Qt::TopToolBarArea, Tb);
+ addToolBar(Qt::TopToolBarArea, toolBar);
}
if (tbinfo.flags & ToolbarInfo::BOTTOM) {
if (newline)
addToolBarBreak(Qt::BottomToolBarArea);
#endif
- addToolBar(Qt::BottomToolBarArea, Tb);
+ addToolBar(Qt::BottomToolBarArea, toolBar);
}
if (tbinfo.flags & ToolbarInfo::LEFT) {
if (newline)
addToolBarBreak(Qt::LeftToolBarArea);
#endif
- addToolBar(Qt::LeftToolBarArea, Tb);
+ addToolBar(Qt::LeftToolBarArea, toolBar);
}
if (tbinfo.flags & ToolbarInfo::RIGHT) {
if (newline)
addToolBarBreak(Qt::RightToolBarArea);
#endif
- addToolBar(Qt::RightToolBarArea, Tb);
+ addToolBar(Qt::RightToolBarArea, toolBar);
}
// The following does not work so I cannot restore to exact toolbar location
/*
ToolbarSection::ToolbarInfo & tbinfo = LyX::ref().session().toolbars().load(tbinfo.name);
- Tb->move(tbinfo.posx, tbinfo.posy);
+ toolBar->move(tbinfo.posx, tbinfo.posy);
*/
- return Toolbars::ToolbarPtr(Tb);
+ return Toolbars::ToolbarPtr(toolBar);
}
-WorkArea * GuiView::workArea(Buffer & buffer)
+WorkArea * GuiViewBase::workArea(Buffer & buffer)
{
for (int i = 0; i != d.tab_widget_->count(); ++i) {
GuiWorkArea * wa = dynamic_cast<GuiWorkArea *>(d.tab_widget_->widget(i));
}
-WorkArea * GuiView::addWorkArea(Buffer & buffer)
+WorkArea * GuiViewBase::addWorkArea(Buffer & buffer)
{
GuiWorkArea * wa = new GuiWorkArea(buffer, *this);
wa->setUpdatesEnabled(false);
}
-WorkArea * GuiView::currentWorkArea()
+WorkArea * GuiViewBase::currentWorkArea()
{
if (d.tab_widget_->count() == 0)
return 0;
}
-WorkArea const * GuiView::currentWorkArea() const
+WorkArea const * GuiViewBase::currentWorkArea() const
{
if (d.tab_widget_->count() == 0)
return 0;
}
-void GuiView::setCurrentWorkArea(WorkArea * work_area)
+void GuiViewBase::setCurrentWorkArea(WorkArea * work_area)
{
BOOST_ASSERT(work_area);
}
-void GuiView::removeWorkArea(WorkArea * work_area)
+void GuiViewBase::removeWorkArea(WorkArea * work_area)
{
BOOST_ASSERT(work_area);
if (work_area == currentWorkArea()) {
}
-void GuiView::showMiniBuffer(bool visible)
+void GuiViewBase::showMiniBuffer(bool visible)
{
Toolbar * t = toolbars_->display("minibuffer", visible);
if (t)
}
-void GuiView::openMenu(docstring const & name)
+void GuiViewBase::openMenu(docstring const & name)
{
d.menubar_->openByName(name);
}
*
* qt4-private implementation of the main LyX window.
*
- * Note: any QObject emits a destroyed(QObject *) Qt signal when it
- * is deleted.This might be useful for closing other dialogs
- * depending on a given GuiView.
+ * Note: a QObject emits a destroyed(QObject *) Qt signal when it
+ * is deleted. This might be useful for closing other dialogs
+ * depending on a given GuiView.
*/
-class GuiView : public QMainWindow, public LyXView {
+class GuiViewBase : public QMainWindow, public LyXView {
Q_OBJECT
public:
/// create a main window of the given dimensions
- GuiView(int id);
+ GuiViewBase(int id);
- ~GuiView();
+ ~GuiViewBase();
virtual void init();
virtual void close();
--- /dev/null
+/**
+ * \file GuiViewSource.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author John Levon
+ * \author Bo Peng
+ * \author Abdelrazak Younes
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "GuiViewSource.h"
+#include "qt_helpers.h"
+
+#include <boost/tuple/tuple.hpp>
+
+#include <QTextCursor>
+#include <QTextDocument>
+
+namespace lyx {
+namespace frontend {
+
+/////////////////////////////////////////////////////////////////////
+//
+// GuiViewSourceDialog
+//
+/////////////////////////////////////////////////////////////////////
+
+GuiViewSourceDialog::GuiViewSourceDialog(GuiViewSource * form)
+ : form_(form)
+{
+ setupUi(this);
+
+ connect(viewFullSourceCB, SIGNAL(clicked()),
+ this, SLOT(update()));
+ connect(autoUpdateCB, SIGNAL(toggled(bool)),
+ updatePB, SLOT(setDisabled(bool)));
+ connect(updatePB, SIGNAL(clicked()),
+ this, SLOT(update()));
+
+ // setting a document at this point trigger an assertion in Qt
+ // so we disable the signals here:
+ form_->document()->blockSignals(true);
+ viewSourceTV->setDocument(form_->document());
+ form_->document()->blockSignals(false);
+ viewSourceTV->setReadOnly(true);
+ ///dialog_->viewSourceTV->setAcceptRichText(false);
+ // this is personal. I think source code should be in fixed-size font
+ QFont font(toqstr(theApp()->typewriterFontName()));
+ font.setKerning(false);
+ font.setFixedPitch(true);
+ font.setStyleHint(QFont::TypeWriter);
+ viewSourceTV->setFont(font);
+ // again, personal taste
+ viewSourceTV->setWordWrapMode(QTextOption::NoWrap);
+}
+
+
+void GuiViewSourceDialog::update()
+{
+ if (autoUpdateCB->isChecked())
+ form_->update(viewFullSourceCB->isChecked());
+
+ int beg, end;
+ boost::tie(beg, end) = form_->getRows();
+ QTextCursor c = QTextCursor(viewSourceTV->document());
+ c.movePosition(QTextCursor::NextBlock, QTextCursor::MoveAnchor, beg);
+ c.select(QTextCursor::BlockUnderCursor);
+ c.movePosition(QTextCursor::NextBlock, QTextCursor::KeepAnchor, end - beg + 1);
+ viewSourceTV->setTextCursor(c);
+ QWidget::update();
+}
+
+
+/////////////////////////////////////////////////////////////////////
+//
+// LaTeXHighlighter
+//
+/////////////////////////////////////////////////////////////////////
+
+
+LaTeXHighlighter::LaTeXHighlighter(QTextDocument * parent)
+ : QSyntaxHighlighter(parent)
+{
+ keywordFormat.setForeground(Qt::darkBlue);
+ keywordFormat.setFontWeight(QFont::Bold);
+ commentFormat.setForeground(Qt::darkGray);
+ mathFormat.setForeground(Qt::red);
+}
+
+
+void LaTeXHighlighter::highlightBlock(QString const & text)
+{
+ // $ $
+ QRegExp exprMath("\\$[^\\$]*\\$");
+ int index = text.indexOf(exprMath);
+ while (index >= 0) {
+ int length = exprMath.matchedLength();
+ setFormat(index, length, mathFormat);
+ index = text.indexOf(exprMath, index + length);
+ }
+ // [ ]
+ QRegExp exprStartDispMath("(\\\\\\[|"
+ "\\\\begin\\{equation\\**\\}|"
+ "\\\\begin\\{eqnarray\\**\\}|"
+ "\\\\begin\\{align(ed|at)*\\**\\}|"
+ "\\\\begin\\{flalign\\**\\}|"
+ "\\\\begin\\{gather\\**\\}|"
+ "\\\\begin\\{multline\\**\\}|"
+ "\\\\begin\\{array\\**\\}|"
+ "\\\\begin\\{cases\\**\\}"
+ ")");
+ QRegExp exprEndDispMath("(\\\\\\]|"
+ "\\\\end\\{equation\\**\\}|"
+ "\\\\end\\{eqnarray\\**\\}|"
+ "\\\\end\\{align(ed|at)*\\**\\}|"
+ "\\\\end\\{flalign\\**\\}|"
+ "\\\\end\\{gather\\**\\}|"
+ "\\\\end\\{multline\\**\\}|"
+ "\\\\end\\{array\\**\\}|"
+ "\\\\end\\{cases\\**\\}"
+ ")");
+ int startIndex = 0;
+ // if previous block was in 'disp math'
+ // start search from 0 (for end disp math)
+ // otherwise, start search from 'begin disp math'
+ if (previousBlockState() != 1)
+ startIndex = text.indexOf(exprStartDispMath);
+ while (startIndex >= 0) {
+ int endIndex = text.indexOf(exprEndDispMath, startIndex);
+ int length;
+ if (endIndex == -1) {
+ setCurrentBlockState(1);
+ length = text.length() - startIndex;
+ } else {
+ length = endIndex - startIndex + exprEndDispMath.matchedLength();
+ }
+ setFormat(startIndex, length, mathFormat);
+ startIndex = text.indexOf(exprStartDispMath, startIndex + length);
+ }
+ // \whatever
+ QRegExp exprKeyword("\\\\[A-Za-z]+");
+ index = text.indexOf(exprKeyword);
+ while (index >= 0) {
+ int length = exprKeyword.matchedLength();
+ setFormat(index, length, keywordFormat);
+ index = text.indexOf(exprKeyword, index + length);
+ }
+ // comment
+ QRegExp exprComment("(^|[^\\\\])%.*$");
+ index = text.indexOf(exprComment);
+ while (index >= 0) {
+ int const length = exprComment.matchedLength();
+ setFormat(index, length, commentFormat);
+ index = text.indexOf(exprComment, index + length);
+ }
+}
+
+
+GuiViewSource::GuiViewSource(Dialog & parent)
+ : ControlViewSource(parent)
+{
+ document_ = new QTextDocument(this);
+ highlighter_ = new LaTeXHighlighter(document_);
+}
+
+
+/////////////////////////////////////////////////////////////////////
+//
+// GuiViewSource
+//
+/////////////////////////////////////////////////////////////////////
+
+void GuiViewSource::update(bool full_source)
+{
+ document_->setPlainText(toqstr(updateContent(full_source)));
+}
+
+
+} // namespace frontend
+} // namespace lyx
+
+#include "GuiViewSource_moc.cpp"
--- /dev/null
+// -*- C++ -*-
+/**
+ * \file GuiViewSource.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author John Levon
+ * \author Bo Peng
+ * \author Abdelrazak Younes
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#ifndef QVIEWSOURCE_H
+#define QVIEWSOURCE_H
+
+#include "frontends/controllers/ControlViewSource.h"
+#include "frontends/Application.h"
+#include "ui_ViewSourceUi.h"
+
+#include <QWidget>
+#include <QSyntaxHighlighter>
+#include <QTextCharFormat>
+
+class QTextDocument;
+
+namespace lyx {
+namespace frontend {
+
+// used already twice...
+class LaTeXHighlighter : public QSyntaxHighlighter
+{
+public:
+ LaTeXHighlighter(QTextDocument * parent);
+
+protected:
+ void highlightBlock(QString const & text);
+
+private:
+ QTextCharFormat commentFormat;
+ QTextCharFormat keywordFormat;
+ QTextCharFormat mathFormat;
+};
+
+
+
+class GuiViewSource;
+
+class GuiViewSourceDialog : public QWidget, public Ui::ViewSourceUi {
+ Q_OBJECT
+public:
+ GuiViewSourceDialog(GuiViewSource * form);
+
+public Q_SLOTS:
+ // update content
+ void update();
+
+private:
+ GuiViewSource * form_;
+};
+
+
+///
+class GuiViewSource : public QObject, public ControlViewSource {
+public:
+ ///
+ GuiViewSource(Dialog &);
+ ///
+ QTextDocument * document() { return document_; }
+ ///
+ void update(bool full_source);
+
+private:
+ ///
+ QTextDocument * document_;
+ /// LaTeX syntax highlighter
+ LaTeXHighlighter * highlighter_;
+};
+
+
+} // namespace frontend
+} // namespace lyx
+
+#endif // QVIEWSOURCE_H
#include "GuiWorkArea.h"
#include "GuiApplication.h"
-#include "QLPainter.h"
-#include "QKeySymbol.h"
+#include "GuiPainter.h"
+#include "GuiKeySymbol.h"
#include "qt_helpers.h"
#include "frontends/LyXView.h"
<< " key=" << e->key()
<< endl;
- boost::shared_ptr<QKeySymbol> sym(new QKeySymbol);
+ boost::shared_ptr<GuiKeySymbol> sym(new GuiKeySymbol);
sym->set(e);
processKeySym(sym, q_key_state(e->modifiers()));
}
-void GuiWorkArea::doubleClickTimeout() {
+
+void GuiWorkArea::doubleClickTimeout()
+{
dc_event_.active = false;
}
+
void GuiWorkArea::mouseDoubleClickEvent(QMouseEvent * e)
{
dc_event_ = double_click(e);
--- /dev/null
+/**
+ * \file GuiWrap.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Jürgen Spitzmüller
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "GuiWrap.h"
+#include "Qt2BC.h"
+
+#include "LengthCombo.h"
+#include "qt_helpers.h"
+
+#include "controllers/ControlWrap.h"
+
+#include "insets/InsetWrap.h"
+
+#include "support/convert.h"
+#include "support/lstrings.h"
+
+#include <QLineEdit>
+#include <QCloseEvent>
+#include <QPushButton>
+
+
+using std::string;
+
+namespace lyx {
+namespace frontend {
+
+/////////////////////////////////////////////////////////////////////
+//
+// GuiWrapDialog
+//
+/////////////////////////////////////////////////////////////////////
+
+
+GuiWrapDialog::GuiWrapDialog(GuiWrap * form)
+ : form_(form)
+{
+ setupUi(this);
+
+ connect(restorePB, SIGNAL(clicked()), form, SLOT(slotRestore()));
+ connect(okPB, SIGNAL(clicked()), form, SLOT(slotOK()));
+ connect(applyPB, SIGNAL(clicked()), form, SLOT(slotApply()));
+ connect(closePB, SIGNAL(clicked()), form, SLOT(slotClose()));
+
+ connect(widthED, SIGNAL(textChanged(const QString &)),
+ this, SLOT(change_adaptor()));
+ connect(unitsLC, SIGNAL(selectionChanged(lyx::Length::UNIT)),
+ this, SLOT(change_adaptor()));
+ connect(valignCO, SIGNAL(highlighted(const QString &)),
+ this, SLOT(change_adaptor()));
+}
+
+
+void GuiWrapDialog::closeEvent(QCloseEvent * e)
+{
+ form_->slotWMHide();
+ e->accept();
+}
+
+
+void GuiWrapDialog::change_adaptor()
+{
+ form_->changed();
+}
+
+/////////////////////////////////////////////////////////////////////
+//
+// GuiWrap
+//
+/////////////////////////////////////////////////////////////////////
+
+typedef QController<ControlWrap, GuiView<GuiWrapDialog> > wrap_base_class;
+
+GuiWrap::GuiWrap(Dialog & parent)
+ : wrap_base_class(parent, _("Text Wrap Settings"))
+{
+}
+
+
+void GuiWrap::build_dialog()
+{
+ dialog_.reset(new GuiWrapDialog(this));
+
+ bcview().setRestore(dialog_->restorePB);
+ bcview().setOK(dialog_->okPB);
+ bcview().setApply(dialog_->applyPB);
+ bcview().setCancel(dialog_->closePB);
+
+ bcview().addReadOnly(dialog_->widthED);
+ bcview().addReadOnly(dialog_->unitsLC);
+ bcview().addReadOnly(dialog_->valignCO);
+}
+
+
+void GuiWrap::apply()
+{
+ double const value = convert<double>(fromqstr(dialog_->widthED->text()));
+ Length::UNIT unit = dialog_->unitsLC->currentLengthItem();
+ if (dialog_->widthED->text().isEmpty())
+ unit = Length::UNIT_NONE;
+
+ InsetWrapParams & params = controller().params();
+
+ params.width = Length(value, unit);
+
+ switch (dialog_->valignCO->currentIndex()) {
+ case 0:
+ params.placement.erase();
+ break;
+ case 1:
+ params.placement = "l";
+ break;
+ case 2:
+ params.placement = "r";
+ break;
+ case 3:
+ params.placement = "p";
+ break;
+ }
+}
+
+
+static string const numtostr(double val)
+{
+ string a = convert<string>(val);
+ // FIXME: Will this test ever trigger? (Lgb)
+ if (a == "0")
+ a.erase();
+ return a;
+}
+
+
+void GuiWrap::update_contents()
+{
+ InsetWrapParams & params = controller().params();
+
+ Length len(params.width);
+ dialog_->widthED->setText(toqstr(numtostr(len.value())));
+ dialog_->unitsLC->setCurrentItem(len.unit());
+
+ int item = 0;
+ if (params.placement == "l")
+ item = 1;
+ else if (params.placement == "r")
+ item = 2;
+ else if (params.placement == "p")
+ item = 3;
+
+ dialog_->valignCO->setCurrentIndex(item);
+}
+
+} // namespace frontend
+} // namespace lyx
+
+
+#include "GuiWrap_moc.cpp"
--- /dev/null
+// -*- C++ -*-
+/**
+ * \file GuiWrap.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Jürgen Spitzmüller
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#ifndef QWRAP_H
+#define QWRAP_H
+
+#include "GuiDialogView.h"
+#include "ui_WrapUi.h"
+
+#include <QDialog>
+#include <QCloseEvent>
+
+namespace lyx {
+namespace frontend {
+
+class GuiWrap;
+
+class GuiWrapDialog : public QDialog, public Ui::WrapUi {
+ Q_OBJECT
+public:
+ GuiWrapDialog(GuiWrap * form);
+protected Q_SLOTS:
+ virtual void change_adaptor();
+protected:
+ virtual void closeEvent(QCloseEvent * e);
+private:
+ GuiWrap * form_;
+};
+
+
+class ControlWrap;
+
+class GuiWrap : public QController<ControlWrap, GuiView<GuiWrapDialog> > {
+public:
+ friend class GuiWrapDialog;
+
+ GuiWrap(Dialog &);
+private:
+ /// Apply changes
+ virtual void apply();
+ /// update
+ virtual void update_contents();
+ /// build the dialog
+ virtual void build_dialog();
+};
+
+} // namespace frontend
+} // namespace lyx
+
+#endif // QWRAP_H
+++ /dev/null
-/**
- * \file qt4/KeySymbolFactory.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Asger & Jürgen
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "frontends/KeySymbol.h"
-
-#include "QKeySymbol.h"
-
-namespace lyx {
-
-KeySymbol * createKeySymbol()
-{
- return new QKeySymbol;
-}
-
-} // namespace lyx
-I$(top_srcdir)/src/frontends/controllers
SOURCEFILES = \
+ Action.cpp \
alert_pimpl.cpp \
+ BulletsModule.cpp \
CheckedLineEdit.cpp \
+ ColorCache.cpp \
Dialogs.cpp \
+ EmptyTable.cpp \
FileDialog.cpp \
+ FloatPlacement.cpp \
+ GuiAbout.cpp \
+ GuiApplication.cpp \
+ GuiBibitem.cpp \
+ GuiBibtex.cpp \
+ GuiBox.cpp \
+ GuiBranch.cpp \
+ GuiBranches.cpp \
+ GuiChanges.cpp \
+ GuiCharacter.cpp \
+ GuiCitation.cpp \
+ GuiCitationDialog.cpp \
GuiClipboard.cpp \
+ GuiCommandBuffer.cpp \
+ GuiCommandEdit.cpp \
+ GuiDelimiterDialog.cpp \
+ GuiDialogView.cpp \
+ GuiDocument.cpp \
+ GuiErrorList.cpp \
+ GuiERT.cpp \
+ GuiExternal.cpp \
+ GuiFloat.cpp \
+ GuiFloatDialog.cpp \
+ GuiFontExample.cpp \
GuiFontLoader.cpp \
GuiFontMetrics.cpp \
- GuiSelection.cpp \
- KeySymbol.cpp \
- QCitation.cpp \
- QFloat.cpp \
- QFontExample.cpp \
- QLImage.cpp \
- QLPainter.cpp \
- QPrint.cpp \
- Qt2BC.cpp \
- qt_helpers.cpp \
- UrlView.cpp \
- Action.cpp \
- BulletsModule.cpp \
- ColorCache.cpp \
- EmptyTable.cpp \
- FloatPlacement.cpp \
- GuiApplication.cpp \
+ GuiGraphics.cpp \
+ GuiGraphicsDialog.cpp \
+ GuiImage.cpp \
GuiImplementation.cpp \
+ GuiInclude.cpp \
+ GuiIndex.cpp \
+ GuiKeySymbol.cpp \
+ GuiKeySymbol.cpp \
+ GuiListings.cpp \
+ GuiLog.cpp \
+ GuiMathMatrixDialog.cpp \
+ GuiMenubar.cpp \
+ GuiNomencl.cpp \
+ GuiNote.cpp \
+ GuiPainter.cpp \
+ GuiParagraph.cpp \
+ GuiPopupMenu.cpp \
+ GuiPrefs.cpp \
+ GuiPrint.cpp \
+ GuiPrintDialog.cpp \
+ GuiRef.cpp \
+ GuiSearch.cpp \
+ GuiSelection.cpp \
+ GuiSelectionManager.cpp \
+ GuiSendto.cpp \
+ GuiSetBorder.cpp \
+ GuiShowFile.cpp \
+ GuiSpellchecker.cpp \
+ GuiTabular.cpp \
+ GuiTabularCreate.cpp \
+ GuiTexinfo.cpp \
+ GuiThesaurus.cpp \
+ GuiToc.cpp \
+ GuiToolbar.cpp \
+ GuiURLDialog.cpp \
GuiView.cpp \
+ GuiViewSource.cpp \
+ GuiVSpace.cpp \
GuiWorkArea.cpp \
+ GuiWrap.cpp \
IconPalette.cpp \
InsertTableWidget.cpp \
LengthCombo.cpp \
LyXFileDialog.cpp \
PanelStack.cpp \
- QAbout.cpp \
- QBibitem.cpp \
- QBibtex.cpp \
- QBox.cpp \
- QBranch.cpp \
- QBranches.cpp \
- QChanges.cpp \
- QCharacter.cpp \
- QCitationDialog.cpp \
- QCommandBuffer.cpp \
- QCommandEdit.cpp \
- QDelimiterDialog.cpp \
- QDialogView.cpp \
- QDocument.cpp \
- QErrorList.cpp \
- QERT.cpp \
- QExternal.cpp \
- QFloatDialog.cpp \
- QGraphics.cpp \
- QGraphicsDialog.cpp \
- QInclude.cpp \
- QIndex.cpp \
- QKeySymbol.cpp \
- QListings.cpp \
- QLMenubar.cpp \
- QLog.cpp \
- QLPopupMenu.cpp \
- QLPrintDialog.cpp \
- QLToolbar.cpp \
- QMathMatrixDialog.cpp \
- QNomencl.cpp \
- QNote.cpp \
- QParagraph.cpp \
- QPrefs.cpp \
- QRef.cpp \
- QSearch.cpp \
- QSelectionManager.cpp \
- QSendto.cpp \
- QSetBorder.cpp \
- QShowFile.cpp \
- QSpellchecker.cpp \
- QTabular.cpp \
- QTabularCreate.cpp \
- QTexinfo.cpp \
- QThesaurus.cpp \
- QToc.cpp \
- QURLDialog.cpp \
- QViewSource.cpp \
- QVSpace.cpp \
- QWrap.cpp \
+ Qt2BC.cpp \
+ qt_helpers.cpp \
socket_callback.cpp \
TocModel.cpp \
TocWidget.cpp \
+ UrlView.cpp \
Validator.cpp
NOMOCHEADER = \
GuiFontLoader.h \
GuiFontMetrics.h \
GuiSelection.h \
- QGraphics.h \
- QLImage.h \
- QLPainter.h \
- QPrint.h \
+ GuiGraphics.h \
+ GuiImage.h \
+ GuiPainter.h \
+ GuiPrint.h \
Qt2BC.h \
qt_helpers.h
DockView.h \
EmptyTable.h \
FloatPlacement.h \
+ GuiAbout.h \
GuiApplication.h \
+ GuiBibitem.h \
+ GuiBibtex.h \
+ GuiBox.h \
+ GuiBranches.h \
+ GuiBranch.h \
+ GuiChanges.h \
+ GuiCharacter.h \
+ GuiCitationDialog.h \
+ GuiCitation.h \
+ GuiCommandBuffer.h \
+ GuiCommandEdit.h \
+ GuiDelimiterDialog.h \
+ GuiDialogView.h \
+ GuiDocument.h \
+ GuiErrorList.h \
+ GuiERT.h \
+ GuiExternal.h \
+ GuiFloatDialog.h \
+ GuiFloat.h \
+ GuiFontExample.h \
+ GuiGraphicsDialog.h \
GuiImplementation.h \
+ GuiInclude.h \
+ GuiIndex.h \
+ GuiKeySymbol.h \
+ GuiListings.h \
+ GuiLog.h \
+ GuiMathMatrixDialog.h \
+ GuiMenubar.h \
+ GuiNomencl.h \
+ GuiNote.h \
+ GuiParagraph.h \
+ GuiPopupMenu.h \
+ GuiPrefs.h \
+ GuiPrintDialog.h \
+ GuiRef.h \
+ GuiSearch.h \
+ GuiSelectionManager.h \
+ GuiSendto.h \
+ GuiSetBorder.h \
+ GuiShowFile.h \
+ GuiSpellchecker.h \
+ GuiTabularCreate.h \
+ GuiTabular.h \
+ GuiTexinfo.h \
+ GuiThesaurus.h \
+ GuiToc.h \
+ GuiToolbar.h \
+ GuiURLDialog.h \
GuiView.h \
+ GuiViewSource.h \
+ GuiVSpace.h \
GuiWorkArea.h \
+ GuiWrap.h \
IconPalette.h \
InsertTableWidget.h \
LengthCombo.h \
LyXFileDialog.h \
PanelStack.h \
- QAbout.h \
- QBibitem.h \
- QBibtex.h \
- QBox.h \
- QBranches.h \
- QBranch.h \
- QChanges.h \
- QCharacter.h \
- QCitationDialog.h \
- QCitation.h \
- QCommandBuffer.h \
- QCommandEdit.h \
- QDelimiterDialog.h \
- QDialogView.h \
- QDocument.h \
- QErrorList.h \
- QERT.h \
- QExternal.h \
- QFloatDialog.h \
- QFloat.h \
- QFontExample.h \
- QGraphicsDialog.h \
- QInclude.h \
- QIndex.h \
- QKeySymbol.h \
- QListings.h \
qlkey.h \
- QLMenubar.h \
- QLog.h \
- QLPopupMenu.h \
- QLPrintDialog.h \
- QLToolbar.h \
- QMathMatrixDialog.h \
- QNomencl.h \
- QNote.h \
- QParagraph.h \
- QPrefs.h \
- QRef.h \
- QSearch.h \
- QSelectionManager.h \
- QSendto.h \
- QSetBorder.h \
- QShowFile.h \
- QSpellchecker.h \
- QTabularCreate.h \
- QTabular.h \
- QTexinfo.h \
- QThesaurus.h \
- QToc.h \
- QURLDialog.h \
- QViewSource.h \
- QVSpace.h \
- QWrap.h \
socket_callback.h \
TocModel.h \
TocWidget.h \
+++ /dev/null
-/**
- * \file QAbout.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Kalle Dalheimer
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "QAbout.h"
-#include "Qt2BC.h"
-#include "qt_helpers.h"
-
-#include "controllers/ButtonController.h"
-#include "controllers/ControlAboutlyx.h"
-
-#include "support/lstrings.h"
-
-#include <sstream>
-
-#include <QLabel>
-#include <QPushButton>
-#include <QTextCodec>
-#include <QTextBrowser>
-
-using lyx::support::prefixIs;
-
-using std::getline;
-
-using std::istringstream;
-using std::ostringstream;
-using std::string;
-
-namespace lyx {
-namespace frontend {
-
-
-typedef QController<ControlAboutlyx, QView<QAboutDialog> > AboutBase;
-
-QAbout::QAbout(Dialog & parent)
- : AboutBase(parent, _("About LyX"))
-{
-}
-
-
-void QAbout::build_dialog()
-{
- dialog_.reset(new QAboutDialog);
- connect(dialog_.get()->closePB, SIGNAL(clicked()),
- this, SLOT(slotClose()));
-
- dialog_->copyrightTB->setPlainText(toqstr(controller().getCopyright()));
- dialog_->copyrightTB->append("");
- dialog_->copyrightTB->append(toqstr(controller().getLicense()));
- dialog_->copyrightTB->append("");
- dialog_->copyrightTB->append(toqstr(controller().getDisclaimer()));
-
- dialog_->versionLA->setText(toqstr(controller().getVersion()));
-
- // The code below should depend on a autoconf test. (Lgb)
-#if 1
- // There are a lot of buggy stringstream implementations..., but the
- // code below will work on all of them (I hope). The drawback with
- // this solutions os the extra copying. (Lgb)
-
- ostringstream in;
- controller().getCredits(in);
-
- istringstream ss(in.str());
-
- string s;
- ostringstream out;
-
- while (getline(ss, s)) {
- if (prefixIs(s, "@b"))
- out << "<b>" << s.substr(2) << "</b>";
- else if (prefixIs(s, "@i"))
- out << "<i>" << s.substr(2) << "</i>";
- else
- out << s;
- out << "<br>";
- }
-#else
- // Good stringstream implementations can handle this. It avoids
- // some copying, and should thus be faster and use less memory. (Lgb)
- // I'll make this the default for a short while to see if anyone
- // see the error...
- stringstream in;
- controller().getCredits(in);
- in.seekg(0);
- string s;
- ostringstream out;
-
- while (getline(in, s)) {
- if (prefixIs(s, "@b"))
- out << "<b>" << s.substr(2) << "</b>";
- else if (prefixIs(s, "@i"))
- out << "<i>" << s.substr(2) << "</i>";
- else
- out << s;
- out << "<br>";
- }
-#endif
-
- dialog_->creditsTB->setHtml(toqstr(out.str()));
-
- // try to resize to a good size
- dialog_->copyrightTB->hide();
- dialog_->setMinimumSize(dialog_->copyrightTB->sizeHint());
- dialog_->copyrightTB->show();
- dialog_->setMinimumSize(dialog_->sizeHint());
-
- // Manage the cancel/close button
- bcview().setCancel(dialog_->closePB);
- bc().refresh();
-}
-
-} // namespace frontend
-} // namespace lyx
-
-#include "QAbout_moc.cpp"
+++ /dev/null
-// -*- C++ -*-
-/**
- * \file QAbout.h
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Kalle Dalheimer
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#ifndef FORMABOUT_H
-#define FORMABOUT_H
-
-#include "QDialogView.h"
-#include "ui_AboutUi.h"
-#include <QDialog>
-
-namespace lyx {
-namespace frontend {
-
-class ControlAboutlyx;
-
-class QAboutDialog : public QDialog, public Ui::QAboutUi {
- Q_OBJECT
-public:
- QAboutDialog(QWidget * parent = 0)
- : QDialog(parent)
- {
- setupUi(this);
- connect(closePB, SIGNAL(clicked()), this, SLOT(reject()));
- }
-};
-
-
-class QAbout
- : public QController<ControlAboutlyx, QView<QAboutDialog> >
-{
-public:
- QAbout(Dialog &);
-private:
- /// not needed
- virtual void apply() {}
- /// not needed
- virtual void update_contents() {}
- // build the dialog
- virtual void build_dialog();
-};
-
-} // namespace frontend
-} // namespace lyx
-
-#endif // FORMABOUT_H
+++ /dev/null
-/**
- * \file QBibitem.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author John Levon
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "QBibitem.h"
-#include "Qt2BC.h"
-#include "qt_helpers.h"
-
-#include "controllers/ControlCommand.h"
-
-#include <QLineEdit>
-#include <QPushButton>
-
-
-namespace lyx {
-namespace frontend {
-
-/////////////////////////////////////////////////////////////////////
-//
-// QBibItemDialog
-//
-/////////////////////////////////////////////////////////////////////
-
-QBibitemDialog::QBibitemDialog(QBibitem * form)
- : form_(form)
-{
- setupUi(this);
- connect(okPB, SIGNAL(clicked()), form, SLOT(slotOK()));
- connect(closePB, SIGNAL(clicked()), form, SLOT(slotClose()));
-
- connect(keyED, SIGNAL(textChanged(const QString &)),
- this, SLOT(change_adaptor()));
- connect(labelED, SIGNAL(textChanged(const QString &)),
- this, SLOT(change_adaptor()));
-}
-
-
-void QBibitemDialog::change_adaptor()
-{
- form_->changed();
-}
-
-
-void QBibitemDialog::closeEvent(QCloseEvent *e)
-{
- form_->slotWMHide();
- e->accept();
-}
-
-
-/////////////////////////////////////////////////////////////////////
-//
-// QBibItem
-//
-/////////////////////////////////////////////////////////////////////
-
-typedef QController<ControlCommand, QView<QBibitemDialog> > BibItemBase;
-
-
-QBibitem::QBibitem(Dialog & parent)
- : BibItemBase(parent, _("Bibliography Entry Settings"))
-{
-}
-
-
-void QBibitem::build_dialog()
-{
- dialog_.reset(new QBibitemDialog(this));
-
- bcview().setOK(dialog_->okPB);
- bcview().setCancel(dialog_->closePB);
- bcview().addReadOnly(dialog_->keyED);
- bcview().addReadOnly(dialog_->labelED);
-}
-
-
-void QBibitem::update_contents()
-{
- dialog_->keyED->setText(toqstr(controller().params()["key"]));
- dialog_->labelED->setText(toqstr(controller().params()["label"]));
-}
-
-
-void QBibitem::apply()
-{
- controller().params()["key"] = qstring_to_ucs4(dialog_->keyED->text());
- controller().params()["label"] = qstring_to_ucs4(dialog_->labelED->text());
-}
-
-
-bool QBibitem::isValid()
-{
- return !dialog_->keyED->text().isEmpty();
-}
-
-} // namespace frontend
-} // namespace lyx
-
-#include "QBibitem_moc.cpp"
+++ /dev/null
-// -*- C++ -*-
-/**
- * \file QBibitem.h
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author John Levon
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#ifndef QBIBITEM_CONTROLLER_H
-#define QBIBITEM_CONTROLLER_H
-
-#include "QDialogView.h"
-
-#include "ui_BibitemUi.h"
-
-#include <QDialog>
-#include <QCloseEvent>
-
-
-namespace lyx {
-namespace frontend {
-
-class QBibitem;
-
-class QBibitemDialog : public QDialog, public Ui::QBibitemUi {
- Q_OBJECT
-public:
-
- QBibitemDialog(QBibitem * form);
-protected Q_SLOTS:
- virtual void change_adaptor();
-protected:
- virtual void closeEvent(QCloseEvent * e);
-private:
- QBibitem * form_;
-};
-
-
-class ControlCommand;
-
-class QBibitem
- : public QController<ControlCommand, QView<QBibitemDialog> >
-{
-public:
- friend class QBibitemDialog;
-
- QBibitem(Dialog &);
-
-protected:
- virtual bool isValid();
-private:
- /// Apply changes
- virtual void apply();
- /// update
- virtual void update_contents();
- /// build the dialog
- virtual void build_dialog();
-};
-
-} // namespace frontend
-} // namespace lyx
-
-#endif // QBIBITEM_H
+++ /dev/null
-/**
- * \file QBibtex.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author John Levon
- * \author Herbert Voß
- * \author Jürgen Spitzmüller
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "QBibtex.h"
-
-#include "ui_BibtexAddUi.h"
-#include "Qt2BC.h"
-#include "qt_helpers.h"
-#include "Validator.h"
-#include "LyXRC.h"
-#include "CheckedLineEdit.h"
-
-#include "controllers/ControlBibtex.h"
-#include "controllers/ButtonPolicy.h"
-
-#include "controllers/ControlBibtex.h"
-
-#include "support/filetools.h" // changeExtension
-#include "support/lstrings.h"
-
-#include <QPushButton>
-#include <QListWidget>
-#include <QCheckBox>
-#include <QCloseEvent>
-#include <QLineEdit>
-
-using lyx::support::changeExtension;
-using lyx::support::split;
-using lyx::support::trim;
-
-using std::vector;
-using std::string;
-
-#include "debug.h"
-#include "support/filetools.h"
-#include "support/lstrings.h"
-
-
-namespace lyx {
-namespace frontend {
-
-
-/////////////////////////////////////////////////////////////////////
-//
-// QBibtexDialog
-//
-/////////////////////////////////////////////////////////////////////
-
-QBibtexDialog::QBibtexDialog(QBibtex * form)
- : form_(form)
-{
- setupUi(this);
- QDialog::setModal(true);
-
- connect(okPB, SIGNAL(clicked()),
- form, SLOT(slotOK()));
- connect(closePB, SIGNAL(clicked()),
- form, SLOT(slotClose()));
- connect(stylePB, SIGNAL(clicked()),
- this, SLOT( browsePressed()));
- connect(deletePB, SIGNAL(clicked()),
- this, SLOT( deletePressed()));
- connect(styleCB, SIGNAL(editTextChanged (const QString &)),
- this, SLOT( change_adaptor()));
- connect(databaseLW, SIGNAL(itemSelectionChanged()),
- this, SLOT( databaseChanged()));
- connect(bibtocCB, SIGNAL(clicked()),
- this, SLOT( change_adaptor()));
- connect(btPrintCO, SIGNAL(activated(int)),
- this, SLOT( change_adaptor()));
- connect(addBibPB, SIGNAL(clicked()),
- this, SLOT( addPressed()));
-
- add_ = new UiDialog<Ui::QBibtexAddUi>(this, true);
-
- Qt2BC * bcview = new Qt2BC(add_bc_);
- add_bc_.view(bcview);
- add_bc_.bp(new OkCancelPolicy);
-
- bcview->setOK(add_->addPB);
- bcview->setCancel(add_->closePB);
-
- addCheckedLineEdit(add_bc_.view(), add_->bibED, 0);
-
- connect(add_->bibED, SIGNAL(textChanged(const QString &)),
- this, SLOT(bibEDChanged()));
- connect(add_->addPB, SIGNAL(clicked()),
- this, SLOT(addDatabase()));
- connect(add_->addPB, SIGNAL(clicked()),
- add_, SLOT(accept()));
- connect(add_->bibLW, SIGNAL(itemActivated(QListWidgetItem *)),
- this, SLOT(addDatabase()));
- connect(add_->bibLW, SIGNAL(itemActivated(QListWidgetItem *)),
- add_, SLOT(accept()));
- connect(add_->bibLW, SIGNAL(itemSelectionChanged()),
- this, SLOT(availableChanged()));
- connect(add_->browsePB, SIGNAL(clicked()),
- this, SLOT(browseBibPressed()));
- connect(add_->closePB, SIGNAL(clicked()),
- add_, SLOT(reject()));
-
-}
-
-
-void QBibtexDialog::bibEDChanged()
-{
- // Indicate to the button controller that the contents have
- // changed. The actual test of validity is carried out by
- // the checkedLineEdit.
- add_bc_.valid(true);
-}
-
-
-void QBibtexDialog::change_adaptor()
-{
- form_->changed();
-}
-
-
-void QBibtexDialog::browsePressed()
-{
- docstring const file = form_->controller().browseBst(docstring());
-
- if (!file.empty()) {
- // FIXME UNICODE
- docstring const filen = from_utf8(changeExtension(to_utf8(file), ""));
- bool present = false;
- unsigned int pres = 0;
-
- for (int i = 0; i != styleCB->count(); ++i) {
- if (qstring_to_ucs4(styleCB->itemText(i)) == filen) {
- present = true;
- pres = i;
- }
- }
-
- if (!present)
- styleCB->insertItem(0, toqstr(filen));
-
- styleCB->setCurrentIndex(pres);
- form_->changed();
- }
-}
-
-
-void QBibtexDialog::browseBibPressed()
-{
- docstring const file = trim(form_->controller().browseBib(docstring()));
-
- if (!file.empty()) {
- // FIXME UNICODE
- QString const f = toqstr(changeExtension(to_utf8(file), ""));
- bool present = false;
-
- for (int i = 0; i < add_->bibLW->count(); ++i) {
- if (add_->bibLW->item(i)->text() == f)
- present = true;
- }
-
- if (!present) {
- add_->bibLW->addItem(f);
- form_->changed();
- }
-
- add_->bibED->setText(f);
- }
-}
-
-
-void QBibtexDialog::addPressed()
-{
- add_bc_.valid(false);
- add_->exec();
-}
-
-
-void QBibtexDialog::addDatabase()
-{
- int const sel = add_->bibLW->currentRow();
- docstring const file = trim(qstring_to_ucs4(add_->bibED->text()));
-
- if (sel < 0 && file.empty())
- return;
-
- // Add the selected browser_bib keys to browser_database
- // multiple selections are possible
- for (int i = 0; i != add_->bibLW->count(); ++i) {
- QListWidgetItem * const item = add_->bibLW->item(i);
- if (add_->bibLW->isItemSelected(item)) {
- add_->bibLW->setItemSelected(item, false);
- QList<QListWidgetItem *> matches =
- databaseLW->findItems(item->text(), Qt::MatchExactly);
- if (matches.empty())
- databaseLW->addItem(item->text());
- }
- }
-
- if (!file.empty()) {
- add_->bibED->clear();
- QString const f = toqstr(from_utf8(changeExtension(to_utf8(file), "")));
- QList<QListWidgetItem *> matches =
- databaseLW->findItems(f, Qt::MatchExactly);
- if (matches.empty())
- databaseLW->addItem(f);
- }
-
- form_->changed();
-}
-
-
-void QBibtexDialog::deletePressed()
-{
- databaseLW->takeItem(databaseLW->currentRow());
- form_->changed();
-}
-
-
-
-void QBibtexDialog::databaseChanged()
-{
- deletePB->setEnabled(!form_->readOnly() && databaseLW->currentRow() != -1);
-}
-
-
-void QBibtexDialog::availableChanged()
-{
- add_bc_.valid(true);
-}
-
-
-void QBibtexDialog::closeEvent(QCloseEvent *e)
-{
- form_->slotWMHide();
- e->accept();
-}
-
-
-/////////////////////////////////////////////////////////////////////
-//
-// QBibTex
-//
-/////////////////////////////////////////////////////////////////////
-
-
-typedef QController<ControlBibtex, QView<QBibtexDialog> > BibtexBase;
-
-QBibtex::QBibtex(Dialog & parent)
- : BibtexBase(parent, _("BibTeX Bibliography"))
-{
-}
-
-
-void QBibtex::build_dialog()
-{
- dialog_.reset(new QBibtexDialog(this));
-
- bcview().setOK(dialog_->okPB);
- bcview().setCancel(dialog_->closePB);
- bcview().addReadOnly(dialog_->databaseLW);
- bcview().addReadOnly(dialog_->stylePB);
- bcview().addReadOnly(dialog_->styleCB);
- bcview().addReadOnly(dialog_->bibtocCB);
- bcview().addReadOnly(dialog_->addBibPB);
- bcview().addReadOnly(dialog_->deletePB);
-}
-
-
-void QBibtex::update_contents()
-{
- bool bibtopic = controller().usingBibtopic();
-
- dialog_->databaseLW->clear();
-
- docstring bibs(controller().params()["bibfiles"]);
- docstring bib;
-
- while (!bibs.empty()) {
- bibs = split(bibs, bib, ',');
- bib = trim(bib);
- if (!bib.empty())
- dialog_->databaseLW->addItem(toqstr(bib));
- }
-
- dialog_->add_->bibLW->clear();
-
- vector<string> bib_str;
- controller().getBibFiles(bib_str);
- for (vector<string>::const_iterator it = bib_str.begin();
- it != bib_str.end(); ++it) {
- string bibItem(changeExtension(*it, ""));
- dialog_->add_->bibLW->addItem(toqstr(bibItem));
- }
-
- string bibstyle(controller().getStylefile());
-
- dialog_->bibtocCB->setChecked(controller().bibtotoc() && !bibtopic);
- dialog_->bibtocCB->setEnabled(!bibtopic);
-
- docstring btprint(controller().params()["btprint"]);
- int btp = 0;
- if (btprint == "btPrintNotCited")
- btp = 1;
- else if (btprint == "btPrintAll")
- btp = 2;
-
- dialog_->btPrintCO->setCurrentIndex(btp);
- dialog_->btPrintCO->setEnabled(bibtopic);
-
- dialog_->styleCB->clear();
-
- int item_nr(-1);
-
- vector<string> str;
- controller().getBibStyles(str);
- for (vector<string>::const_iterator it = str.begin();
- it != str.end(); ++it) {
- string item(changeExtension(*it, ""));
- if (item == bibstyle)
- item_nr = int(it - str.begin());
- dialog_->styleCB->addItem(toqstr(item));
- }
-
- if (item_nr == -1 && !bibstyle.empty()) {
- dialog_->styleCB->addItem(toqstr(bibstyle));
- item_nr = dialog_->styleCB->count() - 1;
- }
-
- if (item_nr != -1)
- dialog_->styleCB->setCurrentIndex(item_nr);
- else
- dialog_->styleCB->clearEditText();
-}
-
-
-void QBibtex::apply()
-{
- docstring dbs(qstring_to_ucs4(dialog_->databaseLW->item(0)->text()));
-
- unsigned int maxCount = dialog_->databaseLW->count();
- for (unsigned int i = 1; i < maxCount; i++) {
- dbs += ',';
- dbs += qstring_to_ucs4(dialog_->databaseLW->item(i)->text());
- }
-
- controller().params()["bibfiles"] = dbs;
-
- docstring const bibstyle(qstring_to_ucs4(dialog_->styleCB->currentText()));
- bool const bibtotoc(dialog_->bibtocCB->isChecked());
-
- if (bibtotoc && (!bibstyle.empty())) {
- // both bibtotoc and style
- controller().params()["options"] = "bibtotoc," + bibstyle;
- } else if (bibtotoc) {
- // bibtotoc and no style
- controller().params()["options"] = from_ascii("bibtotoc");
- } else {
- // only style. An empty one is valid, because some
- // documentclasses have an own \bibliographystyle{}
- // command!
- controller().params()["options"] = bibstyle;
- }
-
- // bibtopic allows three kinds of sections:
- // 1. sections that include all cited references of the database(s)
- // 2. sections that include all uncited references of the database(s)
- // 3. sections that include all references of the database(s), cited or not
- int btp = dialog_->btPrintCO->currentIndex();
-
- switch (btp) {
- case 0:
- controller().params()["btprint"] = from_ascii("btPrintCited");
- break;
- case 1:
- controller().params()["btprint"] = from_ascii("btPrintNotCited");
- break;
- case 2:
- controller().params()["btprint"] = from_ascii("btPrintAll");
- break;
- }
-
- if (!controller().usingBibtopic())
- controller().params()["btprint"] = docstring();
-}
-
-
-bool QBibtex::isValid()
-{
- return dialog_->databaseLW->count() != 0;
-}
-
-} // namespace frontend
-} // namespace lyx
-
-#include "QBibtex_moc.cpp"
+++ /dev/null
-// -*- C++ -*-
-/**
- * \file QBibtex.h
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author John Levon
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#ifndef QBIBTEX_H
-#define QBIBTEX_H
-
-#include "QDialogView.h"
-
-#include "ui_BibtexUi.h"
-#include "ui_BibtexAddUi.h"
-
-#include "ButtonController.h"
-
-#include <QCloseEvent>
-#include <QDialog>
-
-namespace lyx {
-namespace frontend {
-
-class QBibtex;
-
-template<class UI>
-class UiDialog : public QDialog, public UI
-{
-public:
- UiDialog(QWidget * parent=0, bool modal=false, Qt::WFlags f=0)
- : QDialog(parent, f)
- {
- UI::setupUi(this);
- QDialog::setModal(modal);
- }
-};
-
-
-class QBibtexDialog : public QDialog, public Ui::QBibtexUi {
- Q_OBJECT
-
-public:
- QBibtexDialog(QBibtex * form);
-
- UiDialog<Ui::QBibtexAddUi> * add_;
-
-protected Q_SLOTS:
- virtual void change_adaptor();
- virtual void browsePressed();
- virtual void browseBibPressed();
- virtual void addPressed();
- virtual void addDatabase();
- virtual void deletePressed();
- virtual void databaseChanged();
- virtual void availableChanged();
- void bibEDChanged();
-
-protected:
- virtual void closeEvent(QCloseEvent * e);
-
-private:
- QBibtex * form_;
- ButtonController add_bc_;
-};
-
-
-class ControlBibtex;
-
-class QBibtex
- : public QController<ControlBibtex, QView<QBibtexDialog> >
-{
-public:
- friend class QBibtexDialog;
-
- QBibtex(Dialog &);
-protected:
- virtual bool isValid();
-private:
- /// Apply changes
- virtual void apply();
- /// update
- virtual void update_contents();
- /// build the dialog
- virtual void build_dialog();
-};
-
-} // namespace frontend
-} // namespace lyx
-
-#endif // QBIBTEX_H
+++ /dev/null
-/**
- * \file QBox.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Jürgen Vigna (Minipage stuff)
- * \author Martin Vermeer
- * \author Jürgen Spitzmüller
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "QBox.h"
-
-#include "CheckedLineEdit.h"
-#include "LengthCombo.h"
-#include "qt_helpers.h"
-#include "Qt2BC.h"
-#include "lengthcommon.h"
-#include "LyXRC.h" // to set the default length values
-#include "Validator.h"
-
-#include "controllers/ControlBox.h"
-#include "controllers/frontend_helpers.h"
-
-#include "insets/InsetBox.h"
-
-#include "support/lstrings.h"
-
-#include <QPushButton>
-#include <QLineEdit>
-#include <QCloseEvent>
-
-
-using lyx::support::getStringFromVector;
-using lyx::support::isStrDbl;
-using lyx::support::subst;
-using std::string;
-
-
-namespace lyx {
-namespace frontend {
-
-//////////////////////////////////////////////////////////////////
-//
-// QBoxDialog
-//
-//////////////////////////////////////////////////////////////////
-
-QBoxDialog::QBoxDialog(QBox * form)
- : form_(form)
-{
- setupUi(this);
- connect(restorePB, SIGNAL(clicked()), form, SLOT(slotRestore()));
- connect(okPB, SIGNAL(clicked()), form, SLOT(slotOK()));
- connect(applyPB, SIGNAL(clicked()), form, SLOT(slotApply()));
- connect(closePB, SIGNAL(clicked()), form, SLOT(slotClose()));
-
- connect(widthED, SIGNAL(textChanged(const QString &)),
- this, SLOT(change_adaptor()));
- connect(widthUnitsLC, SIGNAL(selectionChanged(lyx::Length::UNIT)),
- this, SLOT(change_adaptor()));
- connect(valignCO, SIGNAL(highlighted(const QString &)),
- this, SLOT(change_adaptor()));
- connect(heightED, SIGNAL(textChanged(const QString &)),
- this, SLOT(change_adaptor()));
- connect(heightUnitsLC, SIGNAL(selectionChanged(lyx::Length::UNIT) ),
- this, SLOT(change_adaptor()));
- connect(restorePB, SIGNAL(clicked()), this, SLOT(restoreClicked()));
- connect(typeCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
- connect(typeCO, SIGNAL(activated(int)), this, SLOT(typeChanged(int)));
- connect(halignCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
- connect(ialignCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
- connect(innerBoxCO, SIGNAL(activated(const QString&)),
- this, SLOT(innerBoxChanged(const QString &)));
- connect(innerBoxCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
-
- heightED->setValidator(unsignedLengthValidator(heightED));
- widthED->setValidator(unsignedLengthValidator(widthED));
-}
-
-
-void QBoxDialog::closeEvent(QCloseEvent * e)
-{
- form_->slotWMHide();
- e->accept();
-}
-
-
-void QBoxDialog::change_adaptor()
-{
- form_->changed();
-}
-
-
-void QBoxDialog::innerBoxChanged(const QString & str)
-{
- bool const ibox = (str != qt_("None"));
- valignCO->setEnabled(ibox);
- ialignCO->setEnabled(ibox);
- halignCO->setEnabled(!ibox);
- heightED->setEnabled(ibox);
- heightUnitsLC->setEnabled(ibox);
- form_->setSpecial(ibox);
-}
-
-
-void QBoxDialog::typeChanged(int index)
-{
- bool const frameless = (index == 0);
- if (frameless) {
- valignCO->setEnabled(true);
- ialignCO->setEnabled(true);
- halignCO->setEnabled(false);
- heightED->setEnabled(true);
- heightUnitsLC->setEnabled(true);
- form_->setSpecial(true);
- }
- int itype = innerBoxCO->currentIndex();
- form_->setInnerType(frameless, itype);
-}
-
-
-void QBoxDialog::restoreClicked()
-{
- form_->setInnerType(true, 2);
- widthED->setText("100");
- widthUnitsLC->setCurrentItem(Length::PCW);
- heightED->setText("1");
- for (int j = 0; j < heightUnitsLC->count(); j++) {
- if (heightUnitsLC->itemText(j) == qt_("Total Height"))
- heightUnitsLC->setCurrentItem(j);
- }
-}
-
-
-//////////////////////////////////////////////////////////////////
-//
-// QBox
-//
-//////////////////////////////////////////////////////////////////
-
-typedef QController<ControlBox, QView<QBoxDialog> > box_base_class;
-
-QBox::QBox(Dialog & parent)
- : box_base_class(parent, _("Box Settings"))
-{}
-
-
-void QBox::build_dialog()
-{
- dialog_.reset(new QBoxDialog(this));
-
- // fill the box type choice
- box_gui_tokens(ids_, gui_names_);
- for (unsigned int i = 0; i < gui_names_.size(); ++i)
- dialog_->typeCO->addItem(toqstr(gui_names_[i]));
-
- // add the special units to the height choice
- // width needs different handling
- box_gui_tokens_special_length(ids_spec_, gui_names_spec_);
- for (unsigned int i = 1; i < gui_names_spec_.size(); ++i)
- dialog_->heightUnitsLC->addItem(toqstr(gui_names_spec_[i]));
-
- bcview().addReadOnly(dialog_->typeCO);
- bcview().addReadOnly(dialog_->innerBoxCO);
- bcview().addReadOnly(dialog_->valignCO);
- bcview().addReadOnly(dialog_->ialignCO);
- bcview().addReadOnly(dialog_->halignCO);
- bcview().addReadOnly(dialog_->widthED);
- bcview().addReadOnly(dialog_->heightED);
- bcview().addReadOnly(dialog_->widthUnitsLC);
- bcview().addReadOnly(dialog_->heightUnitsLC);
-
- bcview().setRestore(dialog_->restorePB);
- bcview().setOK(dialog_->okPB);
- bcview().setApply(dialog_->applyPB);
- bcview().setCancel(dialog_->closePB);
-
- // initialize the length validator
- addCheckedLineEdit(bcview(), dialog_->widthED, dialog_->widthLA);
- addCheckedLineEdit(bcview(), dialog_->heightED, dialog_->heightLA);
-}
-
-
-void QBox::update_contents()
-{
- string type(controller().params().type);
- for (unsigned int i = 0; i < gui_names_.size(); ++i) {
- if (type == ids_[i])
- dialog_->typeCO->setCurrentIndex(i);
- }
-
- // default: minipage
- unsigned int inner_type = 2;
- if (!controller().params().inner_box)
- // none
- inner_type = 0;
- if (controller().params().use_parbox)
- // parbox
- inner_type = 1;
- bool frameless = (controller().params().type == "Frameless");
- setInnerType(frameless, inner_type);
-
- char c = controller().params().pos;
- dialog_->valignCO->setCurrentIndex(string("tcb").find(c, 0));
- c = controller().params().inner_pos;
- dialog_->ialignCO->setCurrentIndex(string("tcbs").find(c, 0));
- c = controller().params().hor_pos;
- dialog_->halignCO->setCurrentIndex(string("lcrs").find(c, 0));
-
- bool ibox = controller().params().inner_box;
- dialog_->valignCO->setEnabled(ibox);
- dialog_->ialignCO->setEnabled(ibox);
- dialog_->halignCO->setEnabled(!ibox);
- setSpecial(ibox);
-
- Length::UNIT default_unit =
- (lyxrc.default_papersize > 3) ? Length::CM : Length::IN;
-
- lengthToWidgets(dialog_->widthED, dialog_->widthUnitsLC,
- (controller().params().width).asString(), default_unit);
-
- string const special(controller().params().special);
- if (!special.empty() && special != "none") {
- QString spc;
- for (unsigned int i = 0; i < gui_names_spec_.size(); i++) {
- if (special == ids_spec_[i])
- spc = toqstr(gui_names_spec_[i].c_str());
- }
- for (int j = 0; j < dialog_->widthUnitsLC->count(); j++) {
- if (dialog_->widthUnitsLC->itemText(j) == spc)
- dialog_->widthUnitsLC->setCurrentIndex(j);
- }
- }
-
- lengthToWidgets(dialog_->heightED, dialog_->heightUnitsLC,
- (controller().params().height).asString(), default_unit);
-
- string const height_special(controller().params().height_special);
- if (!height_special.empty() && height_special != "none") {
- QString hspc;
- for (unsigned int i = 0; i < gui_names_spec_.size(); i++) {
- if (height_special == ids_spec_[i]) {
- hspc = toqstr(gui_names_spec_[i].c_str());
- }
- }
- for (int j = 0; j < dialog_->heightUnitsLC->count(); j++) {
- if (dialog_->heightUnitsLC->itemText(j) == hspc) {
- dialog_->heightUnitsLC->setCurrentIndex(j);
- }
- }
- }
-
- dialog_->heightED->setEnabled(ibox);
- dialog_->heightUnitsLC->setEnabled(ibox);
-}
-
-
-void QBox::apply()
-{
- controller().params().type =
- ids_[dialog_->typeCO->currentIndex()];
-
- controller().params().inner_box =
- dialog_->innerBoxCO->currentText() != qt_("None");
- controller().params().use_parbox =
- dialog_->innerBoxCO->currentText() == qt_("Parbox");
-
- controller().params().pos =
- "tcb"[dialog_->valignCO->currentIndex()];
- controller().params().inner_pos =
- "tcbs"[dialog_->ialignCO->currentIndex()];
- controller().params().hor_pos =
- "lcrs"[dialog_->halignCO->currentIndex()];
-
- int i = 0;
- bool spec = false;
- QString special = dialog_->widthUnitsLC->currentText();
- QString value = dialog_->widthED->text();
- if (special == qt_("Height")) {
- i = 1;
- spec = true;
- } else if (special == qt_("Depth")) {
- i = 2;
- spec = true;
- } else if (special == qt_("Total Height")) {
- i = 3;
- spec = true;
- } else if (special == qt_("Width")) {
- i = 4;
- spec = true;
- }
- // the user might insert a non-special value in the line edit
- if (isValidLength(fromqstr(value))) {
- i = 0;
- spec = false;
- }
- controller().params().special = ids_spec_[i];
-
- string width;
- if (spec) {
- width = fromqstr(value);
- // beware: bogosity! the unit is simply ignored in this case
- width += "in";
- } else
- width = widgetsToLength(dialog_->widthED, dialog_->widthUnitsLC);
-
- controller().params().width = Length(width);
-
- i = 0;
- spec = false;
- special = dialog_->heightUnitsLC->currentText();
- value = dialog_->heightED->text();
- if (special == qt_("Height")) {
- i = 1;
- spec = true;
- } else if (special == qt_("Depth")) {
- i = 2;
- spec = true;
- } else if (special == qt_("Total Height")) {
- i = 3;
- spec = true;
- } else if (special == qt_("Width")) {
- i = 4;
- spec = true;
- }
- // the user might insert a non-special value in the line edit
- if (isValidLength(fromqstr(value))) {
- i = 0;
- spec = false;
- }
- controller().params().height_special = ids_spec_[i];
-
- string height;
- if (spec && !isValidLength(fromqstr(dialog_->heightED->text()))) {
- height = fromqstr(value);
- // beware: bogosity! the unit is simply ignored in this case
- height += "in";
- } else
- height = widgetsToLength(dialog_->heightED, dialog_->heightUnitsLC);
-
- controller().params().height = Length(height);
-}
-
-
-void QBox::setSpecial(bool ibox)
-{
- box_gui_tokens_special_length(ids_spec_, gui_names_spec_);
- // check if the widget contains the special units
- int count = dialog_->widthUnitsLC->count();
- bool has_special = false;
- for (int i = 0; i < count; i++)
- if (dialog_->widthUnitsLC->itemText(i).contains(qt_("Total Height")) > 0)
- has_special = true;
- // insert 'em if needed...
- if (!ibox && !has_special) {
- for (unsigned int i = 1; i < gui_names_spec_.size(); i++)
- dialog_->widthUnitsLC->addItem(toqstr(gui_names_spec_[i]));
- // ... or remove 'em if needed
- } else if (ibox && has_special) {
- dialog_->widthUnitsLC->clear();
- for (int i = 0; i < num_units; i++)
- dialog_->widthUnitsLC->addItem(qt_(unit_name_gui[i]));
- }
-}
-
-
-void QBox::setInnerType(bool frameless, int i)
-{
- // with "frameless" boxes, inner box is mandatory (i.e. is the actual box)
- // we have to remove "none" then and adjust the combo
- if (frameless) {
- dialog_->innerBoxCO->clear();
- dialog_->innerBoxCO->addItem(qt_("Parbox"));
- dialog_->innerBoxCO->addItem(qt_("Minipage"));
- dialog_->innerBoxCO->setCurrentIndex(i - 1);
- } else {
- if (dialog_->innerBoxCO->count() == 2)
- i += 1;
- dialog_->innerBoxCO->clear();
- dialog_->innerBoxCO->addItem(qt_("None"));
- dialog_->innerBoxCO->addItem(qt_("Parbox"));
- dialog_->innerBoxCO->addItem(qt_("Minipage"));
- dialog_->innerBoxCO->setCurrentIndex(i);
- }
-}
-
-} // namespace frontend
-} // namespace lyx
-
-
-#include "QBox_moc.cpp"
+++ /dev/null
-// -*- C++ -*-
-/**
- * \file QBox.h
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Jürgen Spitzmüller
- * \ author Martin Vermeer
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#ifndef QBOX_H
-#define QBOX_H
-
-#include "QDialogView.h"
-
-#include "ui_BoxUi.h"
-
-#include <QCloseEvent>
-#include <QDialog>
-
-#include <vector>
-
-
-namespace lyx {
-namespace frontend {
-
-class ControlBox;
-class QBox;
-
-class QBoxDialog : public QDialog, public Ui::QBoxUi {
- Q_OBJECT
-public:
- QBoxDialog(QBox * form);
-protected Q_SLOTS:
- virtual void change_adaptor();
- virtual void innerBoxChanged(const QString &);
- virtual void typeChanged(int);
- virtual void restoreClicked();
-protected:
- virtual void closeEvent(QCloseEvent * e);
-private:
- QBox * form_;
-};
-
-
-///
-class QBox
- : public QController<ControlBox, QView<QBoxDialog> >
-{
-public:
- ///
- friend class QBoxDialog;
- ///
- QBox(Dialog &);
- /// add and remove special lengths
- void setSpecial(bool ibox);
- /// only show valid inner box items
- void setInnerType(bool frameless, int i);
-private:
- /// Apply changes
- virtual void apply();
- /// update
- virtual void update_contents();
- /// build the dialog
- virtual void build_dialog();
- ///
- std::vector<std::string> ids_;
- ///
- std::vector<docstring> gui_names_;
- ///
- std::vector<std::string> ids_spec_;
- ///
- std::vector<docstring> gui_names_spec_;
-};
-
-} // namespace frontend
-} // namespace lyx
-
-#endif // QBOX_H
+++ /dev/null
-/**
- * \file QBranch.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Jürgen Spitzmüller
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "QBranch.h"
-#include "Qt2BC.h"
-#include "qt_helpers.h"
-
-#include "BranchList.h"
-
-#include "controllers/ControlBranch.h"
-
-#include "insets/InsetBranch.h"
-
-#include <QPushButton>
-#include <QCloseEvent>
-
-namespace lyx {
-namespace frontend {
-
-/////////////////////////////////////////////////////////////////////
-//
-// QBranchDialog
-//
-/////////////////////////////////////////////////////////////////////
-
-QBranchDialog::QBranchDialog(QBranch * form)
- : form_(form)
-{
- setupUi(this);
- connect(okPB, SIGNAL(clicked()),
- form, SLOT(slotOK()));
- connect(closePB, SIGNAL(clicked()),
- form, SLOT(slotClose()));
- connect(branchCO, SIGNAL( activated(int) ),
- this, SLOT( change_adaptor() ) );
-}
-
-
-void QBranchDialog::closeEvent(QCloseEvent * e)
-{
- form_->slotWMHide();
- e->accept();
-}
-
-
-void QBranchDialog::change_adaptor()
-{
- form_->changed();
-}
-
-
-/////////////////////////////////////////////////////////////////////
-//
-// QBranch
-//
-/////////////////////////////////////////////////////////////////////
-
-typedef QController<ControlBranch, QView<QBranchDialog> > branch_base_class;
-
-
-QBranch::QBranch(Dialog & parent)
- : branch_base_class(parent, _("Branch Settings"))
-{}
-
-
-void QBranch::build_dialog()
-{
- dialog_.reset(new QBranchDialog(this));
-
- bcview().setOK(dialog_->okPB);
- bcview().setCancel(dialog_->closePB);
-}
-
-
-void QBranch::update_contents()
-{
- typedef BranchList::const_iterator const_iterator;
-
- BranchList const & branchlist = controller().branchlist();
- docstring const cur_branch = controller().params().branch;
-
- dialog_->branchCO->clear();
-
- const_iterator const begin = branchlist.begin();
- const_iterator const end = branchlist.end();
- int id = 0;
- int count = 0;
- for (const_iterator it = begin; it != end; ++it, ++count) {
- docstring const & branch = it->getBranch();
- dialog_->branchCO->addItem(toqstr(branch));
-
- if (cur_branch == branch)
- id = count;
- }
- dialog_->branchCO->setCurrentIndex(id);
-}
-
-
-void QBranch::apply()
-{
- docstring const type = qstring_to_ucs4(dialog_->branchCO->currentText());
- controller().params().branch = type;
-}
-
-} // namespace frontend
-} // namespace lyx
-
-#include "QBranch_moc.cpp"
+++ /dev/null
-// -*- C++ -*-
-/**
- * \file QBranch.h
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Jürgen Spitzmüller
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#ifndef QBRANCH_H
-#define QBRANCH_H
-
-#include "QDialogView.h"
-#include "ui_BranchUi.h"
-
-#include <QCloseEvent>
-#include <QDialog>
-
-namespace lyx {
-namespace frontend {
-
-class QBranch;
-
-class QBranchDialog : public QDialog, public Ui::QBranchUi {
- Q_OBJECT
-public:
- QBranchDialog(QBranch * form);
-protected Q_SLOTS:
- virtual void change_adaptor();
-protected:
- virtual void closeEvent(QCloseEvent * e);
-private:
- QBranch * form_;
-};
-
-class ControlBranch;
-
-/** This class provides a QT implementation of the Branch Dialog.
- */
-class QBranch : public QController<ControlBranch, QView<QBranchDialog> >
-{
-public:
- friend class QBranchDialog;
-
- /// Constructor
- QBranch(Dialog &);
-private:
- /// Apply changes
- virtual void apply();
- /// Build the dialog
- virtual void build_dialog();
- /// Update dialog before showing it
- virtual void update_contents();
-};
-
-} // namespace frontend
-} // namespace lyx
-
-#endif // QBRANCH_H
+++ /dev/null
-/**
- * \file QBranches.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Edwin Leuven
- * \author Abdelrazak Younes
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "QBranches.h"
-
-#include "GuiApplication.h"
-#include "Validator.h"
-#include "qt_helpers.h"
-
-#include "BufferParams.h"
-#include "controllers/ControlDocument.h"
-
-#include "support/lstrings.h"
-
-#include <QTreeWidget>
-#include <QTreeWidgetItem>
-#include <QPixmap>
-#include <QIcon>
-#include <QColor>
-#include <QColorDialog>
-
-
-namespace lyx {
-namespace frontend {
-
-
-QBranches::QBranches(QWidget * parent, Qt::WFlags f)
- : QWidget(parent, f)
-{
- setupUi(this);
- branchesTW->setColumnCount(3);
- branchesTW->headerItem()->setText(0, qt_("Branch"));
- branchesTW->headerItem()->setText(1, qt_("Activated"));
- branchesTW->headerItem()->setText(2, qt_("Color"));
- branchesTW->setSortingEnabled(true);
-}
-
-void QBranches::update(BufferParams const & params)
-{
- branchlist_ = params.branchlist();
- update();
-}
-
-void QBranches::update()
-{
- // store the selected branch
- QTreeWidgetItem * item = branchesTW->currentItem();
- QString sel_branch;
- if (item != 0)
- sel_branch = item->text(0);
-
- branchesTW->clear();
-
- BranchList::const_iterator it = branchlist_.begin();
- BranchList::const_iterator const end = branchlist_.end();
- for (; it != end; ++it) {
- QTreeWidgetItem * newItem =
- new QTreeWidgetItem(branchesTW);
-
- QString const bname = toqstr(it->getBranch());
- newItem->setText(0, bname);
-
- QString const sel = it->getSelected() ? qt_("Yes") : qt_("No");
- newItem->setText(1, sel);
-
- QColor const itemcolor = rgb2qcolor(it->getColor());
- if (itemcolor.isValid()) {
- QPixmap coloritem(30, 10);
- coloritem.fill(itemcolor);
- newItem->setIcon(2, QIcon(coloritem));
- }
- // restore selected branch
- if (bname == sel_branch) {
- branchesTW->setCurrentItem(newItem);
- branchesTW->setItemSelected(newItem, true);
- }
- }
- // emit signal
- changed();
-}
-
-void QBranches::apply(BufferParams & params) const
-{
- params.branchlist() = branchlist_;
-}
-
-void QBranches::on_addBranchPB_pressed()
-{
- QString const new_branch = newBranchLE->text();
- if (!new_branch.isEmpty()) {
- branchlist_.add(qstring_to_ucs4(new_branch));
- newBranchLE->clear();
- update();
- }
-}
-
-
-void QBranches::on_removePB_pressed()
-{
- QTreeWidgetItem * selItem =
- branchesTW->currentItem();
- QString sel_branch;
- if (selItem != 0)
- sel_branch = selItem->text(0);
- if (!sel_branch.isEmpty()) {
- branchlist_.remove(qstring_to_ucs4(sel_branch));
- newBranchLE->clear();
- update();
- }
-}
-
-
-void QBranches::on_activatePB_pressed()
-{
- toggleBranch(branchesTW->currentItem());
-}
-
-
-void QBranches::on_branchesTW_itemDoubleClicked(QTreeWidgetItem * item, int col)
-{
- if (col < 2)
- toggleBranch(item);
- else
- toggleColor(item);
-}
-
-
-void QBranches::toggleBranch(QTreeWidgetItem * item)
-{
- if (item == 0)
- return;
-
- QString sel_branch = item->text(0);
- if (!sel_branch.isEmpty()) {
- bool const selected = item->text(1) == qt_("Yes");
- Branch * branch = branchlist_.find(qstring_to_ucs4(sel_branch));
- if (branch && branch->setSelected(!selected)) {
- newBranchLE->clear();
- update();
- }
- }
-}
-
-
-void QBranches::on_colorPB_clicked()
-{
- toggleColor(branchesTW->currentItem());
-}
-
-
-void QBranches::toggleColor(QTreeWidgetItem * item)
-{
- if (item == 0)
- return;
-
- QString sel_branch = item->text(0);
- if (!sel_branch.isEmpty()) {
- docstring current_branch = qstring_to_ucs4(sel_branch);
- Branch * branch =
- branchlist_.find(current_branch);
- if (!branch)
- return;
-
- QColor const initial = rgb2qcolor(branch->getColor());
- QColor ncol(QColorDialog::getColor(initial, qApp->focusWidget()));
- if (ncol.isValid()){
- // add the color to the branchlist
- branch->setColor(fromqstr(ncol.name()));
- newBranchLE->clear();
- update();
- }
- }
-}
-
-} // namespace frontend
-} // namespace lyx
-
-#include "QBranches_moc.cpp"
+++ /dev/null
-// -*- C++ -*-
-/**
- * \file QBranches.h
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Edwin Leuven
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#ifndef QBRANCHES_H
-#define QBRANCHES_H
-
-#include "ui_BranchesUi.h"
-#include "QDocument.h"
-#include "BranchList.h"
-
-#include <QWidget>
-
-#include <vector>
-#include <string>
-
-
-class QTreeWidgetItem;
-
-namespace lyx {
-
-class BufferParams;
-
-namespace frontend {
-
-
-class QBranches: public QWidget, public Ui::BranchesUi
-{
- Q_OBJECT
-public:
- QBranches(QWidget * parent=0, Qt::WFlags f=0);
-
- void update(BufferParams const & params);
- void apply(BufferParams & params) const;
-
-Q_SIGNALS:
- void changed();
-
-protected:
- void toggleBranch(QTreeWidgetItem *);
- void toggleColor(QTreeWidgetItem *);
- void update();
-
-protected Q_SLOTS:
- void on_addBranchPB_pressed();
- void on_removePB_pressed();
- void on_activatePB_pressed();
- void on_branchesTW_itemDoubleClicked(QTreeWidgetItem *, int);
- void on_colorPB_clicked();
-
-private:
-
- /// Contains all legal branches for this doc
- BranchList branchlist_;
-
-};
-
-} // namespace frontend
-} // namespace lyx
-
-#endif // DOCUMENTDIALOG_H
+++ /dev/null
-/**
- * \file QChanges.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author John Levon
- * \author Michael Gerz
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "QChanges.h"
-#include "Qt2BC.h"
-#include "qt_helpers.h"
-
-#include "support/lstrings.h"
-
-#include "controllers/ControlChanges.h"
-
-#include <QPushButton>
-#include <QCloseEvent>
-#include <QTextBrowser>
-
-using lyx::support::bformat;
-
-
-namespace lyx {
-namespace frontend {
-
-/////////////////////////////////////////////////////////////////////
-//
-// QChangesDialog
-//
-/////////////////////////////////////////////////////////////////////
-
-QChangesDialog::QChangesDialog(QChanges * form)
- : form_(form)
-{
- setupUi(this);
- connect(closePB, SIGNAL(clicked()), form, SLOT(slotClose()));
- connect(nextPB, SIGNAL(clicked()), this, SLOT(nextPressed()));
- connect(rejectPB, SIGNAL(clicked()), this, SLOT(rejectPressed()));
- connect(acceptPB, SIGNAL(clicked()), this, SLOT(acceptPressed()));
-}
-
-
-void QChangesDialog::nextPressed()
-{
- form_->next();
-}
-
-
-void QChangesDialog::acceptPressed()
-{
- form_->accept();
-}
-
-
-void QChangesDialog::rejectPressed()
-{
- form_->reject();
-}
-
-
-void QChangesDialog::closeEvent(QCloseEvent *e)
-{
- form_->slotWMHide();
- e->accept();
-}
-
-
-
-/////////////////////////////////////////////////////////////////////
-//
-// QChanges
-//
-/////////////////////////////////////////////////////////////////////
-
-typedef QController<ControlChanges, QView<QChangesDialog> > ChangesBase;
-
-
-QChanges::QChanges(Dialog & parent)
- : ChangesBase(parent, _("Merge Changes"))
-{
-}
-
-
-void QChanges::build_dialog()
-{
- dialog_.reset(new QChangesDialog(this));
-
- bcview().setCancel(dialog_->closePB);
- bcview().addReadOnly(dialog_->acceptPB);
- bcview().addReadOnly(dialog_->rejectPB);
-}
-
-
-void QChanges::update_contents()
-{
- docstring text;
- docstring author = controller().getChangeAuthor();
- docstring date = controller().getChangeDate();
-
- if (!author.empty())
- text += bformat(_("Change by %1$s\n\n"), author);
- if (!date.empty())
- text += bformat(_("Change made at %1$s\n"), date);
-
- dialog_->changeTB->setPlainText(toqstr(text));
-}
-
-
-void QChanges::next()
-{
- controller().next();
-}
-
-
-void QChanges::accept()
-{
- controller().accept();
-}
-
-
-void QChanges::reject()
-{
- controller().reject();
-}
-
-} // namespace frontend
-} // namespace lyx
-
-#include "QChanges_moc.cpp"
+++ /dev/null
-// -*- C++ -*-
-/**
- * \file QChanges.h
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author John Levon
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#ifndef QCHANGES_H
-#define QCHANGES_H
-
-#include "QDialogView.h"
-#include "ui_ChangesUi.h"
-#include <QCloseEvent>
-#include <QDialog>
-
-namespace lyx {
-namespace frontend {
-
-class QChanges;
-
-class QChangesDialog : public QDialog, public Ui::QChangesUi {
- Q_OBJECT
-public:
-
- QChangesDialog(QChanges * form);
-
-protected Q_SLOTS:
-
- virtual void nextPressed();
- virtual void acceptPressed();
- virtual void rejectPressed();
-
-protected:
- virtual void closeEvent(QCloseEvent * e);
-
-private:
- QChanges * form_;
-};
-
-class ControlChanges;
-
-class QChanges
- : public QController<ControlChanges, QView<QChangesDialog> >
-{
-public:
- friend class QChangesDialog;
-
- QChanges(Dialog &);
-
- void accept();
-
- void reject();
-
- void next();
-
-private:
- /// Apply changes
- virtual void apply() {};
- /// update
- virtual void update_contents();
- /// build the dialog
- virtual void build_dialog();
-};
-
-} // namespace frontend
-} // namespace lyx
-
-#endif // QCHANGES_H
+++ /dev/null
-/**
- * \file QCharacter.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Edwin Leuven
- * \author John Levon
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "QCharacter.h"
-#include "ControlCharacter.h"
-#include "Qt2BC.h"
-#include "qt_helpers.h"
-
-#include "Color.h"
-
-
-#include <QCloseEvent>
-
-using std::vector;
-
-namespace lyx {
-namespace frontend {
-
-/////////////////////////////////////////////////////////////////////
-//
-// QCharacterDialog
-//
-/////////////////////////////////////////////////////////////////////
-
-QCharacterDialog::QCharacterDialog(QCharacter * form)
- : form_(form)
-{
- setupUi(this);
- connect(okPB, SIGNAL(clicked()), form_, SLOT(slotOK()));
- connect(applyPB, SIGNAL(clicked()), form_, SLOT(slotApply()));
- connect(closePB, SIGNAL(clicked()), form_, SLOT(slotClose()));
-
- connect(miscCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
- connect(sizeCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
- connect(familyCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
- connect(seriesCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
- connect(shapeCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
- connect(colorCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
- connect(langCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
- connect(toggleallCB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
-}
-
-
-void QCharacterDialog::change_adaptor()
-{
- form_->changed();
-
- if (!autoapplyCB->isChecked())
- return;
-
- // to be really good here, we should set the combos to the values of
- // the current text, and make it appear as "no change" if the values
- // stay the same between applys. Might be difficult though wrt to a
- // moved cursor - jbl
- form_->slotApply();
- familyCO->setCurrentIndex(0);
- seriesCO->setCurrentIndex(0);
- sizeCO->setCurrentIndex(0);
- shapeCO->setCurrentIndex(0);
- miscCO->setCurrentIndex(0);
- langCO->setCurrentIndex(0);
- colorCO->setCurrentIndex(0);
-}
-
-
-void QCharacterDialog::closeEvent(QCloseEvent * e)
-{
- form_->slotWMHide();
- e->accept();
-}
-
-
-/////////////////////////////////////////////////////////////////////
-//
-// QCharacter
-//
-/////////////////////////////////////////////////////////////////////
-
-typedef QController<ControlCharacter, QView<QCharacterDialog> > CharacterBase;
-
-QCharacter::QCharacter(Dialog & parent)
- : CharacterBase(parent, _("Text Style"))
-{
-}
-
-
-void QCharacter::build_dialog()
-{
- dialog_.reset(new QCharacterDialog(this));
-
- family = getFamilyData();
- series = getSeriesData();
- shape = getShapeData();
- size = getSizeData();
- bar = getBarData();
- color = getColorData();
- language = getLanguageData(true);
-
- for (vector<FamilyPair>::const_iterator cit = family.begin();
- cit != family.end(); ++cit) {
- dialog_->familyCO->addItem(toqstr(cit->first));
- }
-
- for (vector<SeriesPair>::const_iterator cit = series.begin();
- cit != series.end(); ++cit) {
- dialog_->seriesCO->addItem(toqstr(cit->first));
- }
- for (vector<ShapePair>::const_iterator cit = shape.begin();
- cit != shape.end(); ++cit) {
- dialog_->shapeCO->addItem(toqstr(cit->first));
- }
- for (vector<SizePair>::const_iterator cit = size.begin();
- cit != size.end(); ++cit) {
- dialog_->sizeCO->addItem(toqstr(cit->first));
- }
- for (vector<BarPair>::const_iterator cit = bar.begin();
- cit != bar.end(); ++cit) {
- dialog_->miscCO->addItem(toqstr(cit->first));
- }
- for (vector<ColorPair>::const_iterator cit = color.begin();
- cit != color.end(); ++cit) {
- dialog_->colorCO->addItem(toqstr(cit->first));
- }
- for (vector<LanguagePair>::const_iterator cit = language.begin();
- cit != language.end(); ++cit) {
- dialog_->langCO->addItem(toqstr(cit->first));
- }
-
- bcview().setOK(dialog_->okPB);
- bcview().setApply(dialog_->applyPB);
- bcview().setCancel(dialog_->closePB);
- bcview().addReadOnly(dialog_->familyCO);
- bcview().addReadOnly(dialog_->seriesCO);
- bcview().addReadOnly(dialog_->sizeCO);
- bcview().addReadOnly(dialog_->shapeCO);
- bcview().addReadOnly(dialog_->miscCO);
- bcview().addReadOnly(dialog_->langCO);
- bcview().addReadOnly(dialog_->colorCO);
- bcview().addReadOnly(dialog_->toggleallCB);
- bcview().addReadOnly(dialog_->autoapplyCB);
-
-// FIXME: hack to work around resizing bug in Qt >= 4.2
-// bug verified with Qt 4.2.{0-3} (JSpitzm)
-#if QT_VERSION >= 0x040200
- // qt resizes the comboboxes only after show(), so ...
- dialog_->show();
-#endif
-}
-
-
-namespace {
-
-template<class A, class B>
-int findPos2nd(vector<std::pair<A,B> > const & vec, B const & val)
-{
- typedef typename vector<std::pair<A, B> >::const_iterator
- const_iterator;
-
- const_iterator cit = vec.begin();
- for (; cit != vec.end(); ++cit) {
- if (cit->second == val)
- return int(cit - vec.begin());
- }
- return 0;
-}
-
-} // namespace anon
-
-
-void QCharacter::update_contents()
-{
- ControlCharacter const & ctrl = controller();
-
- dialog_->familyCO->setCurrentIndex(findPos2nd(family,
- ctrl.getFamily()));
- dialog_->seriesCO->setCurrentIndex(findPos2nd(series,
- ctrl.getSeries()));
- dialog_->shapeCO->setCurrentIndex(findPos2nd(shape, ctrl.getShape()));
- dialog_->sizeCO->setCurrentIndex(findPos2nd(size, ctrl.getSize()));
- dialog_->miscCO->setCurrentIndex(findPos2nd(bar, ctrl.getBar()));
- dialog_->colorCO->setCurrentIndex(findPos2nd(color, ctrl.getColor()));
- dialog_->langCO->setCurrentIndex(findPos2nd(language,
- ctrl.getLanguage()));
-
- dialog_->toggleallCB->setChecked(ctrl.getToggleAll());
-}
-
-
-void QCharacter::apply()
-{
- ControlCharacter & ctrl = controller();
-
- ctrl.setFamily(family[dialog_->familyCO->currentIndex()].second);
- ctrl.setSeries(series[dialog_->seriesCO->currentIndex()].second);
- ctrl.setShape(shape[dialog_->shapeCO->currentIndex()].second);
- ctrl.setSize(size[dialog_->sizeCO->currentIndex()].second);
- ctrl.setBar(bar[dialog_->miscCO->currentIndex()].second);
- ctrl.setColor(color[dialog_->colorCO->currentIndex()].second);
- ctrl.setLanguage(language[dialog_->langCO->currentIndex()].second);
-
- ctrl.setToggleAll(dialog_->toggleallCB->isChecked());
-}
-
-} // namespace frontend
-} // namespace lyx
-
-#include "QCharacter_moc.cpp"
+++ /dev/null
-// -*- C++ -*-
-/**
- * \file QCharacter.h
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Edwin Leuven
- * \author John Levon
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#ifndef QCHARACTER_H_CONTROLLER
-#define QCHARACTER_H_CONTROLLER
-
-#include "QDialogView.h"
-#include "ui_CharacterUi.h"
-#include <QDialog>
-
-#include "controllers/frontend_helpers.h"
-
-#include <vector>
-
-namespace lyx {
-
-class Font;
-
-namespace frontend {
-
-class QCharacter;
-
-class QCharacterDialog : public QDialog, public Ui::QCharacterUi {
- Q_OBJECT
-public:
- QCharacterDialog(QCharacter * form);
-protected:
- void closeEvent(QCloseEvent * e);
-private:
- QCharacter * form_;
-protected Q_SLOTS:
- void change_adaptor();
-};
-
-
-class ControlCharacter;
-
-class QCharacter
- : public QController<ControlCharacter, QView<QCharacterDialog> >
-{
-public:
- friend class QCharacterDialog;
-
- QCharacter(Dialog &);
-private:
- /// Apply changes
- virtual void apply();
- /// update
- virtual void update_contents();
- /// build the dialog
- virtual void build_dialog();
-
- std::vector<FamilyPair> family;
- std::vector<SeriesPair> series;
- std::vector<ShapePair> shape;
- std::vector<SizePair> size;
- std::vector<BarPair> bar;
- std::vector<ColorPair> color;
- std::vector<LanguagePair> language;
-};
-
-} // namespace frontend
-} // namespace lyx
-
-#endif // QCHARACTER_H
+++ /dev/null
-/**
- * \file QCitation.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Angus Leeming
- * \author Kalle Dalheimer
- * \author Abdelrazak Younes
- * \author Richard Heck (adapted to QSelectionManager)
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "QCitation.h"
-
-#include "qt_helpers.h"
-
-#include "support/lstrings.h"
-#include "support/docstring.h"
-
-#include "debug.h"
-
-#include <vector>
-#include <string>
-
-using std::vector;
-using std::string;
-
-
-template<typename String> static QStringList to_qstring_list(vector<String> const & v)
-{
- QStringList qlist;
-
- for (size_t i = 0; i != v.size(); ++i) {
- if (v[i].empty())
- continue;
- qlist.append(lyx::toqstr(v[i]));
- }
- return qlist;
-}
-
-
-static vector<lyx::docstring> const to_docstring_vector(QStringList const & qlist)
-{
- vector<lyx::docstring> v;
- for (int i = 0; i != qlist.size(); ++i) {
- if (qlist[i].isEmpty())
- continue;
- v.push_back(lyx::qstring_to_ucs4(qlist[i]));
- }
- return v;
-}
-
-
-namespace lyx {
-namespace frontend {
-
-
-QCitation::QCitation(Dialog & parent)
- : ControlCitation(parent)
-{
-}
-
-
-void QCitation::apply(int const choice, bool const full, bool const force,
- QString before, QString after)
-{
- if (cited_keys_.isEmpty())
- return;
-
- vector<biblio::CiteStyle> const & styles =
- ControlCitation::getCiteStyles();
-
- string const command =
- biblio::CitationStyle(styles[choice], full, force)
- .asLatexStr();
-
- params().setCmdName(command);
- params()["key"] = qstring_to_ucs4(cited_keys_.join(","));
- params()["before"] = qstring_to_ucs4(before);
- params()["after"] = qstring_to_ucs4(after);
- dispatchParams();
-}
-
-
-void QCitation::clearSelection()
-{
- cited_keys_.clear();
- selected_model_.setStringList(cited_keys_);
-}
-
-
-QString QCitation::textBefore()
-{
- return toqstr(params()["before"]);
-}
-
-
-QString QCitation::textAfter()
-{
- return toqstr(params()["after"]);
-}
-
-
-bool QCitation::initialiseParams(std::string const & data)
-{
- if (!ControlCitation::initialiseParams(data))
- return false;
- init();
- return true;
-}
-
-
-void QCitation::init()
-{
- // Make the list of all available bibliography keys
- all_keys_ = to_qstring_list(availableKeys());
- available_model_.setStringList(all_keys_);
-
- // Ditto for the keys cited in this inset
- QString str = toqstr(params()["key"]);
- if (str.isEmpty())
- cited_keys_.clear();
- else
- cited_keys_ = str.split(",");
- selected_model_.setStringList(cited_keys_);
-}
-
-
-void QCitation::findKey(QString const & str, bool only_keys,
- docstring field, docstring entryType,
- bool case_sensitive, bool reg_exp, bool reset)
-{
- // Used for optimisation: store last searched string.
- static QString last_searched_string;
- // Used to disable the above optimisation.
- static bool last_case_sensitive;
- static bool last_reg_exp;
- // Reset last_searched_string in case of changed option.
- if (last_case_sensitive != case_sensitive
- || last_reg_exp != reg_exp) {
- LYXERR(Debug::GUI) << "QCitation::findKey: optimisation disabled!" << std::endl;
- last_searched_string.clear();
- }
- // save option for next search.
- last_case_sensitive = case_sensitive;
- last_reg_exp = reg_exp;
-
- Qt::CaseSensitivity qtcase = case_sensitive?
- Qt::CaseSensitive: Qt::CaseInsensitive;
- QStringList keys;
- // If new string (str) contains the last searched one...
- if (!reset &&
- !last_searched_string.isEmpty() &&
- str.size() > 1 &&
- str.contains(last_searched_string, qtcase))
- // ... then only search within already found list.
- keys = available_model_.stringList();
- else
- // ... else search all keys.
- keys = all_keys_;
- // save searched string for next search.
- last_searched_string = str;
-
- QStringList result;
-
- //First, filter by entryType, which will be faster than
- //what follows, so we may get to do that on less.
- vector<docstring> keyVector = to_docstring_vector(keys);
- filterByEntryType(keyVector, entryType);
-
- if (str.isEmpty())
- result = to_qstring_list(keyVector);
- else
- result = to_qstring_list(searchKeys(keyVector, only_keys,
- qstring_to_ucs4(str), field, case_sensitive, reg_exp));
-
- available_model_.setStringList(result);
-}
-
-
-QStringList QCitation::getFieldsAsQStringList() {
- return to_qstring_list(availableFields());
-}
-
-
-QStringList QCitation::getEntriesAsQStringList() {
- return to_qstring_list(availableEntries());
-}
-
-
-QStringList QCitation::citationStyles(int sel)
-{
- docstring const key = qstring_to_ucs4(cited_keys_[sel]);
- return to_qstring_list(getCiteStrings(key));
-}
-
-
-QString QCitation::getKeyInfo(QString const & sel)
-{
- return toqstr(getInfo(qstring_to_ucs4(sel)));
-}
-
-void QCitation::setCitedKeys()
-{
- cited_keys_ = selected_model_.stringList();
-}
-
-
-} // namespace frontend
-} // namespace lyx
+++ /dev/null
-// -*- C++ -*-
-/**
- * \file QCitation.h
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Angus Leeming
- * \author Kalle Dalheimer
- * \author Abdelrazak Younes
- * \author Richard Heck (adapted to QSelectionManager)
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#ifndef QCITATION_H
-#define QCITATION_H
-
-#include "frontends/controllers/ControlCitation.h"
-#include "support/docstring.h"
-
-#include <QStringList>
-#include <QStringListModel>
-
-namespace lyx {
-namespace frontend {
-
-class QCitation : public ControlCitation
-{
-public:
- ///
- QCitation(Dialog &);
- virtual ~QCitation() {}
- virtual bool initialiseParams(std::string const & data);
-
- ///
- void init();
-
- /// Available keys
- QStringListModel * available() { return &available_model_; }
-
- /// Selected keys
- QStringListModel * selected() { return &selected_model_; }
-
- /// Text before cite
- QString textBefore();
-
- /// Text after cite
- QString textAfter();
-
- /// Get key description
- QString getKeyInfo(QString const &);
-
- /// Clear selected keys
- void clearSelection();
-
- /// Return a list of available fields
- QStringList getFieldsAsQStringList();
-
- /// Return a list of available fields
- QStringList getEntriesAsQStringList();
-
- /// Find keys containing a string.
- void findKey(
- QString const & str, //< string expression
- bool only_keys, //< set to true if only keys shall be searched.
- docstring field, //<field to search, empty for all fields
- docstring entryType, //<entry type to display, empty for all
- bool case_sensitive, //< set to true for case sensitive search.
- bool reg_exp, //< set to true if \c str is a regular expression.
- bool reset = false //< whether to reset and search all keys
- );
-
- /// List of example cite strings
- QStringList citationStyles(int);
-
- /// Set the Params variable for the Controller.
- virtual void apply(int const choice, bool const full, bool const force,
- QString before, QString after);
-
- void setCitedKeys();
-
-private:
- /// available keys.
- QStringListModel available_model_;
-
- /// selected keys.
- QStringListModel selected_model_;
-
- /// All keys.
- QStringList all_keys_;
-
- /// Cited keys.
- QStringList cited_keys_;
-};
-
-
-} // namespace frontend
-} // namespace lyx
-
-#endif // QCITATION_H
+++ /dev/null
-/**
- * \file QCitationDialog.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Kalle Dalheimer
- * \author John Levon
- * \author Jürgen Spitzmüller
- * \author Abdelrazak Younes
- * \author Richard Heck
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "QCitationDialog.h"
-
-#include "QCitation.h"
-
-#include "frontends/controllers/frontend_helpers.h"
-#include "frontends/controllers/ControlCitation.h"
-#include "qt_helpers.h"
-
-#include "support/docstring.h"
-
-#include "debug.h"
-#include "gettext.h"
-
-#include <algorithm>
-#include <vector>
-#include <string>
-
-#include <QCloseEvent>
-#include <QKeyEvent>
-
-#undef KeyPress
-
-using std::vector;
-using std::string;
-
-namespace lyx {
-namespace frontend {
-
-
-QCitationDialog::QCitationDialog(Dialog & dialog, QCitation * form)
- : Dialog::View(dialog, _("Citation")), form_(form)
-{
- setupUi(this);
-
- setWindowTitle(toqstr("LyX: " + getTitle()));
-
- connect(citationStyleCO, SIGNAL(activated(int)),
- this, SLOT(changed()));
- connect(fulllistCB, SIGNAL(clicked()),
- this, SLOT(changed()));
- connect(forceuppercaseCB, SIGNAL(clicked()),
- this, SLOT(changed()));
- connect(textBeforeED, SIGNAL(textChanged(const QString&)),
- this, SLOT(changed()));
- connect(textAfterED, SIGNAL(textChanged(const QString&)),
- this, SLOT(changed()));
- connect(clearPB, SIGNAL(clicked()),
- findLE, SLOT(clear()));
- connect(this, SIGNAL(rejected()), this, SLOT(cleanUp()));
-
- selectionManager =
- new QSelectionManager(availableLV, selectedLV,
- addPB, deletePB, upPB, downPB,
- form_->available(), form_->selected());
- connect(selectionManager, SIGNAL(selectionChanged()),
- this, SLOT(setCitedKeys()));
- connect(selectionManager, SIGNAL(updateHook()),
- this, SLOT(updateDialog()));
- connect(selectionManager, SIGNAL(okHook()),
- this, SLOT(on_okPB_clicked()));
-
-}
-
-
-QCitationDialog::~QCitationDialog()
-{}
-
-
-void QCitationDialog::cleanUp()
-{
- form_->clearSelection();
- form_->clearParams();
- close();
-}
-
-
-void QCitationDialog::closeEvent(QCloseEvent * e)
-{
- form_->clearSelection();
- form_->clearParams();
- e->accept();
-}
-
-
-void QCitationDialog::apply()
-{
- int const choice = std::max(0, citationStyleCO->currentIndex());
- style_ = choice;
- bool const full = fulllistCB->isChecked();
- bool const force = forceuppercaseCB->isChecked();
-
- QString const before = textBeforeED->text();
- QString const after = textAfterED->text();
-
- form_->apply(choice, full, force, before, after);
-}
-
-
-void QCitationDialog::hide()
-{
- form_->clearParams();
- accept();
-}
-
-
-void QCitationDialog::show()
-{
- findLE->clear();
- availableLV->setFocus();
- QDialog::show();
- raise();
- activateWindow();
-}
-
-
-bool QCitationDialog::isVisible() const
-{
- return QDialog::isVisible();
-}
-
-
-void QCitationDialog::on_okPB_clicked()
-{
- apply();
- form_->clearSelection();
- hide();
-}
-
-
-void QCitationDialog::on_cancelPB_clicked()
-{
- form_->clearSelection();
- hide();
-}
-
-
-void QCitationDialog::on_applyPB_clicked()
-{
- apply();
-}
-
-
-void QCitationDialog::on_restorePB_clicked()
-{
- form_->init();
- update();
-}
-
-
-void QCitationDialog::update()
-{
- fillFields();
- fillEntries();
- updateDialog();
-}
-
-
-//The main point of separating this out is that the fill*() methods
-//called in update() do not need to be called for INTERNAL updates,
-//such as when addPB is pressed, as the list of fields, entries, etc,
-//will not have changed. At the moment, however, the division between
-//fillStyles() and updateStyles() doesn't lend itself to dividing the
-//two methods, though they should be divisible.
-void QCitationDialog::updateDialog()
-{
- if (selectionManager->selectedFocused()) {
- if (selectedLV->selectionModel()->selectedIndexes().isEmpty())
- updateInfo(availableLV->currentIndex());
- else
- updateInfo(selectedLV->currentIndex());
- } else {
- if (availableLV->selectionModel()->selectedIndexes().isEmpty())
- updateInfo(QModelIndex());
- else
- updateInfo(availableLV->currentIndex());
- }
- setButtons();
-
- textBeforeED->setText(form_->textBefore());
- textAfterED->setText(form_->textAfter());
- fillStyles();
- updateStyle();
-}
-
-
-void QCitationDialog::updateStyle()
-{
- biblio::CiteEngine const engine = form_->getEngine();
- bool const natbib_engine =
- engine == biblio::ENGINE_NATBIB_AUTHORYEAR ||
- engine == biblio::ENGINE_NATBIB_NUMERICAL;
- bool const basic_engine = engine == biblio::ENGINE_BASIC;
-
- bool const haveSelection =
- selectedLV->model()->rowCount() > 0;
- fulllistCB->setEnabled(natbib_engine && haveSelection);
- forceuppercaseCB->setEnabled(natbib_engine && haveSelection);
- textBeforeED->setEnabled(!basic_engine && haveSelection);
- textBeforeLA->setEnabled(!basic_engine && haveSelection);
- textAfterED->setEnabled(haveSelection);
- textAfterLA->setEnabled(haveSelection);
- citationStyleCO->setEnabled(!basic_engine && haveSelection);
- citationStyleLA->setEnabled(!basic_engine && haveSelection);
-
- string const & command = form_->params().getCmdName();
-
- // Find the style of the citekeys
- vector<biblio::CiteStyle> const & styles =
- ControlCitation::getCiteStyles();
- biblio::CitationStyle const cs(command);
-
- vector<biblio::CiteStyle>::const_iterator cit =
- std::find(styles.begin(), styles.end(), cs.style);
-
- // restore the latest natbib style
- if (style_ >= 0 && style_ < citationStyleCO->count())
- citationStyleCO->setCurrentIndex(style_);
- else
- citationStyleCO->setCurrentIndex(0);
-
- if (cit != styles.end()) {
- int const i = int(cit - styles.begin());
- citationStyleCO->setCurrentIndex(i);
- fulllistCB->setChecked(cs.full);
- forceuppercaseCB->setChecked(cs.forceUCase);
- } else {
- fulllistCB->setChecked(false);
- forceuppercaseCB->setChecked(false);
- }
-}
-
-
-//This one needs to be called whenever citationStyleCO needs
-//to be updated---and this would be on anything that changes the
-//selection in selectedLV, or on a general update.
-void QCitationDialog::fillStyles()
-{
- int const oldIndex = citationStyleCO->currentIndex();
-
- citationStyleCO->clear();
-
- QStringList selected_keys = form_->selected()->stringList();
- if (selected_keys.empty()) {
- citationStyleCO->setEnabled(false);
- citationStyleLA->setEnabled(false);
- return;
- }
-
- int curr = selectedLV->model()->rowCount() - 1;
- if (curr < 0)
- return;
-
- if (!selectedLV->selectionModel()->selectedIndexes().empty())
- curr = selectedLV->selectionModel()->selectedIndexes()[0].row();
-
- QStringList sty = form_->citationStyles(curr);
-
- bool const basic_engine =
- (form_->getEngine() == biblio::ENGINE_BASIC);
-
- citationStyleCO->setEnabled(!sty.isEmpty() && !basic_engine);
- citationStyleLA->setEnabled(!sty.isEmpty() && !basic_engine);
-
- if (sty.isEmpty() || basic_engine)
- return;
-
- citationStyleCO->insertItems(0, sty);
-
- if (oldIndex != -1 && oldIndex < citationStyleCO->count())
- citationStyleCO->setCurrentIndex(oldIndex);
-}
-
-
-void QCitationDialog::fillFields()
-{
- fieldsCO->blockSignals(true);
- int const oldIndex = fieldsCO->currentIndex();
- fieldsCO->clear();
- QStringList const & fields = form_->getFieldsAsQStringList();
- fieldsCO->insertItem(0, qt_("All Fields"));
- fieldsCO->insertItem(1, qt_("Keys"));
- fieldsCO->insertItems(2, fields);
- if (oldIndex != -1 && oldIndex < fieldsCO->count())
- fieldsCO->setCurrentIndex(oldIndex);
- fieldsCO->blockSignals(false);
-}
-
-
-void QCitationDialog::fillEntries()
-{
- entriesCO->blockSignals(true);
- int const oldIndex = entriesCO->currentIndex();
- entriesCO->clear();
- QStringList const & entries = form_->getEntriesAsQStringList();
- entriesCO->insertItem(0, qt_("All Entry Types"));
- entriesCO->insertItems(1, entries);
- if (oldIndex != -1 && oldIndex < entriesCO->count())
- entriesCO->setCurrentIndex(oldIndex);
- entriesCO->blockSignals(false);
-}
-
-
-bool QCitationDialog::isSelected(const QModelIndex & idx)
-{
- QString const str = idx.data().toString();
- return form_->selected()->stringList().contains(str);
-}
-
-
-void QCitationDialog::setButtons()
-{
- selectionManager->update();
- int const srows = selectedLV->model()->rowCount();
- applyPB->setEnabled(srows > 0);
- okPB->setEnabled(srows > 0);
-}
-
-
-void QCitationDialog::updateInfo(QModelIndex const & idx)
-{
- if (idx.isValid()) {
- QString const keytxt = form_->getKeyInfo(idx.data().toString());
- infoML->document()->setPlainText(keytxt);
- } else
- infoML->document()->clear();
-}
-
-
-void QCitationDialog::setCitedKeys()
-{
- form_->setCitedKeys();
-}
-
-
-void QCitationDialog::findText(QString const & text, bool reset)
-{
- //"All Fields" and "Keys" are the first two
- int index = fieldsCO->currentIndex() - 2;
- vector<docstring> const & fields = form_->availableFields();
- docstring field;
-
- if (index <= -1 || index >= int(fields.size()))
- //either "All Fields" or "Keys" or an invalid value
- field = from_ascii("");
- else
- field = fields[index];
-
- //Was it "Keys"?
- bool const onlyKeys = index == -1;
-
- //"All Entry Types" is first.
- index = entriesCO->currentIndex() - 1;
- vector<docstring> const & entries = form_->availableEntries();
- docstring entryType;
- if (index < 0 || index >= int(entries.size()))
- entryType = from_ascii("");
- else
- entryType = entries[index];
-
- bool const case_sentitive = caseCB->checkState();
- bool const reg_exp = regexCB->checkState();
- form_->findKey(text, onlyKeys, field, entryType,
- case_sentitive, reg_exp, reset);
- //FIXME
- //It'd be nice to save and restore the current selection in
- //availableLV. Currently, we get an automatic reset, since the
- //model is reset.
-
- updateDialog();
-}
-
-
-void QCitationDialog::on_fieldsCO_currentIndexChanged(int /*index*/)
-{
- findText(findLE->text(), true);
-}
-
-
-void QCitationDialog::on_entriesCO_currentIndexChanged(int /*index*/)
-{
- findText(findLE->text(), true);
-}
-
-
-void QCitationDialog::on_findLE_textChanged(const QString & text)
-{
- clearPB->setDisabled(text.isEmpty());
- if (text.isEmpty())
- findLE->setFocus();
- findText(text);
-}
-
-
-void QCitationDialog::on_caseCB_stateChanged(int)
-{
- findText(findLE->text());
-}
-
-
-void QCitationDialog::on_regexCB_stateChanged(int)
-{
- findText(findLE->text());
-}
-
-
-void QCitationDialog::changed()
-{
- fillStyles();
- setButtons();
-}
-
-
-} // namespace frontend
-} // namespace lyx
-
-#include "QCitationDialog_moc.cpp"
+++ /dev/null
-// -*- C++ -*-
-/**
- * \file QCitationDialog.h
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Kalle Dalheimer
- * \author Abdelrazak Younes
- * \author Richard Heck
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#ifndef QCITATIONDIALOG_H
-#define QCITATIONDIALOG_H
-
-#include "Dialog.h"
-#include "QSelectionManager.h"
-#include "ui_CitationUi.h"
-
-#include <QCloseEvent>
-#include <QKeyEvent>
-#include <QStringList>
-#include <QStringListModel>
-
-namespace lyx {
-namespace frontend {
-
-class QCitation;
-
-class QCitationDialog: public QDialog, public Ui::QCitationUi, public Dialog::View {
- Q_OBJECT
-
-public:
- QCitationDialog(Dialog &, QCitation * form );
-
- virtual ~QCitationDialog();
-
- virtual void apply();
-
- /// Hide the dialog from sight
- void hide();
-
- /// Redraw the dialog (e.g. if the colors have been remapped).
- void redraw() {}
-
- /// Create the dialog if necessary, update it and display it.
- void show();
-
- /// \return true if the dialog is visible.
- bool isVisible() const;
-
-public Q_SLOTS:
- /// Update the display of the dialog whilst it is still visible.
- void update();
-
-protected:
- void closeEvent (QCloseEvent * e);
- /// prepares a call to QCitation::searchKeys when we
- /// are ready to search the BibTeX entries
- void findText(QString const & text, bool reset = false);
- /// check whether key is already selected
- bool isSelected(const QModelIndex &);
- /// update the display of BibTeX information
- void updateInfo(QModelIndex const &);
-
-protected Q_SLOTS:
- void cleanUp();
- void on_okPB_clicked();
- void on_cancelPB_clicked();
- void on_restorePB_clicked();
- void on_applyPB_clicked();
- void on_findLE_textChanged(const QString & text);
- void on_fieldsCO_currentIndexChanged(int index);
- void on_entriesCO_currentIndexChanged(int index);
- void on_caseCB_stateChanged(int);
- void on_regexCB_stateChanged(int);
- virtual void changed();
- ///
- void setCitedKeys();
- /// performs a limited update, suitable for internal call
- void updateDialog();
-
-private:
- /// enable/disable buttons
- void setButtons();
- /// fill the styles combo
- void fillStyles();
- /// fill the fields combo
- void fillFields();
- /// fill the entries combo
- void fillEntries();
- /// set the styles combo
- void updateStyle();
- /// last used citation style
- int style_;
-
- QCitation * form_;
-
- QSelectionManager * selectionManager;
-};
-
-} // namespace frontend
-} // namespace lyx
-
-#endif // QCITATIOINDIALOG_H
+++ /dev/null
-/**
- * \file QCommandBuffer.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author John Levon
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-// Qt defines a macro 'signals' that clashes with a boost namespace.
-// All is well if the namespace is visible first.
-#include "GuiView.h"
-
-#include "QCommandBuffer.h"
-#include "QCommandEdit.h"
-#include "qt_helpers.h"
-
-#include "support/filetools.h"
-
-#include <QHBoxLayout>
-#include <QKeyEvent>
-#include <QLayout>
-#include <QListWidget>
-#include <QMouseEvent>
-#include <QPixmap>
-#include <QPushButton>
-#include <QToolTip>
-#include <QVBoxLayout>
-
-using lyx::support::libFileSearch;
-
-using std::vector;
-using std::string;
-
-namespace lyx {
-namespace frontend {
-
-namespace {
-
-class QTempListBox : public QListWidget {
-public:
- QTempListBox() {
- //setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
- setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
- setWindowModality(Qt::WindowModal);
- setWindowFlags(Qt::Popup);
- setAttribute(Qt::WA_DeleteOnClose);
- }
-protected:
- void mouseReleaseEvent(QMouseEvent * ev) {
- if (ev->x() < 0 || ev->y() < 0
- || ev->x() > width() || ev->y() > height()) {
- hide();
- } else {
- // emit signal
- itemPressed(currentItem());
- }
- }
-
- void keyPressEvent(QKeyEvent * ev) {
- if (ev->key() == Qt::Key_Escape) {
- hide();
- return;
- } else if (ev->key() == Qt::Key_Return || ev->key() == Qt::Key_Space) {
- // emit signal
- itemPressed(currentItem());
- } else
- QListWidget::keyPressEvent(ev);
- }
-};
-
-} // end of anon
-
-
-QCommandBuffer::QCommandBuffer(GuiView * view)
- : view_(view), controller_(*view)
-{
- QPixmap qpup(toqstr(libFileSearch("images", "up", "png").absFilename()));
- QPixmap qpdown(toqstr(libFileSearch("images", "down", "png").absFilename()));
-
- QVBoxLayout * top = new QVBoxLayout(this);
- QHBoxLayout * layout = new QHBoxLayout(0);
-
- QPushButton * up = new QPushButton(qpup, "", this);
- up->setMaximumSize(24, 24);
- up->setToolTip(qt_("Previous command"));
- connect(up, SIGNAL(clicked()), this, SLOT(up()));
- QPushButton * down = new QPushButton(qpdown, "", this);
- down->setToolTip(qt_("Next command"));
- down->setMaximumSize(24, 24);
- connect(down, SIGNAL(clicked()), this, SLOT(down()));
-
- edit_ = new QCommandEdit(this);
- edit_->setMinimumSize(edit_->sizeHint());
- edit_->setFocusPolicy(Qt::ClickFocus);
-
- connect(edit_, SIGNAL(escapePressed()), this, SLOT(cancel()));
- connect(edit_, SIGNAL(returnPressed()), this, SLOT(dispatch()));
- connect(edit_, SIGNAL(tabPressed()), this, SLOT(complete()));
- connect(edit_, SIGNAL(upPressed()), this, SLOT(up()));
- connect(edit_, SIGNAL(downPressed()), this, SLOT(down()));
- connect(edit_, SIGNAL(hidePressed()), this, SLOT(hideParent()));
-
- layout->addWidget(up, 0);
- layout->addWidget(down, 0);
- layout->addWidget(edit_, 10);
- layout->setMargin(0);
- top->addLayout(layout);
- top->setMargin(0);
- setFocusProxy(edit_);
-}
-
-
-void QCommandBuffer::cancel()
-{
- view_->setFocus();
- edit_->setText(QString());
-}
-
-
-void QCommandBuffer::dispatch()
-{
- controller_.dispatch(fromqstr(edit_->text()));
- view_->setFocus();
- edit_->setText(QString());
- edit_->clearFocus();
-}
-
-
-void QCommandBuffer::complete()
-{
- string const input = fromqstr(edit_->text());
- string new_input;
- vector<string> comp = controller_.completions(input, new_input);
-
- if (comp.empty() && new_input == input) {
- // show_info_suffix(qt_("[no match]"), input);
- return;
- }
-
- if (comp.empty()) {
- edit_->setText(toqstr(new_input));
- // show_info_suffix(("[only completion]"), new_input + ' ');
- return;
- }
-
- edit_->setText(toqstr(new_input));
-
- QTempListBox * list = new QTempListBox;
-
- // For some reason the scrollview's contents are larger
- // than the number of actual items...
- vector<string>::const_iterator cit = comp.begin();
- vector<string>::const_iterator end = comp.end();
- for (; cit != end; ++cit)
- list->addItem(toqstr(*cit));
-
- list->resize(list->sizeHint());
- QPoint const pos = edit_->mapToGlobal(QPoint(0, 0));
-
- int const y = std::max(0, pos.y() - list->height());
-
- list->move(pos.x(), y);
-
- connect(list, SIGNAL(itemPressed(QListWidgetItem *)),
- this, SLOT(complete_selected(QListWidgetItem *)));
- connect(list, SIGNAL(itemActivated(QListWidgetItem *)),
- this, SLOT(complete_selected(QListWidgetItem *)));
-
- list->show();
- list->setFocus();
-}
-
-
-void QCommandBuffer::complete_selected(QListWidgetItem * item)
-{
- QWidget const * widget = static_cast<QWidget const *>(sender());
- const_cast<QWidget *>(widget)->hide();
- edit_->setText(item->text() + ' ');
- edit_->activateWindow();
- edit_->setFocus();
-}
-
-
-void QCommandBuffer::up()
-{
- string const input = fromqstr(edit_->text());
- string const h = controller_.historyUp();
-
- if (h.empty()) {
- // show_info_suffix(qt_("[Beginning of history]"), input);
- } else {
- edit_->setText(toqstr(h));
- }
-}
-
-
-void QCommandBuffer::down()
-{
- string const input = fromqstr(edit_->text());
- string const h = controller_.historyDown();
-
- if (h.empty()) {
- // show_info_suffix(qt_("[End of history]"), input);
- } else {
- edit_->setText(toqstr(h));
- }
-}
-
-
-void QCommandBuffer::hideParent()
-{
- view_->setFocus();
- edit_->setText(QString());
- edit_->clearFocus();
- controller_.hide();
-}
-
-
-#if 0
-void XMiniBuffer::show_info_suffix(string const & suffix, string const & input)
-{
- stored_input_ = input;
- info_suffix_shown_ = true;
- set_input(input + ' ' + suffix);
- suffix_timer_->start();
-}
-
-
-void XMiniBuffer::suffix_timeout()
-{
- info_suffix_shown_ = false;
- set_input(stored_input_);
-}
-
-#endif
-
-} // namespace frontend
-} // namespace lyx
-
-#include "QCommandBuffer_moc.cpp"
+++ /dev/null
-// -*- C++ -*-
-/**
- * \file QCommandBuffer.h
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author John Levon
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#ifndef QCOMMANDBUFFER_H
-#define QCOMMANDBUFFER_H
-
-#include "controllers/ControlCommandBuffer.h"
-
-#include <QWidget>
-
-class QListWidgetItem;
-
-namespace lyx {
-namespace frontend {
-
-class QCommandEdit;
-class GuiView;
-
-class QCommandBuffer : public QWidget {
- Q_OBJECT
-public:
- QCommandBuffer(GuiView * view);
-
-public Q_SLOTS:
- /// cancel command compose
- void cancel();
- /// dispatch a command
- void dispatch();
- /// tab-complete
- void complete();
- /// select-complete
- void complete_selected(QListWidgetItem *);
- /// up
- void up();
- /// down
- void down();
- /// leave and hide the command buffer
- void hideParent();
-private:
- /// owning view
- GuiView * view_;
-
- /// controller
- ControlCommandBuffer controller_;
-
- /// command widget
- QCommandEdit * edit_;
-};
-
-} // namespace frontend
-} // namespace lyx
-
-#endif // QCOMMANDBUFFER_H
+++ /dev/null
-/**
- * \file QCommandEdit.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author John Levon
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "QCommandEdit.h"
-
-#include <QKeyEvent>
-#include <QEvent>
-
-#undef KeyPress
-
-namespace lyx {
-namespace frontend {
-
-QCommandEdit::QCommandEdit(QWidget * parent)
- : QLineEdit(parent)
-{
- setFocusPolicy(Qt::ClickFocus);
-}
-
-
-void QCommandEdit::keyPressEvent(QKeyEvent * e)
-{
- switch (e->key()) {
- case Qt::Key_Escape:
- // emit signal
- escapePressed();
- break;
-
- case Qt::Key_Up:
- // emit signal
- upPressed();
- break;
-
- case Qt::Key_Down:
- // emit signal
- downPressed();
- break;
-
- case Qt::Key_X:
- if (e->modifiers() == Qt::AltModifier
- || e->modifiers() == Qt::MetaModifier) {
- // emit signal
- hidePressed();
- break;
- }
-
- default:
- QLineEdit::keyPressEvent(e);
- break;
- }
-}
-
-
-bool QCommandEdit::event(QEvent * e)
-{
- if (e->type() != QEvent::KeyPress)
- return QLineEdit::event(e);
-
- QKeyEvent * ev = (QKeyEvent *)e;
-
- if (ev->key() != Qt::Key_Tab)
- return QLineEdit::event(e);
-
- // emit signal
- tabPressed();
- return true;
-}
-
-} // namespace frontend
-} // namespace lyx
-
-#include "QCommandEdit_moc.cpp"
+++ /dev/null
-// -*- C++ -*-
-/**
- * \file QCommandEdit.h
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author John Levon
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#ifndef QCOMMANDEDIT_H
-#define QCOMMANDEDIT_H
-
-#include <QLineEdit>
-#include <QKeyEvent>
-#include <QEvent>
-
-namespace lyx {
-namespace frontend {
-
-class QCommandEdit : public QLineEdit {
- Q_OBJECT
-public:
- QCommandEdit(QWidget * parent);
-Q_SIGNALS:
- /// cancel
- void escapePressed();
- /// up history
- void upPressed();
- /// down history
- void downPressed();
- /// complete
- void tabPressed();
- /// leave and hide command buffer
- void hidePressed();
-
-protected:
- ///
- virtual bool event(QEvent * e);
- ///
- virtual void keyPressEvent(QKeyEvent * e);
-};
-
-} // namespace frontend
-} // namespace lyx
-
-#endif // QCOMMANDEDIT_H
+++ /dev/null
-/**
- * \file QDelimiterDialog.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author John Levon
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "QDelimiterDialog.h"
-
-#include "GuiApplication.h"
-#include "GuiView.h"
-
-
-#include "qt_helpers.h"
-#include "controllers/ControlMath.h"
-
-#include "gettext.h"
-
-#include <QPixmap>
-#include <QCheckBox>
-#include <QListWidgetItem>
-
-#include <sstream>
-
-// Set to zero if unicode symbols are preferred.
-#define USE_PIXMAP 1
-
-using std::string;
-
-namespace lyx {
-namespace frontend {
-
-namespace {
-
-QString const bigleft[] = {"", "bigl", "Bigl", "biggl", "Biggl"};
-
-
-QString const bigright[] = {"", "bigr", "Bigr", "biggr", "Biggr"};
-
-
-char const * const biggui[] = {N_("big[[delimiter size]]"), N_("Big[[delimiter size]]"),
- N_("bigg[[delimiter size]]"), N_("Bigg[[delimiter size]]"), ""};
-
-
-// FIXME: It might be better to fix the big delim LFUN to not require
-// additional '\' prefix.
-QString fix_name(QString const & str, bool big)
-{
- if (str.isEmpty())
- return ".";
- if (!big || str == "(" || str == ")" || str == "[" || str == "]"
- || str == "|" || str == "/")
- return str;
-
- return "\\" + str;
-}
-
-} // namespace anon
-
-
-typedef QController<ControlMath, QView<QDelimiterDialog> > delimiter_base;
-
-QMathDelimiter::QMathDelimiter(Dialog & parent)
- : delimiter_base(parent, _("Math Delimiter"))
-{}
-
-
-void QMathDelimiter::build_dialog()
-{
- dialog_.reset(new QDelimiterDialog(this,
- static_cast<GuiView *>(controller().view())));
-}
-
-
-char_type QDelimiterDialog::doMatch(char_type const symbol) const
-{
- string const & str = form_->controller().texName(symbol);
- string match;
- if (str == "(") match = ")";
- else if (str == ")") match = "(";
- else if (str == "[") match = "]";
- else if (str == "]") match = "[";
- else if (str == "{") match = "}";
- else if (str == "}") match = "{";
- else if (str == "l") match = "r";
- else if (str == "rceil") match = "lceil";
- else if (str == "lceil") match = "rceil";
- else if (str == "rfloor") match = "lfloor";
- else if (str == "lfloor") match = "rfloor";
- else if (str == "rangle") match = "langle";
- else if (str == "langle") match = "rangle";
- else if (str == "backslash") match = "/";
- else if (str == "/") match = "backslash";
- else return symbol;
-
- return form_->controller().mathSymbol(match).unicode;
-}
-
-
-QDelimiterDialog::QDelimiterDialog(QMathDelimiter * form, QWidget * parent)
- : QDialog(parent), form_(form)
-{
- setupUi(this);
-
- connect(closePB, SIGNAL(clicked()), this, SLOT(accept()));
-
- setWindowTitle(qt_("LyX: Delimiters"));
- setFocusProxy(leftLW);
-
- leftLW->setViewMode(QListView::IconMode);
- rightLW->setViewMode(QListView::IconMode);
-
- typedef std::map<char_type, QListWidgetItem *> ListItems;
- ListItems list_items;
- // The last element is the empty one.
- int const end = nr_latex_delimiters - 1;
- for (int i = 0; i < end; ++i) {
- string const delim = latex_delimiters[i];
- MathSymbol const & ms = form_->controller().mathSymbol(delim);
- QString symbol(ms.fontcode?
- QChar(ms.fontcode) : toqstr(docstring(1, ms.unicode)));
- QListWidgetItem * lwi = new QListWidgetItem(symbol);
- lwi->setToolTip(toqstr(delim));
- Font lyxfont;
- lyxfont.setFamily(ms.fontfamily);
- QFont const & symbol_font = guiApp->guiFontLoader().get(lyxfont);
- lwi->setFont(symbol_font);
- list_items[ms.unicode] = lwi;
- leftLW->addItem(lwi);
- }
-
- for (int i = 0; i != leftLW->count(); ++i) {
- MathSymbol const & ms = form_->controller().mathSymbol(
- fromqstr(leftLW->item(i)->toolTip()));
- rightLW->addItem(list_items[doMatch(ms.unicode)]->clone());
- }
-
- // The last element is the empty one.
- leftLW->addItem(qt_("(None)"));
- rightLW->addItem(qt_("(None)"));
-
- sizeCO->addItem(qt_("Variable"));
-
- for (int i = 0; *biggui[i]; ++i)
- sizeCO->addItem(qt_(biggui[i]));
-
- on_leftLW_currentRowChanged(0);
-}
-
-
-void QDelimiterDialog::updateTeXCode(int size)
-{
- bool const bigsize = size != 0;
-
- QString left_str = fix_name(leftLW->currentItem()->toolTip(), bigsize);
- QString right_str = fix_name(rightLW->currentItem()->toolTip(), bigsize);
-
- if (!bigsize)
- tex_code_ = left_str + ' ' + right_str;
- else {
- tex_code_ = bigleft[size] + ' '
- + left_str + ' '
- + bigright[size] + ' '
- + right_str;
- }
-
- // Generate TeX-code for GUI display.
- // FIXME: Instead of reconstructing the TeX code it would be nice to
- // FIXME: retrieve the LateX code directly from mathed.
- // In all cases, we want the '\' prefix if needed, so we pass 'true'
- // to fix_name.
- left_str = fix_name(leftLW->currentItem()->toolTip(), true);
- right_str = fix_name(rightLW->currentItem()->toolTip(), true);
- QString code_str;
- if (!bigsize)
- code_str = "\\left" + left_str + " \\right" + right_str;
- else {
- // There should be nothing in the TeX-code when the delimiter is "None".
- if (left_str != ".")
- code_str = "\\" + bigleft[size] + left_str + ' ';
- if (right_str != ".")
- code_str += "\\" + bigright[size] + right_str;
- }
-
- texCodeL->setText(qt_("TeX Code: ") + code_str);
-}
-
-
-void QDelimiterDialog::on_insertPB_clicked()
-{
- if (sizeCO->currentIndex() == 0)
- form_->controller().dispatchDelim(fromqstr(tex_code_));
- else {
- QString command = '"' + tex_code_ + '"';
- command.replace(' ', "\" \"");
- form_->controller().dispatchBigDelim(fromqstr(command));
- }
- }
-
-
-void QDelimiterDialog::on_sizeCO_activated(int index)
-{
- updateTeXCode(index);
-}
-
-
-void QDelimiterDialog::on_leftLW_itemActivated(QListWidgetItem *)
-{
- on_insertPB_clicked();
- accept();
-}
-
-
-void QDelimiterDialog::on_rightLW_itemActivated(QListWidgetItem *)
-{
- on_insertPB_clicked();
- accept();
-}
-
-
-void QDelimiterDialog::on_leftLW_currentRowChanged(int item)
-{
- if (matchCB->isChecked())
- rightLW->setCurrentRow(item);
-
- updateTeXCode(sizeCO->currentIndex());
-}
-
-
-void QDelimiterDialog::on_rightLW_currentRowChanged(int item)
-{
- if (matchCB->isChecked())
- leftLW->setCurrentRow(item);
-
- updateTeXCode(sizeCO->currentIndex());
-}
-
-
-void QDelimiterDialog::on_matchCB_stateChanged(int state)
-{
- if (state == Qt::Checked)
- on_leftLW_currentRowChanged(leftLW->currentRow());
-
- updateTeXCode(sizeCO->currentIndex());
-}
-
-
-} // namespace frontend
-} // namespace lyx
-
-#include "QDelimiterDialog_moc.cpp"
+++ /dev/null
-// -*- C++ -*-
-/**
- * \file QDelimiterDialog.h
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author John Levon
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#ifndef QDELIMITERDIALOG_H
-#define QDELIMITERDIALOG_H
-
-#include "QDialogView.h"
-
-#include "ui_DelimiterUi.h"
-
-#include <string>
-
-class QListWidgetItem;
-
-namespace lyx {
-namespace frontend {
-
-class ControlMath;
-class QMathDelimiter;
-
-class QDelimiterDialog : public QDialog, public Ui::QDelimiterUi {
- Q_OBJECT
-public:
- QDelimiterDialog(QMathDelimiter * form, QWidget * parent);
-public Q_SLOTS:
- void on_leftLW_itemActivated(QListWidgetItem *);
- void on_rightLW_itemActivated(QListWidgetItem *);
- void on_leftLW_currentRowChanged(int);
- void on_rightLW_currentRowChanged(int);
- void on_matchCB_stateChanged(int);
- void on_insertPB_clicked();
- void on_sizeCO_activated(int);
-private:
- ///
- char_type doMatch(char_type const symbol) const;
- ///
- void updateTeXCode(int size);
- /// owning form
- QMathDelimiter * form_;
- /// TeX code that will be inserted.
- QString tex_code_;
-};
-
-
-class QMathDelimiter : public QController<ControlMath, QView<QDelimiterDialog> > {
-public:
- friend class QDelimiterDialog;
-
- QMathDelimiter(Dialog &);
-
-private:
- virtual void apply() {}
- virtual void update_contents() {}
- /// Build the dialog.
- virtual void build_dialog();
-};
-
-
-} // namespace frontend
-} // namespace lyx
-
-#endif // QDELIMITERDIALOG_H
+++ /dev/null
-/**
- * \file QDialogView.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Angus Leeming
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "QDialogView.h"
-#include "Qt2BC.h"
-#include "qt_helpers.h"
-
-#include "controllers/ButtonController.h"
-
-
-namespace lyx {
-namespace frontend {
-
-QDialogView::QDialogView(Dialog & parent, docstring const & t)
- : Dialog::View(parent,t), updating_(false)
-{}
-
-
-Qt2BC & QDialogView::bcview()
-{
- return static_cast<Qt2BC &>(dialog().bc().view());
-}
-
-
-bool QDialogView::isVisible() const
-{
- return form() && form()->isVisible();
-}
-
-
-bool QDialogView::readOnly() const
-{
- return kernel().isBufferReadonly();
-}
-
-
-void QDialogView::show()
-{
- if (!form()) {
- build();
- }
-
- QSize const sizeHint = form()->sizeHint();
- if (sizeHint.height() >= 0 && sizeHint.width() >= 0)
- form()->setMinimumSize(sizeHint);
-
- update(); // make sure its up-to-date
- if (dialog().controller().exitEarly())
- return;
-
- form()->setWindowTitle(toqstr("LyX: " + getTitle()));
-
- if (form()->isVisible()) {
- form()->raise();
- form()->activateWindow();
- form()->setFocus();
- } else {
- form()->show();
- form()->setFocus();
- }
-}
-
-
-void QDialogView::hide()
-{
- if (form() && form()->isVisible())
- form()->hide();
-}
-
-
-bool QDialogView::isValid()
-{
- return true;
-}
-
-
-void QDialogView::changed()
-{
- if (updating_)
- return;
- bc().valid(isValid());
-}
-
-
-void QDialogView::slotWMHide()
-{
- dialog().CancelButton();
-}
-
-
-void QDialogView::slotApply()
-{
- dialog().ApplyButton();
-}
-
-
-void QDialogView::slotOK()
-{
- dialog().OKButton();
-}
-
-
-void QDialogView::slotClose()
-{
- dialog().CancelButton();
-}
-
-
-void QDialogView::slotRestore()
-{
- dialog().RestoreButton();
-}
-
-} // namespace frontend
-} // namespace lyx
-
-#include "QDialogView_moc.cpp"
+++ /dev/null
-// -*- C++ -*-
-/**
- * \file QDialogView.h
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Angus Leeming
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#ifndef QDIALOGVIEW_H
-#define QDIALOGVIEW_H
-
-#include "Dialog.h"
-
-#include <boost/scoped_ptr.hpp>
-
-#include <QApplication>
-#include <QWidget>
-#include <QObject>
-
-namespace lyx {
-namespace frontend {
-
-class Qt2BC;
-
-/** This class is an Qt2 GUI base class.
- */
-class QDialogView : public QObject, public Dialog::View {
- Q_OBJECT
-public:
- ///
- QDialogView(Dialog &, docstring const &);
- ///
- virtual ~QDialogView() {}
- ///
- bool readOnly() const;
-
- /// the dialog has changed contents
- virtual void changed();
-
- ///
- Qt2BC & bcview();
-
-protected:
- /// build the actual dialog
- virtual void build_dialog() = 0;
- ///
- virtual void build() = 0;
- /// Hide the dialog.
- virtual void hide();
- /// Create the dialog if necessary, update it and display it.
- virtual void show();
- /// update the dialog's contents
- virtual void update_contents() = 0;
- ///
- virtual bool isVisible() const;
-
- /// is the dialog currently valid ?
- virtual bool isValid();
-
- /// are we updating ?
- bool updating_;
-
-public Q_SLOTS:
- // dialog closed from WM
- void slotWMHide();
-
- // Restore button clicked
- void slotRestore();
-
- // OK button clicked
- void slotOK();
-
- // Apply button clicked
- void slotApply();
-
- // Close button clicked
- void slotClose();
-private:
- /// Pointer to the actual instantiation of the Qt dialog
- virtual QWidget * form() const = 0;
-};
-
-
-template <class GUIDialog>
-class QView: public QDialogView {
-protected:
- QView(Dialog & p, docstring const & t): QDialogView(p, t)
- {}
-
- virtual ~QView() {}
-
- /// update the dialog
- virtual void update() {
- dialog_->setUpdatesEnabled(false);
-
- // protect the BC from unwarranted state transitions
- updating_ = true;
- update_contents();
- updating_ = false;
-
- dialog_->setUpdatesEnabled(true);
- dialog_->update();
- }
-
- /// Build the dialog
- virtual void build() {
- // protect the BC from unwarranted state transitions
- updating_ = true;
- build_dialog();
- updating_ = false;
- }
-
- /// Pointer to the actual instantiation of the Qt dialog
- virtual GUIDialog * form() const { return dialog_.get(); }
-
- /// Real GUI implementation.
- boost::scoped_ptr<GUIDialog> dialog_;
-};
-
-
-template <class Controller, class Base>
-class QController: public Base
-{
-protected:
- ///
- QController(Dialog & p, docstring const & t): Base(p, t)
- {}
-public:
- /// The parent controller
- Controller & controller()
- { return static_cast<Controller &>(this->getController()); }
-
- /// The parent controller
- Controller const & controller() const
- { return static_cast<Controller const &>(this->getController()); }
-};
-
-} // namespace frontend
-} // namespace lyx
-
-#endif // QDIALOGVIEW_H
+++ /dev/null
-/**
- * \file QDocument.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Edwin Leuven
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "QDocument.h"
-
-#include "CheckedLineEdit.h"
-#include "FloatPlacement.h"
-#include "LengthCombo.h"
-#include "PanelStack.h"
-#include "Qt2BC.h"
-#include "qt_helpers.h"
-#include "Validator.h"
-
-// For the Branches module
-#include "QBranches.h"
-
-#include "QViewSource.h" // For latexHighlighter use in the preamble.
-
-#include "controllers/ControlDocument.h"
-
-#include "BufferParams.h"
-#include "Encoding.h"
-#include "gettext.h"
-#include "frontend_helpers.h" // getSecond()
-#include "Language.h"
-#include "LyXRC.h" // defaultUnit
-#include "TextClassList.h"
-#include "Spacing.h"
-
-#include "insets/InsetListingsParams.h"
-#include "controllers/ControlDocument.h"
-
-#include "support/lstrings.h"
-
-#include <QCloseEvent>
-#include <QScrollBar>
-#include <QTextCursor>
-
-#include <map>
-
-using lyx::support::token;
-using lyx::support::bformat;
-using lyx::support::findToken;
-using lyx::support::getVectorFromString;
-
-using std::distance;
-using std::make_pair;
-using std::pair;
-using std::vector;
-using std::string;
-
-
-char const * const tex_graphics[] = {"default", "dvips", "dvitops", "emtex",
- "ln", "oztex", "textures", "none", ""
-};
-
-
-char const * const tex_graphics_gui[] = {N_("Default"), "Dvips", "DVItoPS", "EmTeX",
- "LN", "OzTeX", "Textures", N_("None"), ""
-};
-
-
-char const * const tex_fonts_roman[] = {"default", "cmr", "lmodern", "ae", "times", "palatino",
- "charter", "newcent", "bookman", "utopia", "beraserif", "ccfonts", "chancery", ""
-};
-
-
-char const * tex_fonts_roman_gui[] = { N_("Default"), N_("Computer Modern Roman"), N_("Latin Modern Roman"),
- N_("AE (Almost European)"), N_("Times Roman"), N_("Palatino"), N_("Bitstream Charter"),
- N_("New Century Schoolbook"), N_("Bookman"), N_("Utopia"), N_("Bera Serif"),
- N_("Concrete Roman"), N_("Zapf Chancery"), ""
-};
-
-
-char const * const tex_fonts_sans[] = {"default", "cmss", "lmss", "helvet", "avant", "berasans", "cmbr", ""
-};
-
-
-char const * tex_fonts_sans_gui[] = { N_("Default"), N_("Computer Modern Sans"), N_("Latin Modern Sans"),
- N_("Helvetica"), N_("Avant Garde"), N_("Bera Sans"), N_("CM Bright"), ""
-};
-
-
-char const * const tex_fonts_monospaced[] = {"default", "cmtt", "lmtt", "courier", "beramono",
- "luximono", "cmtl", ""
-};
-
-
-char const * tex_fonts_monospaced_gui[] = { N_("Default"), N_("Computer Modern Typewriter"),
- N_("Latin Modern Typewriter"), N_("Courier"), N_("Bera Mono"), N_("LuxiMono"),
- N_("CM Typewriter Light"), ""
-};
-
-
-vector<pair<string, lyx::docstring> > pagestyles;
-
-
-namespace lyx {
-namespace frontend {
-
-/////////////////////////////////////////////////////////////////////
-//
-// PreambleModule
-//
-/////////////////////////////////////////////////////////////////////
-
-PreambleModule::PreambleModule(): current_id_(0)
-{
- // This is not a memory leak. The object will be destroyed
- // with this.
- (void) new LaTeXHighlighter(preambleTE->document());
- setFocusProxy(preambleTE);
- connect(preambleTE, SIGNAL(textChanged()), this, SIGNAL(changed()));
-}
-
-
-void PreambleModule::update(BufferParams const & params, BufferId id)
-{
- QString preamble = toqstr(params.preamble);
- // Nothing to do if the params and preamble are unchanged.
- if (id == current_id_
- && preamble == preambleTE->document()->toPlainText())
- return;
-
- QTextCursor cur = preambleTE->textCursor();
- // Save the coords before switching to the new one.
- preamble_coords_[current_id_] =
- 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.
- preamble_coords_[current_id_] = make_pair(0,0);
- 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();
- preamble_coords_[current_id_] =
- make_pair(cur.position(), preambleTE->verticalScrollBar()->value());
- e->accept();
-}
-
-
-/////////////////////////////////////////////////////////////////////
-//
-// DocumentDialog
-//
-/////////////////////////////////////////////////////////////////////
-
-QDocumentDialog::QDocumentDialog(QDocument * form)
- : form_(form),
- lang_(getSecond(getLanguageData(false)))
-{
- setupUi(this);
-
- connect(okPB, SIGNAL(clicked()), form, SLOT(slotOK()));
- connect(applyPB, SIGNAL(clicked()), form, SLOT(slotApply()));
- connect(closePB, SIGNAL(clicked()), form, SLOT(slotClose()));
- connect(restorePB, SIGNAL(clicked()), form, SLOT(slotRestore()));
-
- connect(savePB, SIGNAL(clicked()), this, SLOT(saveDefaultClicked()));
- connect(defaultPB, SIGNAL(clicked()), this, SLOT(useDefaultsClicked()));
-
- // Manage the restore, ok, apply, restore and cancel/close buttons
- form_->bcview().setOK(okPB);
- form_->bcview().setApply(applyPB);
- form_->bcview().setCancel(closePB);
- form_->bcview().setRestore(restorePB);
-
-
- textLayoutModule = new UiWidget<Ui::TextLayoutUi>;
- // text layout
- connect(textLayoutModule->lspacingCO, SIGNAL(activated(int)),
- this, SLOT(change_adaptor()));
- connect(textLayoutModule->lspacingCO, SIGNAL(activated(int)),
- this, SLOT(setLSpacing(int)));
- connect(textLayoutModule->lspacingLE, SIGNAL(textChanged(const QString&)),
- this, SLOT(change_adaptor()));
- connect(textLayoutModule->skipRB, SIGNAL(clicked()),
- this, SLOT(change_adaptor()));
- connect(textLayoutModule->indentRB, SIGNAL(clicked()),
- this, SLOT(change_adaptor()));
- connect(textLayoutModule->skipCO, SIGNAL(activated(int)),
- this, SLOT(change_adaptor()));
- connect(textLayoutModule->skipLE, SIGNAL(textChanged(const QString &)),
- this, SLOT(change_adaptor()));
- connect(textLayoutModule->skipLengthCO, SIGNAL(activated(int)),
- this, SLOT(change_adaptor()));
- connect(textLayoutModule->skipCO, SIGNAL(activated(int)),
- this, SLOT(setSkip(int)));
- connect(textLayoutModule->skipRB, SIGNAL(toggled(bool)),
- this, SLOT(enableSkip(bool)));
- connect(textLayoutModule->twoColumnCB, SIGNAL(clicked()),
- this, SLOT(change_adaptor()));
- connect(textLayoutModule->listingsED, SIGNAL(textChanged()),
- this, SLOT(change_adaptor()));
- connect(textLayoutModule->bypassCB, SIGNAL(clicked()),
- this, SLOT(change_adaptor()));
- connect(textLayoutModule->bypassCB, SIGNAL(clicked()),
- this, SLOT(set_listings_msg()));
- connect(textLayoutModule->listingsED, SIGNAL(textChanged()),
- this, SLOT(set_listings_msg()));
- textLayoutModule->listingsTB->setPlainText(
- qt_("Input listings parameters on the right. Enter ? for a list of parameters."));
- textLayoutModule->lspacingLE->setValidator(new QDoubleValidator(
- textLayoutModule->lspacingLE));
- textLayoutModule->skipLE->setValidator(unsignedLengthValidator(
- textLayoutModule->skipLE));
-
- textLayoutModule->skipCO->addItem(qt_("SmallSkip"));
- textLayoutModule->skipCO->addItem(qt_("MedSkip"));
- textLayoutModule->skipCO->addItem(qt_("BigSkip"));
- textLayoutModule->skipCO->addItem(qt_("Length"));
- // remove the %-items from the unit choice
- textLayoutModule->skipLengthCO->noPercents();
- 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
- addCheckedLineEdit(form_->bcview(), textLayoutModule->skipLE);
-
- fontModule = new UiWidget<Ui::FontUi>;
- // fonts
- 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)));
- connect(fontModule->fontsDefaultCO, SIGNAL(activated(int)),
- this, SLOT(change_adaptor()));
- connect(fontModule->fontsizeCO, SIGNAL(activated(int)),
- this, SLOT(change_adaptor()));
- 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()));
-
- for (int n = 0; tex_fonts_roman[n][0]; ++n) {
- QString font = qt_(tex_fonts_roman_gui[n]);
- if (!form_->controller().isFontAvailable(tex_fonts_roman[n]))
- font += qt_(" (not installed)");
- fontModule->fontsRomanCO->addItem(font);
- }
- for (int n = 0; tex_fonts_sans[n][0]; ++n) {
- QString font = qt_(tex_fonts_sans_gui[n]);
- if (!form_->controller().isFontAvailable(tex_fonts_sans[n]))
- font += qt_(" (not installed)");
- fontModule->fontsSansCO->addItem(font);
- }
- for (int n = 0; tex_fonts_monospaced[n][0]; ++n) {
- QString font = qt_(tex_fonts_monospaced_gui[n]);
- if (!form_->controller().isFontAvailable(tex_fonts_monospaced[n]))
- font += qt_(" (not installed)");
- fontModule->fontsTypewriterCO->addItem(font);
- }
-
- fontModule->fontsizeCO->addItem(qt_("Default"));
- fontModule->fontsizeCO->addItem(qt_("10"));
- fontModule->fontsizeCO->addItem(qt_("11"));
- fontModule->fontsizeCO->addItem(qt_("12"));
-
- for (int n = 0; ControlDocument::fontfamilies_gui[n][0]; ++n)
- fontModule->fontsDefaultCO->addItem(
- qt_(ControlDocument::fontfamilies_gui[n]));
-
-
- pageLayoutModule = new UiWidget<Ui::PageLayoutUi>;
- // page layout
- connect(pageLayoutModule->papersizeCO, SIGNAL(activated(int)),
- this, SLOT(setCustomPapersize(int)));
- connect(pageLayoutModule->papersizeCO, SIGNAL(activated(int)),
- this, SLOT(setCustomPapersize(int)));
- connect(pageLayoutModule->portraitRB, SIGNAL(clicked()),
- this, SLOT(portraitChanged()));
- 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()));
-
- pageLayoutModule->pagestyleCO->addItem(qt_("Default"));
- pageLayoutModule->pagestyleCO->addItem(qt_("empty"));
- pageLayoutModule->pagestyleCO->addItem(qt_("plain"));
- pageLayoutModule->pagestyleCO->addItem(qt_("headings"));
- pageLayoutModule->pagestyleCO->addItem(qt_("fancy"));
- addCheckedLineEdit(form_->bcview(), pageLayoutModule->paperheightLE,
- pageLayoutModule->paperheightL);
- addCheckedLineEdit(form_->bcview(), pageLayoutModule->paperwidthLE,
- pageLayoutModule->paperwidthL);
-
- // paper
- 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"));
- cb->addItem(qt_("A3"));
- cb->addItem(qt_("A4"));
- cb->addItem(qt_("A5"));
- cb->addItem(qt_("B3"));
- cb->addItem(qt_("B4"));
- cb->addItem(qt_("B5"));
- // 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));
-
-
-
-
- marginsModule = new UiWidget<Ui::MarginsUi>;
- // margins
- connect(marginsModule->marginCB, SIGNAL(toggled(bool)),
- this, SLOT(setCustomMargins(bool)));
- connect(marginsModule->marginCB, SIGNAL(clicked()),
- this, SLOT(change_adaptor()));
- connect(marginsModule->topLE, SIGNAL(textChanged(const QString &)),
- this, SLOT(change_adaptor()));
- connect(marginsModule->topUnit, SIGNAL(activated(int)),
- this, SLOT(change_adaptor()));
- connect(marginsModule->bottomLE, SIGNAL(textChanged(const QString &)),
- this, SLOT(change_adaptor()));
- connect(marginsModule->bottomUnit, SIGNAL(activated(int)),
- this, SLOT(change_adaptor()));
- connect(marginsModule->innerLE, SIGNAL(textChanged(const QString &)),
- this, SLOT(change_adaptor()));
- connect(marginsModule->innerUnit, SIGNAL(activated(int)),
- this, SLOT(change_adaptor()));
- connect(marginsModule->outerLE, SIGNAL(textChanged(const QString &)),
- this, SLOT(change_adaptor()));
- connect(marginsModule->outerUnit, SIGNAL(activated(int)),
- this, SLOT(change_adaptor()));
- connect(marginsModule->headheightLE, SIGNAL(textChanged(const QString &)),
- this, SLOT(change_adaptor()));
- connect(marginsModule->headheightUnit, SIGNAL(activated(int)),
- this, SLOT(change_adaptor()));
- connect(marginsModule->headsepLE, SIGNAL(textChanged(const QString &)),
- this, SLOT(change_adaptor()));
- connect(marginsModule->headsepUnit, SIGNAL(activated(int)),
- this, SLOT(change_adaptor()));
- connect(marginsModule->footskipLE, SIGNAL(textChanged(const QString&)),
- this, SLOT(change_adaptor()));
- connect(marginsModule->footskipUnit, SIGNAL(activated(int)),
- this, SLOT(change_adaptor()));
- 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));
-
- addCheckedLineEdit(form_->bcview(), marginsModule->topLE,
- marginsModule->topL);
- addCheckedLineEdit(form_->bcview(), marginsModule->bottomLE,
- marginsModule->bottomL);
- addCheckedLineEdit(form_->bcview(), marginsModule->innerLE,
- marginsModule->innerL);
- addCheckedLineEdit(form_->bcview(), marginsModule->outerLE,
- marginsModule->outerL);
- addCheckedLineEdit(form_->bcview(), marginsModule->headsepLE,
- marginsModule->headsepL);
- addCheckedLineEdit(form_->bcview(), marginsModule->headheightLE,
- marginsModule->headheightL);
- addCheckedLineEdit(form_->bcview(), marginsModule->footskipLE,
- marginsModule->footskipL);
-
-
- langModule = new UiWidget<Ui::LanguageUi>;
- connect(langModule->defaultencodingCB, SIGNAL(toggled(bool)),
- langModule->encodingL, SLOT(setDisabled(bool)));
- connect(langModule->defaultencodingCB, SIGNAL(toggled(bool)),
- langModule->encodingCO, SLOT(setDisabled(bool)));
- // language & quote
- connect(langModule->languageCO, SIGNAL(activated(int)),
- this, SLOT(change_adaptor()));
- connect(langModule->defaultencodingCB, SIGNAL(clicked()),
- this, SLOT(change_adaptor()));
- connect(langModule->encodingCO, SIGNAL(activated(int)),
- this, SLOT(change_adaptor()));
- connect(langModule->quoteStyleCO, SIGNAL(activated(int)),
- this, SLOT(change_adaptor()));
- // language & quotes
- vector<LanguagePair> const langs = getLanguageData(false);
- vector<LanguagePair>::const_iterator lit = langs.begin();
- vector<LanguagePair>::const_iterator lend = langs.end();
- for (; lit != lend; ++lit) {
- langModule->languageCO->addItem(
- toqstr(lit->first));
- }
-
- // Always put the default encoding in the first position.
- // It is special because the displayed text is translated.
- langModule->encodingCO->addItem(qt_("LaTeX default"));
- Encodings::const_iterator it = encodings.begin();
- Encodings::const_iterator const end = encodings.end();
- for (; it != end; ++it)
- langModule->encodingCO->addItem(toqstr(it->latexName()));
-
- langModule->quoteStyleCO->addItem(qt_("``text''"));
- langModule->quoteStyleCO->addItem(qt_("''text''"));
- langModule->quoteStyleCO->addItem(qt_(",,text``"));
- langModule->quoteStyleCO->addItem(qt_(",,text''"));
- langModule->quoteStyleCO->addItem(qt_("<<text>>"));
- langModule->quoteStyleCO->addItem(qt_(">>text<<"));
-
-
-
- numberingModule = new UiWidget<Ui::NumberingUi>;
- // numbering
- 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()));
- 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"));
-
-
- biblioModule = new UiWidget<Ui::BiblioUi>;
- connect(biblioModule->citeNatbibRB, SIGNAL(toggled(bool)),
- biblioModule->citationStyleL, SLOT(setEnabled(bool)));
- connect(biblioModule->citeNatbibRB, SIGNAL(toggled(bool)),
- biblioModule->citeStyleCO, SLOT(setEnabled(bool)));
- // biblio
- connect(biblioModule->citeDefaultRB, SIGNAL(clicked()),
- this, SLOT(change_adaptor()));
- connect(biblioModule->citeNatbibRB, SIGNAL(clicked()),
- this, SLOT(change_adaptor()));
- connect(biblioModule->citeStyleCO, SIGNAL(activated(int)),
- this, SLOT(change_adaptor()));
- connect(biblioModule->citeJurabibRB, SIGNAL(clicked()),
- this, SLOT(change_adaptor()));
- connect(biblioModule->bibtopicCB, SIGNAL(clicked()),
- this, SLOT(change_adaptor()));
- // biblio
- biblioModule->citeStyleCO->addItem(qt_("Author-year"));
- biblioModule->citeStyleCO->addItem(qt_("Numerical"));
- biblioModule->citeStyleCO->setCurrentIndex(0);
-
-
-
- mathsModule = new UiWidget<Ui::MathsUi>;
- connect(mathsModule->amsautoCB, SIGNAL(toggled(bool)),
- mathsModule->amsCB, SLOT(setDisabled(bool)));
- connect(mathsModule->esintautoCB, SIGNAL(toggled(bool)),
- mathsModule->esintCB, SLOT(setDisabled(bool)));
- // maths
- connect(mathsModule->amsCB, SIGNAL(clicked()),
- this, SLOT(change_adaptor()));
- connect(mathsModule->amsautoCB, SIGNAL(clicked()),
- this, SLOT(change_adaptor()));
- connect(mathsModule->esintCB, SIGNAL(clicked()),
- this, SLOT(change_adaptor()));
- connect(mathsModule->esintautoCB, SIGNAL(clicked()),
- this, SLOT(change_adaptor()));
-
- latexModule = new UiWidget<Ui::LaTeXUi>;
- // latex class
- connect(latexModule->classCO, SIGNAL(activated(int)),
- this, SLOT(change_adaptor()));
- connect(latexModule->optionsLE, SIGNAL(textChanged(const QString &)),
- this, SLOT(change_adaptor()));
- connect(latexModule->psdriverCO, SIGNAL(activated(int)),
- this, SLOT(change_adaptor()));
- connect(latexModule->classCO, SIGNAL(activated(int)),
- this, SLOT(classChanged()));
- // packages
- for (int n = 0; tex_graphics[n][0]; ++n) {
- QString enc = qt_(tex_graphics_gui[n]);
- latexModule->psdriverCO->addItem(enc);
- }
- // latex
- for (TextClassList::const_iterator cit = textclasslist.begin();
- cit != textclasslist.end(); ++cit) {
- if (cit->isTeXClassAvailable()) {
- latexModule->classCO->addItem(toqstr(cit->description()));
- } else {
- docstring item =
- bformat(_("Unavailable: %1$s"), from_utf8(cit->description()));
- latexModule->classCO->addItem(toqstr(item));
- }
- }
-
- // branches
- branchesModule = new QBranches;
- connect(branchesModule, SIGNAL(changed()),
- this, SLOT(change_adaptor()));
-
- // preamble
- preambleModule = new PreambleModule;
- connect(preambleModule, SIGNAL(changed()),
- this, SLOT(change_adaptor()));
-
- // bullets
- bulletsModule = new BulletsModule;
- connect(bulletsModule, SIGNAL(changed()),
- this, SLOT(change_adaptor()));
-
-
- // float
- floatModule = new FloatPlacement;
- connect(floatModule, SIGNAL(changed()),
- this, SLOT(change_adaptor()));
-
- docPS->addPanel(latexModule, _("Document Class"));
- docPS->addPanel(fontModule, _("Fonts"));
- docPS->addPanel(textLayoutModule, _("Text Layout"));
- docPS->addPanel(pageLayoutModule, _("Page Layout"));
- docPS->addPanel(marginsModule, _("Page Margins"));
- docPS->addPanel(langModule, _("Language"));
- docPS->addPanel(numberingModule, _("Numbering & TOC"));
- docPS->addPanel(biblioModule, _("Bibliography"));
- docPS->addPanel(mathsModule, _("Math Options"));
- docPS->addPanel(floatModule, _("Float Placement"));
- docPS->addPanel(bulletsModule, _("Bullets"));
- docPS->addPanel(branchesModule, _("Branches"));
- docPS->addPanel(preambleModule, _("LaTeX Preamble"));
- docPS->setCurrentPanel(_("Document Class"));
-// 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
-}
-
-
-void QDocumentDialog::showPreamble()
-{
- docPS->setCurrentPanel(_("LaTeX Preamble"));
-}
-
-
-void QDocumentDialog::saveDefaultClicked()
-{
- form_->saveDocDefault();
-}
-
-
-void QDocumentDialog::useDefaultsClicked()
-{
- form_->useClassDefaults();
-}
-
-
-void QDocumentDialog::change_adaptor()
-{
- form_->changed();
-}
-
-
-docstring QDocumentDialog::validate_listings_params()
-{
- // use a cache here to avoid repeated validation
- // of the same parameters
- static string param_cache = string();
- static docstring msg_cache = docstring();
-
- if (textLayoutModule->bypassCB->isChecked())
- return docstring();
-
- string params = fromqstr(textLayoutModule->listingsED->toPlainText());
- if (params != param_cache) {
- param_cache = params;
- msg_cache = InsetListingsParams(params).validate();
- }
- return msg_cache;
-}
-
-
-void QDocumentDialog::set_listings_msg()
-{
- static bool isOK = true;
- docstring msg = validate_listings_params();
- if (msg.empty()) {
- if (isOK)
- return;
- isOK = true;
- // listingsTB->setTextColor("black");
- textLayoutModule->listingsTB->setPlainText(
- qt_("Input listings parameters on the right. Enter ? for a list of parameters."));
- } else {
- isOK = false;
- // listingsTB->setTextColor("red");
- textLayoutModule->listingsTB->setPlainText(toqstr(msg));
- }
-}
-
-
-void QDocumentDialog::closeEvent(QCloseEvent * e)
-{
- form_->slotWMHide();
- e->accept();
-}
-
-
-void QDocumentDialog::setLSpacing(int item)
-{
- textLayoutModule->lspacingLE->setEnabled(item == 3);
-}
-
-
-void QDocumentDialog::setSkip(int item)
-{
- bool const enable = (item == 3);
- textLayoutModule->skipLE->setEnabled(enable);
- textLayoutModule->skipLengthCO->setEnabled(enable);
-}
-
-
-void QDocumentDialog::enableSkip(bool skip)
-{
- textLayoutModule->skipCO->setEnabled(skip);
- textLayoutModule->skipLE->setEnabled(skip);
- textLayoutModule->skipLengthCO->setEnabled(skip);
- if (skip)
- setSkip(textLayoutModule->skipCO->currentIndex());
-}
-
-void QDocumentDialog::portraitChanged()
-{
- setMargins(pageLayoutModule->papersizeCO->currentIndex());
-}
-
-void QDocumentDialog::setMargins(bool custom)
-{
- marginsModule->marginCB->setChecked(custom);
- setCustomMargins(custom);
-}
-
-
-void QDocumentDialog::setCustomPapersize(int papersize)
-{
- bool const custom = (papersize == 1);
-
- 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);
-}
-
-
-void QDocumentDialog::setCustomMargins(bool custom)
-{
- 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);
-}
-
-
-void QDocumentDialog::updateFontsize(string const & items, string const & sel)
-{
- fontModule->fontsizeCO->clear();
- fontModule->fontsizeCO->addItem(qt_("Default"));
-
- 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;
- }
- }
-}
-
-
-void QDocumentDialog::romanChanged(int item)
-{
- string const font = tex_fonts_roman[item];
-
- fontModule->fontScCB->setEnabled(
- form_->controller().providesSC(font));
- fontModule->fontOsfCB->setEnabled(
- form_->controller().providesOSF(font));
-}
-
-
-void QDocumentDialog::sansChanged(int item)
-{
- string const font = tex_fonts_sans[item];
- bool scaleable = form_->controller().providesScale(font);
- fontModule->scaleSansSB->setEnabled(scaleable);
- fontModule->scaleSansLA->setEnabled(scaleable);
-}
-
-
-void QDocumentDialog::ttChanged(int item)
-{
- string const font = tex_fonts_monospaced[item];
- bool scaleable = form_->controller().providesScale(font);
- fontModule->scaleTypewriterSB->setEnabled(scaleable);
- fontModule->scaleTypewriterLA->setEnabled(scaleable);
-}
-
-
-void QDocumentDialog::updatePagestyle(string const & items, string const & sel)
-{
- pagestyles.clear();
- pageLayoutModule->pagestyleCO->clear();
- pageLayoutModule->pagestyleCO->addItem(qt_("Default"));
-
- for (int n = 0; !token(items,'|',n).empty(); ++n) {
- string style = token(items, '|', n);
- docstring style_gui = _(style);
- pagestyles.push_back(pair<string, docstring>(style, style_gui));
- pageLayoutModule->pagestyleCO->addItem(toqstr(style_gui));
- }
-
- if (sel == "default") {
- pageLayoutModule->pagestyleCO->setCurrentIndex(0);
- return;
- }
-
- int n = 0;
-
- for (size_t i = 0; i < pagestyles.size(); ++i)
- if (pagestyles[i].first == sel)
- n = pageLayoutModule->pagestyleCO->findText(
- toqstr(pagestyles[i].second));
-
- if (n > 0)
- pageLayoutModule->pagestyleCO->setCurrentIndex(n);
-}
-
-
-void QDocumentDialog::classChanged()
-{
- ControlDocument & cntrl = form_->controller();
- BufferParams & params = cntrl.params();
-
- textclass_type const tc = latexModule->classCO->currentIndex();
-
- if (form_->controller().loadTextclass(tc)) {
- params.setJustBaseClass(tc);
- if (lyxrc.auto_reset_options)
- params.useClassDefaults();
- form_->update_contents();
- } else {
- latexModule->classCO->setCurrentIndex(params.getBaseClass());
- }
-}
-
-
-void QDocumentDialog::updateNumbering()
-{
- TextClass const & tclass =
- form_->controller().params().getTextClass();
-
- 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");
- TextClass::const_iterator end = tclass.end();
- TextClass::const_iterator cit = tclass.begin();
- QTreeWidgetItem * item = 0;
- for ( ; cit != end ; ++cit) {
- int const toclevel = (*cit)->toclevel;
- if (toclevel != Layout::NOT_IN_TOC
- && (*cit)->labeltype == LABEL_COUNTER) {
- item = new QTreeWidgetItem(numberingModule->tocTW);
- item->setText(0, toqstr(translateIfPossible((*cit)->name())));
- item->setText(1, (toclevel <= depth) ? yes : no);
- item->setText(2, (toclevel <= toc) ? yes : no);
- }
- }
-
- numberingModule->tocTW->setUpdatesEnabled(true);
- numberingModule->tocTW->update();
-}
-
-void QDocumentDialog::apply(BufferParams & params)
-{
- // preamble
- preambleModule->apply(params);
-
- // biblio
- params.setCiteEngine(biblio::ENGINE_BASIC);
-
- if (biblioModule->citeNatbibRB->isChecked()) {
- bool const use_numerical_citations =
- biblioModule->citeStyleCO->currentIndex();
- if (use_numerical_citations)
- params.setCiteEngine(biblio::ENGINE_NATBIB_NUMERICAL);
- else
- params.setCiteEngine(biblio::ENGINE_NATBIB_AUTHORYEAR);
-
- } else if (biblioModule->citeJurabibRB->isChecked())
- params.setCiteEngine(biblio::ENGINE_JURABIB);
-
- params.use_bibtopic =
- biblioModule->bibtopicCB->isChecked();
-
- // language & quotes
- if (langModule->defaultencodingCB->isChecked()) {
- params.inputenc = "auto";
- } else {
- int i = langModule->encodingCO->currentIndex();
- if (i == 0)
- params.inputenc = "default";
- else
- params.inputenc =
- fromqstr(langModule->encodingCO->currentText());
- }
-
- InsetQuotes::quote_language lga = InsetQuotes::EnglishQ;
- switch (langModule->quoteStyleCO->currentIndex()) {
- case 0:
- lga = InsetQuotes::EnglishQ;
- break;
- case 1:
- lga = InsetQuotes::SwedishQ;
- break;
- case 2:
- lga = InsetQuotes::GermanQ;
- break;
- case 3:
- lga = InsetQuotes::PolishQ;
- break;
- case 4:
- lga = InsetQuotes::FrenchQ;
- break;
- case 5:
- lga = InsetQuotes::DanishQ;
- break;
- }
- params.quotes_language = lga;
-
- int const pos = langModule->languageCO->currentIndex();
- params.language = lyx::languages.getLanguage(lang_[pos]);
-
- // numbering
- if (params.getTextClass().hasTocLevels()) {
- params.tocdepth = numberingModule->tocSL->value();
- params.secnumdepth = numberingModule->depthSL->value();
- }
-
- // bullets
- params.user_defined_bullet(0) = bulletsModule->getBullet(0);
- params.user_defined_bullet(1) = bulletsModule->getBullet(1);
- params.user_defined_bullet(2) = bulletsModule->getBullet(2);
- params.user_defined_bullet(3) = bulletsModule->getBullet(3);
-
- // packages
- params.graphicsDriver =
- tex_graphics[latexModule->psdriverCO->currentIndex()];
-
- if (mathsModule->amsautoCB->isChecked()) {
- params.use_amsmath = BufferParams::package_auto;
- } else {
- if (mathsModule->amsCB->isChecked())
- params.use_amsmath = BufferParams::package_on;
- else
- params.use_amsmath = BufferParams::package_off;
- }
-
- if (mathsModule->esintautoCB->isChecked())
- params.use_esint = BufferParams::package_auto;
- else {
- if (mathsModule->esintCB->isChecked())
- params.use_esint = BufferParams::package_on;
- else
- params.use_esint = BufferParams::package_off;
- }
-
- // text layout
- params.setJustBaseClass(latexModule->classCO->currentIndex());
-
- if (pageLayoutModule->pagestyleCO->currentIndex() == 0)
- params.pagestyle = "default";
- else {
- docstring style_gui =
- qstring_to_ucs4(pageLayoutModule->pagestyleCO->currentText());
- for (size_t i = 0; i < pagestyles.size(); ++i)
- if (pagestyles[i].second == style_gui)
- params.pagestyle = pagestyles[i].first;
- }
-
- switch (textLayoutModule->lspacingCO->currentIndex()) {
- case 0:
- params.spacing().set(Spacing::Single);
- break;
- case 1:
- params.spacing().set(Spacing::Onehalf);
- break;
- case 2:
- params.spacing().set(Spacing::Double);
- break;
- case 3:
- params.spacing().set(Spacing::Other,
- fromqstr(textLayoutModule->lspacingLE->text()));
- break;
- }
-
- if (textLayoutModule->twoColumnCB->isChecked())
- params.columns = 2;
- else
- params.columns = 1;
-
- // text should have passed validation
- params.listings_params =
- InsetListingsParams(fromqstr(textLayoutModule->listingsED->toPlainText())).params();
-
- if (textLayoutModule->indentRB->isChecked())
- params.paragraph_separation = BufferParams::PARSEP_INDENT;
- else
- params.paragraph_separation = BufferParams::PARSEP_SKIP;
-
- switch (textLayoutModule->skipCO->currentIndex()) {
- case 0:
- params.setDefSkip(VSpace(VSpace::SMALLSKIP));
- break;
- case 1:
- params.setDefSkip(VSpace(VSpace::MEDSKIP));
- break;
- case 2:
- params.setDefSkip(VSpace(VSpace::BIGSKIP));
- break;
- case 3:
- {
- VSpace vs = VSpace(
- widgetsToLength(textLayoutModule->skipLE,
- textLayoutModule->skipLengthCO)
- );
- params.setDefSkip(vs);
- break;
- }
- default:
- // DocumentDefskipCB assures that this never happens
- // so Assert then !!! - jbl
- params.setDefSkip(VSpace(VSpace::MEDSKIP));
- break;
- }
-
- params.options =
- fromqstr(latexModule->optionsLE->text());
-
- params.float_placement = floatModule->get();
-
- // fonts
- params.fontsRoman =
- tex_fonts_roman[fontModule->fontsRomanCO->currentIndex()];
-
- params.fontsSans =
- tex_fonts_sans[fontModule->fontsSansCO->currentIndex()];
-
- params.fontsTypewriter =
- tex_fonts_monospaced[fontModule->fontsTypewriterCO->currentIndex()];
-
- params.fontsSansScale = fontModule->scaleSansSB->value();
-
- params.fontsTypewriterScale = fontModule->scaleTypewriterSB->value();
-
- params.fontsSC = fontModule->fontScCB->isChecked();
-
- params.fontsOSF = fontModule->fontOsfCB->isChecked();
-
- params.fontsDefaultFamily = ControlDocument::fontfamilies[
- fontModule->fontsDefaultCO->currentIndex()];
-
- if (fontModule->fontsizeCO->currentIndex() == 0)
- params.fontsize = "default";
- else
- params.fontsize =
- fromqstr(fontModule->fontsizeCO->currentText());
-
- // paper
- params.papersize = PAPER_SIZE(
- pageLayoutModule->papersizeCO->currentIndex());
-
- // custom, A3, B3 and B4 paper sizes need geometry
- int psize = pageLayoutModule->papersizeCO->currentIndex();
- bool geom_papersize = (psize == 1 || psize == 5 || psize == 8 || psize == 9);
-
- params.paperwidth = widgetsToLength(pageLayoutModule->paperwidthLE,
- pageLayoutModule->paperwidthUnitCO);
-
- params.paperheight = widgetsToLength(pageLayoutModule->paperheightLE,
- pageLayoutModule->paperheightUnitCO);
-
- if (pageLayoutModule->facingPagesCB->isChecked())
- params.sides = TextClass::TwoSides;
- else
- params.sides = TextClass::OneSide;
-
- if (pageLayoutModule->landscapeRB->isChecked())
- params.orientation = ORIENTATION_LANDSCAPE;
- else
- params.orientation = ORIENTATION_PORTRAIT;
-
- // margins
- params.use_geometry =
- (!marginsModule->marginCB->isChecked()
- || geom_papersize);
-
- Ui::MarginsUi const * m(marginsModule);
-
- params.leftmargin = widgetsToLength(m->innerLE, m->innerUnit);
-
- params.topmargin = widgetsToLength(m->topLE, m->topUnit);
-
- params.rightmargin = widgetsToLength(m->outerLE, m->outerUnit);
-
- params.bottommargin = widgetsToLength(m->bottomLE, m->bottomUnit);
-
- params.headheight = widgetsToLength(m->headheightLE, m->headheightUnit);
-
- params.headsep = widgetsToLength(m->headsepLE, m->headsepUnit);
-
- params.footskip = widgetsToLength(m->footskipLE, m->footskipUnit);
-
- branchesModule->apply(params);
-}
-
-namespace {
-
-/** Return the position of val in the vector if found.
- If not found, return 0.
- */
-template<class A>
-typename std::vector<A>::size_type
-findPos(std::vector<A> const & vec, A const & val)
-{
- typename std::vector<A>::const_iterator it =
- std::find(vec.begin(), vec.end(), val);
- if (it == vec.end())
- return 0;
- return distance(vec.begin(), it);
-}
-
-} // namespace anom
-
-
-void QDocumentDialog::updateParams(BufferParams const & params)
-{
- // set the default unit
- // FIXME: move to controller
- Length::UNIT defaultUnit = Length::CM;
- switch (lyxrc.default_papersize) {
- case PAPER_DEFAULT: break;
-
- case PAPER_USLETTER:
- case PAPER_USLEGAL:
- case PAPER_USEXECUTIVE:
- defaultUnit = Length::IN;
- break;
-
- case PAPER_A3:
- case PAPER_A4:
- case PAPER_A5:
- case PAPER_B3:
- case PAPER_B4:
- case PAPER_B5:
- defaultUnit = Length::CM;
- break;
- case PAPER_CUSTOM:
- break;
- }
-
- // preamble
- preambleModule->update(params, form_->controller().id());
-
- // biblio
- biblioModule->citeDefaultRB->setChecked(
- params.getEngine() == biblio::ENGINE_BASIC);
-
- biblioModule->citeNatbibRB->setChecked(
- params.getEngine() == biblio::ENGINE_NATBIB_NUMERICAL ||
- params.getEngine() == biblio::ENGINE_NATBIB_AUTHORYEAR);
-
- biblioModule->citeStyleCO->setCurrentIndex(
- params.getEngine() == biblio::ENGINE_NATBIB_NUMERICAL);
-
- biblioModule->citeJurabibRB->setChecked(
- params.getEngine() == biblio::ENGINE_JURABIB);
-
- biblioModule->bibtopicCB->setChecked(
- params.use_bibtopic);
-
- // language & quotes
- int const pos = int(findPos(lang_,
- params.language->lang()));
- langModule->languageCO->setCurrentIndex(pos);
-
- langModule->quoteStyleCO->setCurrentIndex(
- params.quotes_language);
-
- langModule->defaultencodingCB->setChecked(true);
-
- if (params.inputenc != "auto") {
- langModule->defaultencodingCB->setChecked(false);
- if (params.inputenc == "default") {
- langModule->encodingCO->setCurrentIndex(0);
- } else {
- int const i = langModule->encodingCO->findText(
- toqstr(params.inputenc));
- if (i >= 0)
- langModule->encodingCO->setCurrentIndex(i);
- else
- // unknown encoding. Set to default.
- langModule->defaultencodingCB->setChecked(true);
- }
- }
-
- // numbering
- int const min_toclevel = form_->controller().textClass().min_toclevel();
- int const max_toclevel = form_->controller().textClass().max_toclevel();
- if (form_->controller().textClass().hasTocLevels()) {
- numberingModule->setEnabled(true);
- numberingModule->depthSL->setMinimum(min_toclevel - 1);
- numberingModule->depthSL->setMaximum(max_toclevel);
- numberingModule->depthSL->setValue(params.secnumdepth);
- numberingModule->tocSL->setMaximum(min_toclevel - 1);
- numberingModule->tocSL->setMaximum(max_toclevel);
- numberingModule->tocSL->setValue(params.tocdepth);
- updateNumbering();
- } else {
- numberingModule->setEnabled(false);
- numberingModule->tocTW->clear();
- }
-
- // bullets
- bulletsModule->setBullet(0, params.user_defined_bullet(0));
- bulletsModule->setBullet(1, params.user_defined_bullet(1));
- bulletsModule->setBullet(2, params.user_defined_bullet(2));
- bulletsModule->setBullet(3, params.user_defined_bullet(3));
- bulletsModule->init();
-
- // packages
- int nitem = findToken(tex_graphics, params.graphicsDriver);
- if (nitem >= 0)
- latexModule->psdriverCO->setCurrentIndex(nitem);
-
- mathsModule->amsCB->setChecked(
- params.use_amsmath == BufferParams::package_on);
- mathsModule->amsautoCB->setChecked(
- params.use_amsmath == BufferParams::package_auto);
-
- mathsModule->esintCB->setChecked(
- params.use_esint == BufferParams::package_on);
- mathsModule->esintautoCB->setChecked(
- params.use_esint == BufferParams::package_auto);
-
- switch (params.spacing().getSpace()) {
- 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
- latexModule->classCO->setCurrentIndex(params.getBaseClass());
-
- updatePagestyle(form_->controller().textClass().opt_pagestyle(),
- params.pagestyle);
-
- textLayoutModule->lspacingCO->setCurrentIndex(nitem);
- if (params.spacing().getSpace() == Spacing::Other) {
- textLayoutModule->lspacingLE->setText(
- toqstr(params.spacing().getValueAsString()));
- }
- setLSpacing(nitem);
-
- if (params.paragraph_separation
- == BufferParams::PARSEP_INDENT) {
- textLayoutModule->indentRB->setChecked(true);
- } else {
- textLayoutModule->skipRB->setChecked(true);
- }
-
- int skip = 0;
- switch (params.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 = params.getDefSkip().asLyXCommand();
- lengthToWidgets(textLayoutModule->skipLE,
- textLayoutModule->skipLengthCO,
- length, defaultUnit);
- break;
- }
- default:
- skip = 0;
- break;
- }
- textLayoutModule->skipCO->setCurrentIndex(skip);
- setSkip(skip);
-
- textLayoutModule->twoColumnCB->setChecked(
- params.columns == 2);
-
- // break listings_params to multiple lines
- string lstparams =
- InsetListingsParams(params.listings_params).separatedParams();
- textLayoutModule->listingsED->setPlainText(toqstr(lstparams));
-
- if (!params.options.empty()) {
- latexModule->optionsLE->setText(
- toqstr(params.options));
- } else {
- latexModule->optionsLE->setText("");
- }
-
- floatModule->set(params.float_placement);
-
- //fonts
- updateFontsize(form_->controller().textClass().opt_fontsize(),
- params.fontsize);
-
- int n = findToken(tex_fonts_roman, params.fontsRoman);
- if (n >= 0) {
- fontModule->fontsRomanCO->setCurrentIndex(n);
- romanChanged(n);
- }
-
- n = findToken(tex_fonts_sans, params.fontsSans);
- if (n >= 0) {
- fontModule->fontsSansCO->setCurrentIndex(n);
- sansChanged(n);
- }
-
- n = findToken(tex_fonts_monospaced, params.fontsTypewriter);
- if (n >= 0) {
- fontModule->fontsTypewriterCO->setCurrentIndex(n);
- ttChanged(n);
- }
-
- fontModule->fontScCB->setChecked(params.fontsSC);
- fontModule->fontOsfCB->setChecked(params.fontsOSF);
- fontModule->scaleSansSB->setValue(params.fontsSansScale);
- fontModule->scaleTypewriterSB->setValue(params.fontsTypewriterScale);
- n = findToken(ControlDocument::fontfamilies, params.fontsDefaultFamily);
- if (n >= 0)
- fontModule->fontsDefaultCO->setCurrentIndex(n);
-
- // paper
- int const psize = params.papersize;
- pageLayoutModule->papersizeCO->setCurrentIndex(psize);
- setCustomPapersize(psize);
-
- bool const landscape =
- params.orientation == ORIENTATION_LANDSCAPE;
- pageLayoutModule->landscapeRB->setChecked(landscape);
- pageLayoutModule->portraitRB->setChecked(!landscape);
-
- pageLayoutModule->facingPagesCB->setChecked(
- params.sides == TextClass::TwoSides);
-
-
- lengthToWidgets(pageLayoutModule->paperwidthLE,
- pageLayoutModule->paperwidthUnitCO, params.paperwidth, defaultUnit);
-
- lengthToWidgets(pageLayoutModule->paperheightLE,
- pageLayoutModule->paperheightUnitCO, params.paperheight, defaultUnit);
-
- // margins
- Ui::MarginsUi * m = marginsModule;
-
- setMargins(!params.use_geometry);
-
- lengthToWidgets(m->topLE, m->topUnit,
- params.topmargin, defaultUnit);
-
- lengthToWidgets(m->bottomLE, m->bottomUnit,
- params.bottommargin, defaultUnit);
-
- lengthToWidgets(m->innerLE, m->innerUnit,
- params.leftmargin, defaultUnit);
-
- lengthToWidgets(m->outerLE, m->outerUnit,
- params.rightmargin, defaultUnit);
-
- lengthToWidgets(m->headheightLE, m->headheightUnit,
- params.headheight, defaultUnit);
-
- lengthToWidgets(m->headsepLE, m->headsepUnit,
- params.headsep, defaultUnit);
-
- lengthToWidgets(m->footskipLE, m->footskipUnit,
- params.footskip, defaultUnit);
-
- branchesModule->update(params);
-}
-
-
-/////////////////////////////////////////////////////////////////////
-//
-// Document
-//
-/////////////////////////////////////////////////////////////////////
-
-typedef QController<ControlDocument, QView<QDocumentDialog> >
- DocumentBase;
-
-
-QDocument::QDocument(Dialog & parent)
- : DocumentBase(parent, _("Document Settings"))
-{}
-
-
-void QDocument::build_dialog()
-{
- dialog_.reset(new QDocumentDialog(this));
-}
-
-
-void QDocument::showPreamble()
-{
- dialog_->showPreamble();
-}
-
-
-void QDocument::apply()
-{
- if (!dialog_.get())
- return;
-
- dialog_->apply(controller().params());
-}
-
-
-void QDocument::update_contents()
-{
- if (!dialog_.get())
- return;
-
- dialog_->updateParams(controller().params());
-}
-
-void QDocument::saveDocDefault()
-{
- // we have to apply the params first
- apply();
- controller().saveAsDefault();
-}
-
-
-void QDocument::useClassDefaults()
-{
- BufferParams & params = controller().params();
-
- params.setJustBaseClass(dialog_->latexModule->classCO->currentIndex());
-
- params.useClassDefaults();
- update_contents();
-}
-
-
-bool QDocument::isValid()
-{
- return dialog_->validate_listings_params().empty();
-}
-
-
-} // namespace frontend
-} // namespace lyx
-
-#include "QDocument_moc.cpp"
+++ /dev/null
-// -*- C++ -*-
-/**
- * \file QDocument.h
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Edwin Leuven
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#ifndef QDOCUMENT_H
-#define QDOCUMENT_H
-
-#include "QDialogView.h"
-#include "BulletsModule.h"
-
-#include "ui_DocumentUi.h"
-#include "ui_FontUi.h"
-#include "ui_TextLayoutUi.h"
-#include "ui_MathsUi.h"
-#include "ui_LaTeXUi.h"
-#include "ui_PageLayoutUi.h"
-#include "ui_LanguageUi.h"
-#include "ui_BiblioUi.h"
-#include "ui_NumberingUi.h"
-#include "ui_MarginsUi.h"
-
-// For the Preamble module
-#include "ui_PreambleUi.h"
-
-#include <QCloseEvent>
-#include <QDialog>
-
-#include <vector>
-#include <string>
-
-class FloatPlacement;
-
-template<class UI>
-class UiWidget: public QWidget, public UI
-{
-public:
- UiWidget(QWidget * parent = 0) : QWidget(parent)
- {
- UI::setupUi(this);
- }
-};
-
-namespace lyx {
-namespace frontend {
-
-class QBranches;
-class QDocument;
-class PreambleModule;
-
-class QDocumentDialog : public QDialog, public Ui::QDocumentUi {
- Q_OBJECT
-public:
- friend class QDocument;
-
- QDocumentDialog(QDocument *);
-
- void updateParams(BufferParams const & params);
- void apply(BufferParams & params);
-
- void updateFontsize(std::string const &, std::string const &);
- void updatePagestyle(std::string const &, std::string const &);
-
- void showPreamble();
- /// validate listings parameters and return an error message, if any
- docstring validate_listings_params();
-
-public Q_SLOTS:
- void updateNumbering();
- void change_adaptor();
- void set_listings_msg();
- void saveDefaultClicked();
- void useDefaultsClicked();
-
-protected Q_SLOTS:
- void setLSpacing(int);
- void setMargins(bool);
- void setCustomPapersize(int);
- void setCustomMargins(bool);
- void romanChanged(int);
- void sansChanged(int);
- void ttChanged(int);
- void setSkip(int);
- void enableSkip(bool);
- void portraitChanged();
- void classChanged();
-
-protected:
- void closeEvent(QCloseEvent * e);
-
-private:
-
- UiWidget<Ui::TextLayoutUi> *textLayoutModule;
- UiWidget<Ui::FontUi> *fontModule;
- UiWidget<Ui::PageLayoutUi> *pageLayoutModule;
- UiWidget<Ui::MarginsUi> *marginsModule;
- UiWidget<Ui::LanguageUi> *langModule;
- UiWidget<Ui::NumberingUi> *numberingModule;
- UiWidget<Ui::BiblioUi> *biblioModule;
- UiWidget<Ui::MathsUi> *mathsModule;
- UiWidget<Ui::LaTeXUi> *latexModule;
- PreambleModule *preambleModule;
-
- QBranches *branchesModule;
-
- BulletsModule * bulletsModule;
- FloatPlacement * floatModule;
-
- QDocument * form_;
-
- /// FIXME
- std::vector<std::string> lang_;
-};
-
-
-class ControlDocument;
-
-class QDocument
- : public QController<ControlDocument, QView<QDocumentDialog> >
-{
-public:
-
- friend class QDocumentDialog;
-
- QDocument(Dialog &);
-
- void showPreamble();
-
-private:
- /// Apply changes
- void apply();
- /// update
- void update_contents();
- /// build the dialog
- void build_dialog();
- /// save as default template
- void saveDocDefault();
- /// reset to default params
- void useClassDefaults();
-protected:
- /// return false if validate_listings_params returns error
- virtual bool isValid();
-};
-
-
-typedef void const * BufferId;
-
-
-class PreambleModule : public UiWidget<Ui::PreambleUi>
-{
- Q_OBJECT
-public:
- PreambleModule();
- void update(BufferParams const & params, BufferId id);
- void apply(BufferParams & params);
-
-Q_SIGNALS:
- /// signal that something's changed in the Widget.
- void changed();
-
-protected:
- void closeEvent(QCloseEvent *);
- void on_preambleTE_textChanged() { changed(); }
-
-private:
- typedef std::map<BufferId, std::pair<int,int> > Coords;
- Coords preamble_coords_;
- BufferId current_id_;
-};
-
-
-
-} // namespace frontend
-} // namespace lyx
-
-#endif // QDOCUMENT_H
+++ /dev/null
-/**
- * \file QERT.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author John Levon
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "QERT.h"
-#include "Qt2BC.h"
-
-#include "controllers/ControlERT.h"
-
-#include <QRadioButton>
-#include <QPushButton>
-#include <QCloseEvent>
-
-
-namespace lyx {
-namespace frontend {
-
-/////////////////////////////////////////////////////////////////////
-//
-// QERTDialog
-//
-/////////////////////////////////////////////////////////////////////
-
-
-QERTDialog::QERTDialog(QERT * form)
- : form_(form)
-{
- setupUi(this);
- connect(okPB, SIGNAL(clicked()), form, SLOT(slotOK()));
- connect(closePB, SIGNAL(clicked()), form, SLOT(slotClose()));
- connect(collapsedRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
- connect(openRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
-}
-
-
-void QERTDialog::closeEvent(QCloseEvent * e)
-{
- form_->slotWMHide();
- e->accept();
-}
-
-
-void QERTDialog::change_adaptor()
-{
- form_->changed();
-}
-
-
-/////////////////////////////////////////////////////////////////////
-//
-// QERT
-//
-/////////////////////////////////////////////////////////////////////
-
-typedef QController<ControlERT, QView<QERTDialog> > ERTBase;
-
-
-QERT::QERT(Dialog & parent)
- : ERTBase(parent, _("TeX Code Settings"))
-{
-}
-
-
-void QERT::build_dialog()
-{
- dialog_.reset(new QERTDialog(this));
-
- bcview().setOK(dialog_->okPB);
- bcview().setCancel(dialog_->closePB);
-}
-
-
-void QERT::apply()
-{
- if (dialog_->openRB->isChecked())
- controller().setStatus(Inset::Open);
- else
- controller().setStatus(Inset::Collapsed);
-}
-
-
-void QERT::update_contents()
-{
- QRadioButton * rb = 0;
-
- switch (controller().status()) {
- case InsetERT::Open: rb = dialog_->openRB; break;
- case InsetERT::Collapsed: rb = dialog_->collapsedRB; break;
- }
-
- rb->setChecked(true);
-}
-
-} // namespace frontend
-} // namespace lyx
-
-#include "QERT_moc.cpp"
+++ /dev/null
-// -*- C++ -*-
-/**
- * \file QERT.h
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author John Levon
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#ifndef QERT_H
-#define QERT_H
-
-#include "QDialogView.h"
-#include "ui_ERTUi.h"
-
-#include <QCloseEvent>
-#include <QDialog>
-
-namespace lyx {
-namespace frontend {
-
-class QERT;
-
-class QERTDialog : public QDialog, public Ui::QERTUi {
- Q_OBJECT
-public:
- QERTDialog(QERT * form);
-protected Q_SLOTS:
- virtual void change_adaptor();
-protected:
- virtual void closeEvent(QCloseEvent * e);
-private:
- QERT * form_;
-};
-
-
-
-class ControlERT;
-
-class QERT : public QController<ControlERT, QView<QERTDialog> >
-{
-public:
- friend class QERTDialog;
-
- QERT(Dialog &);
-private:
- /// Apply changes
- virtual void apply();
- /// update
- virtual void update_contents();
- /// build the dialog
- virtual void build_dialog();
-};
-
-} // namespace frontend
-} // namespace lyx
-
-#endif // QERT_H
+++ /dev/null
-/**
- * \file QErrorList.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Alfredo Braunstein
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "QErrorList.h"
-#include "Qt2BC.h"
-#include "qt_helpers.h"
-
-#include "controllers/ControlErrorList.h"
-
-#include <QListWidget>
-#include <QTextBrowser>
-#include <QPushButton>
-#include <QCloseEvent>
-
-namespace lyx {
-namespace frontend {
-
-/////////////////////////////////////////////////////////////////////
-//
-// QErrorListDialog
-//
-/////////////////////////////////////////////////////////////////////
-
-QErrorListDialog::QErrorListDialog(QErrorList * form)
- : form_(form)
-{
- setupUi(this);
- connect(closePB, SIGNAL(clicked()),
- form, SLOT(slotClose()));
- connect(errorsLW, SIGNAL( itemActivated(QListWidgetItem *)),
- form, SLOT(slotClose()));
- connect( errorsLW, SIGNAL( itemClicked(QListWidgetItem *)),
- this, SLOT(select_adaptor(QListWidgetItem *)));
-}
-
-
-void QErrorListDialog::select_adaptor(QListWidgetItem * item)
-{
- form_->select(item);
-}
-
-
-void QErrorListDialog::closeEvent(QCloseEvent * e)
-{
- form_->slotWMHide();
- e->accept();
-}
-
-
-void QErrorListDialog::showEvent(QShowEvent *e)
-{
- errorsLW->setCurrentRow(0);
- form_->select(errorsLW->item(0));
- e->accept();
-}
-
-
-/////////////////////////////////////////////////////////////////////
-//
-// QErrorList
-//
-/////////////////////////////////////////////////////////////////////
-
-
-typedef QController<ControlErrorList, QView<QErrorListDialog> >
- ErrorListBase;
-
-QErrorList::QErrorList(Dialog & parent)
- : ErrorListBase(parent, docstring())
-{}
-
-
-void QErrorList::build_dialog()
-{
- dialog_.reset(new QErrorListDialog(this));
- bcview().setCancel(dialog_->closePB);
-}
-
-
-void QErrorList::select(QListWidgetItem * wi)
-{
- int const item = dialog_->errorsLW->row(wi);
- controller().goTo(item);
- dialog_->descriptionTB->setPlainText(toqstr(controller().errorList()[item].description));
-}
-
-
-void QErrorList::update_contents()
-{
- setTitle(from_utf8(controller().name()));
- dialog_->errorsLW->clear();
- dialog_->descriptionTB->setPlainText(QString());
-
- ErrorList::const_iterator it = controller().errorList().begin();
- ErrorList::const_iterator end = controller().errorList().end();
- for(; it != end; ++it) {
- dialog_->errorsLW->addItem(toqstr(it->error));
- }
-}
-
-} // namespace frontend
-} // namespace lyx
-
-
-#include "QErrorList_moc.cpp"
+++ /dev/null
-// -*- C++ -*-
-/**
- * \file QErrorList.h
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Alfredo Braunstein
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#ifndef QERRORLIST_H
-#define QERRORLIST_H
-
-#include "QDialogView.h"
-#include "ui_ErrorListUi.h"
-
-#include <QDialog>
-
-class QListWidgetItem;
-class QCloseEvent;
-class QShowEvent;
-
-namespace lyx {
-namespace frontend {
-
-class QErrorList;
-
-class QErrorListDialog : public QDialog, public Ui::QErrorListUi {
- Q_OBJECT
-public:
- QErrorListDialog(QErrorList * form);
-
-public Q_SLOTS:
- void select_adaptor(QListWidgetItem *);
-protected:
- void closeEvent(QCloseEvent *);
- void showEvent(QShowEvent *);
-private:
- QErrorList * form_;
-};
-
-
-class ControlErrorList;
-
-class QErrorList :
- public QController<ControlErrorList, QView<QErrorListDialog> >
-{
-public:
- friend class QErrorListDialog;
-
- QErrorList(Dialog &);
-private:
- /// select an entry
- void select(QListWidgetItem *);
- /// required apply
- virtual void apply() {}
- /// build dialog
- virtual void build_dialog();
- /// update contents
- virtual void update_contents();
-};
-
-} // namespace frontend
-} // namespace lyx
-
-#endif // QERRORLIST_H
+++ /dev/null
-/**
- * \file QExternal.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author John Levon
- * \author Angus Leeming
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-// Qt defines a macro 'signals' that clashes with a boost namespace.
-// All is well if the namespace is visible first.
-#include "lengthcommon.h"
-#include "LyXRC.h"
-
-#include "controllers/ControlExternal.h"
-#include "controllers/ButtonController.h"
-
-#include "insets/ExternalTemplate.h"
-#include "insets/InsetExternal.h"
-
-#include "support/lstrings.h"
-#include "support/convert.h"
-#include "support/os.h"
-#include "support/lyxlib.h"
-
-#include "QExternal.h"
-#include "Qt2BC.h"
-
-#include "CheckedLineEdit.h"
-#include "LengthCombo.h"
-#include "qt_helpers.h"
-#include "Validator.h"
-
-#include <QLineEdit>
-#include <QPushButton>
-#include <QCheckBox>
-#include <QTabWidget>
-#include <QTextBrowser>
-
-namespace external = lyx::external;
-
-using lyx::support::isStrDbl;
-using lyx::support::token;
-using lyx::support::trim;
-using lyx::support::float_equal;
-
-using lyx::support::os::internal_path;
-
-using std::string;
-using std::vector;
-using std::find;
-
-
-namespace lyx {
-namespace frontend {
-
-/////////////////////////////////////////////////////////////////////
-//
-// QExternalDialog
-//
-/////////////////////////////////////////////////////////////////////
-
-
-QExternalDialog::QExternalDialog(QExternal * form)
- : form_(form)
-{
- setupUi(this);
- connect(okPB, SIGNAL(clicked()), form, SLOT(slotOK()));
- connect(applyPB, SIGNAL(clicked()), form, SLOT(slotApply()));
- connect(closePB, SIGNAL(clicked()), form, SLOT(slotClose()));
-
- connect(displayCB, SIGNAL(toggled(bool)),
- showCO, SLOT(setEnabled(bool)));
- connect(displayCB, SIGNAL(toggled(bool)),
- displayscaleED, SLOT(setEnabled(bool)));
- connect(showCO, SIGNAL(activated(const QString&)),
- this, SLOT(change_adaptor()));
- connect(originCO, SIGNAL(activated(int)),
- this, SLOT(change_adaptor()));
- connect(aspectratioCB, SIGNAL(stateChanged(int)),
- this, SLOT(change_adaptor()));
- connect(browsePB, SIGNAL(clicked()),
- this, SLOT(browseClicked()));
- connect(editPB, SIGNAL(clicked()),
- this, SLOT(editClicked()));
- connect(externalCO, SIGNAL(activated(const QString &)),
- this, SLOT(templateChanged()));
- connect(extraED, SIGNAL(textChanged(const QString &)),
- this, SLOT(extraChanged(const QString&)));
- connect(extraFormatCO, SIGNAL(activated(const QString &)),
- this, SLOT(formatChanged(const QString&)));
- connect(widthUnitCO, SIGNAL(activated(int)),
- this, SLOT(widthUnitChanged()));
- connect(heightUnitCO, SIGNAL(selectionChanged(lyx::Length::UNIT)),
- this, SLOT(change_adaptor()));
- connect(displayCB, SIGNAL(stateChanged(int)),
- this, SLOT(change_adaptor()));
- connect(displayscaleED, SIGNAL(textChanged(const QString &)),
- this, SLOT(change_adaptor()));
- connect(angleED, SIGNAL(textChanged(const QString &)),
- this, SLOT(change_adaptor()));
- connect(widthED, SIGNAL(textChanged(const QString &)),
- this, SLOT(sizeChanged()));
- connect(heightED, SIGNAL(textChanged(const QString &)),
- this, SLOT(sizeChanged()));
- connect(fileED, SIGNAL(textChanged(const QString &)),
- this, SLOT(change_adaptor()));
- connect(clipCB, SIGNAL(stateChanged(int)),
- this, SLOT(change_adaptor()));
- connect(getbbPB, SIGNAL(clicked()), this, SLOT(getbbClicked()));
- connect(xrED, SIGNAL(textChanged(const QString &)), this, SLOT(bbChanged()));
- connect(ytED, SIGNAL(textChanged(const QString &)), this, SLOT(bbChanged()));
- connect(xlED, SIGNAL(textChanged(const QString &)), this, SLOT(bbChanged()));
- connect(ybED, SIGNAL(textChanged(const QString &)), this, SLOT(bbChanged()));
- connect(draftCB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
-
- QIntValidator * validator = new QIntValidator(displayscaleED);
- validator->setBottom(1);
- displayscaleED->setValidator(validator);
-
- angleED->setValidator(new QDoubleValidator(-360, 360, 2, angleED));
-
- xlED->setValidator(new QIntValidator(xlED));
- ybED->setValidator(new QIntValidator(ybED));
- xrED->setValidator(new QIntValidator(xrED));
- ytED->setValidator(new QIntValidator(ytED));
-
- widthED->setValidator(unsignedLengthValidator(widthED));
- heightED->setValidator(unsignedLengthValidator(heightED));
-
- setFocusProxy(fileED);
-}
-
-
-void QExternalDialog::show()
-{
- QDialog::show();
-}
-
-
-
-bool QExternalDialog::activateAspectratio() const
-{
- if (widthUnitCO->currentIndex() == 0)
- return false;
-
- string const wstr = fromqstr(widthED->text());
- if (wstr.empty())
- return false;
- bool const wIsDbl = isStrDbl(wstr);
- if (wIsDbl && float_equal(convert<double>(wstr), 0.0, 0.05))
- return false;
- Length l;
- if (!wIsDbl && (!isValidLength(wstr, &l) || l.zero()))
- return false;
-
- string const hstr = fromqstr(heightED->text());
- if (hstr.empty())
- return false;
- bool const hIsDbl = isStrDbl(hstr);
- if (hIsDbl && float_equal(convert<double>(hstr), 0.0, 0.05))
- return false;
- if (!hIsDbl && (!isValidLength(hstr, &l) || l.zero()))
- return false;
-
- return true;
-}
-
-
-void QExternalDialog::bbChanged()
-{
- form_->controller().bbChanged(true);
- form_->changed();
-}
-
-
-void QExternalDialog::browseClicked()
-{
- int const choice = externalCO->currentIndex();
- docstring const template_name =
- from_utf8(form_->controller().getTemplate(choice).lyxName);
- docstring const str =
- form_->controller().browse(qstring_to_ucs4(fileED->text()),
- template_name);
- if(!str.empty()) {
- fileED->setText(toqstr(str));
- form_->changed();
- }
-}
-
-
-void QExternalDialog::change_adaptor()
-{
- form_->changed();
-}
-
-
-void QExternalDialog::closeEvent(QCloseEvent * e)
-{
- form_->slotWMHide();
- e->accept();
-}
-
-
-void QExternalDialog::editClicked()
-{
- form_->controller().editExternal();
-}
-
-
-
-void QExternalDialog::extraChanged(const QString& text)
-{
- std::string const format = fromqstr(extraFormatCO->currentText());
- form_->extra_[format] = text;
- form_->changed();
-}
-
-
-void QExternalDialog::formatChanged(const QString& format)
-{
- extraED->setText(form_->extra_[fromqstr(format)]);
-}
-
-
-void QExternalDialog::getbbClicked()
-{
- form_->getBB();
-}
-
-
-void QExternalDialog::sizeChanged()
-{
- aspectratioCB->setEnabled(activateAspectratio());
- form_->changed();
-}
-
-
-void QExternalDialog::templateChanged()
-{
- form_->updateTemplate();
- form_->changed();
-}
-
-
-void QExternalDialog::widthUnitChanged()
-{
- bool useHeight = (widthUnitCO->currentIndex() > 0);
-
- if (useHeight)
- widthED->setValidator(unsignedLengthValidator(widthED));
- else
- widthED->setValidator(new QDoubleValidator(0, 1000, 2, widthED));
-
- heightED->setEnabled(useHeight);
- heightUnitCO->setEnabled(useHeight);
- form_->changed();
-}
-
-
-/////////////////////////////////////////////////////////////////////
-//
-// QExternal
-//
-/////////////////////////////////////////////////////////////////////
-
-namespace {
-
-Length::UNIT defaultUnit()
-{
- Length::UNIT default_unit = Length::CM;
- switch (lyxrc.default_papersize) {
- case PAPER_USLETTER:
- case PAPER_USLEGAL:
- case PAPER_USEXECUTIVE:
- default_unit = Length::IN;
- break;
- default:
- break;
- }
- return default_unit;
-}
-
-
-void setDisplay(QCheckBox & displayCB, QComboBox & showCO, QLineEdit & scaleED,
- external::DisplayType display, unsigned int scale,
- bool read_only)
-{
- int item = 0;
- switch (display) {
- case external::DefaultDisplay:
- item = 0;
- break;
- case external::MonochromeDisplay:
- item = 1;
- break;
- case external::GrayscaleDisplay:
- item = 2;
- break;
- case external::ColorDisplay:
- item = 3;
- break;
- case external::PreviewDisplay:
- item = 4;
- break;
- case external::NoDisplay:
- item = 0;
- break;
- }
-
- showCO.setCurrentIndex(item);
- bool const no_display = display == external::NoDisplay;
- showCO.setEnabled(!no_display && !read_only);
- displayCB.setChecked(!no_display);
- scaleED.setEnabled(!no_display && !read_only);
- scaleED.setText(toqstr(convert<string>(scale)));
-}
-
-
-void getDisplay(external::DisplayType & display,
- unsigned int & scale,
- QCheckBox const & displayCB,
- QComboBox const & showCO,
- QLineEdit const & scaleED)
-{
- switch (showCO.currentIndex()) {
- case 0:
- display = external::DefaultDisplay;
- break;
- case 1:
- display = external::MonochromeDisplay;
- break;
- case 2:
- display = external::GrayscaleDisplay;
- break;
- case 3:
- display = external::ColorDisplay;
- break;
- case 4:
- display = external::PreviewDisplay;
- break;
- }
-
- if (!displayCB.isChecked())
- display = external::NoDisplay;
-
- scale = convert<int>(fromqstr(scaleED.text()));
-}
-
-
-void setRotation(QLineEdit & angleED, QComboBox & originCO,
- external::RotationData const & data)
-{
- originCO.setCurrentIndex(int(data.origin()));
- angleED.setText(toqstr(data.angle));
-}
-
-
-void getRotation(external::RotationData & data,
- QLineEdit const & angleED, QComboBox const & originCO)
-{
- typedef external::RotationData::OriginType OriginType;
-
- data.origin(static_cast<OriginType>(originCO.currentIndex()));
- data.angle = fromqstr(angleED.text());
-}
-
-
-void setSize(QLineEdit & widthED, QComboBox & widthUnitCO,
- QLineEdit & heightED, LengthCombo & heightUnitCO,
- QCheckBox & aspectratioCB,
- external::ResizeData const & data)
-{
- bool using_scale = data.usingScale();
- std::string scale = data.scale;
- if (data.no_resize()) {
- // Everything is zero, so default to this!
- using_scale = true;
- scale = "100";
- }
-
- if (using_scale) {
- widthED.setText(toqstr(scale));
- widthUnitCO.setCurrentIndex(0);
- } else {
- widthED.setText(toqstr(convert<string>(data.width.value())));
- // Because 'Scale' is position 0...
- // Note also that width cannot be zero here, so
- // we don't need to worry about the default unit.
- widthUnitCO.setCurrentIndex(data.width.unit() + 1);
- }
-
- string const h = data.height.zero() ? string() : data.height.asString();
- Length::UNIT default_unit = data.width.zero() ?
- defaultUnit() : data.width.unit();
- lengthToWidgets(&heightED, &heightUnitCO, h, default_unit);
-
- heightED.setEnabled(!using_scale);
- heightUnitCO.setEnabled(!using_scale);
-
- aspectratioCB.setChecked(data.keepAspectRatio);
-
- bool const disable_aspectRatio = using_scale ||
- data.width.zero() || data.height.zero();
- aspectratioCB.setEnabled(!disable_aspectRatio);
-}
-
-
-void getSize(external::ResizeData & data,
- QLineEdit const & widthED, QComboBox const & widthUnitCO,
- QLineEdit const & heightED, LengthCombo const & heightUnitCO,
- QCheckBox const & aspectratioCB)
-{
- string const width = fromqstr(widthED.text());
-
- if (widthUnitCO.currentIndex() > 0) {
- // Subtract one, because scale is 0.
- int const unit = widthUnitCO.currentIndex() - 1;
-
- Length w;
- if (isValidLength(width, &w))
- data.width = w;
- else if (isStrDbl(width))
- data.width = Length(convert<double>(width),
- static_cast<Length::UNIT>(unit));
- else
- data.width = Length();
-
- data.scale = string();
-
- } else {
- // scaling instead of a width
- data.scale = width;
- data.width = Length();
- }
-
- data.height = Length(widgetsToLength(&heightED, &heightUnitCO));
-
- data.keepAspectRatio = aspectratioCB.isChecked();
-}
-
-
-void setCrop(QCheckBox & clipCB,
- QLineEdit & xlED, QLineEdit & ybED,
- QLineEdit & xrED, QLineEdit & ytED,
- external::ClipData const & data)
-{
- clipCB.setChecked(data.clip);
- graphics::BoundingBox const & bbox = data.bbox;
- xlED.setText(toqstr(convert<string>(bbox.xl)));
- ybED.setText(toqstr(convert<string>(bbox.yb)));
- xrED.setText(toqstr(convert<string>(bbox.xr)));
- ytED.setText(toqstr(convert<string>(bbox.yt)));
-}
-
-
-void getCrop(external::ClipData & data,
- QCheckBox const & clipCB,
- QLineEdit const & xlED, QLineEdit const & ybED,
- QLineEdit const & xrED, QLineEdit const & ytED,
- bool bb_changed)
-{
- data.clip = clipCB.isChecked();
-
- if (!bb_changed)
- return;
-
- data.bbox.xl = convert<int>(fromqstr(xlED.text()));
- data.bbox.yb = convert<int>(fromqstr(ybED.text()));
- data.bbox.xr = convert<int>(fromqstr(xrED.text()));
- data.bbox.yt = convert<int>(fromqstr(ytED.text()));
-}
-
-
-void getExtra(external::ExtraData & data,
- QExternal::MapType const & extra)
-{
- typedef QExternal::MapType MapType;
- MapType::const_iterator it = extra.begin();
- MapType::const_iterator const end = extra.end();
- for (; it != end; ++it)
- data.set(it->first, trim(fromqstr(it->second)));
-}
-
-} // namespace anon
-
-
-typedef QController<ControlExternal, QView<QExternalDialog> >
- ExternalBase;
-
-QExternal::QExternal(Dialog & parent)
- : ExternalBase(parent, _("External Material"))
-{}
-
-
-void QExternal::build_dialog()
-{
- dialog_.reset(new QExternalDialog(this));
-
- bcview().setOK(dialog_->okPB);
- bcview().setApply(dialog_->applyPB);
- bcview().setCancel(dialog_->closePB);
-
- bcview().addReadOnly(dialog_->fileED);
- bcview().addReadOnly(dialog_->browsePB);
- bcview().addReadOnly(dialog_->editPB);
- bcview().addReadOnly(dialog_->externalCO);
- bcview().addReadOnly(dialog_->draftCB);
- bcview().addReadOnly(dialog_->displayscaleED);
- bcview().addReadOnly(dialog_->showCO);
- bcview().addReadOnly(dialog_->displayCB);
- bcview().addReadOnly(dialog_->angleED);
- bcview().addReadOnly(dialog_->originCO);
- bcview().addReadOnly(dialog_->heightUnitCO);
- bcview().addReadOnly(dialog_->heightED);
- bcview().addReadOnly(dialog_->aspectratioCB);
- bcview().addReadOnly(dialog_->widthUnitCO);
- bcview().addReadOnly(dialog_->widthED);
- bcview().addReadOnly(dialog_->clipCB);
- bcview().addReadOnly(dialog_->getbbPB);
- bcview().addReadOnly(dialog_->ytED);
- bcview().addReadOnly(dialog_->xlED);
- bcview().addReadOnly(dialog_->xrED);
- bcview().addReadOnly(dialog_->ybED);
- bcview().addReadOnly(dialog_->extraFormatCO);
- bcview().addReadOnly(dialog_->extraED);
-
- addCheckedLineEdit(bcview(), dialog_->angleED, dialog_->angleLA);
- addCheckedLineEdit(bcview(), dialog_->displayscaleED, dialog_->scaleLA);
- addCheckedLineEdit(bcview(), dialog_->heightED, dialog_->heightLA);
- addCheckedLineEdit(bcview(), dialog_->widthED, dialog_->widthLA);
- addCheckedLineEdit(bcview(), dialog_->xlED, dialog_->lbLA);
- addCheckedLineEdit(bcview(), dialog_->ybED, dialog_->lbLA);
- addCheckedLineEdit(bcview(), dialog_->xrED, dialog_->rtLA);
- addCheckedLineEdit(bcview(), dialog_->ytED, dialog_->rtLA);
- addCheckedLineEdit(bcview(), dialog_->fileED, dialog_->fileLA);
-
- std::vector<string> templates(controller().getTemplates());
-
- for (std::vector<string>::const_iterator cit = templates.begin();
- cit != templates.end(); ++cit) {
- dialog_->externalCO->addItem(qt_(*cit));
- }
-
- // Fill the origins combo
- typedef vector<external::RotationDataType> Origins;
- Origins const & all_origins = external::all_origins();
- for (Origins::size_type i = 0; i != all_origins.size(); ++i)
- dialog_->originCO->addItem(toqstr(external::origin_gui_str(i)));
-
- // Fill the width combo
- dialog_->widthUnitCO->addItem(qt_("Scale%"));
- for (int i = 0; i < num_units; i++)
- dialog_->widthUnitCO->addItem(qt_(unit_name_gui[i]));
-}
-
-
-void QExternal::update_contents()
-{
- dialog_->tab->setCurrentIndex(0);
- InsetExternalParams const & params = controller().params();
-
- string const name =
- params.filename.outputFilename(kernel().bufferFilepath());
- dialog_->fileED->setText(toqstr(name));
-
- dialog_->externalCO->setCurrentIndex(
- controller().getTemplateNumber(params.templatename()));
- updateTemplate();
-
- dialog_->draftCB->setChecked(params.draft);
-
- setDisplay(*dialog_->displayCB, *dialog_->showCO,
- *dialog_->displayscaleED,
- params.display, params.lyxscale, readOnly());
-
- setRotation(*dialog_->angleED, *dialog_->originCO, params.rotationdata);
-
- setSize(*dialog_->widthED, *dialog_->widthUnitCO,
- *dialog_->heightED, *dialog_->heightUnitCO,
- *dialog_->aspectratioCB,
- params.resizedata);
-
- setCrop(*dialog_->clipCB,
- *dialog_->xlED, *dialog_->ybED,
- *dialog_->xrED, *dialog_->ytED,
- params.clipdata);
- controller().bbChanged(!params.clipdata.bbox.empty());
-
- isValid();
-}
-
-
-void QExternal::updateTemplate()
-{
- external::Template templ =
- controller().getTemplate(dialog_->externalCO->currentIndex());
- dialog_->externalTB->setPlainText(qt_(templ.helpText));
-
- // Ascertain which (if any) transformations the template supports
- // and disable tabs hosting unsupported transforms.
- typedef vector<external::TransformID> TransformIDs;
- TransformIDs const transformIds = templ.transformIds;
- TransformIDs::const_iterator tr_begin = transformIds.begin();
- TransformIDs::const_iterator const tr_end = transformIds.end();
-
- bool found = find(tr_begin, tr_end, external::Rotate) != tr_end;
- dialog_->tab->setTabEnabled(
- dialog_->tab->indexOf(dialog_->rotatetab), found);
- found = find(tr_begin, tr_end, external::Resize) != tr_end;
- dialog_->tab->setTabEnabled(
- dialog_->tab->indexOf(dialog_->scaletab), found);
-
- found = find(tr_begin, tr_end, external::Clip) != tr_end;
- dialog_->tab->setTabEnabled(
- dialog_->tab->indexOf(dialog_->croptab), found);
-
- found = find(tr_begin, tr_end, external::Extra) != tr_end;
- dialog_->tab->setTabEnabled(
- dialog_->tab->indexOf(dialog_->optionstab), found);
-
- if (!found)
- return;
-
- // Ascertain whether the template has any formats supporting
- // the 'Extra' option
- QLineEdit * const extraED = dialog_->extraED;
- QComboBox * const extraCB = dialog_->extraFormatCO;
-
- extra_.clear();
- extraED->clear();
- extraCB->clear();
-
- external::Template::Formats::const_iterator it = templ.formats.begin();
- external::Template::Formats::const_iterator end = templ.formats.end();
- for (; it != end; ++it) {
- if (it->second.option_transformers.find(external::Extra) ==
- it->second.option_transformers.end())
- continue;
- string const format = it->first;
- string const opt = controller().params().extradata.get(format);
- extraCB->addItem(toqstr(format));
- extra_[format] = toqstr(opt);
- }
-
- bool const enabled = extraCB->count() > 0;
-
- dialog_->tab->setTabEnabled(
- dialog_->tab->indexOf(dialog_->optionstab), enabled);
- extraED->setEnabled(enabled && !kernel().isBufferReadonly());
- extraCB->setEnabled(enabled);
-
- if (enabled) {
- extraCB->setCurrentIndex(0);
- extraED->setText(extra_[fromqstr(extraCB->currentText())]);
- }
-}
-
-
-void QExternal::apply()
-{
- InsetExternalParams params = controller().params();
-
- params.filename.set(internal_path(fromqstr(dialog_->fileED->text())),
- kernel().bufferFilepath());
-
- params.settemplate(controller().getTemplate(
- dialog_->externalCO->currentIndex()).lyxName);
-
- params.draft = dialog_->draftCB->isChecked();
-
- getDisplay(params.display, params.lyxscale,
- *dialog_->displayCB, *dialog_->showCO,
- *dialog_->displayscaleED);
-
- if (dialog_->tab->isTabEnabled(
- dialog_->tab->indexOf(dialog_->rotatetab)))
- getRotation(params.rotationdata,
- *dialog_->angleED, *dialog_->originCO);
-
- if (dialog_->tab->isTabEnabled(
- dialog_->tab->indexOf(dialog_->scaletab)))
- getSize(params.resizedata,
- *dialog_->widthED, *dialog_->widthUnitCO,
- *dialog_->heightED, *dialog_->heightUnitCO,
- *dialog_->aspectratioCB);
-
- if (dialog_->tab->isTabEnabled(
- dialog_->tab->indexOf(dialog_->croptab)))
- getCrop(params.clipdata,
- *dialog_->clipCB,
- *dialog_->xlED, *dialog_->ybED,
- *dialog_->xrED, *dialog_->ytED,
- controller().bbChanged());
-
- if (dialog_->tab->isTabEnabled(
- dialog_->tab->indexOf(dialog_->optionstab)))
- getExtra(params.extradata, extra_);
-
- controller().setParams(params);
-}
-
-
-void QExternal::getBB()
-{
- dialog_->xlED->setText("0");
- dialog_->ybED->setText("0");
- dialog_->xrED->setText("0");
- dialog_->ytED->setText("0");
-
- string const filename = fromqstr(dialog_->fileED->text());
- if (filename.empty())
- return;
-
- string const bb = controller().readBB(filename);
- if (bb.empty())
- return;
-
- dialog_->xlED->setText(toqstr(token(bb, ' ', 0)));
- dialog_->ybED->setText(toqstr(token(bb, ' ', 1)));
- dialog_->xrED->setText(toqstr(token(bb, ' ', 2)));
- dialog_->ytED->setText(toqstr(token(bb, ' ', 3)));
-
- controller().bbChanged(false);
-}
-
-} // namespace frontend
-} // namespace lyx
-
-#include "QExternal_moc.cpp"
+++ /dev/null
-// -*- C++ -*-
-/**
- * \file QExternal.h
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author John Levon
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#ifndef QEXTERNAL_H
-#define QEXTERNAL_H
-
-#include "QDialogView.h"
-
-#include "ui_ExternalUi.h"
-
-#include <QCloseEvent>
-#include <QDialog>
-
-#include <map>
-
-namespace lyx {
-namespace frontend {
-
-class QExternal;
-
-class QExternalDialog : public QDialog, public Ui::QExternalUi {
- Q_OBJECT
-public:
- QExternalDialog(QExternal * form);
-
- virtual void show();
-protected Q_SLOTS:
- virtual void bbChanged();
- virtual void browseClicked();
- virtual void change_adaptor();
- virtual void editClicked();
- virtual void extraChanged(const QString&);
- virtual void formatChanged(const QString&);
- virtual void getbbClicked();
- virtual void sizeChanged();
- virtual void templateChanged();
- virtual void widthUnitChanged();
-
-protected:
- virtual void closeEvent(QCloseEvent * e);
-private:
- bool activateAspectratio() const;
- QExternal * form_;
-};
-
-
-class ControlExternal;
-
-class QExternal
- : public QController<ControlExternal, QView<QExternalDialog> >
-{
-public:
- friend class QExternalDialog;
-
- QExternal(Dialog &);
-
- typedef std::map<std::string, QString> MapType;
-
-private:
- /// Apply changes
- virtual void apply();
- /// update
- virtual void update_contents();
- /// build the dialog
- virtual void build_dialog();
-
- /// Helper function called when the template is changed.
- void updateTemplate();
- /// get bounding box from file
- void getBB();
-
- MapType extra_;
-};
-
-} // namespace frontend
-} // namespace lyx
-
-#endif // QEXTERNAL_H
+++ /dev/null
-/**
- * \file QFloat.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Edwin Leuven
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "QFloat.h"
-#include "QFloatDialog.h"
-#include "Qt2BC.h"
-#include "FloatPlacement.h"
-
-#include "controllers/ControlFloat.h"
-
-#include "insets/InsetFloat.h"
-
-#include <QPushButton>
-
-namespace lyx {
-namespace frontend {
-
-typedef QController<ControlFloat, QView<QFloatDialog> > float_base_class;
-
-
-QFloat::QFloat(Dialog & parent)
- : float_base_class(parent, _("Float Settings"))
-{
-}
-
-
-void QFloat::build_dialog()
-{
- dialog_.reset(new QFloatDialog(this));
-
- bcview().setCancel(dialog_->closePB);
- bcview().setApply(dialog_->applyPB);
- bcview().setOK(dialog_->okPB);
- bcview().setRestore(dialog_->restorePB);
-
- bcview().addReadOnly(dialog_->floatFP);
-}
-
-
-void QFloat::update_contents()
-{
- dialog_->floatFP->set(controller().params());
-}
-
-
-void QFloat::apply()
-{
- InsetFloatParams & params = controller().params();
-
- params.placement = dialog_->floatFP->get(params.wide, params.sideways);
-}
-
-} // namespace frontend
-} // namespace lyx
+++ /dev/null
-// -*- C++ -*-
-/**
- * \file QFloat.h
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Edwin Leuven
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#ifndef QFLOAT_H
-#define QFLOAT_H
-
-#include "QDialogView.h"
-#include "QFloatDialog.h"
-
-namespace lyx {
-namespace frontend {
-
-
-class ControlFloat;
-
-///
-class QFloat : public QController<ControlFloat, QView<QFloatDialog> > {
-public:
- ///
- friend class QFloatDialog;
- ///
- QFloat(Dialog &);
-private:
- /// Apply changes
- virtual void apply();
- /// update
- virtual void update_contents();
- /// build the dialog
- virtual void build_dialog();
-};
-
-} // namespace frontend
-} // namespace lyx
-
-#endif // QFLOAT_H
+++ /dev/null
-/**
- * \file QFloatDialog.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Edwin Leuven
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "QFloatDialog.h"
-#include "QFloat.h"
-
-#include <QCloseEvent>
-#include <QPushButton>
-
-#include "FloatPlacement.h"
-
-
-
-namespace lyx {
-namespace frontend {
-
-QFloatDialog::QFloatDialog(QFloat * form)
- : form_(form)
-{
- setupUi(this);
- connect(restorePB, SIGNAL(clicked()),
- form, SLOT(slotRestore()));
- connect(okPB, SIGNAL(clicked()),
- form, SLOT(slotOK()));
- connect(applyPB, SIGNAL(clicked()),
- form, SLOT(slotApply()));
- connect(closePB, SIGNAL(clicked()),
- form, SLOT(slotClose()));
-
- // enable span columns checkbox
- floatFP->useWide();
-
- // enable sideways checkbox
- floatFP->useSideways();
-
- connect(floatFP, SIGNAL(changed()),
- this, SLOT(change_adaptor()));
-}
-
-
-void QFloatDialog::change_adaptor()
-{
- form_->changed();
-}
-
-
-void QFloatDialog::closeEvent(QCloseEvent * e)
-{
- form_->slotWMHide();
- e->accept();
-}
-
-} // namespace frontend
-} // namespace lyx
-
-#include "QFloatDialog_moc.cpp"
+++ /dev/null
-// -*- C++ -*-
-/**
- * \file QFloatDialog.h
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Edwin Leuven
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#ifndef QFLOATDIALOG_H
-#define QFLOATDIALOG_H
-
-#include "ui_FloatUi.h"
-
-#include <QCloseEvent>
-#include <QDialog>
-
-namespace lyx {
-namespace frontend {
-
-class QFloat;
-
-class QFloatDialog : public QDialog, public Ui::QFloatUi {
- Q_OBJECT
-public:
- QFloatDialog(QFloat * form);
-
-protected Q_SLOTS:
- virtual void change_adaptor();
-
-protected:
- virtual void closeEvent(QCloseEvent * e);
-
-private:
- QFloat * form_;
-};
-
-} // namespace frontend
-} // namespace lyx
-
-#endif // QFLOATDIALOG_H
+++ /dev/null
-/**
- * \file QFontExample.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author John Levon
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "QFontExample.h"
-
-#include <QPainter>
-#include <QPaintEvent>
-
-
-//namespace lyx {
-
-void QFontExample::set(QFont const & font, QString const & text)
-{
- font_ = font;
- text_ = text;
- update();
-}
-
-
-QSize QFontExample::sizeHint() const
-{
- QFontMetrics m(font_);
- return QSize(m.width(text_) + 10, m.ascent() + m.descent() + 6);
-}
-
-
-void QFontExample::paintEvent(QPaintEvent *)
-{
- QPainter p;
- QFontMetrics m(font_);
-
- p.begin(this);
- p.setFont(font_);
- p.drawRect(0, 0, width() - 1, height() - 1);
- p.drawText(5, 3 + m.ascent(), text_);
- p.end();
-}
-
-
-//} // namespace lyx
+++ /dev/null
-// -*- C++ -*-
-/**
- * \file QFontExample.h
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author John Levon
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#ifndef QT_QFONTEXAMPLE_H
-#define QT_QFONTEXAMPLE_H
-
-#include <QWidget>
-#include <QFont>
-#include <QString>
-
-class QPaintEvent;
-
-
-//namespace lyx {
-
-class QFontExample : public QWidget {
-
-public:
- QFontExample(QWidget * parent)
- : QWidget(parent) {}
-
- void set(QFont const & font, QString const & text);
-
- virtual QSize sizeHint() const;
-
-protected:
- virtual void paintEvent(QPaintEvent * p);
-
-private:
- QFont font_;
- QString text_;
-};
-
-
-//} // namespace lyx
-
-#endif
+++ /dev/null
-/**
- * \file QGraphics.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author John Levon
- * \author Edwin Leuven
- * \author Herbert Voß
- * \author Richard Heck
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "QGraphics.h"
-
-#include "CheckedLineEdit.h"
-#include "LengthCombo.h"
-#include "QGraphicsDialog.h"
-#include "Qt2BC.h"
-#include "qt_helpers.h"
-
-#include "lengthcommon.h"
-#include "LyXRC.h"
-
-#include "controllers/ControlGraphics.h"
-#include "controllers/frontend_helpers.h"
-
-#include "insets/InsetGraphicsParams.h"
-
-#include "support/convert.h"
-#include "support/lstrings.h"
-#include "support/lyxlib.h"
-#include "support/os.h"
-
-#include <QLineEdit>
-#include <QPushButton>
-#include <QCheckBox>
-#include <QLabel>
-
-#include <cmath>
-
-using lyx::support::float_equal;
-using lyx::support::token;
-
-using lyx::support::os::internal_path;
-
-#ifndef CXX_GLOBAL_CSTD
-using std::floor;
-#endif
-
-using std::vector;
-using std::string;
-
-namespace lyx {
-namespace frontend {
-
-typedef QController<ControlGraphics, QView<QGraphicsDialog> > graphics_base_class;
-
-QGraphics::QGraphics(Dialog & parent)
- : graphics_base_class(parent, _("Graphics"))
-{
-}
-
-
-void QGraphics::build_dialog()
-{
- dialog_.reset(new QGraphicsDialog(this));
-
- bcview().setOK(dialog_->okPB);
- bcview().setApply(dialog_->applyPB);
- bcview().setRestore(dialog_->restorePB);
- bcview().setCancel(dialog_->closePB);
-
- bcview().addReadOnly(dialog_->latexoptions);
- bcview().addReadOnly(dialog_->subfigure);
- bcview().addReadOnly(dialog_->filenameL);
- bcview().addReadOnly(dialog_->filename);
- bcview().addReadOnly(dialog_->browsePB);
- bcview().addReadOnly(dialog_->unzipCB);
- bcview().addReadOnly(dialog_->bbFrame);
- bcview().addReadOnly(dialog_->draftCB);
- bcview().addReadOnly(dialog_->clip);
- bcview().addReadOnly(dialog_->unzipCB);
- bcview().addReadOnly(dialog_->displayGB);
- bcview().addReadOnly(dialog_->sizeGB);
- bcview().addReadOnly(dialog_->rotationGB);
- bcview().addReadOnly(dialog_->latexoptions);
- bcview().addReadOnly(dialog_->getPB);
- bcview().addReadOnly(dialog_->rotateOrderCB);
-
- // initialize the length validator
- addCheckedLineEdit(bcview(), dialog_->Scale, dialog_->scaleCB);
- addCheckedLineEdit(bcview(), dialog_->Width, dialog_->WidthCB);
- addCheckedLineEdit(bcview(), dialog_->Height, dialog_->HeightCB);
- addCheckedLineEdit(bcview(), dialog_->displayscale, dialog_->scaleLA);
- addCheckedLineEdit(bcview(), dialog_->angle, dialog_->angleL);
- addCheckedLineEdit(bcview(), dialog_->lbX, dialog_->xL);
- addCheckedLineEdit(bcview(), dialog_->lbY, dialog_->yL);
- addCheckedLineEdit(bcview(), dialog_->rtX, dialog_->xL_2);
- addCheckedLineEdit(bcview(), dialog_->rtY, dialog_->yL_2);
- addCheckedLineEdit(bcview(), dialog_->filename, dialog_->filenameL);
-}
-
-
-namespace {
-
-// returns the number of the string s in the vector v
-int getItemNo(vector<string> v, string const & s) {
- vector<string>::const_iterator cit =
- find(v.begin(), v.end(), s);
- return (cit != v.end()) ? int(cit - v.begin()) : 0;
-}
-
-}
-
-
-void QGraphics::update_contents()
-{
- // clear and fill in the comboboxes
- vector<string> const bb_units = frontend::getBBUnits();
- dialog_->lbXunit->clear();
- dialog_->lbYunit->clear();
- dialog_->rtXunit->clear();
- dialog_->rtYunit->clear();
- for (vector<string>::const_iterator it = bb_units.begin();
- it != bb_units.end(); ++it) {
- dialog_->lbXunit->addItem(toqstr(*it));
- dialog_->lbYunit->addItem(toqstr(*it));
- dialog_->rtXunit->addItem(toqstr(*it));
- dialog_->rtYunit->addItem(toqstr(*it));
- }
-
- InsetGraphicsParams & igp = controller().params();
-
- // set the right default unit
- Length::UNIT unitDefault = Length::CM;
- switch (lyxrc.default_papersize) {
- case PAPER_USLETTER:
- case PAPER_USLEGAL:
- case PAPER_USEXECUTIVE:
- unitDefault = Length::IN;
- break;
- default:
- break;
- }
-
- string const name =
- igp.filename.outputFilename(kernel().bufferFilepath());
- dialog_->filename->setText(toqstr(name));
-
- // set the bounding box values
- if (igp.bb.empty()) {
- string const bb = controller().readBB(igp.filename.absFilename());
- // the values from the file always have the bigpoint-unit bp
- dialog_->lbX->setText(toqstr(token(bb, ' ', 0)));
- dialog_->lbY->setText(toqstr(token(bb, ' ', 1)));
- dialog_->rtX->setText(toqstr(token(bb, ' ', 2)));
- dialog_->rtY->setText(toqstr(token(bb, ' ', 3)));
- dialog_->lbXunit->setCurrentIndex(0);
- dialog_->lbYunit->setCurrentIndex(0);
- dialog_->rtXunit->setCurrentIndex(0);
- dialog_->rtYunit->setCurrentIndex(0);
- controller().bbChanged = false;
- } else {
- // get the values from the inset
- Length anyLength;
- string const xl(token(igp.bb, ' ', 0));
- string const yl(token(igp.bb, ' ', 1));
- string const xr(token(igp.bb, ' ', 2));
- string const yr(token(igp.bb, ' ', 3));
- if (isValidLength(xl, &anyLength)) {
- dialog_->lbX->setText(toqstr(convert<string>(anyLength.value())));
- string const unit(unit_name[anyLength.unit()]);
- dialog_->lbXunit->setCurrentIndex(getItemNo(bb_units, unit));
- } else {
- dialog_->lbX->setText(toqstr(xl));
- }
- if (isValidLength(yl, &anyLength)) {
- dialog_->lbY->setText(toqstr(convert<string>(anyLength.value())));
- string const unit(unit_name[anyLength.unit()]);
- dialog_->lbYunit->setCurrentIndex(getItemNo(bb_units, unit));
- } else {
- dialog_->lbY->setText(toqstr(xl));
- }
- if (isValidLength(xr, &anyLength)) {
- dialog_->rtX->setText(toqstr(convert<string>(anyLength.value())));
- string const unit(unit_name[anyLength.unit()]);
- dialog_->rtXunit->setCurrentIndex(getItemNo(bb_units, unit));
- } else {
- dialog_->rtX->setText(toqstr(xl));
- }
- if (isValidLength(yr, &anyLength)) {
- dialog_->rtY->setText(toqstr(convert<string>(anyLength.value())));
- string const unit(unit_name[anyLength.unit()]);
- dialog_->rtYunit->setCurrentIndex(getItemNo(bb_units, unit));
- } else {
- dialog_->rtY->setText(toqstr(xl));
- }
- controller().bbChanged = true;
- }
-
- // Update the draft and clip mode
- dialog_->draftCB->setChecked(igp.draft);
- dialog_->clip->setChecked(igp.clip);
- dialog_->unzipCB->setChecked(igp.noUnzip);
-
- // Update the subcaption check button and input field
- dialog_->subfigure->setChecked(igp.subcaption);
- dialog_->subcaption->setText(toqstr(igp.subcaptionText));
-
- int item = 0;
- switch (igp.display) {
- case graphics::DefaultDisplay: item = 0; break;
- case graphics::MonochromeDisplay: item = 1; break;
- case graphics::GrayscaleDisplay: item = 2; break;
- case graphics::ColorDisplay: item = 3; break;
- case graphics::NoDisplay: item = 0; break;
- }
- dialog_->showCB->setCurrentIndex(item);
- dialog_->displayscale->setText(toqstr(convert<string>(igp.lyxscale)));
- dialog_->displayGB->setChecked(igp.display != graphics::NoDisplay);
-
- // the output section (width/height)
-
- dialog_->Scale->setText(toqstr(igp.scale));
- //igp.scale defaults to 100, so we treat it as empty
- bool const scaleChecked = !igp.scale.empty() && igp.scale != "100";
- dialog_->scaleCB->blockSignals(true);
- dialog_->scaleCB->setChecked(scaleChecked);
- dialog_->scaleCB->blockSignals(false);
- dialog_->Scale->setEnabled(scaleChecked);
-
- lengthAutoToWidgets(dialog_->Width, dialog_->widthUnit, igp.width,
- unitDefault);
- bool const widthChecked = !dialog_->Width->text().isEmpty() &&
- dialog_->Width->text() != "auto";
- dialog_->WidthCB->blockSignals(true);
- dialog_->WidthCB->setChecked(widthChecked);
- dialog_->WidthCB->blockSignals(false);
- dialog_->Width->setEnabled(widthChecked);
- dialog_->widthUnit->setEnabled(widthChecked);
-
- lengthAutoToWidgets(dialog_->Height, dialog_->heightUnit, igp.height,
- unitDefault);
- bool const heightChecked = !dialog_->Height->text().isEmpty()
- && dialog_->Height->text() != "auto";
- dialog_->HeightCB->blockSignals(true);
- dialog_->HeightCB->setChecked(heightChecked);
- dialog_->HeightCB->blockSignals(false);
- dialog_->Height->setEnabled(heightChecked);
- dialog_->heightUnit->setEnabled(heightChecked);
-
- dialog_->scaleCB->setEnabled(!widthChecked && !heightChecked);
- dialog_->WidthCB->setEnabled(!scaleChecked);
- dialog_->HeightCB->setEnabled(!scaleChecked);
- dialog_->aspectratio->setEnabled(widthChecked && heightChecked);
-
- dialog_->setAutoText();
-
- dialog_->angle->setText(toqstr(igp.rotateAngle));
- dialog_->rotateOrderCB->setChecked(igp.scaleBeforeRotation);
-
- dialog_->rotateOrderCB->setEnabled((widthChecked ||
- heightChecked ||
- scaleChecked) &&
- (igp.rotateAngle != "0"));
-
- dialog_->origin->clear();
-
- vector<RotationOriginPair> origindata = getRotationOriginData();
- vector<docstring> const origin_lang = getFirst(origindata);
- QGraphics::origin_ltx = getSecond(origindata);
-
- for (vector<docstring>::const_iterator it = origin_lang.begin();
- it != origin_lang.end(); ++it)
- dialog_->origin->addItem(toqstr(*it));
-
- if (!igp.rotateOrigin.empty())
- dialog_->origin->setCurrentIndex(
- getItemNo(origin_ltx, igp.rotateOrigin));
- else
- dialog_->origin->setCurrentIndex(0);
-
- // disable edit button when no filename is present
- dialog_->editPB->setDisabled(dialog_->filename->text().isEmpty());
-
- //// latex section
- dialog_->latexoptions->setText(toqstr(igp.special));
-}
-
-
-void QGraphics::apply()
-{
- InsetGraphicsParams & igp = controller().params();
-
- igp.filename.set(internal_path(fromqstr(dialog_->filename->text())),
- kernel().bufferFilepath());
-
- // the bb section
- igp.bb.erase();
- if (controller().bbChanged) {
- string bb;
- string lbX(fromqstr(dialog_->lbX->text()));
- string lbY(fromqstr(dialog_->lbY->text()));
- string rtX(fromqstr(dialog_->rtX->text()));
- string rtY(fromqstr(dialog_->rtY->text()));
- int bb_sum =
- convert<int>(lbX) + convert<int>(lbY) +
- convert<int>(rtX) + convert<int>(rtX);
- if (bb_sum) {
- if (lbX.empty())
- bb = "0 ";
- else
- bb = lbX + fromqstr(dialog_->lbXunit->currentText()) + ' ';
- if (lbY.empty())
- bb += "0 ";
- else
- bb += (lbY + fromqstr(dialog_->lbYunit->currentText()) + ' ');
- if (rtX.empty())
- bb += "0 ";
- else
- bb += (rtX + fromqstr(dialog_->rtXunit->currentText()) + ' ');
- if (rtY.empty())
- bb += '0';
- else
- bb += (rtY + fromqstr(dialog_->rtYunit->currentText()));
- igp.bb = bb;
- }
- }
-
- igp.draft = dialog_->draftCB->isChecked();
- igp.clip = dialog_->clip->isChecked();
- igp.subcaption = dialog_->subfigure->isChecked();
- igp.subcaptionText = fromqstr(dialog_->subcaption->text());
-
- switch (dialog_->showCB->currentIndex()) {
- case 0: igp.display = graphics::DefaultDisplay; break;
- case 1: igp.display = graphics::MonochromeDisplay; break;
- case 2: igp.display = graphics::GrayscaleDisplay; break;
- case 3: igp.display = graphics::ColorDisplay; break;
- default:;
- }
-
- if (!dialog_->displayGB->isChecked())
- igp.display = graphics::NoDisplay;
-
- //the graphics section
- if (dialog_->scaleCB->isChecked() && !dialog_->Scale->text().isEmpty()) {
- igp.scale = fromqstr(dialog_->Scale->text());
- igp.width = Length("0pt");
- igp.height = Length("0pt");
- igp.keepAspectRatio = false;
- } else {
- igp.scale = string();
- igp.width = dialog_->WidthCB->isChecked() ?
- //Note that this works even if dialog_->Width is "auto", since in
- //that case we get "0pt".
- Length(widgetsToLength(dialog_->Width, dialog_->widthUnit)):
- Length("0pt");
- igp.height = dialog_->HeightCB->isChecked() ?
- Length(widgetsToLength(dialog_->Height, dialog_->heightUnit)) :
- Length("0pt");
- igp.keepAspectRatio = dialog_->aspectratio->isEnabled() &&
- dialog_->aspectratio->isChecked() &&
- igp.width.value() > 0 && igp.height.value() > 0;
- }
-
- igp.noUnzip = dialog_->unzipCB->isChecked();
-
- igp.lyxscale = convert<int>(fromqstr(dialog_->displayscale->text()));
-
- igp.rotateAngle = fromqstr(dialog_->angle->text());
-
- double rotAngle = convert<double>(igp.rotateAngle);
- if (std::abs(rotAngle) > 360.0) {
- rotAngle -= 360.0 * floor(rotAngle / 360.0);
- igp.rotateAngle = convert<string>(rotAngle);
- }
-
- // save the latex name for the origin. If it is the default
- // then origin_ltx returns ""
- igp.rotateOrigin =
- QGraphics::origin_ltx[dialog_->origin->currentIndex()];
-
- igp.scaleBeforeRotation = dialog_->rotateOrderCB->isChecked();
-
- // more latex options
- igp.special = fromqstr(dialog_->latexoptions->text());
-}
-
-
-void QGraphics::getBB()
-{
- string const filename(fromqstr(dialog_->filename->text()));
- if (!filename.empty()) {
- string const bb(controller().readBB(filename));
- if (!bb.empty()) {
- dialog_->lbX->setText(toqstr(token(bb, ' ', 0)));
- dialog_->lbY->setText(toqstr(token(bb, ' ', 1)));
- dialog_->rtX->setText(toqstr(token(bb, ' ', 2)));
- dialog_->rtY->setText(toqstr(token(bb, ' ', 3)));
- // the default units for the bb values when reading
- // it from the file
- dialog_->lbXunit->setCurrentIndex(0);
- dialog_->lbYunit->setCurrentIndex(0);
- dialog_->rtXunit->setCurrentIndex(0);
- dialog_->rtYunit->setCurrentIndex(0);
- }
- controller().bbChanged = false;
- }
-}
-
-
-bool QGraphics::isValid()
-{
- return !dialog_->filename->text().isEmpty();
-}
-
-} // namespace frontend
-} // namespace lyx
+++ /dev/null
-// -*- C++ -*-
-/**
- * \file QGraphics.h
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author John Levon
- * \author Herbert Voß
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#ifndef QGRAPHICS_H
-#define QGRAPHICS_H
-
-#include "QDialogView.h"
-#include "QGraphicsDialog.h"
-
-#include <vector>
-
-namespace lyx {
-namespace frontend {
-
-class ControlGraphics;
-
-///
-class QGraphics
- : public QController<ControlGraphics, QView<QGraphicsDialog> >
-{
-public:
- ///
- friend class QGraphicsDialog;
- ///
- QGraphics(Dialog &);
-protected:
- virtual bool isValid();
-private:
- /// Apply changes
- virtual void apply();
- /// update
- virtual void update_contents();
- /// build the dialog
- virtual void build_dialog();
- /// get bounding box from file
- void getBB();
-
- /// Store the LaTeX names for the rotation origins.
- std::vector<std::string> origin_ltx;
-
-};
-
-} // namespace frontend
-} // namespace lyx
-
-#endif // QGRAPHICS_H
+++ /dev/null
-/**
- * \file QGraphicsDialog.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author John Levon
- * \author Herbert Voß
- * \author Abdelrazak Younes
- * \author Richard Heck
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "QGraphicsDialog.h"
-#include "QGraphics.h"
-
-#include "LengthCombo.h"
-#include "Validator.h"
-#include "qt_helpers.h"
-
-#include "debug.h"
-
-#include "controllers/ControlGraphics.h"
-
-#include "insets/InsetGraphicsParams.h"
-
-#include <QCloseEvent>
-#include <QPushButton>
-#include <QLineEdit>
-#include <QValidator>
-
-
-using std::string;
-
-namespace lyx {
-namespace frontend {
-
-
-QGraphicsDialog::QGraphicsDialog(QGraphics * form)
- : form_(form)
-{
- setupUi(this);
- //main buttons
- connect(okPB, SIGNAL(clicked()),
- form, SLOT(slotOK()));
- connect(applyPB, SIGNAL(clicked()),
- form, SLOT(slotApply()));
- connect(closePB, SIGNAL(clicked()),
- form, SLOT(slotClose()));
- connect(restorePB, SIGNAL(clicked()),
- form, SLOT(slotRestore()));
-
- //graphics pane
- connect(filename, SIGNAL(textChanged(const QString &)),
- this, SLOT(change_adaptor()));
- connect(WidthCB, SIGNAL( clicked()),
- this, SLOT(change_adaptor()));
- connect(HeightCB, SIGNAL( clicked()),
- this, SLOT(change_adaptor()));
- connect(Width, SIGNAL(textChanged(const QString &)),
- this, SLOT(change_adaptor()));
- connect(Height, SIGNAL(textChanged(const QString &)),
- this, SLOT(change_adaptor()));
- connect(heightUnit, SIGNAL(selectionChanged(lyx::Length::UNIT)),
- this, SLOT(change_adaptor()));
- connect(widthUnit, SIGNAL(selectionChanged(lyx::Length::UNIT)),
- this, SLOT(change_adaptor()));
- connect(aspectratio, SIGNAL(stateChanged(int)),
- this, SLOT(change_adaptor()));
- connect(angle, SIGNAL(textChanged(const QString &)),
- this, SLOT(change_adaptor()));
- connect(origin, SIGNAL(activated(int)),
- this, SLOT(change_adaptor()));
- connect(scaleCB, SIGNAL(clicked()),
- this, SLOT(change_adaptor()));
- connect(Scale, SIGNAL(textChanged(const QString &)),
- this, SLOT(change_adaptor()));
- connect(rotateOrderCB, SIGNAL(clicked()),
- this, SLOT(change_adaptor()));
-
- filename->setValidator(new PathValidator(true, filename));
- setFocusProxy(filename);
-
- QDoubleValidator * scaleValidator = new DoubleAutoValidator(Scale);
- scaleValidator->setBottom(0);
- scaleValidator->setDecimals(256); //I guess that will do
- Scale->setValidator(scaleValidator);
- Height->setValidator(unsignedLengthAutoValidator(Height));
- Width->setValidator(unsignedLengthAutoValidator(Width));
- angle->setValidator(new QDoubleValidator(-360, 360, 2, angle));
-
- //clipping pane
- connect(clip, SIGNAL(stateChanged(int)),
- this, SLOT(change_adaptor()));
- connect(lbY, SIGNAL(textChanged(const QString&)),
- this, SLOT(change_bb()));
- connect(lbYunit, SIGNAL(activated(int)),
- this, SLOT(change_bb()));
- connect(rtY, SIGNAL(textChanged(const QString&)),
- this, SLOT(change_bb()));
- connect(rtYunit, SIGNAL(activated(int)),
- this, SLOT(change_bb()));
- connect(lbX, SIGNAL(textChanged(const QString&)),
- this, SLOT(change_bb()));
- connect(lbXunit, SIGNAL(activated(int)),
- this, SLOT(change_bb()));
- connect(rtX, SIGNAL(textChanged(const QString&)),
- this, SLOT(change_bb()));
- connect(rtXunit, SIGNAL(activated(int)),
- this, SLOT(change_bb()));
- connect(getPB, SIGNAL(clicked()),
- this, SLOT(change_adaptor()));
-
- lbX->setValidator(new QDoubleValidator(lbX));
- lbY->setValidator(new QDoubleValidator(lbY));
- rtX->setValidator(new QDoubleValidator(rtX));
- rtY->setValidator(new QDoubleValidator(rtY));
-
- //extra options pane
- connect(latexoptions, SIGNAL(textChanged(const QString&)),
- this, SLOT(change_adaptor()));
- connect(draftCB, SIGNAL(stateChanged(int)),
- this, SLOT(change_adaptor()));
- connect(unzipCB, SIGNAL(stateChanged(int)),
- this, SLOT(change_adaptor()));
- // FIXME: we should connect to clicked() when we move to Qt 4.2 because
- // the toggled(bool) signal is also trigged when we update the widgets
- // (rgh-4/07) this isn't as much or a problem as it was, because we're now
- // using blockSignals() to keep from triggering that signal when we call
- // setChecked(). Note, too, that clicked() would get called whenever it
- // is clicked, even right clicked (I think), not just whenever it is
- // toggled.
- connect(subfigure, SIGNAL(toggled(bool)),
- this, SLOT(change_adaptor()));
- connect(subcaption, SIGNAL(textChanged(const QString&)),
- this, SLOT(change_adaptor()));
- connect(displayGB, SIGNAL(toggled(bool)),
- this, SLOT(change_adaptor()));
- connect(showCB, SIGNAL(currentIndexChanged(int)),
- this, SLOT(change_adaptor()));
- connect(displayscale, SIGNAL(textChanged(const QString&)),
- this, SLOT(change_adaptor()));
- displayscale->setValidator(new QIntValidator(displayscale));
-}
-
-
-void QGraphicsDialog::show()
-{
- QDialog::show();
-}
-
-
-void QGraphicsDialog::change_adaptor()
-{
- form_->changed();
-}
-
-
-void QGraphicsDialog::change_bb()
-{
- form_->controller().bbChanged = true;
- LYXERR(Debug::GRAPHICS)
- << "[controller().bb_Changed set to true]\n";
- form_->changed();
-}
-
-
-void QGraphicsDialog::closeEvent(QCloseEvent * e)
-{
- form_->slotWMHide();
- e->accept();
-}
-
-
-void QGraphicsDialog::on_browsePB_clicked()
-{
- docstring const str =
- form_->controller().browse(qstring_to_ucs4(filename->text()));
- if(!str.empty()){
- filename->setText(toqstr(str));
- form_->changed();
- }
-}
-
-
-void QGraphicsDialog::on_getPB_clicked()
-{
- form_->getBB();
-}
-
-
-void QGraphicsDialog::on_editPB_clicked()
-{
- form_->controller().editGraphics();
-}
-
-
-void QGraphicsDialog::on_filename_textChanged(const QString & filename)
-{
- editPB->setDisabled(filename.isEmpty());
-}
-
-
-void QGraphicsDialog::setAutoText()
-{
- if (scaleCB->isChecked()) return;
- if (!Scale->isEnabled() && Scale->text() != "100")
- Scale->setText(QString("auto"));
-
- setAutoTextCB(WidthCB, Width, widthUnit);
- setAutoTextCB(HeightCB, Height, heightUnit);
-}
-
-
-void QGraphicsDialog::on_scaleCB_toggled(bool setScale)
-{
- Scale->setEnabled(setScale);
- if (setScale) {
- Scale->setText("100");
- Scale->setFocus(Qt::OtherFocusReason);
- }
-
- WidthCB->setDisabled(setScale);
- WidthCB->blockSignals(true);
- WidthCB->setChecked(false);
- WidthCB->blockSignals(false);
- Width->setEnabled(false);
- widthUnit->setEnabled(false);
-
- HeightCB->setDisabled(setScale);
- HeightCB->blockSignals(true);
- HeightCB->setChecked(false);
- HeightCB->blockSignals(false);
- Height->setEnabled(false);
- heightUnit->setEnabled(false);
-
- aspectratio->setDisabled(true);
- aspectratio->setChecked(true);
-
- rotateOrderCB->setEnabled((WidthCB->isChecked() ||
- HeightCB->isChecked() ||
- scaleCB->isChecked()) &&
- (angle->text() != "0"));
-
- setAutoText();
-}
-
-void QGraphicsDialog::on_WidthCB_toggled(bool setWidth)
-{
- Width->setEnabled(setWidth);
- widthUnit->setEnabled(setWidth);
- if (setWidth)
- Width->setFocus(Qt::OtherFocusReason);
-
- bool const setHeight = HeightCB->isChecked();
- aspectratio->setEnabled(setWidth && setHeight);
- aspectratio->blockSignals(true);
- aspectratio->setChecked(!(setWidth && setHeight));
- aspectratio->blockSignals(false);
-
- scaleCB->setEnabled(!setWidth && !setHeight);
- //already will be unchecked, so don't need to do that
- Scale->setEnabled((!setWidth && !setHeight) //=scaleCB->isEnabled()
- && scaleCB->isChecked()); //should be false, but let's check
- rotateOrderCB->setEnabled((setWidth || setHeight ||
- scaleCB->isChecked()) &&
- (angle->text() != "0"));
-
- setAutoText();
-}
-
-void QGraphicsDialog::on_HeightCB_toggled(bool setHeight)
-{
- Height->setEnabled(setHeight);
- heightUnit->setEnabled(setHeight);
- if (setHeight)
- Height->setFocus(Qt::OtherFocusReason);
-
- bool const setWidth = WidthCB->isChecked();
- aspectratio->setEnabled(setWidth && setHeight);
- aspectratio->blockSignals(true);
- aspectratio->setChecked(!(setWidth && setHeight));
- aspectratio->blockSignals(false);
-
- scaleCB->setEnabled(!setWidth && !setHeight);
- //already unchecked
- Scale->setEnabled((!setWidth && !setHeight) //=scaleCB->isEnabled()
- && scaleCB->isChecked()); //should be false
- rotateOrderCB->setEnabled((setWidth || setHeight ||
- scaleCB->isChecked()) &&
- (angle->text() != "0"));
-
- setAutoText();
-}
-
-
-void QGraphicsDialog::on_angle_textChanged(const QString & filename)
-{
- rotateOrderCB->setEnabled((WidthCB->isChecked() ||
- HeightCB->isChecked() ||
- scaleCB->isChecked()) &&
- (filename != "0"));
-}
-
-
-} // namespace frontend
-} // namespace lyx
-
-#include "QGraphicsDialog_moc.cpp"
+++ /dev/null
-// -*- C++ -*-
-/**
- * \file QGraphicsDialog.h
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author John Levon
- * \author Herbert Voß
- * \author Richard Heck
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#ifndef QGRAPHICSDIALOG_H
-#define QGRAPHICSDIALOG_H
-
-#include "ui_GraphicsUi.h"
-
-#include <QCloseEvent>
-#include <QDialog>
-#include <QString>
-
-namespace lyx {
-namespace frontend {
-
-class QGraphics;
-
-class QGraphicsDialog : public QDialog, public Ui::QGraphicsUi {
- Q_OBJECT
-public:
- QGraphicsDialog(QGraphics * form);
- virtual void setAutoText();
- virtual void show();
-protected Q_SLOTS:
- virtual void change_adaptor();
- virtual void change_bb();
- virtual void on_browsePB_clicked();
- virtual void on_getPB_clicked();
- virtual void on_editPB_clicked();
- virtual void on_filename_textChanged(const QString &);
- virtual void on_scaleCB_toggled(bool);
- virtual void on_WidthCB_toggled(bool);
- virtual void on_HeightCB_toggled(bool);
- virtual void on_angle_textChanged(const QString &);
-protected:
- virtual void closeEvent(QCloseEvent * e);
-private:
- QGraphics * form_;
-};
-
-} // namespace frontend
-} // namespace lyx
-
-#endif // QGRAPHICSDIALOG_H
+++ /dev/null
-/**
- * \file QInclude.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author John Levon
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "support/os.h"
-#include "support/lstrings.h"
-
-#include "QInclude.h"
-
-#include "CheckedLineEdit.h"
-#include "Qt2BC.h"
-#include "qt_helpers.h"
-
-#include "LyXRC.h"
-
-#include "insets/InsetListingsParams.h"
-#include "controllers/ControlInclude.h"
-
-#include <QPushButton>
-#include <QCheckBox>
-#include <QCloseEvent>
-#include <QLineEdit>
-
-using std::string;
-using std::vector;
-
-using lyx::support::os::internal_path;
-using lyx::support::prefixIs;
-using lyx::support::getStringFromVector;
-using lyx::support::getVectorFromString;
-
-namespace lyx {
-namespace frontend {
-
-/////////////////////////////////////////////////////////////////////
-//
-// QIncludeDialog
-//
-/////////////////////////////////////////////////////////////////////
-
-QIncludeDialog::QIncludeDialog(QInclude * form)
- : form_(form)
-{
- setupUi(this);
- connect(okPB, SIGNAL(clicked()), form, SLOT(slotOK()));
- connect(closePB, SIGNAL(clicked()), form, SLOT(slotClose()));
-
- connect(visiblespaceCB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
- connect(filenameED, SIGNAL(textChanged(const QString &)),
- this, SLOT(change_adaptor()));
- connect(editPB, SIGNAL(clicked()), this, SLOT(editClicked()));
- connect(browsePB, SIGNAL(clicked()), this, SLOT(browseClicked()));
- connect(typeCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
- connect(typeCO, SIGNAL(activated(int)), this, SLOT(typeChanged(int)));
- connect(previewCB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
- connect(captionLE, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
- connect(labelLE, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
- connect(listingsED, SIGNAL(textChanged()), this, SLOT(change_adaptor()));
- connect(listingsED, SIGNAL(textChanged()), this, SLOT(set_listings_msg()));
- connect(bypassCB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
- connect(bypassCB, SIGNAL(clicked()), this, SLOT(set_listings_msg()));
-
- setFocusProxy(filenameED);
-}
-
-
-void QIncludeDialog::show()
-{
- QDialog::show();
-}
-
-
-void QIncludeDialog::change_adaptor()
-{
- form_->changed();
-}
-
-
-docstring QIncludeDialog::validate_listings_params()
-{
- // use a cache here to avoid repeated validation
- // of the same parameters
- static string param_cache = string();
- static docstring msg_cache = docstring();
-
- if (typeCO->currentIndex() != 3 || bypassCB->isChecked())
- return docstring();
-
- string params = fromqstr(listingsED->toPlainText());
- if (params != param_cache) {
- param_cache = params;
- msg_cache = InsetListingsParams(params).validate();
- }
- return msg_cache;
-}
-
-
-void QIncludeDialog::set_listings_msg()
-{
- static bool isOK = true;
- docstring msg = validate_listings_params();
- if (msg.empty()) {
- if (isOK)
- return;
- isOK = true;
- listingsTB->setPlainText(
- qt_("Input listing parameters on the right. Enter ? for a list of parameters."));
- } else {
- isOK = false;
- listingsTB->setPlainText(toqstr(msg));
- }
-}
-
-
-void QIncludeDialog::closeEvent(QCloseEvent * e)
-{
- form_->slotWMHide();
- e->accept();
-}
-
-
-void QIncludeDialog::typeChanged(int v)
-{
- switch (v) {
- //case Include
- case 0:
- visiblespaceCB->setEnabled(false);
- visiblespaceCB->setChecked(false);
- previewCB->setEnabled(false);
- previewCB->setChecked(false);
- listingsGB->setEnabled(false);
- break;
- //case Input
- case 1:
- visiblespaceCB->setEnabled(false);
- visiblespaceCB->setChecked(false);
- previewCB->setEnabled(true);
- listingsGB->setEnabled(false);
- break;
- //case listings
- case 3:
- visiblespaceCB->setEnabled(false);
- visiblespaceCB->setChecked(false);
- previewCB->setEnabled(false);
- previewCB->setChecked(false);
- listingsGB->setEnabled(true);
- break;
- //case Verbatim
- default:
- visiblespaceCB->setEnabled(true);
- previewCB->setEnabled(false);
- previewCB->setChecked(false);
- listingsGB->setEnabled(false);
- break;
- }
- //see this thread
- // http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg118471.html
- //for the reason this is here.
- okPB->setDefault(true);
-}
-
-
-void QIncludeDialog::editClicked()
-{
- form_->edit();
-}
-
-
-void QIncludeDialog::browseClicked()
-{
- form_->browse();
-}
-
-
-/////////////////////////////////////////////////////////////////////
-//
-// QInclude
-//
-/////////////////////////////////////////////////////////////////////
-
-
-typedef QController<ControlInclude, QView<QIncludeDialog> > IncludeBase;
-
-
-QInclude::QInclude(Dialog & parent)
- : IncludeBase(parent, _("Child Document"))
-{}
-
-
-void QInclude::build_dialog()
-{
- dialog_.reset(new QIncludeDialog(this));
-
- bcview().setOK(dialog_->okPB);
- bcview().setCancel(dialog_->closePB);
- bcview().addReadOnly(dialog_->filenameED);
- bcview().addReadOnly(dialog_->browsePB);
- bcview().addReadOnly(dialog_->visiblespaceCB);
- bcview().addReadOnly(dialog_->typeCO);
- bcview().addReadOnly(dialog_->listingsED);
-
- addCheckedLineEdit(bcview(), dialog_->filenameED, dialog_->filenameLA);
-}
-
-
-void QInclude::update_contents()
-{
- InsetCommandParams const & params = controller().params();
-
- dialog_->filenameED->setText(toqstr(params["filename"]));
-
- dialog_->visiblespaceCB->setChecked(false);
- dialog_->visiblespaceCB->setEnabled(false);
- dialog_->previewCB->setChecked(false);
- dialog_->previewCB->setEnabled(false);
- dialog_->listingsGB->setEnabled(false);
- dialog_->captionLE->clear();
- dialog_->labelLE->clear();
- dialog_->listingsED->clear();
- dialog_->listingsTB->setPlainText(
- qt_("Input listing parameters on the right. Enter ? for a list of parameters."));
-
- string cmdname = controller().params().getCmdName();
- if (cmdname != "include" &&
- cmdname != "verbatiminput" &&
- cmdname != "verbatiminput*" &&
- cmdname != "lstinputlisting")
- cmdname = "input";
-
- if (cmdname == "include") {
- dialog_->typeCO->setCurrentIndex(0);
-
- } else if (cmdname == "input") {
- dialog_->typeCO->setCurrentIndex(1);
- dialog_->previewCB->setEnabled(true);
- dialog_->previewCB->setChecked(params.preview());
-
- } else if (cmdname == "verbatiminput*") {
- dialog_->typeCO->setCurrentIndex(2);
- dialog_->visiblespaceCB->setEnabled(true);
- dialog_->visiblespaceCB->setChecked(true);
-
- } else if (cmdname == "verbatiminput") {
- dialog_->typeCO->setCurrentIndex(2);
- dialog_->visiblespaceCB->setEnabled(true);
-
- } else if (cmdname == "lstinputlisting") {
- dialog_->typeCO->setCurrentIndex(3);
- dialog_->listingsGB->setEnabled(true);
- dialog_->listingsED->setEnabled(true);
- InsetListingsParams par(params.getOptions());
- // extract caption and label and put them into their respective editboxes
- vector<string> pars = getVectorFromString(par.separatedParams(), "\n");
- for (vector<string>::iterator it = pars.begin();
- it != pars.end(); ++it) {
- if (prefixIs(*it, "caption=")) {
- string cap = it->substr(8);
- if (cap[0] == '{' && cap[cap.size()-1] == '}') {
- dialog_->captionLE->setText(toqstr(cap.substr(1, cap.size()-2)));
- *it = "";
- }
- } else if (prefixIs(*it, "label=")) {
- string lbl = it->substr(6);
- if (lbl[0] == '{' && lbl[lbl.size()-1] == '}') {
- dialog_->labelLE->setText(toqstr(lbl.substr(1, lbl.size()-2)));
- *it = "";
- }
- }
- }
- // the rest is put to the extra edit box.
- string extra = getStringFromVector(pars);
- dialog_->listingsED->setPlainText(toqstr(InsetListingsParams(extra).separatedParams()));
- }
-}
-
-
-void QInclude::apply()
-{
- InsetCommandParams params = controller().params();
-
- params["filename"] = from_utf8(internal_path(fromqstr(dialog_->filenameED->text())));
- params.preview(dialog_->previewCB->isChecked());
-
- int const item = dialog_->typeCO->currentIndex();
- if (item == 0) {
- params.setCmdName("include");
- } else if (item == 1) {
- params.setCmdName("input");
- } else if (item == 3) {
- params.setCmdName("lstinputlisting");
- // the parameter string should have passed validation
- InsetListingsParams par(fromqstr(dialog_->listingsED->toPlainText()));
- string caption = fromqstr(dialog_->captionLE->text());
- string label = fromqstr(dialog_->labelLE->text());
- if (!caption.empty())
- par.addParam("caption", "{" + caption + "}");
- if (!label.empty())
- par.addParam("label", "{" + label + "}");
- params.setOptions(par.params());
- } else {
- if (dialog_->visiblespaceCB->isChecked())
- params.setCmdName("verbatiminput*");
- else
- params.setCmdName("verbatiminput");
- }
- controller().setParams(params);
-}
-
-
-void QInclude::browse()
-{
- ControlInclude::Type type;
-
- int const item = dialog_->typeCO->currentIndex();
- if (item == 0)
- type = ControlInclude::INCLUDE;
- else if (item == 1)
- type = ControlInclude::INPUT;
- else if (item == 2)
- type = ControlInclude::VERBATIM;
- else
- type = ControlInclude::LISTINGS;
-
- docstring const & name =
- controller().browse(qstring_to_ucs4(dialog_->filenameED->text()), type);
- if (!name.empty())
- dialog_->filenameED->setText(toqstr(name));
-}
-
-
-void QInclude::edit()
-{
- if (isValid()) {
- string const file = fromqstr(dialog_->filenameED->text());
- slotOK();
- controller().edit(file);
- }
-}
-
-
-bool QInclude::isValid()
-{
- return !dialog_->filenameED->text().isEmpty() &&
- dialog_->validate_listings_params().empty();
-}
-
-} // namespace frontend
-} // namespace lyx
-
-#include "QInclude_moc.cpp"
+++ /dev/null
-// -*- C++ -*-
-/**
- * \file QInclude.h
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author John Levon
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#ifndef QINCLUDE_H
-#define QINCLUDE_H
-
-#include "QDialogView.h"
-
-#include "ui_IncludeUi.h"
-
-#include <QDialog>
-
-namespace lyx {
-namespace frontend {
-
-class QInclude;
-
-class QIncludeDialog : public QDialog, public Ui::QIncludeUi {
- Q_OBJECT
-public:
- QIncludeDialog(QInclude * form);
-
- void updateLists();
-
- virtual void show();
- /// validate listings parameters and return an error message, if any
- docstring validate_listings_params();
-protected Q_SLOTS:
- virtual void change_adaptor();
- virtual void editClicked();
- virtual void browseClicked();
- virtual void typeChanged(int v);
- /// AFAIK, QValidator only works for QLineEdit so
- /// I have to validate listingsED (QTextEdit) manually.
- /// This function displays a hint or error message returned by
- /// validate_listings_params
- void set_listings_msg();
-protected:
- virtual void closeEvent(QCloseEvent * e);
-private:
- QInclude * form_;
-};
-
-
-class ControlInclude;
-
-///
-class QInclude : public QController<ControlInclude, QView<QIncludeDialog> >
-{
-public:
- ///
- friend class QIncludeDialog;
- ///
- QInclude(Dialog &);
-protected:
- virtual bool isValid();
-private:
- /// Apply changes
- virtual void apply();
- /// update
- virtual void update_contents();
- /// build the dialog
- virtual void build_dialog();
-
- /// edit the child document, .lyx file will be opened in lyx
- /// other formats will be edited by external applications.
- void edit();
-
- /// browse for a file
- void browse();
-};
-
-} // namespace frontend
-} // namespace lyx
-
-#endif // QINCLUDE_H
+++ /dev/null
-/**
- * \file QIndex.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author John Levon
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "debug.h"
-#include "ControlCommand.h"
-#include "qt_helpers.h"
-
-#include "QIndex.h"
-#include "Qt2BC.h"
-#include "ButtonController.h"
-
-#include <QLabel>
-#include <QPushButton>
-#include <QLineEdit>
-#include <QWhatsThis>
-#include <QCloseEvent>
-
-
-using std::string;
-
-/////////////////////////////////////////////////////////////////////
-//
-// QIndexDialog
-//
-/////////////////////////////////////////////////////////////////////
-
-namespace lyx {
-namespace frontend {
-
-QIndexDialog::QIndexDialog(QIndex * form)
- : form_(form)
-{
- setupUi(this);
-
- connect(okPB, SIGNAL(clicked()), form, SLOT(slotOK()));
- connect(closePB, SIGNAL(clicked()), form, SLOT(slotClose()));
- connect( keywordED, SIGNAL(textChanged(const QString &)),
- this, SLOT(change_adaptor()));
-
- setFocusProxy(keywordED);
-
- keywordED->setWhatsThis( qt_(
- "The format of the entry in the index.\n"
- "\n"
- "An entry can be specified as a sub-entry of\n"
- "another with \"!\":\n"
- "\n"
- "cars!mileage\n"
- "\n"
- "You can cross-refer to another entry like so:\n"
- "\n"
- "cars!mileage|see{economy}\n"
- "\n"
- "For further details refer to the local LaTeX\n"
- "documentation.\n")
- );
-}
-
-
-void QIndexDialog::change_adaptor()
-{
- form_->changed();
-}
-
-
-void QIndexDialog::reject()
-{
- form_->slotClose();
-}
-
-
-void QIndexDialog::closeEvent(QCloseEvent * e)
-{
- form_->slotWMHide();
- e->accept();
-}
-
-
-/////////////////////////////////////////////////////////////////////
-//
-// QIndex
-//
-/////////////////////////////////////////////////////////////////////
-
-
-typedef QController<ControlCommand, QView<QIndexDialog> > IndexBase;
-
-QIndex::QIndex(Dialog & parent, docstring const & title, QString const & label)
- : IndexBase(parent, title), label_(label)
-{
-}
-
-
-void QIndex::build_dialog()
-{
- dialog_.reset(new QIndexDialog(this));
-
- dialog_->keywordLA->setText(label_);
-
- bcview().setOK(dialog_->okPB);
- bcview().setCancel(dialog_->closePB);
- bcview().addReadOnly(dialog_->keywordED);
-}
-
-
-void QIndex::update_contents()
-{
- docstring const contents = controller().params()["name"];
- dialog_->keywordED->setText(toqstr(contents));
-
- bc().valid(!contents.empty());
-}
-
-
-void QIndex::apply()
-{
- controller().params()["name"] = qstring_to_ucs4(dialog_->keywordED->text());
-}
-
-
-bool QIndex::isValid()
-{
- return !dialog_->keywordED->text().isEmpty();
-}
-
-} // namespace frontend
-} // namespace lyx
-
-#include "QIndex_moc.cpp"
+++ /dev/null
-// -*- C++ -*-
-/**
- * \file QIndex.h
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author John Levon
- * \author Kalle Dalheimer
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#ifndef QINDEX_H
-#define QINDEX_H
-
-#include "QDialogView.h"
-#include "ui_IndexUi.h"
-
-#include <QDialog>
-#include <QCloseEvent>
-
-namespace lyx {
-namespace frontend {
-
-class QIndex;
-
-class QIndexDialog : public QDialog, public Ui::QIndexUi {
- Q_OBJECT
-public:
- QIndexDialog(QIndex * form);
-
-protected Q_SLOTS:
- virtual void change_adaptor();
- virtual void reject();
-protected:
- virtual void closeEvent(QCloseEvent * e);
-private:
- QIndex * form_;
-};
-
-
-class ControlCommand;
-
-class QIndex :
- public QController<ControlCommand, QView<QIndexDialog> >
-{
-public:
- friend class QIndexDialog;
-
- QIndex(Dialog &, docstring const & title, QString const & label);
-protected:
- virtual bool isValid();
-private:
- /// Apply changes
- virtual void apply();
- /// update
- virtual void update_contents();
- /// build the dialog
- virtual void build_dialog();
-
- ///
- QString const label_;
-};
-
-} // namespace frontend
-} // namespace lyx
-
-#endif // QINDEX_H
+++ /dev/null
-/**
- * \file QKeySymbol.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Asger and Jürgen
- * \author John Levon
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "QKeySymbol.h"
-#include "qlkey.h"
-#include "qt_helpers.h"
-
-
-#include "debug.h"
-
-#include <QKeyEvent>
-#include <QKeySequence>
-#include <QEvent>
-#include <QTextCodec>
-
-#include <map>
-#include "support/lstrings.h"
-#include "support/environment.h"
-#include "support/unicode.h"
-
-#include "Encoding.h"
-#include "Language.h"
-
-
-namespace lyx {
-
-using std::endl;
-using std::string;
-using std::map;
-using lyx::support::contains;
-using lyx::support::getEnv;
-
-
-namespace {
-
-typedef map<string, QTextCodec *> EncodingMap;
-EncodingMap encoding_map;
-
-char const encode(string const & encoding, QString const & str)
-{
- QTextCodec * codec = 0;
-
- EncodingMap::const_iterator cit = encoding_map.find(encoding);
- if (cit == encoding_map.end()) {
- LYXERR(Debug::KEY) << "Unrecognised encoding '" << encoding
- << "'." << endl;
- codec = encoding_map.find("")->second;
- } else {
- codec = cit->second;
- }
-
- if (!codec) {
- LYXERR(Debug::KEY) << "No codec for encoding '" << encoding
- << "' found." << endl;
- return 0;
- }
-
- LYXERR(Debug::KEY) << "Using codec " << fromqstr(codec->name()) << endl;
-
- if (!codec->canEncode(str)) {
- LYXERR(Debug::KEY) << "Oof. Can't encode the text !" << endl;
- return 0;
- }
-
- return codec->fromUnicode(str).data()[0];
-}
-
-}
-
-
-QKeySymbol::QKeySymbol()
- : KeySymbol(), key_(0)
-{
-}
-
-
-void QKeySymbol::set(QKeyEvent * ev)
-{
- key_ = ev->key();
- if (ev->text().isNull()) {
- LYXERR(Debug::KEY) << "keyevent has isNull() text !" << endl;
- text_ = "";
- return;
- }
- text_ = ev->text();
- LYXERR(Debug::KEY) << "Setting key to " << key_ << ", " << fromqstr(text_) << endl;
-}
-
-
-void QKeySymbol::init(string const & symbolname)
-{
- key_ = string_to_qkey(symbolname);
- text_ = toqstr(symbolname);
- LYXERR(Debug::KEY) << "Init key to " << key_ << ", " << fromqstr(text_) << endl;
-}
-
-
-bool QKeySymbol::isOK() const
-{
- bool const ok(!(text_.isEmpty() && key_ == Qt::Key_unknown));
- LYXERR(Debug::KEY) << "isOK is " << ok << endl;
- return ok;
-}
-
-
-bool QKeySymbol::isModifier() const
-{
- bool const mod(q_is_modifier(key_));
- LYXERR(Debug::KEY) << "isMod is " << mod << endl;
- return mod;
-}
-
-
-string QKeySymbol::getSymbolName() const
-{
- string sym(qkey_to_string(key_));
-
- // e.g. A-Za-z, and others
- if (sym.empty())
- sym = fromqstr(text_);
-
- return sym;
-}
-
-
-char_type QKeySymbol::getUCSEncoded() const
-{
- if (text_.isEmpty())
- return 0;
-
- // UTF16 has a maximum of two characters.
- BOOST_ASSERT(text_.size() <= 2);
-
- if (lyxerr.debugging() && text_.size() > 1) {
- // We don't know yet how well support the full ucs4 range.
- LYXERR(Debug::KEY) << "QKeySymbol::getUCSEncoded()" << endl;
- for (int i = 0; i < text_.size(); ++i) {
- LYXERR(Debug::KEY) << "char " << i << ": "
- << text_[i].unicode() << endl;
- }
- }
-
- // Only one UCS4 character at the end.
- docstring ucs4_text = qstring_to_ucs4(text_);
- return ucs4_text[0];
-}
-
-
-docstring const QKeySymbol::print(key_modifier::state mod, bool forgui) const
-{
- int tmpkey = key_;
-
- if (mod & key_modifier::shift)
- tmpkey += Qt::SHIFT;
- if (mod & key_modifier::ctrl)
- tmpkey += Qt::CTRL;
- if (mod & key_modifier::alt)
- tmpkey += Qt::ALT;
-
- QKeySequence seq(tmpkey);
-
- return qstring_to_ucs4(seq.toString(forgui ? QKeySequence::NativeText
- : QKeySequence::PortableText));
-}
-
-
-bool QKeySymbol::isText() const
-{
- if (text_.isEmpty()) {
- LYXERR(Debug::KEY) << "text_ empty, isText() == false" << endl;
- return false;
- }
-
- return true;
-}
-
-
-bool QKeySymbol::operator==(KeySymbol const & ks) const
-{
- QKeySymbol const & qks = static_cast<QKeySymbol const &>(ks);
-
- // we do not have enough info for a fair comparison, so return
- // false. This works out OK because unknown text from Qt will
- // get inserted anyway after the isText() check
- if (key_ == Qt::Key_unknown || qks.key_ == Qt::Key_unknown)
- return false;
-
- return key_ == qks.key_;
-}
-
-
-key_modifier::state q_key_state(Qt::KeyboardModifiers state)
-{
- key_modifier::state k = key_modifier::none;
- if (state & Qt::ControlModifier)
- k |= key_modifier::ctrl;
- if (state & Qt::ShiftModifier)
- k |= key_modifier::shift;
- if (state & Qt::AltModifier || state & Qt::MetaModifier)
- k |= key_modifier::alt;
- return k;
-}
-
-} // namespace lyx
+++ /dev/null
-// -*- C++ -*-
-/**
- * \file QKeySymbol.h
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Asger and Jürgen
- * \author John Levon
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#ifndef QLYXKEYSYM_H
-#define QLYXKEYSYM_H
-
-#include "frontends/KeySymbol.h"
-
-#include <QString>
-#include <QKeyEvent>
-
-
-class QKeyEvent;
-
-namespace lyx {
-
-/**
- * Qt-specific key press.
- *
- * This is some really sick stuff.
- */
-class QKeySymbol : public KeySymbol {
-public:
- QKeySymbol();
-
- virtual ~QKeySymbol() {}
-
- /// .
- /// inlined out because of profiling results under linux when
- /// opening a document.
- inline bool operator==(KeySymbol const& ks) const;
-
- /// delayed constructor
- void set(QKeyEvent * ev);
-
- /// set from a LyX symbolic name
- virtual void init(std::string const & symbolname);
-
- /// Is this a valid key?
- virtual bool isOK() const;
-
- /// Is this a modifier key only?
- virtual bool isModifier() const;
-
- /// return the LyX symbolic name
- virtual std::string getSymbolName() const;
-
- /// Is this normal insertable text ? (last ditch attempt only)
- virtual bool isText() const;
-
- /**
- * Return the value of the keysym into the UCS-4 encoding.
- * This converts the KeySymbol to a 32-bit encoded character.
- */
- virtual char_type getUCSEncoded() const;
-
- /**
- * Return a human-readable version of a key+modifier pair.
- * This will be the GUI version (translated and with special
- * characters for Mac OS X) when \c forgui is true.
- */
- virtual docstring const print(key_modifier::state mod, bool forgui) const;
-
- ///
- int key() const {
- return key_;
- }
-private:
- /// the Qt sym value
- int key_;
- /// the event string value
- QString text_;
-};
-
-/// return the LyX key state from Qt's
-key_modifier::state q_key_state(Qt::KeyboardModifiers state);
-
-} // namespace lyx
-
-#endif // QLYXKEYSYM_H
+++ /dev/null
-/**
- * \file QLImage.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Angus Leeming
- * \author John Levon
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "QLImage.h"
-#include "qt_helpers.h"
-
-#include "debug.h"
-#include "Format.h"
-
-#include "graphics/GraphicsParams.h"
-
-#include "support/FileName.h"
-#include "support/lstrings.h" // ascii_lowercase
-
-#include <QPainter>
-#include <QPictureIO>
-#include <QPicture>
-#include <QImage>
-#include <QImageReader>
-
-#include <boost/bind.hpp>
-#include <boost/tuple/tuple.hpp>
-
-using lyx::support::ascii_lowercase;
-
-using boost::bind;
-
-using std::endl;
-using std::equal_to;
-using std::find_if;
-using std::string;
-
-QPictureIO StaticPicture;
-
-namespace lyx {
-namespace graphics {
-
-/// Access to this class is through this static method.
-Image::ImagePtr QLImage::newImage()
-{
- ImagePtr ptr;
- ptr.reset(new QLImage);
- return ptr;
-}
-
-
-/// Return the list of loadable formats.
-Image::FormatList QLImage::loadableFormats()
-{
- static FormatList fmts;
-
- if (!fmts.empty())
- return fmts;
-
- // The formats recognised by LyX
- Formats::const_iterator begin = formats.begin();
- Formats::const_iterator end = formats.end();
-
-
-// LYXERR(Debug::GRAPHICS)
-// << "D:/msys/home/yns/src/lyx-devel/lib/images/banner.png mis of format: "
-// << fromqstr(Pic.pictureFormat("D:/msys/home/yns/src/lyx-devel/lib/images/banner.png"))
-// << endl;
-// if (Pic.pictureFormat("D:/msys/home/yns/src/lyx-devel/lib/images/banner.png"))
-// LYXERR(Debug::GRAPHICS)
-// << "pictureFormat not returned NULL\n" << endl;
-// << "Supported formats are: " << Pic.inputFormats() << endl;
-
- QList<QByteArray> qt_formats = QImageReader::supportedImageFormats ();
-
- LYXERR(Debug::GRAPHICS)
- << "\nThe image loader can load the following directly:\n";
-
- if (qt_formats.empty())
- LYXERR(Debug::GRAPHICS)
- << "\nQt4 Problem: No Format available!" << endl;
-
- for (QList<QByteArray>::const_iterator it =qt_formats.begin(); it != qt_formats.end(); ++it) {
-
- LYXERR(Debug::GRAPHICS) << (const char *) *it << ", ";
-
- string ext = ascii_lowercase((const char *) *it);
-
- // special case
- if (ext == "jpeg")
- ext = "jpg";
-
- Formats::const_iterator fit =
- find_if(begin, end,
- bind(equal_to<string>(),
- bind(&Format::extension, _1),
- ext));
- if (fit != end)
- fmts.push_back(fit->name());
- }
-
- if (lyxerr.debugging()) {
- LYXERR(Debug::GRAPHICS)
- << "\nOf these, LyX recognises the following formats:\n";
-
- FormatList::const_iterator fbegin = fmts.begin();
- FormatList::const_iterator fend = fmts.end();
- for (FormatList::const_iterator fit = fbegin; fit != fend; ++fit) {
- if (fit != fbegin)
- LYXERR(Debug::GRAPHICS) << ", ";
- LYXERR(Debug::GRAPHICS) << *fit;
- }
- LYXERR(Debug::GRAPHICS) << '\n' << endl;
- }
-
- return fmts;
-}
-
-
-QLImage::QLImage()
- : Image()
-{
-}
-
-
-QLImage::QLImage(QLImage const & other)
- : Image(other), original_(other.original_),
- transformed_(other.transformed_),
- transformed_pixmap_(other.transformed_pixmap_)
-{}
-
-
-Image * QLImage::clone_impl() const
-{
- return new QLImage(*this);
-}
-
-
-unsigned int QLImage::getWidth_impl() const
-{
- return transformed_.width();
-}
-
-
-unsigned int QLImage::getHeight_impl() const
-{
- return transformed_.height();
-}
-
-
-void QLImage::load_impl(support::FileName const & filename)
-{
- if (!original_.isNull()) {
- LYXERR(Debug::GRAPHICS)
- << "Image is loaded already!" << endl;
- finishedLoading(false);
- return;
- }
-
- if (!original_.load(toqstr(filename.absFilename()))) {
- LYXERR(Debug::GRAPHICS)
- << "Unable to open image" << endl;
- finishedLoading(false);
- return;
- }
- transformed_ = original_;
- finishedLoading(true);
-}
-
-
-namespace {
-
-// This code is taken from KImageEffect::toGray
-QImage & toGray(QImage & img)
-{
- if (img.width() == 0 || img.height() == 0)
- return img;
-
- int const pixels = img.depth() > 8 ?
- img.width() * img.height() : img.numColors();
-
- unsigned int *data = img.depth() > 8 ?
- reinterpret_cast<unsigned int *>(img.bits()) :
- reinterpret_cast<unsigned int *>(&img.colorTable()[0]);
-
- for(int i = 0; i < pixels; ++i){
- int const val = qGray(data[i]);
- data[i] = qRgba(val, val, val, qAlpha(data[i]));
- }
- return img;
-}
-
-} // namespace anon
-
-
-bool QLImage::setPixmap_impl(Params const & params)
-{
- if (original_.isNull() || params.display == NoDisplay)
- return false;
-
- switch (params.display) {
- case GrayscaleDisplay: {
- toGray(transformed_);
- break;
- }
-
- case MonochromeDisplay: {
- transformed_.convertToFormat(transformed_.format(), Qt::MonoOnly);
- break;
- }
-
- default:
- break;
- }
-
- transformed_pixmap_ = QPixmap::fromImage(transformed_);
- return true;
-}
-
-
-void QLImage::clip_impl(Params const & params)
-{
- if (transformed_.isNull())
- return;
-
- if (params.bb.empty())
- // No clipping is necessary.
- return;
-
- int const new_width = params.bb.xr - params.bb.xl;
- int const new_height = params.bb.yt - params.bb.yb;
-
- // No need to check if the width, height are > 0 because the
- // Bounding Box would be empty() in this case.
- if (new_width > original_.width() || new_height > original_.height()) {
- // Bounds are invalid.
- return;
- }
-
- if (new_width == original_.width() && new_height == original_.height())
- return;
-
- int const xoffset_l = params.bb.xl;
- int const yoffset_t = (original_.height() > int(params.bb.yt) ?
- original_.height() - params.bb.yt : 0);
-
- transformed_ = original_.copy(xoffset_l, yoffset_t,
- new_width, new_height);
-}
-
-
-void QLImage::rotate_impl(Params const & params)
-{
- if (transformed_.isNull())
- return;
-
- if (!params.angle)
- return;
-
- QMatrix m;
- m.rotate(-params.angle);
-
- transformed_ = transformed_.transformed(m);
-}
-
-
-void QLImage::scale_impl(Params const & params)
-{
- if (transformed_.isNull())
- return;
-
- unsigned int width;
- unsigned int height;
- boost::tie(width, height) = getScaledDimensions(params);
-
- if (width == getWidth() && height == getHeight())
- return;
-
- QMatrix m;
- m.scale(double(width) / getWidth(), double(height) / getHeight());
- transformed_ = transformed_.transformed(m);
-}
-
-} // namespace graphics
-} // lyx
+++ /dev/null
-// -*- C++ -*-
-/**
- * \file QLImage.h
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Angus Leeming
- * \author John Levon
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#ifndef QLIMAGE_H
-#define QLIMAGE_H
-
-
-#include "graphics/GraphicsImage.h"
-
-#include <qimage.h>
-//Added by qt3to4:
-#include <QPixmap>
-
-namespace lyx {
-namespace graphics {
-
-class QLImage : public Image {
-public:
- /// Access to this class is through this static method.
- static ImagePtr newImage();
-
- /// Return the list of loadable formats.
- static FormatList loadableFormats();
-
- /// Retrieve the buffered pixmap.
- QPixmap const & qpixmap() const { return transformed_pixmap_; }
-
- /// Retrieve the buffered pixmap.
- QImage const & qimage() const { return transformed_; }
-
-private:
- /// Create a copy
- virtual Image * clone_impl() const;
- /// Get the image width
- virtual unsigned int getWidth_impl() const;
- /// Get the image height
- virtual unsigned int getHeight_impl() const;
- // FIXME Is the image drawable ?
- virtual bool isDrawable_impl() const { return true; }
- /**
- * Load the image file into memory.
- * The process is asynchronous, so this method starts the loading.
- * When finished, the Image::finishedLoading signal is emitted.
- */
- virtual void load_impl(support::FileName const & filename);
- /**
- * Finishes the process of modifying transformed_, using
- * \c params to decide on color, grayscale etc.
- * \returns true if successful.
- */
- virtual bool setPixmap_impl(Params const & params);
- /// Clip the image using params.
- virtual void clip_impl(Params const & params);
- /// Rotate the image using params.
- virtual void rotate_impl(Params const & params);
- /// Scale the image using params.
- virtual void scale_impl(Params const & params);
-
- /// Access to the class is through newImage() and clone.
- QLImage();
- ///
- QLImage(QLImage const &);
-
- /// The original loaded image.
- QImage original_;
-
- /// The transformed image for display.
- QImage transformed_;
- /// Buffer the pixmap itself
- QPixmap transformed_pixmap_;
-};
-
-} // namespace graphics
-} // namespace lyx
-
-#endif // QLIMAGE_H
+++ /dev/null
-/**
- * \file qt4/QLMenubar.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author John Levon
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-// Qt defines a macro 'signals' that clashes with a boost namespace.
-// All is well if the namespace is visible first.
-#include "GuiView.h"
-
-#include "Action.h"
-#include "QLMenubar.h"
-#include "QLPopupMenu.h"
-
-#include "qt_helpers.h"
-#include "support/lstrings.h"
-
-#include "MenuBackend.h"
-
-#include "debug.h"
-
-#include <QCursor>
-#include <QMenuBar>
-
-using std::pair;
-using std::string;
-using std::endl;
-
-namespace lyx {
-namespace frontend {
-
-// MacOSX specific stuff is at the end.
-
-QLMenubar::QLMenubar(LyXView * view, MenuBackend & mbe)
- : owner_(static_cast<GuiView*>(view)), menubackend_(mbe)
-{
- macxMenuBarInit();
-
- LYXERR(Debug::GUI) << "populating menu bar" << to_utf8(menubackend_.getMenubar().name()) << endl;
-
- if (menubackend_.getMenubar().size() == 0) {
- LYXERR(Debug::GUI) << "\tERROR: empty menu bar"
- << to_utf8(menubackend_.getMenubar().name()) << endl;
- return;
- // continue;
- }
- else {
- LYXERR(Debug::GUI) << "menu bar entries "
- << menubackend_.getMenubar().size();
- }
-
- Menu menu;
- menubackend_.expand(menubackend_.getMenubar(), menu, owner_->buffer());
-
- Menu::const_iterator m = menu.begin();
- Menu::const_iterator end = menu.end();
-
- for (; m != end; ++m) {
-
- if (m->kind() != MenuItem::Submenu) {
- LYXERR(Debug::GUI) << "\tERROR: not a submenu "
- << to_utf8(m->label()) << endl;
- continue;
- }
-
- LYXERR(Debug::GUI) << "menu bar item " << to_utf8(m->label())
- << " is a submenu named " << to_utf8(m->submenuname()) << endl;
-
- docstring name = m->submenuname();
- if (!menubackend_.hasMenu(name)) {
- LYXERR(Debug::GUI) << "\tERROR: " << to_utf8(name)
- << " submenu has no menu!" << endl;
- continue;
- }
-
- Menu menu;
- menubackend_.expand(menubackend_.getMenubar(), menu, owner_->buffer());
-
- QLPopupMenu * qMenu = new QLPopupMenu(this, *m, true);
- owner_->menuBar()->addMenu(qMenu);
-
- pair<NameMap::iterator, bool> I = name_map_.insert(make_pair(name, qMenu));
- if (!I.second) {
- LYXERR(Debug::GUI) << "\tERROR: " << to_utf8(name)
- << " submenu is already there!" << endl;
- }
-/*
- QObject::connect(qMenu, SIGNAL(aboutToShow()), this, SLOT(update()));
- QObject::connect(qMenu, SIGNAL(triggered(QAction *)), this, SLOT(update()));
- QObject::connect(qMenu->menuAction(), SIGNAL(triggered()), this, SLOT(update()));
-*/
- }
- //QObject::connect(owner_->menuBar(), SIGNAL(triggered()), this, SLOT(update()));
-}
-
-void QLMenubar::openByName(docstring const & name)
-{
- NameMap::const_iterator const cit = name_map_.find(name);
- if (cit == name_map_.end())
- return;
-
- // I (Abdel) don't understand this comment:
- // this will have to do I'm afraid.
- cit->second->exec(QCursor::pos());
-}
-
-
-GuiView * QLMenubar::view()
-{
- return owner_;
-}
-
-
-MenuBackend const & QLMenubar::backend()
-{
- return menubackend_;
-}
-
-
-/// Some special Qt/Mac support hacks
-
-/*
- Here is what the Qt documentation says about how a menubar is chosen:
-
- 1) If the window has a QMenuBar then it is used. 2) If the window
- is a modal then its menubar is used. If no menubar is specified
- then a default menubar is used (as documented below) 3) If the
- window has no parent then the default menubar is used (as
- documented below).
-
- The above 3 steps are applied all the way up the parent window
- chain until one of the above are satisifed. If all else fails a
- default menubar will be created, the default menubar on Qt/Mac is
- an empty menubar, however you can create a different default
- menubar by creating a parentless QMenuBar, the first one created
- will thus be designated the default menubar, and will be used
- whenever a default menubar is needed.
-
- Thus, for Qt/Mac, we add the menus to a free standing menubar, so
- that this menubar will be used also when one of LyX' dialogs has
- focus. (JMarc)
-*/
-QMenuBar * QLMenubar::menuBar() const
-{
-#ifdef Q_WS_MACX
- return mac_menubar_.get();
-#else
- return owner_->menuBar();
-#endif
-}
-
-#ifdef Q_WS_MACX
-extern void qt_mac_set_menubar_merge(bool b);
-#endif
-
-void QLMenubar::macxMenuBarInit()
-{
-#ifdef Q_WS_MACX
- mac_menubar_.reset(new QMenuBar);
-
-# if QT_VERSION >= 0x040200
- /* Since Qt 4.2, the qt/mac menu code has special code for
- specifying the role of a menu entry. However, it does not
- work very well with our scheme of creating menus on demand,
- and therefore we need to put these entries in a special
- invisible menu. (JMarc)
- */
-
- /* The entries of our special mac menu. If we add support for
- * special entries in MenuBackend, we could imagine something
- * like
- * SpecialItem About " "About LyX" "dialog-show aboutlyx"
- * and therefore avoid hardcoding. I am not sure it is worth
- * the hassle, though. (JMarc)
- */
- struct MacMenuEntry {
- kb_action action;
- char const * arg;
- char const * label;
- QAction::MenuRole role;
- };
-
- MacMenuEntry entries[] = {
- {LFUN_DIALOG_SHOW, "aboutlyx", "About LyX",
- QAction::AboutRole},
- {LFUN_DIALOG_SHOW, "prefs", "Preferences",
- QAction::PreferencesRole},
- {LFUN_RECONFIGURE, "", "Reconfigure",
- QAction::ApplicationSpecificRole},
- {LFUN_LYX_QUIT, "", "Quit LyX", QAction::QuitRole}
- };
- const size_t num_entries = sizeof(entries) / sizeof(MacMenuEntry);
-
- // the special menu for MenuBackend.
- Menu special;
- for (size_t i = 0 ; i < num_entries ; ++i) {
- FuncRequest const func(entries[i].action,
- from_utf8(entries[i].arg));
- special.add(MenuItem(MenuItem::Command,
- from_utf8(entries[i].label),
- func));
- }
- menubackend_.specialMenu(special);
-
- // add the entries to a QMenu that will eventually be empty
- // and therefore invisible.
- QMenu * qMenu = owner_->menuBar()->addMenu("special");
-
- // we do not use 'special' because it is a temporary variable,
- // whereas MenuBackend::specialMenu points to a persistent
- // copy.
- Menu::const_iterator cit = menubackend_.specialMenu().begin();
- Menu::const_iterator end = menubackend_.specialMenu().end();
- for (size_t i = 0 ; cit != end ; ++cit, ++i) {
- Action * action = new Action(*owner_, cit->label(),
- cit->func());
- action->setMenuRole(entries[i].role);
- qMenu->addAction(action);
-
- }
-# else
- qt_mac_set_menubar_merge(false);
-# endif // QT_VERSION >= 0x040200
-#endif // Q_WS_MACX
-}
-
-} // namespace frontend
-} // namespace lyx
-
-#include "QLMenubar_moc.cpp"
+++ /dev/null
-// -*- C++ -*-
-/**
- * \file qt4/QLMenubar.h
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Lars Gullik Bjønnes
- * \author John Levon
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#ifndef QLMENUBAR_H
-#define QLMENUBAR_H
-
-#include "QLPopupMenu.h"
-
-#include <map>
-#include <boost/scoped_ptr.hpp>
-
-#include <QObject>
-#include <QMenuBar>
-
-namespace lyx {
-
-class MenuBackend;
-class Menu;
-class MenuItem;
-
-namespace frontend {
-
-class GuiView;
-class LyXView;
-
-class QLMenubar : public QObject {
- Q_OBJECT
-public:
- QLMenubar(LyXView *, MenuBackend &);
-
- /// opens a top-level submenu given its name
- void openByName(docstring const &);
-
- /// return the owning view
- GuiView * view();
-
- /// return the menu controller
- MenuBackend const & backend();
-
- /// The QMenuBar used by LyX
- QMenuBar * menuBar() const;
-
- /// update the state of the menuitems - not needed
- void update();
-
-private:
- /// Initialize specific MACOS X menubar
- void macxMenuBarInit();
-
- /// owning view
- GuiView * owner_;
-
- /// menu controller
- MenuBackend & menubackend_;
-
- typedef std::map<docstring, QLPopupMenu *> NameMap;
-
- /// name to menu for openByName
- NameMap name_map_;
-
- /// MACOS X special menubar.
- boost::scoped_ptr<QMenuBar> mac_menubar_;
-};
-
-} // namespace frontend
-} // namespace lyx
-
-#endif // QLMENUBAR_H
+++ /dev/null
-/**
- * \file QLPainter.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author John Levon
- * \author Abdelrazak Younes
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "QLPainter.h"
-
-#include "GuiApplication.h"
-#include "GuiFontMetrics.h"
-#include "QLImage.h"
-
-#include "GuiApplication.h"
-#include "qt_helpers.h"
-
-#include "debug.h"
-#include "Language.h"
-#include "Color.h"
-
-#include "support/unicode.h"
-
-#include <QPixmapCache>
-#include <QTextLayout>
-
-// Set USE_PIXMAP_CACHE to 1 for enabling the use of a Pixmap cache when
-// drawing text. This is especially useful for older PPC/Mac systems.
-#if (QT_VERSION < 0x040200) || defined(Q_WS_X11)
-#define USE_PIXMAP_CACHE 0
-#else
-#define USE_PIXMAP_CACHE 1
-#endif
-
-using std::endl;
-using std::string;
-
-namespace lyx {
-namespace frontend {
-
-namespace {
-
-bool const usePixmapCache = USE_PIXMAP_CACHE;
-
-QString generateStringSignature(QString const & str, Font const & f)
-{
- QString sig = str;
- sig.append(QChar(static_cast<short>(f.family())));
- sig.append(QChar(static_cast<short>(f.series())));
- sig.append(QChar(static_cast<short>(f.realShape())));
- sig.append(QChar(static_cast<short>(f.size())));
- sig.append(QChar(static_cast<short>(f.color())));
- return sig;
-}
-
-} // anon namespace
-
-QLPainter::QLPainter(QPaintDevice * device)
- : QPainter(device), Painter()
-{
- // new QPainter has default QPen:
- current_color_ = Color::black;
- current_ls_ = line_solid;
- current_lw_ = line_thin;
-}
-
-
-QLPainter::~QLPainter()
-{
- QPainter::end();
- //lyxerr << "QLPainter::end()" << endl;
-}
-
-
-void QLPainter::setQPainterPen(Color_color col,
- Painter::line_style ls, Painter::line_width lw)
-{
- if (col == current_color_ && ls == current_ls_ && lw == current_lw_)
- return;
-
- current_color_ = col;
- current_ls_ = ls;
- current_lw_ = lw;
-
- QPen pen = QPainter::pen();
-
- pen.setColor(guiApp->colorCache().get(col));
-
- switch (ls) {
- case line_solid: pen.setStyle(Qt::SolidLine); break;
- case line_onoffdash: pen.setStyle(Qt::DotLine); break;
- }
-
- switch (lw) {
- case line_thin: pen.setWidth(0); break;
- case line_thick: pen.setWidth(3); break;
- }
-
- setPen(pen);
-}
-
-
-void QLPainter::point(int x, int y, Color_color col)
-{
- if (!isDrawingEnabled())
- return;
-
- setQPainterPen(col);
- drawPoint(x, y);
-}
-
-
-void QLPainter::line(int x1, int y1, int x2, int y2,
- Color_color col,
- line_style ls,
- line_width lw)
-{
- if (!isDrawingEnabled())
- return;
-
- setQPainterPen(col, ls, lw);
- bool const do_antialiasing = renderHints() & TextAntialiasing
- && x1 != x2 && y1 != y2;
- setRenderHint(Antialiasing, do_antialiasing);
- drawLine(x1, y1, x2, y2);
- setRenderHint(Antialiasing, false);
-}
-
-
-void QLPainter::lines(int const * xp, int const * yp, int np,
- Color_color col,
- line_style ls,
- line_width lw)
-{
- if (!isDrawingEnabled())
- return;
-
- // double the size if needed
- static QVector<QPoint> points(32);
- if (np > points.size())
- points.resize(2 * np);
-
- bool antialias = false;
- for (int i = 0; i < np; ++i) {
- points[i].setX(xp[i]);
- points[i].setY(yp[i]);
- if (i != 0)
- antialias |= xp[i-1] != xp[i] && yp[i-1] != yp[i];
- }
- setQPainterPen(col, ls, lw);
- bool const text_is_antialiased = renderHints() & TextAntialiasing;
- setRenderHint(Antialiasing, antialias && text_is_antialiased);
- drawPolyline(points.data(), np);
- setRenderHint(Antialiasing, false);
-}
-
-
-void QLPainter::rectangle(int x, int y, int w, int h,
- Color_color col,
- line_style ls,
- line_width lw)
-{
- if (!isDrawingEnabled())
- return;
-
- setQPainterPen(col, ls, lw);
- drawRect(x, y, w, h);
-}
-
-
-void QLPainter::fillRectangle(int x, int y, int w, int h, Color_color col)
-{
- fillRect(x, y, w, h, guiApp->colorCache().get(col));
-}
-
-
-void QLPainter::arc(int x, int y, unsigned int w, unsigned int h,
- int a1, int a2, Color_color col)
-{
- if (!isDrawingEnabled())
- return;
-
- // LyX usings 1/64ths degree, Qt usings 1/16th
- setQPainterPen(col);
- bool const do_antialiasing = renderHints() & TextAntialiasing;
- setRenderHint(Antialiasing, do_antialiasing);
- drawArc(x, y, w, h, a1 / 4, a2 / 4);
- setRenderHint(Antialiasing, false);
-}
-
-
-void QLPainter::image(int x, int y, int w, int h, graphics::Image const & i)
-{
- graphics::QLImage const & qlimage =
- static_cast<graphics::QLImage const &>(i);
-
- fillRectangle(x, y, w, h, Color::graphicsbg);
-
- if (!isDrawingEnabled())
- return;
-
- drawImage(x, y, qlimage.qimage(), 0, 0, w, h);
-}
-
-
-int QLPainter::text(int x, int y, char_type c, Font const & f)
-{
- docstring s(1, c);
- return text(x, y, s, f);
-}
-
-
-int QLPainter::smallCapsText(int x, int y,
- QString const & s, Font const & f)
-{
- Font smallfont(f);
- smallfont.decSize().decSize().setShape(Font::UP_SHAPE);
-
- QFont const & qfont = guiApp->guiFontLoader().get(f);
- QFont const & qsmallfont = guiApp->guiFontLoader().get(smallfont);
-
- setQPainterPen(f.realColor());
- int textwidth = 0;
- size_t const ls = s.length();
- for (unsigned int i = 0; i < ls; ++i) {
- QChar const c = s[i].toUpper();
- if (c != s.at(i)) {
- setFont(qsmallfont);
- } else {
- setFont(qfont);
- }
- if (isDrawingEnabled())
- drawText(x + textwidth, y, c);
- textwidth += fontMetrics().width(c);
- }
- return textwidth;
-}
-
-
-int QLPainter::text(int x, int y, docstring const & s,
- Font const & f)
-{
- /* Caution: The following ucs4 to QString conversions work for symbol fonts
- only because they are no real conversions but simple casts in reality.
- When we want to draw a symbol or calculate the metrics we pass the position
- of the symbol in the font (as given in lib/symbols) as a char_type to the
- frontend. This is just wrong, because the symbol is no UCS4 character at
- all. You can think of this number as the code point of the symbol in a
- custom symbol encoding. It works because this char_type is lateron again
- interpreted as a position in the font again.
- The correct solution would be to have extra functions for symbols, but that
- would require to duplicate a lot of frontend and mathed support code.
- */
- QString str = toqstr(s);
-
-#if 0
- // HACK: QT3 refuses to show single compose characters
- // Still needed with Qt4?
- if (ls == 1 && str[0].unicode() >= 0x05b0 && str[0].unicode() <= 0x05c2)
- str = ' ' + str;
-#endif
-
- QLFontInfo & fi = guiApp->guiFontLoader().fontinfo(f);
-
- int textwidth;
-
- if (f.realShape() == Font::SMALLCAPS_SHAPE) {
- textwidth = smallCapsText(x, y, str, f);
- if (f.underbar() == Font::ON)
- underline(f, x, y, textwidth);
- return textwidth;
- }
-
- // Here we use the font width cache instead of
- // textwidth = fontMetrics().width(str);
- // because the above is awfully expensive on MacOSX
- textwidth = fi.metrics->width(s);
- if (f.underbar() == Font::ON)
- underline(f, x, y, textwidth);
-
- if (!isDrawingEnabled())
- return textwidth;
-
- // Qt4 does not display a glyph whose codepoint is the
- // same as that of a soft-hyphen (0x00ad), unless it
- // occurs at a line-break. As a kludge, we force Qt to
- // render this glyph using a one-column line.
- if (s.size() == 1 && str[0].unicode() == 0x00ad) {
- setQPainterPen(f.realColor());
- QTextLayout adsymbol(str);
- adsymbol.setFont(fi.font);
- adsymbol.beginLayout();
- QTextLine line = adsymbol.createLine();
- line.setNumColumns(1);
- line.setPosition(QPointF(0, -line.ascent()));
- adsymbol.endLayout();
- line.draw(this, QPointF(x, y));
- return textwidth;
- }
-
- if (!usePixmapCache) {
- // don't use the pixmap cache,
- // draw directly onto the painting device
- setQPainterPen(f.realColor());
- if (font() != fi.font)
- setFont(fi.font);
- // We need to draw the text as LTR as we use our own bidi code.
- setLayoutDirection(Qt::LeftToRight);
- // We need to draw the text as LTR as we use our own bidi code.
- setLayoutDirection(Qt::LeftToRight);
- drawText(x, y, str);
- LYXERR(Debug::PAINTING) << "draw " << std::string(str.toUtf8())
- << " at " << x << "," << y << std::endl;
- return textwidth;
- }
-
- QPixmap pm;
- QString key = generateStringSignature(str, f);
- // Warning: Left bearing is in general negative! Only the case
- // where left bearing is negative is of interest WRT the the
- // pixmap width and the text x-position.
- // Only the left bearing of the first character is important
- // as we always write from left to right, even for
- // right-to-left languages.
- int const lb = std::min(fi.metrics->lbearing(s[0]), 0);
- int const mA = fi.metrics->maxAscent();
- if (!QPixmapCache::find(key, pm)) {
- // Only the right bearing of the last character is
- // important as we always write from left to right,
- // even for right-to-left languages.
- int const rb = fi.metrics->rbearing(s[s.size()-1]);
- int const w = textwidth + rb - lb;
- int const mD = fi.metrics->maxDescent();
- int const h = mA + mD;
- pm = QPixmap(w, h);
- pm.fill(Qt::transparent);
- QLPainter p(&pm);
- p.setQPainterPen(f.realColor());
- if (p.font() != fi.font)
- p.setFont(fi.font);
- // We need to draw the text as LTR as we use our own bidi code.
- p.setLayoutDirection(Qt::LeftToRight);
- p.drawText(-lb, mA, str);
- QPixmapCache::insert(key, pm);
- LYXERR(Debug::PAINTING) << "h=" << h << " mA=" << mA << " mD=" << mD
- << " w=" << w << " lb=" << lb << " tw=" << textwidth
- << " rb=" << rb << endl;
- }
- // Draw the cached pixmap.
- drawPixmap(x + lb, y - mA, pm);
-
- return textwidth;
-}
-
-
-} // namespace frontend
-} // namespace lyx
+++ /dev/null
-// -*- C++ -*-
-/**
- * \file QLPainter.h
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author John Levon
- * \author Abdelrazak Younes
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#ifndef QLPAINTER_H
-#define QLPAINTER_H
-
-#include "frontends/Painter.h"
-
-#include "Color.h"
-
-#include <QPainter>
-
-class QString;
-
-namespace lyx {
-
-class Font;
-
-namespace frontend {
-
-/**
- * QLPainter - a painter implementation for Qt4
- */
-class QLPainter : public QPainter, public Painter {
-public:
- QLPainter(QPaintDevice *);
- virtual ~QLPainter();
-
- /// draw a line from point to point
- virtual void line(
- int x1, int y1,
- int x2, int y2,
- Color_color,
- line_style = line_solid,
- line_width = line_thin);
-
- /**
- * lines - draw a set of lines
- * @param xp array of points' x co-ords
- * @param yp array of points' y co-ords
- * @param np size of the points array
- */
- virtual void lines(
- int const * xp,
- int const * yp,
- int np,
- Color_color,
- line_style = line_solid,
- line_width = line_thin);
-
- /// draw a rectangle
- virtual void rectangle(
- int x, int y,
- int w, int h,
- Color_color,
- line_style = line_solid,
- line_width = line_thin);
-
- /// draw a filled rectangle
- virtual void fillRectangle(
- int x, int y,
- int w, int h,
- Color_color);
-
- /// draw an arc
- virtual void arc(
- int x, int y,
- unsigned int w, unsigned int h,
- int a1, int a2,
- Color_color);
-
- /// draw a pixel
- virtual void point(
- int x, int y,
- Color_color);
-
- /// draw an image from the image cache
- virtual void image(int x, int y,
- int w, int h,
- lyx::graphics::Image const & image);
-
- /// draw a string at position x, y (y is the baseline)
- virtual int text(int x, int y,
- docstring const & str, Font const & f);
-
- /// draw a char at position x, y (y is the baseline)
- virtual int text(int x, int y, char_type c, Font const & f);
-
-private:
- /// draw small caps text
- /**
- \return width of the drawn text.
- */
- int smallCapsText(int x, int y,
- QString const & str, Font const & f);
-
- /// set pen parameters
- void setQPainterPen(Color_color col,
- line_style ls = line_solid,
- line_width lw = line_thin);
-
- Color::color current_color_;
- Painter::line_style current_ls_;
- Painter::line_width current_lw_;
-};
-
-} // namespace frontend
-} // namespace lyx
-
-#endif // QLPAINTER_H
+++ /dev/null
-/**
- * \file QLPopupMenu.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author John Levon
- * \author Abdelrazak Younes
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include <boost/current_function.hpp>
-
-// Qt defines a macro 'signals' that clashes with a boost namespace.
-// All is well if the namespace is visible first.
-#include "GuiView.h"
-
-#include "Action.h"
-#include "QLPopupMenu.h"
-#include "QLMenubar.h"
-#include "qt_helpers.h"
-#include "MenuBackend.h"
-
-#include "support/lstrings.h"
-#include "debug.h"
-
-
-using std::make_pair;
-using std::string;
-using std::pair;
-using std::endl;
-
-
-namespace lyx {
-namespace frontend {
-
-QLPopupMenu::QLPopupMenu(QLMenubar * owner,
- MenuItem const & mi, bool topLevelMenu)
- : owner_(owner)
-{
- name_ = mi.submenuname();
-
- setTitle(toqstr(getLabel(mi)));
-
- if (topLevelMenu)
- connect(this, SIGNAL(aboutToShow()), this, SLOT(update()));
-}
-
-
-void QLPopupMenu::update()
-{
- LYXERR(Debug::GUI) << BOOST_CURRENT_FUNCTION << endl;
- LYXERR(Debug::GUI) << "\tTriggered menu: " << to_utf8(name_) << endl;
-
- clear();
-
- if (name_.empty())
- return;
-
- // Here, We make sure that theLyXFunc points to the correct LyXView.
- theLyXFunc().setLyXView(owner_->view());
-
- Menu const & fromLyxMenu = owner_->backend().getMenu(name_);
- owner_->backend().expand(fromLyxMenu, topLevelMenu_, owner_->view()->buffer());
-
- if (!owner_->backend().hasMenu(topLevelMenu_.name())) {
- LYXERR(Debug::GUI) << "\tWARNING: menu seems empty"
- << to_utf8(topLevelMenu_.name()) << endl;
- }
- populate(this, &topLevelMenu_);
-}
-
-void QLPopupMenu::populate(QMenu* qMenu, Menu * menu)
-{
- LYXERR(Debug::GUI) << "populating menu " << to_utf8(menu->name()) ;
- if (menu->size() == 0) {
- LYXERR(Debug::GUI) << "\tERROR: empty menu "
- << to_utf8(menu->name()) << endl;
- return;
- }
- else {
- LYXERR(Debug::GUI) << " ***** menu entries " << menu->size() << endl;
- }
-
- Menu::const_iterator m = menu->begin();
- Menu::const_iterator end = menu->end();
-
- for (; m != end; ++m) {
-
- if (m->kind() == MenuItem::Separator) {
-
- qMenu->addSeparator();
- LYXERR(Debug::GUI) << "adding Menubar Separator" << endl;
-
- } else if (m->kind() == MenuItem::Submenu) {
-
- LYXERR(Debug::GUI) << "** creating New Sub-Menu "
- << to_utf8(getLabel(*m)) << endl;
- QMenu * subMenu = qMenu->addMenu(toqstr(getLabel(*m)));
- populate(subMenu, m->submenu());
-
- } else { // we have a MenuItem::Command
-
- LYXERR(Debug::GUI) << "creating Menu Item "
- << to_utf8(m->label()) << endl;
-
- docstring label = getLabel(*m);
- addBinding(label, *m);
-
- Action * action = new Action(*(owner_->view()),
- label, m->func());
- qMenu->addAction(action);
- }
- }
-}
-
-
-docstring const QLPopupMenu::getLabel(MenuItem const & mi)
-{
- docstring const shortcut = mi.shortcut();
- docstring label = support::subst(mi.label(),
- from_ascii("&"), from_ascii("&&"));
-
- if (!shortcut.empty()) {
- docstring::size_type pos = label.find(shortcut);
- if (pos != docstring::npos)
- label.insert(pos, 1, char_type('&'));
- }
-
- return label;
-}
-
-void QLPopupMenu::addBinding(docstring & label, MenuItem const & mi)
-{
-#ifdef Q_WS_MACX
- docstring const binding(mi.binding(false));
-#else
- docstring const binding(mi.binding(true));
-#endif
- if (!binding.empty()) {
- label += '\t' + binding;
- }
-}
-
-} // namespace frontend
-} // namespace lyx
-
-#include "QLPopupMenu_moc.cpp"
+++ /dev/null
-// -*- C++ -*-
-/**
- * \file QLPopupMenu.h
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author John Levon
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#ifndef QLPOPUPMENU_H
-#define QLPOPUPMENU_H
-
-#include <QMenu>
-
-#include "FuncRequest.h"
-#include "MenuBackend.h"
-
-namespace lyx {
-namespace frontend {
-
-class QLMenubar;
-
-/// a submenu
-class QLPopupMenu : public QMenu {
- Q_OBJECT
-public:
-
- QLPopupMenu(QLMenubar * owner, MenuItem const & mi, bool topLevelMenu=false);
-
- /// populates the menu or one of its submenu
- /// This is used as a recursive function
- void populate(QMenu* qMenu, Menu * menu);
-
-public Q_SLOTS:
- /// populate the toplevel menu and all children
- void update();
-
-private:
-
- /// our owning menubar
- QLMenubar * owner_;
-
- /// the name of this menu
- docstring name_;
-
-private:
- /// Get a Menu item label from the menu backend
- docstring const getLabel(MenuItem const & mi);
-
- /// add binding keys a the menu item label.
- void addBinding(docstring & label, MenuItem const & mi);
-
- /// Top Level Menu
- Menu topLevelMenu_;
-};
-
-} // namespace frontend
-} // namespace lyx
-
-#endif // QLPOPUPMENU_H
+++ /dev/null
-/**
- * \file QLPrintDialog.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author John Levon
- * \author Edwin Leuven
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "controllers/ControlPrint.h"
-#include "QLPrintDialog.h"
-#include "QPrint.h"
-#include "qt_helpers.h"
-
-#include <qcheckbox.h>
-#include <qlineedit.h>
-#include <qpushbutton.h>
-#include <qradiobutton.h>
-
-namespace lyx {
-namespace frontend {
-
-QLPrintDialog::QLPrintDialog(QPrint * f)
- : form_(f)
-{
- setupUi(this);
-
- connect(printPB, SIGNAL(clicked()), form_, SLOT(slotOK()));
- connect(closePB, SIGNAL(clicked()), form_, SLOT(slotClose()));
-
- connect(copiesSB, SIGNAL(valueChanged(int)), this, SLOT(copiesChanged(int)));
- connect(printerED, SIGNAL(textChanged(const QString&)),
- this, SLOT(printerChanged()));
- connect(fileED, SIGNAL(textChanged(const QString&)),
- this, SLOT(fileChanged() ));
- connect(browsePB, SIGNAL(clicked()), this, SLOT(browseClicked()));
- connect(allRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
- connect(reverseCB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
- connect(collateCB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
- connect(fromED, SIGNAL(textChanged(const QString&)),
- this, SLOT(pagerangeChanged()));
- connect(fromED, SIGNAL(textChanged(const QString&)),
- this, SLOT(change_adaptor()));
- connect(toED, SIGNAL(textChanged(const QString&)),
- this, SLOT(pagerangeChanged()));
- connect(toED, SIGNAL(textChanged(const QString&)),
- this, SLOT(change_adaptor()));
- connect(fileRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
- connect(printerRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
- connect(rangeRB, SIGNAL(toggled(bool)), fromED, SLOT(setEnabled(bool)));
- connect(rangeRB, SIGNAL(toggled(bool)), toED, SLOT(setEnabled(bool)));
-}
-
-
-void QLPrintDialog::change_adaptor()
-{
- form_->changed();
-}
-
-
-void QLPrintDialog::browseClicked()
-{
- QString file = toqstr(form_->controller().browse(docstring()));
- if (!file.isNull()) {
- fileED->setText(file);
- form_->changed();
- }
-}
-
-
-void QLPrintDialog::fileChanged()
-{
- if (!fileED->text().isEmpty())
- fileRB->setChecked(true);
- form_->changed();
-}
-
-
-void QLPrintDialog::copiesChanged(int i)
-{
- collateCB->setEnabled(i != 1);
- form_->changed();
-}
-
-
-void QLPrintDialog::printerChanged()
-{
- printerRB->setChecked(true);
- form_->changed();
-}
-
-
-void QLPrintDialog::pagerangeChanged()
-{
- form_->changed();
-}
-
-} // namespace frontend
-} // namespace lyx
-
-#include "QLPrintDialog_moc.cpp"
+++ /dev/null
-// -*- C++ -*-
-/**
- * \file QLPrintDialog.h
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author John Levon
- * \author Edwin Leuven
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#ifndef QLPRINTDIALOG_H
-#define QLPRINTDIALOG_H
-
-#include "ui_PrintUi.h"
-
-#include <QDialog>
-
-namespace lyx {
-namespace frontend {
-
-class QPrint;
-
-class QLPrintDialog : public QDialog, public Ui::QPrintUi {
- Q_OBJECT
-public:
- QLPrintDialog(QPrint * f);
-protected Q_SLOTS:
- virtual void change_adaptor();
- virtual void browseClicked();
- virtual void fileChanged();
- virtual void copiesChanged(int);
- virtual void printerChanged();
- virtual void pagerangeChanged();
-private:
- QPrint * form_;
-};
-
-} // namespace frontend
-} // namespace lyx
-
-#endif // QLPRINTDIALOG_H
+++ /dev/null
-/**
- * \file qt4/QLToolbar.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Lars Gullik Bjønnes
- * \author John Levon
- * \author Jean-Marc Lasgouttes
- * \author Angus Leeming
- * \author Abdelrazak Younes
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "Buffer.h"
-#include "BufferParams.h"
-#include "debug.h"
-#include "FuncRequest.h"
-#include "FuncStatus.h"
-#include "gettext.h"
-#include "LyXFunc.h"
-#include "IconPalette.h"
-
-#include "GuiView.h"
-#include "QCommandBuffer.h"
-#include "QLToolbar.h"
-#include "LyXAction.h"
-#include "Action.h"
-#include "qt_helpers.h"
-#include "InsertTableWidget.h"
-#include "support/filetools.h"
-#include "support/lstrings.h"
-#include "controllers/ControlMath.h"
-#include "ToolbarBackend.h"
-
-#include <QComboBox>
-#include <QToolBar>
-#include <QToolButton>
-#include <QAction>
-#include <QPixmap>
-
-namespace lyx {
-
-using std::string;
-using std::endl;
-using support::FileName;
-using support::libFileSearch;
-using support::subst;
-
-namespace frontend {
-
-static TextClass const & textClass(LyXView const & lv)
-{
- return lv.buffer()->params().getTextClass();
-}
-
-
-QLayoutBox::QLayoutBox(QToolBar * toolbar, GuiView & owner)
- : owner_(owner)
-{
- combo_ = new QComboBox;
- combo_->setSizeAdjustPolicy(QComboBox::AdjustToContents);
- combo_->setFocusPolicy(Qt::ClickFocus);
- combo_->setMinimumWidth(combo_->sizeHint().width());
- combo_->setMaxVisibleItems(100);
-
- QObject::connect(combo_, SIGNAL(activated(const QString &)),
- this, SLOT(selected(const QString &)));
-
- toolbar->addWidget(combo_);
-}
-
-
-void QLayoutBox::set(docstring const & layout)
-{
- TextClass const & tc = textClass(owner_);
-
- QString const & name = toqstr(translateIfPossible(tc[layout]->name()));
-
- int i = 0;
- for (; i < combo_->count(); ++i) {
- if (name == combo_->itemText(i))
- break;
- }
-
- if (i == combo_->count()) {
- lyxerr << "Trying to select non existent layout type "
- << fromqstr(name) << endl;
- return;
- }
-
- combo_->setCurrentIndex(i);
-}
-
-
-void QLayoutBox::update()
-{
- TextClass const & tc = textClass(owner_);
-
- combo_->setUpdatesEnabled(false);
-
- combo_->clear();
-
- TextClass::const_iterator it = tc.begin();
- TextClass::const_iterator const end = tc.end();
- for (; it != end; ++it) {
- // ignore obsolete entries
- if ((*it)->obsoleted_by().empty())
- combo_->addItem(toqstr(translateIfPossible((*it)->name())));
- }
-
- // needed to recalculate size hint
- combo_->hide();
- combo_->setMinimumWidth(combo_->sizeHint().width());
- combo_->show();
-
- combo_->setUpdatesEnabled(true);
- combo_->update();
-}
-
-
-void QLayoutBox::clear()
-{
- combo_->clear();
-}
-
-
-void QLayoutBox::open()
-{
- combo_->showPopup();
-}
-
-
-void QLayoutBox::setEnabled(bool enable)
-{
- // Workaround for Qt bug where setEnabled(true) closes
- // the popup
- if (enable != combo_->isEnabled())
- combo_->setEnabled(enable);
-}
-
-
-void QLayoutBox::selected(const QString & str)
-{
- owner_.setFocus();
-
- layoutSelected(owner_, qstring_to_ucs4(str));
-}
-
-
-QLToolbar::QLToolbar(ToolbarInfo const & tbinfo, GuiView & owner)
- : QToolBar(qt_(tbinfo.gui_name), &owner), command_buffer_(0), owner_(owner)
-{
- // give visual separation between adjacent toolbars
- addSeparator();
-
- // TODO: save toolbar position
- setMovable(true);
-
- ToolbarInfo::item_iterator it = tbinfo.items.begin();
- ToolbarInfo::item_iterator end = tbinfo.items.end();
- for (; it != end; ++it)
- add(*it);
-}
-
-
-void QLToolbar::focusCommandBuffer()
-{
- if (command_buffer_)
- command_buffer_->setFocus();
-}
-
-
-void QLToolbar::add(ToolbarItem const & item)
-{
- switch (item.type_) {
- case ToolbarItem::SEPARATOR:
- addSeparator();
- break;
- case ToolbarItem::LAYOUTS:
- layout_.reset(new QLayoutBox(this, owner_));
- break;
- case ToolbarItem::MINIBUFFER:
- command_buffer_ = new QCommandBuffer(&owner_);
- addWidget(command_buffer_);
- /// \todo find a Qt4 equivalent to setHorizontalStretchable(true);
- //setHorizontalStretchable(true);
- break;
- case ToolbarItem::TABLEINSERT: {
- QToolButton * tb = new QToolButton;
- tb->setCheckable(true);
- tb->setIcon(QPixmap(toqstr(getIcon(FuncRequest(LFUN_TABULAR_INSERT)))));
- tb->setToolTip(qt_(to_ascii(item.label_)));
- tb->setStatusTip(qt_(to_ascii(item.label_)));
- tb->setText(qt_(to_ascii(item.label_)));
- InsertTableWidget * iv = new InsertTableWidget(owner_, tb);
- connect(tb, SIGNAL(clicked(bool)), iv, SLOT(show(bool)));
- connect(iv, SIGNAL(visible(bool)), tb, SLOT(setChecked(bool)));
- connect(this, SIGNAL(updated()), iv, SLOT(updateParent()));
- addWidget(tb);
- break;
- }
- case ToolbarItem::ICONPALETTE: {
- QToolButton * tb = new QToolButton(this);
- tb->setToolTip(qt_(to_ascii(item.label_)));
- tb->setStatusTip(qt_(to_ascii(item.label_)));
- tb->setText(qt_(to_ascii(item.label_)));
- connect(this, SIGNAL(iconSizeChanged(const QSize &)),
- tb, SLOT(setIconSize(const QSize &)));
- IconPalette * panel = new IconPalette(tb);
- panel->setWindowTitle(qt_(to_ascii(item.label_)));
- connect(this, SIGNAL(updated()), panel, SLOT(updateParent()));
- ToolbarInfo const * tbinfo = toolbarbackend.getDefinedToolbarInfo(item.name_);
- if (!tbinfo) {
- lyxerr << "Unknown toolbar " << item.name_ << endl;
- break;
- }
- ToolbarInfo::item_iterator it = tbinfo->items.begin();
- ToolbarInfo::item_iterator const end = tbinfo->items.end();
- for (; it != end; ++it)
- if (!getStatus(it->func_).unknown()) {
- Action * action = new Action(owner_,
- getIcon(it->func_),
- it->label_,
- it->func_,
- it->label_);
- panel->addButton(action);
- ActionVector.push_back(action);
- // use the icon of first action for the toolbar button
- if (it == tbinfo->items.begin())
- tb->setIcon(QPixmap(getIcon(it->func_).c_str()));
- }
- tb->setCheckable(true);
- connect(tb, SIGNAL(clicked(bool)), panel, SLOT(setVisible(bool)));
- connect(panel, SIGNAL(visible(bool)), tb, SLOT(setChecked(bool)));
- addWidget(tb);
- break;
- }
- case ToolbarItem::POPUPMENU: {
- QToolButton * tb = new QToolButton;
- tb->setPopupMode(QToolButton::InstantPopup);
- tb->setToolTip(qt_(to_ascii(item.label_)));
- tb->setStatusTip(qt_(to_ascii(item.label_)));
- tb->setText(qt_(to_ascii(item.label_)));
- FileName icon_path = libFileSearch("images/math", item.name_, "png");
- tb->setIcon(QIcon(toqstr(icon_path.absFilename())));
- connect(this, SIGNAL(iconSizeChanged(const QSize &)),
- tb, SLOT(setIconSize(const QSize &)));
-
- ButtonMenu * m = new ButtonMenu(qt_(to_ascii(item.label_)), tb);
- m->setWindowTitle(qt_(to_ascii(item.label_)));
- m->setTearOffEnabled(true);
- connect(this, SIGNAL(updated()), m, SLOT(updateParent()));
- ToolbarInfo const * tbinfo = toolbarbackend.getDefinedToolbarInfo(item.name_);
- if (!tbinfo) {
- lyxerr << "Unknown toolbar " << item.name_ << endl;
- break;
- }
- ToolbarInfo::item_iterator it = tbinfo->items.begin();
- ToolbarInfo::item_iterator const end = tbinfo->items.end();
- for (; it != end; ++it)
- if (!getStatus(it->func_).unknown()) {
- Action * action = new Action(owner_,
- getIcon(it->func_, false),
- it->label_,
- it->func_,
- it->label_);
- m->add(action);
- ActionVector.push_back(action);
- }
- tb->setMenu(m);
- addWidget(tb);
- break;
- }
- case ToolbarItem::COMMAND: {
- if (getStatus(item.func_).unknown())
- break;
-
- Action * action = new Action(owner_,
- getIcon(item.func_),
- item.label_,
- item.func_,
- item.label_);
- addAction(action);
- ActionVector.push_back(action);
- break;
- }
- default:
- break;
- }
-}
-
-
-void QLToolbar::hide(bool)
-{
- QToolBar::hide();
-}
-
-
-void QLToolbar::show(bool)
-{
- QToolBar::show();
-}
-
-
-bool QLToolbar::isVisible() const
-{
- return QToolBar::isVisible();
-}
-
-
-void QLToolbar::saveInfo(ToolbarSection::ToolbarInfo & tbinfo)
-{
- // if tbinfo.state == auto *do not* set on/off
- if (tbinfo.state != ToolbarSection::ToolbarInfo::AUTO) {
- if (QLToolbar::isVisible())
- tbinfo.state = ToolbarSection::ToolbarInfo::ON;
- else
- tbinfo.state = ToolbarSection::ToolbarInfo::OFF;
- }
- //
- // no need to save it here.
- Qt::ToolBarArea loc = owner_.toolBarArea(this);
-
- if (loc == Qt::TopToolBarArea)
- tbinfo.location = ToolbarSection::ToolbarInfo::TOP;
- else if (loc == Qt::BottomToolBarArea)
- tbinfo.location = ToolbarSection::ToolbarInfo::BOTTOM;
- else if (loc == Qt::RightToolBarArea)
- tbinfo.location = ToolbarSection::ToolbarInfo::RIGHT;
- else if (loc == Qt::LeftToolBarArea)
- tbinfo.location = ToolbarSection::ToolbarInfo::LEFT;
- else
- tbinfo.location = ToolbarSection::ToolbarInfo::NOTSET;
-
- // save toolbar position. They are not used to restore toolbar position
- // now because move(x,y) does not work for toolbar.
- tbinfo.posx = pos().x();
- tbinfo.posy = pos().y();
-}
-
-
-void QLToolbar::update()
-{
- // This is a speed bottleneck because this is called on every keypress
- // and update calls getStatus, which copies the cursor at least two times
- for (size_t i = 0; i < ActionVector.size(); ++i)
- ActionVector[i]->update();
-
- // emit signal
- updated();
-}
-
-
-string const getIcon(FuncRequest const & f, bool unknown)
-{
- using frontend::find_png;
-
- string fullname;
-
- switch (f.action) {
- case LFUN_MATH_INSERT:
- if (!f.argument().empty())
- fullname = find_png(to_utf8(f.argument()).substr(1));
- break;
- case LFUN_MATH_DELIM:
- case LFUN_MATH_BIGDELIM:
- fullname = find_png(to_utf8(f.argument()));
- break;
- default:
- string const name = lyxaction.getActionName(f.action);
- string png_name = name;
-
- if (!f.argument().empty())
- png_name = subst(name + ' ' + to_utf8(f.argument()), ' ', '_');
-
- fullname = libFileSearch("images", png_name, "png").absFilename();
-
- if (fullname.empty()) {
- // try without the argument
- fullname = libFileSearch("images", name, "png").absFilename();
- }
- }
-
- if (!fullname.empty()) {
- LYXERR(Debug::GUI) << "Full icon name is `"
- << fullname << '\'' << endl;
- return fullname;
- }
-
- LYXERR(Debug::GUI) << "Cannot find icon for command \""
- << lyxaction.getActionName(f.action)
- << '(' << to_utf8(f.argument()) << ")\"" << endl;
- if (unknown)
- return libFileSearch("images", "unknown", "png").absFilename();
- else
- return string();
-}
-
-
-} // namespace frontend
-} // namespace lyx
-
-#include "QLToolbar_moc.cpp"
+++ /dev/null
-// -*- C++ -*-
-/**
- * \file QLToolbar.h
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Lars Gullik Bjønnes
- * \author John Levon
- * \author Jean-Marc Lasgouttes
- * \author Angus Leeming
- * \author Abdelrazak Younes
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#ifndef QLTOOLBAR_H
-#define QLTOOLBAR_H
-
-#include "frontends/Toolbars.h"
-#include "Session.h"
-
-#include <QToolBar>
-
-#include <boost/scoped_ptr.hpp>
-
-#include <vector>
-
-class QComboBox;
-
-namespace lyx {
-class FuncRequest;
-namespace frontend {
-
-class QCommandBuffer;
-class QLayoutBox;
-class GuiView;
-class Action;
-
-
-class QLayoutBox : public QObject, public LayoutBox {
- Q_OBJECT
-public:
- QLayoutBox(QToolBar *, GuiView &);
-
- /// select the right layout in the combox.
- void set(docstring const & layout);
- /// Populate the layout combox.
- void update();
- /// Erase the layout list.
- void clear();
- /// Display the layout list.
- void open();
- ///
- void setEnabled(bool);
-
-private Q_SLOTS:
- void selected(const QString & str);
-
-private:
- QComboBox * combo_;
- GuiView & owner_;
-};
-
-
-class QLToolbar : public QToolBar, public Toolbar {
- Q_OBJECT
-public:
- QLToolbar(ToolbarInfo const &, GuiView &);
-
- //~QLToolbar();
-
- void add(ToolbarItem const & item);
- void hide(bool);
- void show(bool);
- bool isVisible() const;
- void saveInfo(ToolbarSection::ToolbarInfo & info);
- void update();
- LayoutBox * layout() const { return layout_.get(); }
- ///
- void focusCommandBuffer();
-
-Q_SIGNALS:
- void updated();
-
-private:
- QCommandBuffer * command_buffer_;
-
- std::vector<Action *> ActionVector;
- GuiView & owner_;
-
- boost::scoped_ptr<QLayoutBox> layout_;
-};
-
-/// return a full path of an XPM for the given action
-std::string const getIcon(FuncRequest const & f, bool unknown = true);
-
-} // namespace frontend
-} // namespace lyx
-
-#endif // NOT QLTOOLBAR_H
+++ /dev/null
-/**
- * \file QListings.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Bo Peng
- * \author Jürgen Spitzmüller
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "QListings.h"
-#include "Qt2BC.h"
-#include "qt_helpers.h"
-#include "controllers/ControlListings.h"
-#include "insets/InsetListingsParams.h"
-#include "debug.h"
-
-#include "support/convert.h"
-#include "support/lstrings.h"
-
-#include <QLineEdit>
-#include <QCloseEvent>
-#include <QPushButton>
-#include <QValidator>
-#include <QRegExpValidator>
-
-
-using std::string;
-using std::vector;
-using lyx::support::findToken;
-using lyx::support::getVectorFromString;
-using lyx::support::getStringFromVector;
-using lyx::support::prefixIs;
-using lyx::support::suffixIs;
-using lyx::support::contains;
-
-namespace lyx {
-namespace frontend {
-
-/////////////////////////////////////////////////////////////////////
-//
-// QListingsDialog
-//
-/////////////////////////////////////////////////////////////////////
-
-
-char const * languages[] =
-{ "no language", "ABAP", "ACSL", "Ada", "ALGOL", "Assembler", "Awk", "bash", "Basic", "C",
- "C++", "Caml", "Clean", "Cobol", "Comal 80", "command.com", "Comsol", "csh", "Delphi",
- "Eiffel", "Elan", "Euphoria", "Fortran", "Gnuplot", "Haskell", "HTML", "IDL", "inform",
- "Java", "JVMIS", "ksh", "Lingo", "Lisp", "Logo", "make", "Mathematica", "Matlab", "Mercury",
- "MetaPost", "Miranda", "ML", "Modula-2", "MuPAD", "NASTRAN", "Oberon-2", "OCL", "Octave",
- "Oz", "Pascal", "Perl", "PHP", "PL/I", "Plasm", "PostScript", "POV", "Prolog", "Promela",
- "PSTricks", "Python", "R", "Reduce", "Rexx", "RSL", "Ruby", "S", "SAS", "Scilab", "sh",
- "SHELXL", "Simula", "tcl", "SPARQL", "SQL", "tcl", "TeX", "VBScript", "Verilog", "VHDL",
- "VRML", "XML", "XSLT", "" };
-
-
-char const * languages_gui[] =
-{ N_("No language"), "ABAP", "ACSL", "Ada", "ALGOL", "Assembler", "Awk", "bash", "Basic",
- "C", "C++", "Caml", "Clean", "Cobol", "Comal 80", "command.com", "Comsol", "csh", "Delphi",
- "Eiffel", "Elan", "Euphoria", "Fortran", "Gnuplot", "Haskell", "HTML", "IDL", "inform",
- "Java", "JVMIS", "ksh", "Lingo", "Lisp", "Logo", "make", "Mathematica", "Matlab", "Mercury",
- "MetaPost", "Miranda", "ML", "Modula-2", "MuPAD", "NASTRAN", "Oberon-2", "OCL", "Octave",
- "Oz", "Pascal", "Perl", "PHP", "PL/I", "Plasm", "PostScript", "POV", "Prolog", "Promela",
- "PSTricks", "Python", "R", "Reduce", "Rexx", "RSL", "Ruby", "S", "SAS", "Scilab", "sh",
- "SHELXL", "Simula", "tcl", "SPARQL", "SQL", "tcl", "TeX", "VBScript", "Verilog", "VHDL",
- "VRML", "XML", "XSLT", "" };
-
-
-struct dialect_info {
- /// the dialect
- char const * dialect;
- /// the associated language
- char const * language;
- /// representation of the dialect in the gui
- char const * gui;
- /// is this the default dialect?
- bool is_default;
-};
-
-
-dialect_info const dialects[] = {
- { "R/2 4.3", "ABAP", "R/2 4.3", false },
- { "R/2 5.0", "ABAP", "R/2 5.0", false },
- { "R/3 3.1", "ABAP", "R/3 3.1", false },
- { "R/3 4.6C", "ABAP", "R/3 4.6C", false },
- { "R/3 6.10", "ABAP", "R/3 6.10", true },
- { "2005", "Ada", "2005", true },
- { "83", "Ada", "83", false },
- { "95", "Ada", "95", false },
- { "60", "Algol", "60", false },
- { "68", "Algol", "68", true },
- { "Motorola68k", "Assembler", "Motorola 68xxx", false },
- { "x86masm", "Assembler", "x86 (MASM)", false },
- { "gnu", "Awk", "gnu", true },
- { "POSIX", "Awk", "POSIX", false },
- { "Visual", "Basic", "Visual", false },
- { "ANSI", "C", "ANSI", true },
- { "Handel", "C", "Handel", false },
- { "Objective", "C", "Objective", false },
- { "Sharp", "C", "Sharp", false },
- { "ANSI", "C++", "ANSI", false },
- { "GNU", "C++", "GNU", false },
- { "ISO", "C++", "ISO", true },
- { "Visual", "C++", "Visual", false },
- { "light", "Caml", "light", true },
- { "Objective", "Caml", "Objective", false },
- { "1974", "Cobol", "1974", false },
- { "1985", "Cobol", "1985", true },
- { "ibm", "Cobol", "IBM", false },
- { "WinXP", "command.com", "Windows XP", true },
- { "77", "Fortran", "77", false },
- { "90", "Fortran", "90", false },
- { "95", "Fortran", "95", true },
- { "CORBA", "IDL", "CORBA", false },
- { "AspectJ", "Java", "Aspect J", false },
- { "Auto", "Lisp", "Auto", false },
- { "gnu", "make", "gnu", false },
- { "1.0", "Mathematica", "1.0", false },
- { "3.0", "Mathematica", "3.0", false },
- { "5.2", "Mathematica", "5.2", true },
- { "decorative", "OCL", "decorative", false },
- { "OMG", "OCL", "OMG", true },
- { "Borland6", "Pascal", "Borland 6", false },
- { "Standard", "Pascal", "Standard", true },
- { "XSC", "Pascal", "XSC", false },
- { "PLUS", "S", "PLUS", false },
- { "67", "Simula", "67", true },
- { "CII", "Simula", "CII", false },
- { "DEC", "Simula", "DEC", false },
- { "IBM", "Simula", "IBM", false },
- { "tk", "tcl", "tk", false },
- { "AlLaTeX", "TeX", "AlLaTeX", false },
- { "common", "TeX", "common", false },
- { "LaTeX", "TeX", "LaTeX", false },
- { "plain", "TeX", "plain", true },
- { "primitive", "TeX", "primitive", false },
- { "AMS", "VHDL", "AMS", false },
- { "97", "VRML", "97", true }
-};
-
-
-size_t const nr_dialects = sizeof(dialects) / sizeof(dialect_info);
-
-
-char const * font_sizes[] =
-{ "default", "tiny", "scriptsize", "footnotesize", "small", "normalsize", "large",
- "Large", "" };
-
-char const * font_sizes_gui[] =
-{ N_("Default"), N_("Tiny"), N_("Smallest"), N_("Smaller"), N_("Small"), N_("Normal"),
- N_("Large"), N_("Larger"), "" };
-
-char const * font_styles[] =
-{ "default", "rmfamily", "ttfamily", "sffamily", "" };
-
-char const * font_styles_gui[] =
-{ N_("Default"), N_("Roman"), N_("Typewriter"), N_("Sans Serif"), "" };
-
-
-
-QListingsDialog::QListingsDialog(QListings * form)
- : form_(form)
-{
- setupUi(this);
-
- connect(okPB, SIGNAL(clicked()), form, SLOT(slotOK()));
- connect(applyPB, SIGNAL(clicked()), form_, SLOT(slotApply()));
- connect(closePB, SIGNAL(clicked()), form, SLOT(slotClose()));
-
- connect(languageCO, SIGNAL(currentIndexChanged(int)), this, SLOT(change_adaptor()));
- connect(dialectCO, SIGNAL(currentIndexChanged(int)), this, SLOT(change_adaptor()));
- connect(inlineCB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
- connect(floatCB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
- connect(placementLE, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
- connect(numberSideCO, SIGNAL(currentIndexChanged(int)), this, SLOT(change_adaptor()));
- connect(numberStepLE, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
- connect(numberFontSizeCO, SIGNAL(currentIndexChanged(int)), this, SLOT(change_adaptor()));
- connect(firstlineLE, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
- connect(lastlineLE, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
- connect(fontsizeCO, SIGNAL(currentIndexChanged(int)), this, SLOT(change_adaptor()));
- connect(fontstyleCO, SIGNAL(currentIndexChanged(int)), this, SLOT(change_adaptor()));
- connect(breaklinesCB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
- connect(spaceCB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
- connect(spaceInStringCB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
- connect(extendedcharsCB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
-
- connect(listingsED, SIGNAL(textChanged()), this, SLOT(change_adaptor()));
- connect(listingsED, SIGNAL(textChanged()), this, SLOT(set_listings_msg()));
- connect(bypassCB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
- connect(bypassCB, SIGNAL(clicked()), this, SLOT(set_listings_msg()));
-
- for (int n = 0; languages[n][0]; ++n)
- languageCO->addItem(qt_(languages_gui[n]));
-
- for (int n = 0; font_styles[n][0]; ++n)
- fontstyleCO->addItem(qt_(font_styles_gui[n]));
-
- for (int n = 0; font_sizes[n][0]; ++n) {
- QString font = qt_(font_sizes_gui[n]);
- fontsizeCO->addItem(font);
- numberFontSizeCO->addItem(font);
- }
-
- // set validators
- numberStepLE->setValidator(new QIntValidator(0, 1000000, this));
- firstlineLE->setValidator(new QIntValidator(0, 1000000, this));
- lastlineLE->setValidator(new QIntValidator(0, 1000000, this));
- placementLE->setValidator(new QRegExpValidator(QRegExp("[\\*tbph]*"), this));
-}
-
-
-void QListingsDialog::closeEvent(QCloseEvent * e)
-{
- form_->slotWMHide();
- e->accept();
-}
-
-
-void QListingsDialog::change_adaptor()
-{
- form_->changed();
-}
-
-
-string QListingsDialog::construct_params()
-{
- string language = languages[languageCO->currentIndex()];
- string dialect;
- string const dialect_gui = fromqstr(dialectCO->currentText());
- if (dialectCO->currentIndex() > 0) {
- for (size_t i = 0; i < nr_dialects; ++i) {
- if (dialect_gui == dialects[i].gui
- && dialects[i].language == language
- && !dialects[i].is_default) {
- dialect = dialects[i].dialect;
- break;
- }
- }
- }
-
- bool float_ = floatCB->isChecked();
- string placement;
- if (placementLE->isEnabled())
- placement = fromqstr(placementLE->text());
-
- string numberSide;
- switch (numberSideCO->currentIndex()) {
- case 0:
- numberSide = "none";
- break;
- case 1:
- numberSide = "left";
- break;
- case 2:
- numberSide = "right";
- break;
- default:
- numberSide = "none";
- break;
- }
- string stepnumber = fromqstr(numberStepLE->text());
- string numberfontsize = font_sizes[numberFontSizeCO->currentIndex()];
- string firstline = fromqstr(firstlineLE->text());
- string lastline = fromqstr(lastlineLE->text());
-
- string fontsize = font_sizes[fontsizeCO->currentIndex()];
- string fontstyle = font_styles[fontstyleCO->currentIndex()];
- string basicstyle;
- if (fontsize != "default")
- basicstyle = "\\" + fontsize;
- if (fontstyle != "default")
- basicstyle += "\\" + fontstyle;
- bool breakline = breaklinesCB->isChecked();
- bool space = spaceCB->isChecked();
- bool spaceInString = spaceInStringCB->isChecked();
- bool extendedchars = extendedcharsCB->isChecked();
- string extra = fromqstr(listingsED->toPlainText());
-
- // compose a string
- InsetListingsParams par;
- if (language != "no language" && !contains(extra, "language=")) {
- if (dialect.empty())
- par.addParam("language", language);
- else
- par.addParam("language", "{[" + dialect + "]" + language + "}");
- }
- // this dialog uses float=placement instead of float,floatplacement=placement
- // because float accepts *tbph and floatplacement accepts bph.
- // our placement textedit is actually for the float parameter
- if (float_)
- par.addParam("float", placement);
- if (numberSide != "none")
- par.addParam("numbers", numberSide);
- if (numberfontsize != "default" && numberSide != "none")
- par.addParam("numberstyle", "\\" + numberfontsize);
- if (!stepnumber.empty() && numberSide != "none")
- par.addParam("stepnumber", stepnumber);
- if (!firstline.empty())
- par.addParam("firstline", firstline);
- if (!lastline.empty())
- par.addParam("lastline", lastline);
- if (!basicstyle.empty())
- par.addParam("basicstyle", basicstyle);
- if (breakline)
- par.addParam("breaklines", "true");
- if (space)
- par.addParam("showspaces", "true");
- if (!spaceInString)
- par.addParam("showstringspaces", "false");
- if (extendedchars)
- par.addParam("extendedchars", "true");
- par.addParams(extra);
- return par.params();
-}
-
-
-docstring QListingsDialog::validate_listings_params()
-{
- // use a cache here to avoid repeated validation
- // of the same parameters
- static string param_cache = string();
- static docstring msg_cache = docstring();
-
- if (bypassCB->isChecked())
- return docstring();
-
- string params = construct_params();
- if (params != param_cache) {
- param_cache = params;
- msg_cache = InsetListingsParams(params).validate();
- }
- return msg_cache;
-}
-
-
-void QListingsDialog::set_listings_msg()
-{
- static bool isOK = true;
- docstring msg = validate_listings_params();
- if (msg.empty()) {
- if (isOK)
- return;
- isOK = true;
- listingsTB->setPlainText(
- qt_("Input listing parameters on the right. Enter ? for a list of parameters."));
- } else {
- isOK = false;
- listingsTB->setPlainText(toqstr(msg));
- }
-}
-
-
-void QListingsDialog::on_floatCB_stateChanged(int state)
-{
- if (state == Qt::Checked) {
- inlineCB->setChecked(false);
- placementLE->setEnabled(true);
- } else
- placementLE->setEnabled(false);
-}
-
-
-void QListingsDialog::on_inlineCB_stateChanged(int state)
-{
- if (state == Qt::Checked) {
- floatCB->setChecked(false);
- placementLE->setEnabled(false);
- }
-}
-
-
-void QListingsDialog::on_numberSideCO_currentIndexChanged(int index)
-{
- numberStepLE->setEnabled(index > 0);
- numberFontSizeCO->setEnabled(index > 0);
-}
-
-
-void QListingsDialog::on_languageCO_currentIndexChanged(int index)
-{
- dialectCO->clear();
- // 0 is "no dialect"
- int default_dialect = 0;
- dialectCO->addItem(qt_("No dialect"));
- string const language = languages[index];
-
- for (size_t i = 0; i < nr_dialects; ++i) {
- if (language == dialects[i].language) {
- dialectCO->addItem(qt_(dialects[i].gui));
- if (dialects[i].is_default)
- default_dialect =
- dialectCO->findText(qt_(dialects[i].gui));
- }
- }
- dialectCO->setCurrentIndex(default_dialect);
- dialectCO->setEnabled(dialectCO->count() > 1);
-}
-
-
-/////////////////////////////////////////////////////////////////////
-//
-// QListings
-//
-/////////////////////////////////////////////////////////////////////
-
-typedef QController<ControlListings, QView<QListingsDialog> > listings_wrap_base_class;
-
-QListings::QListings(Dialog & parent)
- : listings_wrap_base_class(parent, _("Program Listing Settings"))
-{
-}
-
-
-void QListings::build_dialog()
-{
- dialog_.reset(new QListingsDialog(this));
-
- bcview().setOK(dialog_->okPB);
- bcview().setApply(dialog_->applyPB);
- bcview().setCancel(dialog_->closePB);
- dialog_->listingsTB->setPlainText(
- qt_("Input listing parameters on the right. Enter ? for a list of parameters."));
-
- update_contents();
-}
-
-
-void QListings::apply()
-{
- InsetListingsParams & params = controller().params();
- params.setInline(dialog_->inlineCB->isChecked());
- params.setParams(dialog_->construct_params());
- controller().setParams(params);
-}
-
-
-namespace {
-
-string plainParam(std::string const & par)
-{
- // remove enclosing braces
- if (prefixIs(par, "{") && suffixIs(par, "}"))
- return par.substr(1, par.size() - 2);
- return par;
-}
-
-} //namespace anon
-
-
-void QListings::update_contents()
-{
- // set default values
- dialog_->listingsTB->setPlainText(
- qt_("Input listing parameters on the right. Enter ? for a list of parameters."));
- dialog_->languageCO->setCurrentIndex(findToken(languages, "no language"));
- dialog_->dialectCO->setCurrentIndex(0);
- dialog_->floatCB->setChecked(false);
- dialog_->placementLE->clear();
- dialog_->numberSideCO->setCurrentIndex(0);
- dialog_->numberStepLE->clear();
- dialog_->numberFontSizeCO->setCurrentIndex(findToken(font_sizes, "default"));
- dialog_->firstlineLE->clear();
- dialog_->lastlineLE->clear();
- dialog_->fontstyleCO->setCurrentIndex(findToken(font_styles, "default"));
- dialog_->fontsizeCO->setCurrentIndex(findToken(font_sizes, "default"));
- dialog_->breaklinesCB->setChecked(false);
- dialog_->spaceCB->setChecked(false);
- dialog_->spaceInStringCB->setChecked(true);
- dialog_->extendedcharsCB->setChecked(false);
-
- // set values from param string
- InsetListingsParams & params = controller().params();
- dialog_->inlineCB->setChecked(params.isInline());
- if (params.isInline()) {
- dialog_->floatCB->setChecked(false);
- dialog_->placementLE->setEnabled(false);
- }
- // break other parameters and set values
- vector<string> pars = getVectorFromString(params.separatedParams(), "\n");
- // process each of them
- for (vector<string>::iterator it = pars.begin();
- it != pars.end(); ++it) {
- if (prefixIs(*it, "language=")) {
- string arg = plainParam(it->substr(9));
- // has dialect?
- string language;
- string dialect;
- bool in_gui = false;
- if (prefixIs(arg, "[") && contains(arg, "]")) {
- string::size_type end_dialect = arg.find("]");
- dialect = arg.substr(1, end_dialect - 1);
- language = arg.substr(end_dialect + 1);
- } else
- language = arg;
- int n = findToken(languages, language);
- if (n >= 0) {
- dialog_->languageCO->setCurrentIndex(n);
- in_gui = true;
- }
- // on_languageCO_currentIndexChanged should have set dialects
- if (!dialect.empty()) {
- string dialect_gui;
- for (size_t i = 0; i < nr_dialects; ++i) {
- if (dialect == dialects[i].dialect
- && dialects[i].language == language) {
- dialect_gui = dialects[i].gui;
- break;
- }
- }
- n = dialog_->dialectCO->findText(qt_(dialect_gui));
- if (n >= 0)
- dialog_->dialectCO->setCurrentIndex(n);
- else
- in_gui = false;
- }
- if (in_gui)
- *it = "";
- dialog_->languageCO->setEnabled(in_gui);
- dialog_->dialectCO->setEnabled(
- in_gui && dialog_->dialectCO->count() > 1);
- } else if (prefixIs(*it, "float")) {
- dialog_->floatCB->setChecked(true);
- dialog_->inlineCB->setChecked(false);
- dialog_->placementLE->setEnabled(true);
- if (prefixIs(*it, "float="))
- dialog_->placementLE->setText(
- toqstr(plainParam(it->substr(6))));
- *it = "";
- } else if (prefixIs(*it, "numbers=")) {
- string s = plainParam(it->substr(8));
- int n = 0;
- if (s == "left")
- n = 1;
- else if (s == "right")
- n = 2;
- dialog_->numberSideCO->setCurrentIndex(n);
- *it = "";
- } else if (prefixIs(*it, "stepnumber=")) {
- dialog_->numberStepLE->setText(
- toqstr(plainParam(it->substr(11))));
- *it = "";
- } else if (prefixIs(*it, "numberstyle=")) {
- string par = plainParam(it->substr(12));
- int n = findToken(font_sizes, par.substr(1));
- if (n >= 0)
- dialog_->numberFontSizeCO->setCurrentIndex(n);
- *it = "";
- } else if (prefixIs(*it, "firstline=")) {
- dialog_->firstlineLE->setText(
- toqstr(plainParam(it->substr(10))));
- *it = "";
- } else if (prefixIs(*it, "lastline=")) {
- dialog_->lastlineLE->setText(
- toqstr(plainParam(it->substr(9))));
- *it = "";
- } else if (prefixIs(*it, "basicstyle=")) {
- string style;
- string size;
- for (int n = 0; font_styles[n][0]; ++n) {
- string const s = font_styles[n];
- if (contains(*it, "\\" + s)) {
- style = "\\" + s;
- break;
- }
- }
- for (int n = 0; font_sizes[n][0]; ++n) {
- string const s = font_sizes[n];
- if (contains(*it, "\\" + s)) {
- size = "\\" + s;
- break;
- }
- }
- if (plainParam(it->substr(11)) == style + size
- || plainParam(it->substr(11)) == size + style) {
- if (!style.empty()) {
- int n = findToken(font_styles, style.substr(1));
- if (n >= 0)
- dialog_->fontstyleCO->setCurrentIndex(n);
- }
- if (!size.empty()) {
- int n = findToken(font_sizes, size.substr(1));
- if (n >= 0)
- dialog_->fontsizeCO->setCurrentIndex(n);
- }
- *it = "";
- }
- } else if (prefixIs(*it, "breaklines=")) {
- dialog_->breaklinesCB->setChecked(contains(*it, "true"));
- *it = "";
- } else if (prefixIs(*it, "showspaces=")) {
- dialog_->spaceCB->setChecked(contains(*it, "true"));
- *it = "";
- } else if (prefixIs(*it, "showstringspaces=")) {
- dialog_->spaceInStringCB->setChecked(contains(*it, "true"));
- *it = "";
- } else if (prefixIs(*it, "extendedchars=")) {
- dialog_->extendedcharsCB->setChecked(contains(*it, "true"));
- *it = "";
- }
- }
-
- dialog_->numberStepLE->setEnabled(dialog_->numberSideCO->currentIndex() > 0);
- dialog_->numberFontSizeCO->setEnabled(dialog_->numberSideCO->currentIndex() > 0);
- // parameters that can be handled by widgets are cleared
- // the rest is put to the extra edit box.
- string extra = getStringFromVector(pars);
- dialog_->listingsED->setPlainText(toqstr(InsetListingsParams(extra).separatedParams()));
-}
-
-
-bool QListings::isValid()
-{
- return dialog_->validate_listings_params().empty();
-}
-
-
-} // namespace frontend
-} // namespace lyx
-
-
-#include "QListings_moc.cpp"
+++ /dev/null
-// -*- C++ -*-
-/**
- * \file QListings.h
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Bo Peng
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#ifndef QLISTINGS_H
-#define QLISTINGS_H
-
-#include "QDialogView.h"
-#include "ui_ListingsUi.h"
-
-#include <QDialog>
-#include <QCloseEvent>
-
-namespace lyx {
-namespace frontend {
-
-class QListings;
-
-class QListingsDialog : public QDialog, public Ui::QListingsUi {
- Q_OBJECT
-public:
- QListingsDialog(QListings * form);
- /// get values from all the widgets and form a string
- std::string construct_params();
- /// validate listings parameters and return an error message, if any
- docstring validate_listings_params();
-protected Q_SLOTS:
- virtual void change_adaptor();
- /// AFAIK, QValidator only works for QLineEdit so
- /// I have to validate listingsED (QTextEdit) manually.
- /// This function displays a hint or error message returned by
- /// validate_listings_params
- void set_listings_msg();
- /// turn off inline when float is clicked
- void on_floatCB_stateChanged(int state);
- /// turn off float when inline is clicked
- void on_inlineCB_stateChanged(int state);
- /// turn off numbering options when none is selected
- void on_numberSideCO_currentIndexChanged(int);
- /// show dialect when language is chosen
- void on_languageCO_currentIndexChanged(int);
-protected:
- virtual void closeEvent(QCloseEvent * e);
-private:
- QListings * form_;
-};
-
-
-class ControlListings;
-
-class QListings : public QController<ControlListings, QView<QListingsDialog> > {
-public:
- friend class QListingsDialog;
-
- QListings(Dialog &);
-private:
- /// Apply changes
- virtual void apply();
- /// update
- virtual void update_contents();
- /// build the dialog
- virtual void build_dialog();
-protected:
- /// return false if validate_listings_params returns error
- virtual bool isValid();
-};
-
-} // namespace frontend
-} // namespace lyx
-
-#endif // QLISTINGS_H
+++ /dev/null
-/**
- * \file QLog.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author John Levon
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "QLog.h"
-#include "qt_helpers.h"
-
-#include "frontends/Application.h"
-
-#include "controllers/ControlLog.h"
-
-#include <sstream>
-
-#include <QTextBrowser>
-#include <QPushButton>
-
-namespace lyx {
-namespace frontend {
-
-/////////////////////////////////////////////////////////////////////
-//
-// QLogDialog
-//
-/////////////////////////////////////////////////////////////////////
-
-
-QLogDialog::QLogDialog(QLog * form)
- : form_(form)
-{
- setupUi(this);
-
- connect(closePB, SIGNAL(clicked()),
- form, SLOT(slotClose()));
- connect( updatePB, SIGNAL( clicked() ),
- this, SLOT( updateClicked() ) );
-}
-
-
-void QLogDialog::closeEvent(QCloseEvent * e)
-{
- form_->slotWMHide();
- e->accept();
-}
-
-
-void QLogDialog::updateClicked()
-{
- form_->update_contents();
-}
-
-
-/////////////////////////////////////////////////////////////////////
-//
-// LogHighlighter
-//
-/////////////////////////////////////////////////////////////////////
-
-LogHighlighter::LogHighlighter(QTextDocument * parent)
- : QSyntaxHighlighter(parent)
-{
- infoFormat.setForeground(Qt::darkGray);
- warningFormat.setForeground(Qt::darkBlue);
- errorFormat.setForeground(Qt::red);
-}
-
-
-void LogHighlighter::highlightBlock(QString const & text)
-{
- // Info
- QRegExp exprInfo("^(Document Class:|LaTeX Font Info:|File:|Package:|Language:|Underfull|Overfull|\\(|\\\\).*$");
- int index = text.indexOf(exprInfo);
- while (index >= 0) {
- int length = exprInfo.matchedLength();
- setFormat(index, length, infoFormat);
- index = text.indexOf(exprInfo, index + length);
- }
- // LaTeX Warning:
- QRegExp exprWarning("^LaTeX Warning.*$");
- index = text.indexOf(exprWarning);
- while (index >= 0) {
- int length = exprWarning.matchedLength();
- setFormat(index, length, warningFormat);
- index = text.indexOf(exprWarning, index + length);
- }
- // ! error
- QRegExp exprError("^!.*$");
- index = text.indexOf(exprError);
- while (index >= 0) {
- int length = exprError.matchedLength();
- setFormat(index, length, errorFormat);
- index = text.indexOf(exprError, index + length);
- }
-}
-
-
-/////////////////////////////////////////////////////////////////////
-//
-// QLog
-//
-/////////////////////////////////////////////////////////////////////
-
-typedef QController<ControlLog, QView<QLogDialog> > LogBase;
-
-QLog::QLog(Dialog & parent)
- : LogBase(parent, docstring())
-{}
-
-
-void QLog::build_dialog()
-{
- dialog_.reset(new QLogDialog(this));
- // set syntax highlighting
- highlighter = new LogHighlighter(dialog_->logTB->document());
- //
- dialog_->logTB->setReadOnly(true);
- QFont font(toqstr(theApp()->typewriterFontName()));
- font.setKerning(false);
- font.setFixedPitch(true);
- font.setStyleHint(QFont::TypeWriter);
- dialog_->logTB->setFont(font);
-}
-
-
-void QLog::update_contents()
-{
- setTitle(controller().title());
-
- std::ostringstream ss;
- controller().getContents(ss);
-
- dialog_->logTB->setPlainText(toqstr(ss.str()));
-}
-
-} // namespace frontend
-} // namespace lyx
-
-#include "QLog_moc.cpp"
+++ /dev/null
-// -*- C++ -*-
-/**
- * \file QLog.h
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author John Levon
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#ifndef QLOG_H
-#define QLOG_H
-
-#include "QDialogView.h"
-
-
-#include "ui_LogUi.h"
-
-#include <QDialog>
-#include <QCloseEvent>
-#include <QSyntaxHighlighter>
-
-namespace lyx {
-namespace frontend {
-
-class QLog;
-
-class QLogDialog : public QDialog, public Ui::QLogUi {
- Q_OBJECT
-public:
- QLogDialog(QLog * form);
-protected Q_SLOTS:
- virtual void updateClicked();
-protected:
- virtual void closeEvent(QCloseEvent * e);
-private:
- QLog * form_;
-};
-
-
-class ControlLog;
-class LogHighlighter;
-
-///
-class QLog
- : public QController<ControlLog, QView<QLogDialog> >
-{
-public:
- ///
- friend class QLogDialog;
- ///
- QLog(Dialog &);
-private:
- /// Apply changes
- virtual void apply() {}
- /// update
- virtual void update_contents();
- /// build the dialog
- virtual void build_dialog();
- /// log syntax highlighter
- LogHighlighter * highlighter;
-};
-
-
-///
-class LogHighlighter : public QSyntaxHighlighter
-{
-public:
- LogHighlighter(QTextDocument * parent);
-
-protected:
- void highlightBlock(QString const & text);
-
-private:
- QTextCharFormat infoFormat;
- QTextCharFormat warningFormat;
- QTextCharFormat errorFormat;
-};
-
-
-} // namespace frontend
-} // namespace lyx
-
-#endif // QLOG_H
+++ /dev/null
-/**
- * \file QMathMatrixDialog.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Jürgen Spitzmüller
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "QMathMatrixDialog.h"
-
-#include "EmptyTable.h"
-#include "qt_helpers.h"
-
-#include "controllers/ControlMath.h"
-
-#include <sstream>
-
-#include <qlineedit.h>
-#include <qpushbutton.h>
-#include <qspinbox.h>
-
-#include "gettext.h"
-
-using std::ostringstream;
-using std::string;
-
-namespace lyx {
-namespace frontend {
-
-namespace {
-
-char h_align_str[80] = "c";
-char v_align_c[] = "tcb";
-
-} // namespace anon
-
-
-typedef QController<ControlMath, QView<QMathMatrixDialog> > matrix_base;
-
-
-QMathMatrix::QMathMatrix(Dialog & parent)
- : matrix_base(parent, _("Math Matrix"))
-{}
-
-
-void QMathMatrix::build_dialog()
-{
- dialog_.reset(new QMathMatrixDialog(this));
-}
-
-
-QMathMatrixDialog::QMathMatrixDialog(QMathMatrix * form)
- : form_(form)
-{
- setupUi(this);
-
- setWindowTitle(qt_("LyX: Insert Matrix"));
-
- table->setMinimumSize(100, 100);
- rowsSB->setValue(5);
- columnsSB->setValue(5);
- valignCO->setCurrentIndex(1);
-
- connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
- connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
-
- connect(table, SIGNAL(rowsChanged(int)),
- rowsSB, SLOT(setValue(int)));
- connect(table, SIGNAL(colsChanged(int)),
- columnsSB, SLOT(setValue(int)));
- connect(rowsSB, SIGNAL(valueChanged(int)),
- table, SLOT(setNumberRows(int)));
- connect(columnsSB, SIGNAL(valueChanged(int)),
- table, SLOT(setNumberColumns(int)));
- connect(rowsSB, SIGNAL(valueChanged(int)),
- this, SLOT(rowsChanged(int)));
- connect(columnsSB, SIGNAL(valueChanged(int)),
- this, SLOT(columnsChanged(int)) );
- connect(valignCO, SIGNAL(highlighted(const QString&)),
- this, SLOT(change_adaptor()));
- connect(halignED, SIGNAL(textChanged(const QString&)),
- this, SLOT(change_adaptor()));
-}
-
-
-void QMathMatrixDialog::columnsChanged(int)
-{
- int const nx = int(columnsSB->value());
- for (int i = 0; i < nx; ++i)
- h_align_str[i] = 'c';
-
- h_align_str[nx] = '\0';
- halignED->setText(h_align_str);
-}
-
-
-void QMathMatrixDialog::rowsChanged(int)
-{
-}
-
-
-void QMathMatrixDialog::change_adaptor()
-{
- // FIXME: We need a filter for the halign input
-}
-
-
-void QMathMatrixDialog::slotOK()
-{
- char const c = v_align_c[valignCO->currentIndex()];
- string const sh = fromqstr(halignED->text());
- int const nx = int(columnsSB->value());
- int const ny = int(rowsSB->value());
-
- ostringstream os;
- os << nx << ' ' << ny << ' ' << c << ' ' << sh;
- form_->controller().dispatchMatrix(os.str().c_str());
-
- // close the dialog
- close();
-}
-
-
-void QMathMatrixDialog::slotClose()
-{
- close();
-}
-
-} // namespace frontend
-} // namespace lyx
-
-#include "QMathMatrixDialog_moc.cpp"
+++ /dev/null
-// -*- C++ -*-
-/**
- * \file QMathMatrixDialog.h
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author John Levon
- * \author Edwin Leuven
- * \author Jürgen Spitzmüller
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#ifndef QMATHMATRIXDIALOG_H
-#define QMATHMATRIXDIALOG_H
-
-#include "QDialogView.h"
-
-#include "ui_MathMatrixUi.h"
-
-#include <QDialog>
-
-namespace lyx {
-namespace frontend {
-
-class QMathMatrix;
-class ControlMath;
-
-
-class QMathMatrixDialog : public QDialog, public Ui::QMathMatrixUi {
- Q_OBJECT
-public:
- QMathMatrixDialog(QMathMatrix * form);
-public Q_SLOTS:
- void slotOK();
- void slotClose();
-protected Q_SLOTS:
- virtual void columnsChanged(int);
- virtual void rowsChanged(int);
- virtual void change_adaptor();
-private:
- QMathMatrix * form_;
-};
-
-
-class QMathMatrix : public QController<ControlMath, QView<QMathMatrixDialog> > {
-public:
- friend class QMathMatrixDialog;
-
- QMathMatrix(Dialog &);
-
-private:
- virtual void apply() {}
- virtual void update_contents() {}
- /// Build the dialog.
- virtual void build_dialog();
-};
-
-
-} // namespace frontend
-} // namespace lyx
-
-#endif // QMATHMATRIXDIALOG_H
+++ /dev/null
-/**
- * \file QNomencl.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author John Levon
- * \author O. U. Baran
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "debug.h"
-#include "ControlCommand.h"
-#include "qt_helpers.h"
-
-#include "QNomencl.h"
-#include "Qt2BC.h"
-#include "ButtonController.h"
-#include <QLabel>
-#include <QLineEdit>
-#include <QPushButton>
-#include <QTextEdit>
-#include <QWhatsThis>
-#include <QCloseEvent>
-
-using std::string;
-
-namespace lyx {
-namespace frontend {
-
-/////////////////////////////////////////////////////////////////////
-//
-// QNomenclDialog
-//
-/////////////////////////////////////////////////////////////////////
-
-QNomenclDialog::QNomenclDialog(QNomencl * form)
- : form_(form)
-{
- setupUi(this);
-
- connect(okPB, SIGNAL(clicked()), form, SLOT(slotOK()));
- connect(closePB, SIGNAL(clicked()), form, SLOT(slotClose()));
- connect(symbolED, SIGNAL(textChanged(const QString&)),
- this, SLOT(change_adaptor()));
- connect(descriptionTE, SIGNAL(textChanged()),
- this, SLOT(change_adaptor()));
-
- setFocusProxy(descriptionTE);
-}
-
-
-void QNomenclDialog::show()
-{
- QDialog::show();
-}
-
-
-void QNomenclDialog::change_adaptor()
-{
- form_->changed();
-}
-
-
-void QNomenclDialog::reject()
-{
- form_->slotClose();
-}
-
-
-void QNomenclDialog::closeEvent(QCloseEvent * e)
-{
- form_->slotWMHide();
- e->accept();
-}
-
-
-/////////////////////////////////////////////////////////////////////
-//
-// QNomencl
-//
-/////////////////////////////////////////////////////////////////////
-
-
-typedef QController<ControlCommand, QView<QNomenclDialog> > NomenBase;
-
-
-QNomencl::QNomencl(Dialog & parent, docstring const & title)
- : NomenBase(parent, title)
-{
-}
-
-
-void QNomencl::build_dialog()
-{
- dialog_.reset(new QNomenclDialog(this));
-
- bcview().setOK(dialog_->okPB);
- bcview().setCancel(dialog_->closePB);
- bcview().addReadOnly(dialog_->symbolED);
- bcview().addReadOnly(dialog_->descriptionTE);
- bcview().addReadOnly(dialog_->prefixED);
-}
-
-
-void QNomencl::update_contents()
-{
- dialog_->prefixED->setText(toqstr(controller().params()["prefix"]));
- dialog_->symbolED->setText(toqstr(controller().params()["symbol"]));
- QString description = toqstr(controller().params()["description"]);
- description.replace("\\\\","\n");
- dialog_->descriptionTE->setPlainText(description);
-
- bc().valid(isValid());
-}
-
-
-void QNomencl::apply()
-{
- controller().params()["prefix"] = qstring_to_ucs4(dialog_->prefixED->text());
- controller().params()["symbol"] = qstring_to_ucs4(dialog_->symbolED->text());
- QString description = dialog_->descriptionTE->toPlainText();
- description.replace('\n',"\\\\");
- controller().params()["description"] = qstring_to_ucs4(description);
-}
-
-
-bool QNomencl::isValid()
-{
- QString const description = dialog_->descriptionTE->toPlainText();
- return !dialog_->symbolED->text().isEmpty() && !description.isEmpty();
-}
-
-} // namespace frontend
-} // namespace lyx
-
-#include "QNomencl_moc.cpp"
+++ /dev/null
-// -*- C++ -*-
-/**
- * \file QNomencl.h
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author John Levon
- * \author Kalle Dalheimer
- * \author O. U. Baran
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#ifndef QNOMENCL_H
-#define QNOMENCL_H
-
-#include "QDialogView.h"
-#include "ui_NomenclUi.h"
-
-#include <QDialog>
-
-class QCloseEvent;
-
-
-namespace lyx {
-namespace frontend {
-
-class QNomencl;
-
-class QNomenclDialog : public QDialog, public Ui::QNomenclUi {
- Q_OBJECT
-public:
- QNomenclDialog(QNomencl * form);
- virtual void show();
-protected Q_SLOTS:
- virtual void change_adaptor();
- virtual void reject();
-protected:
- virtual void closeEvent(QCloseEvent * e);
-private:
- QNomencl * form_;
-};
-
-
-class ControlCommand;
-
-class QNomencl :
- public QController<ControlCommand, QView<QNomenclDialog> >
-{
-public:
- friend class QNomenclDialog;
-
- QNomencl(Dialog &, docstring const & title);
-protected:
- virtual bool isValid();
-private:
- /// Apply changes
- virtual void apply();
- /// update
- virtual void update_contents();
- /// build the dialog
- virtual void build_dialog();
-};
-
-} // namespace frontend
-} // namespace lyx
-
-#endif // QNOMENCL_H
+++ /dev/null
-/**
- * \file QNote.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Jürgen Spitzmüller
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "QNote.h"
-#include "Qt2BC.h"
-
-#include "controllers/ControlNote.h"
-
-#include "insets/InsetNote.h"
-
-#include <QCloseEvent>
-
-namespace lyx {
-namespace frontend {
-
-/////////////////////////////////////////////////////////////////////
-//
-// QNoteDialog
-//
-/////////////////////////////////////////////////////////////////////
-
-QNoteDialog::QNoteDialog(QNote * form)
- : form_(form)
-{
- setupUi(this);
-
- connect(okPB, SIGNAL(clicked()), form, SLOT(slotOK()));
- connect(closePB, SIGNAL(clicked()), form, SLOT(slotClose()));
-
- connect(noteRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
- connect(greyedoutRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
- connect(commentRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
- connect(framedRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
- connect(shadedRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
-}
-
-
-void QNoteDialog::closeEvent(QCloseEvent * e)
-{
- form_->slotWMHide();
- e->accept();
-}
-
-
-void QNoteDialog::change_adaptor()
-{
- form_->changed();
-}
-
-
-/////////////////////////////////////////////////////////////////////
-//
-// QNote
-//
-/////////////////////////////////////////////////////////////////////
-
-typedef QController<ControlNote, QView<QNoteDialog> > NoteBase;
-
-
-QNote::QNote(Dialog & parent)
- : NoteBase(parent, _("Note Settings"))
-{}
-
-
-void QNote::build_dialog()
-{
- dialog_.reset(new QNoteDialog(this));
-
- bcview().setOK(dialog_->okPB);
- bcview().setCancel(dialog_->closePB);
-}
-
-
-void QNote::update_contents()
-{
- QRadioButton * rb = 0;
-
- switch (controller().params().type) {
- case InsetNoteParams::Note:
- rb = dialog_->noteRB;
- break;
- case InsetNoteParams::Comment:
- rb = dialog_->commentRB;
- break;
- case InsetNoteParams::Greyedout:
- rb = dialog_->greyedoutRB;
- break;
- case InsetNoteParams::Framed:
- rb = dialog_->framedRB;
- break;
- case InsetNoteParams::Shaded:
- rb = dialog_->shadedRB;
- break;
- }
-
- rb->setChecked(true);
-}
-
-
-void QNote::apply()
-{
- InsetNoteParams::Type type;
-
- if (dialog_->greyedoutRB->isChecked())
- type = InsetNoteParams::Greyedout;
- else if (dialog_->commentRB->isChecked())
- type = InsetNoteParams::Comment;
- else if (dialog_->framedRB->isChecked())
- type = InsetNoteParams::Framed;
- else if (dialog_->shadedRB->isChecked())
- type = InsetNoteParams::Shaded;
- else
- type = InsetNoteParams::Note;
-
- controller().params().type = type;
-}
-
-} // namespace frontend
-} // namespace lyx
-
-#include "QNote_moc.cpp"
+++ /dev/null
-// -*- C++ -*-
-/**
- * \file QNote.h
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Jürgen Spitzmüller
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#ifndef QNOTE_H
-#define QNOTE_H
-
-#include "QDialogView.h"
-#include "ui_NoteUi.h"
-
-#include <QDialog>
-class QCloseEvent;
-
-namespace lyx {
-namespace frontend {
-
-class QNote;
-
-class QNoteDialog : public QDialog, public Ui::QNoteUi {
- Q_OBJECT
-public:
- QNoteDialog(QNote * form);
-protected Q_SLOTS:
- virtual void change_adaptor();
-protected:
- virtual void closeEvent(QCloseEvent * e);
-private:
- QNote * form_;
-};
-
-
-class ControlNote;
-
-/** This class provides a QT implementation of the Note Dialog.
- */
-class QNote : public QController<ControlNote, QView<QNoteDialog> >
-{
-public:
- friend class QNoteDialog;
-
- /// Constructor
- QNote(Dialog &);
-private:
- /// Apply changes
- virtual void apply();
- /// Build the dialog
- virtual void build_dialog();
- /// Update dialog before showing it
- virtual void update_contents();
-};
-
-} // namespace frontend
-} // namespace lyx
-
-#endif // QNOTE_H
+++ /dev/null
-/**
- * \file QParagraph.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Edwin Leuven
- * \author Richard Heck
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "QParagraph.h"
-#include "Qt2BC.h"
-#include "qt_helpers.h"
-
-#include "debug.h"
-#include "ParagraphParameters.h"
-#include "Spacing.h"
-
-#include "controllers/ControlParagraph.h"
-#include "controllers/frontend_helpers.h"
-
-#include <QCheckBox>
-#include <QLineEdit>
-#include <QPushButton>
-
-using std::string;
-using std::endl;
-
-/////////////////////////////////////////////////////////////////////
-//
-// QParagraphDialog
-//
-/////////////////////////////////////////////////////////////////////
-
-
-#include <boost/current_function.hpp>
-
-namespace lyx {
-namespace frontend {
-
-QParagraphDialog::QParagraphDialog(QParagraph * form)
- : form_(form)
-{
- setupUi(this);
-
- connect(okPB, SIGNAL(clicked()), form_, SLOT(slotOK()));
- connect(applyPB, SIGNAL(clicked()), form_, SLOT(slotApply()));
- connect(closePB, SIGNAL(clicked()), form_, SLOT(slotClose()));
- connect(restorePB, SIGNAL(clicked()), form_, SLOT(slotRestore()));
- connect(alignDefaultRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
- connect(alignJustRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
- connect(alignLeftRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
- connect(alignRightRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
- connect(alignCenterRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
- connect(linespacing, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
- connect(linespacing, SIGNAL(activated(int)),
- this, SLOT(enableLinespacingValue(int)));
- connect(linespacingValue, SIGNAL(textChanged(const QString &)),
- this, SLOT(change_adaptor()));
- connect(indentCB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
- connect(labelWidth, SIGNAL(textChanged(const QString &)),
- this, SLOT(change_adaptor()));
-
- linespacingValue->setValidator(new QDoubleValidator(linespacingValue));
-
- labelWidth->setWhatsThis( qt_(
- "As described in the User Guide, the width of"
- " this text determines the width of the label part"
- " of each item in environments like List and"
- " Description.\n"
- "\n"
- " Normally, you won't need to set this,"
- " since the largest label width of all the"
- " items is used."
- ));
-
- radioMap[LYX_ALIGN_LAYOUT] = alignDefaultRB;
- radioMap[LYX_ALIGN_BLOCK] = alignJustRB;
- radioMap[LYX_ALIGN_LEFT] = alignLeftRB;
- radioMap[LYX_ALIGN_RIGHT] = alignRightRB;
- radioMap[LYX_ALIGN_CENTER] = alignCenterRB;
-
- labelMap[LYX_ALIGN_LAYOUT] = _("Use Paragraph's Default Alignment");
- labelMap[LYX_ALIGN_BLOCK] = _("Justified");
- labelMap[LYX_ALIGN_LEFT] = _("Left");
- labelMap[LYX_ALIGN_RIGHT] = _("Right");
- labelMap[LYX_ALIGN_CENTER] = _("Center");
-}
-
-
-void QParagraphDialog::closeEvent(QCloseEvent * e)
-{
- form_->slotWMHide();
- e->accept();
-}
-
-
-void QParagraphDialog::change_adaptor()
-{
- form_->changed();
-}
-
-
-void QParagraphDialog::enableLinespacingValue(int)
-{
- bool const enable = linespacing->currentIndex() == 4;
- linespacingValue->setEnabled(enable);
-}
-
-
-void QParagraphDialog::checkAlignmentRadioButtons() {
- LyXAlignment const alignPossible = form_->controller().alignPossible();
-
- QPRadioMap::iterator it = radioMap.begin();
- for (; it != radioMap.end(); ++it) {
- LyXAlignment const align = it->first;
- it->second->setEnabled(align & alignPossible);
- }
- docstring label = labelMap[LYX_ALIGN_LAYOUT];
- if (!form_->controller().haveMulitParSelection())
- label += (" (" + labelMap[form_->controller().alignDefault()] + ")");
- alignDefaultRB->setText(toqstr(label));
-}
-
-
-void QParagraphDialog::alignmentToRadioButtons(LyXAlignment align)
-{
- QPRadioMap::const_iterator it = radioMap.begin();
- for (;it != radioMap.end(); ++it) {
- if (align == it->first) {
- it->second->blockSignals(true);
- it->second->setChecked(true);
- it->second->blockSignals(false);
- return;
- }
- }
-
- lyxerr << BOOST_CURRENT_FUNCTION << "Unknown alignment "
- << align << std::endl;
-}
-
-
-LyXAlignment QParagraphDialog::getAlignmentFromDialog()
-{
- LyXAlignment alignment = LYX_ALIGN_NONE;
- QPRadioMap::const_iterator it = radioMap.begin();
- for (; it != radioMap.end(); ++it) {
- if (it->second->isChecked()) {
- alignment = it->first;
- break;
- }
- }
- return alignment;
-}
-
-
-/////////////////////////////////////////////////////////////////////
-//
-// QParagraph
-//
-/////////////////////////////////////////////////////////////////////
-
-typedef QController<ControlParagraph, QView<QParagraphDialog> >
- ParagraphBase;
-
-
-QParagraph::QParagraph(Dialog & parent)
- : ParagraphBase(parent, _("Paragraph Settings"))
-{}
-
-
-void QParagraph::build_dialog()
-{
- // the dialog
- dialog_.reset(new QParagraphDialog(this));
-
- // Manage the ok, apply, restore and cancel/close buttons
- bcview().setOK(dialog_->okPB);
- bcview().setApply(dialog_->applyPB);
- bcview().setCancel(dialog_->closePB);
- bcview().setRestore(dialog_->restorePB);
-}
-
-
-void QParagraph::apply()
-{
- ParagraphParameters & params = controller().params();
-
- params.align(dialog_->getAlignmentFromDialog());
-
- // get spacing
- Spacing::Space linespacing = Spacing::Default;
- string other;
- switch (dialog_->linespacing->currentIndex()) {
- case 0:
- linespacing = Spacing::Default;
- break;
- case 1:
- linespacing = Spacing::Single;
- break;
- case 2:
- linespacing = Spacing::Onehalf;
- break;
- case 3:
- linespacing = Spacing::Double;
- break;
- case 4:
- linespacing = Spacing::Other;
- other = fromqstr(dialog_->linespacingValue->text());
- break;
- }
-
- Spacing const spacing(linespacing, other);
- params.spacing(spacing);
-
- // label width
- params.labelWidthString(qstring_to_ucs4(dialog_->labelWidth->text()));
- // indendation
- params.noindent(!dialog_->indentCB->isChecked());
-}
-
-
-void QParagraph::update_contents()
-{
- ParagraphParameters const & params = controller().params();
-
- // label width
- docstring const & labelwidth = params.labelWidthString();
- // FIXME We should not compare translated strings
- if (labelwidth != _("Senseless with this layout!")) {
- dialog_->labelwidthGB->setEnabled(true);
- dialog_->labelWidth->setText(toqstr(labelwidth));
- } else {
- dialog_->labelwidthGB->setEnabled(false);
- dialog_->labelWidth->setText("");
- }
-
- // alignment
- dialog_->checkAlignmentRadioButtons();
- dialog_->alignmentToRadioButtons(params.align());
-
- //indentation
- bool const canindent = controller().canIndent();
- dialog_->indentCB->setEnabled(canindent);
- dialog_->indentCB->setChecked(canindent && !params.noindent());
-
- // linespacing
- int linespacing;
- Spacing const & space = params.spacing();
- switch (space.getSpace()) {
- case Spacing::Single:
- linespacing = 1;
- break;
- case Spacing::Onehalf:
- linespacing = 2;
- break;
- case Spacing::Double:
- linespacing = 3;
- break;
- case Spacing::Other:
- linespacing = 4;
- break;
- default:
- linespacing = 0;
- break;
- }
- dialog_->linespacing->setCurrentIndex(linespacing);
- if (space.getSpace() == Spacing::Other) {
- dialog_->linespacingValue->setText(toqstr(space.getValueAsString()));
- dialog_->linespacingValue->setEnabled(true);
- } else {
- dialog_->linespacingValue->setText("");
- dialog_->linespacingValue->setEnabled(false);
- }
-}
-
-} // namespace frontend
-} // namespace lyx
-
-#include "QParagraph_moc.cpp"
+++ /dev/null
-// -*- C++ -*-
-/**
- * \file QParagraph.h
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Edwin Leuven
- * \author John Levon
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#ifndef QPARAGRAPH_H
-#define QPARAGRAPH_H
-
-#include "QDialogView.h"
-
-#include "Layout.h"
-#include "ui_ParagraphUi.h"
-
-#include <QDialog>
-#include <QCloseEvent>
-
-#include <map>
-
-namespace lyx {
-namespace frontend {
-
-class QParagraph;
-
-class QParagraphDialog : public QDialog, public Ui::QParagraphUi {
- Q_OBJECT
-public:
- QParagraphDialog(QParagraph * form);
- ///
- void checkAlignmentRadioButtons();
- ///
- void alignmentToRadioButtons(LyXAlignment align = LYX_ALIGN_LAYOUT);
- ///
- LyXAlignment getAlignmentFromDialog();
-protected:
- void closeEvent (QCloseEvent * e);
-private:
- QParagraph * form_;
- typedef std::map<LyXAlignment, QRadioButton *> QPRadioMap;
- QPRadioMap radioMap;
- typedef std::map<LyXAlignment, docstring> QPAlignmentLabels;
- QPAlignmentLabels labelMap;
-
-protected Q_SLOTS:
- ///
- void change_adaptor();
- ///
- void enableLinespacingValue(int);
-};
-
-
-class ControlParagraph;
-
-class QParagraph
- : public QController<ControlParagraph, QView<QParagraphDialog> >
-{
-public:
- friend class QParagraphDialog;
-
- QParagraph(Dialog &);
-private:
- /// Apply changes
- virtual void apply();
- /// update
- virtual void update_contents();
- /// build the dialog
- virtual void build_dialog();
-};
-
-} // namespace frontend
-} // namespace lyx
-
-#endif // QPARAGRAPH_H
+++ /dev/null
-/**
- * \file QPrefs.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author John Levon
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "QPrefs.h"
-
-#include "Qt2BC.h"
-#include "qt_helpers.h"
-#include "GuiApplication.h"
-
-#include "ConverterCache.h"
-#include "Session.h"
-#include "debug.h"
-#include "Color.h"
-#include "Font.h"
-#include "PanelStack.h"
-#include "QFontExample.h"
-#include "gettext.h"
-
-#include "support/lstrings.h"
-#include "support/os.h"
-
-#include "controllers/ControlPrefs.h"
-#include "controllers/frontend_helpers.h"
-
-#include "frontends/alert.h"
-#include "frontends/Application.h"
-
-#include <QCheckBox>
-#include <QColorDialog>
-#include <QFontDatabase>
-#include <QLineEdit>
-#include <QPushButton>
-#include <QSpinBox>
-#include <QString>
-#include <QValidator>
-#include <QCloseEvent>
-
-#include <boost/tuple/tuple.hpp>
-#include <iomanip>
-#include <sstream>
-
-using namespace Ui;
-
-using lyx::support::compare_ascii_no_case;
-using lyx::support::os::external_path;
-using lyx::support::os::external_path_list;
-using lyx::support::os::internal_path;
-using lyx::support::os::internal_path_list;
-
-using std::endl;
-using std::string;
-using std::pair;
-using std::vector;
-
-
-namespace lyx {
-namespace frontend {
-
-/////////////////////////////////////////////////////////////////////
-//
-// Helpers
-//
-/////////////////////////////////////////////////////////////////////
-
-// FIXME: move to frontend_helpers.h
-
-template<class A>
-static size_t findPos_helper(std::vector<A> const & vec, A const & val)
-{
- typedef typename std::vector<A>::const_iterator Cit;
-
- Cit it = std::find(vec.begin(), vec.end(), val);
- if (it == vec.end())
- return 0;
- return std::distance(vec.begin(), it);
-}
-
-
-static void setComboxFont(QComboBox * cb, string const & family,
- string const & foundry)
-{
- string const name = makeFontName(family, foundry);
- for (int i = 0; i < cb->count(); ++i) {
- if (fromqstr(cb->itemText(i)) == name) {
- cb->setCurrentIndex(i);
- return;
- }
- }
-
- // Try matching without foundry name
-
- // We count in reverse in order to prefer the Xft foundry
- for (int i = cb->count() - 1; i >= 0; --i) {
- pair<string, string> tmp = parseFontName(fromqstr(cb->itemText(i)));
- if (compare_ascii_no_case(tmp.first, family) == 0) {
- cb->setCurrentIndex(i);
- return;
- }
- }
-
- // family alone can contain e.g. "Helvetica [Adobe]"
- pair<string, string> tmpfam = parseFontName(family);
-
- // We count in reverse in order to prefer the Xft foundry
- for (int i = cb->count() - 1; i >= 0; --i) {
- pair<string, string> tmp = parseFontName(fromqstr(cb->itemText(i)));
- if (compare_ascii_no_case(tmp.first, tmpfam.first) == 0) {
- cb->setCurrentIndex(i);
- return;
- }
- }
-
- // Bleh, default fonts, and the names couldn't be found. Hack
- // for bug 1063.
-
- QFont font;
- font.setKerning(false);
-
- if (family == theApp()->romanFontName()) {
- font.setStyleHint(QFont::Serif);
- font.setFamily(family.c_str());
- } else if (family == theApp()->sansFontName()) {
- font.setStyleHint(QFont::SansSerif);
- font.setFamily(family.c_str());
- } else if (family == theApp()->typewriterFontName()) {
- font.setStyleHint(QFont::TypeWriter);
- font.setFamily(family.c_str());
- } else {
- lyxerr << "FAILED to find the default font: '"
- << foundry << "', '" << family << '\''<< endl;
- return;
- }
-
- QFontInfo info(font);
- pair<string, string> tmp = parseFontName(fromqstr(info.family()));
- string const & default_font_name = tmp.first;
- lyxerr << "Apparent font is " << default_font_name << endl;
-
- for (int i = 0; i < cb->count(); ++i) {
- lyxerr << "Looking at " << fromqstr(cb->itemText(i)) << endl;
- if (compare_ascii_no_case(fromqstr(cb->itemText(i)),
- default_font_name) == 0) {
- cb->setCurrentIndex(i);
- return;
- }
- }
-
- lyxerr << "FAILED to find the font: '"
- << foundry << "', '" << family << '\'' <<endl;
-}
-
-
-/////////////////////////////////////////////////////////////////////
-//
-// PrefPlaintext
-//
-/////////////////////////////////////////////////////////////////////
-
-PrefPlaintext::PrefPlaintext(QWidget * parent)
- : PrefModule(_("Plain text"), 0, parent)
-{
- setupUi(this);
- connect(plaintextLinelengthSB, SIGNAL(valueChanged(int)),
- this, SIGNAL(changed()));
- connect(plaintextRoffED, SIGNAL(textChanged(const QString&)),
- this, SIGNAL(changed()));
-}
-
-
-void PrefPlaintext::apply(LyXRC & rc) const
-{
- rc.plaintext_linelen = plaintextLinelengthSB->value();
- rc.plaintext_roff_command = fromqstr(plaintextRoffED->text());
-}
-
-
-void PrefPlaintext::update(LyXRC const & rc)
-{
- plaintextLinelengthSB->setValue(rc.plaintext_linelen);
- plaintextRoffED->setText(toqstr(rc.plaintext_roff_command));
-}
-
-
-/////////////////////////////////////////////////////////////////////
-//
-// PrefDate
-//
-/////////////////////////////////////////////////////////////////////
-
-PrefDate::PrefDate(QWidget * parent)
- : PrefModule(_("Date format"), 0, parent)
-{
- setupUi(this);
- connect(DateED, SIGNAL(textChanged(const QString &)),
- this, SIGNAL(changed()));
-}
-
-
-void PrefDate::apply(LyXRC & rc) const
-{
- rc.date_insert_format = fromqstr(DateED->text());
-}
-
-
-void PrefDate::update(LyXRC const & rc)
-{
- DateED->setText(toqstr(rc.date_insert_format));
-}
-
-
-/////////////////////////////////////////////////////////////////////
-//
-// PrefKeyboard
-//
-/////////////////////////////////////////////////////////////////////
-
-PrefKeyboard::PrefKeyboard(QPrefs * form, QWidget * parent)
- : PrefModule(_("Keyboard"), form, parent)
-{
- setupUi(this);
-
- connect(keymapCB, SIGNAL(clicked()),
- this, SIGNAL(changed()));
- connect(firstKeymapED, SIGNAL(textChanged(const QString&)),
- this, SIGNAL(changed()));
- connect(secondKeymapED, SIGNAL(textChanged(const QString&)),
- this, SIGNAL(changed()));
-}
-
-
-void PrefKeyboard::apply(LyXRC & rc) const
-{
- // FIXME: can derive CB from the two EDs
- rc.use_kbmap = keymapCB->isChecked();
- rc.primary_kbmap = internal_path(fromqstr(firstKeymapED->text()));
- rc.secondary_kbmap = internal_path(fromqstr(secondKeymapED->text()));
-}
-
-
-void PrefKeyboard::update(LyXRC const & rc)
-{
- // FIXME: can derive CB from the two EDs
- keymapCB->setChecked(rc.use_kbmap);
- firstKeymapED->setText(toqstr(external_path(rc.primary_kbmap)));
- secondKeymapED->setText(toqstr(external_path(rc.secondary_kbmap)));
-}
-
-
-QString PrefKeyboard::testKeymap(QString keymap)
-{
- return toqstr(form_->controller().browsekbmap(from_utf8(internal_path(fromqstr(keymap)))));
-}
-
-
-void PrefKeyboard::on_firstKeymapPB_clicked(bool)
-{
- QString const file = testKeymap(firstKeymapED->text());
- if (!file.isEmpty())
- firstKeymapED->setText(file);
-}
-
-
-void PrefKeyboard::on_secondKeymapPB_clicked(bool)
-{
- QString const file = testKeymap(secondKeymapED->text());
- if (!file.isEmpty())
- secondKeymapED->setText(file);
-}
-
-
-void PrefKeyboard::on_keymapCB_toggled(bool keymap)
-{
- firstKeymapLA->setEnabled(keymap);
- secondKeymapLA->setEnabled(keymap);
- firstKeymapED->setEnabled(keymap);
- secondKeymapED->setEnabled(keymap);
- firstKeymapPB->setEnabled(keymap);
- secondKeymapPB->setEnabled(keymap);
-}
-
-
-/////////////////////////////////////////////////////////////////////
-//
-// PrefLatex
-//
-/////////////////////////////////////////////////////////////////////
-
-PrefLatex::PrefLatex(QPrefs * form, QWidget * parent)
- : PrefModule(_("LaTeX"), form, parent)
-{
- setupUi(this);
- connect(latexEncodingED, SIGNAL(textChanged(const QString&)),
- this, SIGNAL(changed()));
- connect(latexChecktexED, SIGNAL(textChanged(const QString&)),
- this, SIGNAL(changed()));
- connect(latexBibtexED, SIGNAL(textChanged(const QString&)),
- this, SIGNAL(changed()));
- connect(latexIndexED, SIGNAL(textChanged(const QString&)),
- this, SIGNAL(changed()));
- connect(latexAutoresetCB, SIGNAL(clicked()),
- this, SIGNAL(changed()));
- connect(latexDviPaperED, SIGNAL(textChanged(const QString&)),
- this, SIGNAL(changed()));
- connect(latexPaperSizeCO, SIGNAL(activated(int)),
- this, SIGNAL(changed()));
-}
-
-
-void PrefLatex::apply(LyXRC & rc) const
-{
- rc.fontenc = fromqstr(latexEncodingED->text());
- rc.chktex_command = fromqstr(latexChecktexED->text());
- rc.bibtex_command = fromqstr(latexBibtexED->text());
- rc.index_command = fromqstr(latexIndexED->text());
- rc.auto_reset_options = latexAutoresetCB->isChecked();
- rc.view_dvi_paper_option = fromqstr(latexDviPaperED->text());
- rc.default_papersize =
- form_->controller().toPaperSize(latexPaperSizeCO->currentIndex());
-}
-
-
-void PrefLatex::update(LyXRC const & rc)
-{
- latexEncodingED->setText(toqstr(rc.fontenc));
- latexChecktexED->setText(toqstr(rc.chktex_command));
- latexBibtexED->setText(toqstr(rc.bibtex_command));
- latexIndexED->setText(toqstr(rc.index_command));
- latexAutoresetCB->setChecked(rc.auto_reset_options);
- latexDviPaperED->setText(toqstr(rc.view_dvi_paper_option));
- latexPaperSizeCO->setCurrentIndex(
- form_->controller().fromPaperSize(rc.default_papersize));
-}
-
-
-/////////////////////////////////////////////////////////////////////
-//
-// PrefScreenFonts
-//
-/////////////////////////////////////////////////////////////////////
-
-PrefScreenFonts::PrefScreenFonts(QPrefs * form, QWidget * parent)
- : PrefModule(_("Screen fonts"), form, parent)
-{
- setupUi(this);
-
- connect(screenRomanCO, SIGNAL(activated(const QString&)),
- this, SLOT(select_roman(const QString&)));
- connect(screenSansCO, SIGNAL(activated(const QString&)),
- this, SLOT(select_sans(const QString&)));
- connect(screenTypewriterCO, SIGNAL(activated(const QString&)),
- this, SLOT(select_typewriter(const QString&)));
-
- QFontDatabase fontdb;
- QStringList families(fontdb.families());
- for (QStringList::Iterator it = families.begin(); it != families.end(); ++it) {
- screenRomanCO->addItem(*it);
- screenSansCO->addItem(*it);
- screenTypewriterCO->addItem(*it);
- }
- connect(screenRomanCO, SIGNAL(activated(const QString&)),
- this, SIGNAL(changed()));
- connect(screenSansCO, SIGNAL(activated(const QString&)),
- this, SIGNAL(changed()));
- connect(screenTypewriterCO, SIGNAL(activated(const QString&)),
- this, SIGNAL(changed()));
- connect(screenZoomSB, SIGNAL(valueChanged(int)),
- this, SIGNAL(changed()));
- connect(screenDpiSB, SIGNAL(valueChanged(int)),
- this, SIGNAL(changed()));
- connect(screenTinyED, SIGNAL(textChanged(const QString&)),
- this, SIGNAL(changed()));
- connect(screenSmallestED, SIGNAL(textChanged(const QString&)),
- this, SIGNAL(changed()));
- connect(screenSmallerED, SIGNAL(textChanged(const QString&)),
- this, SIGNAL(changed()));
- connect(screenSmallED, SIGNAL(textChanged(const QString&)),
- this, SIGNAL(changed()));
- connect(screenNormalED, SIGNAL(textChanged(const QString&)),
- this, SIGNAL(changed()));
- connect(screenLargeED, SIGNAL(textChanged(const QString&)),
- this, SIGNAL(changed()));
- connect(screenLargerED, SIGNAL(textChanged(const QString&)),
- this, SIGNAL(changed()));
- connect(screenLargestED, SIGNAL(textChanged(const QString&)),
- this, SIGNAL(changed()));
- connect(screenHugeED, SIGNAL(textChanged(const QString&)),
- this, SIGNAL(changed()));
- connect(screenHugerED, SIGNAL(textChanged(const QString&)),
- this, SIGNAL(changed()));
-
- screenTinyED->setValidator(new QDoubleValidator(
- screenTinyED));
- screenSmallestED->setValidator(new QDoubleValidator(
- screenSmallestED));
- screenSmallerED->setValidator(new QDoubleValidator(
- screenSmallerED));
- screenSmallED->setValidator(new QDoubleValidator(
- screenSmallED));
- screenNormalED->setValidator(new QDoubleValidator(
- screenNormalED));
- screenLargeED->setValidator(new QDoubleValidator(
- screenLargeED));
- screenLargerED->setValidator(new QDoubleValidator(
- screenLargerED));
- screenLargestED->setValidator(new QDoubleValidator(
- screenLargestED));
- screenHugeED->setValidator(new QDoubleValidator(
- screenHugeED));
- screenHugerED->setValidator(new QDoubleValidator(
- screenHugerED));
-}
-
-
-void PrefScreenFonts::apply(LyXRC & rc) const
-{
- LyXRC const oldrc(rc);
-
- boost::tie(rc.roman_font_name, rc.roman_font_foundry)
- = parseFontName(fromqstr(screenRomanCO->currentText()));
- boost::tie(rc.sans_font_name, rc.sans_font_foundry) =
- parseFontName(fromqstr(screenSansCO->currentText()));
- boost::tie(rc.typewriter_font_name, rc.typewriter_font_foundry) =
- parseFontName(fromqstr(screenTypewriterCO->currentText()));
-
- rc.zoom = screenZoomSB->value();
- rc.dpi = screenDpiSB->value();
- rc.font_sizes[Font::SIZE_TINY] = fromqstr(screenTinyED->text());
- rc.font_sizes[Font::SIZE_SCRIPT] = fromqstr(screenSmallestED->text());
- rc.font_sizes[Font::SIZE_FOOTNOTE] = fromqstr(screenSmallerED->text());
- rc.font_sizes[Font::SIZE_SMALL] = fromqstr(screenSmallED->text());
- rc.font_sizes[Font::SIZE_NORMAL] = fromqstr(screenNormalED->text());
- rc.font_sizes[Font::SIZE_LARGE] = fromqstr(screenLargeED->text());
- rc.font_sizes[Font::SIZE_LARGER] = fromqstr(screenLargerED->text());
- rc.font_sizes[Font::SIZE_LARGEST] = fromqstr(screenLargestED->text());
- rc.font_sizes[Font::SIZE_HUGE] = fromqstr(screenHugeED->text());
- rc.font_sizes[Font::SIZE_HUGER] = fromqstr(screenHugerED->text());
-
- if (rc.font_sizes != oldrc.font_sizes
- || rc.roman_font_name != oldrc.roman_font_name
- || rc.sans_font_name != oldrc.sans_font_name
- || rc.typewriter_font_name != oldrc.typewriter_font_name
- || rc.zoom != oldrc.zoom || rc.dpi != oldrc.dpi) {
- form_->controller().updateScreenFonts();
- }
-}
-
-
-void PrefScreenFonts::update(LyXRC const & rc)
-{
- setComboxFont(screenRomanCO, rc.roman_font_name,
- rc.roman_font_foundry);
- setComboxFont(screenSansCO, rc.sans_font_name,
- rc.sans_font_foundry);
- setComboxFont(screenTypewriterCO, rc.typewriter_font_name,
- rc.typewriter_font_foundry);
-
- select_roman(screenRomanCO->currentText());
- select_sans(screenSansCO->currentText());
- select_typewriter(screenTypewriterCO->currentText());
-
- screenZoomSB->setValue(rc.zoom);
- screenDpiSB->setValue(rc.dpi);
- screenTinyED->setText(toqstr(rc.font_sizes[Font::SIZE_TINY]));
- screenSmallestED->setText(toqstr(rc.font_sizes[Font::SIZE_SCRIPT]));
- screenSmallerED->setText(toqstr(rc.font_sizes[Font::SIZE_FOOTNOTE]));
- screenSmallED->setText(toqstr(rc.font_sizes[Font::SIZE_SMALL]));
- screenNormalED->setText(toqstr(rc.font_sizes[Font::SIZE_NORMAL]));
- screenLargeED->setText(toqstr(rc.font_sizes[Font::SIZE_LARGE]));
- screenLargerED->setText(toqstr(rc.font_sizes[Font::SIZE_LARGER]));
- screenLargestED->setText(toqstr(rc.font_sizes[Font::SIZE_LARGEST]));
- screenHugeED->setText(toqstr(rc.font_sizes[Font::SIZE_HUGE]));
- screenHugerED->setText(toqstr(rc.font_sizes[Font::SIZE_HUGER]));
-}
-
-void PrefScreenFonts::select_roman(const QString& name)
-{
- screenRomanFE->set(QFont(name), name);
-}
-
-
-void PrefScreenFonts::select_sans(const QString& name)
-{
- screenSansFE->set(QFont(name), name);
-}
-
-
-void PrefScreenFonts::select_typewriter(const QString& name)
-{
- screenTypewriterFE->set(QFont(name), name);
-}
-
-
-/////////////////////////////////////////////////////////////////////
-//
-// PrefColors
-//
-/////////////////////////////////////////////////////////////////////
-
-PrefColors::PrefColors(QPrefs * form, QWidget * parent)
- : PrefModule( _("Colors"), form, parent)
-{
- setupUi(this);
-
- // FIXME: all of this initialization should be put into the controller.
- // See http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg113301.html
- // for some discussion of why that is not trivial.
- QPixmap icon(32, 32);
- for (int i = 0; i < Color::ignore; ++i) {
- Color::color lc = static_cast<Color::color>(i);
- if (lc == Color::none
- || lc == Color::black
- || lc == Color::white
- || lc == Color::red
- || lc == Color::green
- || lc == Color::blue
- || lc == Color::cyan
- || lc == Color::magenta
- || lc == Color::yellow
- || lc == Color::inherit
- || lc == Color::ignore) continue;
-
- lcolors_.push_back(lc);
- }
- lcolors_ = frontend::getSortedColors(lcolors_);
- vector<Color_color>::const_iterator cit = lcolors_.begin();
- vector<Color_color>::const_iterator const end = lcolors_.end();
- for (; cit != end; ++cit)
- {
- // This is not a memory leak:
- /*QListWidgetItem * newItem =*/ new QListWidgetItem(QIcon(icon),
- toqstr(lcolor.getGUIName(*cit)), lyxObjectsLW);
- }
- curcolors_.resize(lcolors_.size());
- newcolors_.resize(lcolors_.size());
- // End initialization
-
- connect(colorChangePB, SIGNAL(clicked()),
- this, SLOT(change_color()));
- connect(lyxObjectsLW, SIGNAL(itemSelectionChanged()),
- this, SLOT(change_lyxObjects_selection()));
- connect(lyxObjectsLW, SIGNAL(itemActivated(QListWidgetItem*)),
- this, SLOT(change_color()));
-}
-
-
-void PrefColors::apply(LyXRC & /*rc*/) const
-{
- for (unsigned int i = 0; i < lcolors_.size(); ++i) {
- if (curcolors_[i] != newcolors_[i]) {
- form_->controller().setColor(lcolors_[i], fromqstr(newcolors_[i]));
- }
- }
-}
-
-
-void PrefColors::update(LyXRC const & /*rc*/)
-{
- for (unsigned int i = 0; i < lcolors_.size(); ++i) {
- QColor color = QColor(guiApp->colorCache().get(lcolors_[i]));
- QPixmap coloritem(32, 32);
- coloritem.fill(color);
- lyxObjectsLW->item(i)->setIcon(QIcon(coloritem));
- newcolors_[i] = curcolors_[i] = color.name();
- }
- change_lyxObjects_selection();
-}
-
-void PrefColors::change_color()
-{
- int const row = lyxObjectsLW->currentRow();
-
- // just to be sure
- if (row < 0) return;
-
- QString const color = newcolors_[row];
- QColor c(QColorDialog::getColor(QColor(color), qApp->focusWidget()));
-
- if (c.isValid() && c.name() != color) {
- newcolors_[row] = c.name();
- QPixmap coloritem(32, 32);
- coloritem.fill(c);
- lyxObjectsLW->currentItem()->setIcon(QIcon(coloritem));
- // emit signal
- changed();
- }
-}
-
-void PrefColors::change_lyxObjects_selection()
-{
- colorChangePB->setDisabled(lyxObjectsLW->currentRow() < 0);
-}
-
-
-/////////////////////////////////////////////////////////////////////
-//
-// PrefCygwinPath
-//
-/////////////////////////////////////////////////////////////////////
-
-PrefCygwinPath::PrefCygwinPath(QWidget * parent)
- : PrefModule(_("Paths"), 0, parent)
-{
- setupUi(this);
- connect(pathCB, SIGNAL(clicked()), this, SIGNAL(changed()));
-}
-
-
-void PrefCygwinPath::apply(LyXRC & rc) const
-{
- rc.windows_style_tex_paths = pathCB->isChecked();
-}
-
-
-void PrefCygwinPath::update(LyXRC const & rc)
-{
- pathCB->setChecked(rc.windows_style_tex_paths);
-}
-
-
-/////////////////////////////////////////////////////////////////////
-//
-// PrefDisplay
-//
-/////////////////////////////////////////////////////////////////////
-
-PrefDisplay::PrefDisplay(QWidget * parent)
- : PrefModule(_("Graphics"), 0, parent)
-{
- setupUi(this);
- connect(instantPreviewCO, SIGNAL(activated(int)),
- this, SIGNAL(changed()));
- connect(displayGraphicsCO, SIGNAL(activated(int)),
- this, SIGNAL(changed()));
-}
-
-
-void PrefDisplay::apply(LyXRC & rc) const
-{
- switch (instantPreviewCO->currentIndex()) {
- case 0: rc.preview = LyXRC::PREVIEW_OFF; break;
- case 1: rc.preview = LyXRC::PREVIEW_NO_MATH; break;
- case 2: rc.preview = LyXRC::PREVIEW_ON; break;
- }
-
- lyx::graphics::DisplayType dtype;
- switch (displayGraphicsCO->currentIndex()) {
- case 3: dtype = lyx::graphics::NoDisplay; break;
- case 2: dtype = lyx::graphics::ColorDisplay; break;
- case 1: dtype = lyx::graphics::GrayscaleDisplay; break;
- case 0: dtype = lyx::graphics::MonochromeDisplay; break;
- default: dtype = lyx::graphics::GrayscaleDisplay;
- }
- rc.display_graphics = dtype;
-
- // FIXME!! The graphics cache no longer has a changeDisplay method.
-#if 0
- if (old_value != rc.display_graphics) {
- lyx::graphics::GCache & gc = lyx::graphics::GCache::get();
- gc.changeDisplay();
- }
-#endif
-}
-
-
-void PrefDisplay::update(LyXRC const & rc)
-{
- switch (rc.preview) {
- case LyXRC::PREVIEW_OFF:
- instantPreviewCO->setCurrentIndex(0);
- break;
- case LyXRC::PREVIEW_NO_MATH :
- instantPreviewCO->setCurrentIndex(1);
- break;
- case LyXRC::PREVIEW_ON :
- instantPreviewCO->setCurrentIndex(2);
- break;
- }
-
- int item = 2;
- switch (rc.display_graphics) {
- case lyx::graphics::NoDisplay: item = 3; break;
- case lyx::graphics::ColorDisplay: item = 2; break;
- case lyx::graphics::GrayscaleDisplay: item = 1; break;
- case lyx::graphics::MonochromeDisplay: item = 0; break;
- default: break;
- }
- displayGraphicsCO->setCurrentIndex(item);
-}
-
-
-/////////////////////////////////////////////////////////////////////
-//
-// PrefPaths
-//
-/////////////////////////////////////////////////////////////////////
-
-PrefPaths::PrefPaths(QPrefs * form, QWidget * parent)
- : PrefModule(_("Paths"), form, parent)
-{
- setupUi(this);
- connect(templateDirPB, SIGNAL(clicked()), this, SLOT(select_templatedir()));
- connect(tempDirPB, SIGNAL(clicked()), this, SLOT(select_tempdir()));
- connect(backupDirPB, SIGNAL(clicked()), this, SLOT(select_backupdir()));
- connect(workingDirPB, SIGNAL(clicked()), this, SLOT(select_workingdir()));
- connect(lyxserverDirPB, SIGNAL(clicked()), this, SLOT(select_lyxpipe()));
- connect(workingDirED, SIGNAL(textChanged(const QString&)),
- this, SIGNAL(changed()));
- connect(templateDirED, SIGNAL(textChanged(const QString&)),
- this, SIGNAL(changed()));
- connect(backupDirED, SIGNAL(textChanged(const QString&)),
- this, SIGNAL(changed()));
- connect(tempDirED, SIGNAL(textChanged(const QString&)),
- this, SIGNAL(changed()));
- connect(lyxserverDirED, SIGNAL(textChanged(const QString&)),
- this, SIGNAL(changed()));
- connect(pathPrefixED, SIGNAL(textChanged(const QString&)),
- this, SIGNAL(changed()));
-}
-
-
-void PrefPaths::apply(LyXRC & rc) const
-{
- rc.document_path = internal_path(fromqstr(workingDirED->text()));
- rc.template_path = internal_path(fromqstr(templateDirED->text()));
- rc.backupdir_path = internal_path(fromqstr(backupDirED->text()));
- rc.tempdir_path = internal_path(fromqstr(tempDirED->text()));
- rc.path_prefix = internal_path_list(fromqstr(pathPrefixED->text()));
- // FIXME: should be a checkbox only
- rc.lyxpipes = internal_path(fromqstr(lyxserverDirED->text()));
-}
-
-
-void PrefPaths::update(LyXRC const & rc)
-{
- workingDirED->setText(toqstr(external_path(rc.document_path)));
- templateDirED->setText(toqstr(external_path(rc.template_path)));
- backupDirED->setText(toqstr(external_path(rc.backupdir_path)));
- tempDirED->setText(toqstr(external_path(rc.tempdir_path)));
- pathPrefixED->setText(toqstr(external_path_list(rc.path_prefix)));
- // FIXME: should be a checkbox only
- lyxserverDirED->setText(toqstr(external_path(rc.lyxpipes)));
-}
-
-
-void PrefPaths::select_templatedir()
-{
- docstring file(form_->controller().browsedir(
- from_utf8(internal_path(fromqstr(templateDirED->text()))),
- _("Select a document templates directory")));
- if (!file.empty())
- templateDirED->setText(toqstr(file));
-}
-
-
-void PrefPaths::select_tempdir()
-{
- docstring file(form_->controller().browsedir(
- from_utf8(internal_path(fromqstr(tempDirED->text()))),
- _("Select a temporary directory")));
- if (!file.empty())
- tempDirED->setText(toqstr(file));
-}
-
-
-void PrefPaths::select_backupdir()
-{
- docstring file(form_->controller().browsedir(
- from_utf8(internal_path(fromqstr(backupDirED->text()))),
- _("Select a backups directory")));
- if (!file.empty())
- backupDirED->setText(toqstr(file));
-}
-
-
-void PrefPaths::select_workingdir()
-{
- docstring file(form_->controller().browsedir(
- from_utf8(internal_path(fromqstr(workingDirED->text()))),
- _("Select a document directory")));
- if (!file.empty())
- workingDirED->setText(toqstr(file));
-}
-
-
-void PrefPaths::select_lyxpipe()
-{
- docstring file(form_->controller().browse(
- from_utf8(internal_path(fromqstr(lyxserverDirED->text()))),
- _("Give a filename for the LyX server pipe")));
- if (!file.empty())
- lyxserverDirED->setText(toqstr(file));
-}
-
-
-/////////////////////////////////////////////////////////////////////
-//
-// PrefSpellchecker
-//
-/////////////////////////////////////////////////////////////////////
-
-PrefSpellchecker::PrefSpellchecker(QPrefs * form, QWidget * parent)
- : PrefModule(_("Spellchecker"), form, parent)
-{
- setupUi(this);
-
- connect(persDictionaryPB, SIGNAL(clicked()), this, SLOT(select_dict()));
-#if defined (USE_ISPELL)
- connect(spellCommandCO, SIGNAL(activated(int)),
- this, SIGNAL(changed()));
-#else
- spellCommandCO->setEnabled(false);
-#endif
- connect(altLanguageED, SIGNAL(textChanged(const QString&)),
- this, SIGNAL(changed()));
- connect(escapeCharactersED, SIGNAL(textChanged(const QString&)),
- this, SIGNAL(changed()));
- connect(persDictionaryED, SIGNAL(textChanged(const QString&)),
- this, SIGNAL(changed()));
- connect(compoundWordCB, SIGNAL(clicked()),
- this, SIGNAL(changed()));
- connect(inputEncodingCB, SIGNAL(clicked()),
- this, SIGNAL(changed()));
-
- spellCommandCO->addItem(qt_("ispell"));
- spellCommandCO->addItem(qt_("aspell"));
- spellCommandCO->addItem(qt_("hspell"));
-#ifdef USE_PSPELL
- spellCommandCO->addItem(qt_("pspell (library)"));
-#else
-#ifdef USE_ASPELL
- spellCommandCO->addItem(qt_("aspell (library)"));
-#endif
-#endif
-}
-
-
-void PrefSpellchecker::apply(LyXRC & rc) const
-{
- switch (spellCommandCO->currentIndex()) {
- case 0:
- case 1:
- case 2:
- rc.use_spell_lib = false;
- rc.isp_command = fromqstr(spellCommandCO->currentText());
- break;
- case 3:
- rc.use_spell_lib = true;
- break;
- }
-
- // FIXME: remove isp_use_alt_lang
- rc.isp_alt_lang = fromqstr(altLanguageED->text());
- rc.isp_use_alt_lang = !rc.isp_alt_lang.empty();
- // FIXME: remove isp_use_esc_chars
- rc.isp_esc_chars = fromqstr(escapeCharactersED->text());
- rc.isp_use_esc_chars = !rc.isp_esc_chars.empty();
- // FIXME: remove isp_use_pers_dict
- rc.isp_pers_dict = internal_path(fromqstr(persDictionaryED->text()));
- rc.isp_use_pers_dict = !rc.isp_pers_dict.empty();
- rc.isp_accept_compound = compoundWordCB->isChecked();
- rc.isp_use_input_encoding = inputEncodingCB->isChecked();
-}
-
-
-void PrefSpellchecker::update(LyXRC const & rc)
-{
- spellCommandCO->setCurrentIndex(0);
-
- if (rc.isp_command == "ispell") {
- spellCommandCO->setCurrentIndex(0);
- } else if (rc.isp_command == "aspell") {
- spellCommandCO->setCurrentIndex(1);
- } else if (rc.isp_command == "hspell") {
- spellCommandCO->setCurrentIndex(2);
- }
-
- if (rc.use_spell_lib) {
-#if defined(USE_ASPELL) || defined(USE_PSPELL)
- spellCommandCO->setCurrentIndex(3);
-#endif
- }
-
- // FIXME: remove isp_use_alt_lang
- altLanguageED->setText(toqstr(rc.isp_alt_lang));
- // FIXME: remove isp_use_esc_chars
- escapeCharactersED->setText(toqstr(rc.isp_esc_chars));
- // FIXME: remove isp_use_pers_dict
- persDictionaryED->setText(toqstr(external_path(rc.isp_pers_dict)));
- compoundWordCB->setChecked(rc.isp_accept_compound);
- inputEncodingCB->setChecked(rc.isp_use_input_encoding);
-}
-
-
-void PrefSpellchecker::select_dict()
-{
- docstring file(form_->controller().browsedict(
- from_utf8(internal_path(fromqstr(persDictionaryED->text())))));
- if (!file.empty())
- persDictionaryED->setText(toqstr(file));
-}
-
-
-
-/////////////////////////////////////////////////////////////////////
-//
-// PrefConverters
-//
-/////////////////////////////////////////////////////////////////////
-
-
-PrefConverters::PrefConverters(QPrefs * form, QWidget * parent)
- : PrefModule(_("Converters"), form, parent)
-{
- setupUi(this);
-
- connect(converterNewPB, SIGNAL(clicked()),
- this, SLOT(update_converter()));
- connect(converterRemovePB, SIGNAL(clicked()),
- this, SLOT(remove_converter()));
- connect(converterModifyPB, SIGNAL(clicked()),
- this, SLOT(update_converter()));
- connect(convertersLW, SIGNAL(currentRowChanged(int)),
- this, SLOT(switch_converter()));
- connect(converterFromCO, SIGNAL(activated(const QString&)),
- this, SLOT(converter_changed()));
- connect(converterToCO, SIGNAL(activated(const QString&)),
- this, SLOT(converter_changed()));
- connect(converterED, SIGNAL(textChanged(const QString&)),
- this, SLOT(converter_changed()));
- connect(converterFlagED, SIGNAL(textChanged(const QString&)),
- this, SLOT(converter_changed()));
- connect(converterNewPB, SIGNAL(clicked()),
- this, SIGNAL(changed()));
- connect(converterRemovePB, SIGNAL(clicked()),
- this, SIGNAL(changed()));
- connect(converterModifyPB, SIGNAL(clicked()),
- this, SIGNAL(changed()));
- connect(maxAgeLE, SIGNAL(textChanged(const QString&)),
- this, SIGNAL(changed()));
-
- maxAgeLE->setValidator(new QDoubleValidator(maxAgeLE));
- converterDefGB->setFocusProxy(convertersLW);
-}
-
-
-void PrefConverters::apply(LyXRC & rc) const
-{
- rc.use_converter_cache = cacheCB->isChecked();
- rc.converter_cache_maxage = int(maxAgeLE->text().toDouble() * 86400.0);
-}
-
-
-void PrefConverters::update(LyXRC const & rc)
-{
- cacheCB->setChecked(rc.use_converter_cache);
- QString max_age;
- max_age.setNum(double(rc.converter_cache_maxage) / 86400.0, 'g', 6);
- maxAgeLE->setText(max_age);
- updateGui();
-}
-
-
-void PrefConverters::updateGui()
-{
- // save current selection
- QString current = converterFromCO->currentText()
- + " -> " + converterToCO->currentText();
-
- converterFromCO->clear();
- converterToCO->clear();
-
- Formats::const_iterator cit = form_->formats().begin();
- Formats::const_iterator end = form_->formats().end();
- for (; cit != end; ++cit) {
- converterFromCO->addItem(toqstr(cit->prettyname()));
- converterToCO->addItem(toqstr(cit->prettyname()));
- }
-
- // currentRowChanged(int) is also triggered when updating the listwidget
- // block signals to avoid unnecessary calls to switch_converter()
- convertersLW->blockSignals(true);
- convertersLW->clear();
-
- Converters::const_iterator ccit = form_->converters().begin();
- Converters::const_iterator cend = form_->converters().end();
- for (; ccit != cend; ++ccit) {
- std::string const name =
- ccit->From->prettyname() + " -> " + ccit->To->prettyname();
- int type = form_->converters().getNumber(ccit->From->name(), ccit->To->name());
- new QListWidgetItem(toqstr(name), convertersLW, type);
- }
- convertersLW->sortItems(Qt::AscendingOrder);
- convertersLW->blockSignals(false);
-
- // restore selection
- if (!current.isEmpty()) {
- QList<QListWidgetItem *> const item =
- convertersLW->findItems(current, Qt::MatchExactly);
- if (item.size()>0)
- convertersLW->setCurrentItem(item.at(0));
- }
-
- // select first element if restoring failed
- if (convertersLW->currentRow() == -1)
- convertersLW->setCurrentRow(0);
-
- updateButtons();
-}
-
-
-void PrefConverters::switch_converter()
-{
- int const cnr = convertersLW->currentItem()->type();
- Converter const & c(form_->converters().get(cnr));
- converterFromCO->setCurrentIndex(form_->formats().getNumber(c.from));
- converterToCO->setCurrentIndex(form_->formats().getNumber(c.to));
- converterED->setText(toqstr(c.command));
- converterFlagED->setText(toqstr(c.flags));
-
- updateButtons();
-}
-
-
-void PrefConverters::converter_changed()
-{
- updateButtons();
-}
-
-
-void PrefConverters::updateButtons()
-{
- Format const & from(form_->formats().get(converterFromCO->currentIndex()));
- Format const & to(form_->formats().get(converterToCO->currentIndex()));
- int const sel = form_->converters().getNumber(from.name(), to.name());
- bool const known = !(sel < 0);
- bool const valid = !(converterED->text().isEmpty()
- || from.name() == to.name());
-
- int const cnr = convertersLW->currentItem()->type();
- Converter const & c(form_->converters().get(cnr));
- string const old_command = c.command;
- string const old_flag = c.flags;
- string const new_command(fromqstr(converterED->text()));
- string const new_flag(fromqstr(converterFlagED->text()));
-
- bool modified = ((old_command != new_command) || (old_flag != new_flag));
-
- converterModifyPB->setEnabled(valid && known && modified);
- converterNewPB->setEnabled(valid && !known);
- converterRemovePB->setEnabled(known);
-
- maxAgeLE->setEnabled(cacheCB->isChecked());
- maxAgeLA->setEnabled(cacheCB->isChecked());
-}
-
-
-// FIXME: user must
-// specify unique from/to or it doesn't appear. This is really bad UI
-// this is why we can use the same function for both new and modify
-void PrefConverters::update_converter()
-{
- Format const & from(form_->formats().get(converterFromCO->currentIndex()));
- Format const & to(form_->formats().get(converterToCO->currentIndex()));
- string const flags = fromqstr(converterFlagED->text());
- string const command = fromqstr(converterED->text());
-
- Converter const * old = form_->converters().getConverter(from.name(), to.name());
- form_->converters().add(from.name(), to.name(), command, flags);
- if (!old) {
- form_->converters().updateLast(form_->formats());
- }
-
- updateGui();
-
- // Remove all files created by this converter from the cache, since
- // the modified converter might create different files.
- ConverterCache::get().remove_all(from.name(), to.name());
-}
-
-
-void PrefConverters::remove_converter()
-{
- Format const & from(form_->formats().get(converterFromCO->currentIndex()));
- Format const & to(form_->formats().get(converterToCO->currentIndex()));
- form_->converters().erase(from.name(), to.name());
-
- updateGui();
-
- // Remove all files created by this converter from the cache, since
- // a possible new converter might create different files.
- ConverterCache::get().remove_all(from.name(), to.name());
-}
-
-
-void PrefConverters::on_cacheCB_stateChanged(int state)
-{
- maxAgeLE->setEnabled(state == Qt::Checked);
- maxAgeLA->setEnabled(state == Qt::Checked);
- changed();
-}
-
-
-/////////////////////////////////////////////////////////////////////
-//
-// PrefCopiers
-//
-/////////////////////////////////////////////////////////////////////
-
-PrefCopiers::PrefCopiers(QPrefs * form, QWidget * parent)
- : PrefModule(_("Copiers"), form, parent)
-{
- setupUi(this);
-
- connect(copierNewPB, SIGNAL(clicked()), this, SLOT(new_copier()));
- connect(copierRemovePB, SIGNAL(clicked()), this, SLOT(remove_copier()));
- connect(copierModifyPB, SIGNAL(clicked()), this, SLOT(modify_copier()));
- connect(AllCopiersLW, SIGNAL(currentRowChanged(int)),
- this, SLOT(switch_copierLB(int)));
- connect(copierFormatCO, SIGNAL(activated(int)),
- this, SLOT(switch_copierCO(int)));
- connect(copierNewPB, SIGNAL(clicked()),
- this, SIGNAL(changed()));
- connect(copierRemovePB, SIGNAL(clicked()),
- this, SIGNAL(changed()));
- connect(copierModifyPB, SIGNAL(clicked()),
- this, SIGNAL(changed()));
- connect(copierFormatCO, SIGNAL(activated(const QString &)),
- this, SLOT(copiers_changed()));
- connect(copierED, SIGNAL(textChanged(const QString &)),
- this, SLOT(copiers_changed()));
-}
-
-
-void PrefCopiers::apply(LyXRC & /*rc*/) const
-{
-}
-
-
-void PrefCopiers::update(LyXRC const & /*rc*/)
-{
- update();
-}
-
-
-void PrefCopiers::update()
-{
- // The choice widget
- // save current selection
- QString current = copierFormatCO->currentText();
- copierFormatCO->clear();
-
- for (Formats::const_iterator it = form_->formats().begin(),
- end = form_->formats().end();
- it != end; ++it) {
- copierFormatCO->addItem(toqstr(it->prettyname()));
- }
-
- // The browser widget
- AllCopiersLW->clear();
-
- for (Movers::const_iterator it = form_->movers().begin(),
- end = form_->movers().end();
- it != end; ++it) {
- std::string const & command = it->second.command();
- if (command.empty())
- continue;
- QString const pretty = toqstr(form_->formats().prettyName(it->first));
- AllCopiersLW->addItem(pretty);
- }
- AllCopiersLW->sortItems(Qt::AscendingOrder);
-
- // restore selection
- if (!current.isEmpty()) {
- QList<QListWidgetItem *> item =
- AllCopiersLW->findItems(current, Qt::MatchExactly);
- if (item.size()>0)
- AllCopiersLW->setCurrentItem(item.at(0));
- }
- // select first element if restoring failed
- if (AllCopiersLW->currentRow() == -1)
- AllCopiersLW->setCurrentRow(0);
-}
-
-
-namespace {
-
-class SamePrettyName {
-public:
- SamePrettyName(string const & n) : pretty_name_(n) {}
-
- bool operator()(Format const & fmt) const {
- return fmt.prettyname() == pretty_name_;
- }
-
-private:
- string const pretty_name_;
-};
-
-
-Format const * getFormat(std::string const & prettyname)
-{
- Formats::const_iterator it = formats.begin();
- Formats::const_iterator const end = formats.end();
- it = std::find_if(it, end, SamePrettyName(prettyname));
- return it == end ? 0 : &*it;
-}
-
-} // namespace anon
-
-
-void PrefCopiers::switch_copierLB(int row)
-{
- if (row < 0)
- return;
-
- // FIXME UNICODE?
- std::string const browser_text =
- fromqstr(AllCopiersLW->currentItem()->text());
- Format const * fmt = getFormat(browser_text);
- if (fmt == 0)
- return;
-
- QString const gui_name = toqstr(fmt->prettyname());
- QString const command = toqstr(form_->movers().command(fmt->name()));
-
- copierED->clear();
- int const combo_size = copierFormatCO->count();
- for (int i = 0; i < combo_size; ++i) {
- QString const text = copierFormatCO->itemText(i);
- if (text == gui_name) {
- copierFormatCO->setCurrentIndex(i);
- copierED->setText(command);
- break;
- }
- }
- updateButtons();
-}
-
-
-void PrefCopiers::switch_copierCO(int row)
-{
- if (row<0)
- return;
-
- std::string const combo_text =
- fromqstr(copierFormatCO->currentText());
- Format const * fmt = getFormat(combo_text);
- if (fmt == 0)
- return;
-
- QString const command = toqstr(form_->movers().command(fmt->name()));
- copierED->setText(command);
-
- QListWidgetItem * const index = AllCopiersLW->currentItem();
- if (index >= 0)
- AllCopiersLW->setItemSelected(index, false);
-
- QString const gui_name = toqstr(fmt->prettyname());
- int const browser_size = AllCopiersLW->count();
- for (int i = 0; i < browser_size; ++i) {
- QString const text = AllCopiersLW->item(i)->text();
- if (text == gui_name) {
- QListWidgetItem * item = AllCopiersLW->item(i);
- AllCopiersLW->setItemSelected(item, true);
- break;
- }
- }
-}
-
-
-void PrefCopiers::copiers_changed()
-{
- updateButtons();
-}
-
-
-void PrefCopiers::updateButtons()
-{
- QString selected = copierFormatCO->currentText();
-
- bool known = false;
- for (int i = 0; i < AllCopiersLW->count(); ++i) {
- if (AllCopiersLW->item(i)->text() == selected)
- known = true;
- }
-
- bool const valid = !copierED->text().isEmpty();
-
- Format const * fmt = getFormat(fromqstr(selected));
- string const old_command = form_->movers().command(fmt->name());
- string const new_command(fromqstr(copierED->text()));
-
- bool modified = (old_command != new_command);
-
- copierModifyPB->setEnabled(valid && known && modified);
- copierNewPB->setEnabled(valid && !known);
- copierRemovePB->setEnabled(known);
-}
-
-
-void PrefCopiers::new_copier()
-{
- std::string const combo_text =
- fromqstr(copierFormatCO->currentText());
- Format const * fmt = getFormat(combo_text);
- if (fmt == 0)
- return;
-
- string const command = fromqstr(copierED->text());
- if (command.empty())
- return;
-
- form_->movers().set(fmt->name(), command);
-
- update();
- int const last = AllCopiersLW->count() - 1;
- AllCopiersLW->setCurrentRow(last);
-
- updateButtons();
-}
-
-
-void PrefCopiers::modify_copier()
-{
- std::string const combo_text =
- fromqstr(copierFormatCO->currentText());
- Format const * fmt = getFormat(combo_text);
- if (fmt == 0)
- return;
-
- string const command = fromqstr(copierED->text());
- form_->movers().set(fmt->name(), command);
-
- update();
- updateButtons();
-}
-
-
-void PrefCopiers::remove_copier()
-{
- std::string const combo_text =
- fromqstr(copierFormatCO->currentText());
- Format const * fmt = getFormat(combo_text);
- if (fmt == 0)
- return;
-
- string const & fmt_name = fmt->name();
- form_->movers().set(fmt_name, string());
-
- update();
- updateButtons();
-}
-
-
-
-/////////////////////////////////////////////////////////////////////
-//
-// PrefFileformats
-//
-/////////////////////////////////////////////////////////////////////
-
-PrefFileformats::PrefFileformats(QPrefs * form, QWidget * parent)
- : PrefModule(_("File formats"), form, parent)
-{
- setupUi(this);
-
- connect(formatNewPB, SIGNAL(clicked()),
- this, SLOT(new_format()));
- connect(formatRemovePB, SIGNAL(clicked()),
- this, SLOT(remove_format()));
- connect(formatModifyPB, SIGNAL(clicked()),
- this, SLOT(modify_format()));
- connect(formatsLW, SIGNAL(currentRowChanged(int)),
- this, SLOT(switch_format(int)));
- connect(formatED, SIGNAL(textChanged(const QString&)),
- this, SLOT(fileformat_changed()));
- connect(guiNameED, SIGNAL(textChanged(const QString&)),
- this, SLOT(fileformat_changed()));
- connect(shortcutED, SIGNAL(textChanged(const QString&)),
- this, SLOT(fileformat_changed()));
- connect(extensionED, SIGNAL(textChanged(const QString&)),
- this, SLOT(fileformat_changed()));
- connect(viewerED, SIGNAL(textChanged(const QString&)),
- this, SLOT(fileformat_changed()));
- connect(editorED, SIGNAL(textChanged(const QString&)),
- this, SLOT(fileformat_changed()));
- connect(documentCB, SIGNAL(clicked()),
- this, SLOT(fileformat_changed()));
- connect(vectorCB, SIGNAL(clicked()),
- this, SLOT(fileformat_changed()));
- connect(formatNewPB, SIGNAL(clicked()),
- this, SIGNAL(changed()));
- connect(formatRemovePB, SIGNAL(clicked()),
- this, SIGNAL(changed()));
- connect(formatModifyPB, SIGNAL(clicked()),
- this, SIGNAL(changed()));
-}
-
-
-void PrefFileformats::apply(LyXRC & /*rc*/) const
-{
-}
-
-
-void PrefFileformats::update(LyXRC const & /*rc*/)
-{
- update();
-}
-
-
-void PrefFileformats::update()
-{
- // save current selection
- QString current = guiNameED->text();
-
- // update listwidget with formats
- formatsLW->blockSignals(true);
- formatsLW->clear();
- Formats::const_iterator cit = form_->formats().begin();
- Formats::const_iterator end = form_->formats().end();
- for (; cit != end; ++cit) {
- new QListWidgetItem(toqstr(cit->prettyname()),
- formatsLW,
- form_->formats().getNumber(cit->name()) );
- }
- formatsLW->sortItems(Qt::AscendingOrder);
- formatsLW->blockSignals(false);
-
- // restore selection
- if (!current.isEmpty()) {
- QList<QListWidgetItem *> item = formatsLW->findItems(current, Qt::MatchExactly);
- if (item.size()>0)
- formatsLW->setCurrentItem(item.at(0));
- }
- // select first element if restoring failed
- if (formatsLW->currentRow() == -1)
- formatsLW->setCurrentRow(0);
-}
-
-
-void PrefFileformats::switch_format(int nr)
-{
- int const ftype = formatsLW->item(nr)->type();
- Format const f = form_->formats().get(ftype);
-
- formatED->setText(toqstr(f.name()));
- guiNameED->setText(toqstr(f.prettyname()));
- extensionED->setText(toqstr(f.extension()));
- shortcutED->setText(toqstr(f.shortcut()));
- viewerED->setText(toqstr(f.viewer()));
- editorED->setText(toqstr(f.editor()));
- documentCB->setChecked((f.documentFormat()));
- vectorCB->setChecked((f.vectorFormat()));
-
- updateButtons();
-}
-
-
-void PrefFileformats::fileformat_changed()
-{
- updateButtons();
-}
-
-
-void PrefFileformats::updateButtons()
-{
- QString const format = formatED->text();
- QString const gui_name = guiNameED->text();
- int const sel = form_->formats().getNumber(fromqstr(format));
- bool gui_name_known = false;
- int where = sel;
- for (int i = 0; i < formatsLW->count(); ++i) {
- if (formatsLW->item(i)->text() == gui_name) {
- gui_name_known = true;
- where = formatsLW->item(i)->type();
- }
- }
-
- // assure that a gui name cannot be chosen twice
- bool const known_otherwise = gui_name_known && (where != sel);
-
- bool const known = !(sel < 0);
- bool const valid = (!formatED->text().isEmpty()
- && !guiNameED->text().isEmpty());
-
- int const ftype = formatsLW->currentItem()->type();
- Format const & f(form_->formats().get(ftype));
- string const old_pretty(f.prettyname());
- string const old_shortcut(f.shortcut());
- string const old_extension(f.extension());
- string const old_viewer(f.viewer());
- string const old_editor(f.editor());
- bool const old_document(f.documentFormat());
- bool const old_vector(f.vectorFormat());
-
- string const new_pretty(fromqstr(gui_name));
- string const new_shortcut(fromqstr(shortcutED->text()));
- string const new_extension(fromqstr(extensionED->text()));
- string const new_viewer(fromqstr(viewerED->text()));
- string const new_editor(fromqstr(editorED->text()));
- bool const new_document(documentCB->isChecked());
- bool const new_vector(vectorCB->isChecked());
-
- bool modified = ((old_pretty != new_pretty) || (old_shortcut != new_shortcut)
- || (old_extension != new_extension) || (old_viewer != new_viewer)
- || old_editor != new_editor || old_document != new_document
- || old_vector != new_vector);
-
- formatModifyPB->setEnabled(valid && known && modified && !known_otherwise);
- formatNewPB->setEnabled(valid && !known && !gui_name_known);
- formatRemovePB->setEnabled(known);
-}
-
-
-void PrefFileformats::new_format()
-{
- string const name = fromqstr(formatED->text());
- string const prettyname = fromqstr(guiNameED->text());
- string const extension = fromqstr(extensionED->text());
- string const shortcut = fromqstr(shortcutED->text());
- string const viewer = fromqstr(viewerED->text());
- string const editor = fromqstr(editorED->text());
- int flags = Format::none;
- if (documentCB->isChecked())
- flags |= Format::document;
- if (vectorCB->isChecked())
- flags |= Format::vector;
-
- form_->formats().add(name, extension, prettyname, shortcut, viewer,
- editor, flags);
- form_->formats().sort();
- form_->converters().update(form_->formats());
-
- update();
- updateButtons();
- formatsChanged();
-}
-
-
-void PrefFileformats::modify_format()
-{
- int const current_item = formatsLW->currentItem()->type();
- Format const & oldformat = form_->formats().get(current_item);
- form_->formats().erase(oldformat.name());
-
- new_format();
-}
-
-
-void PrefFileformats::remove_format()
-{
- int const nr = formatsLW->currentItem()->type();
- string const current_text = form_->formats().get(nr).name();
- if (form_->converters().formatIsUsed(current_text)) {
- Alert::error(_("Format in use"),
- _("Cannot remove a Format used by a Converter. "
- "Remove the converter first."));
- return;
- }
-
- form_->formats().erase(current_text);
- form_->converters().update(form_->formats());
-
- update();
- updateButtons();
- formatsChanged();
-}
-
-
-/////////////////////////////////////////////////////////////////////
-//
-// PrefLanguage
-//
-/////////////////////////////////////////////////////////////////////
-
-PrefLanguage::PrefLanguage(QWidget * parent)
- : PrefModule(_("Language"), 0, parent)
-{
- setupUi(this);
-
- connect(rtlCB, SIGNAL(clicked()),
- this, SIGNAL(changed()));
- connect(markForeignCB, SIGNAL(clicked()),
- this, SIGNAL(changed()));
- connect(autoBeginCB, SIGNAL(clicked()),
- this, SIGNAL(changed()));
- connect(autoEndCB, SIGNAL(clicked()),
- this, SIGNAL(changed()));
- connect(useBabelCB, SIGNAL(clicked()),
- this, SIGNAL(changed()));
- connect(globalCB, SIGNAL(clicked()),
- this, SIGNAL(changed()));
- connect(languagePackageED, SIGNAL(textChanged(const QString&)),
- this, SIGNAL(changed()));
- connect(startCommandED, SIGNAL(textChanged(const QString&)),
- this, SIGNAL(changed()));
- connect(endCommandED, SIGNAL(textChanged(const QString&)),
- this, SIGNAL(changed()));
- connect(defaultLanguageCO, SIGNAL(activated(int)),
- this, SIGNAL(changed()));
-
- defaultLanguageCO->clear();
-
- // store the lang identifiers for later
- std::vector<LanguagePair> const langs = frontend::getLanguageData(false);
- lang_ = getSecond(langs);
-
- std::vector<LanguagePair>::const_iterator lit = langs.begin();
- std::vector<LanguagePair>::const_iterator lend = langs.end();
- for (; lit != lend; ++lit) {
- defaultLanguageCO->addItem(toqstr(lit->first));
- }
-}
-
-
-void PrefLanguage::apply(LyXRC & rc) const
-{
- // FIXME: remove rtl_support bool
- rc.rtl_support = rtlCB->isChecked();
- rc.mark_foreign_language = markForeignCB->isChecked();
- rc.language_auto_begin = autoBeginCB->isChecked();
- rc.language_auto_end = autoEndCB->isChecked();
- rc.language_use_babel = useBabelCB->isChecked();
- rc.language_global_options = globalCB->isChecked();
- rc.language_package = fromqstr(languagePackageED->text());
- rc.language_command_begin = fromqstr(startCommandED->text());
- rc.language_command_end = fromqstr(endCommandED->text());
- rc.default_language = lang_[defaultLanguageCO->currentIndex()];
-}
-
-
-void PrefLanguage::update(LyXRC const & rc)
-{
- // FIXME: remove rtl_support bool
- rtlCB->setChecked(rc.rtl_support);
- markForeignCB->setChecked(rc.mark_foreign_language);
- autoBeginCB->setChecked(rc.language_auto_begin);
- autoEndCB->setChecked(rc.language_auto_end);
- useBabelCB->setChecked(rc.language_use_babel);
- globalCB->setChecked(rc.language_global_options);
- languagePackageED->setText(toqstr(rc.language_package));
- startCommandED->setText(toqstr(rc.language_command_begin));
- endCommandED->setText(toqstr(rc.language_command_end));
-
- int const pos = int(findPos_helper(lang_, rc.default_language));
- defaultLanguageCO->setCurrentIndex(pos);
-}
-
-
-/////////////////////////////////////////////////////////////////////
-//
-// PrefPrinter
-//
-/////////////////////////////////////////////////////////////////////
-
-PrefPrinter::PrefPrinter(QWidget * parent)
- : PrefModule(_("Printer"), 0, parent)
-{
- setupUi(this);
-
- connect(printerAdaptCB, SIGNAL(clicked()),
- this, SIGNAL(changed()));
- connect(printerCommandED, SIGNAL(textChanged(const QString&)),
- this, SIGNAL(changed()));
- connect(printerNameED, SIGNAL(textChanged(const QString&)),
- this, SIGNAL(changed()));
- connect(printerPageRangeED, SIGNAL(textChanged(const QString&)),
- this, SIGNAL(changed()));
- connect(printerCopiesED, SIGNAL(textChanged(const QString&)),
- this, SIGNAL(changed()));
- connect(printerReverseED, SIGNAL(textChanged(const QString&)),
- this, SIGNAL(changed()));
- connect(printerToPrinterED, SIGNAL(textChanged(const QString&)),
- this, SIGNAL(changed()));
- connect(printerExtensionED, SIGNAL(textChanged(const QString&)),
- this, SIGNAL(changed()));
- connect(printerSpoolCommandED, SIGNAL(textChanged(const QString&)),
- this, SIGNAL(changed()));
- connect(printerPaperTypeED, SIGNAL(textChanged(const QString&)),
- this, SIGNAL(changed()));
- connect(printerEvenED, SIGNAL(textChanged(const QString&)),
- this, SIGNAL(changed()));
- connect(printerOddED, SIGNAL(textChanged(const QString&)),
- this, SIGNAL(changed()));
- connect(printerCollatedED, SIGNAL(textChanged(const QString&)),
- this, SIGNAL(changed()));
- connect(printerLandscapeED, SIGNAL(textChanged(const QString&)),
- this, SIGNAL(changed()));
- connect(printerToFileED, SIGNAL(textChanged(const QString&)),
- this, SIGNAL(changed()));
- connect(printerExtraED, SIGNAL(textChanged(const QString&)),
- this, SIGNAL(changed()));
- connect(printerSpoolPrefixED, SIGNAL(textChanged(const QString&)),
- this, SIGNAL(changed()));
- connect(printerPaperSizeED, SIGNAL(textChanged(const QString&)),
- this, SIGNAL(changed()));
-}
-
-
-void PrefPrinter::apply(LyXRC & rc) const
-{
- rc.print_adapt_output = printerAdaptCB->isChecked();
- rc.print_command = fromqstr(printerCommandED->text());
- rc.printer = fromqstr(printerNameED->text());
-
- rc.print_pagerange_flag = fromqstr(printerPageRangeED->text());
- rc.print_copies_flag = fromqstr(printerCopiesED->text());
- rc.print_reverse_flag = fromqstr(printerReverseED->text());
- rc.print_to_printer = fromqstr(printerToPrinterED->text());
- rc.print_file_extension = fromqstr(printerExtensionED->text());
- rc.print_spool_command = fromqstr(printerSpoolCommandED->text());
- rc.print_paper_flag = fromqstr(printerPaperTypeED->text());
- rc.print_evenpage_flag = fromqstr(printerEvenED->text());
- rc.print_oddpage_flag = fromqstr(printerOddED->text());
- rc.print_collcopies_flag = fromqstr(printerCollatedED->text());
- rc.print_landscape_flag = fromqstr(printerLandscapeED->text());
- rc.print_to_file = internal_path(fromqstr(printerToFileED->text()));
- rc.print_extra_options = fromqstr(printerExtraED->text());
- rc.print_spool_printerprefix = fromqstr(printerSpoolPrefixED->text());
- rc.print_paper_dimension_flag = fromqstr(printerPaperSizeED->text());
-}
-
-
-void PrefPrinter::update(LyXRC const & rc)
-{
- printerAdaptCB->setChecked(rc.print_adapt_output);
- printerCommandED->setText(toqstr(rc.print_command));
- printerNameED->setText(toqstr(rc.printer));
-
- printerPageRangeED->setText(toqstr(rc.print_pagerange_flag));
- printerCopiesED->setText(toqstr(rc.print_copies_flag));
- printerReverseED->setText(toqstr(rc.print_reverse_flag));
- printerToPrinterED->setText(toqstr(rc.print_to_printer));
- printerExtensionED->setText(toqstr(rc.print_file_extension));
- printerSpoolCommandED->setText(toqstr(rc.print_spool_command));
- printerPaperTypeED->setText(toqstr(rc.print_paper_flag));
- printerEvenED->setText(toqstr(rc.print_evenpage_flag));
- printerOddED->setText(toqstr(rc.print_oddpage_flag));
- printerCollatedED->setText(toqstr(rc.print_collcopies_flag));
- printerLandscapeED->setText(toqstr(rc.print_landscape_flag));
- printerToFileED->setText(toqstr(external_path(rc.print_to_file)));
- printerExtraED->setText(toqstr(rc.print_extra_options));
- printerSpoolPrefixED->setText(toqstr(rc.print_spool_printerprefix));
- printerPaperSizeED->setText(toqstr(rc.print_paper_dimension_flag));
-}
-
-
-/////////////////////////////////////////////////////////////////////
-//
-// PrefUserInterface
-//
-/////////////////////////////////////////////////////////////////////
-
-PrefUserInterface::PrefUserInterface(QPrefs * form, QWidget * parent)
- : PrefModule(_("User interface"), form, parent)
-{
- setupUi(this);
-
- connect(autoSaveCB, SIGNAL(toggled(bool)),
- autoSaveLA, SLOT(setEnabled(bool)));
- connect(autoSaveCB, SIGNAL(toggled(bool)),
- autoSaveSB, SLOT(setEnabled(bool)));
- connect(autoSaveCB, SIGNAL(toggled(bool)),
- TextLabel1, SLOT(setEnabled(bool)));
- connect(uiFilePB, SIGNAL(clicked()),
- this, SLOT(select_ui()));
- connect(bindFilePB, SIGNAL(clicked()),
- this, SLOT(select_bind()));
- connect(uiFileED, SIGNAL(textChanged(const QString &)),
- this, SIGNAL(changed()));
- connect(bindFileED, SIGNAL(textChanged(const QString &)),
- this, SIGNAL(changed()));
- connect(restoreCursorCB, SIGNAL(clicked()),
- this, SIGNAL(changed()));
- connect(loadSessionCB, SIGNAL(clicked()),
- this, SIGNAL(changed()));
- connect(loadWindowSizeCB, SIGNAL(clicked()),
- this, SIGNAL(changed()));
- connect(loadWindowLocationCB, SIGNAL(clicked()),
- this, SIGNAL(changed()));
- connect(windowWidthSB, SIGNAL(valueChanged(int)),
- this, SIGNAL(changed()));
- connect(windowHeightSB, SIGNAL(valueChanged(int)),
- this, SIGNAL(changed()));
- connect(cursorFollowsCB, SIGNAL(clicked()),
- this, SIGNAL(changed()));
- connect(autoSaveSB, SIGNAL(valueChanged(int)),
- this, SIGNAL(changed()));
- connect(autoSaveCB, SIGNAL(clicked()),
- this, SIGNAL(changed()));
- connect(lastfilesSB, SIGNAL(valueChanged(int)),
- this, SIGNAL(changed()));
- lastfilesSB->setMaximum(maxlastfiles);
-}
-
-
-void PrefUserInterface::apply(LyXRC & rc) const
-{
- rc.ui_file = internal_path(fromqstr(uiFileED->text()));
- rc.bind_file = internal_path(fromqstr(bindFileED->text()));
- rc.use_lastfilepos = restoreCursorCB->isChecked();
- rc.load_session = loadSessionCB->isChecked();
- if (loadWindowSizeCB->isChecked()) {
- rc.geometry_width = 0;
- rc.geometry_height = 0;
- } else {
- rc.geometry_width = windowWidthSB->value();
- rc.geometry_height = windowHeightSB->value();
- }
- rc.geometry_xysaved = loadWindowLocationCB->isChecked();
- rc.cursor_follows_scrollbar = cursorFollowsCB->isChecked();
- rc.autosave = autoSaveSB->value() * 60;
- rc.make_backup = autoSaveCB->isChecked();
- rc.num_lastfiles = lastfilesSB->value();
-}
-
-
-void PrefUserInterface::update(LyXRC const & rc)
-{
- uiFileED->setText(toqstr(external_path(rc.ui_file)));
- bindFileED->setText(toqstr(external_path(rc.bind_file)));
- restoreCursorCB->setChecked(rc.use_lastfilepos);
- loadSessionCB->setChecked(rc.load_session);
- bool loadWindowSize = rc.geometry_width == 0 && rc.geometry_height == 0;
- loadWindowSizeCB->setChecked(loadWindowSize);
- if (!loadWindowSize) {
- windowWidthSB->setValue(rc.geometry_width);
- windowHeightSB->setValue(rc.geometry_height);
- }
- loadWindowLocationCB->setChecked(rc.geometry_xysaved);
- cursorFollowsCB->setChecked(rc.cursor_follows_scrollbar);
- // convert to minutes
- int mins(rc.autosave / 60);
- if (rc.autosave && !mins)
- mins = 1;
- autoSaveSB->setValue(mins);
- autoSaveCB->setChecked(rc.make_backup);
- lastfilesSB->setValue(rc.num_lastfiles);
-}
-
-
-
-void PrefUserInterface::select_ui()
-{
- docstring const name =
- from_utf8(internal_path(fromqstr(uiFileED->text())));
- docstring file(form_->controller().browseUI(name));
- if (!file.empty())
- uiFileED->setText(toqstr(file));
-}
-
-
-void PrefUserInterface::select_bind()
-{
- docstring const name =
- from_utf8(internal_path(fromqstr(bindFileED->text())));
- docstring file(form_->controller().browsebind(name));
- if (!file.empty())
- bindFileED->setText(toqstr(file));
-}
-
-
-void PrefUserInterface::on_loadWindowSizeCB_toggled(bool loadwindowsize)
-{
- windowWidthLA->setDisabled(loadwindowsize);
- windowHeightLA->setDisabled(loadwindowsize);
- windowWidthSB->setDisabled(loadwindowsize);
- windowHeightSB->setDisabled(loadwindowsize);
-}
-
-
-PrefIdentity::PrefIdentity(QWidget * parent)
-: PrefModule(_("Identity"), 0, parent)
-{
- setupUi(this);
-
- connect(nameED, SIGNAL(textChanged(const QString&)),
- this, SIGNAL(changed()));
- connect(emailED, SIGNAL(textChanged(const QString&)),
- this, SIGNAL(changed()));
-}
-
-
-void PrefIdentity::apply(LyXRC & rc) const
-{
- rc.user_name = fromqstr(nameED->text());
- rc.user_email = fromqstr(emailED->text());
-}
-
-
-void PrefIdentity::update(LyXRC const & rc)
-{
- nameED->setText(toqstr(rc.user_name));
- emailED->setText(toqstr(rc.user_email));
-}
-
-
-
-/////////////////////////////////////////////////////////////////////
-//
-// QPrefsDialog
-//
-/////////////////////////////////////////////////////////////////////
-
-QPrefsDialog::QPrefsDialog(QPrefs * form)
- : form_(form)
-{
- setupUi(this);
- QDialog::setModal(false);
-
- connect(savePB, SIGNAL(clicked()), form, SLOT(slotOK()));
- connect(applyPB, SIGNAL(clicked()), form, SLOT(slotApply()));
- connect(closePB, SIGNAL(clicked()), form, SLOT(slotClose()));
- connect(restorePB, SIGNAL(clicked()), form, SLOT(slotRestore()));
-
- add(new PrefUserInterface(form_));
- add(new PrefScreenFonts(form_));
- add(new PrefColors(form_));
- add(new PrefDisplay);
- add(new PrefKeyboard(form_));
-
- add(new PrefPaths(form_));
-
- add(new PrefIdentity);
-
- add(new PrefLanguage);
- add(new PrefSpellchecker(form_));
-
- add(new PrefPrinter);
- add(new PrefDate);
- add(new PrefPlaintext);
- add(new PrefLatex(form_));
-
-#if defined(__CYGWIN__) || defined(_WIN32)
- add(new PrefCygwinPath);
-#endif
-
-
- PrefConverters * converters = new PrefConverters(form_);
- PrefFileformats * formats = new PrefFileformats(form_);
- connect(formats, SIGNAL(formatsChanged()),
- converters, SLOT(updateGui()));
- add(converters);
- add(formats);
-
- add(new PrefCopiers(form_));
-
-
- prefsPS->setCurrentPanel(_("User interface"));
-// FIXME: hack to work around resizing bug in Qt >= 4.2
-// bug verified with Qt 4.2.{0-3} (JSpitzm)
-#if QT_VERSION >= 0x040200
- prefsPS->updateGeometry();
-#endif
-
- form_->bcview().setOK(savePB);
- form_->bcview().setApply(applyPB);
- form_->bcview().setCancel(closePB);
- form_->bcview().setRestore(restorePB);
-}
-
-
-void QPrefsDialog::add(PrefModule * module)
-{
- BOOST_ASSERT(module);
-
- prefsPS->addPanel(module, module->title());
-
- connect(module, SIGNAL(changed()), this, SLOT(change_adaptor()));
-
- modules_.push_back(module);
-}
-
-void QPrefsDialog::closeEvent(QCloseEvent * e)
-{
- form_->slotWMHide();
- e->accept();
-}
-
-
-void QPrefsDialog::change_adaptor()
-{
- form_->changed();
-}
-
-
-void QPrefsDialog::apply(LyXRC & rc) const
-{
- size_t end = modules_.size();
- for (size_t i = 0; i != end; ++i)
- modules_[i]->apply(rc);
-}
-
-
-void QPrefsDialog::updateRc(LyXRC const & rc)
-{
- size_t const end = modules_.size();
- for (size_t i = 0; i != end; ++i)
- modules_[i]->update(rc);
-}
-
-
-/////////////////////////////////////////////////////////////////////
-//
-// QPrefs
-//
-/////////////////////////////////////////////////////////////////////
-
-typedef QController<ControlPrefs, QView<QPrefsDialog> > PrefsBase;
-
-QPrefs::QPrefs(Dialog & parent)
- : PrefsBase(parent, _("Preferences"))
-{
-}
-
-Converters & QPrefs::converters()
-{
- return controller().converters();
-}
-
-Formats & QPrefs::formats()
-{
- return controller().formats();
-}
-
-Movers & QPrefs::movers()
-{
- return controller().movers();
-}
-
-void QPrefs::build_dialog()
-{
- dialog_.reset(new QPrefsDialog(this));
-}
-
-void QPrefs::apply()
-{
- dialog_->apply(controller().rc());
-}
-
-void QPrefs::update_contents()
-{
- dialog_->updateRc(controller().rc());
-}
-
-} // namespace frontend
-} // namespace lyx
-
-#include "QPrefs_moc.cpp"
+++ /dev/null
-// -*- C++ -*-
-/**
- * \file QPrefs.h
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author John Levon
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#ifndef QPREFS_H
-#define QPREFS_H
-
-#include "QDialogView.h"
-
-#include "Color.h"
-#include "LyXRC.h"
-
-#include "ui_PrefsUi.h"
-
-#include <vector>
-
-#include <QDialog>
-#include <QCloseEvent>
-
-#include "ui_PrefPlaintextUi.h"
-#include "ui_PrefDateUi.h"
-#include "ui_PrefKeyboardUi.h"
-#include "ui_PrefLatexUi.h"
-#include "ui_PrefScreenFontsUi.h"
-#include "ui_PrefColorsUi.h"
-#include "ui_PrefCygwinPathUi.h"
-#include "ui_PrefDisplayUi.h"
-#include "ui_PrefPathsUi.h"
-#include "ui_PrefSpellcheckerUi.h"
-#include "ui_PrefConvertersUi.h"
-#include "ui_PrefCopiersUi.h"
-#include "ui_PrefFileformatsUi.h"
-#include "ui_PrefLanguageUi.h"
-#include "ui_PrefPrinterUi.h"
-#include "ui_PrefUi.h"
-#include "ui_PrefIdentityUi.h"
-
-namespace lyx {
-
-class Converters;
-class Formats;
-class Movers;
-
-namespace frontend {
-
-class QPrefs;
-
-class PrefModule : public QWidget
-{
- Q_OBJECT
-public:
- PrefModule(docstring const & t,
- QPrefs * form = 0, QWidget * parent = 0)
- : QWidget(parent), title_(t), form_(form)
- {}
-
- virtual void apply(LyXRC & rc) const = 0;
- virtual void update(LyXRC const & rc) = 0;
-
- docstring const & title() const { return title_; }
-
-protected:
- docstring title_;
- QPrefs * form_;
-
-Q_SIGNALS:
- void changed();
-};
-
-
-class PrefPlaintext : public PrefModule, public Ui::QPrefPlaintextUi
-{
- Q_OBJECT
-public:
- PrefPlaintext(QWidget * parent = 0);
-
- virtual void apply(LyXRC & rc) const;
- virtual void update(LyXRC const & rc);
-};
-
-
-class PrefDate : public PrefModule, public Ui::QPrefDateUi
-{
- Q_OBJECT
-public:
- PrefDate(QWidget * parent = 0);
-
- virtual void apply(LyXRC & rc) const;
- virtual void update(LyXRC const & rc);
-};
-
-
-class PrefKeyboard : public PrefModule, public Ui::QPrefKeyboardUi
-{
- Q_OBJECT
-public:
- PrefKeyboard(QPrefs * form, QWidget * parent = 0);
-
- virtual void apply(LyXRC & rc) const;
- virtual void update(LyXRC const & rc);
-
-private Q_SLOTS:
- void on_firstKeymapPB_clicked(bool);
- void on_secondKeymapPB_clicked(bool);
- void on_keymapCB_toggled(bool);
-
-private:
- QString testKeymap(QString keymap);
-};
-
-
-class PrefLatex : public PrefModule, public Ui::QPrefLatexUi
-{
- Q_OBJECT
-public:
- PrefLatex(QPrefs * form, QWidget * parent = 0);
-
- virtual void apply(LyXRC & rc) const;
- virtual void update(LyXRC const & rc);
-};
-
-
-class PrefScreenFonts : public PrefModule, public Ui::QPrefScreenFontsUi
-{
- Q_OBJECT
-public:
- PrefScreenFonts(QPrefs * form, QWidget * parent = 0);
-
- virtual void apply(LyXRC & rc) const;
- virtual void update(LyXRC const & rc);
-
-private Q_SLOTS:
- void select_roman(const QString&);
- void select_sans(const QString&);
- void select_typewriter(const QString&);
-};
-
-
-class PrefColors : public PrefModule, public Ui::QPrefColorsUi
-{
- Q_OBJECT
-public:
- PrefColors(QPrefs * form, QWidget * parent = 0);
-
- void apply(LyXRC & rc) const;
- void update(LyXRC const & rc);
-
-private Q_SLOTS:
- void change_color();
- void change_lyxObjects_selection();
-
-private:
- std::vector<Color_color> lcolors_;
- // FIXME the use of mutable here is required due to the
- // fact that initialization is not done in the controller
- // but in the constructor.
- std::vector<QString> curcolors_;
- std::vector<QString> newcolors_;
-
-};
-
-
-class PrefCygwinPath : public PrefModule, public Ui::QPrefCygwinPathUi
-{
- Q_OBJECT
-public:
- PrefCygwinPath(QWidget * parent = 0);
-
- void apply(LyXRC & rc) const;
- void update(LyXRC const & rc);
-};
-
-
-class PrefDisplay : public PrefModule, public Ui::QPrefDisplayUi
-{
- Q_OBJECT
-public:
- PrefDisplay(QWidget * parent = 0);
-
- void apply(LyXRC & rc) const;
- void update(LyXRC const & rc);
-};
-
-
-class PrefPaths : public PrefModule, public Ui::QPrefPathsUi
-{
- Q_OBJECT
-public:
- PrefPaths(QPrefs * form, QWidget * parent = 0);
-
- void apply(LyXRC & rc) const;
- void update(LyXRC const & rc);
-
-private Q_SLOTS:
- void select_templatedir();
- void select_tempdir();
- void select_backupdir();
- void select_workingdir();
- void select_lyxpipe();
-
-};
-
-
-class PrefSpellchecker : public PrefModule, public Ui::QPrefSpellcheckerUi
-{
- Q_OBJECT
-public:
- PrefSpellchecker(QPrefs * form, QWidget * parent = 0);
-
- void apply(LyXRC & rc) const;
- void update(LyXRC const & rc);
-
-private Q_SLOTS:
- void select_dict();
-};
-
-
-class PrefConverters : public PrefModule, public Ui::QPrefConvertersUi
-{
- Q_OBJECT
-public:
- PrefConverters(QPrefs * form, QWidget * parent = 0);
-
- void apply(LyXRC & rc) const;
- void update(LyXRC const & rc);
-
-public Q_SLOTS:
- void updateGui();
-
-private Q_SLOTS:
- void update_converter();
- void switch_converter();
- void converter_changed();
- void remove_converter();
- void on_cacheCB_stateChanged(int state);
-
-private:
- void updateButtons();
-};
-
-
-class PrefCopiers : public PrefModule, public Ui::QPrefCopiersUi
-{
- Q_OBJECT
-public:
- PrefCopiers(QPrefs * form, QWidget * parent = 0);
-
- void apply(LyXRC & rc) const;
- void update(LyXRC const & rc);
-
- void update();
-
-private Q_SLOTS:
- void switch_copierLB(int nr);
- void switch_copierCO(int nr);
- void copiers_changed();
- void new_copier();
- void modify_copier();
- void remove_copier();
-
-private:
- void updateButtons();
-};
-
-
-class PrefFileformats : public PrefModule, public Ui::QPrefFileformatsUi
-{
- Q_OBJECT
-public:
- PrefFileformats(QPrefs * form, QWidget * parent = 0);
-
- void apply(LyXRC & rc) const;
- void update(LyXRC const & rc);
-
- void update();
-Q_SIGNALS:
- void formatsChanged();
-private:
- void updateButtons();
-
-private Q_SLOTS:
- void switch_format(int);
- void fileformat_changed();
- void new_format();
- void modify_format();
- void remove_format();
-};
-
-
-class PrefLanguage : public PrefModule, public Ui::QPrefLanguageUi
-{
- Q_OBJECT
-public:
- PrefLanguage(QWidget * parent = 0);
-
- void apply(LyXRC & rc) const;
- void update(LyXRC const & rc);
-
-private:
- std::vector<std::string> lang_;
-};
-
-
-class PrefPrinter : public PrefModule, public Ui::QPrefPrinterUi
-{
- Q_OBJECT
-public:
- PrefPrinter(QWidget * parent = 0);
-
- void apply(LyXRC & rc) const;
- void update(LyXRC const & rc);
-};
-
-
-class PrefUserInterface : public PrefModule, public Ui::QPrefUi
-{
- Q_OBJECT
-public:
- PrefUserInterface(QPrefs * form, QWidget * parent = 0);
-
- void apply(LyXRC & rc) const;
- void update(LyXRC const & rc);
-
-public Q_SLOTS:
- void select_ui();
- void select_bind();
- void on_loadWindowSizeCB_toggled(bool);
-
-};
-
-
-class PrefIdentity : public PrefModule, public Ui::QPrefIdentityUi
-{
- Q_OBJECT
-public:
- PrefIdentity(QWidget * parent = 0);
-
- void apply(LyXRC & rc) const;
- void update(LyXRC const & rc);
-};
-
-///
-class QPrefsDialog : public QDialog, public Ui::QPrefsUi
-{
- Q_OBJECT
-public:
- QPrefsDialog(QPrefs *);
-
- void apply(LyXRC & rc) const;
- void updateRc(LyXRC const & rc);
-
-public Q_SLOTS:
- void change_adaptor();
-
-protected:
- void closeEvent(QCloseEvent * e);
-
-private:
- void add(PrefModule * module);
-
-private:
- QPrefs * form_;
- std::vector<PrefModule *> modules_;
-};
-
-
-class ControlPrefs;
-
-class QPrefs
- : public QController<ControlPrefs, QView<QPrefsDialog> >
-{
-public:
- QPrefs(Dialog &);
-
- Converters & converters();
- Formats & formats();
- Movers & movers();
-
-private:
- /// Apply changes
- virtual void apply();
-
- /// update (do we need this?)
- virtual void update_contents();
-
- /// build the dialog
- virtual void build_dialog();
-
-};
-
-} // namespace frontend
-} // namespace lyx
-
-#endif // QPREFS_H
+++ /dev/null
-/**
- * \file QPrint.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author John Levon
- * \author Edwin Leuven
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "QPrint.h"
-#include "QLPrintDialog.h"
-#include "Qt2BC.h"
-#include "qt_helpers.h"
-
-#include "PrinterParams.h"
-
-#include "controllers/ControlPrint.h"
-
-#include "support/os.h"
-
-#include <qlineedit.h>
-#include <qcheckbox.h>
-#include <qradiobutton.h>
-#include <qspinbox.h>
-#include <qpushbutton.h>
-
-using lyx::support::os::internal_path;
-
-namespace lyx {
-namespace frontend {
-
-typedef QController<ControlPrint, QView<QLPrintDialog> > print_base_class;
-
-
-QPrint::QPrint(Dialog & parent)
- : print_base_class(parent, _("Print Document"))
-{
-}
-
-
-void QPrint::build_dialog()
-{
- dialog_.reset(new QLPrintDialog(this));
-
- bcview().setOK(dialog_->printPB);
- bcview().setCancel(dialog_->closePB);
-}
-
-
-void QPrint::update_contents()
-{
- PrinterParams & pp = controller().params();
-
- // only reset params if a different buffer
- if (!pp.file_name.empty() && pp.file_name == fromqstr(dialog_->fileED->text()))
- return;
-
- dialog_->printerED->setText(toqstr(pp.printer_name));
- dialog_->fileED->setText(toqstr(pp.file_name));
-
- dialog_->printerRB->setChecked(true);
- if (pp.target == PrinterParams::FILE)
- dialog_->fileRB->setChecked(true);
-
- dialog_->reverseCB->setChecked(pp.reverse_order);
-
- dialog_->copiesSB->setValue(pp.count_copies);
-
- dialog_->oddCB->setChecked(pp.odd_pages);
- dialog_->evenCB->setChecked(pp.even_pages);
-
- dialog_->collateCB->setChecked(pp.sorted_copies);
-
- if (pp.all_pages) {
- dialog_->allRB->setChecked(true);
- return;
- }
-
- dialog_->rangeRB->setChecked(true);
-
- QString s;
- s.setNum(pp.from_page);
- dialog_->fromED->setText(s);
- s.setNum(pp.to_page);
- dialog_->toED->setText(s);
-}
-
-
-void QPrint::apply()
-{
- PrinterParams::Target t = PrinterParams::PRINTER;
- if (dialog_->fileRB->isChecked())
- t = PrinterParams::FILE;
-
- PrinterParams const pp(t,
- fromqstr(dialog_->printerED->text()),
- internal_path(fromqstr(dialog_->fileED->text())),
- dialog_->allRB->isChecked(),
- dialog_->fromED->text().toUInt(),
- dialog_->toED->text().toUInt(),
- dialog_->oddCB->isChecked(),
- dialog_->evenCB->isChecked(),
- dialog_->copiesSB->text().toUInt(),
- dialog_->collateCB->isChecked(),
- dialog_->reverseCB->isChecked());
-
- controller().params() = pp;
-}
-
-} // namespace frontend
-} // namespace lyx
+++ /dev/null
-// -*- C++ -*-
-/**
- * \file QPrint.h
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author John Levon
- * \author Edwin Leuven
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#ifndef QPRINT_H
-#define QPRINT_H
-
-#include "QDialogView.h"
-#include "QLPrintDialog.h"
-
-namespace lyx {
-namespace frontend {
-
-class ControlPrint;
-
-///
-class QPrint
- : public QController<ControlPrint, QView<QLPrintDialog> >
-{
-public:
- ///
- friend class QLPrintDialog;
- ///
- QPrint(Dialog &);
-private:
- /// Apply changes
- virtual void apply();
- /// update
- virtual void update_contents();
- /// build the dialog
- virtual void build_dialog();
-};
-
-} // namespace frontend
-} // namespace lyx
-
-#endif // QPRINT_H
+++ /dev/null
-/**
- * \file QRef.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author John Levon
- * \author Jürgen Spitzmüller
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "QRef.h"
-#include "Qt2BC.h"
-#include "qt_helpers.h"
-
-#include "controllers/ButtonController.h"
-#include "controllers/ControlRef.h"
-
-#include "insets/InsetRef.h"
-
-#include <QLineEdit>
-#include <QCheckBox>
-#include <QListWidget>
-#include <QListWidgetItem>
-#include <QPushButton>
-#include <QToolTip>
-#include <QCloseEvent>
-
-
-using std::vector;
-using std::string;
-
-
-namespace lyx {
-namespace frontend {
-
-/////////////////////////////////////////////////////////////////////
-//
-// QRefDialog
-//
-/////////////////////////////////////////////////////////////////////
-
-QRefDialog::QRefDialog(QRef * form)
- : form_(form)
-{
- setupUi(this);
-
- connect(okPB, SIGNAL(clicked()), form_, SLOT(slotOK()));
- connect(applyPB, SIGNAL(clicked()), form_, SLOT(slotApply()));
- connect(closePB, SIGNAL(clicked()), form_, SLOT(slotClose()));
- connect(closePB, SIGNAL(clicked()), this, SLOT(reset_dialog()));
- connect(this, SIGNAL(rejected()), this, SLOT(reset_dialog()));
-
- connect(typeCO, SIGNAL(activated(int)),
- this, SLOT(changed_adaptor()));
- connect(referenceED, SIGNAL(textChanged(const QString &)),
- this, SLOT(changed_adaptor()));
- connect(nameED, SIGNAL(textChanged(const QString &)),
- this, SLOT(changed_adaptor()));
- connect(refsLW, SIGNAL(itemClicked(QListWidgetItem *)),
- this, SLOT(refHighlighted(QListWidgetItem *)));
- connect(refsLW, SIGNAL(itemSelectionChanged()),
- this, SLOT(selectionChanged()));
- connect(refsLW, SIGNAL(itemActivated(QListWidgetItem *)),
- this, SLOT(refSelected(QListWidgetItem *)));
- connect(sortCB, SIGNAL(clicked(bool)),
- this, SLOT(sortToggled(bool)));
- connect(gotoPB, SIGNAL(clicked()),
- this, SLOT(gotoClicked()));
- connect(updatePB, SIGNAL(clicked()),
- this, SLOT(updateClicked()));
- connect(bufferCO, SIGNAL(activated(int)),
- this, SLOT(updateClicked()));
-
- setFocusProxy(refsLW);
-}
-
-void QRefDialog::show()
-{
- QDialog::show();
-}
-
-
-void QRefDialog::changed_adaptor()
-{
- form_->changed();
-}
-
-
-void QRefDialog::gotoClicked()
-{
- form_->gotoRef();
-}
-
-void QRefDialog::selectionChanged()
-{
- if (form_->readOnly())
- return;
-
- QList<QListWidgetItem *> selections = refsLW->selectedItems();
- if (selections.isEmpty())
- return;
- QListWidgetItem * sel = selections.first();
- refHighlighted(sel);
- return;
-}
-
-
-void QRefDialog::refHighlighted(QListWidgetItem * sel)
-{
- if (form_->readOnly())
- return;
-
-/* int const cur_item = refsLW->currentRow();
- bool const cur_item_selected = cur_item >= 0 ?
- refsLB->isSelected(cur_item) : false;*/
- bool const cur_item_selected = refsLW->isItemSelected(sel);
-
- if (cur_item_selected)
- referenceED->setText(sel->text());
-
- if (form_->at_ref_)
- form_->gotoRef();
- gotoPB->setEnabled(true);
- if (form_->typeAllowed())
- typeCO->setEnabled(true);
- if (form_->nameAllowed())
- nameED->setEnabled(true);
-}
-
-
-void QRefDialog::refSelected(QListWidgetItem * sel)
-{
- if (form_->readOnly())
- return;
-
-/* int const cur_item = refsLW->currentRow();
- bool const cur_item_selected = cur_item >= 0 ?
- refsLB->isSelected(cur_item) : false;*/
- bool const cur_item_selected = refsLW->isItemSelected(sel);
-
- if (cur_item_selected)
- referenceED->setText(sel->text());
- // <enter> or double click, inserts ref and closes dialog
- form_->slotOK();
-}
-
-
-void QRefDialog::sortToggled(bool on)
-{
- form_->sort_ = on;
- form_->redoRefs();
-}
-
-
-void QRefDialog::updateClicked()
-{
- form_->updateRefs();
-}
-
-
-void QRefDialog::reset_dialog() {
- form_->at_ref_ = false;
- form_->setGotoRef();
-}
-
-
-void QRefDialog::closeEvent(QCloseEvent * e)
-{
- form_->slotWMHide();
- reset_dialog();
- e->accept();
-}
-
-
-/////////////////////////////////////////////////////////////////////
-//
-// QRef
-//
-/////////////////////////////////////////////////////////////////////
-
-// full qualification because qt4 has also a ControlRef type
-typedef QController<lyx::frontend::ControlRef, QView<QRefDialog> > RefBase;
-
-
-QRef::QRef(Dialog & parent)
- : RefBase(parent, _("Cross-reference")),
- sort_(false), at_ref_(false)
-{
-}
-
-
-void QRef::build_dialog()
-{
- dialog_.reset(new QRefDialog(this));
-
- bcview().setOK(dialog_->okPB);
- bcview().setApply(dialog_->applyPB);
- bcview().setCancel(dialog_->closePB);
- bcview().addReadOnly(dialog_->refsLW);
- bcview().addReadOnly(dialog_->sortCB);
- bcview().addReadOnly(dialog_->nameED);
- bcview().addReadOnly(dialog_->referenceED);
- bcview().addReadOnly(dialog_->typeCO);
- bcview().addReadOnly(dialog_->bufferCO);
-
- restored_buffer_ = -1;
-}
-
-
-void QRef::update_contents()
-{
- InsetCommandParams const & params = controller().params();
-
- int orig_type = dialog_->typeCO->currentIndex();
-
- dialog_->referenceED->setText(toqstr(params["reference"]));
-
- dialog_->nameED->setText(toqstr(params["name"]));
- dialog_->nameED->setReadOnly(!nameAllowed() && !readOnly());
-
- // restore type settings for new insets
- if (params["reference"].empty())
- dialog_->typeCO->setCurrentIndex(orig_type);
- else
- dialog_->typeCO->setCurrentIndex(InsetRef::getType(params.getCmdName()));
- dialog_->typeCO->setEnabled(typeAllowed() && !readOnly());
- if (!typeAllowed())
- dialog_->typeCO->setCurrentIndex(0);
-
- dialog_->sortCB->setChecked(sort_);
-
- // insert buffer list
- dialog_->bufferCO->clear();
- vector<string> const buffers = controller().getBufferList();
- for (vector<string>::const_iterator it = buffers.begin();
- it != buffers.end(); ++it) {
- dialog_->bufferCO->addItem(toqstr(*it));
- }
- // restore the buffer combo setting for new insets
- if (params["reference"].empty() && restored_buffer_ != -1
- && restored_buffer_ < dialog_->bufferCO->count())
- dialog_->bufferCO->setCurrentIndex(restored_buffer_);
- else
- dialog_->bufferCO->setCurrentIndex(controller().getBufferNum());
-
- updateRefs();
- bc().valid(false);
-}
-
-
-void QRef::apply()
-{
- InsetCommandParams & params = controller().params();
-
- last_reference_ = dialog_->referenceED->text();
-
- params.setCmdName(InsetRef::getName(dialog_->typeCO->currentIndex()));
- params["reference"] = qstring_to_ucs4(last_reference_);
- params["name"] = qstring_to_ucs4(dialog_->nameED->text());
-
- restored_buffer_ = dialog_->bufferCO->currentIndex();
-}
-
-
-bool QRef::nameAllowed()
-{
- Kernel::DocType const doc_type = kernel().docType();
- return doc_type != Kernel::LATEX &&
- doc_type != Kernel::LITERATE;
-}
-
-
-bool QRef::typeAllowed()
-{
- Kernel::DocType const doc_type = kernel().docType();
- return doc_type != Kernel::DOCBOOK;
-}
-
-
-void QRef::setGoBack()
-{
- dialog_->gotoPB->setText(qt_("&Go Back"));
- dialog_->gotoPB->setToolTip("");
- dialog_->gotoPB->setToolTip(qt_("Jump back"));
-}
-
-
-void QRef::setGotoRef()
-{
- dialog_->gotoPB->setText(qt_("&Go to Label"));
- dialog_->gotoPB->setToolTip("");
- dialog_->gotoPB->setToolTip(qt_("Jump to label"));
-}
-
-
-void QRef::gotoRef()
-{
- string ref(fromqstr(dialog_->referenceED->text()));
-
- if (at_ref_) {
- // go back
- setGotoRef();
- controller().gotoBookmark();
- } else {
- // go to the ref
- setGoBack();
- controller().gotoRef(ref);
- }
- at_ref_ = !at_ref_;
-}
-
-
-void QRef::redoRefs()
-{
- // Prevent these widgets from emitting any signals whilst
- // we modify their state.
- dialog_->refsLW->blockSignals(true);
- dialog_->referenceED->blockSignals(true);
- dialog_->refsLW->setUpdatesEnabled(false);
-
- dialog_->refsLW->clear();
-
- // need this because Qt will send a highlight() here for
- // the first item inserted
- QString const oldSelection(dialog_->referenceED->text());
-
- for (std::vector<docstring>::const_iterator iter = refs_.begin();
- iter != refs_.end(); ++iter) {
- dialog_->refsLW->addItem(toqstr(*iter));
- }
-
- if (sort_)
- dialog_->refsLW->sortItems();
-
- dialog_->referenceED->setText(oldSelection);
-
- // restore the last selection or, for new insets, highlight
- // the previous selection
- if (!oldSelection.isEmpty() || !last_reference_.isEmpty()) {
- bool const newInset = oldSelection.isEmpty();
- QString textToFind = newInset ? last_reference_ : oldSelection;
- bool foundItem = false;
- for (int i = 0; !foundItem && i < dialog_->refsLW->count(); ++i) {
- QListWidgetItem * item = dialog_->refsLW->item(i);
- if (textToFind == item->text()) {
- dialog_->refsLW->setCurrentItem(item);
- dialog_->refsLW->setItemSelected(item, !newInset);
- //Make sure selected item is visible
- dialog_->refsLW->scrollToItem(item);
- foundItem = true;
- }
- }
- if (foundItem)
- last_reference_ = textToFind;
- else last_reference_ = "";
- }
- dialog_->refsLW->setUpdatesEnabled(true);
- dialog_->refsLW->update();
-
- // Re-activate the emission of signals by these widgets.
- dialog_->refsLW->blockSignals(false);
- dialog_->referenceED->blockSignals(false);
-}
-
-
-void QRef::updateRefs()
-{
- refs_.clear();
- string const name = controller().getBufferName(dialog_->bufferCO->currentIndex());
- refs_ = controller().getLabelList(name);
- dialog_->sortCB->setEnabled(!refs_.empty());
- dialog_->refsLW->setEnabled(!refs_.empty());
- dialog_->gotoPB->setEnabled(!refs_.empty());
- redoRefs();
-}
-
-bool QRef::isValid()
-{
- return !dialog_->referenceED->text().isEmpty();
-}
-
-} // namespace frontend
-} // namespace lyx
-
-#include "QRef_moc.cpp"
+++ /dev/null
-// -*- C++ -*-
-/**
- * \file QRef.h
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author John Levon
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#ifndef QREF_H
-#define QREF_H
-
-#include "QDialogView.h"
-
-#include "ui_RefUi.h"
-
-#include <QDialog>
-
-#include <vector>
-
-class QListWidgetItem;
-class QCloseEvent;
-
-namespace lyx {
-namespace frontend {
-
-class QRef;
-
-class QRefDialog : public QDialog, public Ui::QRefUi {
- Q_OBJECT
-public:
- QRefDialog(QRef * form);
-
- virtual void show();
-
-public Q_SLOTS:
- void changed_adaptor();
- void gotoClicked();
- void refHighlighted(QListWidgetItem *);
- void selectionChanged();
- void refSelected(QListWidgetItem *);
- void sortToggled(bool);
- void updateClicked();
-
-protected Q_SLOTS:
- void reset_dialog();
-protected:
- void closeEvent(QCloseEvent * e);
-private:
- QRef * form_;
-};
-
-
-class ControlRef;
-
-// full qualification because qt4 has also a ControlRef type
-class QRef
- : public QController<lyx::frontend::ControlRef, QView<QRefDialog> >
-{
-public:
- friend class QRefDialog;
-
- QRef(Dialog &);
-
-protected:
- virtual bool isValid();
-
-private:
- /// apply changes
- virtual void apply();
- /// build dialog
- virtual void build_dialog();
- /// update dialog
- virtual void update_contents();
-
- /// is name allowed for this ?
- bool nameAllowed();
-
- /// is type allowed for this ?
- bool typeAllowed();
-
- /// go to current reference
- void gotoRef();
-
- /// set go back button
- void setGoBack();
-
- /// set goto ref button
- void setGotoRef();
-
- /// re-enter references
- void redoRefs();
-
- /// update references
- void updateRefs();
-
- /// sort or not persistent state
- bool sort_;
-
- /// went to a reference ?
- bool at_ref_;
-
- /// the last reference entered or examined
- QString last_reference_;
-
- /// store the buffer settings
- int restored_buffer_;
-
- /// the references
- std::vector<docstring> refs_;
-};
-
-} // namespace frontend
-} // namespace lyx
-
-#endif // QREF_H
+++ /dev/null
-/**
- * \file QSearch.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author John Levon
- * \author Edwin Leuven
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "QSearch.h"
-#include "qt_helpers.h"
-#include "Qt2BC.h"
-
-#include "controllers/ControlSearch.h"
-
-#include <QLineEdit>
-#include <QCloseEvent>
-
-using std::string;
-
-namespace lyx {
-namespace frontend {
-
-
-/////////////////////////////////////////////////////////////////////
-//
-// QSearchDialog
-//
-/////////////////////////////////////////////////////////////////////
-
-
-static void uniqueInsert(QComboBox * box, QString const & text)
-{
- for (int i = 0; i < box->count(); ++i) {
- if (box->itemText(i) == text)
- return;
- }
-
- box->addItem(text);
-}
-
-
-QSearchDialog::QSearchDialog(QSearch * form)
- : form_(form)
-{
- setupUi(this);
-
- connect(closePB, SIGNAL(clicked()), form_, SLOT(slotClose()));
- connect(findPB, SIGNAL(clicked()), this, SLOT(findClicked()));
- connect(replacePB, SIGNAL(clicked()), this, SLOT(replaceClicked()));
- connect(replaceallPB, SIGNAL(clicked()), this, SLOT(replaceallClicked()));
- connect(findCO, SIGNAL(editTextChanged(const QString &)),
- this, SLOT(findChanged()));
-
- setFocusProxy(findCO);
-}
-
-
-void QSearchDialog::show()
-{
- QDialog::show();
- findCO->lineEdit()->setSelection(0, findCO->lineEdit()->text().length());
-}
-
-
-void QSearchDialog::closeEvent(QCloseEvent * e)
-{
- form_->slotWMHide();
- e->accept();
-}
-
-
-void QSearchDialog::findChanged()
-{
- if (findCO->currentText().isEmpty()) {
- findPB->setEnabled(false);
- replacePB->setEnabled(false);
- replaceallPB->setEnabled(false);
- } else {
- findPB->setEnabled(true);
- replacePB->setEnabled(!form_->readOnly());
- replaceallPB->setEnabled(!form_->readOnly());
- }
-}
-
-
-void QSearchDialog::findClicked()
-{
- docstring const find = qstring_to_ucs4(findCO->currentText());
- form_->find(find,
- caseCB->isChecked(),
- wordsCB->isChecked(),
- backwardsCB->isChecked());
- uniqueInsert(findCO, findCO->currentText());
- findCO->lineEdit()->setSelection(0, findCO->lineEdit()->text().length());
-}
-
-
-void QSearchDialog::replaceClicked()
-{
- docstring const find = qstring_to_ucs4(findCO->currentText());
- docstring const replace = qstring_to_ucs4(replaceCO->currentText());
- form_->replace(find, replace,
- caseCB->isChecked(),
- wordsCB->isChecked(),
- backwardsCB->isChecked(), false);
- uniqueInsert(findCO, findCO->currentText());
- uniqueInsert(replaceCO, replaceCO->currentText());
-}
-
-
-void QSearchDialog::replaceallClicked()
-{
- form_->replace(qstring_to_ucs4(findCO->currentText()),
- qstring_to_ucs4(replaceCO->currentText()),
- caseCB->isChecked(),
- wordsCB->isChecked(),
- false, true);
- uniqueInsert(findCO, findCO->currentText());
- uniqueInsert(replaceCO, replaceCO->currentText());
-}
-
-
-/////////////////////////////////////////////////////////////////////
-//
-// QSearch
-//
-/////////////////////////////////////////////////////////////////////
-
-
-typedef QController<ControlSearch, QView<QSearchDialog> > SearchBase;
-
-
-QSearch::QSearch(Dialog & parent)
- : SearchBase(parent, _("Find and Replace"))
-{
-}
-
-
-void QSearch::build_dialog()
-{
- dialog_.reset(new QSearchDialog(this));
-
- bcview().setCancel(dialog_->closePB);
- bcview().addReadOnly(dialog_->replaceCO);
- bcview().addReadOnly(dialog_->replacePB);
- bcview().addReadOnly(dialog_->replaceallPB);
-
- dialog_->replacePB->setEnabled(false);
- dialog_->replaceallPB->setEnabled(false);
-}
-
-
-void QSearch::find(docstring const & str, bool casesens,
- bool words, bool backwards)
-{
- controller().find(str, casesens, words, !backwards);
-}
-
-
-void QSearch::replace(docstring const & findstr, docstring const & replacestr,
- bool casesens, bool words, bool backwards, bool all)
-{
- controller().replace(findstr, replacestr, casesens, words,
- !backwards, all);
-}
-
-} // namespace frontend
-} // namespace lyx
-
-
-#include "QSearch_moc.cpp"
+++ /dev/null
-// -*- C++ -*-
-/**
- * \file QSearch.h
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author John Levon
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#ifndef QSEARCH_H
-#define QSEARCH_H
-
-#include "QDialogView.h"
-#include "ui_SearchUi.h"
-#include <string>
-
-#include <QDialog>
-
-namespace lyx {
-namespace frontend {
-
-class ControlSearch;
-
-class QSearch;
-
-class QSearchDialog : public QDialog, public Ui::QSearchUi {
- Q_OBJECT
-public:
- QSearchDialog(QSearch * form);
-
- virtual void show();
-protected Q_SLOTS:
- void findChanged();
- void findClicked();
- void replaceClicked();
- void replaceallClicked();
-protected:
- virtual void closeEvent(QCloseEvent * e);
-
-private:
- // add a string to the combo if needed
- void remember(std::string const & find, QComboBox & combo);
-
- QSearch * form_;
-};
-
-
-class QSearch
- : public QController<ControlSearch, QView<QSearchDialog> >
-{
-public:
- ///
- friend class QSearchDialog;
- ///
- QSearch(Dialog &);
-private:
- /// Apply changes
- virtual void apply() {}
- /// update
- virtual void update_contents() {}
- /// build the dialog
- virtual void build_dialog();
-
- void find(docstring const & str, bool casesens,
- bool words, bool backwards);
-
- void replace(docstring const & findstr,
- docstring const & replacestr,
- bool casesens, bool words, bool backwards, bool all);
-};
-
-} // namespace frontend
-} // namespace lyx
-
-#endif // QSEARCH_H
+++ /dev/null
-/**
- * \file QSelectionManager.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Richard Heck
- * \author Et Alia
- *
- * Some of the material in this file previously appeared in
- * QCitationDialog.cpp.
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-#include "QSelectionManager.h"
-
-
-namespace lyx {
-namespace frontend {
-
-QSelectionManager::QSelectionManager(
- QListView * avail,
- QListView * sel,
- QPushButton * add,
- QPushButton * del,
- QPushButton * up,
- QPushButton * down,
- QStringListModel * amod,
- QStringListModel * smod)
-{
- availableLV = avail;
- selectedLV = sel;
- addPB = add;
- deletePB = del;
- upPB = up;
- downPB = down;
- availableModel = amod;
- selectedModel = smod;
-
- selectedLV->setModel(smod);
- availableLV->setModel(amod);
-
- connect(availableLV->selectionModel(),
- SIGNAL(currentChanged(const QModelIndex &, const QModelIndex &)),
- this, SLOT(availableChanged(const QModelIndex &, const QModelIndex &)));
- connect(selectedLV->selectionModel(),
- SIGNAL(currentChanged(const QModelIndex &, const QModelIndex &)),
- this, SLOT(selectedChanged(const QModelIndex &, const QModelIndex &)));
- connect(addPB, SIGNAL(clicked()),
- this, SLOT(addPB_clicked()));
- connect(deletePB, SIGNAL(clicked()),
- this, SLOT(deletePB_clicked()));
- connect(upPB, SIGNAL(clicked()),
- this, SLOT(upPB_clicked()));
- connect(downPB, SIGNAL(clicked()),
- this, SLOT(downPB_clicked()));
- connect(availableLV, SIGNAL(clicked(const QModelIndex &)),
- this, SLOT(availableLV_clicked(const QModelIndex &)));
- connect(availableLV, SIGNAL(doubleClicked(const QModelIndex &)),
- this, SLOT(availableLV_doubleClicked(const QModelIndex &)));
- connect(selectedLV, SIGNAL(clicked(const QModelIndex &)),
- this, SLOT(selectedLV_clicked(const QModelIndex &)));
-
- availableLV->installEventFilter(this);
- selectedLV->installEventFilter(this);
-}
-
-
-void QSelectionManager::update() {
- int const arows = availableLV->model()->rowCount();
- QModelIndexList const availSels =
- availableLV->selectionModel()->selectedIndexes();
- addPB->setEnabled(arows > 0 &&
- !availSels.isEmpty() &&
- !isSelected(availSels.first()));
-
- int const srows = selectedLV->model()->rowCount();
- QModelIndexList const selSels =
- selectedLV->selectionModel()->selectedIndexes();
- int const sel_nr = selSels.empty() ? -1 : selSels.first().row();
- deletePB->setEnabled(sel_nr >= 0);
- upPB->setEnabled(sel_nr > 0);
- downPB->setEnabled(sel_nr >= 0 && sel_nr < srows - 1);
-}
-
-
-bool QSelectionManager::isSelected(const QModelIndex & idx)
-{
- QString const str = idx.data().toString();
- return selectedModel->stringList().contains(str);
-}
-
-
-void QSelectionManager::availableChanged(const QModelIndex & idx, const QModelIndex &)
-{
- if (!idx.isValid())
- return;
-
- selectedHasFocus_ = false;
- updateHook();
-}
-
-
-void QSelectionManager::selectedChanged(const QModelIndex & idx, const QModelIndex &)
-{
- if (!idx.isValid())
- return;
-
- selectedHasFocus_ = true;
- updateHook();
-}
-
-
-namespace {
-//helper function for next two
- QModelIndex getSelectedIndex(QListView * lv) {
- //Encourage compiler to use NRVO
- QModelIndex retval = QModelIndex();
- QModelIndexList selIdx =
- lv->selectionModel()->selectedIndexes();
- if (!selIdx.empty())
- retval = selIdx.first();
- return retval;
- }
-}//anonymous namespace
-
-
-void QSelectionManager::addPB_clicked()
-{
- QModelIndex const idxToAdd = getSelectedIndex(availableLV);
- if (!idxToAdd.isValid())
- return;
- QModelIndex idx = selectedLV->currentIndex();
-
- QStringList keys = selectedModel->stringList();
- keys.append(idxToAdd.data().toString());
- selectedModel->setStringList(keys);
- selectionChanged(); //signal
-
- if (idx.isValid())
- selectedLV->setCurrentIndex(idx);
- updateHook();
-}
-
-
-void QSelectionManager::deletePB_clicked()
-{
- QModelIndex idx = getSelectedIndex(selectedLV);
- if (!idx.isValid())
- return;
-
- QStringList keys = selectedModel->stringList();
- keys.removeAt(idx.row());
- selectedModel->setStringList(keys);
- selectionChanged(); //signal
-
- int nrows = selectedLV->model()->rowCount();
- if (idx.row() == nrows) //was last item on list
- idx = idx.sibling(idx.row() - 1, idx.column());
-
- if (nrows > 1)
- selectedLV->setCurrentIndex(idx);
- else if (nrows == 1)
- selectedLV->setCurrentIndex(selectedLV->model()->index(0,0));
- selectedHasFocus_ = (nrows > 0);
- updateHook();
-}
-
-
-void QSelectionManager::upPB_clicked()
-{
- QModelIndex idx = selectedLV->currentIndex();
-
- int const pos = idx.row();
- QStringList keys = selectedModel->stringList();
- keys.swap(pos, pos - 1);
- selectedModel->setStringList(keys);
- selectionChanged(); //signal
-
- selectedLV->setCurrentIndex(idx.sibling(idx.row() - 1, idx.column()));
- selectedHasFocus_ = true;
- updateHook();
-}
-
-
-void QSelectionManager::downPB_clicked()
-{
- QModelIndex idx = selectedLV->currentIndex();
-
- int const pos = idx.row();
- QStringList keys = selectedModel->stringList();
- keys.swap(pos, pos + 1);
- selectedModel->setStringList(keys);
- selectionChanged(); //signal
-
- selectedLV->setCurrentIndex(idx.sibling(idx.row() + 1, idx.column()));
- selectedHasFocus_ = true;
- updateHook();
-}
-
-
-//FIXME These slots do not really do what they need to do, since focus
-//can enter the QListView in other ways. But there are no signals sent
-//in that case. We need to reimplement focusInEvent() to capture those,
-//which means subclassing QListView. (rgh)
-void QSelectionManager::availableLV_clicked(const QModelIndex &)
-{
- selectedHasFocus_ = false;
- updateHook();
-}
-
-
-void QSelectionManager::availableLV_doubleClicked(const QModelIndex & idx)
-{
- if (isSelected(idx))
- return;
-
- if (idx.isValid())
- selectedHasFocus_ = false;
- addPB_clicked();
- //updateHook() will be emitted there
-}
-
-
-void QSelectionManager::selectedLV_clicked(const QModelIndex &)
-{
- selectedHasFocus_ = true;
- updateHook();
-}
-
-
-bool QSelectionManager::eventFilter(QObject * obj, QEvent * event)
-{
- if (obj == availableLV) {
- if (event->type() != QEvent::KeyPress)
- return QObject::eventFilter(obj, event);
- QKeyEvent * keyEvent = static_cast<QKeyEvent *>(event);
- int const keyPressed = keyEvent->key();
- Qt::KeyboardModifiers const keyModifiers = keyEvent->modifiers();
- //Enter key without modifier will add current item.
- //Ctrl-Enter will add it and close the dialog.
- //This is designed to work both with the main enter key
- //and the one on the numeric keypad.
- if ((keyPressed == Qt::Key_Enter || keyPressed == Qt::Key_Return) &&
- //We want one or both of Control and Keypad, and nothing else
- //(KeypadModifier is what you get if you use the Enter key on the
- //numeric keypad.)
- (!keyModifiers ||
- (keyModifiers == Qt::ControlModifier) ||
- (keyModifiers == Qt::KeypadModifier) ||
- (keyModifiers == (Qt::ControlModifier | Qt::KeypadModifier))
- )
- ) {
- if (addPB->isEnabled()) {
- addPB_clicked();
- okHook(); //signal
- }
- event->accept();
- return true;
- }
- } else if (obj == selectedLV) {
- //Delete or backspace key will delete current item
- //...with control modifier will clear the list
- if (event->type() != QEvent::KeyPress)
- return QObject::eventFilter(obj, event);
- QKeyEvent * keyEvent = static_cast<QKeyEvent *>(event);
- int const keyPressed = keyEvent->key();
- Qt::KeyboardModifiers const keyModifiers = keyEvent->modifiers();
- if (keyPressed == Qt::Key_Delete || keyPressed == Qt::Key_Backspace) {
- if (keyModifiers == Qt::NoModifier && deletePB->isEnabled())
- deletePB_clicked();
- else if (keyModifiers == Qt::ControlModifier) {
- QStringList list = selectedModel->stringList();
- list.clear();
- selectedModel->setStringList(list);
- updateHook();
- } else
- //ignore it otherwise
- return QObject::eventFilter(obj, event);
- event->accept();
- return true;
- }
- }
- return QObject::eventFilter(obj, event);
-}
-
-}//namespace frontend
-}//namespace lyx
-
-#include "QSelectionManager_moc.cpp"
+++ /dev/null
-/**
- * \file QSelectionManager.h
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Richard Heck
- * \author Et Alia
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#ifndef QSELECTIONMANAGER_H
-#define QSELECTIONMANAGER_H
-
-#include "Dialog.h"
-#include <QObject>
-#include <QKeyEvent>
-#include <QStringList>
-#include <QStringListModel>
-#include <QListView>
-#include <QPushButton>
-
-namespace lyx {
-namespace frontend {
-
-/** Class to manage a collection of widgets that allows selection
- * of items from a list of available items. Adapted from code originally
- * written for QCitationDialog.
- * Note that this is a not a QWidget, though it could be converted to
- * one. Rather, the managed widgets---see constructor for descripton
- * of them---should be created independently, and then passed to the
- * constructor.
- */
-class QSelectionManager: public QObject {
- Q_OBJECT
-
- public:
- ///
- QSelectionManager(
- QListView * availableLV,
- QListView * selectedLV,
- QPushButton * addPB,
- QPushButton * delPB,
- QPushButton * upPB,
- QPushButton * downPB,
- QStringListModel * availableModel,
- QStringListModel * selectedModel);
- /// Sets the state of the various push buttons, depending upon the
- /// state of the widgets. (E.g., "delete" is enabled only if the
- /// selection is non-empty.)
- virtual void update();
-
- /// Not strictly a matter of focus, which may be elsewhere, but
- /// whether selectedLV is `more focused' than availableLV. Intended
- /// to be used, for example, in displaying information about a
- /// highlighted item: should it be the highlighted available item
- /// or the highlighted selected item that is displayed?
- bool selectedFocused() { return selectedHasFocus_; };
-
- Q_SIGNALS:
- ///Emitted when the list of selected items has changed.
- void selectionChanged();
- ///Emitted when something has changed that might lead the containing
- ///dialog to want to update---the focused subwidget or selected item.
- ///(Specifically, it is emitted by *_PB_clicked() and *_LV_clicked.)
- ///NOTE: No automatic update of the button state is done here. If you
- ///just want to do that, connect updateHook() to update(). Much of the
- ///time, though, you will want to do a bit more processing first, so
- ///you can connect to some other function that itself calls update().
- void updateHook();
- ///Emitted on Ctrl-Enter in the availableLV. Intended to be connected
- ///to an "OK" event in the parent dialog.
- void okHook();
-
-
- protected:
- ///Given a QModelIndex from availableLV, determines whether it has
- ///been selected (i.e., is also in selectedLV).
- bool isSelected(const QModelIndex & idx);
-
- protected Q_SLOTS:
- ///
- void availableChanged(const QModelIndex & idx, const QModelIndex &);
- ///
- void selectedChanged(const QModelIndex & idx, const QModelIndex &);
- ///
- void addPB_clicked();
- ///
- void deletePB_clicked();
- ///
- void upPB_clicked();
- ///
- void downPB_clicked();
- ///
- void availableLV_clicked(const QModelIndex &);
- ///
- void availableLV_doubleClicked(const QModelIndex &);
- ///
- void selectedLV_clicked(const QModelIndex &);
- ///
- bool eventFilter(QObject *, QEvent *);
-
- private:
- QListView * availableLV;
- QListView * selectedLV;
- QPushButton * addPB;
- QPushButton * deletePB;
- QPushButton * upPB;
- QPushButton * downPB;
- QStringListModel * availableModel;
- QStringListModel * selectedModel;
- Dialog::View * dialog;
-
- bool selectedHasFocus_;
-};
-}//namespace frontend
-}//namespace lyx
-#endif
+++ /dev/null
-/**
- * \file QSendto.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Jürgen Spitzmüller
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "QSendto.h"
-#include "Qt2BC.h"
-#include "qt_helpers.h"
-
-#include "Format.h"
-
-#include "controllers/ControlSendto.h"
-
-#include <QListWidget>
-#include <QPushButton>
-#include <QCloseEvent>
-
-using std::vector;
-using std::string;
-
-
-namespace lyx {
-namespace frontend {
-
-/////////////////////////////////////////////////////////////////////
-//
-// QSendtoDialog
-//
-/////////////////////////////////////////////////////////////////////
-
-QSendtoDialog::QSendtoDialog(QSendto * form)
- : form_(form)
-{
- setupUi(this);
-
- connect(okPB, SIGNAL(clicked()),
- form, SLOT(slotOK()));
- connect(applyPB, SIGNAL(clicked()),
- form, SLOT(slotApply()));
- connect(closePB, SIGNAL(clicked()),
- form, SLOT(slotClose()));
-
- connect( formatLW, SIGNAL( itemClicked(QListWidgetItem *) ),
- this, SLOT( slotFormatHighlighted(QListWidgetItem *) ) );
- connect( formatLW, SIGNAL( itemActivated(QListWidgetItem *) ),
- this, SLOT( slotFormatSelected(QListWidgetItem *) ) );
- connect( formatLW, SIGNAL( itemClicked(QListWidgetItem *) ),
- this, SLOT( changed_adaptor() ) );
- connect( commandCO, SIGNAL( textChanged(const QString&) ),
- this, SLOT( changed_adaptor() ) );
-}
-
-
-void QSendtoDialog::changed_adaptor()
-{
- form_->changed();
-}
-
-
-void QSendtoDialog::closeEvent(QCloseEvent * e)
-{
- form_->slotWMHide();
- e->accept();
-}
-
-
-/////////////////////////////////////////////////////////////////////
-//
-// QSendto
-//
-/////////////////////////////////////////////////////////////////////
-
-typedef QController<ControlSendto, QView<QSendtoDialog> > SendtoBase;
-
-
-QSendto::QSendto(Dialog & parent)
- : SendtoBase(parent, _("Send Document to Command"))
-{
-}
-
-
-void QSendto::build_dialog()
-{
- dialog_.reset(new QSendtoDialog(this));
-
- // Manage the ok, apply, restore and cancel/close buttons
- bcview().setOK(dialog_->okPB);
- bcview().setApply(dialog_->applyPB);
- bcview().setCancel(dialog_->closePB);
-}
-
-
-void QSendto::update_contents()
-{
- all_formats_ = controller().allFormats();
-
- // Check whether the current contents of the browser will be
- // changed by loading the contents of formats
- vector<string> keys;
- keys.resize(all_formats_.size());
-
- vector<string>::iterator result = keys.begin();
- vector<Format const *>::const_iterator it = all_formats_.begin();
- vector<Format const *>::const_iterator end = all_formats_.end();
- for (; it != end; ++it, ++result) {
- *result = (*it)->prettyname();
- }
-
- // Reload the browser
- dialog_->formatLW->clear();
-
- for (vector<string>::const_iterator it = keys.begin();
- it < keys.end(); ++it) {
- dialog_->formatLW->addItem(toqstr(*it));
- }
-
- dialog_->commandCO->addItem(toqstr(controller().getCommand()));
-}
-
-
-void QSendto::apply()
-{
- int const line(dialog_->formatLW->currentRow());
-
- if (line < 0 || line > int(dialog_->formatLW->count()))
- return;
-
- string const cmd(fromqstr(dialog_->commandCO->currentText()));
-
- controller().setFormat(all_formats_[line]);
- controller().setCommand(cmd);
-}
-
-
-bool QSendto::isValid()
-{
- int const line(dialog_->formatLW->currentRow());
-
- if (line < 0 || line > int(dialog_->formatLW->count()))
- return false;
-
- else return dialog_->formatLW->count() != 0 &&
- !dialog_->commandCO->currentText().isEmpty();
-}
-
-} // namespace frontend
-} // namespace lyx
-
-#include "QSendto_moc.cpp"
+++ /dev/null
-// -*- C++ -*-
-/**
- * \file QSendto.h
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Jürgen Spitzmüller
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#ifndef QSENDTO_H
-#define QSENDTO_H
-
-#include "QDialogView.h"
-#include "ui_SendtoUi.h"
-
-#include <QDialog>
-
-#include <vector>
-
-class QCloseEvent;
-class QListWidgetItem;
-
-namespace lyx {
-
-class Format;
-
-namespace frontend {
-
-class QSendto;
-
-class QSendtoDialog : public QDialog, public Ui::QSendtoUi {
- Q_OBJECT
-public:
- QSendtoDialog(QSendto * form);
-protected Q_SLOTS:
- virtual void changed_adaptor();
- virtual void slotFormatHighlighted(QListWidgetItem *) {}
- virtual void slotFormatSelected(QListWidgetItem *) {}
-protected:
- virtual void closeEvent(QCloseEvent * e);
-private:
- QSendto * form_;
-};
-
-
-class ControlSendto;
-
-/** This class provides a Qt implementation of the Custom Export Dialog.
- */
-class QSendto
- : public QController<ControlSendto, QView<QSendtoDialog> >
-{
-public:
- ///
- friend class QSendtoDialog;
- ///
- QSendto(Dialog &);
-protected:
- virtual bool isValid();
-private:
- /// Apply from dialog
- virtual void apply();
- /// Update the dialog
- virtual void update_contents();
- /// Build the dialog
- virtual void build_dialog();
- ///
- std::vector<Format const *> all_formats_;
-};
-
-} // namespace frontend
-} // namespace lyx
-
-#endif // QSENDTO_H
+++ /dev/null
-/**
- * \file QSetBorder.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Edwin Leuven
- * \author John Levon
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "QSetBorder.h"
-
-#include <QPainter>
-
-//Added by qt3to4:
-#include <QMouseEvent>
-#include <QPaintEvent>
-
-
-QSetBorder::QSetBorder(QWidget * parent, Qt::WFlags fl)
- : QWidget(parent, fl), buffer(75, 75)
-{
- /* length of corner line */
- l = buffer.width() / 10;
- /* margin */
- m = buffer.height() / 10;
-
- w = buffer.width();
- h = buffer.height();
-
- init();
-
- setMinimumSize(w,h);
- setMaximumSize(w,h);
-}
-
-
-void QSetBorder::paintEvent(QPaintEvent * e)
-{
- QWidget::paintEvent(e);
- QPainter painter(this);
- painter.drawPixmap(0, 0, buffer);
-}
-
-
-void QSetBorder::init()
-{
- buffer.fill();
- QPainter paint(&buffer);
-
- paint.setPen(Qt::black);
-
- // FIXME: wow, readable !! :)
-
- paint.drawLine(m + l , m, m + l, m + l);
- paint.drawLine(w - (m + l), m, w - (m + l), m + l);
-
- paint.drawLine(m, m + l , m + l, m + l);
- paint.drawLine(m, h - (m + l), m + l, h - (m + l));
-
- paint.drawLine(m + l ,h - m, m + l ,h - (m + l));
- paint.drawLine(w - (m + l), h - m, w - (m + l), h - (m + l));
-
- paint.drawLine(h - m, m+l, h - (m + l), m + l);
- paint.drawLine(h - m, h - (m + l), h - (m + l),h - (m + l));
-}
-
-
-void QSetBorder::mousePressEvent(QMouseEvent * e)
-{
- if (e->y() > e->x()) {
- if (e->y() < height() - e->x()) {
- if (left_.enabled) {
- setLeft(!left_.set);
- // emit signal
- leftSet(left_.set);
- }
- } else {
- if (bottom_.enabled) {
- setBottom(!bottom_.set);
- // emit signal
- bottomSet(bottom_.set);
- }
- }
- } else {
- if (e->y() < height() - e->x()) {
- if (top_.enabled) {
- setTop(!top_.set);
- // emit signal
- topSet(top_.set);
- }
- } else {
- if (right_.enabled) {
- setRight(!right_.set);
- // emit signal
- rightSet(right_.set);
- }
- }
- }
- update();
- // emit signal
- clicked();
-}
-
-
-void QSetBorder::drawLine(QColor const & col, int x, int y, int x2, int y2)
-{
- QPainter paint(&buffer);
- QPen p = paint.pen();
- p.setWidth(2);
- p.setColor(col);
- paint.setPen(p);
- paint.drawLine(x, y, x2, y2);
-}
-
-
-void QSetBorder::drawLeft(bool draw)
-{
- QColor col(draw ? Qt::black : Qt::white);
- if (!left_.enabled)
- col = QColor("grey");
- drawLine(col, m + l, m + l + 2, m + l, h - m - l - 1);
-}
-
-
-void QSetBorder::drawRight(bool draw)
-{
- QColor col(draw ? Qt::black : Qt::white);
- if (!right_.enabled)
- col = QColor("grey");
- drawLine(col, h - m - l + 1, m + l + 2, h - m - l + 1, h - m - l - 1);
-}
-
-
-void QSetBorder::drawTop(bool draw)
-{
- QColor col(draw ? Qt::black : Qt::white);
- if (!top_.enabled)
- col = QColor("grey");
- drawLine(col, m + l + 2, m + l, w - m - l - 1, m + l);
-}
-
-
-void QSetBorder::drawBottom(bool draw)
-{
- QColor col(draw ? Qt::black : Qt::white);
- if (!bottom_.enabled)
- col = QColor("grey");
- drawLine(col, m + l + 2, w - m - l + 1, w - m - l - 1, w - m - l + 1);
-}
-
-
-void QSetBorder::setLeftEnabled(bool border)
-{
- left_.enabled = border;
- drawLeft(border);
-}
-
-
-void QSetBorder::setRightEnabled(bool border)
-{
- right_.enabled = border;
- drawRight(border);
-}
-
-
-void QSetBorder::setTopEnabled(bool border)
-{
- top_.enabled = border;
- drawTop(border);
-}
-
-
-void QSetBorder::setBottomEnabled(bool border)
-{
- bottom_.enabled = border;
- drawBottom(border);
-}
-
-
-void QSetBorder::setLeft(bool border)
-{
- left_.set = border;
- drawLeft(border);
-}
-
-
-void QSetBorder::setRight(bool border)
-{
- right_.set = border;
- drawRight(border);
-}
-
-
-void QSetBorder::setTop(bool border)
-{
- top_.set = border;
- drawTop(border);
-}
-
-
-void QSetBorder::setBottom(bool border)
-{
- bottom_.set = border;
- drawBottom(border);
-}
-
-
-void QSetBorder::setAll(bool border)
-{
- setLeft(border);
- setRight(border);
- setTop(border);
- setBottom(border);
-}
-
-
-bool QSetBorder::getLeft()
-{
- return left_.set;
-}
-
-
-bool QSetBorder::getRight()
-{
- return right_.set;
-}
-
-
-bool QSetBorder::getTop()
-{
- return top_.set;
-}
-
-
-bool QSetBorder::getBottom()
-{
- return bottom_.set;
-}
-
-#include "QSetBorder_moc.cpp"
-
-
-namespace lyx {
-
-
-} // namespace lyx
+++ /dev/null
-// -*- C++ -*-
-/**
- * \file QSetBorder.h
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Edwin Leuven
- * \author John Levon
- *
- * Full author contact details are available in file CREDITS.
- */
-#ifndef QSETBORDER_H
-#define QSETBORDER_H
-
-#include <QWidget>
-#include <QPixmap>
-
-class QColor;
-class QMouseEvent;
-class QPaintEvent;
-
-//namespace lyx {
-
-class QSetBorder : public QWidget
-{
- Q_OBJECT
-public:
- QSetBorder(QWidget * parent = 0, Qt::WFlags fl = 0);
-
- bool getLeft();
- bool getRight();
- bool getTop();
- bool getBottom();
-
-Q_SIGNALS:
- void rightSet(bool);
- void leftSet(bool);
- void topSet(bool);
- void bottomSet(bool);
- void clicked();
-
-public Q_SLOTS:
- void setLeftEnabled(bool);
- void setRightEnabled(bool);
- void setTopEnabled(bool);
- void setBottomEnabled(bool);
- void setLeft(bool);
- void setRight(bool);
- void setTop(bool);
- void setBottom(bool);
- void setAll(bool);
-
-protected:
- void mousePressEvent(QMouseEvent * e);
- void paintEvent(QPaintEvent * e);
-
-private:
- void init();
-
- void drawLine(QColor const & col, int x, int y, int x2, int y2);
-
- void drawLeft(bool);
- void drawRight(bool);
- void drawTop(bool);
- void drawBottom(bool);
-
- class Border {
- public:
- Border() : set(true), enabled(true) {}
- bool set;
- bool enabled;
- };
-
- Border left_;
- Border right_;
- Border top_;
- Border bottom_;
-
- int m;
- int l;
- int w;
- int h;
-
- QPixmap buffer;
-};
-
-
-//} // namespace lyx
-
-#endif // QSETBORDER_H
+++ /dev/null
-/**
- * \file QShowFile.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author John Levon
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "QShowFile.h"
-#include "Qt2BC.h"
-#include "qt_helpers.h"
-
-#include "controllers/ControlShowFile.h"
-
-#include <QTextBrowser>
-#include <QPushButton>
-
-namespace lyx {
-namespace frontend {
-
-/////////////////////////////////////////////////////////////////////
-//
-// QShowFileDialog
-//
-/////////////////////////////////////////////////////////////////////
-
-QShowFileDialog::QShowFileDialog(QShowFile * form)
- : form_(form)
-{
- setupUi(this);
- connect(closePB, SIGNAL(clicked()), form, SLOT(slotClose()));
-}
-
-
-void QShowFileDialog::closeEvent(QCloseEvent * e)
-{
- form_->slotWMHide();
- e->accept();
-}
-
-
-/////////////////////////////////////////////////////////////////////
-//
-// QShowFile
-//
-/////////////////////////////////////////////////////////////////////
-
-typedef QController<ControlShowFile, QView<QShowFileDialog> >
- ShowFileBase;
-
-
-QShowFile::QShowFile(Dialog & parent)
- : ShowFileBase(parent, _("Show File"))
-{
-}
-
-
-void QShowFile::build_dialog()
-{
- dialog_.reset(new QShowFileDialog(this));
-
- bcview().setCancel(dialog_->closePB);
-}
-
-
-void QShowFile::update_contents()
-{
- dialog_->setWindowTitle(toqstr(controller().getFileName()));
-
- std::string contents = controller().getFileContents();
- if (contents.empty()) {
- contents = "Error -> Cannot load file!";
- }
-
- dialog_->textTB->setPlainText(toqstr(contents));
-}
-
-} // namespace frontend
-} // namespace lyx
-
-#include "QShowFile_moc.cpp"
+++ /dev/null
-// -*- C++ -*-
-/**
- * \file QShowFile.h
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author John Levon
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#ifndef QSHOWFILE_H
-#define QSHOWFILE_H
-
-#include "QDialogView.h"
-
-#include "ui_ShowFileUi.h"
-
-#include <QDialog>
-#include <QCloseEvent>
-
-namespace lyx {
-namespace frontend {
-
-class QShowFile;
-
-class QShowFileDialog : public QDialog, public Ui::QShowFileUi {
- Q_OBJECT
-public:
- QShowFileDialog(QShowFile * form);
-protected:
- virtual void closeEvent(QCloseEvent * e);
-private:
- QShowFile * form_;
-};
-
-
-class ControlShowFile;
-
-class QShowFile
- : public QController<ControlShowFile, QView<QShowFileDialog> >
-{
-public:
- friend class QShowFileDialog;
-
- QShowFile(Dialog &);
-private:
- /// Apply changes
- virtual void apply() {}
- /// update
- virtual void update_contents();
- /// build the dialog
- virtual void build_dialog();
-};
-
-} // namespace frontend
-} // namespace lyx
-
-#endif // QSHOWFILE_H
+++ /dev/null
-/**
- * \file QSpellchecker.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author John Levon
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "QSpellchecker.h"
-#include "Qt2BC.h"
-#include "qt_helpers.h"
-
-#include "controllers/ControlSpellchecker.h"
-
-#include <QProgressBar>
-#include <QLineEdit>
-#include <QPushButton>
-#include <QListWidget>
-#include <QListWidgetItem>
-#include <QCloseEvent>
-#include <QSyntaxHighlighter>
-#include <QTextCharFormat>
-#include <QTextDocument>
-
-
-using std::string;
-
-namespace lyx {
-namespace frontend {
-
-/////////////////////////////////////////////////////////////////////
-//
-// QSpellCheckerDialog
-//
-/////////////////////////////////////////////////////////////////////
-
-
-QSpellcheckerDialog::QSpellcheckerDialog(QSpellchecker * form)
- : form_(form)
-{
- setupUi(this);
-
- connect(closePB, SIGNAL(clicked()), form, SLOT(slotClose()));
-
- connect(replaceCO, SIGNAL(highlighted(const QString &)),
- this, SLOT(replaceChanged(const QString &)));
- connect(replacePB, SIGNAL(clicked()),
- this, SLOT(replaceClicked()));
- connect(ignorePB, SIGNAL(clicked()),
- this, SLOT(ignoreClicked()));
- connect(replacePB_3, SIGNAL(clicked()),
- this, SLOT(acceptClicked()));
- connect(addPB, SIGNAL(clicked()),
- this, SLOT(addClicked()));
- connect(suggestionsLW, SIGNAL(itemDoubleClicked(QListWidgetItem*)),
- this, SLOT(replaceClicked() ) );
- connect(suggestionsLW, SIGNAL(itemClicked(QListWidgetItem*)),
- this, SLOT(suggestionChanged(QListWidgetItem*)));
-}
-
-
-void QSpellcheckerDialog::acceptClicked()
-{
- form_->accept();
-}
-
-void QSpellcheckerDialog::addClicked()
-{
- form_->add();
-}
-
-void QSpellcheckerDialog::replaceClicked()
-{
- form_->replace();
-}
-
-void QSpellcheckerDialog::ignoreClicked()
-{
- form_->ignore();
-}
-
-void QSpellcheckerDialog::suggestionChanged(QListWidgetItem * item)
-{
- if (replaceCO->count() != 0)
- replaceCO->setItemText(0, item->text());
- else
- replaceCO->addItem(item->text());
-
- replaceCO->setCurrentIndex(0);
-}
-
-void QSpellcheckerDialog::replaceChanged(const QString & str)
-{
- if (suggestionsLW->currentItem()->text() == str)
- return;
-
- for (int i = 0; i < suggestionsLW->count(); ++i) {
- if (suggestionsLW->item(i)->text() == str) {
- suggestionsLW->setCurrentRow(i);
- break;
- }
- }
-}
-
-
-void QSpellcheckerDialog::closeEvent(QCloseEvent * e)
-{
- form_->slotWMHide();
- e->accept();
-}
-
-
-void QSpellcheckerDialog::reject()
-{
- form_->slotWMHide();
- QDialog::reject();
-}
-
-
-
-/////////////////////////////////////////////////////////////////////
-//
-// QSpellChecker
-//
-/////////////////////////////////////////////////////////////////////
-
-typedef QController<ControlSpellchecker, QView<QSpellcheckerDialog> >
- SpellcheckerBase;
-
-QSpellchecker::QSpellchecker(Dialog & parent)
- : SpellcheckerBase(parent, _("Spellchecker"))
-{}
-
-
-void QSpellchecker::build_dialog()
-{
- dialog_.reset(new QSpellcheckerDialog(this));
-
- bcview().setCancel(dialog_->closePB);
- dialog_->wordED->setReadOnly(true);
-}
-
-
-void QSpellchecker::update_contents()
-{
- if (isVisible() || controller().exitEarly())
- controller().check();
-}
-
-
-void QSpellchecker::accept()
-{
- controller().ignoreAll();
-}
-
-
-void QSpellchecker::add()
-{
- controller().insert();
-}
-
-
-void QSpellchecker::ignore()
-{
- controller().check();
-}
-
-
-void QSpellchecker::replace()
-{
- controller().replace(qstring_to_ucs4(dialog_->replaceCO->currentText()));
-}
-
-
-void QSpellchecker::partialUpdate(int s)
-{
- ControlSpellchecker::State const state =
- static_cast<ControlSpellchecker::State>(s);
-
- switch (state) {
-
- case ControlSpellchecker::SPELL_PROGRESSED:
- dialog_->spellcheckPR->setValue(controller().getProgress());
- break;
-
- case ControlSpellchecker::SPELL_FOUND_WORD: {
- dialog_->wordED->setText(toqstr(controller().getWord()));
- dialog_->suggestionsLW->clear();
-
- docstring w;
- while (!(w = controller().getSuggestion()).empty()) {
- dialog_->suggestionsLW->addItem(toqstr(w));
- }
-
- if (dialog_->suggestionsLW->count() == 0) {
- dialog_->suggestionChanged(new QListWidgetItem(dialog_->wordED->text()));
- } else {
- dialog_->suggestionChanged(dialog_->suggestionsLW->item(0));
- }
-
- dialog_->suggestionsLW->setCurrentRow(0);
- }
- break;
-
- }
-}
-
-} // namespace frontend
-} // namespace lyx
-
-#include "QSpellchecker_moc.cpp"
+++ /dev/null
-// -*- C++ -*-
-/**
- * \file QSpellchecker.h
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author John Levon
- * \author Kalle Dalheimer
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#ifndef QSPELLCHECKER_H
-#define QSPELLCHECKER_H
-
-#include "QDialogView.h"
-#include "ui_SpellcheckerUi.h"
-
-#include <QDialog>
-#include <QCloseEvent>
-
-class QListWidgetItem;
-
-namespace lyx {
-namespace frontend {
-
-class QSpellchecker;
-
-class QSpellcheckerDialog: public QDialog, public Ui::QSpellcheckerUi {
- Q_OBJECT
-public:
- QSpellcheckerDialog(QSpellchecker * form);
-public Q_SLOTS:
- virtual void suggestionChanged(QListWidgetItem *);
-
-protected Q_SLOTS:
- virtual void acceptClicked();
- virtual void addClicked();
- virtual void replaceClicked();
- virtual void ignoreClicked();
- virtual void replaceChanged(const QString &);
- virtual void reject();
-
-protected:
- virtual void closeEvent(QCloseEvent * e);
-
-private:
- QSpellchecker * form_;
-};
-
-
-class ControlSpellchecker;
-
-class QSpellchecker
- : public QController<ControlSpellchecker, QView<QSpellcheckerDialog> >
-{
-public:
- friend class QSpellcheckerDialog;
-
- QSpellchecker(Dialog &);
-
- /// update from controller
- void partialUpdate(int id);
-private:
- void accept();
- void add();
- void ignore();
- void replace();
-
- /// Apply changes
- virtual void apply() {}
- ///
- virtual void update_contents();
- /// build the dialog
- virtual void build_dialog();
-};
-
-} // namespace frontend
-} // namespace lyx
-
-#endif // QSPELLCHECKER_H
+++ /dev/null
-/**
- * \file QTabular.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author John Levon
- * \author Jürgen Spitzmüller
- * \author Herbert Voß
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "CheckedLineEdit.h"
-#include "QTabular.h"
-#include "Qt2BC.h"
-
-#include "LengthCombo.h"
-#include "Validator.h"
-#include "qt_helpers.h"
-
-#include "controllers/ButtonController.h"
-#include "controllers/ControlTabular.h"
-
-#include "support/convert.h"
-
-#include <QCloseEvent>
-#include <QCheckBox>
-#include <QPushButton>
-#include <QRadioButton>
-#include <QLineEdit>
-
-#include "QSetBorder.h"
-
-using std::string;
-
-namespace lyx {
-namespace frontend {
-
-/////////////////////////////////////////////////////////////////////
-//
-// QTabularDialog
-//
-/////////////////////////////////////////////////////////////////////
-
-QTabularDialog::QTabularDialog(QTabular * form)
- : form_(form)
-{
- setupUi(this);
-
- widthED->setValidator(unsignedLengthValidator(widthED));
- topspaceED->setValidator(new LengthValidator(topspaceED));
- bottomspaceED->setValidator(new LengthValidator(bottomspaceED));
- interlinespaceED->setValidator(new LengthValidator(interlinespaceED));
-
- connect(topspaceED, SIGNAL(returnPressed()),
- this, SLOT(topspace_changed()));
- connect(topspaceUnit, SIGNAL(selectionChanged(lyx::Length::UNIT)),
- this, SLOT(topspace_changed()));
- connect(topspaceCO, SIGNAL(activated(int)), this, SLOT(topspace_changed()));
- connect(bottomspaceED, SIGNAL(returnPressed()),
- this, SLOT(bottomspace_changed()));
- connect(bottomspaceUnit, SIGNAL(selectionChanged(lyx::Length::UNIT)),
- this, SLOT(bottomspace_changed()));
- connect(bottomspaceCO, SIGNAL(activated(int)), this, SLOT(bottomspace_changed()));
- connect(interlinespaceED, SIGNAL(returnPressed()),
- this, SLOT(interlinespace_changed()));
- connect(interlinespaceUnit, SIGNAL(selectionChanged(lyx::Length::UNIT)),
- this, SLOT(interlinespace_changed()));
- connect(interlinespaceCO, SIGNAL(activated(int)), this, SLOT(interlinespace_changed()));
- connect(booktabsRB, SIGNAL(clicked(bool)), this, SLOT(booktabsChanged(bool)));
- connect(borderDefaultRB, SIGNAL(clicked(bool)), this, SLOT(booktabsChanged(bool)));
- connect(borderSetPB, SIGNAL(clicked()), this, SLOT(borderSet_clicked()));
- connect(borderUnsetPB, SIGNAL(clicked()), this, SLOT(borderUnset_clicked()));
- connect(longTabularCB, SIGNAL(toggled(bool)), longtableGB, SLOT(setEnabled(bool)));
- connect(longTabularCB, SIGNAL(toggled(bool)), newpageCB, SLOT(setEnabled(bool)));
- connect(hAlignCB, SIGNAL(activated(int)), this, SLOT(hAlign_changed(int)));
- connect(vAlignCB, SIGNAL(activated(int)), this, SLOT(vAlign_changed(int)));
- connect(multicolumnCB, SIGNAL(clicked()), this, SLOT(multicolumn_clicked()));
- connect(newpageCB, SIGNAL(clicked()), this, SLOT(ltNewpage_clicked()));
- connect(headerStatusCB, SIGNAL(clicked()), this, SLOT(ltHeaderStatus_clicked()));
- connect(headerBorderAboveCB, SIGNAL(clicked()), this, SLOT(ltHeaderBorderAbove_clicked()));
- connect(headerBorderBelowCB, SIGNAL(clicked()), this, SLOT(ltHeaderBorderBelow_clicked()));
- connect(firstheaderStatusCB, SIGNAL(clicked()), this, SLOT(ltFirstHeaderStatus_clicked()));
- connect(firstheaderBorderAboveCB, SIGNAL(clicked()), this, SLOT(ltFirstHeaderBorderAbove_clicked()));
- connect(firstheaderBorderBelowCB, SIGNAL(clicked()), this, SLOT(ltFirstHeaderBorderBelow_clicked()));
- connect(firstheaderNoContentsCB, SIGNAL(clicked()), this, SLOT(ltFirstHeaderEmpty_clicked()));
- connect(footerStatusCB, SIGNAL(clicked()), this, SLOT(ltFooterStatus_clicked()));
- connect(footerBorderAboveCB, SIGNAL(clicked()), this, SLOT(ltFooterBorderAbove_clicked()));
- connect(footerBorderBelowCB, SIGNAL(clicked()), this, SLOT(ltFooterBorderBelow_clicked()));
- connect(lastfooterStatusCB, SIGNAL(clicked()), this, SLOT(ltLastFooterStatus_clicked()));
- connect(lastfooterBorderAboveCB, SIGNAL(clicked()), this, SLOT(ltLastFooterBorderAbove_clicked()));
- connect(lastfooterBorderBelowCB, SIGNAL(clicked()), this, SLOT(ltLastFooterBorderBelow_clicked()));
- connect(lastfooterNoContentsCB, SIGNAL(clicked()), this, SLOT(ltLastFooterEmpty_clicked()));
- connect(specialAlignmentED, SIGNAL(returnPressed()), this, SLOT(specialAlignment_changed()));
- connect(widthED, SIGNAL(returnPressed()), this, SLOT(width_changed()));
- connect(widthUnit, SIGNAL(selectionChanged(lyx::Length::UNIT)), this, SLOT(width_changed()));
- connect(closePB, SIGNAL(clicked()), this, SLOT(close_clicked()));
- connect(borders, SIGNAL(topSet(bool)), this, SLOT(topBorder_changed()));
- connect(borders, SIGNAL(bottomSet(bool)), this, SLOT(bottomBorder_changed()));
- connect(borders, SIGNAL(rightSet(bool)), this, SLOT(rightBorder_changed()));
- connect(borders, SIGNAL(leftSet(bool)), this, SLOT(leftBorder_changed()));
- connect(rotateTabularCB, SIGNAL(clicked()), this, SLOT(rotateTabular()));
- connect(rotateCellCB, SIGNAL(clicked()), this, SLOT(rotateCell()));
- connect(longTabularCB, SIGNAL(clicked()), this, SLOT(longTabular()));
-}
-
-
-void QTabularDialog::change_adaptor()
-{
- form_->changed();
-}
-
-
-void QTabularDialog::closeEvent(QCloseEvent * e)
-{
- form_->slotWMHide();
- e->accept();
-}
-
-
-void QTabularDialog::booktabsChanged(bool)
-{
- form_->changed();
- form_->controller().booktabs(booktabsRB->isChecked());
- form_->update_borders();
-}
-
-
-void QTabularDialog::topspace_changed()
-{
- switch(topspaceCO->currentIndex()) {
- case 0: {
- form_->controller().set(Tabular::SET_TOP_SPACE, "");
- topspaceED->setEnabled(false);
- topspaceUnit->setEnabled(false);
- break;
- }
- case 1: {
- form_->controller().set(Tabular::SET_TOP_SPACE, "default");
- topspaceED->setEnabled(false);
- topspaceUnit->setEnabled(false);
- break;
- }
- case 2: {
- if (!topspaceED->text().isEmpty())
- form_->controller().set(Tabular::SET_TOP_SPACE,
- widgetsToLength(topspaceED, topspaceUnit));
- if (!form_->bc().bp().isReadOnly()) {
- topspaceED->setEnabled(true);
- topspaceUnit->setEnabled(true);
- }
- break;
- }
- }
- form_->changed();
-}
-
-
-void QTabularDialog::bottomspace_changed()
-{
- switch(bottomspaceCO->currentIndex()) {
- case 0: {
- form_->controller().set(Tabular::SET_BOTTOM_SPACE, "");
- bottomspaceED->setEnabled(false);
- bottomspaceUnit->setEnabled(false);
- break;
- }
- case 1: {
- form_->controller().set(Tabular::SET_BOTTOM_SPACE, "default");
- bottomspaceED->setEnabled(false);
- bottomspaceUnit->setEnabled(false);
- break;
- }
- case 2: {
- if (!bottomspaceED->text().isEmpty())
- form_->controller().set(Tabular::SET_BOTTOM_SPACE,
- widgetsToLength(bottomspaceED, bottomspaceUnit));
- if (!form_->bc().bp().isReadOnly()) {
- bottomspaceED->setEnabled(true);
- bottomspaceUnit->setEnabled(true);
- }
- break;
- }
- }
- form_->changed();
-}
-
-
-void QTabularDialog::interlinespace_changed()
-{
- switch(interlinespaceCO->currentIndex()) {
- case 0: {
- form_->controller().set(Tabular::SET_INTERLINE_SPACE, "");
- interlinespaceED->setEnabled(false);
- interlinespaceUnit->setEnabled(false);
- break;
- }
- case 1: {
- form_->controller().set(Tabular::SET_INTERLINE_SPACE, "default");
- interlinespaceED->setEnabled(false);
- interlinespaceUnit->setEnabled(false);
- break;
- }
- case 2: {
- if (!interlinespaceED->text().isEmpty())
- form_->controller().set(Tabular::SET_INTERLINE_SPACE,
- widgetsToLength(interlinespaceED, interlinespaceUnit));
- if (!form_->bc().bp().isReadOnly()) {
- interlinespaceED->setEnabled(true);
- interlinespaceUnit->setEnabled(true);
- }
- break;
- }
- }
- form_->changed();
-}
-
-
-void QTabularDialog::close_clicked()
-{
- form_->closeGUI();
- form_->slotClose();
-}
-
-
-void QTabularDialog::borderSet_clicked()
-{
- form_->controller().set(Tabular::SET_ALL_LINES);
- form_->update_borders();
- form_->changed();
-}
-
-
-void QTabularDialog::borderUnset_clicked()
-{
- form_->controller().set(Tabular::UNSET_ALL_LINES);
- form_->update_borders();
- form_->changed();
-}
-
-
-void QTabularDialog::leftBorder_changed()
-{
- form_->controller().toggleLeftLine();
- form_->changed();
-}
-
-
-void QTabularDialog::rightBorder_changed()
-{
- form_->controller().toggleRightLine();
- form_->changed();
-}
-
-
-void QTabularDialog::topBorder_changed()
-{
- form_->controller().toggleTopLine();
- form_->changed();
-}
-
-
-void QTabularDialog::bottomBorder_changed()
-{
- form_->controller().toggleBottomLine();
- form_->changed();
-}
-
-
-void QTabularDialog::specialAlignment_changed()
-{
- string special = fromqstr(specialAlignmentED->text());
- form_->controller().setSpecial(special);
- form_->changed();
-}
-
-
-void QTabularDialog::width_changed()
-{
- form_->changed();
- string const width = widgetsToLength(widthED, widthUnit);
- form_->controller().setWidth(width);
-}
-
-
-void QTabularDialog::multicolumn_clicked()
-{
- form_->controller().toggleMultiColumn();
- form_->changed();
-}
-
-
-void QTabularDialog::rotateTabular()
-{
- form_->controller().rotateTabular(rotateTabularCB->isChecked());
- form_->changed();
-}
-
-
-void QTabularDialog::rotateCell()
-{
- form_->controller().rotateCell(rotateCellCB->isChecked());
- form_->changed();
-}
-
-
-void QTabularDialog::hAlign_changed(int align)
-{
- ControlTabular::HALIGN h = ControlTabular::LEFT;
-
- switch (align) {
- case 0: h = ControlTabular::LEFT; break;
- case 1: h = ControlTabular::CENTER; break;
- case 2: h = ControlTabular::RIGHT; break;
- case 3: h = ControlTabular::BLOCK; break;
- }
-
- form_->controller().halign(h);
-}
-
-
-void QTabularDialog::vAlign_changed(int align)
-{
- ControlTabular::VALIGN v = ControlTabular::TOP;
-
- switch (align) {
- case 0: v = ControlTabular::TOP; break;
- case 1: v = ControlTabular::MIDDLE; break;
- case 2: v = ControlTabular::BOTTOM; break;
- }
-
- form_->controller().valign(v);
-}
-
-
-void QTabularDialog::longTabular()
-{
- form_->controller().longTabular(longTabularCB->isChecked());
- form_->changed();
-}
-
-
-void QTabularDialog::ltNewpage_clicked()
-{
- form_->controller().set(Tabular::SET_LTNEWPAGE);
- form_->changed();
-}
-
-
-void QTabularDialog::ltHeaderStatus_clicked()
-{
- bool enable(headerStatusCB->isChecked());
- if (enable)
- form_->controller().set(Tabular::SET_LTHEAD, "");
- else
- form_->controller().set(Tabular::UNSET_LTHEAD, "");
- headerBorderAboveCB->setEnabled(enable);
- headerBorderBelowCB->setEnabled(enable);
- firstheaderNoContentsCB->setEnabled(enable);
- form_->changed();
-}
-
-
-void QTabularDialog::ltHeaderBorderAbove_clicked()
-{
- if (headerBorderAboveCB->isChecked())
- form_->controller().set(Tabular::SET_LTHEAD, "dl_above");
- else
- form_->controller().set(Tabular::UNSET_LTHEAD, "dl_above");
- form_->changed();
-}
-
-
-void QTabularDialog::ltHeaderBorderBelow_clicked()
-{
- if (headerBorderBelowCB->isChecked())
- form_->controller().set(Tabular::SET_LTHEAD, "dl_below");
- else
- form_->controller().set(Tabular::UNSET_LTHEAD, "dl_below");
- form_->changed();
-}
-
-
-void QTabularDialog::ltFirstHeaderBorderAbove_clicked()
-{
- if (firstheaderBorderAboveCB->isChecked())
- form_->controller().set(Tabular::SET_LTFIRSTHEAD, "dl_above");
- else
- form_->controller().set(Tabular::UNSET_LTFIRSTHEAD, "dl_above");
- form_->changed();
-}
-
-
-void QTabularDialog::ltFirstHeaderBorderBelow_clicked()
-{
- if (firstheaderBorderBelowCB->isChecked())
- form_->controller().set(Tabular::SET_LTFIRSTHEAD, "dl_below");
- else
- form_->controller().set(Tabular::UNSET_LTFIRSTHEAD, "dl_below");
- form_->changed();
-}
-
-
-void QTabularDialog::ltFirstHeaderStatus_clicked()
-{
- bool enable(firstheaderStatusCB->isChecked());
- if (enable)
- form_->controller().set(Tabular::SET_LTFIRSTHEAD, "");
- else
- form_->controller().set(Tabular::UNSET_LTFIRSTHEAD, "");
- firstheaderBorderAboveCB->setEnabled(enable);
- firstheaderBorderBelowCB->setEnabled(enable);
- form_->changed();
-}
-
-
-void QTabularDialog::ltFirstHeaderEmpty_clicked()
-{
- bool enable(firstheaderNoContentsCB->isChecked());
- if (enable)
- form_->controller().set(Tabular::SET_LTFIRSTHEAD, "empty");
- else
- form_->controller().set(Tabular::UNSET_LTFIRSTHEAD, "empty");
- firstheaderStatusCB->setEnabled(!enable);
- firstheaderBorderAboveCB->setEnabled(!enable);
- firstheaderBorderBelowCB->setEnabled(!enable);
- form_->changed();
-}
-
-
-void QTabularDialog::ltFooterStatus_clicked()
-{
- bool enable(footerStatusCB->isChecked());
- if (enable)
- form_->controller().set(Tabular::SET_LTFOOT, "");
- else
- form_->controller().set(Tabular::UNSET_LTFOOT, "");
- footerBorderAboveCB->setEnabled(enable);
- footerBorderBelowCB->setEnabled(enable);
- lastfooterNoContentsCB->setEnabled(enable);
- form_->changed();
-}
-
-
-void QTabularDialog::ltFooterBorderAbove_clicked()
-{
- if (footerBorderAboveCB->isChecked())
- form_->controller().set(Tabular::SET_LTFOOT, "dl_above");
- else
- form_->controller().set(Tabular::UNSET_LTFOOT, "dl_above");
- form_->changed();
-}
-
-
-void QTabularDialog::ltFooterBorderBelow_clicked()
-{
- if (footerBorderBelowCB->isChecked())
- form_->controller().set(Tabular::SET_LTFOOT, "dl_below");
- else
- form_->controller().set(Tabular::UNSET_LTFOOT, "dl_below");
- form_->changed();
-}
-
-
-void QTabularDialog::ltLastFooterStatus_clicked()
-{
- bool enable(lastfooterStatusCB->isChecked());
- if (enable)
- form_->controller().set(Tabular::SET_LTLASTFOOT, "");
- else
- form_->controller().set(Tabular::UNSET_LTLASTFOOT, "");
- lastfooterBorderAboveCB->setEnabled(enable);
- lastfooterBorderBelowCB->setEnabled(enable);
- form_->changed();
-}
-
-
-void QTabularDialog::ltLastFooterBorderAbove_clicked()
-{
- if (lastfooterBorderAboveCB->isChecked())
- form_->controller().set(Tabular::SET_LTLASTFOOT, "dl_above");
- else
- form_->controller().set(Tabular::UNSET_LTLASTFOOT, "dl_above");
- form_->changed();
-}
-
-
-void QTabularDialog::ltLastFooterBorderBelow_clicked()
-{
- if (lastfooterBorderBelowCB->isChecked())
- form_->controller().set(Tabular::SET_LTLASTFOOT, "dl_below");
- else
- form_->controller().set(Tabular::UNSET_LTLASTFOOT, "dl_below");
- form_->changed();
-}
-
-
-void QTabularDialog::ltLastFooterEmpty_clicked()
-{
- bool enable(lastfooterNoContentsCB->isChecked());
- if (enable)
- form_->controller().set(Tabular::SET_LTLASTFOOT, "empty");
- else
- form_->controller().set(Tabular::UNSET_LTLASTFOOT, "empty");
- lastfooterStatusCB->setEnabled(!enable);
- lastfooterBorderAboveCB->setEnabled(!enable);
- lastfooterBorderBelowCB->setEnabled(!enable);
- form_->changed();
-}
-
-
-/////////////////////////////////////////////////////////////////////
-//
-// QTabular
-//
-/////////////////////////////////////////////////////////////////////
-
-typedef QController<ControlTabular, QView<QTabularDialog> > tabular_base_class;
-
-QTabular::QTabular(Dialog & parent)
- : tabular_base_class(parent, _("Table Settings"))
-{
-}
-
-
-void QTabular::build_dialog()
-{
- dialog_.reset(new QTabularDialog(this));
-
- bcview().setCancel(dialog_->closePB);
-
- bcview().addReadOnly(dialog_->topspaceED);
- bcview().addReadOnly(dialog_->topspaceUnit);
- bcview().addReadOnly(dialog_->topspaceCO);
- bcview().addReadOnly(dialog_->bottomspaceED);
- bcview().addReadOnly(dialog_->bottomspaceUnit);
- bcview().addReadOnly(dialog_->bottomspaceCO);
- bcview().addReadOnly(dialog_->interlinespaceED);
- bcview().addReadOnly(dialog_->interlinespaceUnit);
- bcview().addReadOnly(dialog_->interlinespaceCO);
- bcview().addReadOnly(dialog_->borderDefaultRB);
- bcview().addReadOnly(dialog_->booktabsRB);
-
- bcview().addReadOnly(dialog_->multicolumnCB);
- bcview().addReadOnly(dialog_->rotateCellCB);
- bcview().addReadOnly(dialog_->rotateTabularCB);
- bcview().addReadOnly(dialog_->specialAlignmentED);
- bcview().addReadOnly(dialog_->widthED);
- bcview().addReadOnly(dialog_->widthUnit);
- bcview().addReadOnly(dialog_->hAlignCB);
- bcview().addReadOnly(dialog_->vAlignCB);
- bcview().addReadOnly(dialog_->borderSetPB);
- bcview().addReadOnly(dialog_->borderUnsetPB);
- bcview().addReadOnly(dialog_->borders);
- bcview().addReadOnly(dialog_->longTabularCB);
- bcview().addReadOnly(dialog_->headerStatusCB);
- bcview().addReadOnly(dialog_->headerBorderAboveCB);
- bcview().addReadOnly(dialog_->headerBorderBelowCB);
- bcview().addReadOnly(dialog_->firstheaderStatusCB);
- bcview().addReadOnly(dialog_->firstheaderBorderAboveCB);
- bcview().addReadOnly(dialog_->firstheaderBorderBelowCB);
- bcview().addReadOnly(dialog_->firstheaderNoContentsCB);
- bcview().addReadOnly(dialog_->footerStatusCB);
- bcview().addReadOnly(dialog_->footerBorderAboveCB);
- bcview().addReadOnly(dialog_->footerBorderBelowCB);
- bcview().addReadOnly(dialog_->lastfooterStatusCB);
- bcview().addReadOnly(dialog_->lastfooterBorderAboveCB);
- bcview().addReadOnly(dialog_->lastfooterBorderBelowCB);
- bcview().addReadOnly(dialog_->lastfooterNoContentsCB);
- bcview().addReadOnly(dialog_->newpageCB);
-
- // initialize the length validator
- addCheckedLineEdit(bcview(), dialog_->widthED,
- dialog_->fixedWidthColLA);
- addCheckedLineEdit(bcview(), dialog_->topspaceED,
- dialog_->topspaceLA);
- addCheckedLineEdit(bcview(), dialog_->bottomspaceED,
- dialog_->bottomspaceLA);
- addCheckedLineEdit(bcview(), dialog_->interlinespaceED,
- dialog_->interlinespaceLA);
-}
-
-
-bool QTabular::isValid()
-{
- return true;
-}
-
-
-void QTabular::update_borders()
-{
- Tabular const & tabular = controller().tabular();
- Tabular::idx_type const cell = controller().getActiveCell();
- bool const isMulticolumnCell = tabular.isMultiColumn(cell);
-
- if (!isMulticolumnCell) {
- dialog_->borders->setLeftEnabled(true);
- dialog_->borders->setRightEnabled(true);
- dialog_->borders->setTop(tabular.topLine(cell, true));
- dialog_->borders->setBottom(tabular.bottomLine(cell, true));
- dialog_->borders->setLeft(tabular.leftLine(cell, true));
- dialog_->borders->setRight(tabular.rightLine(cell, true));
- // repaint the setborder widget
- dialog_->borders->update();
- return;
- }
-
- dialog_->borders->setTop(tabular.topLine(cell));
- dialog_->borders->setBottom(tabular.bottomLine(cell));
- // pay attention to left/right lines: they are only allowed
- // to set if we are in first/last cell of row or if the left/right
- // cell is also a multicolumn.
- if (tabular.isFirstCellInRow(cell) || tabular.isMultiColumn(cell - 1)) {
- dialog_->borders->setLeftEnabled(true);
- dialog_->borders->setLeft(tabular.leftLine(cell));
- } else {
- dialog_->borders->setLeft(false);
- dialog_->borders->setLeftEnabled(false);
- }
- if (tabular.isLastCellInRow(cell) || tabular.isMultiColumn(cell + 1)) {
- dialog_->borders->setRightEnabled(true);
- dialog_->borders->setRight(tabular.rightLine(cell));
- } else {
- dialog_->borders->setRight(false);
- dialog_->borders->setRightEnabled(false);
- }
- // repaint the setborder widget
- dialog_->borders->update();
-}
-
-
-void QTabular::update_contents()
-{
- controller().initialiseParams(string());
-
- Tabular const & tabular(controller().tabular());
- Tabular::idx_type const cell = controller().getActiveCell();
-
- Tabular::row_type const row(tabular.row_of_cell(cell));
- Tabular::col_type const col(tabular.column_of_cell(cell));
-
- dialog_->tabularRowED->setText(toqstr(convert<string>(row + 1)));
- dialog_->tabularColumnED->setText(toqstr(convert<string>(col + 1)));
-
- bool const multicol(tabular.isMultiColumn(cell));
-
- dialog_->multicolumnCB->setChecked(multicol);
-
- dialog_->rotateCellCB->setChecked(tabular.getRotateCell(cell));
- dialog_->rotateTabularCB->setChecked(tabular.getRotateTabular());
-
- dialog_->longTabularCB->setChecked(tabular.isLongTabular());
-
- update_borders();
-
- Length pwidth;
- docstring special;
-
- if (multicol) {
- special = tabular.getAlignSpecial(cell, Tabular::SET_SPECIAL_MULTI);
- pwidth = tabular.getMColumnPWidth(cell);
- } else {
- special = tabular.getAlignSpecial(cell, Tabular::SET_SPECIAL_COLUMN);
- pwidth = tabular.getColumnPWidth(cell);
- }
-
- dialog_->specialAlignmentED->setText(toqstr(special));
-
- bool const isReadonly = bc().bp().isReadOnly();
- dialog_->specialAlignmentED->setEnabled(!isReadonly);
-
- Length::UNIT default_unit = controller().useMetricUnits() ? Length::CM : Length::IN;
-
- dialog_->borderDefaultRB->setChecked(!tabular.useBookTabs());
- dialog_->booktabsRB->setChecked(tabular.useBookTabs());
-
- if (tabular.row_info[row].top_space.empty()
- && !tabular.row_info[row].top_space_default) {
- dialog_->topspaceCO->setCurrentIndex(0);
- } else if (tabular.row_info[row].top_space_default) {
- dialog_->topspaceCO->setCurrentIndex(1);
- } else {
- dialog_->topspaceCO->setCurrentIndex(2);
- lengthToWidgets(dialog_->topspaceED,
- dialog_->topspaceUnit,
- tabular.row_info[row].top_space.asString(),
- default_unit);
- }
- dialog_->topspaceED->setEnabled(!isReadonly
- && (dialog_->topspaceCO->currentIndex() == 2));
- dialog_->topspaceUnit->setEnabled(!isReadonly
- && (dialog_->topspaceCO->currentIndex() == 2));
- dialog_->topspaceCO->setEnabled(!isReadonly);
-
- if (tabular.row_info[row].bottom_space.empty()
- && !tabular.row_info[row].bottom_space_default) {
- dialog_->bottomspaceCO->setCurrentIndex(0);
- } else if (tabular.row_info[row].bottom_space_default) {
- dialog_->bottomspaceCO->setCurrentIndex(1);
- } else {
- dialog_->bottomspaceCO->setCurrentIndex(2);
- lengthToWidgets(dialog_->bottomspaceED,
- dialog_->bottomspaceUnit,
- tabular.row_info[row].bottom_space.asString(),
- default_unit);
- }
- dialog_->bottomspaceED->setEnabled(!isReadonly
- && (dialog_->bottomspaceCO->currentIndex() == 2));
- dialog_->bottomspaceUnit->setEnabled(!isReadonly
- && (dialog_->bottomspaceCO->currentIndex() == 2));
- dialog_->bottomspaceCO->setEnabled(!isReadonly);
-
- if (tabular.row_info[row].interline_space.empty()
- && !tabular.row_info[row].interline_space_default) {
- dialog_->interlinespaceCO->setCurrentIndex(0);
- } else if (tabular.row_info[row].interline_space_default) {
- dialog_->interlinespaceCO->setCurrentIndex(1);
- } else {
- dialog_->interlinespaceCO->setCurrentIndex(2);
- lengthToWidgets(dialog_->interlinespaceED,
- dialog_->interlinespaceUnit,
- tabular.row_info[row].interline_space.asString(),
- default_unit);
- }
- dialog_->interlinespaceED->setEnabled(!isReadonly
- && (dialog_->interlinespaceCO->currentIndex() == 2));
- dialog_->interlinespaceUnit->setEnabled(!isReadonly
- && (dialog_->interlinespaceCO->currentIndex() == 2));
- dialog_->interlinespaceCO->setEnabled(!isReadonly);
-
- string colwidth;
- if (!pwidth.zero())
- colwidth = pwidth.asString();
- lengthToWidgets(dialog_->widthED, dialog_->widthUnit,
- colwidth, default_unit);
-
- dialog_->widthED->setEnabled(!isReadonly);
- dialog_->widthUnit->setEnabled(!isReadonly);
-
- dialog_->hAlignCB->clear();
- dialog_->hAlignCB->addItem(qt_("Left"));
- dialog_->hAlignCB->addItem(qt_("Center"));
- dialog_->hAlignCB->addItem(qt_("Right"));
- if (!multicol && !pwidth.zero())
- dialog_->hAlignCB->addItem(qt_("Justified"));
-
- int align = 0;
- switch (tabular.getAlignment(cell)) {
- case LYX_ALIGN_LEFT:
- align = 0;
- break;
- case LYX_ALIGN_CENTER:
- align = 1;
- break;
- case LYX_ALIGN_RIGHT:
- align = 2;
- break;
- case LYX_ALIGN_BLOCK:
- {
- if (!multicol && !pwidth.zero())
- align = 3;
- break;
- }
- default:
- align = 0;
- break;
- }
- dialog_->hAlignCB->setCurrentIndex(align);
-
- int valign = 0;
- switch (tabular.getVAlignment(cell)) {
- case Tabular::LYX_VALIGN_TOP:
- valign = 0;
- break;
- case Tabular::LYX_VALIGN_MIDDLE:
- valign = 1;
- break;
- case Tabular::LYX_VALIGN_BOTTOM:
- valign = 2;
- break;
- default:
- valign = 1;
- break;
- }
- if (pwidth.zero())
- valign = 1;
- dialog_->vAlignCB->setCurrentIndex(valign);
-
- dialog_->hAlignCB->setEnabled(true);
- dialog_->vAlignCB->setEnabled(!pwidth.zero());
-
- if (!tabular.isLongTabular()) {
- dialog_->headerStatusCB->setChecked(false);
- dialog_->headerBorderAboveCB->setChecked(false);
- dialog_->headerBorderBelowCB->setChecked(false);
- dialog_->firstheaderStatusCB->setChecked(false);
- dialog_->firstheaderBorderAboveCB->setChecked(false);
- dialog_->firstheaderBorderBelowCB->setChecked(false);
- dialog_->firstheaderNoContentsCB->setChecked(false);
- dialog_->footerStatusCB->setChecked(false);
- dialog_->footerBorderAboveCB->setChecked(false);
- dialog_->footerBorderBelowCB->setChecked(false);
- dialog_->lastfooterStatusCB->setChecked(false);
- dialog_->lastfooterBorderAboveCB->setChecked(false);
- dialog_->lastfooterBorderBelowCB->setChecked(false);
- dialog_->lastfooterNoContentsCB->setChecked(false);
- dialog_->newpageCB->setChecked(false);
- dialog_->newpageCB->setEnabled(false);
- return;
- }
-
- Tabular::ltType ltt;
- bool use_empty;
- bool row_set = tabular.getRowOfLTHead(row, ltt);
- dialog_->headerStatusCB->setChecked(row_set);
- if (ltt.set) {
- dialog_->headerBorderAboveCB->setChecked(ltt.topDL);
- dialog_->headerBorderBelowCB->setChecked(ltt.bottomDL);
- use_empty = true;
- } else {
- dialog_->headerBorderAboveCB->setChecked(false);
- dialog_->headerBorderBelowCB->setChecked(false);
- dialog_->headerBorderAboveCB->setEnabled(false);
- dialog_->headerBorderBelowCB->setEnabled(false);
- dialog_->firstheaderNoContentsCB->setChecked(false);
- dialog_->firstheaderNoContentsCB->setEnabled(false);
- use_empty = false;
- }
-
- row_set = tabular.getRowOfLTFirstHead(row, ltt);
- dialog_->firstheaderStatusCB->setChecked(row_set);
- if (ltt.set && (!ltt.empty || !use_empty)) {
- dialog_->firstheaderBorderAboveCB->setChecked(ltt.topDL);
- dialog_->firstheaderBorderBelowCB->setChecked(ltt.bottomDL);
- } else {
- dialog_->firstheaderBorderAboveCB->setEnabled(false);
- dialog_->firstheaderBorderBelowCB->setEnabled(false);
- dialog_->firstheaderBorderAboveCB->setChecked(false);
- dialog_->firstheaderBorderBelowCB->setChecked(false);
- if (use_empty) {
- dialog_->firstheaderNoContentsCB->setChecked(ltt.empty);
- if (ltt.empty)
- dialog_->firstheaderStatusCB->setEnabled(false);
- }
- }
-
- row_set = tabular.getRowOfLTFoot(row, ltt);
- dialog_->footerStatusCB->setChecked(row_set);
- if (ltt.set) {
- dialog_->footerBorderAboveCB->setChecked(ltt.topDL);
- dialog_->footerBorderBelowCB->setChecked(ltt.bottomDL);
- use_empty = true;
- } else {
- dialog_->footerBorderAboveCB->setChecked(false);
- dialog_->footerBorderBelowCB->setChecked(false);
- dialog_->footerBorderAboveCB->setEnabled(false);
- dialog_->footerBorderBelowCB->setEnabled(false);
- dialog_->lastfooterNoContentsCB->setChecked(false);
- dialog_->lastfooterNoContentsCB->setEnabled(false);
- use_empty = false;
- }
-
- row_set = tabular.getRowOfLTLastFoot(row, ltt);
- dialog_->lastfooterStatusCB->setChecked(row_set);
- if (ltt.set && (!ltt.empty || !use_empty)) {
- dialog_->lastfooterBorderAboveCB->setChecked(ltt.topDL);
- dialog_->lastfooterBorderBelowCB->setChecked(ltt.bottomDL);
- } else {
- dialog_->lastfooterBorderAboveCB->setEnabled(false);
- dialog_->lastfooterBorderBelowCB->setEnabled(false);
- dialog_->lastfooterBorderAboveCB->setChecked(false);
- dialog_->lastfooterBorderBelowCB->setChecked(false);
- if (use_empty) {
- dialog_->lastfooterNoContentsCB->setChecked(ltt.empty);
- if (ltt.empty)
- dialog_->lastfooterStatusCB->setEnabled(false);
- }
- }
- dialog_->newpageCB->setChecked(tabular.getLTNewPage(row));
-}
-
-
-void QTabular::closeGUI()
-{
- // ugly hack to auto-apply the stuff that hasn't been
- // yet. don't let this continue to exist ...
-
- // Subtle here, we must /not/ apply any changes and
- // then refer to tabular, as it will have been freed
- // since the changes update the actual controller().tabular()
- Tabular const & tabular(controller().tabular());
-
- // apply the fixed width values
- Tabular::idx_type const cell = controller().getActiveCell();
- bool const multicol = tabular.isMultiColumn(cell);
- string width = widgetsToLength(dialog_->widthED, dialog_->widthUnit);
- string width2;
-
- Length llen = tabular.getColumnPWidth(cell);
- Length llenMulti = tabular.getMColumnPWidth(cell);
-
- if (multicol && !llenMulti.zero())
- width2 = llenMulti.asString();
- else if (!multicol && !llen.zero())
- width2 = llen.asString();
-
- // apply the special alignment
- docstring const sa1 = qstring_to_ucs4(dialog_->specialAlignmentED->text());
- docstring sa2;
-
- if (multicol)
- sa2 = tabular.getAlignSpecial(cell, Tabular::SET_SPECIAL_MULTI);
- else
- sa2 = tabular.getAlignSpecial(cell, Tabular::SET_SPECIAL_COLUMN);
-
- if (sa1 != sa2) {
- if (multicol)
- controller().set(Tabular::SET_SPECIAL_MULTI, to_utf8(sa1));
- else
- controller().set(Tabular::SET_SPECIAL_COLUMN, to_utf8(sa1));
- }
-
- if (width != width2) {
- if (multicol)
- controller().set(Tabular::SET_MPWIDTH, width);
- else
- controller().set(Tabular::SET_PWIDTH, width);
- }
-
- /* DO WE NEED THIS?
- switch (dialog_->topspaceCO->currentIndex()) {
- case 0:
- controller().set(Tabular::SET_TOP_SPACE, "");
- break;
- case 1:
- controller().set(Tabular::SET_TOP_SPACE, "default");
- break;
- case 2:
- controller().set(Tabular::SET_TOP_SPACE,
- widgetsToLength(dialog_->topspaceED,
- dialog_->topspaceUnit));
- break;
- }
-
- switch (dialog_->bottomspaceCO->currentIndex()) {
- case 0:
- controller().set(Tabular::SET_BOTTOM_SPACE, "");
- break;
- case 1:
- controller().set(Tabular::SET_BOTTOM_SPACE, "default");
- break;
- case 2:
- controller().set(Tabular::SET_BOTTOM_SPACE,
- widgetsToLength(dialog_->bottomspaceED,
- dialog_->bottomspaceUnit));
- break;
- }
-
- switch (dialog_->interlinespaceCO->currentIndex()) {
- case 0:
- controller().set(Tabular::SET_INTERLINE_SPACE, "");
- break;
- case 1:
- controller().set(Tabular::SET_INTERLINE_SPACE, "default");
- break;
- case 2:
- controller().set(Tabular::SET_INTERLINE_SPACE,
- widgetsToLength(dialog_->interlinespaceED,
- dialog_->interlinespaceUnit));
- break;
- }
-*/
-}
-
-} // namespace frontend
-} // namespace lyx
-
-#include "QTabular_moc.cpp"
+++ /dev/null
-// -*- C++ -*-
-/**
- * \file QTabular.h
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author John Levon
- * \author Kalle Dalheimer
- * \author Jürgen Spitzmüller
- * \author Herbert Voß
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#ifndef QTABULAR_H
-#define QTABULAR_H
-
-#include "QDialogView.h"
-
-#include "ui_TabularUi.h"
-
-#include <QDialog>
-#include <QCloseEvent>
-
-namespace lyx {
-namespace frontend {
-
-class QTabular;
-
-class QTabularDialog : public QDialog, public Ui::QTabularUi {
- Q_OBJECT
-public:
- QTabularDialog(QTabular * form);
-
-protected Q_SLOTS:
- virtual void change_adaptor();
-
- virtual void topspace_changed();
- virtual void bottomspace_changed();
- virtual void interlinespace_changed();
- virtual void booktabsChanged(bool);
- virtual void close_clicked();
- virtual void borderSet_clicked();
- virtual void borderUnset_clicked();
- virtual void leftBorder_changed();
- virtual void rightBorder_changed();
- virtual void topBorder_changed();
- virtual void bottomBorder_changed();
- virtual void multicolumn_clicked();
- virtual void rotateTabular();
- virtual void rotateCell();
- virtual void hAlign_changed(int align);
- virtual void vAlign_changed(int align);
- virtual void specialAlignment_changed();
- virtual void width_changed();
- virtual void longTabular();
- virtual void ltNewpage_clicked();
- virtual void ltHeaderStatus_clicked();
- virtual void ltHeaderBorderAbove_clicked();
- virtual void ltHeaderBorderBelow_clicked();
- virtual void ltFirstHeaderStatus_clicked();
- virtual void ltFirstHeaderBorderAbove_clicked();
- virtual void ltFirstHeaderBorderBelow_clicked();
- virtual void ltFirstHeaderEmpty_clicked();
- virtual void ltFooterStatus_clicked();
- virtual void ltFooterBorderAbove_clicked();
- virtual void ltFooterBorderBelow_clicked();
- virtual void ltLastFooterStatus_clicked();
- virtual void ltLastFooterBorderAbove_clicked();
- virtual void ltLastFooterBorderBelow_clicked();
- virtual void ltLastFooterEmpty_clicked();
-
-protected:
- virtual void closeEvent(QCloseEvent * e);
-
-private:
- QTabular * form_;
-};
-
-
-class ControlTabular;
-
-class QTabular :
- public QController<ControlTabular, QView<QTabularDialog> >
-{
-public:
- friend class QTabularDialog;
-
- QTabular(Dialog &);
-
-protected:
- virtual bool isValid();
-
-private:
- /// We can't use this ...
- virtual void apply() {}
- /// update borders
- virtual void update_borders();
- /// update
- virtual void update_contents();
- /// build the dialog
- virtual void build_dialog();
- /// save some values before closing the gui
- virtual void closeGUI();
-};
-
-} // namespace frontend
-} // namespace lyx
-
-#endif // QTABULAR_H
+++ /dev/null
-/**
- * \file QTabularCreate.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author John Levon
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "QTabularCreate.h"
-#include "Qt2BC.h"
-#include "EmptyTable.h"
-
-#include "controllers/ControlTabularCreate.h"
-
-#include <QSpinBox>
-#include <QPushButton>
-
-namespace lyx {
-namespace frontend {
-
-/////////////////////////////////////////////////////////////////////
-//
-// QTabularCreateDialog
-//
-/////////////////////////////////////////////////////////////////////
-
-QTabularCreateDialog::QTabularCreateDialog(QTabularCreate * form)
- : form_(form)
-{
- setupUi(this);
-
- rowsSB->setValue(5);
- columnsSB->setValue(5);
-
- connect(okPB, SIGNAL(clicked()), form_, SLOT(slotOK()));
- connect(closePB, SIGNAL(clicked()), form_, SLOT(slotClose()));
-
- connect(rowsSB, SIGNAL(valueChanged(int)),
- this, SLOT(rowsChanged(int)));
- connect(columnsSB, SIGNAL(valueChanged(int)),
- this, SLOT(columnsChanged(int)));
-}
-
-
-void QTabularCreateDialog::columnsChanged(int)
-{
- form_->changed();
-}
-
-
-void QTabularCreateDialog::rowsChanged(int)
-{
- form_->changed();
-}
-
-
-/////////////////////////////////////////////////////////////////////
-//
-// QTabularCreate
-//
-/////////////////////////////////////////////////////////////////////
-
-typedef QController<ControlTabularCreate, QView<QTabularCreateDialog> >
- TabularCreateBase;
-
-
-QTabularCreate::QTabularCreate(Dialog & parent)
- : TabularCreateBase(parent, _("Insert Table"))
-{
-}
-
-
-void QTabularCreate::build_dialog()
-{
- dialog_.reset(new QTabularCreateDialog(this));
-
- bcview().setOK(dialog_->okPB);
- bcview().setCancel(dialog_->closePB);
-}
-
-
-void QTabularCreate::apply()
-{
- controller().params().first = dialog_->rowsSB->value();
- controller().params().second = dialog_->columnsSB->value();
-}
-
-} // namespace frontend
-} // namespace lyx
-
-#include "QTabularCreate_moc.cpp"
+++ /dev/null
-// -*- C++ -*-
-/**
- * \file QTabularCreate.h
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author John Levon
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#ifndef QTABULARCREATE_H
-#define QTABULARCREATE_H
-
-#include "QDialogView.h"
-#include "ui_TabularCreateUi.h"
-
-#include <QDialog>
-
-namespace lyx {
-namespace frontend {
-
-class QTabularCreate;
-
-class QTabularCreateDialog : public QDialog, public Ui::QTabularCreateUi {
- Q_OBJECT
-public:
- QTabularCreateDialog(QTabularCreate * form);
-protected Q_SLOTS:
- virtual void columnsChanged(int);
- virtual void rowsChanged(int);
-private:
- QTabularCreate * form_;
-};
-
-
-class ControlTabularCreate;
-
-class QTabularCreate
- : public QController<ControlTabularCreate, QView<QTabularCreateDialog> >
-{
-public:
- ///
- friend class QTabularCreateDialog;
- ///
- QTabularCreate(Dialog &);
-private:
- /// Apply changes
- virtual void apply();
- /// update
- virtual void update_contents() {}
- /// build the dialog
- virtual void build_dialog();
-};
-
-} // namespace frontend
-} // namespace lyx
-
-#endif // QTABULARCREATE_H
+++ /dev/null
-/**
- * \file QTexinfo.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Edwin Leuven
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "QTexinfo.h"
-#include "Qt2BC.h"
-#include "qt_helpers.h"
-
-#include "support/filetools.h"
-
-#include <QCheckBox>
-#include <QListWidget>
-#include <QPushButton>
-
-using std::string;
-using std::vector;
-
-namespace lyx {
-namespace frontend {
-
-/////////////////////////////////////////////////////////////////////
-//
-// QTexinfoDialog
-//
-/////////////////////////////////////////////////////////////////////
-
-
-QTexinfoDialog::QTexinfoDialog(QTexinfo * form)
- : form_(form)
-{
- setupUi(this);
-
- connect(closePB, SIGNAL(clicked()), form, SLOT(slotClose()));
-
- connect(viewPB, SIGNAL(clicked()), this, SLOT(viewClicked()));
- connect(whatStyleCO, SIGNAL(activated(const QString &)),
- this, SLOT(enableViewPB()));
- connect(whatStyleCO, SIGNAL(activated(int)), this, SLOT(update()));
- connect(pathCB, SIGNAL(stateChanged(int)), this, SLOT(update()));
- connect(rescanPB, SIGNAL(clicked()), this, SLOT(enableViewPB()));
- connect(rescanPB, SIGNAL(clicked()), this, SLOT(rescanClicked()));
- connect(fileListLW, SIGNAL(itemClicked(QListWidgetItem *)),
- this, SLOT( enableViewPB() ) );
- connect(fileListLW, SIGNAL(itemSelectionChanged()),
- this, SLOT(enableViewPB()));
-}
-
-
-void QTexinfoDialog::change_adaptor()
-{
- form_->changed();
-}
-
-
-void QTexinfoDialog::closeEvent(QCloseEvent * e)
-{
- form_->slotWMHide();
- e->accept();
-}
-
-
-void QTexinfoDialog::rescanClicked()
-{
- // build new *Files.lst
- rescanTexStyles();
- form_->updateStyles();
- enableViewPB();
-}
-
-
-void QTexinfoDialog::viewClicked()
-{
- vector<string>::size_type const fitem = fileListLW->currentRow();
- vector<string> const & data = form_->texdata_[form_->activeStyle];
- string file = data[fitem];
- if (!pathCB->isChecked())
- file = getTexFileFromList(data[fitem],
- form_->controller().getFileType(form_->activeStyle));
- form_->controller().viewFile(file);
-}
-
-
-void QTexinfoDialog::update()
-{
- switch (whatStyleCO->currentIndex()) {
- case 0:
- form_->updateStyles(ControlTexinfo::cls);
- break;
- case 1:
- form_->updateStyles(ControlTexinfo::sty);
- break;
- case 2:
- form_->updateStyles(ControlTexinfo::bst);
- break;
- default:
- break;
- }
-
- enableViewPB();
-}
-
-
-void QTexinfoDialog::enableViewPB()
-{
- viewPB->setEnabled(fileListLW->currentRow() > -1);
-}
-
-
-
-/////////////////////////////////////////////////////////////////////
-//
-// QTexinfo
-//
-/////////////////////////////////////////////////////////////////////
-
-typedef QController<ControlTexinfo, QView<QTexinfoDialog> > texinfo_base_class;
-
-QTexinfo::QTexinfo(Dialog & parent)
- : texinfo_base_class(parent, _("TeX Information")),
- warningPosted(false), activeStyle(ControlTexinfo::cls)
-{
-}
-
-
-void QTexinfo::build_dialog()
-{
- dialog_.reset(new QTexinfoDialog(this));
-
- updateStyles(ControlTexinfo::cls);
-
- bcview().setCancel(dialog_->closePB);
-}
-
-
-void QTexinfo::updateStyles(ControlTexinfo::texFileSuffix whichStyle)
-{
- ContentsType & data = texdata_[whichStyle];
- bool const withFullPath = dialog_->pathCB->isChecked();
-
- getTexFileList(whichStyle, data, withFullPath);
-
- dialog_->fileListLW->clear();
- ContentsType::const_iterator it = data.begin();
- ContentsType::const_iterator end = data.end();
- for (; it != end; ++it)
- dialog_->fileListLW->addItem(toqstr(*it));
-
- activeStyle = whichStyle;
-}
-
-
-void QTexinfo::updateStyles()
-{
- updateStyles(activeStyle);
-}
-
-} // namespace frontend
-} // namespace lyx
-
-
-#include "QTexinfo_moc.cpp"
+++ /dev/null
-// -*- C++ -*-
-/**
- * \file QTexinfo.h
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Edwin Leuven
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#ifndef QTEXINFO_H
-#define QTEXINFO_H
-
-#include "QDialogView.h"
-
-#include "ControlTexinfo.h"
-#include "ui_TexinfoUi.h"
-
-#include <QDialog>
-#include <QCloseEvent>
-
-#include <map>
-#include <vector>
-
-namespace lyx {
-namespace frontend {
-
-class QTexinfo;
-
-class QTexinfoDialog : public QDialog, public Ui::QTexinfoUi {
- Q_OBJECT
-public:
- QTexinfoDialog(QTexinfo * form);
-public Q_SLOTS:
- virtual void update();
-protected Q_SLOTS:
- virtual void change_adaptor();
- virtual void rescanClicked();
- virtual void viewClicked();
- virtual void enableViewPB();
-protected:
- virtual void closeEvent(QCloseEvent * e);
-private:
- QTexinfo * form_;
-};
-
-
-///
-class QTexinfo
- : public QController<ControlTexinfo, QView<QTexinfoDialog> > {
-public:
- ///
- friend class QTexinfoDialog;
- ///
- QTexinfo(Dialog &);
-private:
- /// Apply changes
- virtual void apply() {}
- /// update (do we need this?)
- virtual void update_contents() {}
- /// build the dialog
- virtual void build_dialog();
- ///
- void updateStyles(ControlTexinfo::texFileSuffix);
- ///
- void updateStyles();
- ///
- bool warningPosted;
- ///
- ControlTexinfo::texFileSuffix activeStyle;
- ///
- typedef std::vector<std::string> ContentsType;
- std::map<ControlTexinfo::texFileSuffix, ContentsType> texdata_;
-};
-
-} // namespace frontend
-} // namespace lyx
-
-#endif // QTEXINFO_H
+++ /dev/null
-/**
- * \file QThesaurus.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author John Levon
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "QThesaurus.h"
-#include "Qt2BC.h"
-#include "qt_helpers.h"
-#include "debug.h"
-
-#include "controllers/ControlThesaurus.h"
-
-#include <QHeaderView>
-#include <QLineEdit>
-#include <QPushButton>
-#include <QTreeWidget>
-#include <QTreeWidgetItem>
-
-using std::string;
-
-namespace lyx {
-namespace frontend {
-
-/////////////////////////////////////////////////////////////////////
-//
-// QTheasurusDialog
-//
-/////////////////////////////////////////////////////////////////////
-
-QThesaurusDialog::QThesaurusDialog(QThesaurus * form)
- : form_(form)
-{
- setupUi(this);
-
- meaningsTV->setColumnCount(1);
- meaningsTV->header()->hide();
-
- connect(closePB, SIGNAL(clicked()),
- form, SLOT(slotClose()));
- connect(replaceED, SIGNAL(returnPressed()),
- this, SLOT(replaceClicked()));
- connect(replaceED, SIGNAL(textChanged(const QString &)),
- this, SLOT(change_adaptor() ) );
- connect(entryED, SIGNAL(returnPressed()),
- this, SLOT(entryChanged()));
- connect(replacePB, SIGNAL(clicked()),
- this, SLOT(replaceClicked()));
- connect(meaningsTV, SIGNAL(itemClicked(QTreeWidgetItem *, int)),
- this, SLOT(itemClicked(QTreeWidgetItem *, int)));
- connect(meaningsTV, SIGNAL(itemSelectionChanged()),
- this, SLOT(selectionChanged()));
- connect(meaningsTV, SIGNAL(itemActivated(QTreeWidgetItem *, int)),
- this, SLOT(selectionClicked(QTreeWidgetItem *, int)));
-}
-
-
-void QThesaurusDialog::change_adaptor()
-{
- form_->changed();
-}
-
-
-void QThesaurusDialog::closeEvent(QCloseEvent * e)
-{
- form_->slotWMHide();
- e->accept();
-}
-
-
-void QThesaurusDialog::entryChanged()
-{
- updateLists();
-}
-
-
-void QThesaurusDialog::replaceClicked()
-{
- form_->replace();
-}
-
-
-void QThesaurusDialog::selectionChanged()
-{
- int const col = meaningsTV->currentColumn();
- if (col<0 || form_->readOnly())
- return;
-
- replaceED->setText(meaningsTV->currentItem()->text(col));
- replacePB->setEnabled(true);
- form_->changed();
-}
-
-
-void QThesaurusDialog::itemClicked(QTreeWidgetItem * /*item*/, int /*col*/)
-{
- selectionChanged();
-}
-
-
-void QThesaurusDialog::selectionClicked(QTreeWidgetItem * item, int col)
-{
- entryED->setText(item->text(col));
- selectionChanged();
- updateLists();
-}
-
-
-void QThesaurusDialog::updateLists()
-{
- meaningsTV->clear();
- meaningsTV->setUpdatesEnabled(false);
-
- Thesaurus::Meanings meanings = form_->controller().getMeanings(qstring_to_ucs4(entryED->text()));
-
- for (Thesaurus::Meanings::const_iterator cit = meanings.begin();
- cit != meanings.end(); ++cit) {
- QTreeWidgetItem * i = new QTreeWidgetItem(meaningsTV);
- i->setText(0, toqstr(cit->first));
- meaningsTV->expandItem(i);
- for (std::vector<docstring>::const_iterator cit2 = cit->second.begin();
- cit2 != cit->second.end(); ++cit2) {
- QTreeWidgetItem * i2 = new QTreeWidgetItem(i);
- i2->setText(0, toqstr(*cit2));
- }
- }
-
- meaningsTV->setUpdatesEnabled(true);
- meaningsTV->update();
-}
-
-
-/////////////////////////////////////////////////////////////////////
-//
-// QThesuarus
-//
-/////////////////////////////////////////////////////////////////////
-
-typedef QController<ControlThesaurus, QView<QThesaurusDialog> > ThesaurusBase;
-
-QThesaurus::QThesaurus(Dialog & parent)
- : ThesaurusBase(parent, _("Thesaurus"))
-{
-}
-
-
-void QThesaurus::build_dialog()
-{
- dialog_.reset(new QThesaurusDialog(this));
-
- bcview().setCancel(dialog_->closePB);
- bcview().setApply(dialog_->replacePB);
- bcview().addReadOnly(dialog_->replaceED);
- bcview().addReadOnly(dialog_->replacePB);
-}
-
-
-void QThesaurus::update_contents()
-{
- dialog_->entryED->setText(toqstr(controller().text()));
- dialog_->replaceED->setText("");
- dialog_->updateLists();
-}
-
-
-void QThesaurus::replace()
-{
- controller().replace(qstring_to_ucs4(dialog_->replaceED->text()));
-}
-
-} // namespace frontend
-} // namespace lyx
-
-
-#include "QThesaurus_moc.cpp"
+++ /dev/null
-// -*- C++ -*-
-/**
- * \file QThesaurus.h
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author John Levon
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#ifndef QTHESAURUS_H
-#define QTHESAURUS_H
-
-#include "QDialogView.h"
-#include "ui_ThesaurusUi.h"
-
-#include <QDialog>
-#include <QCloseEvent>
-
-
-class QTreeWidgetItem;
-
-namespace lyx {
-namespace frontend {
-
-class ControlThesaurus;
-
-class QThesaurus;
-
-class QThesaurusDialog : public QDialog, public Ui::QThesaurusUi {
- Q_OBJECT
-public:
- QThesaurusDialog(QThesaurus * form);
-
- void updateLists();
-protected Q_SLOTS:
- virtual void change_adaptor();
- virtual void entryChanged();
- virtual void replaceClicked();
- virtual void selectionChanged();
- virtual void selectionClicked(QTreeWidgetItem *, int);
- virtual void itemClicked(QTreeWidgetItem *, int);
-protected:
- virtual void closeEvent(QCloseEvent * e);
-private:
- QThesaurus * form_;
-};
-
-
-///
-class QThesaurus
- : public QController<ControlThesaurus, QView<QThesaurusDialog> >
-{
-public:
- ///
- friend class QThesaurusDialog;
- ///
- QThesaurus(Dialog &);
-private:
- /// Apply changes
- virtual void apply() {}
- /// update
- virtual void update_contents();
- /// build the dialog
- virtual void build_dialog();
-
- /// replace the word
- void replace();
-};
-
-} // namespace frontend
-} // namespace lyx
-
-#endif // QTHESAURUS_H
+++ /dev/null
-/**
- * \file QToc.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author John Levon
- * \author Abdelrazak Younes
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "QToc.h"
-
-#include "TocModel.h"
-#include "Qt2BC.h"
-#include "qt_helpers.h"
-
-#include "debug.h"
-
-#include "controllers/ControlToc.h"
-
-#include <algorithm>
-
-using std::endl;
-
-using std::pair;
-using std::vector;
-using std::string;
-
-namespace lyx {
-namespace frontend {
-
-
-QToc::QToc(Dialog & dialog, QObject * parent)
- : QObject(parent), ControlToc(dialog)
-{
-}
-
-
-bool QToc::canOutline(int type) const
-{
- if (type < 0)
- return false;
-
- return ControlToc::canOutline(type);
-}
-
-
-int QToc::getTocDepth(int type)
-{
- if (type < 0)
- return 0;
- return toc_models_[type]->modelDepth();
-}
-
-
-QStandardItemModel * QToc::tocModel(int type)
-{
- if (type < 0)
- return 0;
-
- if (toc_models_.empty()) {
- LYXERR(Debug::GUI) << "QToc::tocModel(): no types available " << endl;
- return 0;
- }
-
- LYXERR(Debug::GUI)
- << "QToc: type " << type
- << " toc_models_.size() " << toc_models_.size()
- << endl;
-
- BOOST_ASSERT(type >= 0 && type < int(toc_models_.size()));
- return toc_models_[type];
-}
-
-
-QModelIndex const QToc::getCurrentIndex(int type) const
-{
- if (type < 0)
- return QModelIndex();
-
- // FIXME: The TocBackend infrastructure is not ready for LOF and LOT
- // This is because a proper ParConstIterator is not constructed in
- // InsetCaption::addToToc()
- if(!canOutline(type))
- return QModelIndex();
-
- return toc_models_[type]->modelIndex(getCurrentTocItem(type));
-}
-
-
-void QToc::goTo(int type, QModelIndex const & index)
-{
- if (type < 0 || !index.isValid()
- || index.model() != toc_models_[type]) {
- LYXERR(Debug::GUI)
- << "QToc::goTo(): QModelIndex is invalid!"
- << endl;
- return;
- }
-
- BOOST_ASSERT(type >= 0 && type < int(toc_models_.size()));
-
- TocIterator const it = toc_models_[type]->tocIterator(index);
-
- LYXERR(Debug::GUI) << "QToc::goTo " << to_utf8(it->str()) << endl;
-
- ControlToc::goTo(*it);
-}
-
-
-bool QToc::initialiseParams(std::string const & data)
-{
- if (!ControlToc::initialiseParams(data))
- return false;
- update();
- modelReset();
- return true;
-}
-
-
-void QToc::update()
-{
- toc_models_.clear();
- TocList::const_iterator it = tocs().begin();
- TocList::const_iterator end = tocs().end();
- for (; it != end; ++it)
- toc_models_.push_back(new TocModel(it->second));
-}
-
-
-} // namespace frontend
-} // namespace lyx
-
-#include "QToc_moc.cpp"
+++ /dev/null
-// -*- C++ -*-
-/**
- * \file QToc.h
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author John Levon
- * \author Kalle Dalheimer
- * \author Abdelrazak Younes
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#ifndef QTOC_H
-#define QTOC_H
-
-#include "ControlToc.h"
-
-#include <QObject>
-#include <QStandardItemModel>
-#include <QStringListModel>
-
-namespace lyx {
-namespace frontend {
-
-class ControlToc;
-class TocModel;
-
-class QToc : public QObject, public ControlToc
-{
- Q_OBJECT
-public:
-
- QToc(Dialog &, QObject * parent = 0);
- virtual ~QToc() {}
-
- /// \c ControlToc inherited method.
- virtual bool initialiseParams(std::string const & data);
- ///
- void update();
- ///
- bool canOutline(int type) const;
-
- QStandardItemModel * tocModel(int type);
- ///
- QModelIndex const getCurrentIndex(int type) const;
- ///
- void goTo(int type, QModelIndex const & index);
- ///
- int getType();
- ///
- int getTocDepth(int type);
-
-Q_SIGNALS:
- /// Signal that the internal toc_models_ has been reset.
- void modelReset();
-
-private:
- ///
- std::vector<TocModel *> toc_models_;
-};
-
-} // namespace frontend
-} // namespace lyx
-
-#endif // QTOC_H
+++ /dev/null
-/**
- * \file QURLDialog.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author John Levon
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "QURLDialog.h"
-#include "UrlView.h"
-
-#include <QLineEdit>
-#include <QPushButton>
-#include <QCloseEvent>
-
-namespace lyx {
-namespace frontend {
-
-QURLDialog::QURLDialog(UrlView * form)
- : form_(form)
-{
- setupUi(this);
-
- connect(okPB, SIGNAL(clicked()), form_, SLOT(slotOK()));
- connect(closePB, SIGNAL(clicked()), form_, SLOT(slotClose()));
- connect(urlED, SIGNAL(textChanged(const QString &)),
- this, SLOT(changed_adaptor()));
- connect(hyperlinkCB, SIGNAL(clicked()),
- this, SLOT(changed_adaptor()));
- connect(nameED, SIGNAL(textChanged(const QString &)),
- this, SLOT(changed_adaptor()));
-
- setFocusProxy(urlED);
-}
-
-
-void QURLDialog::changed_adaptor()
-{
- form_->changed();
-}
-
-
-void QURLDialog::closeEvent(QCloseEvent * e)
-{
- form_->slotWMHide();
- e->accept();
-}
-
-} // namespace frontend
-} // namespace lyx
-
-#include "QURLDialog_moc.cpp"
+++ /dev/null
-// -*- C++ -*-
-/**
- * \file QURLDialog.h
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author John Levon
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#ifndef QURLDIALOG_H
-#define QURLDIALOG_H
-
-#include "ui_URLUi.h"
-
-#include <QDialog>
-#include <QCloseEvent>
-
-namespace lyx {
-namespace frontend {
-
-class UrlView;
-
-class QURLDialog : public QDialog, public Ui::QURLUi {
- Q_OBJECT
-public:
- QURLDialog(UrlView * form);
-public Q_SLOTS:
- void changed_adaptor();
-protected:
- void closeEvent(QCloseEvent *);
-private:
- UrlView * form_;
-};
-
-} // namespace frontend
-} // namespace lyx
-
-#endif // QURLDIALOG_H
+++ /dev/null
-/**
- * \file QVSpace.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author André Pönitz
- * \author Jürgen Vigna
- * \author Rob Lahaye
- * \author Angus Leeming
- * \author Edwin Leuven
- * \author Jürgen Spitzmüller
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "QVSpace.h"
-#include "Qt2BC.h"
-
-#include "CheckedLineEdit.h"
-#include "LengthCombo.h"
-#include "qt_helpers.h"
-#include "Validator.h"
-
-#include "LyXRC.h" // to set the default length values
-#include "Spacing.h"
-#include "VSpace.h"
-
-#include "controllers/ControlVSpace.h"
-#include "controllers/frontend_helpers.h"
-
-#include "support/lstrings.h"
-
-#include <QCheckBox>
-#include <QCloseEvent>
-#include <QLineEdit>
-#include <QPushButton>
-#include <QValidator>
-
-
-using std::string;
-
-namespace lyx {
-namespace frontend {
-
-
-/////////////////////////////////////////////////////////////////////
-//
-// QVSpaceDialog
-//
-/////////////////////////////////////////////////////////////////////
-
-
-QVSpaceDialog::QVSpaceDialog(QVSpace * form)
- : form_(form)
-{
- setupUi(this);
-
- connect(okPB, SIGNAL(clicked()), form_, SLOT(slotOK()));
- connect(applyPB, SIGNAL(clicked()), form_, SLOT(slotApply()));
- connect(closePB, SIGNAL(clicked()), form_, SLOT(slotClose()));
-
- connect(spacingCO, SIGNAL(highlighted(const QString &)),
- this, SLOT(change_adaptor()));
- connect(valueLE, SIGNAL(textChanged(const QString &)),
- this, SLOT(change_adaptor()));
- connect(spacingCO, SIGNAL(activated(int)),
- this, SLOT(enableCustom(int)));
- connect(keepCB, SIGNAL(clicked()),
- this, SLOT(change_adaptor()));
- connect(unitCO, SIGNAL(selectionChanged(lyx::Length::UNIT)),
- this, SLOT(change_adaptor()));
-
- valueLE->setValidator(unsignedLengthValidator(valueLE));
-}
-
-
-void QVSpaceDialog::closeEvent(QCloseEvent * e)
-{
- form_->slotWMHide();
- e->accept();
-}
-
-
-void QVSpaceDialog::change_adaptor()
-{
- form_->changed();
-}
-
-
-void QVSpaceDialog::enableCustom(int selection)
-{
- bool const enable = selection == 5;
- valueLE->setEnabled(enable);
- unitCO->setEnabled(enable);
-}
-
-
-/////////////////////////////////////////////////////////////////////
-//
-// QVSpace
-//
-/////////////////////////////////////////////////////////////////////
-
-static void setWidgetsFromVSpace(VSpace const & space,
- QComboBox * spacing,
- QLineEdit * value,
- LengthCombo * unit,
- QCheckBox * keep)
-{
- int item = 0;
- switch (space.kind()) {
- case VSpace::DEFSKIP:
- item = 0;
- break;
- case VSpace::SMALLSKIP:
- item = 1;
- break;
- case VSpace::MEDSKIP:
- item = 2;
- break;
- case VSpace::BIGSKIP:
- item = 3;
- break;
- case VSpace::VFILL:
- item = 4;
- break;
- case VSpace::LENGTH:
- item = 5;
- break;
- }
- spacing->setCurrentIndex(item);
- keep->setChecked(space.keep());
-
- Length::UNIT default_unit =
- (lyxrc.default_papersize > 3) ? Length::CM : Length::IN;
- bool const custom_vspace = space.kind() == VSpace::LENGTH;
- if (custom_vspace) {
- value->setEnabled(true);
- unit->setEnabled(true);
- string length = space.length().asString();
- lengthToWidgets(value, unit, length, default_unit);
- } else {
- lengthToWidgets(value, unit, "", default_unit);
- value->setEnabled(false);
- unit->setEnabled(false);
- }
-}
-
-
-static VSpace setVSpaceFromWidgets(int spacing,
- QLineEdit * value,
- LengthCombo * unit,
- bool keep)
-{
- VSpace space;
-
- switch (spacing) {
- case 0:
- space = VSpace(VSpace::DEFSKIP);
- break;
- case 1:
- space = VSpace(VSpace::SMALLSKIP);
- break;
- case 2:
- space = VSpace(VSpace::MEDSKIP);
- break;
- case 3:
- space = VSpace(VSpace::BIGSKIP);
- break;
- case 4:
- space = VSpace(VSpace::VFILL);
- break;
- case 5:
- space = VSpace(GlueLength(widgetsToLength(value, unit)));
- break;
- }
-
- space.setKeep(keep);
- return space;
-}
-
-
-typedef QController<ControlVSpace, QView<QVSpaceDialog> > VSpaceBase;
-
-QVSpace::QVSpace(Dialog & parent)
- : VSpaceBase(parent, _("Vertical Space Settings"))
-{}
-
-
-void QVSpace::build_dialog()
-{
- // the tabbed folder
- dialog_.reset(new QVSpaceDialog(this));
-
- // Manage the ok, apply, restore and cancel/close buttons
- bcview().setOK(dialog_->okPB);
- bcview().setApply(dialog_->applyPB);
- bcview().setCancel(dialog_->closePB);
-
- // disable for read-only documents
- bcview().addReadOnly(dialog_->spacingCO);
- bcview().addReadOnly(dialog_->valueLE);
- bcview().addReadOnly(dialog_->unitCO);
- bcview().addReadOnly(dialog_->keepCB);
-
- // initialize the length validator
- addCheckedLineEdit(bcview(), dialog_->valueLE, dialog_->valueL);
-
- // remove the %-items from the unit choice
- dialog_->unitCO->noPercents();
-}
-
-
-void QVSpace::apply()
-{
- // spacing
- // If a vspace choice is "Length" but there's no text in
- // the input field, do not insert a vspace at all.
- if (dialog_->spacingCO->currentIndex() == 5
- && dialog_->valueLE->text().isEmpty())
- return;
-
- VSpace const space =
- setVSpaceFromWidgets(dialog_->spacingCO->currentIndex(),
- dialog_->valueLE,
- dialog_->unitCO,
- dialog_->keepCB->isChecked());
-
- controller().params() = space;
-}
-
-
-void QVSpace::update_contents()
-{
- setWidgetsFromVSpace(controller().params(),
- dialog_->spacingCO,
- dialog_->valueLE,
- dialog_->unitCO,
- dialog_->keepCB);
-}
-
-} // namespace frontend
-} // namespace lyx
-
-
-#include "QVSpace_moc.cpp"
+++ /dev/null
-// -*- C++ -*-
-/**
- * \file QVSpace.h
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author André Pönitz
- * \author Angus Leeming
- * \author Jürgen Spitzmüller
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#ifndef QVSPACE_H
-#define QVSPACE_H
-
-#include "QDialogView.h"
-
-#include "ui_VSpaceUi.h"
-
-#include <QDialog>
-
-class QCloseEvent;
-
-namespace lyx {
-namespace frontend {
-
-class ControlVSpace;
-
-class QVSpace;
-
-
-class QVSpaceDialog : public QDialog, public Ui::QVSpaceUi {
- Q_OBJECT
-
-public:
- QVSpaceDialog(QVSpace * form);
-
-public Q_SLOTS:
- void change_adaptor();
-
-protected Q_SLOTS:
- void closeEvent(QCloseEvent *);
- void enableCustom(int);
-
-private:
- QVSpace * form_;
-};
-
-
-
-class QVSpace
- : public QController<ControlVSpace, QView<QVSpaceDialog> >
-{
-public:
- ///
- friend class QVSpaceDialog;
- ///
- QVSpace(Dialog &);
-private:
- /// Build the dialog
- virtual void build_dialog();
- /// Apply from dialog
- virtual void apply();
- /// Update the dialog
- virtual void update_contents();
-};
-
-} // namespace frontend
-} // namespace lyx
-
-#endif //QVSPACE_H
+++ /dev/null
-/**
- * \file QViewSource.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author John Levon
- * \author Bo Peng
- * \author Abdelrazak Younes
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "QViewSource.h"
-#include "qt_helpers.h"
-
-#include <boost/tuple/tuple.hpp>
-
-#include <QTextCursor>
-#include <QTextDocument>
-
-namespace lyx {
-namespace frontend {
-
-/////////////////////////////////////////////////////////////////////
-//
-// QViewSourceDialog
-//
-/////////////////////////////////////////////////////////////////////
-
-QViewSourceDialog::QViewSourceDialog(QViewSource * form)
- : form_(form)
-{
- setupUi(this);
-
- connect(viewFullSourceCB, SIGNAL(clicked()),
- this, SLOT(update()));
- connect(autoUpdateCB, SIGNAL(toggled(bool)),
- updatePB, SLOT(setDisabled(bool)));
- connect(updatePB, SIGNAL(clicked()),
- this, SLOT(update()));
-
- // setting a document at this point trigger an assertion in Qt
- // so we disable the signals here:
- form_->document()->blockSignals(true);
- viewSourceTV->setDocument(form_->document());
- form_->document()->blockSignals(false);
- viewSourceTV->setReadOnly(true);
- ///dialog_->viewSourceTV->setAcceptRichText(false);
- // this is personal. I think source code should be in fixed-size font
- QFont font(toqstr(theApp()->typewriterFontName()));
- font.setKerning(false);
- font.setFixedPitch(true);
- font.setStyleHint(QFont::TypeWriter);
- viewSourceTV->setFont(font);
- // again, personal taste
- viewSourceTV->setWordWrapMode(QTextOption::NoWrap);
-}
-
-
-void QViewSourceDialog::update()
-{
- if (autoUpdateCB->isChecked())
- form_->update(viewFullSourceCB->isChecked());
-
- int beg, end;
- boost::tie(beg, end) = form_->getRows();
- QTextCursor c = QTextCursor(viewSourceTV->document());
- c.movePosition(QTextCursor::NextBlock, QTextCursor::MoveAnchor, beg);
- c.select(QTextCursor::BlockUnderCursor);
- c.movePosition(QTextCursor::NextBlock, QTextCursor::KeepAnchor, end - beg + 1);
- viewSourceTV->setTextCursor(c);
- QWidget::update();
-}
-
-
-/////////////////////////////////////////////////////////////////////
-//
-// LaTeXHighlighter
-//
-/////////////////////////////////////////////////////////////////////
-
-
-LaTeXHighlighter::LaTeXHighlighter(QTextDocument * parent)
- : QSyntaxHighlighter(parent)
-{
- keywordFormat.setForeground(Qt::darkBlue);
- keywordFormat.setFontWeight(QFont::Bold);
- commentFormat.setForeground(Qt::darkGray);
- mathFormat.setForeground(Qt::red);
-}
-
-
-void LaTeXHighlighter::highlightBlock(QString const & text)
-{
- // $ $
- QRegExp exprMath("\\$[^\\$]*\\$");
- int index = text.indexOf(exprMath);
- while (index >= 0) {
- int length = exprMath.matchedLength();
- setFormat(index, length, mathFormat);
- index = text.indexOf(exprMath, index + length);
- }
- // [ ]
- QRegExp exprStartDispMath("(\\\\\\[|"
- "\\\\begin\\{equation\\**\\}|"
- "\\\\begin\\{eqnarray\\**\\}|"
- "\\\\begin\\{align(ed|at)*\\**\\}|"
- "\\\\begin\\{flalign\\**\\}|"
- "\\\\begin\\{gather\\**\\}|"
- "\\\\begin\\{multline\\**\\}|"
- "\\\\begin\\{array\\**\\}|"
- "\\\\begin\\{cases\\**\\}"
- ")");
- QRegExp exprEndDispMath("(\\\\\\]|"
- "\\\\end\\{equation\\**\\}|"
- "\\\\end\\{eqnarray\\**\\}|"
- "\\\\end\\{align(ed|at)*\\**\\}|"
- "\\\\end\\{flalign\\**\\}|"
- "\\\\end\\{gather\\**\\}|"
- "\\\\end\\{multline\\**\\}|"
- "\\\\end\\{array\\**\\}|"
- "\\\\end\\{cases\\**\\}"
- ")");
- int startIndex = 0;
- // if previous block was in 'disp math'
- // start search from 0 (for end disp math)
- // otherwise, start search from 'begin disp math'
- if (previousBlockState() != 1)
- startIndex = text.indexOf(exprStartDispMath);
- while (startIndex >= 0) {
- int endIndex = text.indexOf(exprEndDispMath, startIndex);
- int length;
- if (endIndex == -1) {
- setCurrentBlockState(1);
- length = text.length() - startIndex;
- } else {
- length = endIndex - startIndex + exprEndDispMath.matchedLength();
- }
- setFormat(startIndex, length, mathFormat);
- startIndex = text.indexOf(exprStartDispMath, startIndex + length);
- }
- // \whatever
- QRegExp exprKeyword("\\\\[A-Za-z]+");
- index = text.indexOf(exprKeyword);
- while (index >= 0) {
- int length = exprKeyword.matchedLength();
- setFormat(index, length, keywordFormat);
- index = text.indexOf(exprKeyword, index + length);
- }
- // comment
- QRegExp exprComment("(^|[^\\\\])%.*$");
- index = text.indexOf(exprComment);
- while (index >= 0) {
- int const length = exprComment.matchedLength();
- setFormat(index, length, commentFormat);
- index = text.indexOf(exprComment, index + length);
- }
-}
-
-
-QViewSource::QViewSource(Dialog & parent)
- : ControlViewSource(parent)
-{
- document_ = new QTextDocument(this);
- highlighter_ = new LaTeXHighlighter(document_);
-}
-
-
-/////////////////////////////////////////////////////////////////////
-//
-// QViewSource
-//
-/////////////////////////////////////////////////////////////////////
-
-void QViewSource::update(bool full_source)
-{
- document_->setPlainText(toqstr(updateContent(full_source)));
-}
-
-
-} // namespace frontend
-} // namespace lyx
-
-#include "QViewSource_moc.cpp"
+++ /dev/null
-// -*- C++ -*-
-/**
- * \file QViewSource.h
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author John Levon
- * \author Bo Peng
- * \author Abdelrazak Younes
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#ifndef QVIEWSOURCE_H
-#define QVIEWSOURCE_H
-
-#include "frontends/controllers/ControlViewSource.h"
-#include "frontends/Application.h"
-#include "ui_ViewSourceUi.h"
-
-#include <QWidget>
-#include <QSyntaxHighlighter>
-#include <QTextCharFormat>
-
-class QTextDocument;
-
-namespace lyx {
-namespace frontend {
-
-// used already twice...
-class LaTeXHighlighter : public QSyntaxHighlighter
-{
-public:
- LaTeXHighlighter(QTextDocument * parent);
-
-protected:
- void highlightBlock(QString const & text);
-
-private:
- QTextCharFormat commentFormat;
- QTextCharFormat keywordFormat;
- QTextCharFormat mathFormat;
-};
-
-
-
-class QViewSource;
-
-class QViewSourceDialog : public QWidget, public Ui::QViewSourceUi {
- Q_OBJECT
-public:
- QViewSourceDialog(QViewSource * form);
-
-public Q_SLOTS:
- // update content
- void update();
-
-private:
- QViewSource * form_;
-};
-
-
-///
-class QViewSource : public QObject, public ControlViewSource {
-public:
- ///
- QViewSource(Dialog &);
- ///
- QTextDocument * document() { return document_; }
- ///
- void update(bool full_source);
-
-private:
- ///
- QTextDocument * document_;
- /// LaTeX syntax highlighter
- LaTeXHighlighter * highlighter_;
-};
-
-
-} // namespace frontend
-} // namespace lyx
-
-#endif // QVIEWSOURCE_H
+++ /dev/null
-/**
- * \file QWrap.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Jürgen Spitzmüller
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "QWrap.h"
-#include "Qt2BC.h"
-
-#include "LengthCombo.h"
-#include "qt_helpers.h"
-
-#include "controllers/ControlWrap.h"
-
-#include "insets/InsetWrap.h"
-
-#include "support/convert.h"
-#include "support/lstrings.h"
-
-#include <QLineEdit>
-#include <QCloseEvent>
-#include <QPushButton>
-
-
-using std::string;
-
-namespace lyx {
-namespace frontend {
-
-/////////////////////////////////////////////////////////////////////
-//
-// QWrapDialog
-//
-/////////////////////////////////////////////////////////////////////
-
-
-QWrapDialog::QWrapDialog(QWrap * form)
- : form_(form)
-{
- setupUi(this);
-
- connect(restorePB, SIGNAL(clicked()), form, SLOT(slotRestore()));
- connect(okPB, SIGNAL(clicked()), form, SLOT(slotOK()));
- connect(applyPB, SIGNAL(clicked()), form, SLOT(slotApply()));
- connect(closePB, SIGNAL(clicked()), form, SLOT(slotClose()));
-
- connect(widthED, SIGNAL(textChanged(const QString &)),
- this, SLOT(change_adaptor()));
- connect(unitsLC, SIGNAL(selectionChanged(lyx::Length::UNIT)),
- this, SLOT(change_adaptor()));
- connect(valignCO, SIGNAL(highlighted(const QString &)),
- this, SLOT(change_adaptor()));
-}
-
-
-void QWrapDialog::closeEvent(QCloseEvent * e)
-{
- form_->slotWMHide();
- e->accept();
-}
-
-
-void QWrapDialog::change_adaptor()
-{
- form_->changed();
-}
-
-/////////////////////////////////////////////////////////////////////
-//
-// QWrap
-//
-/////////////////////////////////////////////////////////////////////
-
-typedef QController<ControlWrap, QView<QWrapDialog> > wrap_base_class;
-
-QWrap::QWrap(Dialog & parent)
- : wrap_base_class(parent, _("Text Wrap Settings"))
-{
-}
-
-
-void QWrap::build_dialog()
-{
- dialog_.reset(new QWrapDialog(this));
-
- bcview().setRestore(dialog_->restorePB);
- bcview().setOK(dialog_->okPB);
- bcview().setApply(dialog_->applyPB);
- bcview().setCancel(dialog_->closePB);
-
- bcview().addReadOnly(dialog_->widthED);
- bcview().addReadOnly(dialog_->unitsLC);
- bcview().addReadOnly(dialog_->valignCO);
-}
-
-
-void QWrap::apply()
-{
- double const value = convert<double>(fromqstr(dialog_->widthED->text()));
- Length::UNIT unit = dialog_->unitsLC->currentLengthItem();
- if (dialog_->widthED->text().isEmpty())
- unit = Length::UNIT_NONE;
-
- InsetWrapParams & params = controller().params();
-
- params.width = Length(value, unit);
-
- switch (dialog_->valignCO->currentIndex()) {
- case 0:
- params.placement.erase();
- break;
- case 1:
- params.placement = "l";
- break;
- case 2:
- params.placement = "r";
- break;
- case 3:
- params.placement = "p";
- break;
- }
-}
-
-
-static string const numtostr(double val)
-{
- string a = convert<string>(val);
- // FIXME: Will this test ever trigger? (Lgb)
- if (a == "0")
- a.erase();
- return a;
-}
-
-
-void QWrap::update_contents()
-{
- InsetWrapParams & params = controller().params();
-
- Length len(params.width);
- dialog_->widthED->setText(toqstr(numtostr(len.value())));
- dialog_->unitsLC->setCurrentItem(len.unit());
-
- int item = 0;
- if (params.placement == "l")
- item = 1;
- else if (params.placement == "r")
- item = 2;
- else if (params.placement == "p")
- item = 3;
-
- dialog_->valignCO->setCurrentIndex(item);
-}
-
-} // namespace frontend
-} // namespace lyx
-
-
-#include "QWrap_moc.cpp"
+++ /dev/null
-// -*- C++ -*-
-/**
- * \file QWrap.h
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Jürgen Spitzmüller
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#ifndef QWRAP_H
-#define QWRAP_H
-
-#include "QDialogView.h"
-#include "ui_WrapUi.h"
-
-#include <QDialog>
-#include <QCloseEvent>
-
-namespace lyx {
-namespace frontend {
-
-class QWrap;
-
-class QWrapDialog : public QDialog, public Ui::QWrapUi {
- Q_OBJECT
-public:
- QWrapDialog(QWrap * form);
-protected Q_SLOTS:
- virtual void change_adaptor();
-protected:
- virtual void closeEvent(QCloseEvent * e);
-private:
- QWrap * form_;
-};
-
-
-class ControlWrap;
-
-class QWrap : public QController<ControlWrap, QView<QWrapDialog> > {
-public:
- friend class QWrapDialog;
-
- QWrap(Dialog &);
-private:
- /// Apply changes
- virtual void apply();
- /// update
- virtual void update_contents();
- /// build the dialog
- virtual void build_dialog();
-};
-
-} // namespace frontend
-} // namespace lyx
-
-#endif // QWRAP_H
/**
- * \file QTocDialog.C
+ * \file GuiTocDialog.C
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
#include "TocWidget.h"
-#include "QToc.h"
+#include "GuiToc.h"
#include "qt_helpers.h"
#include "support/filetools.h"
#include "support/lstrings.h"
namespace frontend {
-TocWidget::TocWidget(QToc * form, QWidget * parent)
+TocWidget::TocWidget(GuiToc * form, QWidget * parent)
: QWidget(parent), form_(form), depth_(0)
{
setupUi(this);
namespace lyx {
namespace frontend {
-class QToc;
+class GuiToc;
-class TocWidget : public QWidget, public Ui::QTocUi {
+class TocWidget : public QWidget, public Ui::TocUi {
Q_OBJECT
public:
- TocWidget(QToc * form, QWidget * parent = 0);
+ TocWidget(GuiToc * form, QWidget * parent = 0);
/// Update the display of the dialog whilst it is still visible.
void update();
//This is a workaround for a problem of signals blocking.
void disconnectSelectionModel();
- QToc * form_;
+ GuiToc * form_;
/// depth of list shown
int depth_;
#include <config.h>
#include "UrlView.h"
-#include "QURLDialog.h"
+#include "GuiURLDialog.h"
#include "Qt2BC.h"
#include "qt_helpers.h"
namespace lyx {
namespace frontend {
-typedef QController< ControlCommand, QView<QURLDialog> > urlview_base_class;
+typedef QController< ControlCommand, GuiView<GuiURLDialog> > urlview_base_class;
UrlView::UrlView(Dialog & parent)
: urlview_base_class(parent, _("URL"))
void UrlView::build_dialog()
{
- dialog_.reset(new QURLDialog(this));
+ dialog_.reset(new GuiURLDialog(this));
bcview().setOK(dialog_->okPB);
bcview().setCancel(dialog_->closePB);
#ifndef QT4_URL_VIEW_H
#define QT4_URL_VIEW_H
-#include "QDialogView.h"
-#include "QURLDialog.h"
+#include "GuiDialogView.h"
+#include "GuiURLDialog.h"
namespace lyx {
namespace frontend {
class ControlCommand;
class UrlView :
- public QController<ControlCommand, QView<QURLDialog> >
+ public QController<ControlCommand, GuiView<GuiURLDialog> >
{
public:
friend class QURLDialog;
//determines what text is to be written for "auto". But making
//that work involves more extensive revisions than we now want
//to make, since "auto" also appears in update_contents() (see
-//QGraphics.cpp).
+//GuiGraphics.cpp).
//The right way to do this, I think, would be to define a class
//checkedLengthSet (and a partnering labeledLengthSete) that encapsulated
//the checkbox, line edit, and length combo together, and then made e.g.
<author></author>
<comment></comment>
<exportmacro></exportmacro>
- <class>QAboutUi</class>
- <widget class="QDialog" name="QAboutUi" >
+ <class>AboutUi</class>
+ <widget class="QDialog" name="AboutUi" >
<property name="geometry" >
<rect>
<x>0</x>
<author></author>
<comment></comment>
<exportmacro></exportmacro>
- <class>QAskForTextUi</class>
- <widget class="QDialog" name="QAskForTextUi" >
+ <class>AskForTextUi</class>
+ <widget class="QDialog" name="AskForTextUi" >
<property name="geometry" >
<rect>
<x>0</x>
<author></author>
<comment></comment>
<exportmacro></exportmacro>
- <class>QBibitemUi</class>
- <widget class="QDialog" name="QBibitemUi" >
+ <class>BibitemUi</class>
+ <widget class="QDialog" name="BibitemUi" >
<property name="geometry" >
<rect>
<x>0</x>
<author></author>
<comment></comment>
<exportmacro></exportmacro>
- <class>QBibtexAddUi</class>
- <widget class="QDialog" name="QBibtexAddUi" >
+ <class>BibtexAddUi</class>
+ <widget class="QDialog" name="BibtexAddUi" >
<property name="geometry" >
<rect>
<x>0</x>
<author></author>
<comment></comment>
<exportmacro></exportmacro>
- <class>QBibtexUi</class>
- <widget class="QDialog" name="QBibtexUi" >
+ <class>BibtexUi</class>
+ <widget class="QDialog" name="BibtexUi" >
<property name="geometry" >
<rect>
<x>0</x>
<author></author>
<comment></comment>
<exportmacro></exportmacro>
- <class>QBoxUi</class>
- <widget class="QDialog" name="QBoxUi" >
+ <class>BoxUi</class>
+ <widget class="QDialog" name="BoxUi" >
<property name="geometry" >
<rect>
<x>0</x>
<author></author>
<comment></comment>
<exportmacro></exportmacro>
- <class>QBranchUi</class>
- <widget class="QDialog" name="QBranchUi" >
+ <class>BranchUi</class>
+ <widget class="QDialog" name="BranchUi" >
<property name="geometry" >
<rect>
<x>0</x>
<author></author>
<comment></comment>
<exportmacro></exportmacro>
- <class>QChangesUi</class>
- <widget class="QDialog" name="QChangesUi" >
+ <class>ChangesUi</class>
+ <widget class="QDialog" name="ChangesUi" >
<property name="geometry" >
<rect>
<x>0</x>
<ui version="4.0" >
- <class>QCharacterUi</class>
- <widget class="QDialog" name="QCharacterUi" >
+ <class>CharacterUi</class>
+ <widget class="QDialog" name="CharacterUi" >
<property name="geometry" >
<rect>
<x>0</x>
<ui version="4.0" >
- <class>QCitationUi</class>
- <widget class="QDialog" name="QCitationUi" >
+ <class>CitationUi</class>
+ <widget class="QDialog" name="CitationUi" >
<property name="geometry" >
<rect>
<x>0</x>
<ui version="4.0" >
- <class>QDelimiterUi</class>
- <widget class="QDialog" name="QDelimiterUi" >
+ <class>DelimiterUi</class>
+ <widget class="QDialog" name="DelimiterUi" >
<property name="geometry" >
<rect>
<x>0</x>
<author></author>
<comment></comment>
<exportmacro></exportmacro>
- <class>QDocumentUi</class>
- <widget class="QDialog" name="QDocumentUi" >
+ <class>DocumentUi</class>
+ <widget class="QDialog" name="DocumentUi" >
<property name="geometry" >
<rect>
<x>0</x>
<author></author>
<comment></comment>
<exportmacro></exportmacro>
- <class>QERTUi</class>
- <widget class="QDialog" name="QERTUi" >
+ <class>ERTUi</class>
+ <widget class="QDialog" name="ERTUi" >
<property name="geometry" >
<rect>
<x>0</x>
<author></author>
<comment></comment>
<exportmacro></exportmacro>
- <class>QErrorListUi</class>
- <widget class="QDialog" name="QErrorListUi" >
+ <class>ErrorListUi</class>
+ <widget class="QDialog" name="ErrorListUi" >
<property name="geometry" >
<rect>
<x>0</x>
<author></author>
<comment></comment>
<exportmacro></exportmacro>
- <class>QExternalUi</class>
- <widget class="QDialog" name="QExternalUi" >
+ <class>ExternalUi</class>
+ <widget class="QDialog" name="ExternalUi" >
<property name="geometry" >
<rect>
<x>0</x>
<author></author>
<comment></comment>
<exportmacro></exportmacro>
- <class>QFloatUi</class>
- <widget class="QDialog" name="QFloatUi" >
+ <class>FloatUi</class>
+ <widget class="QDialog" name="FloatUi" >
<property name="geometry" >
<rect>
<x>0</x>
<ui version="4.0" >
- <class>QGraphicsUi</class>
- <widget class="QDialog" name="QGraphicsUi" >
+ <class>GraphicsUi</class>
+ <widget class="QDialog" name="GraphicsUi" >
<property name="geometry" >
<rect>
<x>0</x>
<ui version="4.0" >
- <class>QIncludeUi</class>
- <widget class="QDialog" name="QIncludeUi" >
+ <class>IncludeUi</class>
+ <widget class="QDialog" name="IncludeUi" >
<property name="geometry" >
<rect>
<x>0</x>
<ui version="4.0" >
- <class>QIndexUi</class>
- <widget class="QDialog" name="QIndexUi" >
+ <class>IndexUi</class>
+ <widget class="QDialog" name="IndexUi" >
<property name="geometry" >
<rect>
<x>0</x>
<ui version="4.0" >
- <class>QListingsUi</class>
- <widget class="QDialog" name="QListingsUi" >
+ <class>ListingsUi</class>
+ <widget class="QDialog" name="ListingsUi" >
<property name="windowModality" >
<enum>Qt::NonModal</enum>
</property>
<ui version="4.0" >
- <author></author>
- <comment></comment>
- <exportmacro></exportmacro>
- <class>QLogUi</class>
- <widget class="QDialog" name="QLogUi" >
+ <class>LogUi</class>
+ <widget class="QDialog" name="LogUi" >
<property name="geometry" >
<rect>
<x>0</x>
<ui version="4.0" >
- <author></author>
- <comment></comment>
- <exportmacro></exportmacro>
- <class>QMathMatrixUi</class>
- <widget class="QDialog" name="QMathMatrixUi" >
+ <class>MathMatrixUi</class>
+ <widget class="QDialog" name="MathMatrixUi" >
<property name="geometry" >
<rect>
<x>0</x>
<ui version="4.0" >
- <author></author>
- <comment></comment>
- <exportmacro></exportmacro>
<class>MathsUi</class>
<widget class="QWidget" name="MathsUi" >
<property name="geometry" >
<ui version="4.0" >
- <class>QNomenclUi</class>
- <widget class="QDialog" name="QNomenclUi" >
+ <class>NomenclUi</class>
+ <widget class="QDialog" name="NomenclUi" >
<property name="geometry" >
<rect>
<x>0</x>
<ui version="4.0" >
- <author></author>
- <comment></comment>
- <exportmacro></exportmacro>
- <class>QNoteUi</class>
- <widget class="QDialog" name="QNoteUi" >
+ <class>NoteUi</class>
+ <widget class="QDialog" name="NoteUi" >
<property name="geometry" >
<rect>
<x>0</x>
<ui version="4.0" >
- <author></author>
- <comment></comment>
- <exportmacro></exportmacro>
<class>NumberingUi</class>
<widget class="QWidget" name="NumberingUi" >
<property name="geometry" >
<ui version="4.0" >
- <author></author>
- <comment></comment>
- <exportmacro></exportmacro>
<class>PageLayoutUi</class>
<widget class="QWidget" name="PageLayoutUi" >
<property name="geometry" >
<ui version="4.0" >
- <class>QParagraphUi</class>
- <widget class="QDialog" name="QParagraphUi" >
+ <class>ParagraphUi</class>
+ <widget class="QDialog" name="ParagraphUi" >
<property name="windowModality" >
<enum>Qt::ApplicationModal</enum>
</property>
<ui version="4.0" >
- <author></author>
- <comment></comment>
- <exportmacro></exportmacro>
<class>PreambleUi</class>
<widget class="QWidget" name="PreambleUi" >
<property name="geometry" >
<ui version="4.0" >
- <class>QPrefColorsUi</class>
- <widget class="QWidget" name="QPrefColorsUi" >
+ <class>PrefColorsUi</class>
+ <widget class="QWidget" name="PrefColorsUi" >
<property name="geometry" >
<rect>
<x>0</x>
<ui version="4.0" >
- <class>QPrefConvertersUi</class>
- <widget class="QWidget" name="QPrefConvertersUi" >
+ <class>PrefConvertersUi</class>
+ <widget class="QWidget" name="PrefConvertersUi" >
<property name="geometry" >
<rect>
<x>0</x>
<ui version="4.0" >
- <class>QPrefCopiersUi</class>
- <widget class="QWidget" name="QPrefCopiersUi" >
+ <class>PrefCopiersUi</class>
+ <widget class="QWidget" name="PrefCopiersUi" >
<property name="geometry" >
<rect>
<x>0</x>
<ui version="4.0" >
- <class>QPrefCygwinPathUi</class>
- <widget class="QWidget" name="QPrefCygwinPathUi" >
+ <class>PrefCygwinPathUi</class>
+ <widget class="QWidget" name="PrefCygwinPathUi" >
<property name="geometry" >
<rect>
<x>0</x>
<ui version="4.0" >
- <author></author>
- <comment></comment>
- <exportmacro></exportmacro>
- <class>QPrefDateUi</class>
- <widget class="QWidget" name="QPrefDateUi" >
+ <class>PrefDateUi</class>
+ <widget class="QWidget" name="PrefDateUi" >
<property name="geometry" >
<rect>
<x>0</x>
<ui version="4.0" >
- <author></author>
- <comment></comment>
- <exportmacro></exportmacro>
- <class>QPrefDisplayUi</class>
- <widget class="QWidget" name="QPrefDisplayUi" >
+ <class>PrefDisplayUi</class>
+ <widget class="QWidget" name="PrefDisplayUi" >
<property name="geometry" >
<rect>
<x>0</x>
<ui version="4.0" >
- <class>QPrefFileformatsUi</class>
- <widget class="QWidget" name="QPrefFileformatsUi" >
+ <class>PrefFileformatsUi</class>
+ <widget class="QWidget" name="PrefFileformatsUi" >
<property name="geometry" >
<rect>
<x>0</x>
<ui version="4.0" >
- <author></author>
- <comment></comment>
- <exportmacro></exportmacro>
- <class>QPrefIdentityUi</class>
- <widget class="QWidget" name="QPrefIdentityUi" >
+ <class>PrefIdentityUi</class>
+ <widget class="QWidget" name="PrefIdentityUi" >
<property name="geometry" >
<rect>
<x>0</x>
<ui version="4.0" >
- <class>QPrefKeyboardUi</class>
- <widget class="QWidget" name="QPrefKeyboardUi" >
+ <class>PrefKeyboardUi</class>
+ <widget class="QWidget" name="PrefKeyboardUi" >
<property name="geometry" >
<rect>
<x>0</x>
<ui version="4.0" >
- <author></author>
- <comment></comment>
- <exportmacro></exportmacro>
- <class>QPrefLanguageUi</class>
- <widget class="QWidget" name="QPrefLanguageUi" >
+ <class>PrefLanguageUi</class>
+ <widget class="QWidget" name="PrefLanguageUi" >
<property name="geometry" >
<rect>
<x>0</x>
<ui version="4.0" >
- <author></author>
- <comment></comment>
- <exportmacro></exportmacro>
- <class>QPrefLatexUi</class>
- <widget class="QWidget" name="QPrefLatexUi" >
+ <class>PrefLatexUi</class>
+ <widget class="QWidget" name="PrefLatexUi" >
<property name="geometry" >
<rect>
<x>0</x>
<ui version="4.0" >
- <author></author>
- <comment></comment>
- <exportmacro></exportmacro>
- <class>QPrefPathsUi</class>
- <widget class="QWidget" name="QPrefPathsUi" >
+ <class>PrefPathsUi</class>
+ <widget class="QWidget" name="PrefPathsUi" >
<property name="geometry" >
<rect>
<x>0</x>
<ui version="4.0" >
- <author></author>
- <comment></comment>
- <exportmacro></exportmacro>
- <class>QPrefPlaintextUi</class>
- <widget class="QWidget" name="QPrefPlaintextUi" >
+ <class>PrefPlaintextUi</class>
+ <widget class="QWidget" name="PrefPlaintextUi" >
<property name="geometry" >
<rect>
<x>0</x>
<ui version="4.0" >
- <class>QPrefPrinterUi</class>
- <widget class="QWidget" name="QPrefPrinterUi" >
+ <class>PrefPrinterUi</class>
+ <widget class="QWidget" name="PrefPrinterUi" >
<property name="geometry" >
<rect>
<x>0</x>
<ui version="4.0" >
- <author></author>
- <comment></comment>
- <exportmacro></exportmacro>
- <class>QPrefScreenFontsUi</class>
- <widget class="QWidget" name="QPrefScreenFontsUi" >
+ <class>PrefScreenFontsUi</class>
+ <widget class="QWidget" name="PrefScreenFontsUi" >
<property name="geometry" >
<rect>
<x>0</x>
</widget>
</item>
<item row="1" column="2" >
- <widget class="QFontExample" name="screenSansFE" >
+ <widget class="GuiFontExample" name="screenSansFE" >
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>3</hsizetype>
</widget>
</item>
<item row="0" column="2" >
- <widget class="QFontExample" name="screenRomanFE" >
+ <widget class="GuiFontExample" name="screenRomanFE" >
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>3</hsizetype>
</widget>
</item>
<item row="2" column="2" >
- <widget class="QFontExample" name="screenTypewriterFE" >
+ <widget class="GuiFontExample" name="screenTypewriterFE" >
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>3</hsizetype>
</includes>
<customwidgets>
<customwidget>
- <class>QFontExample</class>
+ <class>GuiFontExample</class>
<extends>QWidget</extends>
- <header>QFontExample.h</header>
+ <header>GuiFontExample.h</header>
<container>0</container>
<pixmap></pixmap>
</customwidget>
<ui version="4.0" >
- <author></author>
- <comment></comment>
- <exportmacro></exportmacro>
- <class>QPrefSpellcheckerUi</class>
- <widget class="QWidget" name="QPrefSpellcheckerUi" >
+ <class>PrefSpellcheckerUi</class>
+ <widget class="QWidget" name="PrefSpellcheckerUi" >
<property name="geometry" >
<rect>
<x>0</x>
<ui version="4.0" >
- <class>QPrefUi</class>
- <widget class="QWidget" name="QPrefUi" >
+ <class>PrefUi</class>
+ <widget class="QWidget" name="PrefUi" >
<property name="geometry" >
<rect>
<x>0</x>
<ui version="4.0" >
- <author></author>
- <comment></comment>
- <exportmacro></exportmacro>
- <class>QPrefsUi</class>
- <widget class="QDialog" name="QPrefsUi" >
+ <class>PrefsUi</class>
+ <widget class="QDialog" name="PrefsUi" >
<property name="geometry" >
<rect>
<x>0</x>
<ui version="4.0" >
- <author></author>
- <comment></comment>
- <exportmacro></exportmacro>
- <class>QPrintUi</class>
- <widget class="QDialog" name="QPrintUi" >
+ <class>PrintUi</class>
+ <widget class="QDialog" name="PrintUi" >
<property name="geometry" >
<rect>
<x>0</x>
<ui version="4.0" >
- <author></author>
- <comment></comment>
- <exportmacro></exportmacro>
- <class>QRefUi</class>
- <widget class="QDialog" name="QRefUi" >
+ <class>RefUi</class>
+ <widget class="QDialog" name="RefUi" >
<property name="geometry" >
<rect>
<x>0</x>
<ui version="4.0" >
- <author></author>
- <comment></comment>
- <exportmacro></exportmacro>
- <class>QSearchUi</class>
- <widget class="QDialog" name="QSearchUi" >
+ <class>SearchUi</class>
+ <widget class="QDialog" name="SearchUi" >
<property name="geometry" >
<rect>
<x>0</x>
<ui version="4.0" >
- <author></author>
- <comment></comment>
- <exportmacro></exportmacro>
- <class>QSendtoUi</class>
- <widget class="QDialog" name="QSendtoUi" >
+ <class>SendtoUi</class>
+ <widget class="QDialog" name="SendtoUi" >
<property name="geometry" >
<rect>
<x>0</x>
<ui version="4.0" >
- <author></author>
- <comment></comment>
- <exportmacro></exportmacro>
- <class>QShowFileUi</class>
- <widget class="QDialog" name="QShowFileUi" >
+ <class>ShowFileUi</class>
+ <widget class="QDialog" name="ShowFileUi" >
<property name="geometry" >
<rect>
<x>0</x>
<ui version="4.0" >
- <author></author>
- <comment></comment>
- <exportmacro></exportmacro>
- <class>QSpellcheckerUi</class>
- <widget class="QDialog" name="QSpellcheckerUi" >
+ <class>SpellcheckerUi</class>
+ <widget class="QDialog" name="SpellcheckerUi" >
<property name="geometry" >
<rect>
<x>0</x>
<ui version="4.0" >
- <author></author>
- <comment></comment>
- <exportmacro></exportmacro>
- <class>QTabularCreateUi</class>
- <widget class="QDialog" name="QTabularCreateUi" >
+ <class>TabularCreateUi</class>
+ <widget class="QDialog" name="TabularCreateUi" >
<property name="geometry" >
<rect>
<x>0</x>
<ui version="4.0" >
- <author></author>
- <comment></comment>
- <exportmacro></exportmacro>
- <class>QTabularUi</class>
- <widget class="QDialog" name="QTabularUi" >
+ <class>TabularUi</class>
+ <widget class="QDialog" name="TabularUi" >
<property name="geometry" >
<rect>
<x>0</x>
<number>6</number>
</property>
<item row="0" column="0" >
- <widget class="QSetBorder" name="borders" >
+ <widget class="GuiSetBorder" name="borders" >
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>1</hsizetype>
<pixmap></pixmap>
</customwidget>
<customwidget>
- <class>QSetBorder</class>
+ <class>GuiSetBorder</class>
<extends>QWidget</extends>
- <header>QSetBorder.h</header>
+ <header>GuiSetBorder.h</header>
<container>0</container>
<pixmap></pixmap>
</customwidget>
<ui version="4.0" >
- <class>QTexinfoUi</class>
- <widget class="QDialog" name="QTexinfoUi" >
+ <class>TexinfoUi</class>
+ <widget class="QDialog" name="TexinfoUi" >
<property name="geometry" >
<rect>
<x>0</x>
<ui version="4.0" >
- <author></author>
- <comment></comment>
- <exportmacro></exportmacro>
- <class>QThesaurusUi</class>
- <widget class="QDialog" name="QThesaurusUi" >
+ <class>ThesaurusUi</class>
+ <widget class="QDialog" name="ThesaurusUi" >
<property name="geometry" >
<rect>
<x>0</x>
<ui version="4.0" >
- <class>QTocUi</class>
- <widget class="QWidget" name="QTocUi" >
+ <class>TocUi</class>
+ <widget class="QWidget" name="TocUi" >
<property name="windowModality" >
<enum>Qt::NonModal</enum>
</property>
<ui version="4.0" >
- <author></author>
- <comment></comment>
- <exportmacro></exportmacro>
- <class>QURLUi</class>
- <widget class="QDialog" name="QURLUi" >
+ <class>URLUi</class>
+ <widget class="QDialog" name="URLUi" >
<property name="geometry" >
<rect>
<x>0</x>
<ui version="4.0" >
- <class>QVSpaceUi</class>
- <widget class="QDialog" name="QVSpaceUi" >
+ <class>VSpaceUi</class>
+ <widget class="QDialog" name="VSpaceUi" >
<property name="geometry" >
<rect>
<x>0</x>
<ui version="4.0" >
- <class>QViewSourceUi</class>
- <widget class="QWidget" name="QViewSourceUi" >
+ <class>ViewSourceUi</class>
+ <widget class="QWidget" name="ViewSourceUi" >
<property name="geometry" >
<rect>
<x>0</x>
<ui version="4.0" >
- <author></author>
- <comment></comment>
- <exportmacro></exportmacro>
- <class>QWrapUi</class>
- <widget class="QDialog" name="QWrapUi" >
+ <class>WrapUi</class>
+ <widget class="QDialog" name="WrapUi" >
<property name="geometry" >
<rect>
<x>0</x>