]> git.lyx.org Git - features.git/commitdiff
all CheckedWidgets are line edits...
authorAndré Pönitz <poenitz@gmx.net>
Sun, 2 Sep 2007 08:19:43 +0000 (08:19 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Sun, 2 Sep 2007 08:19:43 +0000 (08:19 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@19988 a592a061-630c-0410-9148-cb99ea01b6c8

16 files changed:
development/qmake/qt4/qt4.pro
development/scons/scons_manifest.py
po/POTFILES.in
src/frontends/qt4/CheckedLineEdit.cpp [deleted file]
src/frontends/qt4/CheckedLineEdit.h [deleted file]
src/frontends/qt4/GuiBibtex.cpp
src/frontends/qt4/GuiBox.cpp
src/frontends/qt4/GuiDocument.cpp
src/frontends/qt4/GuiExternal.cpp
src/frontends/qt4/GuiGraphics.cpp
src/frontends/qt4/GuiInclude.cpp
src/frontends/qt4/GuiTabular.cpp
src/frontends/qt4/GuiVSpace.cpp
src/frontends/qt4/Makefile.am
src/frontends/qt4/Qt2BC.cpp
src/frontends/qt4/Qt2BC.h

index 96a39bee125c89fc2c528c00973da9b38e427deb..d922829972bb0381be0201b31f7c08eb1f5d136f 100644 (file)
@@ -16,7 +16,6 @@ INC += src/frontends/qt4
 
 HPP += Action.h
 HPP += BulletsModule.h
-HPP += CheckedLineEdit.h
 HPP += ColorCache.h
 HPP += DockView.h
 HPP += EmptyTable.h
@@ -97,7 +96,6 @@ HPP += Validator.h
 CPP += Action.cpp
 CPP += alert_pimpl.cpp
 CPP += BulletsModule.cpp
-CPP += CheckedLineEdit.cpp
 CPP += ColorCache.cpp
 CPP += Dialogs.cpp
 CPP += EmptyTable.cpp
index fefad9f1c4d87206d3ee557975866c2bcdb1e245..9250ddbc64eb54127200e5733934870eb1f3bddb 100644 (file)
@@ -843,7 +843,6 @@ src_frontends_controllers_tests_regfiles_extra_files = Split('''
 src_frontends_qt4_header_files = Split('''
     Action.h
     BulletsModule.h
-    CheckedLineEdit.h
     ColorCache.h
     DockView.h
     EmptyTable.h
@@ -928,7 +927,6 @@ src_frontends_qt4_header_files = Split('''
 src_frontends_qt4_files = Split('''
     Action.cpp
     BulletsModule.cpp
-    CheckedLineEdit.cpp
     ColorCache.cpp
     Dialogs.cpp
     EmptyTable.cpp
index bcd9d336a9897f26ce17fef231439425e0ad29be..5bae5f35e4e579f02addc726099c46f3020c708d 100644 (file)
@@ -33,10 +33,171 @@ src/callback.cpp
 src/client/debug.cpp
 src/debug.cpp
 src/frontends/LyXView.cpp
+src/frontends/backup1/BulletsModule.cpp
+src/frontends/backup1/Dialogs.cpp
+src/frontends/backup1/FileDialog.cpp
+src/frontends/backup1/GuiAbout.cpp
+src/frontends/backup1/GuiApplication.cpp
+src/frontends/backup1/GuiBibitem.cpp
+src/frontends/backup1/GuiBibtex.cpp
+src/frontends/backup1/GuiBox.cpp
+src/frontends/backup1/GuiBranch.cpp
+src/frontends/backup1/GuiBranches.cpp
+src/frontends/backup1/GuiChanges.cpp
+src/frontends/backup1/GuiCharacter.cpp
+src/frontends/backup1/GuiCitation.cpp
+src/frontends/backup1/GuiCommandBuffer.cpp
+src/frontends/backup1/GuiDelimiter.cpp
+src/frontends/backup1/GuiDocument.cpp
+src/frontends/backup1/GuiERT.cpp
+src/frontends/backup1/GuiExternal.cpp
+src/frontends/backup1/GuiFloat.cpp
+src/frontends/backup1/GuiGraphics.cpp
+src/frontends/backup1/GuiInclude.cpp
+src/frontends/backup1/GuiListings.cpp
+src/frontends/backup1/GuiMathMatrix.cpp
+src/frontends/backup1/GuiNote.cpp
+src/frontends/backup1/GuiParagraph.cpp
+src/frontends/backup1/GuiPrefs.cpp
+src/frontends/backup1/GuiPrint.cpp
+src/frontends/backup1/GuiRef.cpp
+src/frontends/backup1/GuiSearch.cpp
+src/frontends/backup1/GuiSendto.cpp
+src/frontends/backup1/GuiShowFile.cpp
+src/frontends/backup1/GuiSpellchecker.cpp
+src/frontends/backup1/GuiTabular.cpp
+src/frontends/backup1/GuiTabularCreate.cpp
+src/frontends/backup1/GuiTexinfo.cpp
+src/frontends/backup1/GuiThesaurus.cpp
+src/frontends/backup1/GuiURL.cpp
+src/frontends/backup1/GuiVSpace.cpp
+src/frontends/backup1/GuiView.cpp
+src/frontends/backup1/GuiWrap.cpp
+src/frontends/backup1/IconPalette.cpp
+src/frontends/backup1/Qt2BC.h
+src/frontends/backup1/Validator.cpp
+src/frontends/backup1/alert_pimpl.cpp
+src/frontends/backup2/controllers/ControlAboutlyx.cpp
+src/frontends/backup2/controllers/ControlBibtex.cpp
+src/frontends/backup2/controllers/ControlBox.cpp
+src/frontends/backup2/controllers/ControlDocument.cpp
+src/frontends/backup2/controllers/ControlErrorList.cpp
+src/frontends/backup2/controllers/ControlExternal.cpp
+src/frontends/backup2/controllers/ControlGraphics.cpp
+src/frontends/backup2/controllers/ControlInclude.cpp
+src/frontends/backup2/controllers/ControlLog.cpp
+src/frontends/backup2/controllers/ControlPrefs.cpp
+src/frontends/backup2/controllers/ControlPrint.cpp
+src/frontends/backup2/controllers/ControlSpellchecker.cpp
+src/frontends/backup2/controllers/ControlToc.cpp
+src/frontends/backup2/controllers/frontend_helpers.cpp
+src/frontends/backup2/qt4/BulletsModule.cpp
+src/frontends/backup2/qt4/Dialogs.cpp
+src/frontends/backup2/qt4/FileDialog.cpp
+src/frontends/backup2/qt4/GuiAbout.cpp
+src/frontends/backup2/qt4/GuiApplication.cpp
+src/frontends/backup2/qt4/GuiBibitem.cpp
+src/frontends/backup2/qt4/GuiBibtex.cpp
+src/frontends/backup2/qt4/GuiBox.cpp
+src/frontends/backup2/qt4/GuiBranch.cpp
+src/frontends/backup2/qt4/GuiBranches.cpp
+src/frontends/backup2/qt4/GuiChanges.cpp
+src/frontends/backup2/qt4/GuiCharacter.cpp
+src/frontends/backup2/qt4/GuiCitation.cpp
+src/frontends/backup2/qt4/GuiCommandBuffer.cpp
+src/frontends/backup2/qt4/GuiDelimiter.cpp
+src/frontends/backup2/qt4/GuiDocument.cpp
+src/frontends/backup2/qt4/GuiERT.cpp
+src/frontends/backup2/qt4/GuiExternal.cpp
+src/frontends/backup2/qt4/GuiFloat.cpp
+src/frontends/backup2/qt4/GuiGraphics.cpp
+src/frontends/backup2/qt4/GuiInclude.cpp
+src/frontends/backup2/qt4/GuiListings.cpp
+src/frontends/backup2/qt4/GuiMathMatrix.cpp
+src/frontends/backup2/qt4/GuiNote.cpp
+src/frontends/backup2/qt4/GuiParagraph.cpp
+src/frontends/backup2/qt4/GuiPrefs.cpp
+src/frontends/backup2/qt4/GuiPrint.cpp
+src/frontends/backup2/qt4/GuiRef.cpp
+src/frontends/backup2/qt4/GuiSearch.cpp
+src/frontends/backup2/qt4/GuiSendto.cpp
+src/frontends/backup2/qt4/GuiShowFile.cpp
+src/frontends/backup2/qt4/GuiSpellchecker.cpp
+src/frontends/backup2/qt4/GuiTabular.cpp
+src/frontends/backup2/qt4/GuiTabularCreate.cpp
+src/frontends/backup2/qt4/GuiTexinfo.cpp
+src/frontends/backup2/qt4/GuiThesaurus.cpp
+src/frontends/backup2/qt4/GuiURL.cpp
+src/frontends/backup2/qt4/GuiVSpace.cpp
+src/frontends/backup2/qt4/GuiView.cpp
+src/frontends/backup2/qt4/GuiWrap.cpp
+src/frontends/backup2/qt4/IconPalette.cpp
+src/frontends/backup2/qt4/Qt2BC.h
+src/frontends/backup2/qt4/Validator.cpp
+src/frontends/backup2/qt4/alert_pimpl.cpp
+src/frontends/backup3/controllers/ControlAboutlyx.cpp
+src/frontends/backup3/controllers/ControlBibtex.cpp
+src/frontends/backup3/controllers/ControlBox.cpp
+src/frontends/backup3/controllers/ControlDocument.cpp
+src/frontends/backup3/controllers/ControlErrorList.cpp
+src/frontends/backup3/controllers/ControlExternal.cpp
+src/frontends/backup3/controllers/ControlGraphics.cpp
+src/frontends/backup3/controllers/ControlInclude.cpp
+src/frontends/backup3/controllers/ControlLog.cpp
+src/frontends/backup3/controllers/ControlPrefs.cpp
+src/frontends/backup3/controllers/ControlPrint.cpp
+src/frontends/backup3/controllers/ControlSpellchecker.cpp
+src/frontends/backup3/controllers/ControlToc.cpp
+src/frontends/backup3/controllers/frontend_helpers.cpp
+src/frontends/backup3/qt4/BulletsModule.cpp
+src/frontends/backup3/qt4/Dialogs.cpp
+src/frontends/backup3/qt4/FileDialog.cpp
+src/frontends/backup3/qt4/GuiAbout.cpp
+src/frontends/backup3/qt4/GuiApplication.cpp
+src/frontends/backup3/qt4/GuiBibitem.cpp
+src/frontends/backup3/qt4/GuiBibtex.cpp
+src/frontends/backup3/qt4/GuiBox.cpp
+src/frontends/backup3/qt4/GuiBranch.cpp
+src/frontends/backup3/qt4/GuiBranches.cpp
+src/frontends/backup3/qt4/GuiChanges.cpp
+src/frontends/backup3/qt4/GuiCharacter.cpp
+src/frontends/backup3/qt4/GuiCitation.cpp
+src/frontends/backup3/qt4/GuiCommandBuffer.cpp
+src/frontends/backup3/qt4/GuiDelimiter.cpp
+src/frontends/backup3/qt4/GuiDocument.cpp
+src/frontends/backup3/qt4/GuiERT.cpp
+src/frontends/backup3/qt4/GuiExternal.cpp
+src/frontends/backup3/qt4/GuiFloat.cpp
+src/frontends/backup3/qt4/GuiGraphics.cpp
+src/frontends/backup3/qt4/GuiInclude.cpp
+src/frontends/backup3/qt4/GuiListings.cpp
+src/frontends/backup3/qt4/GuiMathMatrix.cpp
+src/frontends/backup3/qt4/GuiNote.cpp
+src/frontends/backup3/qt4/GuiParagraph.cpp
+src/frontends/backup3/qt4/GuiPrefs.cpp
+src/frontends/backup3/qt4/GuiPrint.cpp
+src/frontends/backup3/qt4/GuiRef.cpp
+src/frontends/backup3/qt4/GuiSearch.cpp
+src/frontends/backup3/qt4/GuiSendto.cpp
+src/frontends/backup3/qt4/GuiShowFile.cpp
+src/frontends/backup3/qt4/GuiSpellchecker.cpp
+src/frontends/backup3/qt4/GuiTabular.cpp
+src/frontends/backup3/qt4/GuiTabularCreate.cpp
+src/frontends/backup3/qt4/GuiTexinfo.cpp
+src/frontends/backup3/qt4/GuiThesaurus.cpp
+src/frontends/backup3/qt4/GuiURL.cpp
+src/frontends/backup3/qt4/GuiVSpace.cpp
+src/frontends/backup3/qt4/GuiView.cpp
+src/frontends/backup3/qt4/GuiWrap.cpp
+src/frontends/backup3/qt4/IconPalette.cpp
+src/frontends/backup3/qt4/Qt2BC.cpp
+src/frontends/backup3/qt4/Validator.cpp
+src/frontends/backup3/qt4/alert_pimpl.cpp
 src/frontends/controllers/ControlAboutlyx.cpp
 src/frontends/controllers/ControlBibtex.cpp
 src/frontends/controllers/ControlBox.cpp
 src/frontends/controllers/ControlDocument.cpp
+src/frontends/controllers/ControlEmbeddedFiles.cpp
 src/frontends/controllers/ControlErrorList.cpp
 src/frontends/controllers/ControlExternal.cpp
 src/frontends/controllers/ControlGraphics.cpp
@@ -83,12 +244,12 @@ src/frontends/qt4/GuiTabular.cpp
 src/frontends/qt4/GuiTabularCreate.cpp
 src/frontends/qt4/GuiTexinfo.cpp
 src/frontends/qt4/GuiThesaurus.cpp
-src/frontends/qt4/GuiUrl.cpp
+src/frontends/qt4/GuiURL.cpp
 src/frontends/qt4/GuiVSpace.cpp
 src/frontends/qt4/GuiView.cpp
 src/frontends/qt4/GuiWrap.cpp
 src/frontends/qt4/IconPalette.cpp
-src/frontends/qt4/Qt2BC.h
+src/frontends/qt4/Qt2BC.cpp
 src/frontends/qt4/Validator.cpp
 src/frontends/qt4/alert_pimpl.cpp
 src/gettext.h
diff --git a/src/frontends/qt4/CheckedLineEdit.cpp b/src/frontends/qt4/CheckedLineEdit.cpp
deleted file mode 100644 (file)
index 9c23cde..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-/**
- * \file CheckedLineEdit.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 "CheckedLineEdit.h"
-#include "Qt2BC.h"
-
-#include <QLabel>
-#include <QLineEdit>
-#include <QValidator>
-
-namespace lyx {
-namespace frontend {
-
-void addCheckedLineEdit(BCView & bcview, QLineEdit * input, QWidget * label)
-{
-       Qt2BC * bc = static_cast<Qt2BC *>(&bcview);
-       bc->addCheckedWidget(new CheckedLineEdit(input, label));
-}
-
-
-namespace {
-
-void setWarningColor(QWidget * widget)
-{
-       QPalette pal = widget->palette();
-       pal.setColor(QPalette::Active, QPalette::Foreground, QColor(255, 0, 0));
-       widget->setPalette(pal);
-}
-
-
-void setWidget(bool valid, QLineEdit * input, QWidget * label)
-{
-       if (valid)
-               input->setPalette(QPalette());
-       else
-               setWarningColor(input);
-
-       if (!label)
-               return;
-
-       if (valid)
-               label->setPalette(QPalette());
-       else
-               setWarningColor(label);
-}
-
-} // namespace anon
-
-
-CheckedLineEdit::CheckedLineEdit(QLineEdit * input, QWidget * label)
-       : input_(input), label_(label)
-{}
-
-
-bool CheckedLineEdit::check() const
-{
-       QValidator const * validator = input_->validator();
-       if (!validator)
-               return true;
-
-       QString t = input_->text();
-       int p = 0;
-       bool const valid = validator->validate(t, p) == QValidator::Acceptable;
-
-       // Visual feedback.
-       setWidget(valid, input_, label_);
-
-       return valid;
-}
-
-} // namespace frontend
-} // namespace lyx
diff --git a/src/frontends/qt4/CheckedLineEdit.h b/src/frontends/qt4/CheckedLineEdit.h
deleted file mode 100644 (file)
index a9cf841..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-// -*- C++ -*-
-/**
- * \file qt4/CheckedLineEdit.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 CHECKEDLINEEDIT_H
-#define CHECKEDLINEEDIT_H
-
-class QWidget;
-class QLineEdit;
-
-namespace lyx {
-namespace frontend {
-
-class BCView;
-
-void addCheckedLineEdit(BCView & bcview,
-       QLineEdit * input, QWidget * label = 0);
-
-class CheckedLineEdit
-{
-public:
-       CheckedLineEdit(QLineEdit * input, QWidget * label = 0);
-       bool check() const;
-
-private:
-       QLineEdit * input_;
-       QWidget * label_;
-};
-
-} // namespace frontend
-} // namespace lyx
-
-#endif // CHECKEDLINEEDIT_H
index b92bc8cbdc3cc0dddf2186d32b9a8ae1b78d7de6..06210eefbd9f50810f1fcfb6547ea1d745d4345a 100644 (file)
@@ -19,7 +19,6 @@
 #include "qt_helpers.h"
 #include "Validator.h"
 #include "LyXRC.h"
-#include "CheckedLineEdit.h"
 
 #include "controllers/ControlBibtex.h"
 #include "controllers/ButtonPolicy.h"
@@ -88,8 +87,7 @@ GuiBibtexDialog::GuiBibtexDialog(GuiBibtex * form)
 
        bcview->setOK(add_->addPB);
        bcview->setCancel(add_->closePB);
-
-       addCheckedLineEdit(add_bc_.view(), add_->bibED, 0);
+       bcview->addCheckedLineEdit(add_->bibED, 0);
 
        connect(add_->bibED, SIGNAL(textChanged(const QString &)),
                this, SLOT(bibEDChanged()));
index f6ed74df617c56ff48ca0e8cb8f956d4d9124085..2dc3045923b8d9383e01cb44994826abff692008 100644 (file)
@@ -14,7 +14,6 @@
 
 #include "GuiBox.h"
 
-#include "CheckedLineEdit.h"
 #include "LengthCombo.h"
 #include "qt_helpers.h"
 #include "Qt2BC.h"
index 954a433e3d9ee313dd761141ca883eff458cd34b..48e312457a40bb7531c75033a9cecc2d417492d4 100644 (file)
@@ -12,7 +12,6 @@
 
 #include "GuiDocument.h"
 
-#include "CheckedLineEdit.h"
 #include "FloatPlacement.h"
 #include "LengthCombo.h"
 #include "PanelStack.h"
index 0a2b285c0e5c17bcf52dd1944c46bb472d42117e..bbdf922c434889c75c0ca6083aea9a1b501518d8 100644 (file)
@@ -11,8 +11,6 @@
 
 #include <config.h>
 
-// Qt defines a macro 'signals' that clashes with a boost namespace.
-// All is well if the namespace is visible first.
 #include "lengthcommon.h"
 #include "LyXRC.h"
 
@@ -29,7 +27,6 @@
 #include "GuiExternal.h"
 #include "Qt2BC.h"
 
-#include "CheckedLineEdit.h"
 #include "LengthCombo.h"
 #include "qt_helpers.h"
 #include "Validator.h"
@@ -185,7 +182,7 @@ void GuiExternalDialog::browseClicked()
        docstring const str =
                form_->controller().browse(qstring_to_ucs4(fileED->text()),
                                           template_name);
-       if(!str.empty()) {
+       if (!str.empty()) {
                fileED->setText(toqstr(str));
                form_->changed();
        }
index 1b804c841cce3e68771e11cf09c6a6ff8515d5b3..a2a05a78924a59e6f643c8fc58d73eb1fc9989fa 100644 (file)
@@ -15,7 +15,6 @@
 
 #include "GuiGraphics.h"
 
-#include "CheckedLineEdit.h"
 #include "debug.h"
 #include "LengthCombo.h"
 #include "lengthcommon.h"
@@ -295,6 +294,7 @@ void GuiGraphicsDialog::on_WidthCB_toggled(bool setWidth)
        setAutoText();
 }
 
+
 void GuiGraphicsDialog::on_HeightCB_toggled(bool setHeight)
 {
        Height->setEnabled(setHeight);
@@ -375,17 +375,14 @@ void GuiGraphics::build_dialog()
 }
 
 
-namespace {
-
 // returns the number of the string s in the vector v
-int getItemNo(vector<string> v, string const & s) {
+static int getItemNo(const vector<string> & v, string const & s)
+{
        vector<string>::const_iterator cit =
                    find(v.begin(), v.end(), s);
        return (cit != v.end()) ? int(cit - v.begin()) : 0;
 }
 
-}
-
 
 void GuiGraphics::update_contents()
 {
index 8debf85106195844657fc3411d45e6d7677d352c..a2650d5f3517f031d211eaec88553a0982cfda4e 100644 (file)
 
 #include "GuiInclude.h"
 
-#include "CheckedLineEdit.h"
 #include "Qt2BC.h"
 #include "qt_helpers.h"
-
 #include "LyXRC.h"
 
 #include "insets/InsetListingsParams.h"
index 7094568f2099b34c1dfb6f3a49bb554f22fd9caf..050a487eac7ac9062d54cb609b3745a7890b2a3d 100644 (file)
@@ -14,7 +14,6 @@
 
 #include "GuiTabular.h"
 
-#include "CheckedLineEdit.h"
 #include "GuiSetBorder.h"
 #include "Qt2BC.h"
 
index 8828accd77c0aadffd8dfb63bbe03b9eb544b47a..3473f82f7949bba9b818aa56cfc9d571ee7ed9ac 100644 (file)
@@ -18,7 +18,6 @@
 #include "GuiVSpace.h"
 #include "Qt2BC.h"
 
-#include "CheckedLineEdit.h"
 #include "LengthCombo.h"
 #include "qt_helpers.h"
 #include "Validator.h"
index 2835115028955d84c8d9cab6681748415d8b2111..0c532fdd87a3c65783860cac382d0876e76343c7 100644 (file)
@@ -38,7 +38,6 @@ SOURCEFILES = \
        Action.cpp \
        alert_pimpl.cpp \
        BulletsModule.cpp \
-       CheckedLineEdit.cpp \
        ColorCache.cpp \
        Dialogs.cpp \
        EmptyTable.cpp \
@@ -119,7 +118,6 @@ SOURCEFILES = \
        Validator.cpp 
 
 NOMOCHEADER = \
-       CheckedLineEdit.h \
        GuiClipboard.h \
        GuiFontLoader.h \
        GuiFontMetrics.h \
index 929ffe31c00688fc0370ce29e378bda14ea70945..289ac65de93b93c00557c5886b8f0b0f0c27b6d6 100644 (file)
@@ -19,6 +19,9 @@
 
 #include <QPushButton>
 #include <QLineEdit>
+#include <QLabel>
+#include <QValidator>
+
 
 namespace lyx {
 namespace frontend {
@@ -85,10 +88,9 @@ void Qt2BC::setWidgetEnabled(QWidget * obj, bool enabled) const
 }
 
 
-void Qt2BC::addCheckedWidget(CheckedLineEdit * ptr)
+void Qt2BC::addCheckedLineEdit(QLineEdit * input, QWidget * label)
 {
-       if (ptr)
-               checked_widgets.push_back(CheckedWidgetPtr(ptr));
+       checked_widgets.push_back(CheckedLineEdit(input, label));
 }
 
 
@@ -100,12 +102,65 @@ bool Qt2BC::checkWidgets() const
        CheckedWidgetList::const_iterator end = checked_widgets.end();
 
        for (; it != end; ++it)
-               valid &= (*it)->check();
+               valid &= it->check();
 
        // return valid status after checking ALL widgets
        return valid;
 }
 
 
+//////////////////////////////////////////////////////////////
+//
+// CheckedLineEdit
+//
+//////////////////////////////////////////////////////////////
+
+void addCheckedLineEdit(BCView & bcview, QLineEdit * input, QWidget * label)
+{
+       Qt2BC * bc = static_cast<Qt2BC *>(&bcview);
+       bc->addCheckedLineEdit(input, label);
+}
+
+
+static void setWarningColor(QWidget * widget)
+{
+       QPalette pal = widget->palette();
+       pal.setColor(QPalette::Active, QPalette::Foreground, QColor(255, 0, 0));
+       widget->setPalette(pal);
+}
+
+
+
+CheckedLineEdit::CheckedLineEdit(QLineEdit * input, QWidget * label)
+       : input_(input), label_(label)
+{}
+
+
+bool CheckedLineEdit::check() const
+{
+       QValidator const * validator = input_->validator();
+       if (!validator)
+               return true;
+
+       QString t = input_->text();
+       int p = 0;
+       bool const valid = validator->validate(t, p) == QValidator::Acceptable;
+
+       // Visual feedback.
+       if (valid)
+               input_->setPalette(QPalette());
+       else
+               setWarningColor(input_);
+
+       if (!label_) {
+               if (valid)
+                       label_->setPalette(QPalette());
+               else
+                       setWarningColor(label_);
+       }
+
+       return valid;
+}
+
 } // namespace frontend
 } // namespace lyx
index 5b72c5cdeeb46b03b54aed2291ebf6b1987c6718..4189274a339023831c0f48c6a6461bb9571c4fba 100644 (file)
 
 #include "BCView.h"
 #include "gettext.h"
-#include "CheckedLineEdit.h"
 
 class QWidget;
 class QPushButton;
+class QLineEdit;
 
 namespace lyx {
 namespace frontend {
 
+
+void addCheckedLineEdit(BCView & bcview,
+       QLineEdit * input, QWidget * label = 0);
+
+class CheckedLineEdit
+{
+public:
+       CheckedLineEdit(QLineEdit * input, QWidget * label = 0);
+       bool check() const;
+
+private:
+       // non-owned
+       QLineEdit * input_;
+       QWidget * label_;
+};
+
 /** General purpose button controller for up to four buttons.
     Controls the activation of the OK, Apply and Cancel buttons.
     Actually supports 4 buttons in all and it's up to the user to decide on
@@ -60,15 +76,14 @@ public:
        /** Add a widget to the list of all widgets whose validity should
         *  be checked explicitly when the buttons are refreshed.
         */
-       void addCheckedWidget(CheckedLineEdit * ptr);
+       void addCheckedLineEdit(QLineEdit * input, QWidget * label = 0);
 
 protected:
        /// \return true if all CheckedWidgets are in a valid state.
        bool checkWidgets() const;
 
 private:
-       typedef boost::shared_ptr<CheckedLineEdit> CheckedWidgetPtr;
-       typedef std::list<CheckedWidgetPtr> CheckedWidgetList;
+       typedef std::list<CheckedLineEdit> CheckedWidgetList;
        CheckedWidgetList checked_widgets;
 
 private: