the fun begins....

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20077 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2007-09-05 20:33:29 +00:00
parent fe0f7858c2
commit c9ea6e6eef
113 changed files with 3653 additions and 5147 deletions

View File

@ -181,7 +181,7 @@ void Dialogs::updateBufferDependent(bool switched) const
Dialog * dialog = it->second.get();
if (switched && dialog->controller().isBufferDependent()) {
if (dialog->isVisible() && dialog->controller().initialiseParams(""))
dialog->view().updateView();
dialog->updateView();
else
dialog->hide();
} else {

View File

@ -92,7 +92,7 @@ void ControlExternal::editExternal()
{
BOOST_ASSERT(params_.get());
dialog().view().applyView();
dialog().applyView();
string const lfun =
InsetExternalMailer::params2string(params(), kernel().buffer());
kernel().dispatch(FuncRequest(LFUN_EXTERNAL_EDIT, lfun));

View File

@ -142,7 +142,7 @@ void ControlGraphics::editGraphics()
{
BOOST_ASSERT(params_.get());
dialog().view().applyView();
dialog().applyView();
string const lfun =
InsetGraphicsMailer::params2string(params(), kernel().buffer());
kernel().dispatch(FuncRequest(LFUN_GRAPHICS_EDIT, lfun));

View File

@ -233,7 +233,7 @@ void ControlSpellchecker::check()
LYXERR(Debug::GUI) << "Updating spell progress." << endl;
oldval_ = newvalue_;
// set progress bar
dialog().view().partialUpdateView(SPELL_PROGRESSED);
dialog().partialUpdateView(SPELL_PROGRESSED);
}
// speller might be dead ...
@ -261,7 +261,7 @@ void ControlSpellchecker::check()
// set suggestions
if (res != SpellBase::OK && res != SpellBase::IGNORED_WORD) {
LYXERR(Debug::GUI) << "Found a word needing checking." << endl;
dialog().view().partialUpdateView(SPELL_FOUND_WORD);
dialog().partialUpdateView(SPELL_FOUND_WORD);
}
}

View File

@ -142,14 +142,14 @@ void ControlTabular::setWidth(string const & width)
else
set(Tabular::SET_PWIDTH, width);
dialog().view().updateView();
dialog().updateView();
}
void ControlTabular::toggleMultiColumn()
{
set(Tabular::MULTICOLUMN);
dialog().view().updateView();
dialog().updateView();
}

View File

@ -51,7 +51,7 @@ void Dialog::show(string const & data)
}
preShow();
view().showView();
showView();
postShow();
}
@ -68,7 +68,7 @@ void Dialog::update(string const & data)
}
preUpdate();
view().updateView();
updateView();
postUpdate();
}
@ -80,11 +80,11 @@ void Dialog::checkStatus()
void Dialog::hide()
{
if (!view().isVisibleView())
if (!isVisibleView())
return;
controller().clearParams();
view().hideView();
hideView();
kernel().disconnect(name());
}
@ -93,31 +93,30 @@ void Dialog::apply()
{
if (controller().isBufferDependent()) {
if (!kernel().isBufferAvailable() ||
(kernel().isBufferReadonly() &&
!controller().canApplyToReadOnly()))
(kernel().isBufferReadonly() && !controller().canApplyToReadOnly()))
return;
}
view().applyView();
applyView();
controller().dispatchParams();
if (controller().disconnectOnApply() && !is_closing_) {
kernel().disconnect(name());
controller().initialiseParams(string());
view().updateView();
updateView();
}
}
bool Dialog::isVisible() const
{
return view().isVisibleView();
return isVisibleView();
}
void Dialog::redraw()
{
view().redrawView();
redrawView();
}
@ -128,14 +127,6 @@ void Dialog::setController(Controller * i)
}
void Dialog::setView(View * v)
{
BOOST_ASSERT(v && !view_ptr_.get());
view_ptr_.reset(v);
}
Dialog::Controller::Controller(Dialog & parent)
: parent_(parent)
{}
@ -156,32 +147,17 @@ Dialog::Controller & Dialog::controller() const
}
Dialog::View::View(Dialog & parent, docstring title) :
p_(parent), title_(title)
{}
Dialog::View & Dialog::view() const
{
BOOST_ASSERT(view_ptr_.get());
return *view_ptr_.get();
}
void Dialog::View::setViewTitle(docstring const & newtitle)
void Dialog::setViewTitle(docstring const & newtitle)
{
title_ = newtitle;
}
docstring const & Dialog::View::getViewTitle() const
docstring const & Dialog::getViewTitle() const
{
return title_;
}
void Dialog::View::partialUpdateView(int)
{}
} // namespace frontend
} // namespace lyx

View File

@ -87,13 +87,13 @@ public:
* show() and update() methods.
*/
Kernel & kernel() { return kernel_; }
Kernel const & kernel() const { return kernel_; }
/** Different dialogs will have different Controllers and Views.
* deriving from these base classes.
*/
//@{
class Controller;
class View;
//@}
/** \name Dialog Specialization
@ -103,20 +103,60 @@ public:
//@{
/// \param ptr is stored and destroyed by \c Dialog.
void setController(Controller * ptr);
/// \param ptr is stored and destroyed by \c Dialog.
void setView(View * ptr);
//@}
/** \name Dialog Components
* Methods to access the various components making up a dialog.
*/
//@{
Controller & controller() const;
View & view() const;
virtual Controller & controller() const;
//@}
/** \c Button controller part
*/
virtual void setButtonsValid(bool valid);
/** \c View part
* of a Model-Controller-View split of a generic dialog.
* These few methods are all that a generic dialog needs of a
* view.
*/
//@{
/** A request to modify the data structures stored by the
* accompanying Controller in preparation for their dispatch to
* the LyX kernel.
*/
virtual void applyView() = 0;
/// Hide the dialog from sight
virtual void hideView() = 0;
/// Redraw the dialog (e.g. if the colors have been remapped).
virtual void redrawView() {}
/// Create the dialog if necessary, update it and display it.
virtual void showView() = 0;
/// Update the display of the dialog whilst it is still visible.
virtual void updateView() = 0;
/// \return true if the dialog is visible.
virtual bool isVisibleView() const = 0;
//@}
/** Defaults to nothing. Can be used by the Controller, however, to
* indicate to the View that something has changed and that the
* dialog therefore needs updating.
* \param id identifies what should be updated.
*/
virtual void partialUpdateView(int /*id*/) {}
/// sets the title of the dialog (window caption)
void setViewTitle(docstring const &);
/// gets the title of the dialog (window caption)
docstring const & getViewTitle() const;
protected:
void apply();
@ -124,7 +164,8 @@ protected:
Kernel kernel_;
std::string name_;
boost::scoped_ptr<Controller> controller_ptr_;
boost::scoped_ptr<View> view_ptr_;
docstring title_;
};
@ -223,75 +264,6 @@ private:
};
/** \c Dialog::View is an abstract base class to the View
* of a Model-Controller-View split of a generic dialog.
*/
class Dialog::View : boost::noncopyable {
public:
/** \param parent Dialog owning this Controller.
* \param title is the dialog title displayed by the WM.
*/
View(Dialog & parent, docstring title);
virtual ~View() {}
/** \name Generic View
* These few methods are all that a generic dialog needs of a
* view.
*/
//@{
/** A request to modify the data structures stored by the
* accompanying Controller in preparation for their dispatch to
* the LyX kernel.
*/
virtual void applyView() = 0;
/// Hide the dialog from sight
virtual void hideView() = 0;
/// Redraw the dialog (e.g. if the colors have been remapped).
virtual void redrawView() {}
/// Create the dialog if necessary, update it and display it.
virtual void showView() = 0;
/// Update the display of the dialog whilst it is still visible.
virtual void updateView() = 0;
/// \return true if the dialog is visible.
virtual bool isVisibleView() const = 0;
//@}
/** Defaults to nothing. Can be used by the Controller, however, to
* indicate to the View that something has changed and that the
* dialog therefore needs updating.
* \param id identifies what should be updated.
*/
virtual void partialUpdateView(int id);
/// sets the title of the dialog (window caption)
void setViewTitle(docstring const &);
/// gets the title of the dialog (window caption)
docstring const & getViewTitle() const;
/** \name View Access
* Enable the derived classes to access the other parts of the whole.
*/
//@{
Dialog & dialog() { return p_; }
Dialog const & dialog() const { return p_; }
protected:
Kernel & kernel() { return p_.kernel(); }
Kernel const & kernel() const { return p_.kernel(); }
Controller & getController() { return p_.controller(); }
Controller const & getController() const { return p_.controller(); }
//@}
private:
Dialog & p_;
docstring title_;
};
} // namespace frontend
} // namespace lyx

View File

@ -114,195 +114,92 @@ Dialog * Dialogs::build(string const & name)
{
BOOST_ASSERT(isValidName(name));
GuiDialog * dialog = new GuiDialog(lyxview_, name);
Dialog * dialog = 0;
if (name == "aboutlyx") {
dialog->setController(new ControlAboutlyx(*dialog));
dialog->setView(new GuiAbout(*dialog));
dialog->bc().setPolicy(ButtonPolicy::OkCancelPolicy);
dialog = new GuiAboutDialog(lyxview_);
} else if (name == "bibitem") {
dialog->setController(new ControlCommand(*dialog, name, name));
dialog->setView(new GuiBibitem(*dialog));
dialog->bc().setPolicy(ButtonPolicy::OkCancelReadOnlyPolicy);
dialog = new GuiBibitemDialog(lyxview_);
} else if (name == "bibtex") {
dialog->setController(new ControlBibtex(*dialog));
dialog->setView(new GuiBibtex(*dialog));
dialog->bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
dialog = new GuiBibtexDialog(lyxview_);
} else if (name == "box") {
dialog->setController(new ControlBox(*dialog));
dialog->setView(new GuiBox(*dialog));
dialog->bc().setPolicy(ButtonPolicy::OkApplyCancelReadOnlyPolicy);
dialog = new GuiBoxDialog(lyxview_);
} else if (name == "branch") {
dialog->setController(new ControlBranch(*dialog));
dialog->setView(new GuiBranch(*dialog));
dialog->bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
dialog = new GuiBranchDialog(lyxview_);
} else if (name == "changes") {
dialog->setController(new ControlChanges(*dialog));
dialog->setView(new GuiChanges(*dialog));
dialog->bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
dialog = new GuiChangesDialog(lyxview_);
} else if (name == "character") {
dialog->setController(new ControlCharacter(*dialog));
dialog->setView(new GuiCharacter(*dialog));
dialog->bc().setPolicy(ButtonPolicy::OkApplyCancelReadOnlyPolicy);
dialog = new GuiCharacterDialog(lyxview_);
} else if (name == "citation") {
GuiCitation * ci = new GuiCitation(*dialog);
dialog->setController(ci);
dialog->setView(new GuiCitationDialog(*dialog, ci));
dialog->bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
dialog = new GuiCitationDialog(lyxview_);
} else if (name == "document") {
dialog->setController(new ControlDocument(*dialog));
dialog->setView(new GuiDocument(*dialog));
dialog->bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
dialog = new GuiDocumentDialog(lyxview_);
} else if (name == "embedding") {
GuiViewBase & gui_view = static_cast<GuiViewBase &>(lyxview_);
GuiEmbeddedFiles * qef = new GuiEmbeddedFiles(*dialog);
dialog->setController(qef);
dialog->setView(new DockView<GuiEmbeddedFiles, GuiEmbeddedFilesDialog>(
*dialog, qef, &gui_view, _("Embedded Files"), Qt::RightDockWidgetArea));
dialog->bc().setPolicy(ButtonPolicy::OkCancelPolicy);
dialog = new GuiEmbeddedFilesDialog(lyxview_);
} else if (name == "errorlist") {
dialog->setController(new ControlErrorList(*dialog));
dialog->setView(new GuiErrorList(*dialog));
dialog->bc().setPolicy(ButtonPolicy::OkCancelPolicy);
dialog = new GuiErrorListDialog(lyxview_);
} else if (name == "ert") {
dialog->setController(new ControlERT(*dialog));
dialog->setView(new GuiERT(*dialog));
dialog->bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
dialog = new GuiERTDialog(lyxview_);
} else if (name == "external") {
dialog->setController(new ControlExternal(*dialog));
dialog->setView(new GuiExternal(*dialog));
dialog->bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
dialog = new GuiExternalDialog(lyxview_);
} else if (name == "file") {
dialog->setController(new ControlShowFile(*dialog));
dialog->setView(new GuiShowFile(*dialog));
dialog->bc().setPolicy(ButtonPolicy::OkCancelPolicy);
dialog = new GuiShowFileDialog(lyxview_);
} else if (name == "findreplace") {
dialog->setController(new ControlSearch(*dialog));
dialog->setView(new GuiSearch(*dialog));
dialog->bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
dialog = new GuiSearchDialog(lyxview_);
} else if (name == "float") {
dialog->setController(new ControlFloat(*dialog));
dialog->setView(new GuiFloat(*dialog));
dialog->bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
dialog = new GuiFloatDialog(lyxview_);
} else if (name == "graphics") {
dialog->setController(new ControlGraphics(*dialog));
dialog->setView(new GuiGraphics(*dialog));
dialog->bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
dialog = new GuiGraphicsDialog(lyxview_);
} else if (name == "include") {
dialog->setController(new ControlInclude(*dialog));
dialog->setView(new GuiInclude(*dialog));
dialog->bc().setPolicy(ButtonPolicy::OkApplyCancelReadOnlyPolicy);
dialog = new GuiIncludeDialog(lyxview_);
} else if (name == "index") {
dialog->setController(new ControlCommand(*dialog, name, name));
dialog->setView(new GuiIndex(*dialog,
_("Index Entry"),
qt_("&Keyword:")));
dialog->bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
dialog = new GuiIndexDialog(lyxview_);
} else if (name == "nomenclature") {
dialog->setController(new ControlCommand(*dialog, name, name));
dialog->setView(new GuiNomencl(*dialog, _("Nomenclature Entry")));
dialog->bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
dialog = new GuiNomenclDialog(lyxview_);
} else if (name == "label") {
dialog->setController(new ControlCommand(*dialog, name, name));
dialog->setView(new GuiIndex(*dialog,
_("Label"),
qt_("&Label:")));
dialog->bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
dialog = new GuiLabelDialog(lyxview_);
} else if (name == "log") {
dialog->setController(new ControlLog(*dialog));
dialog->setView(new GuiLog(*dialog));
dialog->bc().setPolicy(ButtonPolicy::OkCancelPolicy);
dialog = new GuiLogDialog(lyxview_);
} else if (name == "view-source") {
GuiViewSource * qvs = new GuiViewSource(*dialog);
dialog->setController(qvs);
GuiViewBase & gui_view = static_cast<GuiViewBase &>(lyxview_);
dialog->setView(new DockView<GuiViewSource, GuiViewSourceDialog>(
*dialog, qvs, &gui_view, _("LaTeX Source"), Qt::BottomDockWidgetArea));
dialog->bc().setPolicy(ButtonPolicy::OkCancelPolicy);
dialog = new GuiViewSourceDialog(lyxview_);
} else if (name == "mathdelimiter") {
dialog->setController(new ControlMath(*dialog));
dialog->setView(new GuiDelimiter(*dialog));
dialog->bc().setPolicy(ButtonPolicy::IgnorantPolicy);
dialog = new GuiDelimiterDialog(lyxview_);
} else if (name == "mathmatrix") {
dialog->setController(new ControlMath(*dialog));
dialog->setView(new GuiMathMatrix(*dialog));
dialog->bc().setPolicy(ButtonPolicy::IgnorantPolicy);
dialog = new GuiMathMatrixDialog(lyxview_);
} else if (name == "note") {
dialog->setController(new ControlNote(*dialog));
dialog->setView(new GuiNote(*dialog));
dialog->bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
dialog = new GuiNoteDialog(lyxview_);
} else if (name == "paragraph") {
dialog->setController(new ControlParagraph(*dialog));
dialog->setView(new GuiParagraph(*dialog));
dialog->bc().setPolicy(ButtonPolicy::OkApplyCancelReadOnlyPolicy);
dialog = new GuiParagraphDialog(lyxview_);
} else if (name == "prefs") {
dialog->setController(new ControlPrefs(*dialog));
dialog->setView(new GuiPrefs(*dialog));
dialog->bc().setPolicy(ButtonPolicy::PreferencesPolicy);
dialog = new GuiPrefsDialog(lyxview_);
} else if (name == "print") {
dialog->setController(new ControlPrint(*dialog));
dialog->setView(new GuiPrint(*dialog));
dialog->bc().setPolicy(ButtonPolicy::OkApplyCancelPolicy);
dialog = new GuiPrintDialog(lyxview_);
} else if (name == "ref") {
// full qualification because qt4 has also a ControlRef type
dialog->setController(new ControlRef(*dialog));
dialog->setView(new GuiRef(*dialog));
dialog->bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
dialog = new GuiRefDialog(lyxview_);
} else if (name == "sendto") {
dialog->setController(new ControlSendto(*dialog));
dialog->setView(new GuiSendto(*dialog));
dialog->bc().setPolicy(ButtonPolicy::OkApplyCancelPolicy);
dialog = new GuiSendtoDialog(lyxview_);
} else if (name == "spellchecker") {
dialog->setController(new ControlSpellchecker(*dialog));
dialog->setView(new GuiSpellchecker(*dialog));
dialog->bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
dialog = new GuiSpellcheckerDialog(lyxview_);
} else if (name == "tabular") {
dialog->setController(new ControlTabular(*dialog));
dialog->setView(new GuiTabular(*dialog));
dialog->bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
dialog = new GuiTabularDialog(lyxview_);
} else if (name == "tabularcreate") {
dialog->setController(new ControlTabularCreate(*dialog));
dialog->setView(new GuiTabularCreate(*dialog));
dialog->bc().setPolicy(ButtonPolicy::IgnorantPolicy);
dialog = new GuiTabularCreateDialog(lyxview_);
} else if (name == "texinfo") {
dialog->setController(new ControlTexinfo(*dialog));
dialog->setView(new GuiTexinfo(*dialog));
dialog->bc().setPolicy(ButtonPolicy::OkCancelPolicy);
dialog = new GuiTexinfoDialog(lyxview_);
#ifdef HAVE_LIBAIKSAURUS
} else if (name == "thesaurus") {
dialog->setController(new ControlThesaurus(*dialog));
dialog->setView(new GuiThesaurus(*dialog));
dialog->bc().setPolicy(ButtonPolicy::OkApplyCancelReadOnlyPolicy);
dialog = new GuiThesaurusDialog(lyxview_);
#endif
} else if (name == "toc") {
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<GuiToc, TocWidget>(
*dialog, qtoc, &gui_view, _("Outline"), Qt::RightDockWidgetArea, Qt::Drawer));
#else
dialog->setView(new DockView<GuiToc, TocWidget>(
*dialog, qtoc, &gui_view, _("Outline")));
#endif
dialog->bc().setPolicy(ButtonPolicy::OkCancelPolicy);
dialog = new GuiToc(lyxview_);
} else if (name == "url") {
dialog->setController(new ControlCommand(*dialog, name, name));
dialog->setView(new UrlView(*dialog));
dialog->bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
dialog = new GuiURLDialog(lyxview_);
} else if (name == "vspace") {
dialog->setController(new ControlVSpace(*dialog));
dialog->setView(new GuiVSpace(*dialog));
dialog->bc().setPolicy(ButtonPolicy::OkApplyCancelReadOnlyPolicy);
dialog = new GuiVSpaceDialog(lyxview_);
} else if (name == "wrap") {
dialog->setController(new ControlWrap(*dialog));
dialog->setView(new GuiWrap(*dialog));
dialog->bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
dialog = new GuiWrapDialog(lyxview_);
} else if (name == "listings") {
dialog->setController(new ControlListings(*dialog));
dialog->setView(new GuiListings(*dialog));
dialog->bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
dialog = new GuiListingsDialog(lyxview_);
}
return dialog;

View File

@ -23,6 +23,7 @@
namespace lyx {
namespace frontend {
/*
/// Dock Widget container for LyX dialogs.
/// This template class that encapsulates a given Widget inside a
/// DockWidget and presents a Dialog::View interface
@ -65,6 +66,7 @@ private:
/// The encapsulated widget.
boost::scoped_ptr<Widget> widget_;
};
*/
} // frontend
} // lyx

View File

@ -31,29 +31,30 @@ using std::istringstream;
using std::ostringstream;
using std::string;
namespace lyx {
namespace frontend {
GuiAbout::GuiAbout(GuiDialog & parent)
: GuiView<GuiAboutDialog>(parent, _("About LyX"))
GuiAboutDialog::GuiAboutDialog(LyXView & lv)
: GuiDialog(lv, "aboutlyx")
{
}
setupUi(this);
setViewTitle(_("About LyX"));
setController(new ControlAboutlyx(*this));
void GuiAbout::build_dialog()
{
dialog_.reset(new GuiAboutDialog);
connect(dialog_.get()->closePB, SIGNAL(clicked()),
connect(closePB, SIGNAL(clicked()), this, SLOT(reject()));
connect(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()));
copyrightTB->setPlainText(toqstr(controller().getCopyright()));
copyrightTB->append("");
copyrightTB->append(toqstr(controller().getLicense()));
copyrightTB->append("");
copyrightTB->append(toqstr(controller().getDisclaimer()));
dialog_->versionLA->setText(toqstr(controller().getVersion()));
versionLA->setText(toqstr(controller().getVersion()));
// The code below should depend on a autoconf test. (Lgb)
#if 1
@ -100,17 +101,24 @@ void GuiAbout::build_dialog()
}
#endif
dialog_->creditsTB->setHtml(toqstr(out.str()));
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());
copyrightTB->hide();
setMinimumSize(copyrightTB->sizeHint());
copyrightTB->show();
setMinimumSize(sizeHint());
// Manage the cancel/close button
bc().setCancel(dialog_->closePB);
//FIXME bc().refresh();
bc().setPolicy(ButtonPolicy::OkCancelPolicy);
bc().setCancel(closePB);
bc().refresh();
}
ControlAboutlyx & GuiAboutDialog::controller() const
{
return static_cast<ControlAboutlyx &>(Dialog::controller());
}
} // namespace frontend

View File

