From 85deaeb1659c4bcd5cb8d60bbdebe55506a767d5 Mon Sep 17 00:00:00 2001 From: Richard Heck Date: Thu, 14 Feb 2008 18:06:47 +0000 Subject: [PATCH] Get rid of GuiIndex since we no longer need it. Simplify the remaining code. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23006 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/qt4/GuiIndex.cpp | 160 ------------------ src/frontends/qt4/GuiLabel.cpp | 98 +++++++++++ src/frontends/qt4/{GuiIndex.h => GuiLabel.h} | 30 +--- src/frontends/qt4/GuiView.cpp | 3 - src/frontends/qt4/Makefile.am | 6 +- .../qt4/ui/{IndexUi.ui => LabelUi.ui} | 8 +- 6 files changed, 111 insertions(+), 194 deletions(-) delete mode 100644 src/frontends/qt4/GuiIndex.cpp create mode 100644 src/frontends/qt4/GuiLabel.cpp rename src/frontends/qt4/{GuiIndex.h => GuiLabel.h} (60%) rename src/frontends/qt4/ui/{IndexUi.ui => LabelUi.ui} (95%) diff --git a/src/frontends/qt4/GuiIndex.cpp b/src/frontends/qt4/GuiIndex.cpp deleted file mode 100644 index 737b30c1e0..0000000000 --- a/src/frontends/qt4/GuiIndex.cpp +++ /dev/null @@ -1,160 +0,0 @@ -/** - * \file GuiIndex.cpp - * This file is part of LyX, the document processor. - * Licence details can be found in the file COPYING. - * - * \author John Levon - * - * Full author contact details are available in file CREDITS. - */ - -#include - -#include "GuiIndex.h" - -#include "support/debug.h" -#include "qt_helpers.h" - -#include -#include -#include -#include - -using namespace std; - -namespace lyx { -namespace frontend { - -///////////////////////////////////////////////////////////////// -// -// Base implementation -// -///////////////////////////////////////////////////////////////// - -GuiIndexDialogBase::GuiIndexDialogBase(GuiView & lv, - QString const & title, QString const & label, string const & name) - : GuiCommand(lv, name, title) -{ - label_ = label; - setupUi(this); - - 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" - "An entry can be specified as a sub-entry of\n" - "another with \"!\":\n" - "\n" - "cars!mileage\n" - "\n" - "You can cross-refer to another entry like so:\n" - "\n" - "cars!mileage|see{economy}\n" - "\n" - "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 GuiIndexDialogBase::change_adaptor() -{ - changed(); -} - - -void GuiIndexDialogBase::reject() -{ - slotClose(); -} - - -void GuiIndexDialogBase::closeEvent(QCloseEvent * e) -{ - slotClose(); - e->accept(); -} - - -void GuiIndexDialogBase::updateContents() -{ - docstring const contents = params_["name"]; - keywordED->setText(toqstr(contents)); - bc().setValid(!contents.empty()); -} - - -void GuiIndexDialogBase::applyView() -{ - params_["name"] = qstring_to_ucs4(keywordED->text()); -} - - -bool GuiIndexDialogBase::isValid() -{ - return !keywordED->text().isEmpty(); -} - - -///////////////////////////////////////////////////////////////// -// -// Index Dialog -// -///////////////////////////////////////////////////////////////// - - -GuiIndex::GuiIndex(GuiView & lv) - : GuiIndexDialogBase(lv, qt_("Index Entry"), qt_("&Keyword:"), "index") -{ - keywordED->setWhatsThis( qt_( - "The format of the entry in the index.\n" - "\n" - "An entry can be specified as a sub-entry of\n" - "another with \"!\":\n" - "\n" - "cars!mileage\n" - "\n" - "You can cross-refer to another entry like so:\n" - "\n" - "cars!mileage|see{economy}\n" - "\n" - "For further details refer to the local LaTeX\n" - "documentation.\n") - ); -} - - -Dialog * createGuiIndex(GuiView & lv) { return new GuiIndex(lv); } - - -///////////////////////////////////////////////////////////////// -// -// Label Dialog -// -///////////////////////////////////////////////////////////////// - -GuiLabel::GuiLabel(GuiView & lv) - : GuiIndexDialogBase(lv, qt_("Label"), qt_("&Label:"), "label") -{} - - -Dialog * createGuiLabel(GuiView & lv) { return new GuiLabel(lv); } - - -} // namespace frontend -} // namespace lyx - -#include "GuiIndex_moc.cpp" diff --git a/src/frontends/qt4/GuiLabel.cpp b/src/frontends/qt4/GuiLabel.cpp new file mode 100644 index 0000000000..d49bb74585 --- /dev/null +++ b/src/frontends/qt4/GuiLabel.cpp @@ -0,0 +1,98 @@ +/** + * \file GuiLabel.cpp + * This file is part of LyX, the document processor. + * Licence details can be found in the file COPYING. + * + * \author John Levon + * + * Full author contact details are available in file CREDITS. + */ + +#include + +#include "GuiLabel.h" + +#include "support/debug.h" +#include "qt_helpers.h" + +#include +#include +#include +#include + +using namespace std; + +namespace lyx { +namespace frontend { + +///////////////////////////////////////////////////////////////// +// +// Base implementation +// +///////////////////////////////////////////////////////////////// + +GuiLabel::GuiLabel(GuiView & lv) + : GuiCommand(lv, "label", qt_("Label")) +{ + setupUi(this); + + 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); + + bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy); + bc().setOK(okPB); + bc().setCancel(closePB); + bc().addReadOnly(keywordED); +} + + +void GuiLabel::change_adaptor() +{ + changed(); +} + + +void GuiLabel::reject() +{ + slotClose(); +} + + +void GuiLabel::closeEvent(QCloseEvent * e) +{ + slotClose(); + e->accept(); +} + + +void GuiLabel::updateContents() +{ + docstring const contents = params_["name"]; + keywordED->setText(toqstr(contents)); + bc().setValid(!contents.empty()); +} + + +void GuiLabel::applyView() +{ + params_["name"] = qstring_to_ucs4(keywordED->text()); +} + + +bool GuiLabel::isValid() +{ + return !keywordED->text().isEmpty(); +} + + +Dialog * createGuiLabel(GuiView & lv) { return new GuiLabel(lv); } + + +} // namespace frontend +} // namespace lyx + +#include "GuiLabel_moc.cpp" diff --git a/src/frontends/qt4/GuiIndex.h b/src/frontends/qt4/GuiLabel.h similarity index 60% rename from src/frontends/qt4/GuiIndex.h rename to src/frontends/qt4/GuiLabel.h index 32d1a27b90..15ecdee562 100644 --- a/src/frontends/qt4/GuiIndex.h +++ b/src/frontends/qt4/GuiLabel.h @@ -1,6 +1,6 @@ // -*- C++ -*- /** - * \file GuiIndex.h + * \file GuiLabel.h * This file is part of LyX, the document processor. * Licence details can be found in the file COPYING. * @@ -10,22 +10,21 @@ * Full author contact details are available in file CREDITS. */ -#ifndef GUIINDEX_H -#define GUIINDEX_H +#ifndef GUILABEL_H +#define GUILABEL_H #include "GuiDialog.h" -#include "ui_IndexUi.h" +#include "ui_LabelUi.h" namespace lyx { namespace frontend { -class GuiIndexDialogBase : public GuiCommand, public Ui::IndexUi +class GuiLabel : public GuiCommand, public Ui::LabelUi { Q_OBJECT public: - GuiIndexDialogBase(GuiView & lv, QString const & title, - QString const & label, std::string const & name); + GuiLabel(GuiView & lv); private Q_SLOTS: void change_adaptor(); @@ -40,23 +39,6 @@ private: void applyView(); /// update void updateContents(); - - /// - QString label_; -}; - - -class GuiIndex : public GuiIndexDialogBase -{ -public: - GuiIndex(GuiView & lv); -}; - - -class GuiLabel : public GuiIndexDialogBase -{ -public: - GuiLabel(GuiView & lv); }; diff --git a/src/frontends/qt4/GuiView.cpp b/src/frontends/qt4/GuiView.cpp index 7e7439573e..ef3f5b7933 100644 --- a/src/frontends/qt4/GuiView.cpp +++ b/src/frontends/qt4/GuiView.cpp @@ -2128,7 +2128,6 @@ Dialog * createGuiExternal(GuiView & lv); Dialog * createGuiFloat(GuiView & lv); Dialog * createGuiGraphics(GuiView & lv); Dialog * createGuiInclude(GuiView & lv); -Dialog * createGuiIndex(GuiView & lv); Dialog * createGuiLabel(GuiView & lv); Dialog * createGuiListings(GuiView & lv); Dialog * createGuiLog(GuiView & lv); @@ -2193,8 +2192,6 @@ Dialog * GuiView::build(string const & name) return createGuiGraphics(*this); if (name == "include") return createGuiInclude(*this); - if (name == "index") - return createGuiIndex(*this); if (name == "nomenclature") return createGuiNomenclature(*this); if (name == "label") diff --git a/src/frontends/qt4/Makefile.am b/src/frontends/qt4/Makefile.am index 4a054ad3ba..8965b97f92 100644 --- a/src/frontends/qt4/Makefile.am +++ b/src/frontends/qt4/Makefile.am @@ -88,8 +88,8 @@ SOURCEFILES = \ GuiIdListModel.cpp \ GuiImage.cpp \ GuiInclude.cpp \ - GuiIndex.cpp \ GuiKeySymbol.cpp \ + GuiLabel.cpp \ GuiListings.cpp \ GuiLog.cpp \ GuiMath.cpp \ @@ -182,7 +182,7 @@ MOCHEADER = \ GuiGraphics.h \ GuiHyperlink.h \ GuiInclude.h \ - GuiIndex.h \ + GuiLabel.h \ GuiListings.h \ GuiLog.h \ GuiMathMatrix.h \ @@ -248,7 +248,7 @@ UIFILES = \ GraphicsUi.ui \ HyperlinkUi.ui \ IncludeUi.ui \ - IndexUi.ui \ + LabelUi.ui \ LanguageUi.ui \ LaTeXUi.ui \ ListingsUi.ui \ diff --git a/src/frontends/qt4/ui/IndexUi.ui b/src/frontends/qt4/ui/LabelUi.ui similarity index 95% rename from src/frontends/qt4/ui/IndexUi.ui rename to src/frontends/qt4/ui/LabelUi.ui index 76895fdfd5..3edf562d9f 100644 --- a/src/frontends/qt4/ui/IndexUi.ui +++ b/src/frontends/qt4/ui/LabelUi.ui @@ -1,11 +1,11 @@ - IndexUi - + LabelUi + 0 0 - 203 + 300 82 @@ -36,7 +36,7 @@ - + &Label: keywordED