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
This commit is contained in:
Richard Heck 2008-02-14 18:06:47 +00:00
parent b1306a979a
commit 85deaeb165
6 changed files with 111 additions and 194 deletions

View File

@ -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 <config.h>
#include "GuiIndex.h"
#include "support/debug.h"
#include "qt_helpers.h"
#include <QLabel>
#include <QPushButton>
#include <QLineEdit>
#include <QCloseEvent>
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"

View File

@ -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 <config.h>
#include "GuiLabel.h"
#include "support/debug.h"
#include "qt_helpers.h"
#include <QLabel>
#include <QPushButton>
#include <QLineEdit>
#include <QCloseEvent>
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"

View File

@ -1,6 +1,6 @@
// -*- C++ -*- // -*- C++ -*-
/** /**
* \file GuiIndex.h * \file GuiLabel.h
* This file is part of LyX, the document processor. * This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING. * Licence details can be found in the file COPYING.
* *
@ -10,22 +10,21 @@
* Full author contact details are available in file CREDITS. * Full author contact details are available in file CREDITS.
*/ */
#ifndef GUIINDEX_H #ifndef GUILABEL_H
#define GUIINDEX_H #define GUILABEL_H
#include "GuiDialog.h" #include "GuiDialog.h"
#include "ui_IndexUi.h" #include "ui_LabelUi.h"
namespace lyx { namespace lyx {
namespace frontend { namespace frontend {
class GuiIndexDialogBase : public GuiCommand, public Ui::IndexUi class GuiLabel : public GuiCommand, public Ui::LabelUi
{ {
Q_OBJECT Q_OBJECT
public: public:
GuiIndexDialogBase(GuiView & lv, QString const & title, GuiLabel(GuiView & lv);
QString const & label, std::string const & name);
private Q_SLOTS: private Q_SLOTS:
void change_adaptor(); void change_adaptor();
@ -40,23 +39,6 @@ private:
void applyView(); void applyView();
/// update /// update
void updateContents(); void updateContents();
///
QString label_;
};
class GuiIndex : public GuiIndexDialogBase
{
public:
GuiIndex(GuiView & lv);
};
class GuiLabel : public GuiIndexDialogBase
{
public:
GuiLabel(GuiView & lv);
}; };

View File

@ -2128,7 +2128,6 @@ Dialog * createGuiExternal(GuiView & lv);
Dialog * createGuiFloat(GuiView & lv); Dialog * createGuiFloat(GuiView & lv);
Dialog * createGuiGraphics(GuiView & lv); Dialog * createGuiGraphics(GuiView & lv);
Dialog * createGuiInclude(GuiView & lv); Dialog * createGuiInclude(GuiView & lv);
Dialog * createGuiIndex(GuiView & lv);
Dialog * createGuiLabel(GuiView & lv); Dialog * createGuiLabel(GuiView & lv);
Dialog * createGuiListings(GuiView & lv); Dialog * createGuiListings(GuiView & lv);
Dialog * createGuiLog(GuiView & lv); Dialog * createGuiLog(GuiView & lv);
@ -2193,8 +2192,6 @@ Dialog * GuiView::build(string const & name)
return createGuiGraphics(*this); return createGuiGraphics(*this);
if (name == "include") if (name == "include")
return createGuiInclude(*this); return createGuiInclude(*this);
if (name == "index")
return createGuiIndex(*this);
if (name == "nomenclature") if (name == "nomenclature")
return createGuiNomenclature(*this); return createGuiNomenclature(*this);
if (name == "label") if (name == "label")

View File

@ -88,8 +88,8 @@ SOURCEFILES = \
GuiIdListModel.cpp \ GuiIdListModel.cpp \
GuiImage.cpp \ GuiImage.cpp \
GuiInclude.cpp \ GuiInclude.cpp \
GuiIndex.cpp \
GuiKeySymbol.cpp \ GuiKeySymbol.cpp \
GuiLabel.cpp \
GuiListings.cpp \ GuiListings.cpp \
GuiLog.cpp \ GuiLog.cpp \
GuiMath.cpp \ GuiMath.cpp \
@ -182,7 +182,7 @@ MOCHEADER = \
GuiGraphics.h \ GuiGraphics.h \
GuiHyperlink.h \ GuiHyperlink.h \
GuiInclude.h \ GuiInclude.h \
GuiIndex.h \ GuiLabel.h \
GuiListings.h \ GuiListings.h \
GuiLog.h \ GuiLog.h \
GuiMathMatrix.h \ GuiMathMatrix.h \
@ -248,7 +248,7 @@ UIFILES = \
GraphicsUi.ui \ GraphicsUi.ui \
HyperlinkUi.ui \ HyperlinkUi.ui \
IncludeUi.ui \ IncludeUi.ui \
IndexUi.ui \ LabelUi.ui \
LanguageUi.ui \ LanguageUi.ui \
LaTeXUi.ui \ LaTeXUi.ui \
ListingsUi.ui \ ListingsUi.ui \

View File

@ -1,11 +1,11 @@
<ui version="4.0" > <ui version="4.0" >
<class>IndexUi</class> <class>LabelUi</class>
<widget class="QDialog" name="IndexUi" > <widget class="QDialog" name="LabelUi" >
<property name="geometry" > <property name="geometry" >
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>203</width> <width>300</width>
<height>82</height> <height>82</height>
</rect> </rect>
</property> </property>
@ -36,7 +36,7 @@
<string/> <string/>
</property> </property>
<property name="text" > <property name="text" >
<string/> <string>&amp;Label:</string>
</property> </property>
<property name="buddy" > <property name="buddy" >
<cstring>keywordED</cstring> <cstring>keywordED</cstring>