@ -12,7 +12,7 @@
#ifndef GUIABOUT_H
#define GUIABOUT_H
#include "GuiDialogView.h"
#include "GuiDialog.h"
#include "ControlAboutlyx.h"
#include "ui_AboutUi.h"
@ -21,35 +21,15 @@
namespace lyx {
namespace frontend {
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 GuiView<GuiAboutDialog>
class GuiAboutDialog : public GuiDialog, public Ui::AboutUi
{
Q_OBJECT
public:
GuiAbout(GuiDialog &);
// Constructor
GuiAboutDialog(LyXView & lv);
/// parent controller
ControlAboutlyx & controller()
{ return static_cast<ControlAboutlyx &>(this->getController()); }
/// parent controller
ControlAboutlyx const & controller() const
{ return static_cast<ControlAboutlyx const &>(this->getController()); }
private:
/// not needed
virtual void applyView() {}
/// not needed
virtual void update_contents() {}
// build the dialog
virtual void build_dialog();
ControlAboutlyx & controller() const;
};
} // namespace frontend

View File

@ -1,5 +1,5 @@
/**
* \file qt4/GuiApplication.cpp
* \file GuiApplication.cpp
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*

View File

@ -123,8 +123,6 @@ public:
extern GuiApplication * guiApp;
} // namespace frontend
} // namespace lyx
#endif // GUIAPPLICATION_H

View File

@ -11,6 +11,7 @@
#include <config.h>
#include "GuiBibitem.h"
#include "ControlCommand.h"
#include "qt_helpers.h"
#include <QCloseEvent>
@ -21,80 +22,66 @@
namespace lyx {
namespace frontend {
/////////////////////////////////////////////////////////////////////
//
// GuiBibItemDialog
//
/////////////////////////////////////////////////////////////////////
GuiBibitemDialog::GuiBibitemDialog(GuiBibitem * form)
: form_(form)
GuiBibitemDialog::GuiBibitemDialog(LyXView & lv)
: GuiDialog(lv, "bibitem")
{
setupUi(this);
connect(okPB, SIGNAL(clicked()), form, SLOT(slotOK()));
connect(closePB, SIGNAL(clicked()), form, SLOT(slotClose()));
setViewTitle(_("Bibliography Entry Settings"));
setController(new ControlCommand(*this, "bibitem", "bibitem"));
connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
connect(keyED, SIGNAL(textChanged(const QString &)),
this, SLOT(change_adaptor()));
connect(labelED, SIGNAL(textChanged(const QString &)),
this, SLOT(change_adaptor()));
bc().setPolicy(ButtonPolicy::OkCancelReadOnlyPolicy);
bc().setOK(okPB);
bc().setCancel(closePB);
bc().addReadOnly(keyED);
bc().addReadOnly(labelED);
}
ControlCommand & GuiBibitemDialog::controller() const
{
return static_cast<ControlCommand &>(Dialog::controller());
}
void GuiBibitemDialog::change_adaptor()
{
form_->changed();
changed();
}
void GuiBibitemDialog::closeEvent(QCloseEvent *e)
{
form_->slotWMHide();
slotWMHide();
e->accept();
}
/////////////////////////////////////////////////////////////////////
//
// GuiBibItem
//
/////////////////////////////////////////////////////////////////////
GuiBibitem::GuiBibitem(GuiDialog & parent)
: GuiView<GuiBibitemDialog>(parent, _("Bibliography Entry Settings"))
void GuiBibitemDialog::update_contents()
{
keyED->setText(toqstr(controller().params()["key"]));
labelED->setText(toqstr(controller().params()["label"]));
}
void GuiBibitem::build_dialog()
void GuiBibitemDialog::applyView()
{
dialog_.reset(new GuiBibitemDialog(this));
bc().setOK(dialog_->okPB);
bc().setCancel(dialog_->closePB);
bc().addReadOnly(dialog_->keyED);
bc().addReadOnly(dialog_->labelED);
controller().params()["key"] = qstring_to_ucs4(keyED->text());
controller().params()["label"] = qstring_to_ucs4(labelED->text());
}
void GuiBibitem::update_contents()
bool GuiBibitemDialog::isValid()
{
dialog_->keyED->setText(toqstr(controller().params()["key"]));
dialog_->labelED->setText(toqstr(controller().params()["label"]));
}
void GuiBibitem::applyView()
{
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();
return !keyED->text().isEmpty();
}
} // namespace frontend

View File

@ -12,53 +12,36 @@
#ifndef GUIBIBITEM_H
#define GUIBIBITEM_H
#include "GuiDialogView.h"
#include "GuiDialog.h"
#include "ControlCommand.h"
#include "ui_BibitemUi.h"
#include <QDialog>
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 GuiBibitem : public GuiView<GuiBibitemDialog>
class GuiBibitemDialog : public GuiDialog, public Ui::BibitemUi
{
Q_OBJECT
public:
///
GuiBibitem(GuiDialog &);
/// parent controller
ControlCommand & controller()
{ return static_cast<ControlCommand &>(this->getController()); }
/// parent controller
ControlCommand const & controller() const
{ return static_cast<ControlCommand const &>(this->getController()); }
protected:
virtual bool isValid();
GuiBibitemDialog(LyXView & lv);
private Q_SLOTS:
void change_adaptor();
private:
friend class GuiBibitemDialog;
///
void closeEvent(QCloseEvent * e);
/// parent controller
ControlCommand & controller() const;
private:
///
bool isValid();
/// Apply changes
virtual void applyView();
void applyView();
/// update
virtual void update_contents();
/// build the dialog
virtual void build_dialog();
void update_contents();
};
} // namespace frontend

View File

@ -19,8 +19,8 @@
#include "Validator.h"
#include "LyXRC.h"
#include "controllers/ControlBibtex.h"
#include "controllers/ButtonPolicy.h"
#include "ControlBibtex.h"
#include "ButtonPolicy.h"
#include "support/filetools.h" // changeExtension
#include "support/lstrings.h"
@ -47,27 +47,25 @@ using support::split;
using support::trim;
/////////////////////////////////////////////////////////////////////
//
// GuiBibtexDialog
//
/////////////////////////////////////////////////////////////////////
GuiBibtexDialog::GuiBibtexDialog(GuiBibtex * form)
: form_(form)
GuiBibtexDialog::GuiBibtexDialog(LyXView & lv)
: GuiDialog(lv, "bibtex")
{
setupUi(this);
setViewTitle( _("BibTeX Bibliography"));
setController(new ControlBibtex(*this));
QDialog::setModal(true);
connect(okPB, SIGNAL(clicked()),
form, SLOT(slotOK()));
this, SLOT(slotOK()));
connect(closePB, SIGNAL(clicked()),
form, SLOT(slotClose()));
this, SLOT(slotClose()));
connect(stylePB, SIGNAL(clicked()),
this, SLOT(browsePressed()));
connect(deletePB, SIGNAL(clicked()),
this, SLOT(deletePressed()));
connect(styleCB, SIGNAL(editTextChanged (const QString &)),
connect(styleCB, SIGNAL(editTextChanged(const QString &)),
this, SLOT(change_adaptor()));
connect(databaseLW, SIGNAL(itemSelectionChanged()),
this, SLOT(databaseChanged()));
@ -78,7 +76,7 @@ GuiBibtexDialog::GuiBibtexDialog(GuiBibtex * form)
connect(addBibPB, SIGNAL(clicked()),
this, SLOT(addPressed()));
add_ = new UiDialog<Ui::BibtexAddUi>(this, true);
add_ = new GuiBibtexAddDialog(this);
add_bc_.setPolicy(ButtonPolicy::OkCancelPolicy);
add_bc_.setOK(add_->addPB);
add_bc_.setCancel(add_->closePB);
@ -100,6 +98,22 @@ GuiBibtexDialog::GuiBibtexDialog(GuiBibtex * form)
this, SLOT(browseBibPressed()));
connect(add_->closePB, SIGNAL(clicked()),
add_, SLOT(reject()));
bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
bc().setOK(okPB);
bc().setCancel(closePB);
bc().addReadOnly(databaseLW);
bc().addReadOnly(stylePB);
bc().addReadOnly(styleCB);
bc().addReadOnly(bibtocCB);
bc().addReadOnly(addBibPB);
bc().addReadOnly(deletePB);
}
ControlBibtex & GuiBibtexDialog::controller() const
{
return static_cast<ControlBibtex &>(Dialog::controller());
}
@ -114,13 +128,13 @@ void GuiBibtexDialog::bibEDChanged()
void GuiBibtexDialog::change_adaptor()
{
form_->changed();
changed();
}
void GuiBibtexDialog::browsePressed()
{
docstring const file = form_->controller().browseBst(docstring());
docstring const file = controller().browseBst(docstring());
if (!file.empty()) {
// FIXME UNICODE
@ -139,14 +153,14 @@ void GuiBibtexDialog::browsePressed()
styleCB->insertItem(0, toqstr(filen));
styleCB->setCurrentIndex(pres);
form_->changed();
changed();
}
}
void GuiBibtexDialog::browseBibPressed()
{
docstring const file = trim(form_->controller().browseBib(docstring()));
docstring const file = trim(controller().browseBib(docstring()));
if (!file.empty()) {
// FIXME UNICODE
@ -160,7 +174,7 @@ void GuiBibtexDialog::browseBibPressed()
if (!present) {
add_->bibLW->addItem(f);
form_->changed();
changed();
}
add_->bibED->setText(f);
@ -205,21 +219,21 @@ void GuiBibtexDialog::addDatabase()
databaseLW->addItem(f);
}
form_->changed();
changed();
}
void GuiBibtexDialog::deletePressed()
{
databaseLW->takeItem(databaseLW->currentRow());
form_->changed();
changed();
}
void GuiBibtexDialog::databaseChanged()
{
deletePB->setEnabled(!form_->readOnly() && databaseLW->currentRow() != -1);
deletePB->setEnabled(!readOnly() && databaseLW->currentRow() != -1);
}
@ -231,44 +245,16 @@ void GuiBibtexDialog::availableChanged()
void GuiBibtexDialog::closeEvent(QCloseEvent *e)
{
form_->slotWMHide();
slotWMHide();
e->accept();
}
/////////////////////////////////////////////////////////////////////
//
// GuiBibTex
//
/////////////////////////////////////////////////////////////////////
GuiBibtex::GuiBibtex(GuiDialog & parent)
: GuiView<GuiBibtexDialog>(parent, _("BibTeX Bibliography"))
{
}
void GuiBibtex::build_dialog()
{
dialog_.reset(new GuiBibtexDialog(this));
bc().setOK(dialog_->okPB);
bc().setCancel(dialog_->closePB);
bc().addReadOnly(dialog_->databaseLW);
bc().addReadOnly(dialog_->stylePB);
bc().addReadOnly(dialog_->styleCB);
bc().addReadOnly(dialog_->bibtocCB);
bc().addReadOnly(dialog_->addBibPB);
bc().addReadOnly(dialog_->deletePB);
}
void GuiBibtex::update_contents()
void GuiBibtexDialog::update_contents()
{
bool bibtopic = controller().usingBibtopic();
dialog_->databaseLW->clear();
databaseLW->clear();
docstring bibs(controller().params()["bibfiles"]);
docstring bib;
@ -277,23 +263,23 @@ void GuiBibtex::update_contents()
bibs = split(bibs, bib, ',');
bib = trim(bib);
if (!bib.empty())
dialog_->databaseLW->addItem(toqstr(bib));
databaseLW->addItem(toqstr(bib));
}
dialog_->add_->bibLW->clear();
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));
add_->bibLW->addItem(toqstr(bibItem));
}
string bibstyle(controller().getStylefile());
dialog_->bibtocCB->setChecked(controller().bibtotoc() && !bibtopic);
dialog_->bibtocCB->setEnabled(!bibtopic);
bibtocCB->setChecked(controller().bibtotoc() && !bibtopic);
bibtocCB->setEnabled(!bibtopic);
docstring btprint(controller().params()["btprint"]);
int btp = 0;
@ -302,10 +288,10 @@ void GuiBibtex::update_contents()
else if (btprint == "btPrintAll")
btp = 2;
dialog_->btPrintCO->setCurrentIndex(btp);
dialog_->btPrintCO->setEnabled(bibtopic);
btPrintCO->setCurrentIndex(btp);
btPrintCO->setEnabled(bibtopic);
dialog_->styleCB->clear();
styleCB->clear();
int item_nr(-1);
@ -316,35 +302,35 @@ void GuiBibtex::update_contents()
string item(changeExtension(*it, ""));
if (item == bibstyle)
item_nr = int(it - str.begin());
dialog_->styleCB->addItem(toqstr(item));
styleCB->addItem(toqstr(item));
}
if (item_nr == -1 && !bibstyle.empty()) {
dialog_->styleCB->addItem(toqstr(bibstyle));
item_nr = dialog_->styleCB->count() - 1;
styleCB->addItem(toqstr(bibstyle));
item_nr = styleCB->count() - 1;
}
if (item_nr != -1)
dialog_->styleCB->setCurrentIndex(item_nr);
styleCB->setCurrentIndex(item_nr);
else
dialog_->styleCB->clearEditText();
styleCB->clearEditText();
}
void GuiBibtex::applyView()
void GuiBibtexDialog::applyView()
{
docstring dbs(qstring_to_ucs4(dialog_->databaseLW->item(0)->text()));
docstring dbs = qstring_to_ucs4(databaseLW->item(0)->text());
unsigned int maxCount = dialog_->databaseLW->count();
unsigned int maxCount = databaseLW->count();
for (unsigned int i = 1; i < maxCount; i++) {
dbs += ',';
dbs += qstring_to_ucs4(dialog_->databaseLW->item(i)->text());
dbs += qstring_to_ucs4(databaseLW->item(i)->text());
}
controller().params()["bibfiles"] = dbs;
docstring const bibstyle(qstring_to_ucs4(dialog_->styleCB->currentText()));
bool const bibtotoc(dialog_->bibtocCB->isChecked());
docstring const bibstyle(qstring_to_ucs4(styleCB->currentText()));
bool const bibtotoc(bibtocCB->isChecked());
if (bibtotoc && (!bibstyle.empty())) {
// both bibtotoc and style
@ -363,7 +349,7 @@ void GuiBibtex::applyView()
// 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();
int btp = btPrintCO->currentIndex();
switch (btp) {
case 0:
@ -382,9 +368,9 @@ void GuiBibtex::applyView()
}
bool GuiBibtex::isValid()
bool GuiBibtexDialog::isValid()
{
return dialog_->databaseLW->count() != 0;
return databaseLW->count() != 0;
}
} // namespace frontend

View File

@ -12,81 +12,61 @@
#ifndef GUIBIBTEX_H
#define GUIBIBTEX_H
#include "GuiDialogView.h"
#include "ButtonController.h"
#include "GuiDialog.h"
#include "ControlBibtex.h"
#include "ButtonController.h"
#include "ui_BibtexUi.h"
#include "ui_BibtexAddUi.h"
#include <QDialog>
namespace lyx {
namespace frontend {
class GuiBibtex;
template<class UI>
class UiDialog : public QDialog, public UI
class GuiBibtexAddDialog : public QDialog, public Ui::BibtexAddUi
{
public:
UiDialog(QWidget * parent=0, bool modal=false, Qt::WFlags f=0)
: QDialog(parent, f)
GuiBibtexAddDialog(QWidget * parent) : QDialog(parent)
{
UI::setupUi(this);
QDialog::setModal(modal);
Ui::BibtexAddUi::setupUi(this);
QDialog::setModal(true);
}
};
class GuiBibtexDialog : public QDialog, public Ui::BibtexUi {
class GuiBibtexDialog : public GuiDialog, public Ui::BibtexUi
{
Q_OBJECT
public:
GuiBibtexDialog(GuiBibtex * form);
GuiBibtexDialog(LyXView & lv);
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();
private Q_SLOTS:
void change_adaptor();
void browsePressed();
void browseBibPressed();
void addPressed();
void addDatabase();
void deletePressed();
void databaseChanged();
void availableChanged();
void bibEDChanged();
protected:
virtual void closeEvent(QCloseEvent * e);
private:
void closeEvent(QCloseEvent * e);
private:
GuiBibtex * form_;
ButtonController add_bc_;
};
class GuiBibtex : public GuiView<GuiBibtexDialog>
{
public:
friend class GuiBibtexDialog;
GuiBibtex(GuiDialog &);
/// parent controller
ControlBibtex & controller()
{ return static_cast<ControlBibtex &>(this->getController()); }
/// parent controller
ControlBibtex const & controller() const
{ return static_cast<ControlBibtex const &>(this->getController()); }
protected:
ControlBibtex & controller() const;
///
virtual bool isValid();
private:
/// Apply changes
virtual void applyView();
/// update
virtual void update_contents();
/// build the dialog
virtual void build_dialog();
///
GuiBibtexAddDialog * add_;
///
ButtonController add_bc_;
};
} // namespace frontend

View File

@ -14,6 +14,8 @@
#include "GuiBox.h"
#include "ControlBox.h"
#include "LengthCombo.h"
#include "qt_helpers.h"
#include "lengthcommon.h"
@ -41,20 +43,29 @@ using std::string;
namespace lyx {
namespace frontend {
//////////////////////////////////////////////////////////////////
//
// GuiBoxDialog
//
//////////////////////////////////////////////////////////////////
GuiBoxDialog::GuiBoxDialog(GuiBox * form)
: form_(form)
GuiBoxDialog::GuiBoxDialog(LyXView & lv)
: GuiDialog(lv, "box")
{
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()));
setViewTitle(_("Box Settings"));
setController(new ControlBox(*this));
// fill the box type choice
box_gui_tokens(ids_, gui_names_);
for (unsigned int i = 0; i < gui_names_.size(); ++i)
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)
heightUnitsLC->addItem(toqstr(gui_names_spec_[i]));
connect(restorePB, SIGNAL(clicked()), this, SLOT(slotRestore()));
connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
connect(applyPB, SIGNAL(clicked()), this, SLOT(slotApply()));
connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
connect(widthED, SIGNAL(textChanged(const QString &)),
this, SLOT(change_adaptor()));
@ -77,19 +88,46 @@ GuiBoxDialog::GuiBoxDialog(GuiBox * form)
heightED->setValidator(unsignedLengthValidator(heightED));
widthED->setValidator(unsignedLengthValidator(widthED));
bc().setPolicy(ButtonPolicy::OkApplyCancelReadOnlyPolicy);
bc().addReadOnly(typeCO);
bc().addReadOnly(innerBoxCO);
bc().addReadOnly(valignCO);
bc().addReadOnly(ialignCO);
bc().addReadOnly(halignCO);
bc().addReadOnly(widthED);
bc().addReadOnly(heightED);
bc().addReadOnly(widthUnitsLC);
bc().addReadOnly(heightUnitsLC);
bc().setRestore(restorePB);
bc().setOK(okPB);
bc().setApply(applyPB);
bc().setCancel(closePB);
// initialize the length validator
bc().addCheckedLineEdit(widthED, widthLA);
bc().addCheckedLineEdit(heightED, heightLA);
}
ControlBox & GuiBoxDialog::controller() const
{
return static_cast<ControlBox &>(Dialog::controller());
}
void GuiBoxDialog::closeEvent(QCloseEvent * e)
{
form_->slotWMHide();
slotWMHide();
e->accept();
}
void GuiBoxDialog::change_adaptor()
{
form_->changed();
changed();
}
@ -101,7 +139,7 @@ void GuiBoxDialog::innerBoxChanged(const QString & str)
halignCO->setEnabled(!ibox);
heightED->setEnabled(ibox);
heightUnitsLC->setEnabled(ibox);
form_->setSpecial(ibox);
setSpecial(ibox);
}
@ -114,16 +152,16 @@ void GuiBoxDialog::typeChanged(int index)
halignCO->setEnabled(false);
heightED->setEnabled(true);
heightUnitsLC->setEnabled(true);
form_->setSpecial(true);
setSpecial(true);
}
int itype = innerBoxCO->currentIndex();
form_->setInnerType(frameless, itype);
setInnerType(frameless, itype);
}
void GuiBoxDialog::restoreClicked()
{
form_->setInnerType(true, 2);
setInnerType(true, 2);
widthED->setText("100");
widthUnitsLC->setCurrentItem(Length::PCW);
heightED->setText("1");
@ -134,60 +172,12 @@ void GuiBoxDialog::restoreClicked()
}
//////////////////////////////////////////////////////////////////
//
// GuiBox
//
//////////////////////////////////////////////////////////////////
GuiBox::GuiBox(GuiDialog & parent)
: GuiView<GuiBoxDialog>(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]));
bc().addReadOnly(dialog_->typeCO);
bc().addReadOnly(dialog_->innerBoxCO);
bc().addReadOnly(dialog_->valignCO);
bc().addReadOnly(dialog_->ialignCO);
bc().addReadOnly(dialog_->halignCO);
bc().addReadOnly(dialog_->widthED);
bc().addReadOnly(dialog_->heightED);
bc().addReadOnly(dialog_->widthUnitsLC);
bc().addReadOnly(dialog_->heightUnitsLC);
bc().setRestore(dialog_->restorePB);
bc().setOK(dialog_->okPB);
bc().setApply(dialog_->applyPB);
bc().setCancel(dialog_->closePB);
// initialize the length validator
bc().addCheckedLineEdit(dialog_->widthED, dialog_->widthLA);
bc().addCheckedLineEdit(dialog_->heightED, dialog_->heightLA);
}
void GuiBox::update_contents()
void GuiBoxDialog::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);
typeCO->setCurrentIndex(i);
}
// default: minipage
@ -202,22 +192,22 @@ void GuiBox::update_contents()
setInnerType(frameless, inner_type);
char c = controller().params().pos;
dialog_->valignCO->setCurrentIndex(string("tcb").find(c, 0));
valignCO->setCurrentIndex(string("tcb").find(c, 0));
c = controller().params().inner_pos;
dialog_->ialignCO->setCurrentIndex(string("tcbs").find(c, 0));
ialignCO->setCurrentIndex(string("tcbs").find(c, 0));
c = controller().params().hor_pos;
dialog_->halignCO->setCurrentIndex(string("lcrs").find(c, 0));
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);
valignCO->setEnabled(ibox);
ialignCO->setEnabled(ibox);
halignCO->setEnabled(!ibox);
setSpecial(ibox);
Length::UNIT default_unit =
(lyxrc.default_papersize > 3) ? Length::CM : Length::IN;
lengthToWidgets(dialog_->widthED, dialog_->widthUnitsLC,
lengthToWidgets(widthED, widthUnitsLC,
(controller().params().width).asString(), default_unit);
string const special(controller().params().special);
@ -227,13 +217,13 @@ void GuiBox::update_contents()
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);
for (int j = 0; j < widthUnitsLC->count(); j++) {
if (widthUnitsLC->itemText(j) == spc)
widthUnitsLC->setCurrentIndex(j);
}
}
lengthToWidgets(dialog_->heightED, dialog_->heightUnitsLC,
lengthToWidgets(heightED, heightUnitsLC,
(controller().params().height).asString(), default_unit);
string const height_special(controller().params().height_special);
@ -244,39 +234,39 @@ void GuiBox::update_contents()
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);
for (int j = 0; j < heightUnitsLC->count(); j++) {
if (heightUnitsLC->itemText(j) == hspc) {
heightUnitsLC->setCurrentIndex(j);
}
}
}
dialog_->heightED->setEnabled(ibox);
dialog_->heightUnitsLC->setEnabled(ibox);
heightED->setEnabled(ibox);
heightUnitsLC->setEnabled(ibox);
}
void GuiBox::applyView()
void GuiBoxDialog::applyView()
{
controller().params().type =
ids_[dialog_->typeCO->currentIndex()];
ids_[typeCO->currentIndex()];
controller().params().inner_box =
dialog_->innerBoxCO->currentText() != qt_("None");
innerBoxCO->currentText() != qt_("None");
controller().params().use_parbox =
dialog_->innerBoxCO->currentText() == qt_("Parbox");
innerBoxCO->currentText() == qt_("Parbox");
controller().params().pos =
"tcb"[dialog_->valignCO->currentIndex()];
"tcb"[valignCO->currentIndex()];
controller().params().inner_pos =
"tcbs"[dialog_->ialignCO->currentIndex()];
"tcbs"[ialignCO->currentIndex()];
controller().params().hor_pos =
"lcrs"[dialog_->halignCO->currentIndex()];
"lcrs"[halignCO->currentIndex()];
int i = 0;
bool spec = false;
QString special = dialog_->widthUnitsLC->currentText();
QString value = dialog_->widthED->text();
QString special = widthUnitsLC->currentText();
QString value = widthED->text();
if (special == qt_("Height")) {
i = 1;
spec = true;
@ -303,14 +293,14 @@ void GuiBox::applyView()
// beware: bogosity! the unit is simply ignored in this case
width += "in";
} else
width = widgetsToLength(dialog_->widthED, dialog_->widthUnitsLC);
width = widgetsToLength(widthED, widthUnitsLC);
controller().params().width = Length(width);
i = 0;
spec = false;
special = dialog_->heightUnitsLC->currentText();
value = dialog_->heightED->text();
special = heightUnitsLC->currentText();
value = heightED->text();
if (special == qt_("Height")) {
i = 1;
spec = true;
@ -332,56 +322,56 @@ void GuiBox::applyView()
controller().params().height_special = ids_spec_[i];
string height;
if (spec && !isValidLength(fromqstr(dialog_->heightED->text()))) {
if (spec && !isValidLength(fromqstr(heightED->text()))) {
height = fromqstr(value);
// beware: bogosity! the unit is simply ignored in this case
height += "in";
} else
height = widgetsToLength(dialog_->heightED, dialog_->heightUnitsLC);
height = widgetsToLength(heightED, heightUnitsLC);
controller().params().height = Length(height);
}
void GuiBox::setSpecial(bool ibox)
void GuiBoxDialog::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();
int count = widthUnitsLC->count();
bool has_special = false;
for (int i = 0; i < count; i++)
if (dialog_->widthUnitsLC->itemText(i).contains(qt_("Total Height")) > 0)
if (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]));
widthUnitsLC->addItem(toqstr(gui_names_spec_[i]));
// ... or remove 'em if needed
} else if (ibox && has_special) {
dialog_->widthUnitsLC->clear();
widthUnitsLC->clear();
for (int i = 0; i < num_units; i++)
dialog_->widthUnitsLC->addItem(qt_(unit_name_gui[i]));
widthUnitsLC->addItem(qt_(unit_name_gui[i]));
}
}
void GuiBox::setInnerType(bool frameless, int i)
void GuiBoxDialog::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);
innerBoxCO->clear();
innerBoxCO->addItem(qt_("Parbox"));
innerBoxCO->addItem(qt_("Minipage"));
innerBoxCO->setCurrentIndex(i - 1);
} else {
if (dialog_->innerBoxCO->count() == 2)
if (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);
innerBoxCO->clear();
innerBoxCO->addItem(qt_("None"));
innerBoxCO->addItem(qt_("Parbox"));
innerBoxCO->addItem(qt_("Minipage"));
innerBoxCO->setCurrentIndex(i);
}
}

View File

@ -13,60 +13,43 @@
#ifndef GUIBOX_H
#define GUIBOX_H
#include "GuiDialogView.h"
#include "GuiDialog.h"
#include "ControlBox.h"
#include "ui_BoxUi.h"
#include <QDialog>
#include <vector>
namespace lyx {
namespace frontend {
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 GuiView<GuiBoxDialog>
class GuiBoxDialog : public GuiDialog, public Ui::BoxUi
{
Q_OBJECT
public:
///
GuiBox(GuiDialog &);
GuiBoxDialog(LyXView & lv);
private Q_SLOTS:
void change_adaptor();
void innerBoxChanged(const QString &);
void typeChanged(int);
void restoreClicked();
private:
void closeEvent(QCloseEvent * e);
/// parent controller
ControlBox & controller()
{ return static_cast<ControlBox &>(this->getController()); }
/// parent controller
ControlBox const & controller() const
{ return static_cast<ControlBox const &>(this->getController()); }
ControlBox & controller() const;
/// add and remove special lengths
void setSpecial(bool ibox);
/// only show valid inner box items
void setInnerType(bool frameless, int i);
private:
///
friend class GuiBoxDialog;
/// Apply changes
virtual void applyView();
void applyView();
/// update
virtual void update_contents();
/// build the dialog
virtual void build_dialog();
void update_contents();
///
std::vector<std::string> ids_;
///

View File

@ -11,8 +11,10 @@
#include <config.h>
#include "GuiBranch.h"
#include "qt_helpers.h"
#include "ControlBranch.h"
#include "qt_helpers.h"
#include "BranchList.h"
#include "insets/InsetBranch.h"
@ -20,70 +22,54 @@
#include <QPushButton>
#include <QCloseEvent>
namespace lyx {
namespace frontend {
/////////////////////////////////////////////////////////////////////
//
// GuiBranchDialog
//
/////////////////////////////////////////////////////////////////////
GuiBranchDialog::GuiBranchDialog(GuiBranch * form)
: form_(form)
GuiBranchDialog::GuiBranchDialog(LyXView & lv)
: GuiDialog(lv, "branch")
{
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() ) );
setController(new ControlBranch(*this));
setViewTitle(_("Branch Settings"));
connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
connect(branchCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
bc().setOK(okPB);
bc().setCancel(closePB);
}
ControlBranch & GuiBranchDialog::controller() const
{
return static_cast<ControlBranch &>(Dialog::controller());
}
void GuiBranchDialog::closeEvent(QCloseEvent * e)
{
form_->slotWMHide();
slotWMHide();
e->accept();
}
void GuiBranchDialog::change_adaptor()
{
form_->changed();
changed();
}
/////////////////////////////////////////////////////////////////////
//
// GuiBranch
//
/////////////////////////////////////////////////////////////////////
GuiBranch::GuiBranch(GuiDialog & parent)
: GuiView<GuiBranchDialog>(parent, _("Branch Settings"))
{}
void GuiBranch::build_dialog()
{
dialog_.reset(new GuiBranchDialog(this));
bc().setOK(dialog_->okPB);
bc().setCancel(dialog_->closePB);
}
void GuiBranch::update_contents()
void GuiBranchDialog::update_contents()
{
typedef BranchList::const_iterator const_iterator;
BranchList const & branchlist = controller().branchlist();
docstring const cur_branch = controller().params().branch;
dialog_->branchCO->clear();
branchCO->clear();
const_iterator const begin = branchlist.begin();
const_iterator const end = branchlist.end();
@ -91,18 +77,18 @@ void GuiBranch::update_contents()
int count = 0;
for (const_iterator it = begin; it != end; ++it, ++count) {
docstring const & branch = it->getBranch();
dialog_->branchCO->addItem(toqstr(branch));
branchCO->addItem(toqstr(branch));
if (cur_branch == branch)
id = count;
}
dialog_->branchCO->setCurrentIndex(id);
branchCO->setCurrentIndex(id);
}
void GuiBranch::applyView()
void GuiBranchDialog::applyView()
{
docstring const type = qstring_to_ucs4(dialog_->branchCO->currentText());
docstring const type = qstring_to_ucs4(branchCO->currentText());
controller().params().branch = type;
}

View File

@ -12,54 +12,35 @@
#ifndef GUIBRANCH_H
#define GUIBRANCH_H
#include "GuiDialogView.h"
#include "GuiDialog.h"
#include "ControlBranch.h"
#include "ui_BranchUi.h"
#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_;
};
/** This class provides a QT implementation of the Branch Dialog.
*/
class GuiBranch : public GuiView<GuiBranchDialog>
class GuiBranchDialog : public GuiDialog, public Ui::BranchUi
{
public:
/// Constructor
GuiBranch(GuiDialog &);
/// parent controller
ControlBranch & controller()
{ return static_cast<ControlBranch &>(this->getController()); }
/// parent controller
ControlBranch const & controller() const
{ return static_cast<ControlBranch const &>(this->getController()); }
private:
friend class GuiBranchDialog;
Q_OBJECT
public:
GuiBranchDialog(LyXView & lv);
private Q_SLOTS:
void change_adaptor();
private:
///
void closeEvent(QCloseEvent * e);
/// parent controller
ControlBranch & controller() const;
/// Apply changes
virtual void applyView();
/// Build the dialog
virtual void build_dialog();
void applyView();
/// Update dialog before showing it
virtual void update_contents();
void update_contents();
};
} // namespace frontend
} // namespace lyx

View File

@ -13,12 +13,13 @@
#include "GuiBranches.h"
#include "ControlBranch.h"
#include "ControlDocument.h"
#include "GuiApplication.h"
#include "Validator.h"
#include "qt_helpers.h"
#include "BufferParams.h"
#include "controllers/ControlDocument.h"
#include "support/lstrings.h"

View File

