lyx_mirror/src/frontends/qt4/Dialogs.cpp

278 lines
8.3 KiB
C++
Raw Normal View History

/**
* \file qt4/Dialogs.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 "Dialogs.h"
#include "GuiDialog.h"
#include "ButtonController.h"
#include "DialogView.h"
#include "DockView.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 "GuiDelimiter.h"
#include "GuiDocument.h"
#include "GuiEmbeddedFiles.h"
#include "GuiErrorList.h"
#include "GuiERT.h"
#include "GuiExternal.h"
#include "GuiFloat.h"
#include "GuiGraphics.h"
#include "GuiInclude.h"
#include "GuiIndex.h"
#include "GuiMathMatrix.h"
#include "GuiNomencl.h"
#include "GuiListings.h"
#include "GuiLog.h"
#include "GuiParagraph.h"
#include "GuiPrefs.h"
#include "GuiPrint.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 "GuiView.h"
#include "GuiViewSource.h"
#include "TocWidget.h"
#include "GuiURL.h"
#include "GuiVSpace.h"
#ifdef HAVE_LIBAIKSAURUS
#include "ControlThesaurus.h"
#include "GuiThesaurus.h"
#endif
// Uncomment this if you prefer dock widget
//#define USE_DOCK_WIDGET
#include "qt_helpers.h"
#include <boost/assert.hpp>
using std::string;
namespace lyx {
namespace frontend {
namespace {
// This list should be kept in sync with the list of insets in
// src/insets/Inset.cpp. I.e., if a dialog goes with an inset, the
// dialog should have the same name as the inset.
char const * const dialognames[] = {
"aboutlyx", "bibitem", "bibtex", "box", "branch", "changes", "character",
"citation", "document", "embedding", "errorlist", "ert", "external", "file",
New nomenclature inset from Ugras * src/LyXAction.C (LyXAction::init): Add LFUN_NOMENCL_INSERT and LFUN_NOMENCL_PRINT * src/insets/insetbase.C (build_translator): ditto * src/LaTeXFeatures.C (LaTeXFeatures::getPackages): Add nomencl * src/insets/insetnomencl.[Ch]: new insets InsetNomencl and InsetPrintNomencl * src/insets/insetbase.h: Add NOMENCL_CODE and NOMENCL_PRINT_CODE * src/insets/insetcommandparams.C (InsetCommandParams::findInfo): Add nomenclature and printnomenclature (InsetCommandParams::getCommand): Extend end of command protection to cover commands with only optional arguments like printnomenclature * src/insets/insetert.C (InsetERT::getStatus): disable LFUN_NOMENCL_INSERT and LFUN_NOMENCL_PRINT * src/insets/Makefile.am: Add new files * src/frontends/qt4/Makefile.dialogs: ditto * src/frontends/qt4/Makefile.am: ditto * src/factory.C (createInset): Handle InsetNomencl and InsetPrintNomencl (readInset): ditto * src/buffer.C (LYX_FORMAT): increase * src/lyxfunc.C (LyXFunc::dispatch): Handle nomenclature * src/LaTeX.C (LaTeX::deleteFilesOnError): Delete .nls file (LaTeX::run): Run makeindex for nomenclature (LaTeX::runMakeIndex): handle nomenclature options (LaTeX::deplog): Recognize nomenclature file * src/frontends/qt4/QNomenclDialog.[Ch]: new * src/frontends/qt4/QNomencl.[Ch]: ditto * src/frontends/qt4/ui/QNomenclUi.ui: ditto * src/frontends/qt4/Dialogs.C (Dialogs::build): handle nomenclature dialog * src/text3.C (LyXText::dispatch): Handle LFUN_NOMENCL_INSERT and LFUN_NOMENCL_PRINT (LyXText::getStatus): Ditto * src/lfuns.h (kb_action): Add LFUN_NOMENCL_INSERT and LFUN_NOMENCL_PRINT * lib/lyx2lyx/LyX.py (format_relation): Update 1.5 format range * lib/lyx2lyx/lyx_1_5.py (revert_nomenclature): New (revert_printnomenclature): ditto * lib/chkconfig.ltx: Test for nomencl package * lib/doc/LaTeXConfig.lyx.in: Add nomencl package * lib/doc/Extended.lyx: Add documentation for nomencl * lib/ui/stdtoolbars.ui (Toolbar "extra" "Extra"): Add nomencl-insert * lib/ui/classic.ui: Add nomencl-insert and nomencl-print * lib/ui/stdmenus.ui: ditto * development/scons/scons_manifest.py: Add new files * development/FORMAT: Describe new format git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15739 a592a061-630c-0410-9148-cb99ea01b6c8
2006-11-04 17:55:36 +00:00
"findreplace", "float", "graphics", "include", "index", "nomenclature", "label", "log",
"mathdelimiter", "mathmatrix", "note", "paragraph",
"prefs", "print", "ref", "sendto", "spellchecker","tabular", "tabularcreate",
#ifdef HAVE_LIBAIKSAURUS
"thesaurus",
#endif
Add support for listings package. Two listings command \lstinline, \lstinputlisting and an environment \lstlisting are supported, along with preamble \lstset. \lstinputlisting is implemented through Include dialog, and the other two are implemented with a new inset listings, along with its dialog. * src/LyXAction.cpp: listing-insert action * src/insets/Inset.h,cpp: LISTINGS_CODE * src/insets/InsetInclude.cpp: handle \lstinputlisting * src/insets/InsetListings.h,cpp: new listings inset * src/insets/InsetListingsParams.h,cpp: parameters from listings package * src/insets/InsetCommandParams.h,cpp: handle lstinputlisting option * src/Bidi.cpp: handle LISTINGS_CODE * src/frontends/qt4/ui/TextLayoutUi.ui: update UI * src/frontends/qt4/ui/ListingsUi.ui: new dialog * src/frontends/qt4/ui/IncludeUi.ui: update UI * src/frontends/qt4/QInclude.h,cpp: add lstinputlisting * src/frontends/qt4/QDocument.h,cpp: add textedit for preamble listings_params * src/frontends/qt4/QListings.h,cpp: new listings inset * src/frontends/qt4/Dialogs.cpp: new listings dialog * src/frontends/controllers/ControlInclude.h,cpp: add lstinputlisting * src/frontends/controllers/ControlListings.h,cpp: new listings inset * src/LyXFunc.cpp: handle LISTING_CODE * src/Paragraph.cpp: handle LISTING_CODE * src/factory.cpp: new listings inset * src/CutAndPaste.cpp: handle LISTINGS_CODE * src/LaTeXFeatures.cpp: require listings * src/Text3.cpp: Handle LISTINGS_CODE * src/lfuns.h: add LFUN_LISTING_INSERT * src/Buffer.cpp: change lyx file format to 269 * src/BufferParams.h,cpp: add listings_params to preamble * lib/lyx2lyx/LyX.py: lyx2lyx * lib/lyx2lyx/lyx_1_5.py: lyx2lyx * lib/ui/stdmenus.inc: new menu item (no shortcut!) * src/insets/Makefile.am: update autotools * src/frontends/controllers/Makefile.am * src/frontends/qt4/Makefile.dialogs * src/frontends/qt4/Makefile.am * po/POTFILES.in: a few more translatable files. * development/scons/scons_manifest.py: scons build system * development/FORMAT: document format changes git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@18243 a592a061-630c-0410-9148-cb99ea01b6c8
2007-05-09 19:11:42 +00:00
"texinfo", "toc", "url", "view-source", "vspace", "wrap", "listings" };
char const * const * const end_dialognames =
dialognames + (sizeof(dialognames) / sizeof(char *));
class cmpCStr {
public:
cmpCStr(char const * name) : name_(name) {}
bool operator()(char const * other) {
return strcmp(other, name_) == 0;
}
private:
char const * name_;
};
} // namespace anon
// will be replaced by a proper factory...
Dialog * createGuiAboutDialog(LyXView & lv);
Dialog * createGuiBibitemDialog(LyXView & lv);
Dialog * createGuiBibtexDialog(LyXView & lv);
Dialog * createGuiBoxDialog(LyXView & lv);
Dialog * createGuiBranchDialog(LyXView & lv);
Dialog * createGuiChangesDialog(LyXView & lv);
Dialog * createGuiCharacterDialog(LyXView & lv);
Dialog * createGuiCitationDialog(LyXView & lv);
Dialog * createGuiDelimiterDialog(LyXView & lv);
Dialog * createGuiDocumentDialog(LyXView & lv);
Dialog * createGuiErrorListDialog(LyXView & lv);
Dialog * createGuiERTDialog(LyXView & lv);
Dialog * createGuiExternalDialog(LyXView & lv);
Dialog * createGuiFloatDialog(LyXView & lv);
Dialog * createGuiGraphicsDialog(LyXView & lv);
Dialog * createGuiIncludeDialog(LyXView & lv);
Dialog * createGuiIndexDialog(LyXView & lv);
Dialog * createGuiLabelDialog(LyXView & lv);
Dialog * createGuiListingsDialog(LyXView & lv);
Dialog * createGuiLogDialog(LyXView & lv);
Dialog * createGuiMathMatrixDialog(LyXView & lv);
Dialog * createGuiNomenclDialog(LyXView & lv);
Dialog * createGuiNote(LyXView & lv);
Dialog * createGuiPrefsDialog(LyXView & lv);
Dialog * createGuiPrintDialog(LyXView & lv);
Dialog * createGuiRef(LyXView & lv);
Dialog * createGuiSearchDialog(LyXView & lv);
Dialog * createGuiSendtoDialog(LyXView & lv);
Dialog * createGuiShowFileDialog(LyXView & lv);
Dialog * createGuiSpellcheckerDialog(LyXView & lv);
Dialog * createGuiTabularCreateDialog(LyXView & lv);
Dialog * createGuiTabularDialog(LyXView & lv);
Dialog * createGuiTexinfoDialog(LyXView & lv);
Dialog * createGuiThesaurusDialog(LyXView & lv);
Dialog * createGuiURLDialog(LyXView & lv);
Dialog * createGuiVSpaceDialog(LyXView & lv);
Dialog * createGuiWrap(LyXView & lv);
bool Dialogs::isValidName(string const & name) const
{
return std::find_if(dialognames, end_dialognames,
cmpCStr(name.c_str())) != end_dialognames;
}
Dialog * Dialogs::build(string const & name)
{
BOOST_ASSERT(isValidName(name));
Dialog * dialog = 0;
GuiViewBase & guiview = static_cast<GuiViewBase &>(lyxview_);
if (name == "aboutlyx") {
dialog = new GuiAboutDialog(lyxview_);
} else if (name == "bibitem") {
dialog = new GuiBibitemDialog(lyxview_);
} else if (name == "bibtex") {
dialog = new GuiBibtexDialog(lyxview_);
} else if (name == "box") {
dialog = new GuiBoxDialog(lyxview_);
} else if (name == "branch") {
dialog = new GuiBranchDialog(lyxview_);
} else if (name == "changes") {
dialog = new GuiChangesDialog(lyxview_);
} else if (name == "character") {
dialog = new GuiCharacterDialog(lyxview_);
} else if (name == "citation") {
dialog = new GuiCitationDialog(lyxview_);
} else if (name == "document") {
dialog = new GuiDocumentDialog(lyxview_);
} else if (name == "embedding") {
dialog = new DockView<ControlEmbeddedFiles, GuiEmbeddedFilesDialog>(
guiview, name, Qt::RightDockWidgetArea);
} else if (name == "errorlist") {
dialog = new GuiErrorListDialog(lyxview_);
} else if (name == "ert") {
dialog = new GuiERTDialog(lyxview_);
} else if (name == "external") {
dialog = new GuiExternalDialog(lyxview_);
} else if (name == "file") {
dialog = new GuiShowFileDialog(lyxview_);
} else if (name == "findreplace") {
dialog = new GuiSearchDialog(lyxview_);
} else if (name == "float") {
dialog = new GuiFloatDialog(lyxview_);
} else if (name == "graphics") {
dialog = new GuiGraphicsDialog(lyxview_);
} else if (name == "include") {
dialog = new GuiIncludeDialog(lyxview_);
} else if (name == "index") {
dialog = new GuiIndexDialog(lyxview_);
New nomenclature inset from Ugras * src/LyXAction.C (LyXAction::init): Add LFUN_NOMENCL_INSERT and LFUN_NOMENCL_PRINT * src/insets/insetbase.C (build_translator): ditto * src/LaTeXFeatures.C (LaTeXFeatures::getPackages): Add nomencl * src/insets/insetnomencl.[Ch]: new insets InsetNomencl and InsetPrintNomencl * src/insets/insetbase.h: Add NOMENCL_CODE and NOMENCL_PRINT_CODE * src/insets/insetcommandparams.C (InsetCommandParams::findInfo): Add nomenclature and printnomenclature (InsetCommandParams::getCommand): Extend end of command protection to cover commands with only optional arguments like printnomenclature * src/insets/insetert.C (InsetERT::getStatus): disable LFUN_NOMENCL_INSERT and LFUN_NOMENCL_PRINT * src/insets/Makefile.am: Add new files * src/frontends/qt4/Makefile.dialogs: ditto * src/frontends/qt4/Makefile.am: ditto * src/factory.C (createInset): Handle InsetNomencl and InsetPrintNomencl (readInset): ditto * src/buffer.C (LYX_FORMAT): increase * src/lyxfunc.C (LyXFunc::dispatch): Handle nomenclature * src/LaTeX.C (LaTeX::deleteFilesOnError): Delete .nls file (LaTeX::run): Run makeindex for nomenclature (LaTeX::runMakeIndex): handle nomenclature options (LaTeX::deplog): Recognize nomenclature file * src/frontends/qt4/QNomenclDialog.[Ch]: new * src/frontends/qt4/QNomencl.[Ch]: ditto * src/frontends/qt4/ui/QNomenclUi.ui: ditto * src/frontends/qt4/Dialogs.C (Dialogs::build): handle nomenclature dialog * src/text3.C (LyXText::dispatch): Handle LFUN_NOMENCL_INSERT and LFUN_NOMENCL_PRINT (LyXText::getStatus): Ditto * src/lfuns.h (kb_action): Add LFUN_NOMENCL_INSERT and LFUN_NOMENCL_PRINT * lib/lyx2lyx/LyX.py (format_relation): Update 1.5 format range * lib/lyx2lyx/lyx_1_5.py (revert_nomenclature): New (revert_printnomenclature): ditto * lib/chkconfig.ltx: Test for nomencl package * lib/doc/LaTeXConfig.lyx.in: Add nomencl package * lib/doc/Extended.lyx: Add documentation for nomencl * lib/ui/stdtoolbars.ui (Toolbar "extra" "Extra"): Add nomencl-insert * lib/ui/classic.ui: Add nomencl-insert and nomencl-print * lib/ui/stdmenus.ui: ditto * development/scons/scons_manifest.py: Add new files * development/FORMAT: Describe new format git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15739 a592a061-630c-0410-9148-cb99ea01b6c8
2006-11-04 17:55:36 +00:00
} else if (name == "nomenclature") {
dialog = new GuiNomenclDialog(lyxview_);
} else if (name == "label") {
dialog = new GuiLabelDialog(lyxview_);
} else if (name == "log") {
dialog = new GuiLogDialog(lyxview_);
} else if (name == "view-source") {
dialog = new DockView<ControlViewSource, GuiViewSourceDialog>(
guiview, name, Qt::BottomDockWidgetArea);
} else if (name == "mathdelimiter") {
dialog = new GuiDelimiterDialog(lyxview_);
} else if (name == "mathmatrix") {
dialog = new GuiMathMatrixDialog(lyxview_);
} else if (name == "note") {
dialog = createGuiNote(lyxview_);
} else if (name == "paragraph") {
#ifdef USE_DOCK_WIDGET
DockView<ControlParagraph, GuiParagraph> * dv =
new DockView<ControlParagraph, GuiParagraph>(guiview, name,
Qt::TopDockWidgetArea);
#else
DialogView<ControlParagraph, GuiParagraph> * dv =
new DialogView<ControlParagraph, GuiParagraph>(guiview, name);
#endif
dialog = dv;
} else if (name == "prefs") {
dialog = new GuiPrefsDialog(lyxview_);
} else if (name == "print") {
dialog = new GuiPrintDialog(lyxview_);
} else if (name == "ref") {
dialog = createGuiRef(lyxview_);
} else if (name == "sendto") {
dialog = new GuiSendtoDialog(lyxview_);
} else if (name == "spellchecker") {
dialog = new GuiSpellcheckerDialog(lyxview_);
} else if (name == "tabular") {
dialog = new GuiTabularDialog(lyxview_);
} else if (name == "tabularcreate") {
dialog = new GuiTabularCreateDialog(lyxview_);
} else if (name == "texinfo") {
dialog = new GuiTexinfoDialog(lyxview_);
#ifdef HAVE_LIBAIKSAURUS
} else if (name == "thesaurus") {
dialog = new GuiThesaurusDialog(lyxview_);
#endif
} else if (name == "toc") {
#ifdef Q_WS_MACX
// On Mac show as a drawer at the right
dialog = new DockView<GuiToc, TocWidget>(guiview, name,
Qt::RightDockWidgetArea, Qt::Drawer);
#else
dialog = new DockView<GuiToc, TocWidget>(guiview, name);
#endif
} else if (name == "url") {
dialog = new GuiURLDialog(lyxview_);
} else if (name == "vspace") {
dialog = new GuiVSpaceDialog(lyxview_);
} else if (name == "wrap") {
dialog = createGuiWrap(lyxview_);
Add support for listings package. Two listings command \lstinline, \lstinputlisting and an environment \lstlisting are supported, along with preamble \lstset. \lstinputlisting is implemented through Include dialog, and the other two are implemented with a new inset listings, along with its dialog. * src/LyXAction.cpp: listing-insert action * src/insets/Inset.h,cpp: LISTINGS_CODE * src/insets/InsetInclude.cpp: handle \lstinputlisting * src/insets/InsetListings.h,cpp: new listings inset * src/insets/InsetListingsParams.h,cpp: parameters from listings package * src/insets/InsetCommandParams.h,cpp: handle lstinputlisting option * src/Bidi.cpp: handle LISTINGS_CODE * src/frontends/qt4/ui/TextLayoutUi.ui: update UI * src/frontends/qt4/ui/ListingsUi.ui: new dialog * src/frontends/qt4/ui/IncludeUi.ui: update UI * src/frontends/qt4/QInclude.h,cpp: add lstinputlisting * src/frontends/qt4/QDocument.h,cpp: add textedit for preamble listings_params * src/frontends/qt4/QListings.h,cpp: new listings inset * src/frontends/qt4/Dialogs.cpp: new listings dialog * src/frontends/controllers/ControlInclude.h,cpp: add lstinputlisting * src/frontends/controllers/ControlListings.h,cpp: new listings inset * src/LyXFunc.cpp: handle LISTING_CODE * src/Paragraph.cpp: handle LISTING_CODE * src/factory.cpp: new listings inset * src/CutAndPaste.cpp: handle LISTINGS_CODE * src/LaTeXFeatures.cpp: require listings * src/Text3.cpp: Handle LISTINGS_CODE * src/lfuns.h: add LFUN_LISTING_INSERT * src/Buffer.cpp: change lyx file format to 269 * src/BufferParams.h,cpp: add listings_params to preamble * lib/lyx2lyx/LyX.py: lyx2lyx * lib/lyx2lyx/lyx_1_5.py: lyx2lyx * lib/ui/stdmenus.inc: new menu item (no shortcut!) * src/insets/Makefile.am: update autotools * src/frontends/controllers/Makefile.am * src/frontends/qt4/Makefile.dialogs * src/frontends/qt4/Makefile.am * po/POTFILES.in: a few more translatable files. * development/scons/scons_manifest.py: scons build system * development/FORMAT: document format changes git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@18243 a592a061-630c-0410-9148-cb99ea01b6c8
2007-05-09 19:11:42 +00:00
} else if (name == "listings") {
dialog = new GuiListingsDialog(lyxview_);
}
return dialog;
}
/// Are the tooltips on or off?
bool Dialogs::tooltipsEnabled()
{
return false;
}
} // namespace frontend
} // namespace lyx