From: Angus Leeming Date: Thu, 12 May 2005 22:37:43 +0000 (+0000) Subject: Make the Qt Alert boxes recognize their parent. X-Git-Tag: 1.6.10~14293 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=a8a852b4e99cdbbb5a1c866e495361a06f284cd2;p=features.git Make the Qt Alert boxes recognize their parent. Lots of gratuitous changes that should not alter Lyx's behaviour. ************************************************************************** You're all going to get failure on link. Please "rm -f lengthvalidator.*". ************************************************************************** git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9940 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/po/POTFILES.in b/po/POTFILES.in index 162e37752b..081a530718 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -107,6 +107,7 @@ src/frontends/qt2/QWrap.C src/frontends/qt2/Qt2BC.h src/frontends/qt2/QtView.C src/frontends/qt2/floatplacement.C +src/frontends/qt2/validators.C src/frontends/xforms/Alert_pimpl.C src/frontends/xforms/ColorHandler.C src/frontends/xforms/Dialogs.C diff --git a/src/frontends/controllers/ChangeLog b/src/frontends/controllers/ChangeLog index c0308b48b8..ae17a736fa 100644 --- a/src/frontends/controllers/ChangeLog +++ b/src/frontends/controllers/ChangeLog @@ -1,3 +1,8 @@ +2005-05-08 Angus Leeming + + * Kernel.h (KernelDocType): wrapper class for the Kernel::DocTypes + enum. + 2005-05-07 Michael Schmitt * ControlRef.C: rename LFUN_REF_GOTO to LFUN_LABEL_GOTO diff --git a/src/frontends/controllers/Kernel.C b/src/frontends/controllers/Kernel.C index 327ede82f3..b4a0e57c1f 100644 --- a/src/frontends/controllers/Kernel.C +++ b/src/frontends/controllers/Kernel.C @@ -69,7 +69,7 @@ string const Kernel::bufferFilepath() const } -Kernel::DocTypes Kernel::docType() const +Kernel::DocType Kernel::docType() const { if (buffer().isLatex()) return LATEX; diff --git a/src/frontends/controllers/Kernel.h b/src/frontends/controllers/Kernel.h index 1bc7461f89..f046c7f150 100644 --- a/src/frontends/controllers/Kernel.h +++ b/src/frontends/controllers/Kernel.h @@ -64,18 +64,18 @@ public: std::string const bufferFilepath() const; //@} - /** \enum DocTypes used to flag the different kinds of buffer + /** \enum DocType used to flag the different kinds of buffer * without making the kernel header files available to the * dialog's Controller or View. */ - enum DocTypes { + enum DocType { LATEX, LITERATE, LINUXDOC, DOCBOOK }; /// The type of the current buffer. - DocTypes docType() const; + DocType docType() const; /** A request that the GUI be redrawn, * e.g. because the colors have been remapped. @@ -101,6 +101,19 @@ private: LyXView & lyxview_; }; + +/** \c KernelDocType is a wrapper for Kernel::DocType. + * It can be forward-declared and passed as a function argument without + * having to expose Kernel.h. + */ +class KernelDocType { +public: + KernelDocType(Kernel::DocType val) : val_(val) {} + operator Kernel::DocType() const { return val_; } +private: + Kernel::DocType val_; +}; + } // namespace frontend } // namespace lyx diff --git a/src/frontends/qt2/Alert_pimpl.C b/src/frontends/qt2/Alert_pimpl.C index 10197ea63f..3dadee0320 100644 --- a/src/frontends/qt2/Alert_pimpl.C +++ b/src/frontends/qt2/Alert_pimpl.C @@ -18,6 +18,7 @@ #include "gettext.h" +#include #include #include #include @@ -37,9 +38,16 @@ int prompt_pimpl(string const & tit, string const & question, { string const title = bformat(_("LyX: %1$s"), tit); - int res = QMessageBox::information(0, toqstr(title), toqstr(formatted(question)), - toqstr(b1), toqstr(b2), b3.empty() ? QString::null : toqstr(b3), - default_button, cancel_button); + QWidget * const parent = qApp->focusWidget() ? + qApp->focusWidget() : qApp->mainWidget(); + + int res = QMessageBox::information(parent, + toqstr(title), + toqstr(formatted(question)), + toqstr(b1), + toqstr(b2), + b3.empty() ? QString::null : toqstr(b3), + default_button, cancel_button); // Qt bug: can return -1 on cancel or WM close, despite the docs. if (res == -1) @@ -50,30 +58,48 @@ int prompt_pimpl(string const & tit, string const & question, void warning_pimpl(string const & tit, string const & message) { + QWidget * const parent = qApp->focusWidget() ? + qApp->focusWidget() : qApp->mainWidget(); + string const title = bformat(_("LyX: %1$s"), tit); - QMessageBox::warning(0, toqstr(title), toqstr(formatted(message))); + QMessageBox::warning(parent, + toqstr(title), + toqstr(formatted(message))); } void error_pimpl(string const & tit, string const & message) { + QWidget * const parent = qApp->focusWidget() ? + qApp->focusWidget() : qApp->mainWidget(); + string const title = bformat(_("LyX: %1$s"), tit); - QMessageBox::critical(0, toqstr(title), toqstr(formatted(message))); + QMessageBox::critical(parent, + toqstr(title), + toqstr(formatted(message))); } void information_pimpl(string const & tit, string const & message) { + QWidget * const parent = qApp->focusWidget() ? + qApp->focusWidget() : qApp->mainWidget(); + string const title = bformat(_("LyX: %1$s"), tit); - QMessageBox::information(0, toqstr(title), toqstr(formatted(message))); + QMessageBox::information(parent, + toqstr(title), + toqstr(formatted(message))); } pair const askForText_pimpl(string const & msg, string const & dflt) { + QWidget * const parent = qApp->focusWidget() ? + qApp->focusWidget() : qApp->mainWidget(); + string const title = bformat(_("LyX: %1$s"), msg); - QAskForTextDialog d(0, toqstr(title), true); + QAskForTextDialog d(parent, toqstr(title), true); // less than ideal ! d.askLA->setText(toqstr('&' + msg)); d.askLE->setText(toqstr(dflt)); diff --git a/src/frontends/qt2/ChangeLog b/src/frontends/qt2/ChangeLog index 152374fca5..4138277ac1 100644 --- a/src/frontends/qt2/ChangeLog +++ b/src/frontends/qt2/ChangeLog @@ -1,3 +1,22 @@ +2005-05-07 Angus Leeming + + * Alert_pimpl.C (prompt_pimpl, warning_pimpl, error_pimpl) + (information_pimpl, askForText_pimpl): make these warning dialogs + modal with respect to the calling dialog, rather than with respect + to the main window. + + * lengthvalidator.[Ch]: removed. + * validators.[Ch]: added. + * Makefile.dialogs: remove lengthvalidator.[Ch]. Add validators.[Ch]. + + * QBoxDialog.C (unsignedLengthValidator): + * QDocumentDialog.C (unsignedLengthValidator): + * QExternalDialog.C (unsignedLengthValidator): + * QGraphicsDialog.C (unsignedLengthValidator): + * QTabularDialog.C (unsignedLengthValidator): + * QVSpaceDialog.C (unsignedLengthValidator): + removed. Use the version in validators.C. + 2005-05-12 Jean-Marc Lasgouttes * QLPopupMenu.C (fire): use lyx_gui::sync_events. @@ -47,7 +66,7 @@ 2005-05-02 Jürgen Spitzmüller - * QTabularDialog.C: correcht handling of the LFUN_UNSET_* + * QTabularDialog.C: correct handling of the LFUN_UNSET_* functions within longtabular. * ui/QTabularDialogBase.ui: add tooltips to longtabular tab. diff --git a/src/frontends/qt2/Makefile.dialogs b/src/frontends/qt2/Makefile.dialogs index 6fc0c196cc..a0f1bb3d99 100644 --- a/src/frontends/qt2/Makefile.dialogs +++ b/src/frontends/qt2/Makefile.dialogs @@ -126,5 +126,5 @@ MOCFILES = \ QVSpaceDialog.C QVSpaceDialog.h \ QWrapDialog.C QWrapDialog.h \ QLToolbar.C QLToolbar.h \ - lengthvalidator.C lengthvalidator.h \ - socket_callback.C socket_callback.h + socket_callback.C socket_callback.h \ + validators.C validators.h diff --git a/src/frontends/qt2/QBoxDialog.C b/src/frontends/qt2/QBoxDialog.C index 6cb449572c..6bd909759a 100644 --- a/src/frontends/qt2/QBoxDialog.C +++ b/src/frontends/qt2/QBoxDialog.C @@ -13,7 +13,7 @@ #include "QBoxDialog.h" #include "lengthcombo.h" -#include "lengthvalidator.h" +#include "validators.h" #include "QBox.h" #include "qt_helpers.h" @@ -24,18 +24,6 @@ namespace lyx { namespace frontend { -namespace { - -LengthValidator * unsignedLengthValidator(QLineEdit * ed) -{ - LengthValidator * v = new LengthValidator(ed); - v->setBottom(LyXLength()); - return v; -} - -} // namespace anon - - QBoxDialog::QBoxDialog(QBox * form) : QBoxDialogBase(0, 0, false, 0), form_(form) diff --git a/src/frontends/qt2/QDocumentDialog.C b/src/frontends/qt2/QDocumentDialog.C index daad83f66a..bcb30bad2e 100644 --- a/src/frontends/qt2/QDocumentDialog.C +++ b/src/frontends/qt2/QDocumentDialog.C @@ -15,7 +15,7 @@ #include "floatplacement.h" #include "lengthcombo.h" -#include "lengthvalidator.h" +#include "validators.h" #include "panelstack.h" #include "qt_helpers.h" @@ -48,18 +48,6 @@ namespace lyx { namespace frontend { -namespace { - -LengthValidator * unsignedLengthValidator(QLineEdit * ed) -{ - LengthValidator * v = new LengthValidator(ed); - v->setBottom(LyXLength()); - return v; -} - -} // namespace anon - - QDocumentDialog::QDocumentDialog(QDocument * form) : QDocumentDialogBase(0, 0, false, 0), form_(form) { diff --git a/src/frontends/qt2/QExternalDialog.C b/src/frontends/qt2/QExternalDialog.C index 39f3fa8367..c951728856 100644 --- a/src/frontends/qt2/QExternalDialog.C +++ b/src/frontends/qt2/QExternalDialog.C @@ -25,7 +25,7 @@ #include "QExternalDialog.h" #include "lengthcombo.h" -#include "lengthvalidator.h" +#include "validators.h" #include "qt_helpers.h" #include "QExternal.h" @@ -35,7 +35,7 @@ #include #include #include -#include + using lyx::support::float_equal; using lyx::support::isStrDbl; @@ -44,18 +44,6 @@ using std::string; namespace lyx { namespace frontend { -namespace { - -LengthValidator * unsignedLengthValidator(QLineEdit * ed) -{ - LengthValidator * v = new LengthValidator(ed); - v->setBottom(LyXLength()); - return v; -} - -} // namespace anon - - QExternalDialog::QExternalDialog(QExternal * form) : QExternalDialogBase(0, 0, false, 0), form_(form) diff --git a/src/frontends/qt2/QGraphicsDialog.C b/src/frontends/qt2/QGraphicsDialog.C index 09b598ef74..efc2c99d33 100644 --- a/src/frontends/qt2/QGraphicsDialog.C +++ b/src/frontends/qt2/QGraphicsDialog.C @@ -15,7 +15,7 @@ #include "QGraphics.h" #include "lengthcombo.h" -#include "lengthvalidator.h" +#include "validators.h" #include "qt_helpers.h" #include "debug.h" @@ -33,18 +33,6 @@ namespace lyx { namespace frontend { -namespace { - -LengthValidator * unsignedLengthValidator(QLineEdit * ed) -{ - LengthValidator * v = new LengthValidator(ed); - v->setBottom(LyXLength()); - return v; -} - -} // namespace anon - - QGraphicsDialog::QGraphicsDialog(QGraphics * form) : QGraphicsDialogBase(0, 0, false, 0), form_(form) diff --git a/src/frontends/qt2/QRef.C b/src/frontends/qt2/QRef.C index 0093a49822..0b6deff123 100644 --- a/src/frontends/qt2/QRef.C +++ b/src/frontends/qt2/QRef.C @@ -116,7 +116,7 @@ void QRef::apply() bool QRef::nameAllowed() { - Kernel::DocTypes doc_type = kernel().docType(); + Kernel::DocType const doc_type = kernel().docType(); return doc_type != Kernel::LATEX && doc_type != Kernel::LITERATE; } @@ -124,7 +124,7 @@ bool QRef::nameAllowed() bool QRef::typeAllowed() { - Kernel::DocTypes doc_type = kernel().docType(); + Kernel::DocType const doc_type = kernel().docType(); return doc_type != Kernel::LINUXDOC && doc_type != Kernel::DOCBOOK; } diff --git a/src/frontends/qt2/QTabularDialog.C b/src/frontends/qt2/QTabularDialog.C index 9f081b68ad..b1fafff8bb 100644 --- a/src/frontends/qt2/QTabularDialog.C +++ b/src/frontends/qt2/QTabularDialog.C @@ -14,7 +14,7 @@ #include "QTabularDialog.h" #include "QTabular.h" -#include "lengthvalidator.h" +#include "validators.h" #include "qt_helpers.h" #include "controllers/ControlTabular.h" @@ -29,18 +29,6 @@ namespace lyx { namespace frontend { -namespace { - -LengthValidator * unsignedLengthValidator(QLineEdit * ed) -{ - LengthValidator * v = new LengthValidator(ed); - v->setBottom(LyXLength()); - return v; -} - -} // namespace anon - - QTabularDialog::QTabularDialog(QTabular * form) : QTabularDialogBase(0, 0, false, 0), form_(form) diff --git a/src/frontends/qt2/QVSpaceDialog.C b/src/frontends/qt2/QVSpaceDialog.C index 39daee67c9..ab1feede1c 100644 --- a/src/frontends/qt2/QVSpaceDialog.C +++ b/src/frontends/qt2/QVSpaceDialog.C @@ -16,7 +16,7 @@ #include "QVSpace.h" #include "lengthcombo.h" -#include "lengthvalidator.h" +#include "validators.h" #include "qt_helpers.h" #include @@ -29,18 +29,6 @@ namespace lyx { namespace frontend { -namespace { - -LengthValidator * unsignedLengthValidator(QLineEdit * ed) -{ - LengthValidator * v = new LengthValidator(ed); - v->setBottom(LyXGlueLength()); - return v; -} - -} // namespace anon - - QVSpaceDialog::QVSpaceDialog(QVSpace * form) : QVSpaceDialogBase(0, 0, false, 0), form_(form) diff --git a/src/frontends/qt2/lengthvalidator.C b/src/frontends/qt2/lengthvalidator.C deleted file mode 100644 index c7625b4e90..0000000000 --- a/src/frontends/qt2/lengthvalidator.C +++ /dev/null @@ -1,69 +0,0 @@ -/** - * \file lengthvalidator.C - * 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 - -#include "lengthvalidator.h" -#include "qt_helpers.h" - -#include "support/lstrings.h" - -#include - - -using lyx::support::isStrDbl; -using std::string; - - -LengthValidator::LengthValidator(QWidget * parent, const char * name) - : QValidator(parent, name), - no_bottom_(true), glue_length_(false) -{} - - -QValidator::State LengthValidator::validate(QString & qtext, int &) const -{ - string const text = fromqstr(qtext); - if (text.empty() || isStrDbl(text)) - return QValidator::Acceptable; - - if (glue_length_) { - LyXGlueLength gl; - return (isValidGlueLength(text, &gl)) ? - QValidator::Acceptable : QValidator::Intermediate; - } - - LyXLength l; - bool const valid_length = isValidLength(text, &l); - if (!valid_length) - return QValidator::Intermediate; - - if (no_bottom_) - return QValidator::Acceptable; - - return b_.inPixels(100) <= l.inPixels(100) ? - QValidator::Acceptable : QValidator::Intermediate; -} - - -void LengthValidator::setBottom(LyXLength const & b) -{ - b_ = b; - no_bottom_ = false; -} - - -void LengthValidator::setBottom(LyXGlueLength const & g) -{ - g_ = g; - no_bottom_ = false; - glue_length_ = true; -} diff --git a/src/frontends/qt2/lengthvalidator.h b/src/frontends/qt2/lengthvalidator.h deleted file mode 100644 index 9f60b9869c..0000000000 --- a/src/frontends/qt2/lengthvalidator.h +++ /dev/null @@ -1,46 +0,0 @@ -// -*- C++ -*- -/** - * \file lengthvalidator.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 LENGTHVALIDATOR_H -#define LENGTHVALIDATOR_H - -#include "lyxlength.h" -#include "lyxgluelength.h" -#include - -class QWidget; - - -class LengthValidator : public QValidator -{ - Q_OBJECT -public: - LengthValidator(QWidget * parent, const char *name = 0); - - QValidator::State validate(QString &, int &) const; - - void setBottom(LyXLength const &); - void setBottom(LyXGlueLength const &); - LyXLength bottom() const { return b_; } - -private: -#if defined(Q_DISABLE_COPY) - LengthValidator( const LengthValidator & ); - LengthValidator& operator=( const LengthValidator & ); -#endif - - LyXLength b_; - LyXGlueLength g_; - bool no_bottom_; - bool glue_length_; -}; - -# endif // NOT LENGTHVALIDATOR_H diff --git a/src/frontends/qt2/validators.C b/src/frontends/qt2/validators.C new file mode 100644 index 0000000000..87c47750e4 --- /dev/null +++ b/src/frontends/qt2/validators.C @@ -0,0 +1,169 @@ +/** + * \file validators.C + * 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 + +#include "validators.h" +#include "qt_helpers.h" + +#include "gettext.h" +#include "lyxrc.h" + +#include "frontends/Alert.h" + +#include "frontends/controllers/Dialog.h" + +#include "support/lstrings.h" +#include "support/std_ostream.h" + +#include +#include + +#include + +using lyx::support::isStrDbl; +using std::string; + + +LengthValidator::LengthValidator(QWidget * parent, const char * name) + : QValidator(parent, name), + no_bottom_(true), glue_length_(false) +{} + + +QValidator::State LengthValidator::validate(QString & qtext, int &) const +{ + string const text = fromqstr(qtext); + if (text.empty() || isStrDbl(text)) + return QValidator::Acceptable; + + if (glue_length_) { + LyXGlueLength gl; + return (isValidGlueLength(text, &gl)) ? + QValidator::Acceptable : QValidator::Intermediate; + } + + LyXLength l; + bool const valid_length = isValidLength(text, &l); + if (!valid_length) + return QValidator::Intermediate; + + if (no_bottom_) + return QValidator::Acceptable; + + return b_.inPixels(100) <= l.inPixels(100) ? + QValidator::Acceptable : QValidator::Intermediate; +} + + +void LengthValidator::setBottom(LyXLength const & b) +{ + b_ = b; + no_bottom_ = false; +} + + +void LengthValidator::setBottom(LyXGlueLength const & g) +{ + g_ = g; + no_bottom_ = false; + glue_length_ = true; +} + + +LengthValidator * unsignedLengthValidator(QLineEdit * ed) +{ + LengthValidator * v = new LengthValidator(ed); + v->setBottom(LyXLength()); + return v; +} + + +PathValidator::PathValidator(bool acceptable_if_empty, + QWidget * parent, const char * name) + : QValidator(parent, name), + acceptable_if_empty_(acceptable_if_empty), + latex_doc_(false), + tex_allows_spaces_(false) +{} + + +namespace { + +string const printable_list(string const & invalid_chars) +{ + std::ostringstream ss; + string::const_iterator const begin = invalid_chars.begin(); + string::const_iterator const end = invalid_chars.end(); + string::const_iterator it = begin; + + for (; it != end; ++it) { + if (it != begin) + ss << ", "; + if (*it == ' ') + ss << _("space"); + else + ss << *it; + } + + return ss.str(); +} + +} // namespace anon + + +QValidator::State PathValidator::validate(QString & qtext, int &) const +{ + if (!latex_doc_) + return QValidator::Acceptable; + + string const text = lyx::support::trim(fromqstr(qtext)); + if (text.empty()) + return acceptable_if_empty_ ? + QValidator::Acceptable : QValidator::Intermediate; + + string invalid_chars("#$%{}()[]:\"^"); + if (!tex_allows_spaces_) + invalid_chars += ' '; + + if (text.find_first_of(invalid_chars) != string::npos) { + + static int counter = 0; + if (counter == 0) { + Alert::error(_("Invalid filename"), + _("LyX does not provide LateX support for file names containing any of these characters:\n") + + printable_list(invalid_chars)); + } + ++counter; + return QValidator::Intermediate; + } + + return QValidator::Acceptable; +} + + +void PathValidator::setChecker(lyx::frontend::KernelDocType const & type, + LyXRC const & lyxrc) +{ + latex_doc_ = type == lyx::frontend::Kernel::LATEX; + tex_allows_spaces_ = lyxrc.tex_allows_spaces; +} + + +PathValidator * getPathValidator(QLineEdit * ed) +{ + if (!ed) + return 0; + QValidator * validator = const_cast(ed->validator()); + if (!validator) + return 0; + return dynamic_cast(validator); +} diff --git a/src/frontends/qt2/validators.h b/src/frontends/qt2/validators.h new file mode 100644 index 0000000000..56bcc77a51 --- /dev/null +++ b/src/frontends/qt2/validators.h @@ -0,0 +1,132 @@ +// -*- C++ -*- +/** + * \file validators.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. + * + * Validators are used to decide upon the legality of some input action. + * For example, a "line edit" widget might be used to input a "glue length". + * The correct syntax for such a length is "2em + 0.5em". The LengthValidator + * below will report whether the input text conforms to this syntax. + * + * This information is used in LyX primarily to give the user some + * feedback on the validity of the input data using the "checked_widget" + * concept. For example, if the data is invalid then the label of + * a "line edit" widget is changed in colour and the dialog's "Ok" + * and "Apply" buttons are disabled. See checked_widgets.[Ch] for + * further details. + */ + +#ifndef VALIDATORS_H +#define VALIDATORS_H + +#include "lyxlength.h" +#include "lyxgluelength.h" +#include + +class QWidget; +class QLineEdit; + + +/** A class to ascertain whether the data passed to the @c validate() + * member function can be interpretted as a LyXGlueLength. + */ +class LengthValidator : public QValidator +{ + Q_OBJECT +public: + /// Define a validator for widget @c parent. + LengthValidator(QWidget * parent, const char *name = 0); + + /** @returns QValidator::Acceptable if @c data is a LyXGlueLength. + * If not, returns QValidator::Intermediate. + */ + QValidator::State validate(QString & data, int &) const; + + /** @name Bottom + * Set and retrieve the minimum allowed LyXLength value. + */ + //@{ + void setBottom(LyXLength const &); + void setBottom(LyXGlueLength const &); + LyXLength bottom() const { return b_; } + //@} + +private: +#if defined(Q_DISABLE_COPY) + LengthValidator( const LengthValidator & ); + LengthValidator& operator=( const LengthValidator & ); +#endif + + LyXLength b_; + LyXGlueLength g_; + bool no_bottom_; + bool glue_length_; +}; + + +/// @returns a new @c LengthValidator that does not accept negative lengths. +LengthValidator * unsignedLengthValidator(QLineEdit *); + + +// Forward declarations +class LyXRC; + +namespace lyx { +namespace frontend { + +class KernelDocType; + +} // namespace frontend +} // namespace lyx + + +/** A class to ascertain whether the data passed to the @c validate() + * member function is a valid file path. + * The test is active only when the path is to be stored in a LaTeX + * file, LaTeX being quite picky about legal names. + */ +class PathValidator : public QValidator +{ + Q_OBJECT +public: + /** Define a validator for widget @c parent. + * If @c acceptable_if_empty is @c true then an empty path + * is regarded as acceptable. + */ + PathValidator(bool acceptable_if_empty, + QWidget * parent, const char *name = 0); + + /** @returns QValidator::Acceptable if @c data is a valid path. + * If not, returns QValidator::Intermediate. + */ + QValidator::State validate(QString &, int &) const; + + /** Define what checks that @c validate() will perform. + * @param doc_type checks are activated only for @c LATEX docs. + * @param lyxrc contains a @c tex_allows_spaces member that + * is used to define what is legal. + */ + void setChecker(lyx::frontend::KernelDocType const & doc_type, + LyXRC const & lyxrc); + +private: +#if defined(Q_DISABLE_COPY) + PathValidator( const PathValidator & ); + PathValidator& operator=( const PathValidator & ); +#endif + + bool acceptable_if_empty_; + bool latex_doc_; + bool tex_allows_spaces_; +}; + + +/// @returns the PathValidator attached to the widget, or 0. +PathValidator * getPathValidator(QLineEdit *); + +# endif // NOT VALIDATORS_H diff --git a/src/frontends/xforms/FormRef.C b/src/frontends/xforms/FormRef.C index 70ab49238f..43dce8a34c 100644 --- a/src/frontends/xforms/FormRef.C +++ b/src/frontends/xforms/FormRef.C @@ -98,7 +98,7 @@ void FormRef::update() switch_go_button(); // Name is irrelevant to LaTeX/Literate documents - Kernel::DocTypes doctype = kernel().docType(); + Kernel::DocType const doctype = kernel().docType(); if (doctype == Kernel::LATEX || doctype == Kernel::LITERATE) { setEnabled(dialog_->input_name, false); } else {