@ -12,8 +12,8 @@
#ifndef GUIBRANCHES_H
#define GUIBRANCHES_H
#include "ui_BranchesUi.h"
#include "GuiDocument.h"
#include "ui_BranchesUi.h"
#include "BranchList.h"
#include <QWidget>
@ -30,7 +30,7 @@ class BufferParams;
namespace frontend {
class GuiBranches: public QWidget, public Ui::BranchesUi
class GuiBranches : public QWidget, public Ui::BranchesUi
{
Q_OBJECT
public:

View File

@ -12,6 +12,8 @@
#include <config.h>
#include "GuiChanges.h"
#include "ControlChanges.h"
#include "qt_helpers.h"
#include "support/lstrings.h"
@ -25,73 +27,39 @@ using lyx::support::bformat;
namespace lyx {
namespace frontend {
/////////////////////////////////////////////////////////////////////
//
// GuiChangesDialog
//
/////////////////////////////////////////////////////////////////////
GuiChangesDialog::GuiChangesDialog(GuiChanges * form)
: form_(form)
GuiChangesDialog::GuiChangesDialog(LyXView & lv)
: GuiDialog(lv, "changes")
{
setupUi(this);
connect(closePB, SIGNAL(clicked()), form, SLOT(slotClose()));
setController(new ControlChanges(*this));
setViewTitle(_("Merge Changes"));
connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
connect(nextPB, SIGNAL(clicked()), this, SLOT(nextPressed()));
connect(rejectPB, SIGNAL(clicked()), this, SLOT(rejectPressed()));
connect(acceptPB, SIGNAL(clicked()), this, SLOT(acceptPressed()));
bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
bc().setCancel(closePB);
bc().addReadOnly(acceptPB);
bc().addReadOnly(rejectPB);
}
void GuiChangesDialog::nextPressed()
ControlChanges & GuiChangesDialog::controller() const
{
form_->next();
}
void GuiChangesDialog::acceptPressed()
{
form_->accept();
}
void GuiChangesDialog::rejectPressed()
{
form_->reject();
return static_cast<ControlChanges &>(Dialog::controller());
}
void GuiChangesDialog::closeEvent(QCloseEvent *e)
{
form_->slotWMHide();
slotWMHide();
e->accept();
}
/////////////////////////////////////////////////////////////////////
//
// GuiChanges
//
/////////////////////////////////////////////////////////////////////
GuiChanges::GuiChanges(GuiDialog & parent)
: GuiView<GuiChangesDialog>(parent, _("Merge Changes"))
{
}
void GuiChanges::build_dialog()
{
dialog_.reset(new GuiChangesDialog(this));
bc().setCancel(dialog_->closePB);
bc().addReadOnly(dialog_->acceptPB);
bc().addReadOnly(dialog_->rejectPB);
}
void GuiChanges::update_contents()
void GuiChangesDialog::update_contents()
{
docstring text;
docstring author = controller().getChangeAuthor();
@ -102,23 +70,23 @@ void GuiChanges::update_contents()
if (!date.empty())
text += bformat(_("Change made at %1$s\n"), date);
dialog_->changeTB->setPlainText(toqstr(text));
changeTB->setPlainText(toqstr(text));
}
void GuiChanges::next()
void GuiChangesDialog::nextPressed()
{
controller().next();
}
void GuiChanges::accept()
void GuiChangesDialog::acceptPressed()
{
controller().accept();
}
void GuiChanges::reject()
void GuiChangesDialog::rejectPressed()
{
controller().reject();
}

View File

@ -12,63 +12,29 @@
#ifndef GUICHANGES_H
#define GUICHANGES_H
#include "GuiDialogView.h"
#include "GuiDialog.h"
#include "ControlChanges.h"
#include "ui_ChangesUi.h"
#include <QDialog>
namespace lyx {
namespace frontend {
class GuiChanges;
class GuiChangesDialog : public QDialog, public Ui::ChangesUi {
class GuiChangesDialog : public GuiDialog, public Ui::ChangesUi
{
Q_OBJECT
public:
GuiChangesDialog(GuiChanges * form);
public:
GuiChangesDialog(LyXView & lv);
protected Q_SLOTS:
virtual void nextPressed();
virtual void acceptPressed();
virtual void rejectPressed();
protected:
virtual void closeEvent(QCloseEvent * e);
void nextPressed();
void acceptPressed();
void rejectPressed();
private:
GuiChanges * form_;
};
class GuiChanges : public GuiView<GuiChangesDialog>
{
public:
///
GuiChanges(GuiDialog &);
/// parent controller
ControlChanges & controller()
{ return static_cast<ControlChanges &>(this->getController()); }
/// parent controller
ControlChanges const & controller() const
{ return static_cast<ControlChanges const &>(this->getController()); }
void accept();
void reject();
void next();
private:
friend class GuiChangesDialog;
/// Apply changes
virtual void applyView() {};
/// update
virtual void update_contents();
/// build the dialog
virtual void build_dialog();
void closeEvent(QCloseEvent * e);
ControlChanges & controller() const;
void update_contents();
};
} // namespace frontend

View File

@ -12,6 +12,8 @@
#include <config.h>
#include "GuiCharacter.h"
#include "ControlCharacter.h"
#include "qt_helpers.h"
#include "frontend_helpers.h"
#include "Color.h"
@ -23,19 +25,16 @@ using std::vector;
namespace lyx {
namespace frontend {
/////////////////////////////////////////////////////////////////////
//
// GuiCharacterDialog
//
/////////////////////////////////////////////////////////////////////
GuiCharacterDialog::GuiCharacterDialog(GuiCharacter * form)
: form_(form)
GuiCharacterDialog::GuiCharacterDialog(LyXView & lv)
: GuiDialog(lv, "character")
{
setupUi(this);
connect(okPB, SIGNAL(clicked()), form_, SLOT(slotOK()));
connect(applyPB, SIGNAL(clicked()), form_, SLOT(slotApply()));
connect(closePB, SIGNAL(clicked()), form_, SLOT(slotClose()));
setController(new ControlCharacter(*this));
setViewTitle(_("Text Style"));
connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
connect(applyPB, SIGNAL(clicked()), this, SLOT(slotApply()));
connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
connect(miscCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
connect(sizeCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
@ -45,12 +44,77 @@ GuiCharacterDialog::GuiCharacterDialog(GuiCharacter * form)
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()));
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) {
familyCO->addItem(toqstr(cit->first));
}
for (vector<SeriesPair>::const_iterator cit = series.begin();
cit != series.end(); ++cit) {
seriesCO->addItem(toqstr(cit->first));
}
for (vector<ShapePair>::const_iterator cit = shape.begin();
cit != shape.end(); ++cit) {
shapeCO->addItem(toqstr(cit->first));
}
for (vector<SizePair>::const_iterator cit = size.begin();
cit != size.end(); ++cit) {
sizeCO->addItem(toqstr(cit->first));
}
for (vector<BarPair>::const_iterator cit = bar.begin();
cit != bar.end(); ++cit) {
miscCO->addItem(toqstr(cit->first));
}
for (vector<ColorPair>::const_iterator cit = color.begin();
cit != color.end(); ++cit) {
colorCO->addItem(toqstr(cit->first));
}
for (vector<LanguagePair>::const_iterator cit = language.begin();
cit != language.end(); ++cit) {
langCO->addItem(toqstr(cit->first));
}
bc().setPolicy(ButtonPolicy::OkApplyCancelReadOnlyPolicy);
bc().setOK(okPB);
bc().setApply(applyPB);
bc().setCancel(closePB);
bc().addReadOnly(familyCO);
bc().addReadOnly(seriesCO);
bc().addReadOnly(sizeCO);
bc().addReadOnly(shapeCO);
bc().addReadOnly(miscCO);
bc().addReadOnly(langCO);
bc().addReadOnly(colorCO);
bc().addReadOnly(toggleallCB);
bc().addReadOnly(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 ...
QDialog::show();
#endif
}
ControlCharacter & GuiCharacterDialog::controller() const
{
return static_cast<ControlCharacter &>(Dialog::controller());
}
void GuiCharacterDialog::change_adaptor()
{
form_->changed();
changed();
if (!autoapplyCB->isChecked())
return;
@ -59,7 +123,7 @@ void GuiCharacterDialog::change_adaptor()
// 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();
slotApply();
familyCO->setCurrentIndex(0);
seriesCO->setCurrentIndex(0);
sizeCO->setCurrentIndex(0);
@ -72,92 +136,13 @@ void GuiCharacterDialog::change_adaptor()
void GuiCharacterDialog::closeEvent(QCloseEvent * e)
{
form_->slotWMHide();
slotWMHide();
e->accept();
}
/////////////////////////////////////////////////////////////////////
//
// GuiCharacter
//
/////////////////////////////////////////////////////////////////////
GuiCharacter::GuiCharacter(GuiDialog & parent)
: GuiView<GuiCharacterDialog>(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));
}
bc().setOK(dialog_->okPB);
bc().setApply(dialog_->applyPB);
bc().setCancel(dialog_->closePB);
bc().addReadOnly(dialog_->familyCO);
bc().addReadOnly(dialog_->seriesCO);
bc().addReadOnly(dialog_->sizeCO);
bc().addReadOnly(dialog_->shapeCO);
bc().addReadOnly(dialog_->miscCO);
bc().addReadOnly(dialog_->langCO);
bc().addReadOnly(dialog_->colorCO);
bc().addReadOnly(dialog_->toggleallCB);
bc().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)
static int findPos2nd(vector<std::pair<A,B> > const & vec, B const & val)
{
typedef typename vector<std::pair<A, B> >::const_iterator
const_iterator;
@ -170,41 +155,39 @@ int findPos2nd(vector<std::pair<A,B> > const & vec, B const & val)
return 0;
}
} // namespace anon
void GuiCharacter::update_contents()
void GuiCharacterDialog::update_contents()
{
ControlCharacter const & ctrl = controller();
dialog_->familyCO->setCurrentIndex(findPos2nd(family,
familyCO->setCurrentIndex(findPos2nd(family,
ctrl.getFamily()));
dialog_->seriesCO->setCurrentIndex(findPos2nd(series,
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,
shapeCO->setCurrentIndex(findPos2nd(shape, ctrl.getShape()));
sizeCO->setCurrentIndex(findPos2nd(size, ctrl.getSize()));
miscCO->setCurrentIndex(findPos2nd(bar, ctrl.getBar()));
colorCO->setCurrentIndex(findPos2nd(color, ctrl.getColor()));
langCO->setCurrentIndex(findPos2nd(language,
ctrl.getLanguage()));
dialog_->toggleallCB->setChecked(ctrl.getToggleAll());
toggleallCB->setChecked(ctrl.getToggleAll());
}
void GuiCharacter::applyView()
void GuiCharacterDialog::applyView()
{
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.setFamily(family[familyCO->currentIndex()].second);
ctrl.setSeries(series[seriesCO->currentIndex()].second);
ctrl.setShape(shape[shapeCO->currentIndex()].second);
ctrl.setSize(size[sizeCO->currentIndex()].second);
ctrl.setBar(bar[miscCO->currentIndex()].second);
ctrl.setColor(color[colorCO->currentIndex()].second);
ctrl.setLanguage(language[langCO->currentIndex()].second);
ctrl.setToggleAll(dialog_->toggleallCB->isChecked());
ctrl.setToggleAll(toggleallCB->isChecked());
}
} // namespace frontend

View File

@ -13,51 +13,33 @@
#ifndef GUICHARACTER_H
#define GUICHARACTER_H
#include "GuiDialogView.h"
#include "GuiDialog.h"
#include "ControlCharacter.h"
#include "ui_CharacterUi.h"
#include <QDialog>
#include <vector>
namespace lyx {
namespace frontend {
class GuiCharacter;
class GuiCharacterDialog : public QDialog, public Ui::CharacterUi {
class GuiCharacterDialog : public GuiDialog, public Ui::CharacterUi
{
Q_OBJECT
public:
GuiCharacterDialog(GuiCharacter * form);
protected:
void closeEvent(QCloseEvent * e);
private:
GuiCharacter * form_;
GuiCharacterDialog(LyXView & lv);
protected Q_SLOTS:
void change_adaptor();
};
class GuiCharacter : public GuiView<GuiCharacterDialog>
{
public:
friend class GuiCharacterDialog;
GuiCharacter(GuiDialog &);
/// parent controller
ControlCharacter & controller()
{ return static_cast<ControlCharacter &>(this->getController()); }
/// parent controller
ControlCharacter const & controller() const
{ return static_cast<ControlCharacter const &>(this->getController()); }
private:
void closeEvent(QCloseEvent * e);
/// parent controller
ControlCharacter & controller() const;
/// Apply changes
virtual void applyView();
void applyView();
/// update
virtual void update_contents();
/// build the dialog
virtual void build_dialog();
void update_contents();
std::vector<FamilyPair> family;
std::vector<SeriesPair> series;

View File

@ -38,6 +38,9 @@ using std::vector;
using std::string;
namespace lyx {
namespace frontend {
template<typename String>
static QStringList to_qstring_list(vector<String> const & v)
{
@ -64,20 +67,12 @@ static vector<lyx::docstring> to_docstring_vector(QStringList const & qlist)
}
namespace lyx {
namespace frontend {
///////////////////////////////////////////////////////////////////////
//
// GuiCitationDialog
//
///////////////////////////////////////////////////////////////////////
GuiCitationDialog::GuiCitationDialog(Dialog & dialog, GuiCitation * form)
: Dialog::View(dialog, _("Citation")), form_(form)
GuiCitationDialog::GuiCitationDialog(LyXView & lv)
: GuiDialog(lv, "citation")
{
setupUi(this);
setViewTitle(_("Citation"));
setController(new ControlCitation(*this));
setWindowTitle(toqstr("LyX: " + getViewTitle()));
@ -97,8 +92,7 @@ GuiCitationDialog::GuiCitationDialog(Dialog & dialog, GuiCitation * form)
selectionManager =
new GuiSelectionManager(availableLV, selectedLV,
addPB, deletePB, upPB, downPB,
form_->available(), form_->selected());
addPB, deletePB, upPB, downPB, available(), selected());
connect(selectionManager, SIGNAL(selectionChanged()),
this, SLOT(setCitedKeys()));
connect(selectionManager, SIGNAL(updateHook()),
@ -106,25 +100,28 @@ GuiCitationDialog::GuiCitationDialog(Dialog & dialog, GuiCitation * form)
connect(selectionManager, SIGNAL(okHook()),
this, SLOT(on_okPB_clicked()));
bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
}
GuiCitationDialog::~GuiCitationDialog()
{}
ControlCitation & GuiCitationDialog::controller() const
{
return static_cast<ControlCitation &>(Dialog::controller());
}
void GuiCitationDialog::cleanUp()
{
form_->clearSelection();
form_->clearParams();
clearSelection();
controller().clearParams();
close();
}
void GuiCitationDialog::closeEvent(QCloseEvent * e)
{
form_->clearSelection();
form_->clearParams();
clearSelection();
controller().clearParams();
e->accept();
}
@ -139,13 +136,13 @@ void GuiCitationDialog::applyView()
QString const before = textBeforeED->text();
QString const after = textAfterED->text();
form_->apply(choice, full, force, before, after);
apply(choice, full, force, before, after);
}
void GuiCitationDialog::hideView()
{
form_->clearParams();
controller().clearParams();
accept();
}
@ -169,15 +166,15 @@ bool GuiCitationDialog::isVisibleView() const
void GuiCitationDialog::on_okPB_clicked()
{
applyView();
form_->clearSelection();
clearSelection();
hideView();
}
void GuiCitationDialog::on_cancelPB_clicked()
{
form_->clearSelection();
hide();
clearSelection();
hideView();
}
@ -189,8 +186,8 @@ void GuiCitationDialog::on_applyPB_clicked()
void GuiCitationDialog::on_restorePB_clicked()
{
form_->init();
update();
init();
updateView();
}
@ -202,12 +199,12 @@ void GuiCitationDialog::updateView()
}
//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.
// 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()) {
@ -223,8 +220,8 @@ void GuiCitationDialog::updateDialog()
}
setButtons();
textBeforeED->setText(form_->textBefore());
textAfterED->setText(form_->textAfter());
textBeforeED->setText(textBefore());
textAfterED->setText(textAfter());
fillStyles();
updateStyle();
}
@ -232,7 +229,7 @@ void GuiCitationDialog::updateDialog()
void GuiCitationDialog::updateStyle()
{
biblio::CiteEngine const engine = form_->getEngine();
biblio::CiteEngine const engine = controller().getEngine();
bool const natbib_engine =
engine == biblio::ENGINE_NATBIB_AUTHORYEAR ||
engine == biblio::ENGINE_NATBIB_NUMERICAL;
@ -249,7 +246,7 @@ void GuiCitationDialog::updateStyle()
citationStyleCO->setEnabled(!basic_engine && haveSelection);
citationStyleLA->setEnabled(!basic_engine && haveSelection);
string const & command = form_->params().getCmdName();
string const & command = controller().params().getCmdName();
// Find the style of the citekeys
vector<biblio::CiteStyle> const & styles =
@ -286,7 +283,7 @@ void GuiCitationDialog::fillStyles()
citationStyleCO->clear();
QStringList selected_keys = form_->selected()->stringList();
QStringList selected_keys = selected()->stringList();
if (selected_keys.empty()) {
citationStyleCO->setEnabled(false);
citationStyleLA->setEnabled(false);
@ -300,10 +297,10 @@ void GuiCitationDialog::fillStyles()
if (!selectedLV->selectionModel()->selectedIndexes().empty())
curr = selectedLV->selectionModel()->selectedIndexes()[0].row();
QStringList sty = form_->citationStyles(curr);
QStringList sty = citationStyles(curr);
bool const basic_engine =
(form_->getEngine() == biblio::ENGINE_BASIC);
(controller().getEngine() == biblio::ENGINE_BASIC);
citationStyleCO->setEnabled(!sty.isEmpty() && !basic_engine);
citationStyleLA->setEnabled(!sty.isEmpty() && !basic_engine);
@ -323,7 +320,7 @@ void GuiCitationDialog::fillFields()
fieldsCO->blockSignals(true);
int const oldIndex = fieldsCO->currentIndex();
fieldsCO->clear();
QStringList const & fields = form_->getFieldsAsQStringList();
QStringList const & fields = getFieldsAsQStringList();
fieldsCO->insertItem(0, qt_("All Fields"));
fieldsCO->insertItem(1, qt_("Keys"));
fieldsCO->insertItems(2, fields);
@ -338,7 +335,7 @@ void GuiCitationDialog::fillEntries()
entriesCO->blockSignals(true);
int const oldIndex = entriesCO->currentIndex();
entriesCO->clear();
QStringList const & entries = form_->getEntriesAsQStringList();
QStringList const & entries = getEntriesAsQStringList();
entriesCO->insertItem(0, qt_("All Entry Types"));
entriesCO->insertItems(1, entries);
if (oldIndex != -1 && oldIndex < entriesCO->count())
@ -350,7 +347,7 @@ void GuiCitationDialog::fillEntries()
bool GuiCitationDialog::isSelected(const QModelIndex & idx)
{
QString const str = idx.data().toString();
return form_->selected()->stringList().contains(str);
return selected()->stringList().contains(str);
}
@ -366,24 +363,18 @@ void GuiCitationDialog::setButtons()
void GuiCitationDialog::updateInfo(QModelIndex const & idx)
{
if (idx.isValid()) {
QString const keytxt = form_->getKeyInfo(idx.data().toString());
QString const keytxt = 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();
vector<docstring> const & fields = controller().availableFields();
docstring field;
if (index <= -1 || index >= int(fields.size()))
@ -397,7 +388,7 @@ void GuiCitationDialog::findText(QString const & text, bool reset)
//"All Entry Types" is first.
index = entriesCO->currentIndex() - 1;
vector<docstring> const & entries = form_->availableEntries();
vector<docstring> const & entries = controller().availableEntries();
docstring entryType;
if (index < 0 || index >= int(entries.size()))
entryType = from_ascii("");
@ -406,7 +397,7 @@ void GuiCitationDialog::findText(QString const & text, bool reset)
bool const case_sentitive = caseCB->checkState();
bool const reg_exp = regexCB->checkState();
form_->findKey(text, onlyKeys, field, entryType,
findKey(text, onlyKeys, field, entryType,
case_sentitive, reg_exp, reset);
//FIXME
//It'd be nice to save and restore the current selection in
@ -456,20 +447,10 @@ void GuiCitationDialog::changed()
setButtons();
}
///////////////////////////////////////////////////////////////////////
//
// GuiCitation
//
///////////////////////////////////////////////////////////////////////
GuiCitation::GuiCitation(GuiDialog & parent)
: ControlCitation(parent)
{
}
void GuiCitation::apply(int const choice, bool const full, bool const force,
QString before, QString after)
void GuiCitationDialog::apply(int const choice,
bool const full, bool const force,
QString before, QString after)
{
if (cited_keys_.isEmpty())
return;
@ -481,50 +462,50 @@ void GuiCitation::apply(int const choice, bool const full, bool const force,
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();
controller().params().setCmdName(command);
controller().params()["key"] = qstring_to_ucs4(cited_keys_.join(","));
controller().params()["before"] = qstring_to_ucs4(before);
controller().params()["after"] = qstring_to_ucs4(after);
controller().dispatchParams();
}
void GuiCitation::clearSelection()
void GuiCitationDialog::clearSelection()
{
cited_keys_.clear();
selected_model_.setStringList(cited_keys_);
}
QString GuiCitation::textBefore()
QString GuiCitationDialog::textBefore()
{
return toqstr(params()["before"]);
return toqstr(controller().params()["before"]);
}
QString GuiCitation::textAfter()
QString GuiCitationDialog::textAfter()
{
return toqstr(params()["after"]);
return toqstr(controller().params()["after"]);
}
bool GuiCitation::initialiseParams(std::string const & data)
bool GuiCitationDialog::initialiseParams(std::string const & data)
{
if (!ControlCitation::initialiseParams(data))
if (!controller().initialiseParams(data))
return false;
init();
return true;
}
void GuiCitation::init()
void GuiCitationDialog::init()
{
// Make the list of all available bibliography keys
all_keys_ = to_qstring_list(availableKeys());
all_keys_ = to_qstring_list(controller().availableKeys());
available_model_.setStringList(all_keys_);
// Ditto for the keys cited in this inset
QString str = toqstr(params()["key"]);
QString str = toqstr(controller().params()["key"]);
if (str.isEmpty())
cited_keys_.clear();
else
@ -533,7 +514,7 @@ void GuiCitation::init()
}
void GuiCitation::findKey(QString const & str, bool only_keys,
void GuiCitationDialog::findKey(QString const & str, bool only_keys,
docstring field, docstring entryType,
bool case_sensitive, bool reg_exp, bool reset)
{
@ -573,43 +554,44 @@ void GuiCitation::findKey(QString const & str, bool only_keys,
// 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);
controller().filterByEntryType(keyVector, entryType);
if (str.isEmpty())
result = to_qstring_list(keyVector);
else
result = to_qstring_list(searchKeys(keyVector, only_keys,
result = to_qstring_list(controller().searchKeys(keyVector, only_keys,
qstring_to_ucs4(str), field, case_sensitive, reg_exp));
available_model_.setStringList(result);
}
QStringList GuiCitation::getFieldsAsQStringList()
QStringList GuiCitationDialog::getFieldsAsQStringList()
{
return to_qstring_list(availableFields());
return to_qstring_list(controller().availableFields());
}
QStringList GuiCitation::getEntriesAsQStringList()
QStringList GuiCitationDialog::getEntriesAsQStringList()
{
return to_qstring_list(availableEntries());
return to_qstring_list(controller().availableEntries());
}
QStringList GuiCitation::citationStyles(int sel)
QStringList GuiCitationDialog::citationStyles(int sel)
{
docstring const key = qstring_to_ucs4(cited_keys_[sel]);
return to_qstring_list(getCiteStrings(key));
return to_qstring_list(controller().getCiteStrings(key));
}
QString GuiCitation::getKeyInfo(QString const & sel)
QString GuiCitationDialog::getKeyInfo(QString const & sel)
{
return toqstr(getInfo(qstring_to_ucs4(sel)));
return toqstr(controller().getInfo(qstring_to_ucs4(sel)));
}
void GuiCitation::setCitedKeys()
void GuiCitationDialog::setCitedKeys()
{
cited_keys_ = selected_model_.stringList();
}

View File

@ -16,9 +16,9 @@
#define GUICITATION_H
#include "GuiDialog.h"
#include "ControlCitation.h"
#include "GuiSelectionManager.h"
#include "ui_CitationUi.h"
#include "ControlCitation.h"
#include "support/docstring.h"
#include <QKeyEvent>
@ -28,29 +28,22 @@
namespace lyx {
namespace frontend {
class GuiCitation;
class GuiCitationDialog : public QDialog,
public Ui::CitationUi, public Dialog::View
class GuiCitationDialog : public GuiDialog, public Ui::CitationUi
{
Q_OBJECT
public:
GuiCitationDialog(Dialog &, GuiCitation * form );
virtual ~GuiCitationDialog();
virtual void applyView();
///
GuiCitationDialog(LyXView & lv);
///
void applyView();
/// Hide the dialog from sight
void hideView();
/// Redraw the dialog (e.g. if the colors have been remapped).
void redrawView() {}
/// Create the dialog if necessary, update it and display it.
void showView();
/// \return true if the dialog is visible.
bool isVisibleView() const;
@ -58,7 +51,10 @@ public Q_SLOTS:
/// Update the display of the dialog whilst it is still visible.
void updateView();
protected:
private:
///
ControlCitation & controller() const;
///
void closeEvent(QCloseEvent * e);
/// prepares a call to GuiCitation::searchKeys when we
/// are ready to search the BibTeX entries
@ -68,7 +64,7 @@ protected:
/// update the display of BibTeX information
void updateInfo(QModelIndex const &);
protected Q_SLOTS:
private Q_SLOTS:
void cleanUp();
void on_okPB_clicked();
void on_cancelPB_clicked();
@ -79,7 +75,7 @@ protected Q_SLOTS:
void on_entriesCO_currentIndexChanged(int index);
void on_caseCB_stateChanged(int);
void on_regexCB_stateChanged(int);
virtual void changed();
void changed();
///
void setCitedKeys();
/// performs a limited update, suitable for internal call
@ -99,19 +95,10 @@ private:
/// last used citation style
int style_;
GuiCitation * form_;
GuiSelectionManager * selectionManager;
};
class GuiCitation : public ControlCitation
{
public:
///
GuiCitation(GuiDialog &);
virtual ~GuiCitation() {}
virtual bool initialiseParams(std::string const & data);
bool initialiseParams(std::string const & data);
///
void init();
@ -155,10 +142,8 @@ public:
QStringList citationStyles(int);
/// Set the Params variable for the Controller.
virtual void apply(int const choice, bool const full, bool const force,
void apply(int const choice, bool const full, bool const force,
QString before, QString after);
void setCitedKeys();
private:
/// available keys.

View File

@ -23,8 +23,10 @@ namespace frontend {
class GuiCommandEdit;
class GuiCommandBuffer : public QWidget {
class GuiCommandBuffer : public QWidget
{
Q_OBJECT
public:
GuiCommandBuffer(GuiViewBase * view);

View File

@ -19,7 +19,8 @@
namespace lyx {
namespace frontend {
class GuiCommandEdit : public QLineEdit {
class GuiCommandEdit : public QLineEdit
{
Q_OBJECT
public:

View File

@ -30,21 +30,22 @@ using std::string;
namespace lyx {
namespace frontend {
namespace {
static QString const bigleft[] = {"", "bigl", "Bigl", "biggl", "Biggl"};
QString const bigleft[] = {"", "bigl", "Bigl", "biggl", "Biggl"};
static QString const bigright[] = {"", "bigr", "Bigr", "biggr", "Biggr"};
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]]"), ""};
static 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)
static QString fix_name(QString const & str, bool big)
{
if (str.isEmpty())
return ".";
@ -55,24 +56,70 @@ QString fix_name(QString const & str, bool big)
return "\\" + str;
}
} // namespace anon
GuiDelimiter::GuiDelimiter(GuiDialog & parent)
: GuiView<GuiDelimiterDialog>(parent, _("Math Delimiter"))
{}
void GuiDelimiter::build_dialog()
GuiDelimiterDialog::GuiDelimiterDialog(LyXView & lv)
: GuiDialog(lv, "mathdelimiter")
{
dialog_.reset(new GuiDelimiterDialog(this,
static_cast<GuiViewBase *>(controller().view())));
setupUi(this);
setViewTitle(_("Math Delimiter"));
setController(new ControlMath(*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 = 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 = 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);
bc().setPolicy(ButtonPolicy::IgnorantPolicy);
}
ControlMath & GuiDelimiterDialog::controller() const
{
return static_cast<ControlMath &>(GuiDialog::controller());
}
char_type GuiDelimiterDialog::doMatch(char_type const symbol) const
{
string const & str = form_->controller().texName(symbol);
string const & str = controller().texName(symbol);
string match;
if (str == "(") match = ")";
else if (str == ")") match = "(";
@ -91,58 +138,7 @@ char_type GuiDelimiterDialog::doMatch(char_type const symbol) const
else if (str == "/") match = "backslash";
else return symbol;
return form_->controller().mathSymbol(match).unicode;
}
GuiDelimiterDialog::GuiDelimiterDialog(GuiDelimiter * 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);
return controller().mathSymbol(match).unicode;
}
@ -187,11 +183,11 @@ void GuiDelimiterDialog::updateTeXCode(int size)
void GuiDelimiterDialog::on_insertPB_clicked()
{
if (sizeCO->currentIndex() == 0)
form_->controller().dispatchDelim(fromqstr(tex_code_));
controller().dispatchDelim(fromqstr(tex_code_));
else {
QString command = '"' + tex_code_ + '"';
command.replace(' ', "\" \"");
form_->controller().dispatchBigDelim(fromqstr(command));
controller().dispatchBigDelim(fromqstr(command));
}
}

View File

@ -12,7 +12,7 @@
#ifndef GUIDELIMITERDIALOG_H
#define GUIDELIMITERDIALOG_H
#include "GuiDialogView.h"
#include "GuiDialog.h"
#include "ControlMath.h"
#include "ui_DelimiterUi.h"
@ -21,14 +21,13 @@ class QListWidgetItem;
namespace lyx {
namespace frontend {
class ControlMath;
class GuiDelimiter;
class GuiDelimiterDialog : public QDialog, public Ui::DelimiterUi
class GuiDelimiterDialog : public GuiDialog, public Ui::DelimiterUi
{
Q_OBJECT
public:
GuiDelimiterDialog(GuiDelimiter * form, QWidget * parent);
GuiDelimiterDialog(LyXView & lv);
public Q_SLOTS:
void on_leftLW_itemActivated(QListWidgetItem *);
void on_rightLW_itemActivated(QListWidgetItem *);
@ -37,38 +36,19 @@ public Q_SLOTS:
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
GuiDelimiter * form_;
/// parent controller
ControlMath & controller() const;
/// TeX code that will be inserted.
QString tex_code_;
};
class GuiDelimiter : public GuiView<GuiDelimiterDialog>
{
public:
friend class GuiDelimiterDialog;
///
GuiDelimiter(GuiDialog &);
/// parent controller
ControlMath & controller()
{ return static_cast<ControlMath &>(this->getController()); }
/// parent controller
ControlMath const & controller() const
{ return static_cast<ControlMath const &>(this->getController()); }
private:
virtual void applyView() {}
virtual void update_contents() {}
/// Build the dialog.
virtual void build_dialog();
};
} // namespace frontend
} // namespace lyx

View File

@ -12,7 +12,7 @@
#include "GuiDialog.h"
#include "debug.h"
#include "qt_helpers.h"
namespace lyx {
namespace frontend {
@ -40,14 +40,14 @@ void GuiDialog::OKButton()
is_closing_ = true;
apply();
is_closing_ = false;
hide();
QDialog::hide();
bc().ok();
}
void GuiDialog::CancelButton()
{
hide();
QDialog::hide();
bc().cancel();
}
@ -117,5 +117,104 @@ void GuiDialog::checkStatus()
}
}
bool GuiDialog::isVisibleView() const
{
return QDialog::isVisible();
}
bool GuiDialog::readOnly() const
{
return kernel().isBufferReadonly();
}
void GuiDialog::showView()
{
QSize const hint = sizeHint();
if (hint.height() >= 0 && hint.width() >= 0)
setMinimumSize(hint);
updateView(); // make sure its up-to-date
if (controller().exitEarly())
return;
setWindowTitle(toqstr("LyX: " + getViewTitle()));
if (QWidget::isVisible()) {
raise();
activateWindow();
} else {
QWidget::show();
}
setFocus();
}
void GuiDialog::hideView()
{
QDialog::hide();
}
bool GuiDialog::isValid()
{
return true;
}
void GuiDialog::changed()
{
if (updating_)
return;
bc().setValid(isValid());
}
void GuiDialog::slotWMHide()
{
CancelButton();
}
void GuiDialog::slotApply()
{
ApplyButton();
}
void GuiDialog::slotOK()
{
OKButton();
}
void GuiDialog::slotClose()
{
CancelButton();
}
void GuiDialog::slotRestore()
{
RestoreButton();
}
void GuiDialog::updateView()
{
setUpdatesEnabled(false);
// protect the BC from unwarranted state transitions
updating_ = true;
update_contents();
updating_ = false;
setUpdatesEnabled(true);
QDialog::update();
}
} // namespace frontend
} // namespace lyx
#include "GuiDialog_moc.cpp"

View File

@ -15,20 +15,39 @@
#include "Dialog.h"
#include "ButtonController.h"
#include <QDialog>
#include <QObject>
namespace lyx {
namespace frontend {
/** \c Dialog collects the different parts of a Model-Controller-View
* split of a generic dialog together.
*/
class GuiDialog : public Dialog
class GuiDialog : public QDialog, public Dialog
{
Q_OBJECT
public:
/// \param lv is the access point for the dialog to the LyX kernel.
/// \param name is the identifier given to the dialog by its parent
/// container.
GuiDialog(LyXView & lv, std::string const & name);
//GuiDialog(GuiDialog &, docstring const &);
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();
public:
/** \name Buttons
* These methods are publicly accessible because they are invoked
* by the View when the user presses... guess what ;-)
@ -47,7 +66,6 @@ public:
void checkStatus();
void setButtonsValid(bool valid);
/** \name Dialog Components
* Methods to access the various components making up a dialog.
*/
@ -61,8 +79,34 @@ public:
void preUpdate();
void postUpdate();
///
bool readOnly() const;
/// the dialog has changed contents
virtual void changed();
/// default: do nothing
virtual void applyView() {}
/// default: do nothing
virtual void update_contents() {}
protected:
/// Hide the dialog.
virtual void hideView();
/// Create the dialog if necessary, update it and display it.
virtual void showView();
///
virtual bool isVisibleView() const;
/// is the dialog currently valid ?
virtual bool isValid();
private:
/// update the dialog
virtual void updateView();
ButtonController bc_;
/// are we updating ?
bool updating_;
};
} // namespace frontend

View File

@ -1,131 +0,0 @@
/**
* \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 "qt_helpers.h"
namespace lyx {
namespace frontend {
GuiDialogView::GuiDialogView(GuiDialog & parent, docstring const & t)
: Dialog::View(parent, t), updating_(false), parent_(parent)
{}
ButtonController & GuiDialogView::bc()
{
return parent_.bc();
}
bool GuiDialogView::isVisibleView() const
{
return form() && form()->isVisible();
}
bool GuiDialogView::readOnly() const
{
return kernel().isBufferReadonly();
}
void GuiDialogView::showView()
{
if (!form())
build();
QSize const sizeHint = form()->sizeHint();
if (sizeHint.height() >= 0 && sizeHint.width() >= 0)
form()->setMinimumSize(sizeHint);
updateView(); // make sure its up-to-date
if (dialog().controller().exitEarly())
return;
form()->setWindowTitle(toqstr("LyX: " + getViewTitle()));
if (form()->isVisible()) {
form()->raise();
form()->activateWindow();
form()->setFocus();
} else {
form()->show();
form()->setFocus();
}
}
void GuiDialogView::hideView()
{
if (form() && form()->isVisible())
form()->hide();
}
void GuiDialogView::build()
{
// protect the BC from unwarranted state transitions
updating_ = true;
build_dialog();
updating_ = false;
}
bool GuiDialogView::isValid()
{
return true;
}
void GuiDialogView::changed()
{
if (updating_)
return;
parent_.bc().setValid(isValid());
}
void GuiDialogView::slotWMHide()
{
parent_.CancelButton();
}
void GuiDialogView::slotApply()
{
parent_.ApplyButton();
}
void GuiDialogView::slotOK()
{
parent_.OKButton();
}
void GuiDialogView::slotClose()
{
parent_.CancelButton();
}
void GuiDialogView::slotRestore()
{
parent_.RestoreButton();
}
} // namespace frontend
} // namespace lyx
#include "GuiDialogView_moc.cpp"

View File

@ -1,116 +0,0 @@
// -*- 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 GUIDIALOGVIEW_H
#define GUIDIALOGVIEW_H
#include "GuiDialog.h"
#include <boost/scoped_ptr.hpp>
#include <QApplication>
#include <QWidget>
#include <QObject>
namespace lyx {
namespace frontend {
/** This class is an Qt2 GUI base class.
*/
class GuiDialogView : public QObject, public Dialog::View
{
Q_OBJECT
public:
///
GuiDialogView(GuiDialog &, docstring const &);
///
virtual ~GuiDialogView() {}
///
bool readOnly() const;
/// the dialog has changed contents
virtual void changed();
///
ButtonController & bc();
protected:
/// build the actual dialog
virtual void build_dialog() = 0;
/// Build the dialog
virtual void build();
/// Hide the dialog.
virtual void hideView();
/// Create the dialog if necessary, update it and display it.
virtual void showView();
/// update the dialog's contents
virtual void update_contents() = 0;
///
virtual bool isVisibleView() const;
/// is the dialog currently valid ?
virtual bool isValid();
/// are we updating ?
bool updating_;
///
GuiDialog & parent_;
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(GuiDialog & p, docstring const & t)
: GuiDialogView(p, t)
{}
virtual ~GuiView() {}
/// update the dialog
virtual void updateView() {
dialog_->setUpdatesEnabled(false);
// protect the BC from unwarranted state transitions
updating_ = true;
update_contents();
updating_ = false;
dialog_->setUpdatesEnabled(true);
dialog_->update();
}
/// Pointer to the actual instantiation of the Qt dialog
virtual GUIDialog * form() const { return dialog_.get(); }
/// Real GUI implementation.
boost::scoped_ptr<GUIDialog> dialog_;
};
} // namespace frontend
} // namespace lyx
#endif // GUIDIALOGVIEW_H

View File

@ -54,45 +54,62 @@ using std::vector;
using std::string;
char const * const tex_graphics[] = {"default", "dvips", "dvitops", "emtex",
"ln", "oztex", "textures", "none", ""
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_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 * 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 * 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 * 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 * 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 * 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"), ""
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"), ""
};
@ -171,25 +188,30 @@ void PreambleModule::closeEvent(QCloseEvent * e)
/////////////////////////////////////////////////////////////////////
GuiDocumentDialog::GuiDocumentDialog(GuiDocument * form)
: form_(form), lang_(getSecond(getLanguageData(false)))
GuiDocumentDialog::GuiDocumentDialog(LyXView & lv)
: GuiDialog(lv, "document")
{
setupUi(this);
setController(new ControlDocument(*this));
setViewTitle(_("Document Settings"));
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()));
lang_ = getSecond(getLanguageData(false));
connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
connect(applyPB, SIGNAL(clicked()), this, SLOT(slotApply()));
connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
connect(restorePB, SIGNAL(clicked()), this, SLOT(slotRestore()));
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_->bc().setOK(okPB);
form_->bc().setApply(applyPB);
form_->bc().setCancel(closePB);
form_->bc().setRestore(restorePB);
bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
bc().setOK(okPB);
bc().setApply(applyPB);
bc().setCancel(closePB);
bc().setRestore(restorePB);
textLayoutModule = new UiWidget<Ui::TextLayoutUi>;
// text layout
@ -246,7 +268,7 @@ GuiDocumentDialog::GuiDocumentDialog(GuiDocument * form)
Spacing::Other, qt_("Custom"));
// initialize the length validator
form_->bc().addCheckedLineEdit(textLayoutModule->skipLE);
bc().addCheckedLineEdit(textLayoutModule->skipLE);
fontModule = new UiWidget<Ui::FontUi>;
// fonts
@ -277,19 +299,19 @@ GuiDocumentDialog::GuiDocumentDialog(GuiDocument * form)
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]))
if (!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]))
if (!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]))
if (!controller().isFontAvailable(tex_fonts_monospaced[n]))
font += qt_(" (not installed)");
fontModule->fontsTypewriterCO->addItem(font);
}
@ -336,9 +358,9 @@ GuiDocumentDialog::GuiDocumentDialog(GuiDocument * form)
pageLayoutModule->pagestyleCO->addItem(qt_("plain"));
pageLayoutModule->pagestyleCO->addItem(qt_("headings"));
pageLayoutModule->pagestyleCO->addItem(qt_("fancy"));
form_->bc().addCheckedLineEdit(pageLayoutModule->paperheightLE,
bc().addCheckedLineEdit(pageLayoutModule->paperheightLE,
pageLayoutModule->paperheightL);
form_->bc().addCheckedLineEdit(pageLayoutModule->paperwidthLE,
bc().addCheckedLineEdit(pageLayoutModule->paperwidthLE,
pageLayoutModule->paperwidthL);
// paper
@ -363,8 +385,6 @@ GuiDocumentDialog::GuiDocumentDialog(GuiDocument * form)
pageLayoutModule->paperwidthLE));
marginsModule = new UiWidget<Ui::MarginsUi>;
// margins
connect(marginsModule->marginCB, SIGNAL(toggled(bool)),
@ -414,19 +434,19 @@ GuiDocumentDialog::GuiDocumentDialog(GuiDocument * form)
marginsModule->footskipLE->setValidator(unsignedLengthValidator(
marginsModule->footskipLE));
form_->bc().addCheckedLineEdit(marginsModule->topLE,
bc().addCheckedLineEdit(marginsModule->topLE,
marginsModule->topL);
form_->bc().addCheckedLineEdit(marginsModule->bottomLE,
bc().addCheckedLineEdit(marginsModule->bottomLE,
marginsModule->bottomL);
form_->bc().addCheckedLineEdit(marginsModule->innerLE,
bc().addCheckedLineEdit(marginsModule->innerLE,
marginsModule->innerL);
form_->bc().addCheckedLineEdit(marginsModule->outerLE,
bc().addCheckedLineEdit(marginsModule->outerLE,
marginsModule->outerL);
form_->bc().addCheckedLineEdit(marginsModule->headsepLE,
bc().addCheckedLineEdit(marginsModule->headsepLE,
marginsModule->headsepL);
form_->bc().addCheckedLineEdit(marginsModule->headheightLE,
bc().addCheckedLineEdit(marginsModule->headheightLE,
marginsModule->headheightL);
form_->bc().addCheckedLineEdit(marginsModule->footskipLE,
bc().addCheckedLineEdit(marginsModule->footskipLE,
marginsModule->footskipL);
@ -449,8 +469,7 @@ GuiDocumentDialog::GuiDocumentDialog(GuiDocument * form)
vector<LanguagePair>::const_iterator lit = langs.begin();
vector<LanguagePair>::const_iterator lend = langs.end();
for (; lit != lend; ++lit) {
langModule->languageCO->addItem(
toqstr(lit->first));
langModule->languageCO->addItem(toqstr(lit->first));
}
// Always put the default encoding in the first position.
@ -593,6 +612,12 @@ GuiDocumentDialog::GuiDocumentDialog(GuiDocument * form)
}
ControlDocument & GuiDocumentDialog::controller() const
{
return static_cast<ControlDocument &>(Dialog::controller());
}
void GuiDocumentDialog::showPreamble()
{
docPS->setCurrentPanel(_("LaTeX Preamble"));
@ -601,19 +626,19 @@ void GuiDocumentDialog::showPreamble()
void GuiDocumentDialog::saveDefaultClicked()
{
form_->saveDocDefault();
saveDocDefault();
}
void GuiDocumentDialog::useDefaultsClicked()
{
form_->useClassDefaults();
useClassDefaults();
}
void GuiDocumentDialog::change_adaptor()
{
form_->changed();
changed();
}
@ -657,7 +682,7 @@ void GuiDocumentDialog::set_listings_msg()
void GuiDocumentDialog::closeEvent(QCloseEvent * e)
{
form_->slotWMHide();
slotWMHide();
e->accept();
}
@ -764,18 +789,15 @@ void GuiDocumentDialog::updateFontsize(string const & items, string const & sel)
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));
fontModule->fontScCB->setEnabled(controller().providesSC(font));
fontModule->fontOsfCB->setEnabled(controller().providesOSF(font));
}
void GuiDocumentDialog::sansChanged(int item)
{
string const font = tex_fonts_sans[item];
bool scaleable = form_->controller().providesScale(font);
bool scaleable = controller().providesScale(font);
fontModule->scaleSansSB->setEnabled(scaleable);
fontModule->scaleSansLA->setEnabled(scaleable);
}
@ -784,7 +806,7 @@ void GuiDocumentDialog::sansChanged(int item)
void GuiDocumentDialog::ttChanged(int item)
{
string const font = tex_fonts_monospaced[item];
bool scaleable = form_->controller().providesScale(font);
bool scaleable = controller().providesScale(font);
fontModule->scaleTypewriterSB->setEnabled(scaleable);
fontModule->scaleTypewriterLA->setEnabled(scaleable);
}
@ -822,19 +844,18 @@ void GuiDocumentDialog::updatePagestyle(string const & items, string const & sel
void GuiDocumentDialog::classChanged()
{
BufferParams & params = form_->controller().params();
BufferParams & params = controller().params();
textclass_type const tc = latexModule->classCO->currentIndex();
params.setJustBaseClass(tc);
if (lyxrc.auto_reset_options)
params.useClassDefaults();
form_->update_contents();
update_contents();
}
void GuiDocumentDialog::updateNumbering()
{
TextClass const & tclass =
form_->controller().params().getTextClass();
TextClass const & tclass = controller().params().getTextClass();
numberingModule->tocTW->setUpdatesEnabled(false);
numberingModule->tocTW->clear();
@ -1104,14 +1125,12 @@ void GuiDocumentDialog::apply(BufferParams & params)
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)
static size_t findPos(std::vector<A> const & vec, A const & val)
{
typename std::vector<A>::const_iterator it =
std::find(vec.begin(), vec.end(), val);
@ -1120,8 +1139,6 @@ findPos(std::vector<A> const & vec, A const & val)
return distance(vec.begin(), it);
}
} // namespace anom
void GuiDocumentDialog::updateParams(BufferParams const & params)
{
@ -1150,7 +1167,7 @@ void GuiDocumentDialog::updateParams(BufferParams const & params)
}
// preamble
preambleModule->update(params, form_->controller().id());
preambleModule->update(params, controller().id());
// biblio
biblioModule->citeDefaultRB->setChecked(
@ -1195,9 +1212,9 @@ void GuiDocumentDialog::updateParams(BufferParams const & params)
}
// numbering
int const min_toclevel = form_->controller().textClass().min_toclevel();
int const max_toclevel = form_->controller().textClass().max_toclevel();
if (form_->controller().textClass().hasTocLevels()) {
int const min_toclevel = controller().textClass().min_toclevel();
int const max_toclevel = controller().textClass().max_toclevel();
if (controller().textClass().hasTocLevels()) {
numberingModule->setEnabled(true);
numberingModule->depthSL->setMinimum(min_toclevel - 1);
numberingModule->depthSL->setMaximum(max_toclevel);
@ -1243,7 +1260,7 @@ void GuiDocumentDialog::updateParams(BufferParams const & params)
// text layout
latexModule->classCO->setCurrentIndex(params.getBaseClass());
updatePagestyle(form_->controller().textClass().opt_pagestyle(),
updatePagestyle(controller().textClass().opt_pagestyle(),
params.pagestyle);
textLayoutModule->lspacingCO->setCurrentIndex(nitem);
@ -1299,13 +1316,13 @@ void GuiDocumentDialog::updateParams(BufferParams const & params)
latexModule->optionsLE->setText(
toqstr(params.options));
} else {
latexModule->optionsLE->setText("");
latexModule->optionsLE->setText(QString());
}
floatModule->set(params.float_placement);
//fonts
updateFontsize(form_->controller().textClass().opt_fontsize(),
// Fonts
updateFontsize(controller().textClass().opt_fontsize(),
params.fontsize);
int n = findToken(tex_fonts_roman, params.fontsRoman);
@ -1384,48 +1401,19 @@ void GuiDocumentDialog::updateParams(BufferParams const & params)
}
/////////////////////////////////////////////////////////////////////
//
// GuiDocument
//
/////////////////////////////////////////////////////////////////////
GuiDocument::GuiDocument(GuiDialog & parent)
: GuiView<GuiDocumentDialog>(parent, _("Document Settings"))
{}
void GuiDocument::build_dialog()
void GuiDocumentDialog::applyView()
{
dialog_.reset(new GuiDocumentDialog(this));
apply(controller().params());
}
void GuiDocument::showPreamble()
void GuiDocumentDialog::update_contents()
{
dialog_->showPreamble();
updateParams(controller().params());
}
void GuiDocument::applyView()
{
if (!dialog_.get())
return;
dialog_->apply(controller().params());
}
void GuiDocument::update_contents()
{
if (!dialog_.get())
return;
dialog_->updateParams(controller().params());
}
void GuiDocument::saveDocDefault()
void GuiDocumentDialog::saveDocDefault()
{
// we have to apply the params first
applyView();
@ -1433,20 +1421,20 @@ void GuiDocument::saveDocDefault()
}
void GuiDocument::useClassDefaults()
void GuiDocumentDialog::useClassDefaults()
{
BufferParams & params = controller().params();
params.setJustBaseClass(dialog_->latexModule->classCO->currentIndex());
params.setJustBaseClass(latexModule->classCO->currentIndex());
params.useClassDefaults();
update_contents();
}
bool GuiDocument::isValid()
bool GuiDocumentDialog::isValid()
{
return dialog_->validate_listings_params().empty();
return validate_listings_params().empty();
}

View File

@ -12,7 +12,7 @@
#ifndef GUIDOCUMENT_H
#define GUIDOCUMENT_H
#include "GuiDialogView.h"
#include "GuiDialog.h"
#include "BulletsModule.h"
#include "ControlDocument.h"
@ -52,12 +52,13 @@ class GuiBranches;
class GuiDocument;
class PreambleModule;
class GuiDocumentDialog : public QDialog, public Ui::DocumentUi {
class GuiDocumentDialog : public GuiDialog, public Ui::DocumentUi
{
Q_OBJECT
public:
friend class GuiDocument;
GuiDocumentDialog(GuiDocument *);
GuiDocumentDialog(LyXView & lv);
void updateParams(BufferParams const & params);
void apply(BufferParams & params);
@ -76,7 +77,7 @@ public Q_SLOTS:
void saveDefaultClicked();
void useDefaultsClicked();
protected Q_SLOTS:
private Q_SLOTS:
void setLSpacing(int);
void setMargins(bool);
void setCustomPapersize(int);
@ -89,11 +90,10 @@ protected Q_SLOTS:
void portraitChanged();
void classChanged();
protected:
private:
void closeEvent(QCloseEvent * e);
private:
UiWidget<Ui::TextLayoutUi> *textLayoutModule;
UiWidget<Ui::FontUi> *fontModule;
UiWidget<Ui::PageLayoutUi> *pageLayoutModule;
@ -110,42 +110,22 @@ private:
BulletsModule * bulletsModule;
FloatPlacement * floatModule;
GuiDocument * form_;
/// FIXME
std::vector<std::string> lang_;
};
class GuiDocument : public GuiView<GuiDocumentDialog>
{
public:
friend class GuiDocumentDialog;
GuiDocument(GuiDialog &);
void showPreamble();
/// parent controller
ControlDocument & controller()
{ return static_cast<ControlDocument &>(this->getController()); }
/// parent controller
ControlDocument const & controller() const
{ return static_cast<ControlDocument const &>(this->getController()); }
ControlDocument & controller() const;
private:
/// Apply changes
void applyView();
/// 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();
bool isValid();
};
@ -164,7 +144,7 @@ Q_SIGNALS:
/// signal that something's changed in the Widget.
void changed();
protected:
private:
void closeEvent(QCloseEvent *);
void on_preambleTE_textChanged() { changed(); }

View File

@ -11,6 +11,7 @@
#include <config.h>
#include "GuiERT.h"
#include "ControlERT.h"
#include "gettext.h"
#include <QRadioButton>
@ -21,77 +22,58 @@
namespace lyx {
namespace frontend {
/////////////////////////////////////////////////////////////////////
//
// GuiERTDialog
//
/////////////////////////////////////////////////////////////////////
GuiERTDialog::GuiERTDialog(GuiERT * form)
: form_(form)
GuiERTDialog::GuiERTDialog(LyXView & lv)
: GuiDialog(lv, "ert")
{
setupUi(this);
connect(okPB, SIGNAL(clicked()), form, SLOT(slotOK()));
connect(closePB, SIGNAL(clicked()), form, SLOT(slotClose()));
setViewTitle(_("TeX Code Settings"));
setController(new ControlERT(*this));
connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
connect(collapsedRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
connect(openRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
bc().setOK(okPB);
bc().setCancel(closePB);
}
ControlERT & GuiERTDialog::controller() const
{
return static_cast<ControlERT &>(Dialog::controller());
}
void GuiERTDialog::closeEvent(QCloseEvent * e)
{
form_->slotWMHide();
slotWMHide();
e->accept();
}
void GuiERTDialog::change_adaptor()
{
form_->changed();
changed();
}
/////////////////////////////////////////////////////////////////////
//
// GuiERT
//
/////////////////////////////////////////////////////////////////////
GuiERT::GuiERT(GuiDialog & parent)
: GuiView<GuiERTDialog>(parent, _("TeX Code Settings"))
void GuiERTDialog::applyView()
{
}
void GuiERT::build_dialog()
{
dialog_.reset(new GuiERTDialog(this));
bc().setOK(dialog_->okPB);
bc().setCancel(dialog_->closePB);
}
void GuiERT::applyView()
{
if (dialog_->openRB->isChecked())
if (openRB->isChecked())
controller().setStatus(Inset::Open);
else
controller().setStatus(Inset::Collapsed);
}
void GuiERT::update_contents()
void GuiERTDialog::update_contents()
{
QRadioButton * rb = 0;
switch (controller().status()) {
case InsetERT::Open: rb = dialog_->openRB; break;
case InsetERT::Collapsed: rb = dialog_->collapsedRB; break;
case InsetERT::Open: openRB->setChecked(true); break;
case InsetERT::Collapsed: collapsedRB->setChecked(true); break;
}
rb->setChecked(true);
}
} // namespace frontend

View File

@ -13,33 +13,41 @@
#include "GuiEmbeddedFiles.h"
#include "debug.h"
namespace lyx {
namespace frontend {
/////////////////////////////////////////////////////////////////////
//
// GuiEmbeddedFilesDialog
//
/////////////////////////////////////////////////////////////////////
static QString const INVALID_COLOR = "gray";
static QString const AUTO_COLOR = "green";
static QString const EMBEDDED_COLOR = "black";
static QString const EXTERNAL_COLOR = "blue";
GuiEmbeddedFilesDialog::GuiEmbeddedFilesDialog(GuiEmbeddedFiles * form)
: form_(form)
GuiEmbeddedFilesDialog::GuiEmbeddedFilesDialog(LyXView & lv)
: GuiDialog(lv, "embedding")
{
setupUi(this);
//
update();
setController(new ControlEmbeddedFiles(*this));
setViewTitle(_("Embedded Files"));
//setView(new DockView<GuiEmbeddedFiles, GuiEmbeddedFilesDialog>(
// *dialog, qef, &gui_view, _("Embedded Files"), Qt::RightDockWidgetArea));
bc().setPolicy(ButtonPolicy::OkCancelPolicy);
updateView();
}
ControlEmbeddedFiles & GuiEmbeddedFilesDialog::controller() const
{
return static_cast<ControlEmbeddedFiles &>(Dialog::controller());
}
void GuiEmbeddedFilesDialog::on_filesLW_itemSelectionChanged()
{
EmbeddedFiles & files = form_->embeddedFiles();
EmbeddedFiles & files = controller().embeddedFiles();
QList<QListWidgetItem *> selection = filesLW->selectedItems();
@ -53,7 +61,7 @@ void GuiEmbeddedFilesDialog::on_filesLW_itemSelectionChanged()
int idx = filesLW->row(*it);
fullpathLE->setText(toqstr(files[idx].absFilename()));
// go to the first selected item
form_->goTo(files[idx]);
controller().goTo(files[idx]);
}
EmbeddedFile::STATUS mode = EmbeddedFile::NONE;
@ -77,9 +85,9 @@ void GuiEmbeddedFilesDialog::on_filesLW_itemSelectionChanged()
void GuiEmbeddedFilesDialog::on_filesLW_itemDoubleClicked()
{
EmbeddedFiles & files = form_->embeddedFiles();
EmbeddedFiles & files = controller().embeddedFiles();
QList<QListWidgetItem *> selection = filesLW->selectedItems();
form_->view(files[filesLW->row(*selection.begin())]);
controller().view(files[filesLW->row(*selection.begin())]);
}
@ -88,7 +96,7 @@ void GuiEmbeddedFilesDialog::updateView()
filesLW->clear();
//
EmbeddedFiles const & files = form_->embeddedFiles();
EmbeddedFiles const & files = controller().embeddedFiles();
EmbeddedFiles::EmbeddedFileList::const_iterator it = files.begin();
EmbeddedFiles::EmbeddedFileList::const_iterator it_end = files.end();
for (; it != it_end; ++it) {
@ -113,9 +121,9 @@ void GuiEmbeddedFilesDialog::updateView()
void GuiEmbeddedFilesDialog::on_addPB_clicked()
{
docstring const file = form_->browseFile();
docstring const file = controller().browseFile();
if (!file.empty()) {
EmbeddedFiles & files = form_->embeddedFiles();
EmbeddedFiles & files = controller().embeddedFiles();
files.registerFile(to_utf8(file), EmbeddedFile::EMBEDDED);
}
}
@ -123,11 +131,11 @@ void GuiEmbeddedFilesDialog::on_addPB_clicked()
void GuiEmbeddedFilesDialog::on_extractPB_clicked()
{
EmbeddedFiles const & files = form_->embeddedFiles();
EmbeddedFiles const & files = controller().embeddedFiles();
QList<QListWidgetItem *> selection = filesLW->selectedItems();
for (QList<QListWidgetItem*>::iterator it = selection.begin();
it != selection.end(); ++it)
form_->extract(files[filesLW->row(*it)]);
controller().extract(files[filesLW->row(*it)]);
}
@ -138,20 +146,20 @@ void GuiEmbeddedFilesDialog::on_enableCB_toggled(bool enable)
// When a embedded file is turned to disabled, it should save its
// embedded files. Otherwise, embedded files will be lost!!!
//
form_->embeddedFiles().enable(enable);
controller().embeddedFiles().enable(enable);
// immediately post the change to buffer (and bufferView)
if (enable)
form_->setMessage("Enable file embedding");
controller().setMessage("Enable file embedding");
else
form_->setMessage("Disable file embedding");
controller().setMessage("Disable file embedding");
// update bufferView
form_->dispatchParams();
controller().dispatchParams();
}
void GuiEmbeddedFilesDialog::set_embedding_status(EmbeddedFile::STATUS status)
{
EmbeddedFiles & files = form_->embeddedFiles();
EmbeddedFiles & files = controller().embeddedFiles();
QList<QListWidgetItem *> selection = filesLW->selectedItems();
for (QList<QListWidgetItem*>::iterator it = selection.begin();
it != selection.end(); ++it) {
@ -167,16 +175,16 @@ void GuiEmbeddedFilesDialog::set_embedding_status(EmbeddedFile::STATUS status)
(*it)->setTextColor(EXTERNAL_COLOR);
}
if (status == EmbeddedFile::AUTO)
form_->setMessage("Switch to auto embedding");
controller().setMessage("Switch to auto embedding");
else if (status == EmbeddedFile::EMBEDDED)
form_->setMessage("Switch to always embedding");
controller().setMessage("Switch to always embedding");
else
form_->setMessage("Switch to never embedding");
controller().setMessage("Switch to never embedding");
autoRB->setChecked(status == EmbeddedFile::AUTO);
embeddedRB->setChecked(status == EmbeddedFile::EMBEDDED);
externalRB->setChecked(status == EmbeddedFile::EXTERNAL);
// update bufferView
form_->dispatchParams();
controller().dispatchParams();
}

View File

@ -12,6 +12,7 @@
#ifndef GUIEMBEDDEDFILES_H
#define GUIEMBEDDEDFILES_H
#include "GuiDialog.h"
#include "EmbeddedFiles.h"
#include "ControlEmbeddedFiles.h"
#include "ui_EmbeddedFilesUi.h"
@ -19,12 +20,12 @@
namespace lyx {
namespace frontend {
class GuiEmbeddedFiles;
class GuiEmbeddedFilesDialog : public QWidget, public Ui::GuiEmbeddedFilesUi {
class GuiEmbeddedFilesDialog : public GuiDialog, public Ui::GuiEmbeddedFilesUi
{
Q_OBJECT
public:
GuiEmbeddedFilesDialog(GuiEmbeddedFiles * form);
GuiEmbeddedFilesDialog(LyXView & lv);
public Q_SLOTS:
///
@ -43,22 +44,10 @@ public Q_SLOTS:
void on_addPB_clicked();
//
void on_extractPB_clicked();
private:
ControlEmbeddedFiles & controller() const;
void set_embedding_status(EmbeddedFile::STATUS);
///
GuiEmbeddedFiles * form_;
};
class GuiEmbeddedFiles : public QObject, public ControlEmbeddedFiles
{
Q_OBJECT
public:
/// Constructor
GuiEmbeddedFiles(Dialog & dialog)
: ControlEmbeddedFiles(dialog) {}
///
virtual ~GuiEmbeddedFiles() {}
};
} // namespace frontend

View File

@ -11,6 +11,8 @@
#include <config.h>
#include "GuiErrorList.h"
#include "ControlErrorList.h"
#include "qt_helpers.h"
#include <QListWidget>
@ -18,37 +20,44 @@
#include <QPushButton>
#include <QCloseEvent>
namespace lyx {
namespace frontend {
/////////////////////////////////////////////////////////////////////
//
// GuiErrorListDialog
//
/////////////////////////////////////////////////////////////////////
GuiErrorListDialog::GuiErrorListDialog(GuiErrorList * form)
: form_(form)
GuiErrorListDialog::GuiErrorListDialog(LyXView & lv)
: GuiDialog(lv, "errorlist")
{
setupUi(this);
setController(new ControlErrorList(*this));
connect(closePB, SIGNAL(clicked()),
form, SLOT(slotClose()));
connect(errorsLW, SIGNAL( itemActivated(QListWidgetItem *)),
form, SLOT(slotClose()));
connect( errorsLW, SIGNAL( itemClicked(QListWidgetItem *)),
this, SLOT(slotClose()));
connect(errorsLW, SIGNAL(itemActivated(QListWidgetItem *)),
this, SLOT(slotClose()));
connect( errorsLW, SIGNAL(itemClicked(QListWidgetItem *)),
this, SLOT(select_adaptor(QListWidgetItem *)));
bc().setPolicy(ButtonPolicy::OkCancelPolicy);
bc().setCancel(closePB);
}
ControlErrorList & GuiErrorListDialog::controller() const
{
return static_cast<ControlErrorList &>(Dialog::controller());
}
void GuiErrorListDialog::select_adaptor(QListWidgetItem * item)
{
form_->select(item);
select(item);
}
void GuiErrorListDialog::closeEvent(QCloseEvent * e)
{
form_->slotWMHide();
slotWMHide();
e->accept();
}
@ -56,49 +65,29 @@ void GuiErrorListDialog::closeEvent(QCloseEvent * e)
void GuiErrorListDialog::showEvent(QShowEvent *e)
{
errorsLW->setCurrentRow(0);
form_->select(errorsLW->item(0));
select(errorsLW->item(0));
e->accept();
}
/////////////////////////////////////////////////////////////////////
//
// GuiErrorList
//
/////////////////////////////////////////////////////////////////////
GuiErrorList::GuiErrorList(GuiDialog & parent)
: GuiView<GuiErrorListDialog>(parent, docstring())
{}
void GuiErrorList::build_dialog()
void GuiErrorListDialog::select(QListWidgetItem * wi)
{
dialog_.reset(new GuiErrorListDialog(this));
bc().setCancel(dialog_->closePB);
}
void GuiErrorList::select(QListWidgetItem * wi)
{
int const item = dialog_->errorsLW->row(wi);
int const item = errorsLW->row(wi);
controller().goTo(item);
dialog_->descriptionTB->setPlainText(toqstr(controller().errorList()[item].description));
descriptionTB->setPlainText(toqstr(controller().errorList()[item].description));
}
void GuiErrorList::update_contents()
void GuiErrorListDialog::update_contents()
{
setViewTitle(from_utf8(controller().name()));
dialog_->errorsLW->clear();
dialog_->descriptionTB->setPlainText(QString());
errorsLW->clear();
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));
}
for (; it != end; ++it)
errorsLW->addItem(toqstr(it->error));
}
} // namespace frontend

View File

@ -12,55 +12,34 @@
#ifndef GUIERRORLIST_H
#define GUIERRORLIST_H
#include "GuiDialogView.h"
#include "GuiDialog.h"
#include "ControlErrorList.h"
#include "ui_ErrorListUi.h"
#include <QDialog>
class QListWidgetItem;
namespace lyx {
namespace frontend {
class GuiErrorList;
class GuiErrorListDialog : public QDialog, public Ui::ErrorListUi {
class GuiErrorListDialog : public GuiDialog, public Ui::ErrorListUi
{
Q_OBJECT
public:
GuiErrorListDialog(GuiErrorList * form);
GuiErrorListDialog(LyXView & lv);
public Q_SLOTS:
void select_adaptor(QListWidgetItem *);
protected:
private:
void closeEvent(QCloseEvent *);
void showEvent(QShowEvent *);
private:
GuiErrorList * form_;
};
class GuiErrorList : public GuiView<GuiErrorListDialog>
{
public:
friend class GuiErrorListDialog;
GuiErrorList(GuiDialog &);
/// parent controller
ControlErrorList & controller()
{ return static_cast<ControlErrorList &>(this->getController()); }
/// parent controller
ControlErrorList const & controller() const
{ return static_cast<ControlErrorList const &>(this->getController()); }
private:
ControlErrorList & controller() const;
/// select an entry
void select(QListWidgetItem *);
/// required apply
virtual void applyView() {}
/// build dialog
virtual void build_dialog();
/// update contents
virtual void update_contents();
void update_contents();
};
} // namespace frontend

View File

@ -11,6 +11,9 @@
#include <config.h>
#include "GuiExternal.h"
#include "ControlExternal.h"
#include "lengthcommon.h"
#include "LyXRC.h"
@ -22,15 +25,14 @@
#include "support/os.h"
#include "support/lyxlib.h"
#include "GuiExternal.h"
#include "LengthCombo.h"
#include "qt_helpers.h"
#include "Validator.h"
#include <QCloseEvent>
#include <QCheckBox>
#include <QLineEdit>
#include <QPushButton>
#include <QCheckBox>
#include <QTabWidget>
#include <QTextBrowser>
@ -45,26 +47,21 @@ 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)
GuiExternalDialog::GuiExternalDialog(LyXView & lv)
: GuiDialog(lv, "external")
{
setupUi(this);
connect(okPB, SIGNAL(clicked()), form, SLOT(slotOK()));
connect(applyPB, SIGNAL(clicked()), form, SLOT(slotApply()));
connect(closePB, SIGNAL(clicked()), form, SLOT(slotClose()));
setViewTitle(_("External Material"));
setController(new ControlExternal(*this));
connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
connect(applyPB, SIGNAL(clicked()), this, SLOT(slotApply()));
connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
connect(displayCB, SIGNAL(toggled(bool)),
showCO, SLOT(setEnabled(bool)));
@ -126,6 +123,70 @@ GuiExternalDialog::GuiExternalDialog(GuiExternal * form)
heightED->setValidator(unsignedLengthValidator(heightED));
setFocusProxy(fileED);
bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
bc().setOK(okPB);
bc().setApply(applyPB);
bc().setCancel(closePB);
bc().addReadOnly(fileED);
bc().addReadOnly(browsePB);
bc().addReadOnly(editPB);
bc().addReadOnly(externalCO);
bc().addReadOnly(draftCB);
bc().addReadOnly(displayscaleED);
bc().addReadOnly(showCO);
bc().addReadOnly(displayCB);
bc().addReadOnly(angleED);
bc().addReadOnly(originCO);
bc().addReadOnly(heightUnitCO);
bc().addReadOnly(heightED);
bc().addReadOnly(aspectratioCB);
bc().addReadOnly(widthUnitCO);
bc().addReadOnly(widthED);
bc().addReadOnly(clipCB);
bc().addReadOnly(getbbPB);
bc().addReadOnly(ytED);
bc().addReadOnly(xlED);
bc().addReadOnly(xrED);
bc().addReadOnly(ybED);
bc().addReadOnly(extraFormatCO);
bc().addReadOnly(extraED);
bc().addCheckedLineEdit(angleED, angleLA);
bc().addCheckedLineEdit(displayscaleED, scaleLA);
bc().addCheckedLineEdit(heightED, heightLA);
bc().addCheckedLineEdit(widthED, widthLA);
bc().addCheckedLineEdit(xlED, lbLA);
bc().addCheckedLineEdit(ybED, lbLA);
bc().addCheckedLineEdit(xrED, rtLA);
bc().addCheckedLineEdit(ytED, rtLA);
bc().addCheckedLineEdit(fileED, fileLA);
std::vector<string> templates(controller().getTemplates());
for (std::vector<string>::const_iterator cit = templates.begin();
cit != templates.end(); ++cit) {
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)
originCO->addItem(toqstr(external::origin_gui_str(i)));
// Fill the width combo
widthUnitCO->addItem(qt_("Scale%"));
for (int i = 0; i < num_units; i++)
widthUnitCO->addItem(qt_(unit_name_gui[i]));
}
ControlExternal & GuiExternalDialog::controller() const
{
return static_cast<ControlExternal &>(Dialog::controller());
}
@ -165,8 +226,8 @@ bool GuiExternalDialog::activateAspectratio() const
void GuiExternalDialog::bbChanged()
{
form_->controller().bbChanged(true);
form_->changed();
controller().bbChanged(true);
changed();
}
@ -174,33 +235,33 @@ void GuiExternalDialog::browseClicked()
{
int const choice = externalCO->currentIndex();
docstring const template_name =
from_utf8(form_->controller().getTemplate(choice).lyxName);
from_utf8(controller().getTemplate(choice).lyxName);
docstring const str =
form_->controller().browse(qstring_to_ucs4(fileED->text()),
controller().browse(qstring_to_ucs4(fileED->text()),
template_name);
if (!str.empty()) {
fileED->setText(toqstr(str));
form_->changed();
changed();
}
}
void GuiExternalDialog::change_adaptor()
{
form_->changed();
changed();
}
void GuiExternalDialog::closeEvent(QCloseEvent * e)
{
form_->slotWMHide();
slotWMHide();
e->accept();
}
void GuiExternalDialog::editClicked()
{
form_->controller().editExternal();
controller().editExternal();
}
@ -208,34 +269,34 @@ void GuiExternalDialog::editClicked()
void GuiExternalDialog::extraChanged(const QString& text)
{
std::string const format = fromqstr(extraFormatCO->currentText());
form_->extra_[format] = text;
form_->changed();
extra_[format] = text;
changed();
}
void GuiExternalDialog::formatChanged(const QString& format)
{
extraED->setText(form_->extra_[fromqstr(format)]);
extraED->setText(extra_[fromqstr(format)]);
}
void GuiExternalDialog::getbbClicked()
{
form_->getBB();
getBB();
}
void GuiExternalDialog::sizeChanged()
{
aspectratioCB->setEnabled(activateAspectratio());
form_->changed();
changed();
}
void GuiExternalDialog::templateChanged()
{
form_->updateTemplate();
form_->changed();
updateTemplate();
changed();
}
@ -250,15 +311,10 @@ void GuiExternalDialog::widthUnitChanged()
heightED->setEnabled(useHeight);
heightUnitCO->setEnabled(useHeight);
form_->changed();
changed();
}
/////////////////////////////////////////////////////////////////////
//
// GuiExternal
//
/////////////////////////////////////////////////////////////////////
namespace {
@ -469,9 +525,9 @@ void getCrop(external::ClipData & data,
void getExtra(external::ExtraData & data,
GuiExternal::MapType const & extra)
GuiExternalDialog::MapType const & extra)
{
typedef GuiExternal::MapType MapType;
typedef GuiExternalDialog::MapType MapType;
MapType::const_iterator it = extra.begin();
MapType::const_iterator const end = extra.end();
for (; it != end; ++it)
@ -481,102 +537,36 @@ void getExtra(external::ExtraData & data,
} // namespace anon
GuiExternal::GuiExternal(GuiDialog & parent)
: GuiView<GuiExternalDialog>(parent, _("External Material"))
{}
void GuiExternal::build_dialog()
void GuiExternalDialog::update_contents()
{
dialog_.reset(new GuiExternalDialog(this));
bc().setOK(dialog_->okPB);
bc().setApply(dialog_->applyPB);
bc().setCancel(dialog_->closePB);
bc().addReadOnly(dialog_->fileED);
bc().addReadOnly(dialog_->browsePB);
bc().addReadOnly(dialog_->editPB);
bc().addReadOnly(dialog_->externalCO);
bc().addReadOnly(dialog_->draftCB);
bc().addReadOnly(dialog_->displayscaleED);
bc().addReadOnly(dialog_->showCO);
bc().addReadOnly(dialog_->displayCB);
bc().addReadOnly(dialog_->angleED);
bc().addReadOnly(dialog_->originCO);
bc().addReadOnly(dialog_->heightUnitCO);
bc().addReadOnly(dialog_->heightED);
bc().addReadOnly(dialog_->aspectratioCB);
bc().addReadOnly(dialog_->widthUnitCO);
bc().addReadOnly(dialog_->widthED);
bc().addReadOnly(dialog_->clipCB);
bc().addReadOnly(dialog_->getbbPB);
bc().addReadOnly(dialog_->ytED);
bc().addReadOnly(dialog_->xlED);
bc().addReadOnly(dialog_->xrED);
bc().addReadOnly(dialog_->ybED);
bc().addReadOnly(dialog_->extraFormatCO);
bc().addReadOnly(dialog_->extraED);
bc().addCheckedLineEdit(dialog_->angleED, dialog_->angleLA);
bc().addCheckedLineEdit(dialog_->displayscaleED, dialog_->scaleLA);
bc().addCheckedLineEdit(dialog_->heightED, dialog_->heightLA);
bc().addCheckedLineEdit(dialog_->widthED, dialog_->widthLA);
bc().addCheckedLineEdit(dialog_->xlED, dialog_->lbLA);
bc().addCheckedLineEdit(dialog_->ybED, dialog_->lbLA);
bc().addCheckedLineEdit(dialog_->xrED, dialog_->rtLA);
bc().addCheckedLineEdit(dialog_->ytED, dialog_->rtLA);
bc().addCheckedLineEdit(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);
tab->setCurrentIndex(0);
InsetExternalParams const & params = controller().params();
string const name =
params.filename.outputFilename(kernel().bufferFilepath());
dialog_->fileED->setText(toqstr(name));
fileED->setText(toqstr(name));
dialog_->externalCO->setCurrentIndex(
externalCO->setCurrentIndex(
controller().getTemplateNumber(params.templatename()));
updateTemplate();
dialog_->draftCB->setChecked(params.draft);
draftCB->setChecked(params.draft);
setDisplay(*dialog_->displayCB, *dialog_->showCO,
*dialog_->displayscaleED,
setDisplay(*displayCB, *showCO,
*displayscaleED,
params.display, params.lyxscale, readOnly());
setRotation(*dialog_->angleED, *dialog_->originCO, params.rotationdata);
setRotation(*angleED, *originCO, params.rotationdata);
setSize(*dialog_->widthED, *dialog_->widthUnitCO,
*dialog_->heightED, *dialog_->heightUnitCO,
*dialog_->aspectratioCB,
setSize(*widthED, *widthUnitCO,
*heightED, *heightUnitCO,
*aspectratioCB,
params.resizedata);
setCrop(*dialog_->clipCB,
*dialog_->xlED, *dialog_->ybED,
*dialog_->xrED, *dialog_->ytED,
setCrop(*clipCB,
*xlED, *ybED,
*xrED, *ytED,
params.clipdata);
controller().bbChanged(!params.clipdata.bbox.empty());
@ -584,11 +574,11 @@ void GuiExternal::update_contents()
}
void GuiExternal::updateTemplate()
void GuiExternalDialog::updateTemplate()
{
external::Template templ =
controller().getTemplate(dialog_->externalCO->currentIndex());
dialog_->externalTB->setPlainText(qt_(templ.helpText));
controller().getTemplate(externalCO->currentIndex());
externalTB->setPlainText(qt_(templ.helpText));
// Ascertain which (if any) transformations the template supports
// and disable tabs hosting unsupported transforms.
@ -597,32 +587,25 @@ void GuiExternal::updateTemplate()
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);
bool found = std::find(tr_begin, tr_end, external::Rotate) != tr_end;
tab->setTabEnabled(tab->indexOf(rotatetab), found);
found = std::find(tr_begin, tr_end, external::Resize) != tr_end;
tab->setTabEnabled(tab->indexOf(scaletab), found);
found = find(tr_begin, tr_end, external::Clip) != tr_end;
dialog_->tab->setTabEnabled(
dialog_->tab->indexOf(dialog_->croptab), found);
found = std::find(tr_begin, tr_end, external::Clip) != tr_end;
tab->setTabEnabled(tab->indexOf(croptab), found);
found = find(tr_begin, tr_end, external::Extra) != tr_end;
dialog_->tab->setTabEnabled(
dialog_->tab->indexOf(dialog_->optionstab), found);
found = std::find(tr_begin, tr_end, external::Extra) != tr_end;
tab->setTabEnabled(tab->indexOf(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();
extraFormatCO->clear();
external::Template::Formats::const_iterator it = templ.formats.begin();
external::Template::Formats::const_iterator end = templ.formats.end();
@ -632,76 +615,66 @@ void GuiExternal::updateTemplate()
continue;
string const format = it->first;
string const opt = controller().params().extradata.get(format);
extraCB->addItem(toqstr(format));
extraFormatCO->addItem(toqstr(format));
extra_[format] = toqstr(opt);
}
bool const enabled = extraCB->count() > 0;
bool const enabled = extraFormatCO->count() > 0;
dialog_->tab->setTabEnabled(
dialog_->tab->indexOf(dialog_->optionstab), enabled);
tab->setTabEnabled(
tab->indexOf(optionstab), enabled);
extraED->setEnabled(enabled && !kernel().isBufferReadonly());
extraCB->setEnabled(enabled);
extraFormatCO->setEnabled(enabled);
if (enabled) {
extraCB->setCurrentIndex(0);
extraED->setText(extra_[fromqstr(extraCB->currentText())]);
extraFormatCO->setCurrentIndex(0);
extraED->setText(extra_[fromqstr(extraFormatCO->currentText())]);
}
}
void GuiExternal::applyView()
void GuiExternalDialog::applyView()
{
InsetExternalParams params = controller().params();
params.filename.set(internal_path(fromqstr(dialog_->fileED->text())),
params.filename.set(internal_path(fromqstr(fileED->text())),
kernel().bufferFilepath());
params.settemplate(controller().getTemplate(
dialog_->externalCO->currentIndex()).lyxName);
externalCO->currentIndex()).lyxName);
params.draft = dialog_->draftCB->isChecked();
params.draft = draftCB->isChecked();
getDisplay(params.display, params.lyxscale,
*dialog_->displayCB, *dialog_->showCO,
*dialog_->displayscaleED);
*displayCB, *showCO,
*displayscaleED);
if (dialog_->tab->isTabEnabled(
dialog_->tab->indexOf(dialog_->rotatetab)))
getRotation(params.rotationdata,
*dialog_->angleED, *dialog_->originCO);
if (tab->isTabEnabled(tab->indexOf(rotatetab)))
getRotation(params.rotationdata, *angleED, *originCO);
if (dialog_->tab->isTabEnabled(
dialog_->tab->indexOf(dialog_->scaletab)))
getSize(params.resizedata,
*dialog_->widthED, *dialog_->widthUnitCO,
*dialog_->heightED, *dialog_->heightUnitCO,
*dialog_->aspectratioCB);
if (tab->isTabEnabled(tab->indexOf(scaletab)))
getSize(params.resizedata, *widthED, *widthUnitCO,
*heightED, *heightUnitCO, *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 (tab->isTabEnabled(tab->indexOf(croptab)))
getCrop(params.clipdata, *clipCB, *xlED, *ybED,
*xrED, *ytED, controller().bbChanged());
if (dialog_->tab->isTabEnabled(
dialog_->tab->indexOf(dialog_->optionstab)))
if (tab->isTabEnabled(tab->indexOf(optionstab)))
getExtra(params.extradata, extra_);
controller().setParams(params);
}
void GuiExternal::getBB()
void GuiExternalDialog::getBB()
{
dialog_->xlED->setText("0");
dialog_->ybED->setText("0");
dialog_->xrED->setText("0");
dialog_->ytED->setText("0");
xlED->setText("0");
ybED->setText("0");
xrED->setText("0");
ytED->setText("0");
string const filename = fromqstr(dialog_->fileED->text());
string const filename = fromqstr(fileED->text());
if (filename.empty())
return;
@ -709,10 +682,10 @@ void GuiExternal::getBB()
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)));
xlED->setText(toqstr(token(bb, ' ', 0)));
ybED->setText(toqstr(token(bb, ' ', 1)));
xrED->setText(toqstr(token(bb, ' ', 2)));
ytED->setText(toqstr(token(bb, ' ', 3)));
controller().bbChanged(false);
}

View File

@ -12,74 +12,54 @@
#ifndef GUIEXTERNAL_H
#define GUIEXTERNAL_H
#include "GuiDialogView.h"
#include "GuiDialog.h"
#include "ControlExternal.h"
#include "ui_ExternalUi.h"
#include <QCloseEvent>
#include <QDialog>
#include <map>
namespace lyx {
namespace frontend {
class GuiExternal;
class GuiExternalDialog : public QDialog, public Ui::ExternalUi
class GuiExternalDialog : public GuiDialog, public Ui::ExternalUi
{
Q_OBJECT
public:
GuiExternalDialog(GuiExternal * form);
GuiExternalDialog(LyXView & lv);
virtual void showView();
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();
private Q_SLOTS:
void bbChanged();
void browseClicked();
void change_adaptor();
void editClicked();
void extraChanged(const QString&);
void formatChanged(const QString&);
void getbbClicked();
void sizeChanged();
void templateChanged();
void widthUnitChanged();
protected:
virtual void closeEvent(QCloseEvent * e);
private:
public:
void showView();
void closeEvent(QCloseEvent * e);
//
bool activateAspectratio() const;
GuiExternal * form_;
};
class GuiExternal : public GuiView<GuiExternalDialog>
{
public:
friend class GuiExternalDialog;
GuiExternal(GuiDialog &);
/// parent controller
ControlExternal & controller()
{ return static_cast<ControlExternal &>(this->getController()); }
/// parent controller
ControlExternal const & controller() const
{ return static_cast<ControlExternal const &>(this->getController()); }
///
typedef std::map<std::string, QString> MapType;
private:
ControlExternal & controller() const;
/// Apply changes
virtual void applyView();
void applyView();
/// update
virtual void update_contents();
/// build the dialog
virtual void build_dialog();
void update_contents();
/// Helper function called when the template is changed.
void updateTemplate();
/// get bounding box from file
void getBB();
///
typedef std::map<std::string, QString> MapType;
///
MapType extra_;
};

View File

@ -11,6 +11,8 @@
#include <config.h>
#include "GuiFloat.h"
#include "ControlFloat.h"
#include "FloatPlacement.h"
#include "insets/InsetFloat.h"
@ -18,76 +20,69 @@
#include <QCloseEvent>
#include <QPushButton>
namespace lyx {
namespace frontend {
GuiFloatDialog::GuiFloatDialog(GuiFloat * form)
: form_(form)
GuiFloatDialog::GuiFloatDialog(LyXView & lv)
: GuiDialog(lv, "float")
{
setController(new ControlFloat(*this));
setViewTitle(_("Float Settings"));
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(restorePB, SIGNAL(clicked()), this, SLOT(slotRestore()));
connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
connect(applyPB, SIGNAL(clicked()), this, SLOT(slotApply()));
connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
// enable span columns checkbox
floatFP->useWide();
// enable sideways checkbox
floatFP->useSideways();
connect(floatFP, SIGNAL(changed()),
this, SLOT(change_adaptor()));
connect(floatFP, SIGNAL(changed()), this, SLOT(change_adaptor()));
bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
bc().setCancel(closePB);
bc().setApply(applyPB);
bc().setOK(okPB);
bc().setRestore(restorePB);
bc().addReadOnly(floatFP);
}
ControlFloat & GuiFloatDialog::controller() const
{
return static_cast<ControlFloat &>(Dialog::controller());
}
void GuiFloatDialog::change_adaptor()
{
form_->changed();
changed();
}
void GuiFloatDialog::closeEvent(QCloseEvent * e)
{
form_->slotWMHide();
slotWMHide();
e->accept();
}
GuiFloat::GuiFloat(GuiDialog & parent)
: GuiView<GuiFloatDialog>(parent, _("Float Settings"))
void GuiFloatDialog::update_contents()
{
floatFP->set(controller().params());
}
void GuiFloat::build_dialog()
{
dialog_.reset(new GuiFloatDialog(this));
bc().setCancel(dialog_->closePB);
bc().setApply(dialog_->applyPB);
bc().setOK(dialog_->okPB);
bc().setRestore(dialog_->restorePB);
bc().addReadOnly(dialog_->floatFP);
}
void GuiFloat::update_contents()
{
dialog_->floatFP->set(controller().params());
}
void GuiFloat::applyView()
void GuiFloatDialog::applyView()
{
InsetFloatParams & params = controller().params();
params.placement = dialog_->floatFP->get(params.wide, params.sideways);
params.placement = floatFP->get(params.wide, params.sideways);
}
} // namespace frontend

View File

@ -12,53 +12,31 @@
#ifndef GUIFLOAT_H
#define GUIFLOAT_H
#include "GuiDialogView.h"
#include "ui_FloatUi.h"
#include "GuiDialog.h"
#include "ControlFloat.h"
#include <QDialog>
#include "ui_FloatUi.h"
namespace lyx {
namespace frontend {
class GuiFloat;
class GuiFloatDialog : public QDialog, public Ui::FloatUi {
class GuiFloatDialog : public GuiDialog, public Ui::FloatUi
{
Q_OBJECT
public:
GuiFloatDialog(GuiFloat * form);
GuiFloatDialog(LyXView & lv);
protected Q_SLOTS:
virtual void change_adaptor();
protected:
virtual void closeEvent(QCloseEvent * e);
private Q_SLOTS:
void change_adaptor();
private:
GuiFloat * form_;
};
///
class GuiFloat : public GuiView<GuiFloatDialog> {
public:
///
friend class GuiFloatDialog;
///
GuiFloat(GuiDialog &);
void closeEvent(QCloseEvent * e);
/// parent controller
ControlFloat & controller()
{ return static_cast<ControlFloat &>(this->getController()); }
/// parent controller
ControlFloat const & controller() const
{ return static_cast<ControlFloat const &>(this->getController()); }
private:
ControlFloat & controller() const;
/// Apply changes
virtual void applyView();
void applyView();
/// update
virtual void update_contents();
/// build the dialog
virtual void build_dialog();
void update_contents();
};
} // namespace frontend

View File

@ -18,14 +18,12 @@
class QPaintEvent;
//namespace lyx {
class GuiFontExample : public QWidget {
class GuiFontExample : public QWidget
{
public:
GuiFontExample(QWidget * parent)
: QWidget(parent) {}
GuiFontExample(QWidget * parent) : QWidget(parent) {}
void set(QFont const & font, QString const & text);

View File

@ -28,7 +28,8 @@ namespace frontend {
* Qt font loader for LyX. Matches Fonts against
* actual QFont instances, and also caches metrics.
*/
class QLFontInfo {
class QLFontInfo
{
public:
QLFontInfo(Font const & f);

View File

@ -19,7 +19,6 @@
#include <QFontMetrics>
#include <QHash>
namespace lyx {
namespace frontend {

View File

@ -15,6 +15,7 @@
#include "GuiGraphics.h"
#include "ControlGraphics.h"
#include "debug.h"
#include "LengthCombo.h"
#include "lengthcommon.h"
@ -68,19 +69,18 @@ getFirst(std::vector<Pair> const & pr)
return tmp;
}
GuiGraphicsDialog::GuiGraphicsDialog(GuiGraphics * form)
: form_(form)
GuiGraphicsDialog::GuiGraphicsDialog(LyXView & lv)
: GuiDialog(lv, "graphics")
{
setupUi(this);
setViewTitle(_("Graphics"));
setController(new ControlGraphics(*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()));
connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
connect(applyPB, SIGNAL(clicked()), this, SLOT(slotApply()));
connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
connect(restorePB, SIGNAL(clicked()), this, SLOT(slotRestore()));
//graphics pane
connect(filename, SIGNAL(textChanged(const QString &)),
@ -173,6 +173,47 @@ GuiGraphicsDialog::GuiGraphicsDialog(GuiGraphics * form)
connect(displayscale, SIGNAL(textChanged(const QString&)),
this, SLOT(change_adaptor()));
displayscale->setValidator(new QIntValidator(displayscale));
bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
bc().setOK(okPB);
bc().setApply(applyPB);
bc().setRestore(restorePB);
bc().setCancel(closePB);
bc().addReadOnly(latexoptions);
bc().addReadOnly(subfigure);
bc().addReadOnly(filenameL);
bc().addReadOnly(filename);
bc().addReadOnly(browsePB);
bc().addReadOnly(unzipCB);
bc().addReadOnly(bbFrame);
bc().addReadOnly(draftCB);
bc().addReadOnly(clip);
bc().addReadOnly(unzipCB);
bc().addReadOnly(displayGB);
bc().addReadOnly(sizeGB);
bc().addReadOnly(rotationGB);
bc().addReadOnly(latexoptions);
bc().addReadOnly(getPB);
bc().addReadOnly(rotateOrderCB);
// initialize the length validator
bc().addCheckedLineEdit(Scale, scaleCB);
bc().addCheckedLineEdit(Width, WidthCB);
bc().addCheckedLineEdit(Height, HeightCB);
bc().addCheckedLineEdit(displayscale, scaleLA);
bc().addCheckedLineEdit(angle, angleL);
bc().addCheckedLineEdit(lbX, xL);
bc().addCheckedLineEdit(lbY, yL);
bc().addCheckedLineEdit(rtX, xL_2);
bc().addCheckedLineEdit(rtY, yL_2);
bc().addCheckedLineEdit(filename, filenameL);
}
ControlGraphics & GuiGraphicsDialog::controller() const
{
return static_cast<ControlGraphics &>(GuiDialog::controller());
}
@ -184,22 +225,22 @@ void GuiGraphicsDialog::showView()
void GuiGraphicsDialog::change_adaptor()
{
form_->changed();
changed();
}
void GuiGraphicsDialog::change_bb()
{
form_->controller().bbChanged = true;
controller().bbChanged = true;
LYXERR(Debug::GRAPHICS)
<< "[controller().bb_Changed set to true]\n";
form_->changed();
changed();
}
void GuiGraphicsDialog::closeEvent(QCloseEvent * e)
{
form_->slotWMHide();
slotWMHide();
e->accept();
}
@ -207,23 +248,23 @@ void GuiGraphicsDialog::closeEvent(QCloseEvent * e)
void GuiGraphicsDialog::on_browsePB_clicked()
{
docstring const str =
form_->controller().browse(qstring_to_ucs4(filename->text()));
controller().browse(qstring_to_ucs4(filename->text()));
if(!str.empty()){
filename->setText(toqstr(str));
form_->changed();
changed();
}
}
void GuiGraphicsDialog::on_getPB_clicked()
{
form_->getBB();
getBB();
}
void GuiGraphicsDialog::on_editPB_clicked()
{
form_->controller().editGraphics();
controller().editGraphics();
}
@ -235,7 +276,8 @@ void GuiGraphicsDialog::on_filename_textChanged(const QString & filename)
void GuiGraphicsDialog::setAutoText()
{
if (scaleCB->isChecked()) return;
if (scaleCB->isChecked())
return;
if (!Scale->isEnabled() && Scale->text() != "100")
Scale->setText(QString("auto"));
@ -277,6 +319,7 @@ void GuiGraphicsDialog::on_scaleCB_toggled(bool setScale)
setAutoText();
}
void GuiGraphicsDialog::on_WidthCB_toggled(bool setWidth)
{
Width->setEnabled(setWidth);
@ -335,53 +378,6 @@ void GuiGraphicsDialog::on_angle_textChanged(const QString & filename)
(filename != "0"));
}
GuiGraphics::GuiGraphics(GuiDialog & parent)
: GuiView<GuiGraphicsDialog>(parent, _("Graphics"))
{
}
void GuiGraphics::build_dialog()
{
dialog_.reset(new GuiGraphicsDialog(this));
bc().setOK(dialog_->okPB);
bc().setApply(dialog_->applyPB);
bc().setRestore(dialog_->restorePB);
bc().setCancel(dialog_->closePB);
bc().addReadOnly(dialog_->latexoptions);
bc().addReadOnly(dialog_->subfigure);
bc().addReadOnly(dialog_->filenameL);
bc().addReadOnly(dialog_->filename);
bc().addReadOnly(dialog_->browsePB);
bc().addReadOnly(dialog_->unzipCB);
bc().addReadOnly(dialog_->bbFrame);
bc().addReadOnly(dialog_->draftCB);
bc().addReadOnly(dialog_->clip);
bc().addReadOnly(dialog_->unzipCB);
bc().addReadOnly(dialog_->displayGB);
bc().addReadOnly(dialog_->sizeGB);
bc().addReadOnly(dialog_->rotationGB);
bc().addReadOnly(dialog_->latexoptions);
bc().addReadOnly(dialog_->getPB);
bc().addReadOnly(dialog_->rotateOrderCB);
// initialize the length validator
bc().addCheckedLineEdit(dialog_->Scale, dialog_->scaleCB);
bc().addCheckedLineEdit(dialog_->Width, dialog_->WidthCB);
bc().addCheckedLineEdit(dialog_->Height, dialog_->HeightCB);
bc().addCheckedLineEdit(dialog_->displayscale, dialog_->scaleLA);
bc().addCheckedLineEdit(dialog_->angle, dialog_->angleL);
bc().addCheckedLineEdit(dialog_->lbX, dialog_->xL);
bc().addCheckedLineEdit(dialog_->lbY, dialog_->yL);
bc().addCheckedLineEdit(dialog_->rtX, dialog_->xL_2);
bc().addCheckedLineEdit(dialog_->rtY, dialog_->yL_2);
bc().addCheckedLineEdit(dialog_->filename, dialog_->filenameL);
}
// returns the number of the string s in the vector v
static int getItemNo(const vector<string> & v, string const & s)
{
@ -391,20 +387,20 @@ static int getItemNo(const vector<string> & v, string const & s)
}
void GuiGraphics::update_contents()
void GuiGraphicsDialog::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();
lbXunit->clear();
lbYunit->clear();
rtXunit->clear();
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));
lbXunit->addItem(toqstr(*it));
lbYunit->addItem(toqstr(*it));
rtXunit->addItem(toqstr(*it));
rtYunit->addItem(toqstr(*it));
}
InsetGraphicsParams & igp = controller().params();
@ -423,20 +419,20 @@ void GuiGraphics::update_contents()
string const name =
igp.filename.outputFilename(kernel().bufferFilepath());
dialog_->filename->setText(toqstr(name));
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);
lbX->setText(toqstr(token(bb, ' ', 0)));
lbY->setText(toqstr(token(bb, ' ', 1)));
rtX->setText(toqstr(token(bb, ' ', 2)));
rtY->setText(toqstr(token(bb, ' ', 3)));
lbXunit->setCurrentIndex(0);
lbYunit->setCurrentIndex(0);
rtXunit->setCurrentIndex(0);
rtYunit->setCurrentIndex(0);
controller().bbChanged = false;
} else {
// get the values from the inset
@ -446,44 +442,44 @@ void GuiGraphics::update_contents()
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())));
lbX->setText(toqstr(convert<string>(anyLength.value())));
string const unit(unit_name[anyLength.unit()]);
dialog_->lbXunit->setCurrentIndex(getItemNo(bb_units, unit));
lbXunit->setCurrentIndex(getItemNo(bb_units, unit));
} else {
dialog_->lbX->setText(toqstr(xl));
lbX->setText(toqstr(xl));
}
if (isValidLength(yl, &anyLength)) {
dialog_->lbY->setText(toqstr(convert<string>(anyLength.value())));
lbY->setText(toqstr(convert<string>(anyLength.value())));
string const unit(unit_name[anyLength.unit()]);
dialog_->lbYunit->setCurrentIndex(getItemNo(bb_units, unit));
lbYunit->setCurrentIndex(getItemNo(bb_units, unit));
} else {
dialog_->lbY->setText(toqstr(xl));
lbY->setText(toqstr(xl));
}
if (isValidLength(xr, &anyLength)) {
dialog_->rtX->setText(toqstr(convert<string>(anyLength.value())));
rtX->setText(toqstr(convert<string>(anyLength.value())));
string const unit(unit_name[anyLength.unit()]);
dialog_->rtXunit->setCurrentIndex(getItemNo(bb_units, unit));
rtXunit->setCurrentIndex(getItemNo(bb_units, unit));
} else {
dialog_->rtX->setText(toqstr(xl));
rtX->setText(toqstr(xl));
}
if (isValidLength(yr, &anyLength)) {
dialog_->rtY->setText(toqstr(convert<string>(anyLength.value())));
rtY->setText(toqstr(convert<string>(anyLength.value())));
string const unit(unit_name[anyLength.unit()]);
dialog_->rtYunit->setCurrentIndex(getItemNo(bb_units, unit));
rtYunit->setCurrentIndex(getItemNo(bb_units, unit));
} else {
dialog_->rtY->setText(toqstr(xl));
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);
draftCB->setChecked(igp.draft);
clip->setChecked(igp.clip);
unzipCB->setChecked(igp.noUnzip);
// Update the subcaption check button and input field
dialog_->subfigure->setChecked(igp.subcaption);
dialog_->subcaption->setText(toqstr(igp.subcaptionText));
subfigure->setChecked(igp.subcaption);
subcaption->setText(toqstr(igp.subcaptionText));
int item = 0;
switch (igp.display) {
@ -493,124 +489,122 @@ void GuiGraphics::update_contents()
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);
showCB->setCurrentIndex(item);
displayscale->setText(toqstr(convert<string>(igp.lyxscale)));
displayGB->setChecked(igp.display != graphics::NoDisplay);
// the output section (width/height)
dialog_->Scale->setText(toqstr(igp.scale));
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);
scaleCB->blockSignals(true);
scaleCB->setChecked(scaleChecked);
scaleCB->blockSignals(false);
Scale->setEnabled(scaleChecked);
lengthAutoToWidgets(dialog_->Width, dialog_->widthUnit, igp.width,
lengthAutoToWidgets(Width, 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);
bool const widthChecked = !Width->text().isEmpty() &&
Width->text() != "auto";
WidthCB->blockSignals(true);
WidthCB->setChecked(widthChecked);
WidthCB->blockSignals(false);
Width->setEnabled(widthChecked);
widthUnit->setEnabled(widthChecked);
lengthAutoToWidgets(dialog_->Height, dialog_->heightUnit, igp.height,
lengthAutoToWidgets(Height, 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);
bool const heightChecked = !Height->text().isEmpty()
&& Height->text() != "auto";
HeightCB->blockSignals(true);
HeightCB->setChecked(heightChecked);
HeightCB->blockSignals(false);
Height->setEnabled(heightChecked);
heightUnit->setEnabled(heightChecked);
dialog_->scaleCB->setEnabled(!widthChecked && !heightChecked);
dialog_->WidthCB->setEnabled(!scaleChecked);
dialog_->HeightCB->setEnabled(!scaleChecked);
dialog_->aspectratio->setEnabled(widthChecked && heightChecked);
scaleCB->setEnabled(!widthChecked && !heightChecked);
WidthCB->setEnabled(!scaleChecked);
HeightCB->setEnabled(!scaleChecked);
aspectratio->setEnabled(widthChecked && heightChecked);
dialog_->setAutoText();
setAutoText();
dialog_->angle->setText(toqstr(igp.rotateAngle));
dialog_->rotateOrderCB->setChecked(igp.scaleBeforeRotation);
angle->setText(toqstr(igp.rotateAngle));
rotateOrderCB->setChecked(igp.scaleBeforeRotation);
dialog_->rotateOrderCB->setEnabled((widthChecked ||
heightChecked ||
scaleChecked) &&
(igp.rotateAngle != "0"));
rotateOrderCB->setEnabled( (widthChecked || heightChecked || scaleChecked)
&& igp.rotateAngle != "0");
dialog_->origin->clear();
origin->clear();
vector<RotationOriginPair> origindata = getRotationOriginData();
vector<docstring> const origin_lang = getFirst(origindata);
GuiGraphics::origin_ltx = getSecond(origindata);
origin_ltx = getSecond(origindata);
for (vector<docstring>::const_iterator it = origin_lang.begin();
it != origin_lang.end(); ++it)
dialog_->origin->addItem(toqstr(*it));
origin->addItem(toqstr(*it));
if (!igp.rotateOrigin.empty())
dialog_->origin->setCurrentIndex(
origin->setCurrentIndex(
getItemNo(origin_ltx, igp.rotateOrigin));
else
dialog_->origin->setCurrentIndex(0);
origin->setCurrentIndex(0);
// disable edit button when no filename is present
dialog_->editPB->setDisabled(dialog_->filename->text().isEmpty());
editPB->setDisabled(filename->text().isEmpty());
//// latex section
dialog_->latexoptions->setText(toqstr(igp.special));
latexoptions->setText(toqstr(igp.special));
}
void GuiGraphics::applyView()
void GuiGraphicsDialog::applyView()
{
InsetGraphicsParams & igp = controller().params();
igp.filename.set(internal_path(fromqstr(dialog_->filename->text())),
igp.filename.set(internal_path(fromqstr(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()));
string lbXs = fromqstr(lbX->text());
string lbYs = fromqstr(lbY->text());
string rtXs = fromqstr(rtX->text());
string rtYs = fromqstr(rtY->text());
int bb_sum =
convert<int>(lbX) + convert<int>(lbY) +
convert<int>(rtX) + convert<int>(rtX);
convert<int>(lbXs) + convert<int>(lbYs) +
convert<int>(rtXs) + convert<int>(rtXs);
if (bb_sum) {
if (lbX.empty())
if (lbXs.empty())
bb = "0 ";
else
bb = lbX + fromqstr(dialog_->lbXunit->currentText()) + ' ';
if (lbY.empty())
bb = lbXs + fromqstr(lbXunit->currentText()) + ' ';
if (lbYs.empty())
bb += "0 ";
else
bb += (lbY + fromqstr(dialog_->lbYunit->currentText()) + ' ');
if (rtX.empty())
bb += (lbYs + fromqstr(lbYunit->currentText()) + ' ');
if (rtXs.empty())
bb += "0 ";
else
bb += (rtX + fromqstr(dialog_->rtXunit->currentText()) + ' ');
if (rtY.empty())
bb += (rtXs + fromqstr(rtXunit->currentText()) + ' ');
if (rtYs.empty())
bb += '0';
else
bb += (rtY + fromqstr(dialog_->rtYunit->currentText()));
bb += (rtYs + fromqstr(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());
igp.draft = draftCB->isChecked();
igp.clip = clip->isChecked();
igp.subcaption = subfigure->isChecked();
igp.subcaptionText = fromqstr(subcaption->text());
switch (dialog_->showCB->currentIndex()) {
switch (showCB->currentIndex()) {
case 0: igp.display = graphics::DefaultDisplay; break;
case 1: igp.display = graphics::MonochromeDisplay; break;
case 2: igp.display = graphics::GrayscaleDisplay; break;
@ -618,35 +612,33 @@ void GuiGraphics::applyView()
default:;
}
if (!dialog_->displayGB->isChecked())
if (!displayGB->isChecked())
igp.display = graphics::NoDisplay;
//the graphics section
if (dialog_->scaleCB->isChecked() && !dialog_->Scale->text().isEmpty()) {
igp.scale = fromqstr(dialog_->Scale->text());
if (scaleCB->isChecked() && !Scale->text().isEmpty()) {
igp.scale = fromqstr(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
igp.width = WidthCB->isChecked() ?
//Note that this works even if Width is "auto", since in
//that case we get "0pt".
Length(widgetsToLength(dialog_->Width, dialog_->widthUnit)):
Length(widgetsToLength(Width, widthUnit)):
Length("0pt");
igp.height = dialog_->HeightCB->isChecked() ?
Length(widgetsToLength(dialog_->Height, dialog_->heightUnit)) :
igp.height = HeightCB->isChecked() ?
Length(widgetsToLength(Height, heightUnit)) :
Length("0pt");
igp.keepAspectRatio = dialog_->aspectratio->isEnabled() &&
dialog_->aspectratio->isChecked() &&
igp.keepAspectRatio = aspectratio->isEnabled() &&
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());
igp.noUnzip = unzipCB->isChecked();
igp.lyxscale = displayscale->text().toInt();
igp.rotateAngle = fromqstr(angle->text());
double rotAngle = convert<double>(igp.rotateAngle);
if (std::abs(rotAngle) > 360.0) {
@ -656,41 +648,39 @@ void GuiGraphics::applyView()
// 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();
igp.rotateOrigin = origin_ltx[origin->currentIndex()];
igp.scaleBeforeRotation = rotateOrderCB->isChecked();
// more latex options
igp.special = fromqstr(dialog_->latexoptions->text());
igp.special = fromqstr(latexoptions->text());
}
void GuiGraphics::getBB()
void GuiGraphicsDialog::getBB()
{
string const filename(fromqstr(dialog_->filename->text()));
if (!filename.empty()) {
string const bb(controller().readBB(filename));
string const fn = fromqstr(filename->text());
if (!fn.empty()) {
string const bb = controller().readBB(fn);
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)));
lbX->setText(toqstr(token(bb, ' ', 0)));
lbY->setText(toqstr(token(bb, ' ', 1)));
rtX->setText(toqstr(token(bb, ' ', 2)));
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);
lbXunit->setCurrentIndex(0);
lbYunit->setCurrentIndex(0);
rtXunit->setCurrentIndex(0);
rtYunit->setCurrentIndex(0);
}
controller().bbChanged = false;
}
}
bool GuiGraphics::isValid()
bool GuiGraphicsDialog::isValid()
{
return !dialog_->filename->text().isEmpty();
return !filename->text().isEmpty();
}
} // namespace frontend

View File

@ -13,11 +13,9 @@
#ifndef GUIGRAPHICS_H
#define GUIGRAPHICS_H
#include "GuiDialogView.h"
#include "ui_GraphicsUi.h"
#include "GuiDialog.h"
#include "ControlGraphics.h"
#include <QDialog>
#include "ui_GraphicsUi.h"
#include <vector>
@ -26,61 +24,38 @@ class QString;
namespace lyx {
namespace frontend {
class GuiGraphics;
class GuiGraphicsDialog : public QDialog, public Ui::GraphicsUi
class GuiGraphicsDialog : public GuiDialog, public Ui::GraphicsUi
{
Q_OBJECT
public:
GuiGraphicsDialog(GuiGraphics * form);
virtual void setAutoText();
virtual void showView();
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);
GuiGraphicsDialog(LyXView & lv);
void setAutoText();
void showView();
private Q_SLOTS:
void change_adaptor();
void change_bb();
void on_browsePB_clicked();
void on_getPB_clicked();
void on_editPB_clicked();
void on_filename_textChanged(const QString &);
void on_scaleCB_toggled(bool);
void on_WidthCB_toggled(bool);
void on_HeightCB_toggled(bool);
void on_angle_textChanged(const QString &);
private:
GuiGraphics * form_;
};
class GuiGraphics : public GuiView<GuiGraphicsDialog>
{
public:
///
friend class GuiGraphicsDialog;
///
GuiGraphics(GuiDialog &);
void closeEvent(QCloseEvent * e);
/// parent controller
ControlGraphics & controller()
{ return static_cast<ControlGraphics &>(this->getController()); }
/// parent controller
ControlGraphics const & controller() const
{ return static_cast<ControlGraphics const &>(this->getController()); }
protected:
virtual bool isValid();
private:
ControlGraphics & controller() const;
bool isValid();
/// Apply changes
virtual void applyView();
void applyView();
/// update
virtual void update_contents();
/// build the dialog
virtual void build_dialog();
void update_contents();
/// get bounding box from file
void getBB();
/// Store the LaTeX names for the rotation origins.
std::vector<std::string> origin_ltx;
};
} // namespace frontend

View File

@ -21,7 +21,8 @@
namespace lyx {
namespace graphics {
class GuiImage : public Image {
class GuiImage : public Image
{
public:
/// Access to this class is through this static method.
static ImagePtr newImage();

View File

@ -10,11 +10,12 @@
#include <config.h>
#include "GuiInclude.h"
#include "ControlInclude.h"
#include "support/os.h"
#include "support/lstrings.h"
#include "GuiInclude.h"
#include "qt_helpers.h"
#include "LyXRC.h"
@ -33,21 +34,19 @@ using lyx::support::prefixIs;
using lyx::support::getStringFromVector;
using lyx::support::getVectorFromString;
namespace lyx {
namespace frontend {
/////////////////////////////////////////////////////////////////////
//
// GuiIncludeDialog
//
/////////////////////////////////////////////////////////////////////
GuiIncludeDialog::GuiIncludeDialog(GuiInclude * form)
: form_(form)
GuiIncludeDialog::GuiIncludeDialog(LyXView & lv)
: GuiDialog(lv, "include")
{
setupUi(this);
connect(okPB, SIGNAL(clicked()), form, SLOT(slotOK()));
connect(closePB, SIGNAL(clicked()), form, SLOT(slotClose()));
setViewTitle(_("Child Document"));
setController(new ControlInclude(*this));
connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
connect(visiblespaceCB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
connect(filenameED, SIGNAL(textChanged(const QString &)),
@ -65,6 +64,23 @@ GuiIncludeDialog::GuiIncludeDialog(GuiInclude * form)
connect(bypassCB, SIGNAL(clicked()), this, SLOT(set_listings_msg()));
setFocusProxy(filenameED);
bc().setPolicy(ButtonPolicy::OkApplyCancelReadOnlyPolicy);
bc().setOK(okPB);
bc().setCancel(closePB);
bc().addReadOnly(filenameED);
bc().addReadOnly(browsePB);
bc().addReadOnly(visiblespaceCB);
bc().addReadOnly(typeCO);
bc().addReadOnly(listingsED);
bc().addCheckedLineEdit(filenameED, filenameLA);
}
ControlInclude & GuiIncludeDialog::controller() const
{
return static_cast<ControlInclude &>(Dialog::controller());
}
@ -76,7 +92,7 @@ void GuiIncludeDialog::showView()
void GuiIncludeDialog::change_adaptor()
{
form_->changed();
changed();
}
@ -118,7 +134,7 @@ void GuiIncludeDialog::set_listings_msg()
void GuiIncludeDialog::closeEvent(QCloseEvent * e)
{
form_->slotWMHide();
slotWMHide();
e->accept();
}
@ -166,59 +182,31 @@ void GuiIncludeDialog::typeChanged(int v)
void GuiIncludeDialog::editClicked()
{
form_->edit();
edit();
}
void GuiIncludeDialog::browseClicked()
{
form_->browse();
browse();
}
/////////////////////////////////////////////////////////////////////
//
// GuiInclude
//
/////////////////////////////////////////////////////////////////////
GuiInclude::GuiInclude(GuiDialog & parent)
: GuiView<GuiIncludeDialog>(parent, _("Child Document"))
{}
void GuiInclude::build_dialog()
{
dialog_.reset(new GuiIncludeDialog(this));
bc().setOK(dialog_->okPB);
bc().setCancel(dialog_->closePB);
bc().addReadOnly(dialog_->filenameED);
bc().addReadOnly(dialog_->browsePB);
bc().addReadOnly(dialog_->visiblespaceCB);
bc().addReadOnly(dialog_->typeCO);
bc().addReadOnly(dialog_->listingsED);
bc().addCheckedLineEdit(dialog_->filenameED, dialog_->filenameLA);
}
void GuiInclude::update_contents()
void GuiIncludeDialog::update_contents()
{
InsetCommandParams const & params = controller().params();
dialog_->filenameED->setText(toqstr(params["filename"]));
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(
visiblespaceCB->setChecked(false);
visiblespaceCB->setEnabled(false);
previewCB->setChecked(false);
previewCB->setEnabled(false);
listingsGB->setEnabled(false);
captionLE->clear();
labelLE->clear();
listingsED->clear();
listingsTB->setPlainText(
qt_("Input listing parameters on the right. Enter ? for a list of parameters."));
string cmdname = controller().params().getCmdName();
@ -229,26 +217,26 @@ void GuiInclude::update_contents()
cmdname = "input";
if (cmdname == "include") {
dialog_->typeCO->setCurrentIndex(0);
typeCO->setCurrentIndex(0);
} else if (cmdname == "input") {
dialog_->typeCO->setCurrentIndex(1);
dialog_->previewCB->setEnabled(true);
dialog_->previewCB->setChecked(params.preview());
typeCO->setCurrentIndex(1);
previewCB->setEnabled(true);
previewCB->setChecked(params.preview());
} else if (cmdname == "verbatiminput*") {
dialog_->typeCO->setCurrentIndex(2);
dialog_->visiblespaceCB->setEnabled(true);
dialog_->visiblespaceCB->setChecked(true);
typeCO->setCurrentIndex(2);
visiblespaceCB->setEnabled(true);
visiblespaceCB->setChecked(true);
} else if (cmdname == "verbatiminput") {
dialog_->typeCO->setCurrentIndex(2);
dialog_->visiblespaceCB->setEnabled(true);
typeCO->setCurrentIndex(2);
visiblespaceCB->setEnabled(true);
} else if (cmdname == "lstinputlisting") {
dialog_->typeCO->setCurrentIndex(3);
dialog_->listingsGB->setEnabled(true);
dialog_->listingsED->setEnabled(true);
typeCO->setCurrentIndex(3);
listingsGB->setEnabled(true);
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");
@ -257,32 +245,32 @@ void GuiInclude::update_contents()
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)));
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)));
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()));
listingsED->setPlainText(toqstr(InsetListingsParams(extra).separatedParams()));
}
}
void GuiInclude::applyView()
void GuiIncludeDialog::applyView()
{
InsetCommandParams params = controller().params();
params["filename"] = from_utf8(internal_path(fromqstr(dialog_->filenameED->text())));
params.preview(dialog_->previewCB->isChecked());
params["filename"] = from_utf8(internal_path(fromqstr(filenameED->text())));
params.preview(previewCB->isChecked());
int const item = dialog_->typeCO->currentIndex();
int const item = typeCO->currentIndex();
if (item == 0) {
params.setCmdName("include");
} else if (item == 1) {
@ -290,16 +278,16 @@ void GuiInclude::applyView()
} 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());
InsetListingsParams par(fromqstr(listingsED->toPlainText()));
string caption = fromqstr(captionLE->text());
string label = fromqstr(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())
if (visiblespaceCB->isChecked())
params.setCmdName("verbatiminput*");
else
params.setCmdName("verbatiminput");
@ -308,11 +296,11 @@ void GuiInclude::applyView()
}
void GuiInclude::browse()
void GuiIncludeDialog::browse()
{
ControlInclude::Type type;
int const item = dialog_->typeCO->currentIndex();
int const item = typeCO->currentIndex();
if (item == 0)
type = ControlInclude::INCLUDE;
else if (item == 1)
@ -323,26 +311,26 @@ void GuiInclude::browse()
type = ControlInclude::LISTINGS;
docstring const & name =
controller().browse(qstring_to_ucs4(dialog_->filenameED->text()), type);
controller().browse(qstring_to_ucs4(filenameED->text()), type);
if (!name.empty())
dialog_->filenameED->setText(toqstr(name));
filenameED->setText(toqstr(name));
}
void GuiInclude::edit()
void GuiIncludeDialog::edit()
{
if (isValid()) {
string const file = fromqstr(dialog_->filenameED->text());
string const file = fromqstr(filenameED->text());
slotOK();
controller().edit(file);
}
}
bool GuiInclude::isValid()
bool GuiIncludeDialog::isValid()
{
return !dialog_->filenameED->text().isEmpty() &&
dialog_->validate_listings_params().empty();
return !filenameED->text().isEmpty() &&
validate_listings_params().empty();
}
} // namespace frontend

View File

@ -12,71 +12,51 @@
#ifndef GUIINCLUDE_H
#define GUIINCLUDE_H
#include "GuiDialogView.h"
#include "GuiDialog.h"
#include "ControlInclude.h"
#include "ui_IncludeUi.h"
#include <QDialog>
namespace lyx {
namespace frontend {
class GuiInclude;
class GuiIncludeDialog : public QDialog, public Ui::IncludeUi {
class GuiIncludeDialog : public GuiDialog, public Ui::IncludeUi
{
Q_OBJECT
public:
GuiIncludeDialog(GuiInclude * form);
GuiIncludeDialog(LyXView & lv);
void updateLists();
virtual void showView();
/// 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);
private Q_SLOTS:
void change_adaptor();
void editClicked();
void browseClicked();
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 GuiInclude : public GuiView<GuiIncludeDialog>
{
public:
///
friend class GuiIncludeDialog;
///
GuiInclude(GuiDialog &);
/// parent controller
ControlInclude & controller()
{ return static_cast<ControlInclude &>(this->getController()); }
/// parent controller
ControlInclude const & controller() const
{ return static_cast<ControlInclude const &>(this->getController()); }
protected:
virtual bool isValid();
private:
void closeEvent(QCloseEvent * e);
/// parent controller
ControlInclude & controller() const;
///
void updateLists();
///
void showView();
/// validate listings parameters and return an error message, if any
docstring validate_listings_params();
///
bool isValid();
/// Apply changes
virtual void applyView();
void applyView();
/// update
virtual void update_contents();
/// build the dialog
virtual void build_dialog();
void update_contents();
/// 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();
};

View File

@ -12,6 +12,8 @@
#include "GuiIndex.h"
#include "ControlCommand.h"
#include "debug.h"
#include "qt_helpers.h"
@ -20,30 +22,30 @@
#include <QLineEdit>
#include <QCloseEvent>
using std::string;
/////////////////////////////////////////////////////////////////////
//
// GuiIndexDialog
//
/////////////////////////////////////////////////////////////////////
namespace lyx {
namespace frontend {
GuiIndexDialog::GuiIndexDialog(GuiIndex * form)
: form_(form)
GuiIndexDialogBase::GuiIndexDialogBase(LyXView & lv,
docstring const & title, QString const & label)
: GuiDialog(lv, "index")
{
label_ = label;
setupUi(this);
setViewTitle(title);
setController(new ControlCommand(*this, "index", "index"));
connect(okPB, SIGNAL(clicked()), form, SLOT(slotOK()));
connect(closePB, SIGNAL(clicked()), form, SLOT(slotClose()));
connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
connect(keywordED, SIGNAL(textChanged(const QString &)),
this, SLOT(change_adaptor()));
setFocusProxy(keywordED);
keywordLA->setText(label_);
keywordED->setWhatsThis( qt_(
"The format of the entry in the index.\n"
"\n"
@ -59,72 +61,56 @@ GuiIndexDialog::GuiIndexDialog(GuiIndex * form)
"For further details refer to the local LaTeX\n"
"documentation.\n")
);
bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
bc().setOK(okPB);
bc().setCancel(closePB);
bc().addReadOnly(keywordED);
}
void GuiIndexDialog::change_adaptor()
ControlCommand & GuiIndexDialogBase::controller() const
{
form_->changed();
return static_cast<ControlCommand &>(Dialog::controller());
}
void GuiIndexDialog::reject()
void GuiIndexDialogBase::change_adaptor()
{
form_->slotClose();
changed();
}
void GuiIndexDialog::closeEvent(QCloseEvent * e)
void GuiIndexDialogBase::reject()
{
form_->slotWMHide();
slotClose();
}
void GuiIndexDialogBase::closeEvent(QCloseEvent * e)
{
slotWMHide();
e->accept();
}
/////////////////////////////////////////////////////////////////////
//
// GuiIndex
//
/////////////////////////////////////////////////////////////////////
GuiIndex::GuiIndex(GuiDialog & parent, docstring const & title,
QString const & label)
: GuiView<GuiIndexDialog>(parent, title), label_(label)
{
}
void GuiIndex::build_dialog()
{
dialog_.reset(new GuiIndexDialog(this));
dialog_->keywordLA->setText(label_);
bc().setOK(dialog_->okPB);
bc().setCancel(dialog_->closePB);
bc().addReadOnly(dialog_->keywordED);
}
void GuiIndex::update_contents()
void GuiIndexDialogBase::update_contents()
{
docstring const contents = controller().params()["name"];
dialog_->keywordED->setText(toqstr(contents));
keywordED->setText(toqstr(contents));
bc().setValid(!contents.empty());
}
void GuiIndex::applyView()
void GuiIndexDialogBase::applyView()
{
controller().params()["name"] = qstring_to_ucs4(dialog_->keywordED->text());
controller().params()["name"] = qstring_to_ucs4(keywordED->text());
}
bool GuiIndex::isValid()
bool GuiIndexDialogBase::isValid()
{
return !dialog_->keywordED->text().isEmpty();
return !keywordED->text().isEmpty();
}
} // namespace frontend

View File

@ -13,56 +13,57 @@
#ifndef GUIINDEX_H
#define GUIINDEX_H
#include "GuiDialogView.h"
#include "GuiDialog.h"
#include "ControlCommand.h"
#include "ui_IndexUi.h"
#include <QDialog>
namespace lyx {
namespace frontend {
class GuiIndex;
class GuiIndexDialog : public QDialog, public Ui::IndexUi {
class GuiIndexDialogBase : public GuiDialog, 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);
public:
GuiIndexDialogBase(LyXView & lv, docstring const & title,
QString const & label);
private Q_SLOTS:
void change_adaptor();
void reject();
private:
GuiIndex * form_;
///
void closeEvent(QCloseEvent * e);
/// parent controller
ControlCommand & controller() const;
///
bool isValid();
/// Apply changes
void applyView();
/// update
void update_contents();
///
QString label_;
};
class GuiIndex : public GuiView<GuiIndexDialog>
class GuiIndexDialog : public GuiIndexDialogBase
{
public:
friend class GuiIndexDialog;
GuiIndexDialog(LyXView & lv)
: GuiIndexDialogBase(lv, _("Index Entry"), qt_("&Keyword:"))
{}
};
GuiIndex(GuiDialog &, docstring const & title, QString const & label);
/// parent controller
ControlCommand & controller()
{ return static_cast<ControlCommand &>(this->getController()); }
/// parent controller
ControlCommand const & controller() const
{ return static_cast<ControlCommand const &>(this->getController()); }
protected:
virtual bool isValid();
private:
/// Apply changes
virtual void applyView();
/// update
virtual void update_contents();
/// build the dialog
virtual void build_dialog();
///
QString const label_;
class GuiLabelDialog : public GuiIndexDialogBase
{
public:
GuiLabelDialog(LyXView & lv)
: GuiIndexDialogBase(lv, _("Label"), qt_("&Label:"))
{}
};
} // namespace frontend

View File

@ -26,7 +26,8 @@ namespace lyx {
*
* This is some really sick stuff.
*/
class GuiKeySymbol : public KeySymbol {
class GuiKeySymbol : public KeySymbol
{
public:
GuiKeySymbol();

View File

@ -12,6 +12,8 @@
#include <config.h>
#include "GuiListings.h"
#include "ControlListings.h"
#include "qt_helpers.h"
#include "insets/InsetListingsParams.h"
#include "debug.h"
@ -161,36 +163,58 @@ char const * font_styles_gui[] =
GuiListingsDialog::GuiListingsDialog(GuiListings * form)
: form_(form)
GuiListingsDialog::GuiListingsDialog(LyXView & lv)
: GuiDialog(lv, "listings")
{
setupUi(this);
setViewTitle(_("Program Listing Settings"));
setController(new ControlListings(*this));
connect(okPB, SIGNAL(clicked()), form, SLOT(slotOK()));
connect(applyPB, SIGNAL(clicked()), form_, SLOT(slotApply()));
connect(closePB, SIGNAL(clicked()), form, SLOT(slotClose()));
connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
connect(applyPB, SIGNAL(clicked()), this, SLOT(slotApply()));
connect(closePB, SIGNAL(clicked()), this, 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(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()));
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]));
@ -209,19 +233,34 @@ GuiListingsDialog::GuiListingsDialog(GuiListings * form)
firstlineLE->setValidator(new QIntValidator(0, 1000000, this));
lastlineLE->setValidator(new QIntValidator(0, 1000000, this));
placementLE->setValidator(new QRegExpValidator(QRegExp("[\\*tbph]*"), this));
bc().setOK(okPB);
bc().setApply(applyPB);
bc().setCancel(closePB);
listingsTB->setPlainText(
qt_("Input listing parameters on the right. Enter ? for a list of parameters."));
update_contents();
}
ControlListings & GuiListingsDialog::controller() const
{
return static_cast<ControlListings &>(Dialog::controller());
}
void GuiListingsDialog::closeEvent(QCloseEvent * e)
{
form_->slotWMHide();
slotWMHide();
e->accept();
}
void GuiListingsDialog::change_adaptor()
{
form_->changed();
changed();
}
@ -400,45 +439,16 @@ void GuiListingsDialog::on_languageCO_currentIndexChanged(int index)
}
/////////////////////////////////////////////////////////////////////
//
// GuiListings
//
/////////////////////////////////////////////////////////////////////
GuiListings::GuiListings(GuiDialog & parent)
: GuiView<GuiListingsDialog>(parent, _("Program Listing Settings"))
{
}
void GuiListings::build_dialog()
{
dialog_.reset(new GuiListingsDialog(this));
bc().setOK(dialog_->okPB);
bc().setApply(dialog_->applyPB);
bc().setCancel(dialog_->closePB);
dialog_->listingsTB->setPlainText(
qt_("Input listing parameters on the right. Enter ? for a list of parameters."));
update_contents();
}
void GuiListings::applyView()
void GuiListingsDialog::applyView()
{
InsetListingsParams & params = controller().params();
params.setInline(dialog_->inlineCB->isChecked());
params.setParams(dialog_->construct_params());
params.setInline(inlineCB->isChecked());
params.setParams(construct_params());
controller().setParams(params);
}
namespace {
string plainParam(std::string const & par)
static string plainParam(std::string const & par)
{
// remove enclosing braces
if (prefixIs(par, "{") && suffixIs(par, "}"))
@ -446,36 +456,34 @@ string plainParam(std::string const & par)
return par;
}
} //namespace anon
void GuiListings::update_contents()
void GuiListingsDialog::update_contents()
{
// set default values
dialog_->listingsTB->setPlainText(
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);
languageCO->setCurrentIndex(findToken(languages, "no language"));
dialectCO->setCurrentIndex(0);
floatCB->setChecked(false);
placementLE->clear();
numberSideCO->setCurrentIndex(0);
numberStepLE->clear();
numberFontSizeCO->setCurrentIndex(findToken(font_sizes, "default"));
firstlineLE->clear();
lastlineLE->clear();
fontstyleCO->setCurrentIndex(findToken(font_styles, "default"));
fontsizeCO->setCurrentIndex(findToken(font_sizes, "default"));
breaklinesCB->setChecked(false);
spaceCB->setChecked(false);
spaceInStringCB->setChecked(true);
extendedcharsCB->setChecked(false);
// set values from param string
InsetListingsParams & params = controller().params();
dialog_->inlineCB->setChecked(params.isInline());
inlineCB->setChecked(params.isInline());
if (params.isInline()) {
dialog_->floatCB->setChecked(false);
dialog_->placementLE->setEnabled(false);
floatCB->setChecked(false);
placementLE->setEnabled(false);
}
// break other parameters and set values
vector<string> pars = getVectorFromString(params.separatedParams(), "\n");
@ -496,7 +504,7 @@ void GuiListings::update_contents()
language = arg;
int n = findToken(languages, language);
if (n >= 0) {
dialog_->languageCO->setCurrentIndex(n);
languageCO->setCurrentIndex(n);
in_gui = true;
}
// on_languageCO_currentIndexChanged should have set dialects
@ -509,23 +517,23 @@ void GuiListings::update_contents()
break;
}
}
n = dialog_->dialectCO->findText(qt_(dialect_gui));
n = dialectCO->findText(qt_(dialect_gui));
if (n >= 0)
dialog_->dialectCO->setCurrentIndex(n);
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);
languageCO->setEnabled(in_gui);
dialectCO->setEnabled(
in_gui && dialectCO->count() > 1);
} else if (prefixIs(*it, "float")) {
dialog_->floatCB->setChecked(true);
dialog_->inlineCB->setChecked(false);
dialog_->placementLE->setEnabled(true);
floatCB->setChecked(true);
inlineCB->setChecked(false);
placementLE->setEnabled(true);
if (prefixIs(*it, "float="))
dialog_->placementLE->setText(
placementLE->setText(
toqstr(plainParam(it->substr(6))));
*it = "";
} else if (prefixIs(*it, "numbers=")) {
@ -535,24 +543,24 @@ void GuiListings::update_contents()
n = 1;
else if (s == "right")
n = 2;
dialog_->numberSideCO->setCurrentIndex(n);
numberSideCO->setCurrentIndex(n);
*it = "";
} else if (prefixIs(*it, "stepnumber=")) {
dialog_->numberStepLE->setText(
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);
numberFontSizeCO->setCurrentIndex(n);
*it = "";
} else if (prefixIs(*it, "firstline=")) {
dialog_->firstlineLE->setText(
firstlineLE->setText(
toqstr(plainParam(it->substr(10))));
*it = "";
} else if (prefixIs(*it, "lastline=")) {
dialog_->lastlineLE->setText(
lastlineLE->setText(
toqstr(plainParam(it->substr(9))));
*it = "";
} else if (prefixIs(*it, "basicstyle=")) {
@ -577,42 +585,42 @@ void GuiListings::update_contents()
if (!style.empty()) {
int n = findToken(font_styles, style.substr(1));
if (n >= 0)
dialog_->fontstyleCO->setCurrentIndex(n);
fontstyleCO->setCurrentIndex(n);
}
if (!size.empty()) {
int n = findToken(font_sizes, size.substr(1));
if (n >= 0)
dialog_->fontsizeCO->setCurrentIndex(n);
fontsizeCO->setCurrentIndex(n);
}
*it = "";
}
} else if (prefixIs(*it, "breaklines=")) {
dialog_->breaklinesCB->setChecked(contains(*it, "true"));
breaklinesCB->setChecked(contains(*it, "true"));
*it = "";
} else if (prefixIs(*it, "showspaces=")) {
dialog_->spaceCB->setChecked(contains(*it, "true"));
spaceCB->setChecked(contains(*it, "true"));
*it = "";
} else if (prefixIs(*it, "showstringspaces=")) {
dialog_->spaceInStringCB->setChecked(contains(*it, "true"));
spaceInStringCB->setChecked(contains(*it, "true"));
*it = "";
} else if (prefixIs(*it, "extendedchars=")) {
dialog_->extendedcharsCB->setChecked(contains(*it, "true"));
extendedcharsCB->setChecked(contains(*it, "true"));
*it = "";
}
}
dialog_->numberStepLE->setEnabled(dialog_->numberSideCO->currentIndex() > 0);
dialog_->numberFontSizeCO->setEnabled(dialog_->numberSideCO->currentIndex() > 0);
numberStepLE->setEnabled(numberSideCO->currentIndex() > 0);
numberFontSizeCO->setEnabled(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()));
listingsED->setPlainText(toqstr(InsetListingsParams(extra).separatedParams()));
}
bool GuiListings::isValid()
bool GuiListingsDialog::isValid()
{
return dialog_->validate_listings_params().empty();
return validate_listings_params().empty();
}

View File

@ -12,27 +12,24 @@
#ifndef GUILISTINGS_H
#define GUILISTINGS_H
#include "GuiDialogView.h"
#include "GuiDialog.h"
#include "ControlListings.h"
#include "ui_ListingsUi.h"
#include <QDialog>
namespace lyx {
namespace frontend {
class GuiListings;
class GuiListingsDialog : public QDialog, public Ui::ListingsUi {
class GuiListingsDialog : public GuiDialog, public Ui::ListingsUi
{
Q_OBJECT
public:
GuiListingsDialog(GuiListings * form);
GuiListingsDialog(LyXView & lv);
/// 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();
private Q_SLOTS:
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
@ -46,34 +43,16 @@ protected Q_SLOTS:
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 GuiListings : public GuiView<GuiListingsDialog> {
public:
friend class GuiListingsDialog;
GuiListings(GuiDialog &);
void closeEvent(QCloseEvent * e);
/// parent controller
ControlListings & controller()
{ return static_cast<ControlListings &>(this->getController()); }
/// parent controller
ControlListings const & controller() const
{ return static_cast<ControlListings const &>(this->getController()); }
private:
/// Apply changes
virtual void applyView();
/// update
virtual void update_contents();
/// build the dialog
virtual void build_dialog();
protected:
ControlListings & controller() const;
/// return false if validate_listings_params returns error
virtual bool isValid();
bool isValid();
/// Apply changes
void applyView();
/// update
void update_contents();
};
} // namespace frontend

View File

@ -10,57 +10,45 @@
#include <config.h>
#include <sstream>
#include "GuiLog.h"
#include "ControlLog.h"
#include "qt_helpers.h"
#include "frontends/Application.h"
#include <QCloseEvent>
#include <QTextBrowser>
#include <QTextBrowser>
#include <QSyntaxHighlighter>
#include <sstream>
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
//
/////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////
class LogHighlighter : public QSyntaxHighlighter
{
public:
LogHighlighter(QTextDocument * parent);
private:
void highlightBlock(QString const & text);
private:
QTextCharFormat infoFormat;
QTextCharFormat warningFormat;
QTextCharFormat errorFormat;
};
LogHighlighter::LogHighlighter(QTextDocument * parent)
: QSyntaxHighlighter(parent)
@ -106,35 +94,56 @@ void LogHighlighter::highlightBlock(QString const & text)
//
/////////////////////////////////////////////////////////////////////
GuiLog::GuiLog(GuiDialog & parent)
: GuiView<GuiLogDialog>(parent, docstring())
{}
void GuiLog::build_dialog()
GuiLogDialog::GuiLogDialog(LyXView & lv)
: GuiDialog(lv, "log")
{
dialog_.reset(new GuiLogDialog(this));
setupUi(this);
setController(new ControlLog(*this));
connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
connect(updatePB, SIGNAL(clicked()), this, SLOT(updateClicked()));
bc().setPolicy(ButtonPolicy::OkCancelPolicy);
// set syntax highlighting
highlighter = new LogHighlighter(dialog_->logTB->document());
//
dialog_->logTB->setReadOnly(true);
highlighter = new LogHighlighter(logTB->document());
logTB->setReadOnly(true);
QFont font(toqstr(theApp()->typewriterFontName()));
font.setKerning(false);
font.setFixedPitch(true);
font.setStyleHint(QFont::TypeWriter);
dialog_->logTB->setFont(font);
logTB->setFont(font);
}
void GuiLog::update_contents()
ControlLog & GuiLogDialog::controller() const
{
return static_cast<ControlLog &>(Dialog::controller());
}
void GuiLogDialog::closeEvent(QCloseEvent * e)
{
slotWMHide();
e->accept();
}
void GuiLogDialog::updateClicked()
{
update_contents();
}
void GuiLogDialog::update_contents()
{
setViewTitle(controller().title());
std::ostringstream ss;
controller().getContents(ss);
dialog_->logTB->setPlainText(toqstr(ss.str()));
logTB->setPlainText(toqstr(ss.str()));
}
} // namespace frontend

View File

@ -12,76 +12,36 @@
#ifndef GUILOG_H
#define GUILOG_H
#include "GuiDialogView.h"
#include "GuiDialog.h"
#include "ControlLog.h"
#include "ui_LogUi.h"
#include <QDialog>
#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 GuiView<GuiLogDialog>
class GuiLogDialog : public GuiDialog, public Ui::LogUi
{
Q_OBJECT
public:
///
friend class GuiLogDialog;
///
GuiLog(GuiDialog &);
/// parent controller
ControlLog & controller()
{ return static_cast<ControlLog &>(this->getController()); }
/// parent controller
ControlLog const & controller() const
{ return static_cast<ControlLog const &>(this->getController()); }
GuiLogDialog(LyXView & lv);
private Q_SLOTS:
void updateClicked();
private:
void closeEvent(QCloseEvent * e);
/// parent controller
ControlLog & controller() const;
/// Apply changes
virtual void applyView() {}
void applyView() {}
/// update
virtual void update_contents();
/// build the dialog
virtual void build_dialog();
void update_contents();
/// 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

View File

@ -12,6 +12,7 @@
#include "GuiMathMatrix.h"
#include "ControlMath.h"
#include "EmptyTable.h"
#include "qt_helpers.h"
#include "gettext.h"
@ -28,21 +29,12 @@ using std::string;
namespace lyx {
namespace frontend {
GuiMathMatrix::GuiMathMatrix(GuiDialog & parent)
: GuiView<GuiMathMatrixDialog>(parent, _("Math Matrix"))
{}
void GuiMathMatrix::build_dialog()
{
dialog_.reset(new GuiMathMatrixDialog(this));
}
GuiMathMatrixDialog::GuiMathMatrixDialog(GuiMathMatrix * form)
: form_(form)
GuiMathMatrixDialog::GuiMathMatrixDialog(LyXView & lv)
: GuiDialog(lv, "mathmatrix")
{
setupUi(this);
setViewTitle(_("Math Matrix"));
setController(new ControlMath(*this));
setWindowTitle(qt_("LyX: Insert Matrix"));
@ -70,6 +62,14 @@ GuiMathMatrixDialog::GuiMathMatrixDialog(GuiMathMatrix * form)
this, SLOT(change_adaptor()));
connect(halignED, SIGNAL(textChanged(const QString&)),
this, SLOT(change_adaptor()));
bc().setPolicy(ButtonPolicy::IgnorantPolicy);
}
ControlMath & GuiMathMatrixDialog::controller() const
{
return static_cast<ControlMath &>(Dialog::controller());
}
@ -106,7 +106,7 @@ void GuiMathMatrixDialog::slotOK()
ostringstream os;
os << nx << ' ' << ny << ' ' << c << ' ' << sh;
form_->controller().dispatchMatrix(os.str().c_str());
controller().dispatchMatrix(os.str().c_str());
// close the dialog
close();

View File

@ -14,7 +14,7 @@
#ifndef GUIMATHMATRIXDIALOG_H
#define GUIMATHMATRIXDIALOG_H
#include "GuiDialogView.h"
#include "GuiDialog.h"
#include "ControlMath.h"
#include "ui_MathMatrixUi.h"
@ -23,45 +23,24 @@
namespace lyx {
namespace frontend {
class GuiMathMatrix;
class ControlMath;
class GuiMathMatrixDialog : public QDialog, public Ui::MathMatrixUi {
class GuiMathMatrixDialog : public GuiDialog, public Ui::MathMatrixUi
{
Q_OBJECT
public:
GuiMathMatrixDialog(GuiMathMatrix * form);
GuiMathMatrixDialog(LyXView & lv);
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_;
};
void columnsChanged(int);
void rowsChanged(int);
void change_adaptor();
class GuiMathMatrix : public GuiView<GuiMathMatrixDialog> {
public:
friend class GuiMathMatrixDialog;
GuiMathMatrix(GuiDialog &);
/// parent controller
ControlMath & controller()
{ return static_cast<ControlMath &>(this->getController()); }
/// parent controller
ControlMath const & controller() const
{ return static_cast<ControlMath const &>(this->getController()); }
private:
virtual void applyView() {}
virtual void update_contents() {}
/// Build the dialog.
virtual void build_dialog();
ControlMath & controller() const;
};
} // namespace frontend
} // namespace lyx

View File

@ -32,7 +32,8 @@ namespace frontend {
class GuiViewBase;
class LyXView;
class GuiMenubar : public QObject {
class GuiMenubar : public QObject
{
Q_OBJECT
public:
GuiMenubar(LyXView *, MenuBackend &);

View File

@ -29,25 +29,33 @@ using std::string;
namespace lyx {
namespace frontend {
/////////////////////////////////////////////////////////////////////
//
// GuiNomenclDialog
//
/////////////////////////////////////////////////////////////////////
GuiNomenclDialog::GuiNomenclDialog(GuiNomencl * form)
: form_(form)
GuiNomenclDialog::GuiNomenclDialog(LyXView & lv)
: GuiDialog(lv, "nomenclature")
{
setupUi(this);
setController(new ControlCommand(*this, "nomenclature", "nomenclature"));
connect(okPB, SIGNAL(clicked()), form, SLOT(slotOK()));
connect(closePB, SIGNAL(clicked()), form, SLOT(slotClose()));
connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
connect(symbolED, SIGNAL(textChanged(const QString&)),
this, SLOT(change_adaptor()));
connect(descriptionTE, SIGNAL(textChanged()),
this, SLOT(change_adaptor()));
setFocusProxy(descriptionTE);
bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
bc().setOK(okPB);
bc().setCancel(closePB);
bc().addReadOnly(symbolED);
bc().addReadOnly(descriptionTE);
bc().addReadOnly(prefixED);
}
ControlCommand & GuiNomenclDialog::controller() const
{
return static_cast<ControlCommand &>(Dialog::controller());
}
@ -59,74 +67,49 @@ void GuiNomenclDialog::showView()
void GuiNomenclDialog::change_adaptor()
{
form_->changed();
changed();
}
void GuiNomenclDialog::reject()
{
form_->slotClose();
slotClose();
}
void GuiNomenclDialog::closeEvent(QCloseEvent * e)
{
form_->slotWMHide();
slotWMHide();
e->accept();
}
/////////////////////////////////////////////////////////////////////
//
// GuiNomencl
//
/////////////////////////////////////////////////////////////////////
GuiNomencl::GuiNomencl(GuiDialog & parent, docstring const & title)
: GuiView<GuiNomenclDialog>(parent, title)
void GuiNomenclDialog::update_contents()
{
}
void GuiNomencl::build_dialog()
{
dialog_.reset(new GuiNomenclDialog(this));
bc().setOK(dialog_->okPB);
bc().setCancel(dialog_->closePB);
bc().addReadOnly(dialog_->symbolED);
bc().addReadOnly(dialog_->descriptionTE);
bc().addReadOnly(dialog_->prefixED);
}
void GuiNomencl::update_contents()
{
dialog_->prefixED->setText(toqstr(controller().params()["prefix"]));
dialog_->symbolED->setText(toqstr(controller().params()["symbol"]));
prefixED->setText(toqstr(controller().params()["prefix"]));
symbolED->setText(toqstr(controller().params()["symbol"]));
QString description = toqstr(controller().params()["description"]);
description.replace("\\\\","\n");
dialog_->descriptionTE->setPlainText(description);
descriptionTE->setPlainText(description);
bc().setValid(isValid());
}
void GuiNomencl::applyView()
void GuiNomenclDialog::applyView()
{
controller().params()["prefix"] = qstring_to_ucs4(dialog_->prefixED->text());
controller().params()["symbol"] = qstring_to_ucs4(dialog_->symbolED->text());
QString description = dialog_->descriptionTE->toPlainText();
controller().params()["prefix"] = qstring_to_ucs4(prefixED->text());
controller().params()["symbol"] = qstring_to_ucs4(symbolED->text());
QString description = descriptionTE->toPlainText();
description.replace('\n',"\\\\");
controller().params()["description"] = qstring_to_ucs4(description);
}
bool GuiNomencl::isValid()
bool GuiNomenclDialog::isValid()
{
QString const description = dialog_->descriptionTE->toPlainText();
return !dialog_->symbolED->text().isEmpty() && !description.isEmpty();
QString const description = descriptionTE->toPlainText();
return !symbolED->text().isEmpty() && !description.isEmpty();
}
} // namespace frontend

View File

@ -14,55 +14,37 @@
#ifndef GUINOMENCL_H
#define GUINOMENCL_H
#include "GuiDialogView.h"
#include "GuiDialog.h"
#include "ControlCommand.h"
#include "ui_NomenclUi.h"
#include <QDialog>
namespace lyx {
namespace frontend {
class GuiNomencl;
class GuiNomenclDialog : public QDialog, public Ui::NomenclUi
class GuiNomenclDialog : public GuiDialog, public Ui::NomenclUi
{
Q_OBJECT
public:
GuiNomenclDialog(GuiNomencl * form);
virtual void showView();
protected Q_SLOTS:
virtual void change_adaptor();
virtual void reject();
protected:
virtual void closeEvent(QCloseEvent * e);
GuiNomenclDialog(LyXView & lv);
private Q_SLOTS:
void change_adaptor();
void reject();
private:
GuiNomencl * form_;
};
class GuiNomencl : public GuiView<GuiNomenclDialog>
{
public:
friend class GuiNomenclDialog;
GuiNomencl(GuiDialog &, docstring const & title);
///
void showView();
///
void closeEvent(QCloseEvent * e);
/// parent controller
ControlCommand & controller()
{ return static_cast<ControlCommand &>(this->getController()); }
/// parent controller
ControlCommand const & controller() const
{ return static_cast<ControlCommand const &>(this->getController()); }
protected:
virtual bool isValid();
private:
ControlCommand & controller() const;
///
bool isValid();
/// Apply changes
virtual void applyView();
void applyView();
/// update
virtual void update_contents();
/// build the dialog
virtual void build_dialog();
void update_contents();
};
} // namespace frontend

View File

@ -12,6 +12,7 @@
#include "GuiNote.h"
#include "ControlNote.h"
#include "insets/InsetNote.h"
#include <QCloseEvent>
@ -19,81 +20,66 @@
namespace lyx {
namespace frontend {
/////////////////////////////////////////////////////////////////////
//
// GuiNoteDialog
//
/////////////////////////////////////////////////////////////////////
GuiNoteDialog::GuiNoteDialog(GuiNote * form)
: form_(form)
GuiNoteDialog::GuiNoteDialog(LyXView & lv)
: GuiDialog(lv, "note")
{
setupUi(this);
setController(new ControlNote(*this));
setViewTitle(_("Note Settings"));
connect(okPB, SIGNAL(clicked()), form, SLOT(slotOK()));
connect(closePB, SIGNAL(clicked()), form, SLOT(slotClose()));
connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
connect(closePB, SIGNAL(clicked()), this, 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()));
bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
bc().setOK(okPB);
bc().setCancel(closePB);
}
ControlNote & GuiNoteDialog::controller() const
{
return static_cast<ControlNote &>(Dialog::controller());
}
void GuiNoteDialog::closeEvent(QCloseEvent * e)
{
form_->slotWMHide();
slotWMHide();
e->accept();
}
void GuiNoteDialog::change_adaptor()
{
form_->changed();
changed();
}
/////////////////////////////////////////////////////////////////////
//
// GuiNote
//
/////////////////////////////////////////////////////////////////////
GuiNote::GuiNote(GuiDialog & parent)
: GuiView<GuiNoteDialog>(parent, _("Note Settings"))
{}
void GuiNote::build_dialog()
{
dialog_.reset(new GuiNoteDialog(this));
bc().setOK(dialog_->okPB);
bc().setCancel(dialog_->closePB);
}
void GuiNote::update_contents()
void GuiNoteDialog::update_contents()
{
QRadioButton * rb = 0;
switch (controller().params().type) {
case InsetNoteParams::Note:
rb = dialog_->noteRB;
rb = noteRB;
break;
case InsetNoteParams::Comment:
rb = dialog_->commentRB;
rb = commentRB;
break;
case InsetNoteParams::Greyedout:
rb = dialog_->greyedoutRB;
rb = greyedoutRB;
break;
case InsetNoteParams::Framed:
rb = dialog_->framedRB;
rb = framedRB;
break;
case InsetNoteParams::Shaded:
rb = dialog_->shadedRB;
rb = shadedRB;
break;
}
@ -101,17 +87,17 @@ void GuiNote::update_contents()
}
void GuiNote::applyView()
void GuiNoteDialog::applyView()
{
InsetNoteParams::Type type;
if (dialog_->greyedoutRB->isChecked())
if (greyedoutRB->isChecked())
type = InsetNoteParams::Greyedout;
else if (dialog_->commentRB->isChecked())
else if (commentRB->isChecked())
type = InsetNoteParams::Comment;
else if (dialog_->framedRB->isChecked())
else if (framedRB->isChecked())
type = InsetNoteParams::Framed;
else if (dialog_->shadedRB->isChecked())
else if (shadedRB->isChecked())
type = InsetNoteParams::Shaded;
else
type = InsetNoteParams::Note;

View File

@ -12,53 +12,28 @@
#ifndef GUINOTE_H
#define GUINOTE_H
#include "GuiDialogView.h"
#include "GuiDialog.h"
#include "ControlNote.h"
#include "ui_NoteUi.h"
#include <QDialog>
namespace lyx {
namespace frontend {
class GuiNote;
class GuiNoteDialog : public QDialog, public Ui::NoteUi {
class GuiNoteDialog : public GuiDialog, public Ui::NoteUi
{
Q_OBJECT
public:
GuiNoteDialog(GuiNote * form);
protected Q_SLOTS:
virtual void change_adaptor();
protected:
virtual void closeEvent(QCloseEvent * e);
GuiNoteDialog(LyXView & lv);
private Q_SLOTS:
void change_adaptor();
private:
GuiNote * form_;
};
/** This class provides a QT implementation of the Note Dialog.
*/
class GuiNote : public GuiView<GuiNoteDialog>
{
public:
friend class GuiNoteDialog;
/// Constructor
GuiNote(GuiDialog &);
void closeEvent(QCloseEvent * e);
/// parent controller
ControlNote & controller()
{ return static_cast<ControlNote &>(this->getController()); }
/// parent controller
ControlNote const & controller() const
{ return static_cast<ControlNote const &>(this->getController()); }
private:
/// Apply changes
virtual void applyView();
/// Build the dialog
virtual void build_dialog();
ControlNote & controller() const;
/// Apply changes
void applyView();
/// Update dialog before showing it
virtual void update_contents();
void update_contents();
};
} // namespace frontend

View File

@ -13,6 +13,8 @@
#include "GuiParagraph.h"
#include "ControlParagraph.h"
#include "debug.h"
#include "frontend_helpers.h"
#include "ParagraphParameters.h"
@ -24,30 +26,25 @@
#include <QLineEdit>
#include <QPushButton>
#include <boost/current_function.hpp>
using std::string;
using std::endl;
/////////////////////////////////////////////////////////////////////
//
// GuiParagraphDialog
//
/////////////////////////////////////////////////////////////////////
#include <boost/current_function.hpp>
namespace lyx {
namespace frontend {
GuiParagraphDialog::GuiParagraphDialog(GuiParagraph * form)
: form_(form)
GuiParagraphDialog::GuiParagraphDialog(LyXView & lv)
: GuiDialog(lv, "paragraph")
{
setupUi(this);
setViewTitle(_("Paragraph Settings"));
setController(new ControlParagraph(*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(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
connect(applyPB, SIGNAL(clicked()), this, SLOT(slotApply()));
connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
connect(restorePB, SIGNAL(clicked()), this, SLOT(slotRestore()));
connect(alignDefaultRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
connect(alignJustRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
connect(alignLeftRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
@ -86,19 +83,31 @@ GuiParagraphDialog::GuiParagraphDialog(GuiParagraph * form)
labelMap[LYX_ALIGN_LEFT] = _("Left");
labelMap[LYX_ALIGN_RIGHT] = _("Right");
labelMap[LYX_ALIGN_CENTER] = _("Center");
bc().setPolicy(ButtonPolicy::OkApplyCancelReadOnlyPolicy);
bc().setOK(okPB);
bc().setApply(applyPB);
bc().setCancel(closePB);
bc().setRestore(restorePB);
}
ControlParagraph & GuiParagraphDialog::controller() const
{
return static_cast<ControlParagraph &>(Dialog::controller());
}
void GuiParagraphDialog::closeEvent(QCloseEvent * e)
{
form_->slotWMHide();
slotWMHide();
e->accept();
}
void GuiParagraphDialog::change_adaptor()
{
form_->changed();
changed();
}
@ -110,23 +119,23 @@ void GuiParagraphDialog::enableLinespacingValue(int)
void GuiParagraphDialog::checkAlignmentRadioButtons() {
LyXAlignment const alignPossible = form_->controller().alignPossible();
LyXAlignment const alignPossible = controller().alignPossible();
QPRadioMap::iterator it = radioMap.begin();
RadioMap::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()] + ")");
if (!controller().haveMulitParSelection())
label += (" (" + labelMap[controller().alignDefault()] + ")");
alignDefaultRB->setText(toqstr(label));
}
void GuiParagraphDialog::alignmentToRadioButtons(LyXAlignment align)
{
QPRadioMap::const_iterator it = radioMap.begin();
RadioMap::const_iterator it = radioMap.begin();
for (;it != radioMap.end(); ++it) {
if (align == it->first) {
it->second->blockSignals(true);
@ -144,7 +153,7 @@ void GuiParagraphDialog::alignmentToRadioButtons(LyXAlignment align)
LyXAlignment GuiParagraphDialog::getAlignmentFromDialog()
{
LyXAlignment alignment = LYX_ALIGN_NONE;
QPRadioMap::const_iterator it = radioMap.begin();
RadioMap::const_iterator it = radioMap.begin();
for (; it != radioMap.end(); ++it) {
if (it->second->isChecked()) {
alignment = it->first;
@ -155,70 +164,45 @@ LyXAlignment GuiParagraphDialog::getAlignmentFromDialog()
}
/////////////////////////////////////////////////////////////////////
//
// GuiParagraph
//
/////////////////////////////////////////////////////////////////////
GuiParagraph::GuiParagraph(GuiDialog & parent)
: GuiView<GuiParagraphDialog>(parent, _("Paragraph Settings"))
{}
void GuiParagraph::build_dialog()
{
// the dialog
dialog_.reset(new GuiParagraphDialog(this));
// Manage the ok, apply, restore and cancel/close buttons
bc().setOK(dialog_->okPB);
bc().setApply(dialog_->applyPB);
bc().setCancel(dialog_->closePB);
bc().setRestore(dialog_->restorePB);
}
void GuiParagraph::applyView()
void GuiParagraphDialog::applyView()
{
ParagraphParameters & params = controller().params();
params.align(dialog_->getAlignmentFromDialog());
params.align(getAlignmentFromDialog());
// get spacing
Spacing::Space linespacing = Spacing::Default;
Spacing::Space ls = Spacing::Default;
string other;
switch (dialog_->linespacing->currentIndex()) {
switch (linespacing->currentIndex()) {
case 0:
linespacing = Spacing::Default;
ls = Spacing::Default;
break;
case 1:
linespacing = Spacing::Single;
ls = Spacing::Single;
break;
case 2:
linespacing = Spacing::Onehalf;
ls = Spacing::Onehalf;
break;
case 3:
linespacing = Spacing::Double;
ls = Spacing::Double;
break;
case 4:
linespacing = Spacing::Other;
other = fromqstr(dialog_->linespacingValue->text());
ls = Spacing::Other;
other = fromqstr(linespacingValue->text());
break;
}
Spacing const spacing(linespacing, other);
Spacing const spacing(ls, other);
params.spacing(spacing);
// label width
params.labelWidthString(qstring_to_ucs4(dialog_->labelWidth->text()));
params.labelWidthString(qstring_to_ucs4(labelWidth->text()));
// indendation
params.noindent(!dialog_->indentCB->isChecked());
params.noindent(!indentCB->isChecked());
}
void GuiParagraph::update_contents()
void GuiParagraphDialog::update_contents()
{
ParagraphParameters const & params = controller().params();
@ -226,49 +210,49 @@ void GuiParagraph::update_contents()
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));
labelwidthGB->setEnabled(true);
labelWidth->setText(toqstr(labelwidth));
} else {
dialog_->labelwidthGB->setEnabled(false);
dialog_->labelWidth->setText("");
labelwidthGB->setEnabled(false);
labelWidth->setText("");
}
// alignment
dialog_->checkAlignmentRadioButtons();
dialog_->alignmentToRadioButtons(params.align());
checkAlignmentRadioButtons();
alignmentToRadioButtons(params.align());
//indentation
bool const canindent = controller().canIndent();
dialog_->indentCB->setEnabled(canindent);
dialog_->indentCB->setChecked(canindent && !params.noindent());
indentCB->setEnabled(canindent);
indentCB->setChecked(canindent && !params.noindent());
// linespacing
int linespacing;
int ls;
Spacing const & space = params.spacing();
switch (space.getSpace()) {
case Spacing::Single:
linespacing = 1;
ls = 1;
break;
case Spacing::Onehalf:
linespacing = 2;
ls = 2;
break;
case Spacing::Double:
linespacing = 3;
ls = 3;
break;
case Spacing::Other:
linespacing = 4;
ls = 4;
break;
default:
linespacing = 0;
ls = 0;
break;
}
dialog_->linespacing->setCurrentIndex(linespacing);
linespacing->setCurrentIndex(ls);
if (space.getSpace() == Spacing::Other) {
dialog_->linespacingValue->setText(toqstr(space.getValueAsString()));
dialog_->linespacingValue->setEnabled(true);
linespacingValue->setText(toqstr(space.getValueAsString()));
linespacingValue->setEnabled(true);
} else {
dialog_->linespacingValue->setText("");
dialog_->linespacingValue->setEnabled(false);
linespacingValue->setText(QString());
linespacingValue->setEnabled(false);
}
}

View File

@ -13,66 +13,48 @@
#ifndef GUIPARAGRAPH_H
#define GUIPARAGRAPH_H
#include "GuiDialogView.h"
#include "GuiDialog.h"
#include "ControlParagraph.h"
#include "Layout.h"
#include "ui_ParagraphUi.h"
#include <QDialog>
#include <map>
namespace lyx {
namespace frontend {
class GuiParagraph;
class GuiParagraphDialog : public QDialog, public Ui::ParagraphUi {
class GuiParagraphDialog : public GuiDialog, public Ui::ParagraphUi
{
Q_OBJECT
public:
GuiParagraphDialog(GuiParagraph * form);
GuiParagraphDialog(LyXView & lv);
///
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;
///
void closeEvent(QCloseEvent * e);
///
typedef std::map<LyXAlignment, QRadioButton *> RadioMap;
RadioMap radioMap;
///
typedef std::map<LyXAlignment, docstring> AlignmentLabels;
AlignmentLabels labelMap;
protected Q_SLOTS:
private Q_SLOTS:
///
void change_adaptor();
///
void enableLinespacingValue(int);
};
class GuiParagraph : public GuiView<GuiParagraphDialog>
{
public:
friend class GuiParagraphDialog;
GuiParagraph(GuiDialog &);
/// parent controller
ControlParagraph & controller()
{ return static_cast<ControlParagraph &>(this->getController()); }
/// parent controller
ControlParagraph const & controller() const
{ return static_cast<ControlParagraph const &>(this->getController()); }
private:
ControlParagraph & controller() const;
/// Apply changes
virtual void applyView();
void applyView();
/// update
virtual void update_contents();
/// build the dialog
virtual void build_dialog();
void update_contents();
};
} // namespace frontend

View File

@ -11,6 +11,7 @@
#include <config.h>
#include "GuiPrefs.h"
#include "ControlPrefs.h"
#include "qt_helpers.h"
#include "GuiApplication.h"
@ -27,8 +28,7 @@
#include "support/lstrings.h"
#include "support/os.h"
#include "controllers/ControlPrefs.h"
#include "controllers/frontend_helpers.h"
#include "frontend_helpers.h"
#include "frontends/alert.h"
#include "frontends/Application.h"
@ -225,7 +225,7 @@ void PrefDate::update(LyXRC const & rc)
//
/////////////////////////////////////////////////////////////////////
PrefKeyboard::PrefKeyboard(GuiPrefs * form, QWidget * parent)
PrefKeyboard::PrefKeyboard(GuiPrefsDialog * form, QWidget * parent)
: PrefModule(_("Keyboard"), form, parent)
{
setupUi(this);
@ -296,7 +296,7 @@ void PrefKeyboard::on_keymapCB_toggled(bool keymap)
//
/////////////////////////////////////////////////////////////////////
PrefLatex::PrefLatex(GuiPrefs * form, QWidget * parent)
PrefLatex::PrefLatex(GuiPrefsDialog * form, QWidget * parent)
: PrefModule(_("LaTeX"), form, parent)
{
setupUi(this);
@ -364,7 +364,7 @@ void PrefLatex::update(LyXRC const & rc)
//
/////////////////////////////////////////////////////////////////////
PrefScreenFonts::PrefScreenFonts(GuiPrefs * form, QWidget * parent)
PrefScreenFonts::PrefScreenFonts(GuiPrefsDialog * form, QWidget * parent)
: PrefModule(_("Screen fonts"), form, parent)
{
setupUi(this);
@ -522,7 +522,7 @@ void PrefScreenFonts::select_typewriter(const QString& name)
//
/////////////////////////////////////////////////////////////////////
PrefColors::PrefColors(GuiPrefs * form, QWidget * parent)
PrefColors::PrefColors(GuiPrefsDialog * form, QWidget * parent)
: PrefModule( _("Colors"), form, parent)
{
setupUi(this);
@ -694,7 +694,7 @@ void PrefDisplay::update(LyXRC const & rc)
//
/////////////////////////////////////////////////////////////////////
PrefPaths::PrefPaths(GuiPrefs * form, QWidget * parent)
PrefPaths::PrefPaths(GuiPrefsDialog * form, QWidget * parent)
: PrefModule(_("Paths"), form, parent)
{
setupUi(this);
@ -798,7 +798,7 @@ void PrefPaths::select_lyxpipe()
//
/////////////////////////////////////////////////////////////////////
PrefSpellchecker::PrefSpellchecker(GuiPrefs * form, QWidget * parent)
PrefSpellchecker::PrefSpellchecker(GuiPrefsDialog * form, QWidget * parent)
: PrefModule(_("Spellchecker"), form, parent)
{
setupUi(this);
@ -908,7 +908,7 @@ void PrefSpellchecker::select_dict()
/////////////////////////////////////////////////////////////////////
PrefConverters::PrefConverters(GuiPrefs * form, QWidget * parent)
PrefConverters::PrefConverters(GuiPrefsDialog * form, QWidget * parent)
: PrefModule(_("Converters"), form, parent)
{
setupUi(this);
@ -1106,7 +1106,7 @@ void PrefConverters::on_cacheCB_stateChanged(int state)
//
/////////////////////////////////////////////////////////////////////
PrefCopiers::PrefCopiers(GuiPrefs * form, QWidget * parent)
PrefCopiers::PrefCopiers(GuiPrefsDialog * form, QWidget * parent)
: PrefModule(_("Copiers"), form, parent)
{
setupUi(this);
@ -1359,7 +1359,7 @@ void PrefCopiers::remove_copier()
//
/////////////////////////////////////////////////////////////////////
PrefFileformats::PrefFileformats(GuiPrefs * form, QWidget * parent)
PrefFileformats::PrefFileformats(GuiPrefsDialog * form, QWidget * parent)
: PrefModule(_("File formats"), form, parent)
{
setupUi(this);
@ -1751,7 +1751,7 @@ void PrefPrinter::update(LyXRC const & rc)
//
/////////////////////////////////////////////////////////////////////
PrefUserInterface::PrefUserInterface(GuiPrefs * form, QWidget * parent)
PrefUserInterface::PrefUserInterface(GuiPrefsDialog * form, QWidget * parent)
: PrefModule(_("User interface"), form, parent)
{
setupUi(this);
@ -1902,43 +1902,46 @@ void PrefIdentity::update(LyXRC const & rc)
//
/////////////////////////////////////////////////////////////////////
GuiPrefsDialog::GuiPrefsDialog(GuiPrefs * form)
: form_(form)
GuiPrefsDialog::GuiPrefsDialog(LyXView & lv)
: GuiDialog(lv, "prefs")
{
setupUi(this);
setViewTitle(_("Preferences"));
setController(new ControlPrefs(*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()));
connect(savePB, SIGNAL(clicked()), this, SLOT(slotOK()));
connect(applyPB, SIGNAL(clicked()), this, SLOT(slotApply()));
connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
connect(restorePB, SIGNAL(clicked()), this, SLOT(slotRestore()));
add(new PrefUserInterface(form_));
add(new PrefScreenFonts(form_));
add(new PrefColors(form_));
add(new PrefUserInterface(this));
add(new PrefScreenFonts(this));
add(new PrefColors(this));
add(new PrefDisplay);
add(new PrefKeyboard(form_));
add(new PrefKeyboard(this));
add(new PrefPaths(form_));
add(new PrefPaths(this));
add(new PrefIdentity);
add(new PrefLanguage);
add(new PrefSpellchecker(form_));
add(new PrefSpellchecker(this));
add(new PrefPrinter);
add(new PrefDate);
add(new PrefPlaintext);
add(new PrefLatex(form_));
add(new PrefLatex(this));
PrefConverters * converters = new PrefConverters(form_);
PrefFileformats * formats = new PrefFileformats(form_);
PrefConverters * converters = new PrefConverters(this);
PrefFileformats * formats = new PrefFileformats(this);
connect(formats, SIGNAL(formatsChanged()),
converters, SLOT(updateGui()));
add(converters);
add(formats);
add(new PrefCopiers(form_));
add(new PrefCopiers(this));
prefsPS->setCurrentPanel(_("User interface"));
@ -1948,34 +1951,39 @@ GuiPrefsDialog::GuiPrefsDialog(GuiPrefs * form)
prefsPS->updateGeometry();
#endif
form_->bc().setOK(savePB);
form_->bc().setApply(applyPB);
form_->bc().setCancel(closePB);
form_->bc().setRestore(restorePB);
bc().setPolicy(ButtonPolicy::PreferencesPolicy);
bc().setOK(savePB);
bc().setApply(applyPB);
bc().setCancel(closePB);
bc().setRestore(restorePB);
}
ControlPrefs & GuiPrefsDialog::controller() const
{
return static_cast<ControlPrefs &>(Dialog::controller());
}
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();
slotWMHide();
e->accept();
}
void GuiPrefsDialog::change_adaptor()
{
form_->changed();
changed();
}
@ -1995,46 +2003,29 @@ void GuiPrefsDialog::updateRc(LyXRC const & rc)
}
/////////////////////////////////////////////////////////////////////
//
// GuiPrefs
//
/////////////////////////////////////////////////////////////////////
GuiPrefs::GuiPrefs(GuiDialog & parent)
: GuiView<GuiPrefsDialog>(parent, _("Preferences"))
{
}
Converters & GuiPrefs::converters()
Converters & GuiPrefsDialog::converters()
{
return controller().converters();
}
Formats & GuiPrefs::formats()
Formats & GuiPrefsDialog::formats()
{
return controller().formats();
}
Movers & GuiPrefs::movers()
Movers & GuiPrefsDialog::movers()
{
return controller().movers();
}
void GuiPrefs::build_dialog()
void GuiPrefsDialog::applyView()
{
dialog_.reset(new GuiPrefsDialog(this));
apply(controller().rc());
}
void GuiPrefs::applyView()
void GuiPrefsDialog::update_contents()
{
dialog_->apply(controller().rc());
}
void GuiPrefs::update_contents()
{
dialog_->updateRc(controller().rc());
updateRc(controller().rc());
}
} // namespace frontend

View File

@ -12,7 +12,7 @@
#ifndef GUIPREFS_H
#define GUIPREFS_H
#include "GuiDialogView.h"
#include "GuiDialog.h"
#include "ControlPrefs.h"
#include "Color.h"
#include "LyXRC.h"
@ -48,14 +48,14 @@ class Movers;
namespace frontend {
class GuiPrefs;
class GuiPrefsDialog;
class PrefModule : public QWidget
{
Q_OBJECT
public:
PrefModule(docstring const & t,
GuiPrefs * form = 0, QWidget * parent = 0)
GuiPrefsDialog * form = 0, QWidget * parent = 0)
: QWidget(parent), title_(t), form_(form)
{}
@ -66,14 +66,14 @@ public:
protected:
docstring title_;
GuiPrefs * form_;
GuiPrefsDialog * form_;
Q_SIGNALS:
void changed();
};
class PrefPlaintext : public PrefModule, public Ui::PrefPlaintextUi
class PrefPlaintext : public PrefModule, public Ui::PrefPlaintextUi
{
Q_OBJECT
public:
@ -84,7 +84,7 @@ public:
};
class PrefDate : public PrefModule, public Ui::PrefDateUi
class PrefDate : public PrefModule, public Ui::PrefDateUi
{
Q_OBJECT
public:
@ -95,11 +95,11 @@ public:
};
class PrefKeyboard : public PrefModule, public Ui::PrefKeyboardUi
class PrefKeyboard : public PrefModule, public Ui::PrefKeyboardUi
{
Q_OBJECT
public:
PrefKeyboard(GuiPrefs * form, QWidget * parent = 0);
PrefKeyboard(GuiPrefsDialog * form, QWidget * parent = 0);
virtual void apply(LyXRC & rc) const;
virtual void update(LyXRC const & rc);
@ -114,22 +114,22 @@ private:
};
class PrefLatex : public PrefModule, public Ui::PrefLatexUi
class PrefLatex : public PrefModule, public Ui::PrefLatexUi
{
Q_OBJECT
public:
PrefLatex(GuiPrefs * form, QWidget * parent = 0);
PrefLatex(GuiPrefsDialog * form, QWidget * parent = 0);
virtual void apply(LyXRC & rc) const;
virtual void update(LyXRC const & rc);
};
class PrefScreenFonts : public PrefModule, public Ui::PrefScreenFontsUi
class PrefScreenFonts : public PrefModule, public Ui::PrefScreenFontsUi
{
Q_OBJECT
public:
PrefScreenFonts(GuiPrefs * form, QWidget * parent = 0);
PrefScreenFonts(GuiPrefsDialog * form, QWidget * parent = 0);
virtual void apply(LyXRC & rc) const;
virtual void update(LyXRC const & rc);
@ -141,11 +141,11 @@ private Q_SLOTS:
};
class PrefColors : public PrefModule, public Ui::PrefColorsUi
class PrefColors : public PrefModule, public Ui::PrefColorsUi
{
Q_OBJECT
public:
PrefColors(GuiPrefs * form, QWidget * parent = 0);
PrefColors(GuiPrefsDialog * form, QWidget * parent = 0);
void apply(LyXRC & rc) const;
void update(LyXRC const & rc);
@ -165,7 +165,7 @@ private:
};
class PrefDisplay : public PrefModule, public Ui::PrefDisplayUi
class PrefDisplay : public PrefModule, public Ui::PrefDisplayUi
{
Q_OBJECT
public:
@ -176,11 +176,11 @@ public:
};
class PrefPaths : public PrefModule, public Ui::PrefPathsUi
class PrefPaths : public PrefModule, public Ui::PrefPathsUi
{
Q_OBJECT
public:
PrefPaths(GuiPrefs * form, QWidget * parent = 0);
PrefPaths(GuiPrefsDialog * form, QWidget * parent = 0);
void apply(LyXRC & rc) const;
void update(LyXRC const & rc);
@ -195,11 +195,11 @@ private Q_SLOTS:
};
class PrefSpellchecker : public PrefModule, public Ui::PrefSpellcheckerUi
class PrefSpellchecker : public PrefModule, public Ui::PrefSpellcheckerUi
{
Q_OBJECT
public:
PrefSpellchecker(GuiPrefs * form, QWidget * parent = 0);
PrefSpellchecker(GuiPrefsDialog * form, QWidget * parent = 0);
void apply(LyXRC & rc) const;
void update(LyXRC const & rc);
@ -209,11 +209,11 @@ private Q_SLOTS:
};
class PrefConverters : public PrefModule, public Ui::PrefConvertersUi
class PrefConverters : public PrefModule, public Ui::PrefConvertersUi
{
Q_OBJECT
public:
PrefConverters(GuiPrefs * form, QWidget * parent = 0);
PrefConverters(GuiPrefsDialog * form, QWidget * parent = 0);
void apply(LyXRC & rc) const;
void update(LyXRC const & rc);
@ -233,11 +233,11 @@ private:
};
class PrefCopiers : public PrefModule, public Ui::PrefCopiersUi
class PrefCopiers : public PrefModule, public Ui::PrefCopiersUi
{
Q_OBJECT
public:
PrefCopiers(GuiPrefs * form, QWidget * parent = 0);
PrefCopiers(GuiPrefsDialog * form, QWidget * parent = 0);
void apply(LyXRC & rc) const;
void update(LyXRC const & rc);
@ -257,11 +257,11 @@ private:
};
class PrefFileformats : public PrefModule, public Ui::PrefFileformatsUi
class PrefFileformats : public PrefModule, public Ui::PrefFileformatsUi
{
Q_OBJECT
public:
PrefFileformats(GuiPrefs * form, QWidget * parent = 0);
PrefFileformats(GuiPrefsDialog * form, QWidget * parent = 0);
void apply(LyXRC & rc) const;
void update(LyXRC const & rc);
@ -281,7 +281,7 @@ private Q_SLOTS:
};
class PrefLanguage : public PrefModule, public Ui::PrefLanguageUi
class PrefLanguage : public PrefModule, public Ui::PrefLanguageUi
{
Q_OBJECT
public:
@ -295,7 +295,7 @@ private:
};
class PrefPrinter : public PrefModule, public Ui::PrefPrinterUi
class PrefPrinter : public PrefModule, public Ui::PrefPrinterUi
{
Q_OBJECT
public:
@ -306,11 +306,11 @@ public:
};
class PrefUserInterface : public PrefModule, public Ui::PrefUi
class PrefUserInterface : public PrefModule, public Ui::PrefUi
{
Q_OBJECT
public:
PrefUserInterface(GuiPrefs * form, QWidget * parent = 0);
PrefUserInterface(GuiPrefsDialog * form, QWidget * parent = 0);
void apply(LyXRC & rc) const;
void update(LyXRC const & rc);
@ -323,7 +323,7 @@ public Q_SLOTS:
};
class PrefIdentity : public PrefModule, public Ui::PrefIdentityUi
class PrefIdentity : public PrefModule, public Ui::PrefIdentityUi
{
Q_OBJECT
public:
@ -334,11 +334,11 @@ public:
};
///
class GuiPrefsDialog : public QDialog, public Ui::PrefsUi
class GuiPrefsDialog : public GuiDialog, public Ui::PrefsUi
{
Q_OBJECT
public:
GuiPrefsDialog(GuiPrefs *);
GuiPrefsDialog(LyXView & lv);
void apply(LyXRC & rc) const;
void updateRc(LyXRC const & rc);
@ -346,44 +346,28 @@ public:
public Q_SLOTS:
void change_adaptor();
protected:
public:
//
void closeEvent(QCloseEvent * e);
private:
///
void add(PrefModule * module);
///
Converters & converters();
///
Formats & formats();
///
Movers & movers();
/// parent controller
ControlPrefs & controller() const;
/// Apply changes
void applyView();
/// update (do we need this?)
void update_contents();
private:
GuiPrefs * form_;
std::vector<PrefModule *> modules_;
};
class GuiPrefs : public GuiView<GuiPrefsDialog>
{
public:
GuiPrefs(GuiDialog &);
Converters & converters();
Formats & formats();
Movers & movers();
/// parent controller
ControlPrefs & controller()
{ return static_cast<ControlPrefs &>(this->getController()); }
/// parent controller
ControlPrefs const & controller() const
{ return static_cast<ControlPrefs const &>(this->getController()); }
private:
/// Apply changes
virtual void applyView();
/// update (do we need this?)
virtual void update_contents();
/// build the dialog
virtual void build_dialog();
};
} // namespace frontend
} // namespace lyx

View File

@ -13,6 +13,7 @@
#include "GuiPrint.h"
#include "ControlPrint.h"
#include "qt_helpers.h"
#include "PrinterParams.h"
@ -24,16 +25,19 @@
#include <QSpinBox>
#include <QPushButton>
namespace lyx {
namespace frontend {
GuiPrintDialog::GuiPrintDialog(GuiPrint * f)
: form_(f)
GuiPrintDialog::GuiPrintDialog(LyXView & lv)
: GuiDialog(lv, "print")
{
setupUi(this);
setController(new ControlPrint(*this));
setViewTitle(_("Print Document"));
connect(printPB, SIGNAL(clicked()), form_, SLOT(slotOK()));
connect(closePB, SIGNAL(clicked()), form_, SLOT(slotClose()));
connect(printPB, SIGNAL(clicked()), this, SLOT(slotOK()));
connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
connect(copiesSB, SIGNAL(valueChanged(int)), this, SLOT(copiesChanged(int)));
connect(printerED, SIGNAL(textChanged(const QString&)),
@ -56,21 +60,31 @@ GuiPrintDialog::GuiPrintDialog(GuiPrint * f)
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)));
bc().setPolicy(ButtonPolicy::OkApplyCancelPolicy);
bc().setOK(printPB);
bc().setCancel(closePB);
}
ControlPrint & GuiPrintDialog::controller() const
{
return static_cast<ControlPrint &>(Dialog::controller());
}
void GuiPrintDialog::change_adaptor()
{
form_->changed();
changed();
}
void GuiPrintDialog::browseClicked()
{
QString file = toqstr(form_->controller().browse(docstring()));
QString file = toqstr(controller().browse(docstring()));
if (!file.isNull()) {
fileED->setText(file);
form_->changed();
changed();
}
}
@ -79,101 +93,81 @@ void GuiPrintDialog::fileChanged()
{
if (!fileED->text().isEmpty())
fileRB->setChecked(true);
form_->changed();
changed();
}
void GuiPrintDialog::copiesChanged(int i)
{
collateCB->setEnabled(i != 1);
form_->changed();
changed();
}
void GuiPrintDialog::printerChanged()
{
printerRB->setChecked(true);
form_->changed();
changed();
}
void GuiPrintDialog::pagerangeChanged()
{
form_->changed();
changed();
}
GuiPrint::GuiPrint(GuiDialog & parent)
: GuiView<GuiPrintDialog>(parent, _("Print Document"))
{
}
void GuiPrint::build_dialog()
{
dialog_.reset(new GuiPrintDialog(this));
bc().setOK(dialog_->printPB);
bc().setCancel(dialog_->closePB);
}
void GuiPrint::update_contents()
void GuiPrintDialog::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()))
if (!pp.file_name.empty() && pp.file_name == fromqstr(fileED->text()))
return;
dialog_->printerED->setText(toqstr(pp.printer_name));
dialog_->fileED->setText(toqstr(pp.file_name));
printerED->setText(toqstr(pp.printer_name));
fileED->setText(toqstr(pp.file_name));
dialog_->printerRB->setChecked(true);
printerRB->setChecked(true);
if (pp.target == PrinterParams::FILE)
dialog_->fileRB->setChecked(true);
fileRB->setChecked(true);
dialog_->reverseCB->setChecked(pp.reverse_order);
reverseCB->setChecked(pp.reverse_order);
dialog_->copiesSB->setValue(pp.count_copies);
copiesSB->setValue(pp.count_copies);
dialog_->oddCB->setChecked(pp.odd_pages);
dialog_->evenCB->setChecked(pp.even_pages);
oddCB->setChecked(pp.odd_pages);
evenCB->setChecked(pp.even_pages);
dialog_->collateCB->setChecked(pp.sorted_copies);
collateCB->setChecked(pp.sorted_copies);
if (pp.all_pages) {
dialog_->allRB->setChecked(true);
return;
allRB->setChecked(true);
} else {
rangeRB->setChecked(true);
fromED->setText(QString::number(pp.from_page));
toED->setText(QString::number(pp.to_page));
}
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::applyView()
void GuiPrintDialog::applyView()
{
PrinterParams::Target t = PrinterParams::PRINTER;
if (dialog_->fileRB->isChecked())
if (fileRB->isChecked())
t = PrinterParams::FILE;
PrinterParams const pp(t,
fromqstr(dialog_->printerED->text()),
support::os::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());
fromqstr(printerED->text()),
support::os::internal_path(fromqstr(fileED->text())),
allRB->isChecked(),
fromED->text().toUInt(),
toED->text().toUInt(),
oddCB->isChecked(),
evenCB->isChecked(),
copiesSB->text().toUInt(),
collateCB->isChecked(),
reverseCB->isChecked());
controller().params() = pp;
}

View File

@ -13,53 +13,35 @@
#ifndef GUIPRINT_H
#define GUIPRINT_H
#include "GuiDialogView.h"
#include "GuiDialog.h"
#include "ControlPrint.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_;
};
class GuiPrint : public GuiView<GuiPrintDialog>
class GuiPrintDialog : public GuiDialog, public Ui::PrintUi
{
Q_OBJECT
public:
///
friend class GuiPrintDialog;
///
GuiPrint(GuiDialog &);
GuiPrintDialog(LyXView & lv);
private Q_SLOTS:
void change_adaptor();
void browseClicked();
void fileChanged();
void copiesChanged(int);
void printerChanged();
void pagerangeChanged();
/// parent controller
ControlPrint & controller()
{ return static_cast<ControlPrint &>(this->getController()); }
/// parent controller
ControlPrint const & controller() const
{ return static_cast<ControlPrint const &>(this->getController()); }
ControlPrint & controller() const;
private:
/// Apply changes
virtual void applyView();
void applyView();
/// update
virtual void update_contents();
/// build the dialog
virtual void build_dialog();
void update_contents();
};
} // namespace frontend

View File

@ -12,6 +12,8 @@
#include <config.h>
#include "GuiRef.h"
#include "ControlRef.h"
#include "qt_helpers.h"
#include "insets/InsetRef.h"
@ -32,20 +34,19 @@ using std::string;
namespace lyx {
namespace frontend {
/////////////////////////////////////////////////////////////////////
//
// GuiRefDialog
//
/////////////////////////////////////////////////////////////////////
GuiRefDialog::GuiRefDialog(GuiRef * form)
: form_(form)
GuiRefDialog::GuiRefDialog(LyXView & lv)
: GuiDialog(lv, "ref")
{
setupUi(this);
setController(new ControlRef(*this));
setViewTitle(_("Cross-reference"));
connect(okPB, SIGNAL(clicked()), form_, SLOT(slotOK()));
connect(applyPB, SIGNAL(clicked()), form_, SLOT(slotApply()));
connect(closePB, SIGNAL(clicked()), form_, SLOT(slotClose()));
sort_ = false;
at_ref_ = false;
connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
connect(applyPB, SIGNAL(clicked()), this, SLOT(slotApply()));
connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
connect(closePB, SIGNAL(clicked()), this, SLOT(reset_dialog()));
connect(this, SIGNAL(rejected()), this, SLOT(reset_dialog()));
@ -71,8 +72,28 @@ GuiRefDialog::GuiRefDialog(GuiRef * form)
this, SLOT(updateClicked()));
setFocusProxy(refsLW);
bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
bc().setOK(okPB);
bc().setApply(applyPB);
bc().setCancel(closePB);
bc().addReadOnly(refsLW);
bc().addReadOnly(sortCB);
bc().addReadOnly(nameED);
bc().addReadOnly(referenceED);
bc().addReadOnly(typeCO);
bc().addReadOnly(bufferCO);
restored_buffer_ = -1;
}
ControlRef & GuiRefDialog::controller() const
{
return static_cast<ControlRef &>(Dialog::controller());
}
void GuiRefDialog::showView()
{
QDialog::show();
@ -81,18 +102,18 @@ void GuiRefDialog::showView()
void GuiRefDialog::changed_adaptor()
{
form_->changed();
changed();
}
void GuiRefDialog::gotoClicked()
{
form_->gotoRef();
gotoRef();
}
void GuiRefDialog::selectionChanged()
{
if (form_->readOnly())
if (readOnly())
return;
QList<QListWidgetItem *> selections = refsLW->selectedItems();
@ -106,7 +127,7 @@ void GuiRefDialog::selectionChanged()
void GuiRefDialog::refHighlighted(QListWidgetItem * sel)
{
if (form_->readOnly())
if (readOnly())
return;
/* int const cur_item = refsLW->currentRow();
@ -117,19 +138,19 @@ void GuiRefDialog::refHighlighted(QListWidgetItem * sel)
if (cur_item_selected)
referenceED->setText(sel->text());
if (form_->at_ref_)
form_->gotoRef();
if (at_ref_)
gotoRef();
gotoPB->setEnabled(true);
if (form_->typeAllowed())
if (typeAllowed())
typeCO->setEnabled(true);
if (form_->nameAllowed())
if (nameAllowed())
nameED->setEnabled(true);
}
void GuiRefDialog::refSelected(QListWidgetItem * sel)
{
if (form_->readOnly())
if (readOnly())
return;
/* int const cur_item = refsLW->currentRow();
@ -140,125 +161,94 @@ void GuiRefDialog::refSelected(QListWidgetItem * sel)
if (cur_item_selected)
referenceED->setText(sel->text());
// <enter> or double click, inserts ref and closes dialog
form_->slotOK();
slotOK();
}
void GuiRefDialog::sortToggled(bool on)
{
form_->sort_ = on;
form_->redoRefs();
sort_ = on;
redoRefs();
}
void GuiRefDialog::updateClicked()
{
form_->updateRefs();
updateRefs();
}
void GuiRefDialog::reset_dialog() {
form_->at_ref_ = false;
form_->setGotoRef();
void GuiRefDialog::reset_dialog()
{
at_ref_ = false;
setGotoRef();
}
void GuiRefDialog::closeEvent(QCloseEvent * e)
{
form_->slotWMHide();
slotWMHide();
reset_dialog();
e->accept();
}
/////////////////////////////////////////////////////////////////////
//
// GuiRef
//
/////////////////////////////////////////////////////////////////////
GuiRef::GuiRef(GuiDialog & parent)
: GuiView<GuiRefDialog>(parent, _("Cross-reference")),
sort_(false), at_ref_(false)
{
}
void GuiRef::build_dialog()
{
dialog_.reset(new GuiRefDialog(this));
bc().setOK(dialog_->okPB);
bc().setApply(dialog_->applyPB);
bc().setCancel(dialog_->closePB);
bc().addReadOnly(dialog_->refsLW);
bc().addReadOnly(dialog_->sortCB);
bc().addReadOnly(dialog_->nameED);
bc().addReadOnly(dialog_->referenceED);
bc().addReadOnly(dialog_->typeCO);
bc().addReadOnly(dialog_->bufferCO);
restored_buffer_ = -1;
}
void GuiRef::update_contents()
void GuiRefDialog::update_contents()
{
InsetCommandParams const & params = controller().params();
int orig_type = dialog_->typeCO->currentIndex();
int orig_type = typeCO->currentIndex();
dialog_->referenceED->setText(toqstr(params["reference"]));
referenceED->setText(toqstr(params["reference"]));
dialog_->nameED->setText(toqstr(params["name"]));
dialog_->nameED->setReadOnly(!nameAllowed() && !readOnly());
nameED->setText(toqstr(params["name"]));
nameED->setReadOnly(!nameAllowed() && !readOnly());
// restore type settings for new insets
if (params["reference"].empty())
dialog_->typeCO->setCurrentIndex(orig_type);
typeCO->setCurrentIndex(orig_type);
else
dialog_->typeCO->setCurrentIndex(InsetRef::getType(params.getCmdName()));
dialog_->typeCO->setEnabled(typeAllowed() && !readOnly());
typeCO->setCurrentIndex(InsetRef::getType(params.getCmdName()));
typeCO->setEnabled(typeAllowed() && !readOnly());
if (!typeAllowed())
dialog_->typeCO->setCurrentIndex(0);
typeCO->setCurrentIndex(0);
dialog_->sortCB->setChecked(sort_);
sortCB->setChecked(sort_);
// insert buffer list
dialog_->bufferCO->clear();
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));
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_);
&& restored_buffer_ < bufferCO->count())
bufferCO->setCurrentIndex(restored_buffer_);
else
dialog_->bufferCO->setCurrentIndex(controller().getBufferNum());
bufferCO->setCurrentIndex(controller().getBufferNum());
updateRefs();
bc().setValid(false);
}
void GuiRef::applyView()
void GuiRefDialog::applyView()
{
InsetCommandParams & params = controller().params();
last_reference_ = dialog_->referenceED->text();
last_reference_ = referenceED->text();
params.setCmdName(InsetRef::getName(dialog_->typeCO->currentIndex()));
params.setCmdName(InsetRef::getName(typeCO->currentIndex()));
params["reference"] = qstring_to_ucs4(last_reference_);
params["name"] = qstring_to_ucs4(dialog_->nameED->text());
params["name"] = qstring_to_ucs4(nameED->text());
restored_buffer_ = dialog_->bufferCO->currentIndex();
restored_buffer_ = bufferCO->currentIndex();
}
bool GuiRef::nameAllowed()
bool GuiRefDialog::nameAllowed()
{
Kernel::DocType const doc_type = kernel().docType();
return doc_type != Kernel::LATEX &&
@ -266,32 +256,32 @@ bool GuiRef::nameAllowed()
}
bool GuiRef::typeAllowed()
bool GuiRefDialog::typeAllowed()
{
Kernel::DocType const doc_type = kernel().docType();
return doc_type != Kernel::DOCBOOK;
}
void GuiRef::setGoBack()
void GuiRefDialog::setGoBack()
{
dialog_->gotoPB->setText(qt_("&Go Back"));
dialog_->gotoPB->setToolTip("");
dialog_->gotoPB->setToolTip(qt_("Jump back"));
gotoPB->setText(qt_("&Go Back"));
gotoPB->setToolTip("");
gotoPB->setToolTip(qt_("Jump back"));
}
void GuiRef::setGotoRef()
void GuiRefDialog::setGotoRef()
{
dialog_->gotoPB->setText(qt_("&Go to Label"));
dialog_->gotoPB->setToolTip("");
dialog_->gotoPB->setToolTip(qt_("Jump to label"));
gotoPB->setText(qt_("&Go to Label"));
gotoPB->setToolTip("");
gotoPB->setToolTip(qt_("Jump to label"));
}
void GuiRef::gotoRef()
void GuiRefDialog::gotoRef()
{
string ref(fromqstr(dialog_->referenceED->text()));
string ref(fromqstr(referenceED->text()));
if (at_ref_) {
// go back
@ -306,29 +296,29 @@ void GuiRef::gotoRef()
}
void GuiRef::redoRefs()
void GuiRefDialog::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);
refsLW->blockSignals(true);
referenceED->blockSignals(true);
refsLW->setUpdatesEnabled(false);
dialog_->refsLW->clear();
refsLW->clear();
// need this because Qt will send a highlight() here for
// the first item inserted
QString const oldSelection(dialog_->referenceED->text());
QString const oldSelection(referenceED->text());
for (std::vector<docstring>::const_iterator iter = refs_.begin();
iter != refs_.end(); ++iter) {
dialog_->refsLW->addItem(toqstr(*iter));
refsLW->addItem(toqstr(*iter));
}
if (sort_)
dialog_->refsLW->sortItems();
refsLW->sortItems();
dialog_->referenceED->setText(oldSelection);
referenceED->setText(oldSelection);
// restore the last selection or, for new insets, highlight
// the previous selection
@ -336,13 +326,13 @@ void GuiRef::redoRefs()
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);
for (int i = 0; !foundItem && i < refsLW->count(); ++i) {
QListWidgetItem * item = refsLW->item(i);
if (textToFind == item->text()) {
dialog_->refsLW->setCurrentItem(item);
dialog_->refsLW->setItemSelected(item, !newInset);
refsLW->setCurrentItem(item);
refsLW->setItemSelected(item, !newInset);
//Make sure selected item is visible
dialog_->refsLW->scrollToItem(item);
refsLW->scrollToItem(item);
foundItem = true;
}
}
@ -350,29 +340,30 @@ void GuiRef::redoRefs()
last_reference_ = textToFind;
else last_reference_ = "";
}
dialog_->refsLW->setUpdatesEnabled(true);
dialog_->refsLW->update();
refsLW->setUpdatesEnabled(true);
refsLW->update();
// Re-activate the emission of signals by these widgets.
dialog_->refsLW->blockSignals(false);
dialog_->referenceED->blockSignals(false);
refsLW->blockSignals(false);
referenceED->blockSignals(false);
}
void GuiRef::updateRefs()
void GuiRefDialog::updateRefs()
{
refs_.clear();
string const name = controller().getBufferName(dialog_->bufferCO->currentIndex());
string const name = controller().getBufferName(bufferCO->currentIndex());
refs_ = controller().getLabelList(name);
dialog_->sortCB->setEnabled(!refs_.empty());
dialog_->refsLW->setEnabled(!refs_.empty());
dialog_->gotoPB->setEnabled(!refs_.empty());
sortCB->setEnabled(!refs_.empty());
refsLW->setEnabled(!refs_.empty());
gotoPB->setEnabled(!refs_.empty());
redoRefs();
}
bool GuiRef::isValid()
bool GuiRefDialog::isValid()
{
return !dialog_->referenceED->text().isEmpty();
return !referenceED->text().isEmpty();
}
} // namespace frontend

View File

@ -12,12 +12,10 @@
#ifndef GUIREF_H
#define GUIREF_H
#include "GuiDialogView.h"
#include "GuiDialog.h"
#include "ControlRef.h"
#include "ui_RefUi.h"
#include <QDialog>
#include <vector>
class QListWidgetItem;
@ -25,16 +23,14 @@ class QListWidgetItem;
namespace lyx {
namespace frontend {
class GuiRef;
class GuiRefDialog : public QDialog, public Ui::RefUi {
class GuiRefDialog : public GuiDialog, public Ui::RefUi
{
Q_OBJECT
public:
GuiRefDialog(GuiRef * form);
GuiRefDialog(LyXView & lv);
virtual void showView();
public Q_SLOTS:
private Q_SLOTS:
void changed_adaptor();
void gotoClicked();
void refHighlighted(QListWidgetItem *);
@ -42,39 +38,21 @@ public Q_SLOTS:
void refSelected(QListWidgetItem *);
void sortToggled(bool);
void updateClicked();
protected Q_SLOTS:
void reset_dialog();
protected:
private:
///
void showView();
///
void closeEvent(QCloseEvent * e);
private:
GuiRef * form_;
};
class GuiRef : public GuiView<GuiRefDialog>
{
public:
friend class GuiRefDialog;
GuiRef(GuiDialog &);
/// parent controller
ControlRef & controller()
{ return static_cast<ControlRef &>(this->getController()); }
/// parent controller
ControlRef const & controller() const
{ return static_cast<ControlRef const &>(this->getController()); }
protected:
virtual bool isValid();
private:
ControlRef & controller() const;
///
bool isValid();
/// apply changes
virtual void applyView();
/// build dialog
virtual void build_dialog();
void applyView();
/// update dialog
virtual void update_contents();
void update_contents();
/// is name allowed for this ?
bool nameAllowed();

View File

@ -12,6 +12,8 @@
#include <config.h>
#include "GuiSearch.h"
#include "ControlSearch.h"
#include "qt_helpers.h"
#include <QLineEdit>
@ -19,17 +21,10 @@
using std::string;
namespace lyx {
namespace frontend {
/////////////////////////////////////////////////////////////////////
//
// GuiSearchDialog
//
/////////////////////////////////////////////////////////////////////
static void uniqueInsert(QComboBox * box, QString const & text)
{
for (int i = 0; i < box->count(); ++i) {
@ -41,12 +36,14 @@ static void uniqueInsert(QComboBox * box, QString const & text)
}
GuiSearchDialog::GuiSearchDialog(GuiSearch * form)
: form_(form)
GuiSearchDialog::GuiSearchDialog(LyXView & lv)
: GuiDialog(lv, "findreplace")
{
setupUi(this);
setController(new ControlSearch(*this));
setViewTitle(_("Find and Replace"));
connect(closePB, SIGNAL(clicked()), form_, SLOT(slotClose()));
connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
connect(findPB, SIGNAL(clicked()), this, SLOT(findClicked()));
connect(replacePB, SIGNAL(clicked()), this, SLOT(replaceClicked()));
connect(replaceallPB, SIGNAL(clicked()), this, SLOT(replaceallClicked()));
@ -54,6 +51,21 @@ GuiSearchDialog::GuiSearchDialog(GuiSearch * form)
this, SLOT(findChanged()));
setFocusProxy(findCO);
bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
bc().setCancel(closePB);
bc().addReadOnly(replaceCO);
bc().addReadOnly(replacePB);
bc().addReadOnly(replaceallPB);
replacePB->setEnabled(false);
replaceallPB->setEnabled(false);
}
ControlSearch & GuiSearchDialog::controller() const
{
return static_cast<ControlSearch &>(Dialog::controller());
}
@ -66,7 +78,7 @@ void GuiSearchDialog::showView()
void GuiSearchDialog::closeEvent(QCloseEvent * e)
{
form_->slotWMHide();
slotWMHide();
e->accept();
}
@ -79,18 +91,16 @@ void GuiSearchDialog::findChanged()
replaceallPB->setEnabled(false);
} else {
findPB->setEnabled(true);
replacePB->setEnabled(!form_->readOnly());
replaceallPB->setEnabled(!form_->readOnly());
replacePB->setEnabled(!readOnly());
replaceallPB->setEnabled(!readOnly());
}
}
void GuiSearchDialog::findClicked()
{
docstring const find = qstring_to_ucs4(findCO->currentText());
form_->find(find,
caseCB->isChecked(),
wordsCB->isChecked(),
docstring const needle = qstring_to_ucs4(findCO->currentText());
find(needle, caseCB->isChecked(), wordsCB->isChecked(),
backwardsCB->isChecked());
uniqueInsert(findCO, findCO->currentText());
findCO->lineEdit()->setSelection(0, findCO->lineEdit()->text().length());
@ -99,11 +109,9 @@ void GuiSearchDialog::findClicked()
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(),
docstring const needle = qstring_to_ucs4(findCO->currentText());
docstring const repl = qstring_to_ucs4(replaceCO->currentText());
replace(needle, repl, caseCB->isChecked(), wordsCB->isChecked(),
backwardsCB->isChecked(), false);
uniqueInsert(findCO, findCO->currentText());
uniqueInsert(replaceCO, replaceCO->currentText());
@ -112,51 +120,23 @@ void GuiSearchDialog::replaceClicked()
void GuiSearchDialog::replaceallClicked()
{
form_->replace(qstring_to_ucs4(findCO->currentText()),
replace(qstring_to_ucs4(findCO->currentText()),
qstring_to_ucs4(replaceCO->currentText()),
caseCB->isChecked(),
wordsCB->isChecked(),
false, true);
caseCB->isChecked(), wordsCB->isChecked(), false, true);
uniqueInsert(findCO, findCO->currentText());
uniqueInsert(replaceCO, replaceCO->currentText());
}
/////////////////////////////////////////////////////////////////////
//
// GuiSearch
//
/////////////////////////////////////////////////////////////////////
GuiSearch::GuiSearch(GuiDialog & parent)
: GuiView<GuiSearchDialog>(parent, _("Find and Replace"))
{
}
void GuiSearch::build_dialog()
{
dialog_.reset(new GuiSearchDialog(this));
bc().setCancel(dialog_->closePB);
bc().addReadOnly(dialog_->replaceCO);
bc().addReadOnly(dialog_->replacePB);
bc().addReadOnly(dialog_->replaceallPB);
dialog_->replacePB->setEnabled(false);
dialog_->replaceallPB->setEnabled(false);
}
void GuiSearch::find(docstring const & str, bool casesens,
bool words, bool backwards)
void GuiSearchDialog::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,
void GuiSearchDialog::replace(docstring const & findstr,
docstring const & replacestr,
bool casesens, bool words, bool backwards, bool all)
{
controller().replace(findstr, replacestr, casesens, words,

View File

@ -12,65 +12,40 @@
#ifndef GUISEARCH_H
#define GUISEARCH_H
#include "GuiDialogView.h"
#include "GuiDialog.h"
#include "ControlSearch.h"
#include "ui_SearchUi.h"
#include <string>
#include <QDialog>
namespace lyx {
namespace frontend {
class GuiSearch;
class ControlSearch;
class GuiSearchDialog : public QDialog, public Ui::SearchUi {
class GuiSearchDialog : public GuiDialog, public Ui::SearchUi
{
Q_OBJECT
public:
GuiSearchDialog(GuiSearch * form);
virtual void showView();
protected Q_SLOTS:
public:
GuiSearchDialog(LyXView & lv);
private Q_SLOTS:
void findChanged();
void findClicked();
void replaceClicked();
void replaceallClicked();
protected:
virtual void closeEvent(QCloseEvent * e);
private:
GuiSearch * form_;
};
class GuiSearch : public GuiView<GuiSearchDialog>
{
public:
///
friend class GuiSearchDialog;
///
GuiSearch(GuiDialog &);
void showView();
void closeEvent(QCloseEvent * e);
/// parent controller
ControlSearch & controller()
{ return static_cast<ControlSearch &>(this->getController()); }
/// parent controller
ControlSearch const & controller() const
{ return static_cast<ControlSearch const &>(this->getController()); }
private:
/// Apply changes
virtual void applyView() {}
/// update
virtual void update_contents() {}
/// build the dialog
virtual void build_dialog();
ControlSearch & controller() const;
///
void find(docstring const & str, bool casesens,
bool words, bool backwards);
bool words, bool backwards);
///
void replace(docstring const & findstr,
docstring const & replacestr,
bool casesens, bool words, bool backwards, bool all);
docstring const & replacestr,
bool casesens, bool words, bool backwards, bool all);
};
} // namespace frontend

View File

@ -20,181 +20,181 @@ namespace lyx {
namespace frontend {
GuiSelectionManager::GuiSelectionManager(
QListView * avail,
QListView * sel,
QPushButton * add,
QPushButton * del,
QPushButton * up,
QPushButton * down,
QStringListModel * amod,
QStringListModel * smod)
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);
availableLV = avail;
selectedLV = sel;
addPB = add;
deletePB = del;
upPB = up;
downPB = down;
availableModel = amod;
selectedModel = smod;
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 &)));
selectedLV->setModel(smod);
availableLV->setModel(amod);
availableLV->installEventFilter(this);
selectedLV->installEventFilter(this);
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::updateView()
{
int const arows = availableLV->model()->rowCount();
QModelIndexList const availSels =
availableLV->selectionModel()->selectedIndexes();
addPB->setEnabled(arows > 0 &&
!availSels.isEmpty() &&
!isSelected(availSels.first()));
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);
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);
QString const str = idx.data().toString();
return selectedModel->stringList().contains(str);
}
void GuiSelectionManager::availableChanged(const QModelIndex & idx, const QModelIndex &)
{
if (!idx.isValid())
return;
if (!idx.isValid())
return;
selectedHasFocus_ = false;
updateHook();
selectedHasFocus_ = false;
updateHook();
}
void GuiSelectionManager::selectedChanged(const QModelIndex & idx, const QModelIndex &)
{
if (!idx.isValid())
return;
if (!idx.isValid())
return;
selectedHasFocus_ = true;
updateHook();
selectedHasFocus_ = true;
updateHook();
}
static QModelIndex getSelectedIndex(QListView * lv)
{
QModelIndex retval = QModelIndex();
QModelIndexList selIdx =
lv->selectionModel()->selectedIndexes();
if (!selIdx.empty())
retval = selIdx.first();
return retval;
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();
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;
QModelIndex idx = getSelectedIndex(selectedLV);
if (!idx.isValid())
return;
QStringList keys = selectedModel->stringList();
keys.removeAt(idx.row());
selectedModel->setStringList(keys);
selectionChanged(); //signal
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());
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();
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();
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();
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();
}
@ -204,40 +204,40 @@ void GuiSelectionManager::downPB_clicked()
//which means subclassing QListView. (rgh)
void GuiSelectionManager::availableLV_clicked(const QModelIndex &)
{
selectedHasFocus_ = false;
updateHook();
selectedHasFocus_ = false;
updateHook();
}
void GuiSelectionManager::availableLV_doubleClicked(const QModelIndex & idx)
{
if (isSelected(idx))
return;
if (isSelected(idx))
return;
if (idx.isValid())
selectedHasFocus_ = false;
addPB_clicked();
//updateHook() will be emitted there
if (idx.isValid())
selectedHasFocus_ = false;
addPB_clicked();
//updateHook() will be emitted there
}
void GuiSelectionManager::selectedLV_clicked(const QModelIndex &)
{
selectedHasFocus_ = true;
updateHook();
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.
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) &&
@ -283,7 +283,7 @@ bool GuiSelectionManager::eventFilter(QObject * obj, QEvent * event)
return QObject::eventFilter(obj, event);
}
}//namespace frontend
}//namespace lyx
} // namespace frontend
} // namespace lyx
#include "GuiSelectionManager_moc.cpp"

View File

@ -9,10 +9,11 @@
* Full author contact details are available in file CREDITS.
*/
#ifndef QSELECTIONMANAGER_H
#define QSELECTIONMANAGER_H
#ifndef GUISELECTIONMANAGER_H
#define GUISELECTIONMANAGER_H
#include "Dialog.h"
#include <QObject>
#include <QKeyEvent>
#include <QStringList>
@ -20,7 +21,6 @@
#include <QListView>
#include <QPushButton>
namespace lyx {
namespace frontend {
@ -32,90 +32,91 @@ namespace frontend {
* 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 updateView();
/// 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 updateView(). 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 updateView().
void updateHook();
///Emitted on Ctrl-Enter in the availableLV. Intended to be connected
///to an "OK" event in the parent dialog.
void okHook();
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 updateView();
protected:
///Given a QModelIndex from availableLV, determines whether it has
///been selected (i.e., is also in selectedLV).
bool isSelected(const QModelIndex & idx);
/// 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_; };
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 *);
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 updateView(). 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 updateView().
void updateHook();
///Emitted on Ctrl-Enter in the availableLV. Intended to be connected
///to an "OK" event in the parent dialog.
void okHook();
private:
QListView * availableLV;
QListView * selectedLV;
QPushButton * addPB;
QPushButton * deletePB;
QPushButton * upPB;
QPushButton * downPB;
QStringListModel * availableModel;
QStringListModel * selectedModel;
Dialog::View * dialog;
bool selectedHasFocus_;
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
#endif // GUISELECTIONMANAGER

View File

@ -11,6 +11,8 @@
#include <config.h>
#include "GuiSendto.h"
#include "ControlSendto.h"
#include "qt_helpers.h"
#include "Format.h"
@ -26,73 +28,53 @@ using std::string;
namespace lyx {
namespace frontend {
/////////////////////////////////////////////////////////////////////
//
// GuiSendtoDialog
//
/////////////////////////////////////////////////////////////////////
GuiSendtoDialog::GuiSendtoDialog(GuiSendto * form)
: form_(form)
GuiSendtoDialog::GuiSendtoDialog(LyXView & lv)
: GuiDialog(lv, "sendto")
{
setupUi(this);
setViewTitle(_("Send Document to Command"));
setController(new ControlSendto(*this));
connect(okPB, SIGNAL(clicked()),
form, SLOT(slotOK()));
connect(applyPB, SIGNAL(clicked()),
form, SLOT(slotApply()));
connect(closePB, SIGNAL(clicked()),
form, SLOT(slotClose()));
connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
connect(applyPB, SIGNAL(clicked()), this, SLOT(slotApply()));
connect(closePB, SIGNAL(clicked()), this, 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() ) );
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()));
bc().setPolicy(ButtonPolicy::OkApplyCancelPolicy);
bc().setOK(okPB);
bc().setApply(applyPB);
bc().setCancel(closePB);
}
ControlSendto & GuiSendtoDialog::controller() const
{
return static_cast<ControlSendto &>(Dialog::controller());
}
void GuiSendtoDialog::changed_adaptor()
{
form_->changed();
changed();
}
void GuiSendtoDialog::closeEvent(QCloseEvent * e)
{
form_->slotWMHide();
slotWMHide();
e->accept();
}
/////////////////////////////////////////////////////////////////////
//
// GuiSendto
//
/////////////////////////////////////////////////////////////////////
GuiSendto::GuiSendto(GuiDialog & parent)
: GuiView<GuiSendtoDialog>(parent, _("Send Document to Command"))
{
}
void GuiSendto::build_dialog()
{
dialog_.reset(new GuiSendtoDialog(this));
// Manage the ok, apply, restore and cancel/close buttons
bc().setOK(dialog_->okPB);
bc().setApply(dialog_->applyPB);
bc().setCancel(dialog_->closePB);
}
void GuiSendto::update_contents()
void GuiSendtoDialog::update_contents()
{
all_formats_ = controller().allFormats();
@ -104,45 +86,42 @@ void GuiSendto::update_contents()
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) {
for (; it != end; ++it, ++result)
*result = (*it)->prettyname();
}
// Reload the browser
dialog_->formatLW->clear();
formatLW->clear();
for (vector<string>::const_iterator it = keys.begin();
it < keys.end(); ++it) {
dialog_->formatLW->addItem(toqstr(*it));
it != keys.end(); ++it) {
formatLW->addItem(toqstr(*it));
}
dialog_->commandCO->addItem(toqstr(controller().getCommand()));
commandCO->addItem(toqstr(controller().getCommand()));
}
void GuiSendto::applyView()
void GuiSendtoDialog::applyView()
{
int const line(dialog_->formatLW->currentRow());
int const line = formatLW->currentRow();
if (line < 0 || line > int(dialog_->formatLW->count()))
if (line < 0 || line > int(formatLW->count()))
return;
string const cmd(fromqstr(dialog_->commandCO->currentText()));
controller().setFormat(all_formats_[line]);
controller().setCommand(cmd);
controller().setCommand(fromqstr(commandCO->currentText()));
}
bool GuiSendto::isValid()
bool GuiSendtoDialog::isValid()
{
int const line(dialog_->formatLW->currentRow());
int const line = formatLW->currentRow();
if (line < 0 || line > int(dialog_->formatLW->count()))
if (line < 0 || line > int(formatLW->count()))
return false;
else return dialog_->formatLW->count() != 0 &&
!dialog_->commandCO->currentText().isEmpty();
return formatLW->count() != 0 &&
!commandCO->currentText().isEmpty();
}
} // namespace frontend

View File

@ -12,12 +12,10 @@
#ifndef GUISENDTO_H
#define GUISENDTO_H
#include "GuiDialogView.h"
#include "GuiDialog.h"
#include "ControlSendto.h"
#include "ui_SendtoUi.h"
#include <QDialog>
#include <vector>
class QListWidgetItem;
@ -28,47 +26,29 @@ 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_;
};
/** This class provides a Qt implementation of the Custom Export Dialog.
*/
class GuiSendto : public GuiView<GuiSendtoDialog>
class GuiSendtoDialog : public GuiDialog, public Ui::SendtoUi
{
Q_OBJECT
public:
///
friend class GuiSendtoDialog;
///
GuiSendto(GuiDialog &);
/// parent controller
ControlSendto & controller()
{ return static_cast<ControlSendto &>(this->getController()); }
/// parent controller
ControlSendto const & controller() const
{ return static_cast<ControlSendto const &>(this->getController()); }
protected:
virtual bool isValid();
GuiSendtoDialog(LyXView & lv);
private Q_SLOTS:
void changed_adaptor();
void slotFormatHighlighted(QListWidgetItem *) {}
void slotFormatSelected(QListWidgetItem *) {}
private:
void closeEvent(QCloseEvent * e);
/// parent controller
ControlSendto & controller() const;
///
bool isValid();
/// Apply from dialog
virtual void applyView();
void applyView();
/// Update the dialog
virtual void update_contents();
/// Build the dialog
virtual void build_dialog();
void update_contents();
///
std::vector<Format const *> all_formats_;
};

View File

@ -9,8 +9,9 @@
*
* Full author contact details are available in file CREDITS.
*/
#ifndef QSETBORDER_H
#define QSETBORDER_H
#ifndef GUISETBORDER_H
#define GUISETBORDER_H
#include <QWidget>
#include <QPixmap>
@ -87,4 +88,4 @@ private:
//} // namespace lyx
#endif // QSETBORDER_H
#endif // GUISETBORDER_H

View File

@ -11,67 +11,55 @@
#include <config.h>
#include "GuiShowFile.h"
#include "ControlShowFile.h"
#include "qt_helpers.h"
#include <QTextBrowser>
#include <QPushButton>
#include <QCloseEvent>
namespace lyx {
namespace frontend {
/////////////////////////////////////////////////////////////////////
//
// GuiShowFileDialog
//
/////////////////////////////////////////////////////////////////////
GuiShowFileDialog::GuiShowFileDialog(GuiShowFile * form)
: form_(form)
GuiShowFileDialog::GuiShowFileDialog(LyXView & lv)
: GuiDialog(lv, "file")
{
setupUi(this);
connect(closePB, SIGNAL(clicked()), form, SLOT(slotClose()));
setViewTitle(_("Show File"));
setController(new ControlShowFile(*this));
connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
bc().setPolicy(ButtonPolicy::OkCancelPolicy);
bc().setCancel(closePB);
}
ControlShowFile & GuiShowFileDialog::controller() const
{
return static_cast<ControlShowFile &>(Dialog::controller());
}
void GuiShowFileDialog::closeEvent(QCloseEvent * e)
{
form_->slotWMHide();
slotWMHide();
e->accept();
}
/////////////////////////////////////////////////////////////////////
//
// GuiShowFile
//
/////////////////////////////////////////////////////////////////////
GuiShowFile::GuiShowFile(GuiDialog & parent)
: GuiView<GuiShowFileDialog>(parent, _("Show File"))
void GuiShowFileDialog::update_contents()
{
}
void GuiShowFile::build_dialog()
{
dialog_.reset(new GuiShowFileDialog(this));
bc().setCancel(dialog_->closePB);
}
void GuiShowFile::update_contents()
{
dialog_->setWindowTitle(toqstr(controller().getFileName()));
setWindowTitle(toqstr(controller().getFileName()));
std::string contents = controller().getFileContents();
if (contents.empty()) {
contents = "Error -> Cannot load file!";
}
dialog_->textTB->setPlainText(toqstr(contents));
textTB->setPlainText(toqstr(contents));
}
} // namespace frontend

View File

@ -9,55 +9,33 @@
* Full author contact details are available in file CREDITS.
*/
#ifndef QSHOWFILE_H
#define QSHOWFILE_H
#ifndef GUISHOWFILE_H
#define GUISHOWFILE_H
#include "GuiDialogView.h"
#include "GuiDialog.h"
#include "ControlShowFile.h"
#include "ui_ShowFileUi.h"
#include <QDialog>
namespace lyx {
namespace frontend {
class GuiShowFile;
class GuiShowFileDialog : public QDialog, public Ui::ShowFileUi
class GuiShowFileDialog : public GuiDialog, public Ui::ShowFileUi
{
Q_OBJECT
public:
GuiShowFileDialog(GuiShowFile * form);
protected:
virtual void closeEvent(QCloseEvent * e);
GuiShowFileDialog(LyXView & lv);
private:
GuiShowFile * form_;
};
class GuiShowFile : public GuiView<GuiShowFileDialog>
{
public:
friend class GuiShowFileDialog;
GuiShowFile(GuiDialog &);
///
void closeEvent(QCloseEvent * e);
/// parent controller
ControlShowFile & controller()
{ return static_cast<ControlShowFile &>(this->getController()); }
/// parent controller
ControlShowFile const & controller() const
{ return static_cast<ControlShowFile const &>(this->getController()); }
private:
/// Apply changes
virtual void applyView() {}
ControlShowFile & controller() const;
/// update
virtual void update_contents();
/// build the dialog
virtual void build_dialog();
void update_contents();
};
} // namespace frontend
} // namespace lyx
#endif // QSHOWFILE_H
#endif // GUISHOWFILE_H

View File

@ -11,6 +11,8 @@
#include <config.h>
#include "GuiSpellchecker.h"
#include "ControlSpellchecker.h"
#include "qt_helpers.h"
#include <QProgressBar>
@ -29,19 +31,14 @@ using std::string;
namespace lyx {
namespace frontend {
/////////////////////////////////////////////////////////////////////
//
// GuiSpellCheckerDialog
//
/////////////////////////////////////////////////////////////////////
GuiSpellcheckerDialog::GuiSpellcheckerDialog(GuiSpellchecker * form)
: form_(form)
GuiSpellcheckerDialog::GuiSpellcheckerDialog(LyXView & lv)
: GuiDialog(lv, "spellchecker")
{
setupUi(this);
setViewTitle(_("Spellchecker"));
setController(new ControlSpellchecker(*this));
connect(closePB, SIGNAL(clicked()), form, SLOT(slotClose()));
connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
connect(replaceCO, SIGNAL(highlighted(const QString &)),
this, SLOT(replaceChanged(const QString &)));
@ -57,29 +54,44 @@ GuiSpellcheckerDialog::GuiSpellcheckerDialog(GuiSpellchecker * form)
this, SLOT(replaceClicked() ) );
connect(suggestionsLW, SIGNAL(itemClicked(QListWidgetItem*)),
this, SLOT(suggestionChanged(QListWidgetItem*)));
wordED->setReadOnly(true);
bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
bc().setCancel(closePB);
}
ControlSpellchecker & GuiSpellcheckerDialog::controller() const
{
return static_cast<ControlSpellchecker &>(Dialog::controller());
}
void GuiSpellcheckerDialog::acceptClicked()
{
form_->accept();
accept();
}
void GuiSpellcheckerDialog::addClicked()
{
form_->add();
add();
}
void GuiSpellcheckerDialog::replaceClicked()
{
form_->replace();
replace();
}
void GuiSpellcheckerDialog::ignoreClicked()
{
form_->ignore();
ignore();
}
void GuiSpellcheckerDialog::suggestionChanged(QListWidgetItem * item)
{
if (replaceCO->count() != 0)
@ -90,6 +102,7 @@ void GuiSpellcheckerDialog::suggestionChanged(QListWidgetItem * item)
replaceCO->setCurrentIndex(0);
}
void GuiSpellcheckerDialog::replaceChanged(const QString & str)
{
if (suggestionsLW->currentItem()->text() == str)
@ -106,101 +119,72 @@ void GuiSpellcheckerDialog::replaceChanged(const QString & str)
void GuiSpellcheckerDialog::closeEvent(QCloseEvent * e)
{
form_->slotWMHide();
slotWMHide();
e->accept();
}
void GuiSpellcheckerDialog::reject()
{
form_->slotWMHide();
slotWMHide();
QDialog::reject();
}
/////////////////////////////////////////////////////////////////////
//
// GuiSpellChecker
//
/////////////////////////////////////////////////////////////////////
GuiSpellchecker::GuiSpellchecker(GuiDialog & parent)
: GuiView<GuiSpellcheckerDialog>(parent, _("Spellchecker"))
{}
void GuiSpellchecker::build_dialog()
{
dialog_.reset(new GuiSpellcheckerDialog(this));
bc().setCancel(dialog_->closePB);
dialog_->wordED->setReadOnly(true);
}
void GuiSpellchecker::update_contents()
void GuiSpellcheckerDialog::update_contents()
{
if (isVisibleView() || controller().exitEarly())
controller().check();
}
void GuiSpellchecker::accept()
void GuiSpellcheckerDialog::accept()
{
controller().ignoreAll();
}
void GuiSpellchecker::add()
void GuiSpellcheckerDialog::add()
{
controller().insert();
}
void GuiSpellchecker::ignore()
void GuiSpellcheckerDialog::ignore()
{
controller().check();
}
void GuiSpellchecker::replace()
void GuiSpellcheckerDialog::replace()
{
controller().replace(qstring_to_ucs4(dialog_->replaceCO->currentText()));
controller().replace(qstring_to_ucs4(replaceCO->currentText()));
}
void GuiSpellchecker::partialUpdate(int s)
void GuiSpellcheckerDialog::partialUpdate(int state)
{
ControlSpellchecker::State const state =
static_cast<ControlSpellchecker::State>(s);
switch (state) {
case ControlSpellchecker::SPELL_PROGRESSED:
spellcheckPR->setValue(controller().getProgress());
break;
case ControlSpellchecker::SPELL_PROGRESSED:
dialog_->spellcheckPR->setValue(controller().getProgress());
break;
case ControlSpellchecker::SPELL_FOUND_WORD: {
wordED->setText(toqstr(controller().getWord()));
suggestionsLW->clear();
case ControlSpellchecker::SPELL_FOUND_WORD: {
dialog_->wordED->setText(toqstr(controller().getWord()));
dialog_->suggestionsLW->clear();
docstring w;
while (!(w = controller().getSuggestion()).empty())
suggestionsLW->addItem(toqstr(w));
docstring w;
while (!(w = controller().getSuggestion()).empty()) {
dialog_->suggestionsLW->addItem(toqstr(w));
if (suggestionsLW->count() == 0)
suggestionChanged(new QListWidgetItem(wordED->text()));
else
suggestionChanged(suggestionsLW->item(0));
suggestionsLW->setCurrentRow(0);
break;
}
if (dialog_->suggestionsLW->count() == 0) {
dialog_->suggestionChanged(new QListWidgetItem(dialog_->wordED->text()));
} else {
dialog_->suggestionChanged(dialog_->suggestionsLW->item(0));
}
dialog_->suggestionsLW->setCurrentRow(0);
}
break;
}
}

View File

@ -13,70 +13,47 @@
#ifndef GUISPELLCHECKER_H
#define GUISPELLCHECKER_H
#include "GuiDialogView.h"
#include "GuiDialog.h"
#include "ControlSpellchecker.h"
#include "ui_SpellcheckerUi.h"
#include <QDialog>
class QListWidgetItem;
namespace lyx {
namespace frontend {
class GuiSpellchecker;
class GuiSpellcheckerDialog: public QDialog, public Ui::SpellcheckerUi {
class GuiSpellcheckerDialog : public GuiDialog, public Ui::SpellcheckerUi
{
Q_OBJECT
public:
GuiSpellcheckerDialog(GuiSpellchecker * form);
GuiSpellcheckerDialog(LyXView & lv);
public Q_SLOTS:
virtual void suggestionChanged(QListWidgetItem *);
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 Q_SLOTS:
void acceptClicked();
void addClicked();
void replaceClicked();
void ignoreClicked();
void replaceChanged(const QString &);
void reject();
private:
GuiSpellchecker * form_;
};
class GuiSpellchecker : public GuiView<GuiSpellcheckerDialog>
{
public:
friend class GuiSpellcheckerDialog;
GuiSpellchecker(GuiDialog &);
///
void closeEvent(QCloseEvent * e);
/// update from controller
void partialUpdate(int id);
/// parent controller
ControlSpellchecker & controller()
{ return static_cast<ControlSpellchecker &>(this->getController()); }
/// parent controller
ControlSpellchecker const & controller() const
{ return static_cast<ControlSpellchecker const &>(this->getController()); }
private:
ControlSpellchecker & controller() const;
////
void accept();
void add();
void ignore();
void replace();
/// Apply changes
virtual void applyView() {}
///
virtual void update_contents();
/// build the dialog
virtual void build_dialog();
void update_contents();
};
} // namespace frontend

File diff suppressed because it is too large Load Diff

View File

@ -15,96 +15,71 @@
#ifndef GUITABULAR_H
#define GUITABULAR_H
#include "GuiDialogView.h"
#include "GuiDialog.h"
#include "ControlTabular.h"
#include "ui_TabularUi.h"
#include <QDialog>
namespace lyx {
namespace frontend {
class GuiTabular;
class GuiTabularDialog : public QDialog, public Ui::TabularUi
class GuiTabularDialog : public GuiDialog, public Ui::TabularUi
{
Q_OBJECT
public:
GuiTabularDialog(GuiTabular * form);
GuiTabularDialog(LyXView & lv);
protected Q_SLOTS:
virtual void change_adaptor();
private Q_SLOTS:
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);
void topspace_changed();
void bottomspace_changed();
void interlinespace_changed();
void booktabsChanged(bool);
void close_clicked();
void borderSet_clicked();
void borderUnset_clicked();
void leftBorder_changed();
void rightBorder_changed();
void topBorder_changed();
void bottomBorder_changed();
void multicolumn_clicked();
void rotateTabular();
void rotateCell();
void hAlign_changed(int align);
void vAlign_changed(int align);
void specialAlignment_changed();
void width_changed();
void longTabular();
void ltNewpage_clicked();
void ltHeaderStatus_clicked();
void ltHeaderBorderAbove_clicked();
void ltHeaderBorderBelow_clicked();
void ltFirstHeaderStatus_clicked();
void ltFirstHeaderBorderAbove_clicked();
void ltFirstHeaderBorderBelow_clicked();
void ltFirstHeaderEmpty_clicked();
void ltFooterStatus_clicked();
void ltFooterBorderAbove_clicked();
void ltFooterBorderBelow_clicked();
void ltLastFooterStatus_clicked();
void ltLastFooterBorderAbove_clicked();
void ltLastFooterBorderBelow_clicked();
void ltLastFooterEmpty_clicked();
private:
GuiTabular * form_;
};
class GuiTabular : public GuiView<GuiTabularDialog>
{
public:
friend class GuiTabularDialog;
GuiTabular(GuiDialog &);
///
void closeEvent(QCloseEvent * e);
/// parent controller
ControlTabular & controller()
{ return static_cast<ControlTabular &>(this->getController()); }
/// parent controller
ControlTabular const & controller() const
{ return static_cast<ControlTabular const &>(this->getController()); }
protected:
virtual bool isValid();
private:
/// We can't use this ...
virtual void applyView() {}
ControlTabular & controller() const;
///
bool isValid() { return true; }
/// update borders
virtual void update_borders();
void update_borders();
/// update
virtual void update_contents();
/// build the dialog
virtual void build_dialog();
void update_contents();
/// save some values before closing the gui
virtual void closeGUI();
void closeGUI();
};
} // namespace frontend

View File

@ -11,77 +11,64 @@
#include <config.h>
#include "GuiTabularCreate.h"
#include "ControlTabularCreate.h"
#include "EmptyTable.h"
#include <QCloseEvent>
#include <QSpinBox>
#include <QPushButton>
namespace lyx {
namespace frontend {
/////////////////////////////////////////////////////////////////////
//
// GuiTabularCreateDialog
//
/////////////////////////////////////////////////////////////////////
GuiTabularCreateDialog::GuiTabularCreateDialog(GuiTabularCreate * form)
: form_(form)
GuiTabularCreateDialog::GuiTabularCreateDialog(LyXView & lv)
: GuiDialog(lv, "tabularcreate")
{
setupUi(this);
setViewTitle(_("Insert Table"));
setController(new ControlTabularCreate(*this));
rowsSB->setValue(5);
columnsSB->setValue(5);
connect(okPB, SIGNAL(clicked()), form_, SLOT(slotOK()));
connect(closePB, SIGNAL(clicked()), form_, SLOT(slotClose()));
connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
connect(rowsSB, SIGNAL(valueChanged(int)),
this, SLOT(rowsChanged(int)));
connect(columnsSB, SIGNAL(valueChanged(int)),
this, SLOT(columnsChanged(int)));
bc().setPolicy(ButtonPolicy::IgnorantPolicy);
bc().setOK(okPB);
bc().setCancel(closePB);
}
ControlTabularCreate & GuiTabularCreateDialog::controller() const
{
return static_cast<ControlTabularCreate &>(Dialog::controller());
}
void GuiTabularCreateDialog::columnsChanged(int)
{
form_->changed();
changed();
}
void GuiTabularCreateDialog::rowsChanged(int)
{
form_->changed();
changed();
}
/////////////////////////////////////////////////////////////////////
//
// GuiTabularCreate
//
/////////////////////////////////////////////////////////////////////
GuiTabularCreate::GuiTabularCreate(GuiDialog & parent)
: GuiView<GuiTabularCreateDialog>(parent, _("Insert Table"))
void GuiTabularCreateDialog::applyView()
{
}
void GuiTabularCreate::build_dialog()
{
dialog_.reset(new GuiTabularCreateDialog(this));
bc().setOK(dialog_->okPB);
bc().setCancel(dialog_->closePB);
}
void GuiTabularCreate::applyView()
{
controller().params().first = dialog_->rowsSB->value();
controller().params().second = dialog_->columnsSB->value();
controller().params().first = rowsSB->value();
controller().params().second = columnsSB->value();
}
} // namespace frontend

View File

@ -12,50 +12,30 @@
#ifndef GUITABULARCREATE_H
#define GUITABULARCREATE_H
#include "GuiDialogView.h"
#include "GuiDialog.h"
#include "ControlTabularCreate.h"
#include "ui_TabularCreateUi.h"
#include <QDialog>
namespace lyx {
namespace frontend {
class GuiTabularCreate;
class GuiTabularCreateDialog : public QDialog, public Ui::TabularCreateUi
class GuiTabularCreateDialog : public GuiDialog, public Ui::TabularCreateUi
{
Q_OBJECT
public:
GuiTabularCreateDialog(GuiTabularCreate * form);
protected Q_SLOTS:
virtual void columnsChanged(int);
virtual void rowsChanged(int);
private:
GuiTabularCreate * form_;
};
class GuiTabularCreate : public GuiView<GuiTabularCreateDialog>
{
public:
///
friend class GuiTabularCreateDialog;
///
GuiTabularCreate(GuiDialog &);
GuiTabularCreateDialog(LyXView & lv);
private Q_SLOTS:
void columnsChanged(int);
void rowsChanged(int);
/// parent controller
ControlTabularCreate & controller()
{ return static_cast<ControlTabularCreate &>(this->getController()); }
/// parent controller
ControlTabularCreate const & controller() const
{ return static_cast<ControlTabularCreate const &>(this->getController()); }
ControlTabularCreate & controller() const;
private:
/// Apply changes
virtual void applyView();
/// update
virtual void update_contents() {}
/// build the dialog
virtual void build_dialog();
void applyView();
};
} // namespace frontend

View File

@ -11,6 +11,8 @@
#include <config.h>
#include "GuiTexinfo.h"
#include "ControlTexinfo.h"
#include "qt_helpers.h"
#include "support/filetools.h"
@ -23,22 +25,21 @@
using std::string;
using std::vector;
namespace lyx {
namespace frontend {
/////////////////////////////////////////////////////////////////////
//
// GuiTexinfoDialog
//
/////////////////////////////////////////////////////////////////////
GuiTexinfoDialog::GuiTexinfoDialog(GuiTexinfo * form)
: form_(form)
GuiTexinfoDialog::GuiTexinfoDialog(LyXView & lv)
: GuiDialog(lv, "texinfo")
{
setupUi(this);
setViewTitle(_("TeX Information"));
setController(new ControlTexinfo(*this));
connect(closePB, SIGNAL(clicked()), form, SLOT(slotClose()));
warningPosted = false;
activeStyle = ControlTexinfo::cls;
connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
connect(viewPB, SIGNAL(clicked()), this, SLOT(viewClicked()));
connect(whatStyleCO, SIGNAL(activated(const QString &)),
@ -48,21 +49,32 @@ GuiTexinfoDialog::GuiTexinfoDialog(GuiTexinfo * form)
connect(rescanPB, SIGNAL(clicked()), this, SLOT(enableViewPB()));
connect(rescanPB, SIGNAL(clicked()), this, SLOT(rescanClicked()));
connect(fileListLW, SIGNAL(itemClicked(QListWidgetItem *)),
this, SLOT( enableViewPB() ) );
this, SLOT(enableViewPB()));
connect(fileListLW, SIGNAL(itemSelectionChanged()),
this, SLOT(enableViewPB()));
updateStyles(ControlTexinfo::cls);
bc().setPolicy(ButtonPolicy::OkCancelPolicy);
bc().setCancel(closePB);
}
ControlTexinfo & GuiTexinfoDialog::controller() const
{
return static_cast<ControlTexinfo &>(Dialog::controller());
}
void GuiTexinfoDialog::change_adaptor()
{
form_->changed();
changed();
}
void GuiTexinfoDialog::closeEvent(QCloseEvent * e)
{
form_->slotWMHide();
slotWMHide();
e->accept();
}
@ -71,7 +83,7 @@ void GuiTexinfoDialog::rescanClicked()
{
// build new *Files.lst
rescanTexStyles();
form_->updateStyles();
updateStyles();
enableViewPB();
}
@ -79,29 +91,29 @@ void GuiTexinfoDialog::rescanClicked()
void GuiTexinfoDialog::viewClicked()
{
size_t const fitem = fileListLW->currentRow();
vector<string> const & data = form_->texdata_[form_->activeStyle];
vector<string> const & data = texdata_[activeStyle];
string file = data[fitem];
if (!pathCB->isChecked())
file = getTexFileFromList(data[fitem],
form_->controller().getFileType(form_->activeStyle));
form_->controller().viewFile(file);
controller().getFileType(activeStyle));
controller().viewFile(file);
}
void GuiTexinfoDialog::updateView()
{
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;
case 0:
updateStyles(ControlTexinfo::cls);
break;
case 1:
updateStyles(ControlTexinfo::sty);
break;
case 2:
updateStyles(ControlTexinfo::bst);
break;
default:
break;
}
enableViewPB();
@ -114,48 +126,24 @@ void GuiTexinfoDialog::enableViewPB()
}
/////////////////////////////////////////////////////////////////////
//
// GuiTexinfo
//
/////////////////////////////////////////////////////////////////////
GuiTexinfo::GuiTexinfo(GuiDialog & parent)
: GuiView<GuiTexinfoDialog>(parent, _("TeX Information")),
warningPosted(false), activeStyle(ControlTexinfo::cls)
{
}
void GuiTexinfo::build_dialog()
{
dialog_.reset(new GuiTexinfoDialog(this));
updateStyles(ControlTexinfo::cls);
bc().setCancel(dialog_->closePB);
}
void GuiTexinfo::updateStyles(ControlTexinfo::texFileSuffix whichStyle)
void GuiTexinfoDialog::updateStyles(ControlTexinfo::texFileSuffix whichStyle)
{
ContentsType & data = texdata_[whichStyle];
bool const withFullPath = dialog_->pathCB->isChecked();
bool const withFullPath = pathCB->isChecked();
getTexFileList(whichStyle, data, withFullPath);
dialog_->fileListLW->clear();
fileListLW->clear();
ContentsType::const_iterator it = data.begin();
ContentsType::const_iterator end = data.end();
for (; it != end; ++it)
dialog_->fileListLW->addItem(toqstr(*it));
fileListLW->addItem(toqstr(*it));
activeStyle = whichStyle;
}
void GuiTexinfo::updateStyles()
void GuiTexinfoDialog::updateStyles()
{
updateStyles(activeStyle);
}

View File

@ -9,63 +9,40 @@
* Full author contact details are available in file CREDITS.
*/
#ifndef QTEXINFO_H
#define QTEXINFO_H
#ifndef GUITEXINFO_H
#define GUITEXINFO_H
#include "GuiDialogView.h"
#include "GuiDialog.h"
#include "ControlTexinfo.h"
#include "ui_TexinfoUi.h"
#include <QDialog>
#include <map>
#include <vector>
namespace lyx {
namespace frontend {
class GuiTexinfo;
class GuiTexinfoDialog : public QDialog, public Ui::TexinfoUi
class GuiTexinfoDialog : public GuiDialog, public Ui::TexinfoUi
{
Q_OBJECT
public:
GuiTexinfoDialog(GuiTexinfo * form);
GuiTexinfoDialog(LyXView & lv);
public Q_SLOTS:
virtual void updateView();
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_;
};
void updateView();
private Q_SLOTS:
void change_adaptor();
void rescanClicked();
void viewClicked();
void enableViewPB();
///
class GuiTexinfo : public GuiView<GuiTexinfoDialog>
{
public:
///
friend class GuiTexinfoDialog;
///
GuiTexinfo(GuiDialog &);
/// parent controller
ControlTexinfo & controller()
{ return static_cast<ControlTexinfo &>(this->getController()); }
/// parent controller
ControlTexinfo const & controller() const
{ return static_cast<ControlTexinfo const &>(this->getController()); }
private:
/// Apply changes
virtual void applyView() {}
/// update (do we need this?)
virtual void update_contents() {}
/// build the dialog
virtual void build_dialog();
///
void closeEvent(QCloseEvent * e);
///
ControlTexinfo & controller() const;
///
void updateStyles(ControlTexinfo::texFileSuffix);
///
@ -82,4 +59,4 @@ private:
} // namespace frontend
} // namespace lyx
#endif // QTEXINFO_H
#endif // GUITEXINFO_H

View File

@ -11,6 +11,8 @@
#include <config.h>
#include "GuiThesaurus.h"
#include "ControlThesaurus.h"
#include "qt_helpers.h"
#include "debug.h"
@ -23,25 +25,22 @@
using std::string;
namespace lyx {
namespace frontend {
/////////////////////////////////////////////////////////////////////
//
// QTheasurusDialog
//
/////////////////////////////////////////////////////////////////////
GuiThesaurusDialog::GuiThesaurusDialog(GuiThesaurus * form)
: form_(form)
GuiThesaurusDialog::GuiThesaurusDialog(LyXView & lv)
: GuiDialog(lv, "thesaurus")
{
setupUi(this);
setViewTitle(_("Thesaurus"));
setController(new ControlThesaurus(*this));
meaningsTV->setColumnCount(1);
meaningsTV->header()->hide();
connect(closePB, SIGNAL(clicked()),
form, SLOT(slotClose()));
this, SLOT(slotClose()));
connect(replaceED, SIGNAL(returnPressed()),
this, SLOT(replaceClicked()));
connect(replaceED, SIGNAL(textChanged(const QString &)),
@ -56,18 +55,29 @@ GuiThesaurusDialog::GuiThesaurusDialog(GuiThesaurus * form)
this, SLOT(selectionChanged()));
connect(meaningsTV, SIGNAL(itemActivated(QTreeWidgetItem *, int)),
this, SLOT(selectionClicked(QTreeWidgetItem *, int)));
bc().setCancel(closePB);
bc().setApply(replacePB);
bc().addReadOnly(replaceED);
bc().addReadOnly(replacePB);
bc().setPolicy(ButtonPolicy::OkApplyCancelReadOnlyPolicy);
}
ControlThesaurus & GuiThesaurusDialog::controller() const
{
return static_cast<ControlThesaurus &>(Dialog::controller());
}
void GuiThesaurusDialog::change_adaptor()
{
form_->changed();
changed();
}
void GuiThesaurusDialog::closeEvent(QCloseEvent * e)
{
form_->slotWMHide();
slotWMHide();
e->accept();
}
@ -78,21 +88,15 @@ void GuiThesaurusDialog::entryChanged()
}
void GuiThesaurusDialog::replaceClicked()
{
form_->replace();
}
void GuiThesaurusDialog::selectionChanged()
{
int const col = meaningsTV->currentColumn();
if (col<0 || form_->readOnly())
if (col<0 || readOnly())
return;
replaceED->setText(meaningsTV->currentItem()->text(col));
replacePB->setEnabled(true);
form_->changed();
changed();
}
@ -115,7 +119,7 @@ void GuiThesaurusDialog::updateLists()
meaningsTV->clear();
meaningsTV->setUpdatesEnabled(false);
Thesaurus::Meanings meanings = form_->controller().getMeanings(qstring_to_ucs4(entryED->text()));
Thesaurus::Meanings meanings = controller().getMeanings(qstring_to_ucs4(entryED->text()));
for (Thesaurus::Meanings::const_iterator cit = meanings.begin();
cit != meanings.end(); ++cit) {
@ -134,40 +138,17 @@ void GuiThesaurusDialog::updateLists()
}
/////////////////////////////////////////////////////////////////////
//
// GuiThesaurus
//
/////////////////////////////////////////////////////////////////////
GuiThesaurus::GuiThesaurus(GuiDialog & parent)
: GuiView<GuiThesaurusDialog>(parent, _("Thesaurus"))
void GuiThesaurusDialog::update_contents()
{
entryED->setText(toqstr(controller().text()));
replaceED->setText("");
updateLists();
}
void GuiThesaurus::build_dialog()
void GuiThesaurusDialog::replaceClicked()
{
dialog_.reset(new GuiThesaurusDialog(this));
bc().setCancel(dialog_->closePB);
bc().setApply(dialog_->replacePB);
bc().addReadOnly(dialog_->replaceED);
bc().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()));
controller().replace(qstring_to_ucs4(replaceED->text()));
}
} // namespace frontend

View File

@ -12,67 +12,38 @@
#ifndef GUITHESAURUS_H
#define GUITHESAURUS_H
#include "GuiDialogView.h"
#include "GuiDialog.h"
#include "ControlThesaurus.h"
#include "ui_ThesaurusUi.h"
#include <QDialog>
class QTreeWidgetItem;
namespace lyx {
namespace frontend {
class ControlThesaurus;
class GuiThesaurus;
class GuiThesaurusDialog : public QDialog, public Ui::ThesaurusUi
class GuiThesaurusDialog : public GuiDialog, public Ui::ThesaurusUi
{
Q_OBJECT
public:
GuiThesaurusDialog(GuiThesaurus * form);
GuiThesaurusDialog(LyXView & lv);
private Q_SLOTS:
void change_adaptor();
void entryChanged();
void replaceClicked();
void selectionChanged();
void selectionClicked(QTreeWidgetItem *, int);
void itemClicked(QTreeWidgetItem *, int);
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 GuiView<GuiThesaurusDialog>
{
public:
///
friend class GuiThesaurusDialog;
///
GuiThesaurus(GuiDialog &);
void closeEvent(QCloseEvent * e);
/// parent controller
ControlThesaurus & controller()
{ return static_cast<ControlThesaurus &>(this->getController()); }
/// parent controller
ControlThesaurus const & controller() const
{ return static_cast<ControlThesaurus const &>(this->getController()); }
private:
/// Apply changes
virtual void applyView() {}
ControlThesaurus & controller() const;
/// update
virtual void update_contents();
/// build the dialog
virtual void build_dialog();
/// replace the word
void replace();
void update_contents();
///
void updateLists();
};
} // namespace frontend

View File

@ -32,9 +32,26 @@ namespace lyx {
namespace frontend {
GuiToc::GuiToc(Dialog & dialog, QObject * parent)
: QObject(parent), ControlToc(dialog)
GuiToc::GuiToc(LyXView & lv)
: GuiDialog(lv, "toc")
{
setViewTitle(_("Outline"));
setController(new ControlToc(*this));
#ifdef Q_WS_MACX
// On Mac show as a drawer at the right
//setView(new DockView<GuiToc, TocWidget>(
// *dialog, qtoc, &gui_view, _("Outline"), Qt::RightDockWidgetArea, Qt::Drawer));
#else
//setView(new DockView<GuiToc, TocWidget>(
// *dialog, qtoc, &gui_view, _("Outline")));
#endif
bc().setPolicy(ButtonPolicy::OkCancelPolicy);
}
ControlToc & GuiToc::controller() const
{
return static_cast<ControlToc &>(Dialog::controller());
}
@ -43,7 +60,7 @@ bool GuiToc::canOutline(int type) const
if (type < 0)
return false;
return ControlToc::canOutline(type);
return controller().canOutline(type);
}
@ -86,7 +103,7 @@ QModelIndex const GuiToc::getCurrentIndex(int type) const
if(!canOutline(type))
return QModelIndex();
return toc_models_[type]->modelIndex(getCurrentTocItem(type));
return toc_models_[type]->modelIndex(controller().getCurrentTocItem(type));
}
@ -106,13 +123,13 @@ void GuiToc::goTo(int type, QModelIndex const & index)
LYXERR(Debug::GUI) << "GuiToc::goTo " << to_utf8(it->str()) << endl;
ControlToc::goTo(*it);
controller().goTo(*it);
}
bool GuiToc::initialiseParams(std::string const & data)
{
if (!ControlToc::initialiseParams(data))
if (!controller().initialiseParams(data))
return false;
updateView();
modelReset();
@ -123,8 +140,8 @@ bool GuiToc::initialiseParams(std::string const & data)
void GuiToc::updateView()
{
toc_models_.clear();
TocList::const_iterator it = tocs().begin();
TocList::const_iterator end = tocs().end();
TocList::const_iterator it = controller().tocs().begin();
TocList::const_iterator end = controller().tocs().end();
for (; it != end; ++it)
toc_models_.push_back(new TocModel(it->second));
}

View File

@ -14,6 +14,7 @@
#ifndef GUITOC_H
#define GUITOC_H
#include "GuiDialog.h"
#include "ControlToc.h"
#include <QObject>
@ -23,16 +24,15 @@
namespace lyx {
namespace frontend {
class ControlToc;
class TocModel;
class GuiToc : public QObject, public ControlToc
class GuiToc : public GuiDialog
{
Q_OBJECT
public:
GuiToc(Dialog &, QObject * parent = 0);
virtual ~GuiToc() {}
public:
///
GuiToc(LyXView & lv);
/// \c ControlToc inherited method.
virtual bool initialiseParams(std::string const & data);
@ -51,6 +51,8 @@ public:
///
int getTocDepth(int type);
ControlToc & controller() const;
Q_SIGNALS:
/// Signal that the internal toc_models_ has been reset.
void modelReset();

View File

@ -39,7 +39,8 @@ class GuiViewBase;
class Action;
class GuiLayoutBox : public QObject, public LayoutBox {
class GuiLayoutBox : public QObject, public LayoutBox
{
Q_OBJECT
public:
GuiLayoutBox(QToolBar *, GuiViewBase &);
@ -64,7 +65,8 @@ private:
};
class GuiToolbar : public QToolBar, public Toolbar {
class GuiToolbar : public QToolBar, public Toolbar
{
Q_OBJECT
public:
GuiToolbar(ToolbarInfo const &, GuiViewBase &);

Some files were not shown because too many files have changed in this diff Show More