mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 05:16:21 +00:00
all CheckedWidgets are line edits...
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@19988 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
dd7059d798
commit
904fd84bba
@ -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
|
||||
|
@ -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
|
||||
|
165
po/POTFILES.in
165
po/POTFILES.in
@ -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
|
||||
|
@ -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
|
@ -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
|
@ -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()));
|
||||
|
@ -14,7 +14,6 @@
|
||||
|
||||
#include "GuiBox.h"
|
||||
|
||||
#include "CheckedLineEdit.h"
|
||||
#include "LengthCombo.h"
|
||||
#include "qt_helpers.h"
|
||||
#include "Qt2BC.h"
|
||||
|
@ -12,7 +12,6 @@
|
||||
|
||||
#include "GuiDocument.h"
|
||||
|
||||
#include "CheckedLineEdit.h"
|
||||
#include "FloatPlacement.h"
|
||||
#include "LengthCombo.h"
|
||||
#include "PanelStack.h"
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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()
|
||||
{
|
||||
|
@ -15,10 +15,8 @@
|
||||
|
||||
#include "GuiInclude.h"
|
||||
|
||||
#include "CheckedLineEdit.h"
|
||||
#include "Qt2BC.h"
|
||||
#include "qt_helpers.h"
|
||||
|
||||
#include "LyXRC.h"
|
||||
|
||||
#include "insets/InsetListingsParams.h"
|
||||
|
@ -14,7 +14,6 @@
|
||||
|
||||
#include "GuiTabular.h"
|
||||
|
||||
#include "CheckedLineEdit.h"
|
||||
#include "GuiSetBorder.h"
|
||||
#include "Qt2BC.h"
|
||||
|
||||
|
@ -18,7 +18,6 @@
|
||||
#include "GuiVSpace.h"
|
||||
#include "Qt2BC.h"
|
||||
|
||||
#include "CheckedLineEdit.h"
|
||||
#include "LengthCombo.h"
|
||||
#include "qt_helpers.h"
|
||||
#include "Validator.h"
|
||||
|
@ -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 \
|
||||
|
@ -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
|
||||
|
@ -16,14 +16,30 @@
|
||||
|
||||
#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:
|
||||
|
Loading…
Reference in New Issue
Block a user