some refactoring

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20821 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2007-10-07 14:59:01 +00:00
parent 4b510c9b7c
commit 24b95a387c
5 changed files with 32 additions and 50 deletions

View File

@ -160,11 +160,11 @@ Dialog * Dialogs::build(string const & name)
if (name == "include")
return createGuiInclude(lyxview_);
if (name == "index")
return new GuiIndexDialog(lyxview_);
return createGuiIndex(lyxview_);
if (name == "nomenclature")
return createGuiNomenclature(lyxview_);
if (name == "label")
return new GuiLabelDialog(lyxview_);
return createGuiLabel(lyxview_);
if (name == "log")
return createGuiLog(lyxview_);
if (name == "view-source")

View File

@ -25,6 +25,8 @@
#include "support/lstrings.h"
#include "support/docstring.h"
#include "insets/InsetCommand.h"
#include <vector>
#include <string>
@ -75,11 +77,10 @@ static vector<lyx::docstring> to_docstring_vector(QStringList const & qlist)
GuiCitation::GuiCitation(LyXView & lv)
: GuiDialog(lv, "citation"), ControlCommand(*this, "citation")
: GuiCommand(lv, "citation")
{
setupUi(this);
setViewTitle(_("Citation"));
setController(this, false);
connect(citationStyleCO, SIGNAL(activated(int)),
this, SLOT(changed()));
@ -246,7 +247,7 @@ void GuiCitation::updateStyle()
citationStyleCO->setEnabled(!basic_engine && haveSelection);
citationStyleLA->setEnabled(!basic_engine && haveSelection);
string const & command = params().getCmdName();
string const & command = params_.getCmdName();
// Find the style of the citekeys
vector<biblio::CiteStyle> const & styles = citeStyles_;
@ -458,10 +459,10 @@ void GuiCitation::apply(int const choice, bool const full, bool const force,
biblio::CitationStyle(styles[choice], full, force)
.asLatexStr();
params().setCmdName(command);
params()["key"] = qstring_to_ucs4(cited_keys_.join(","));
params()["before"] = qstring_to_ucs4(before);
params()["after"] = qstring_to_ucs4(after);
params_.setCmdName(command);
params_["key"] = qstring_to_ucs4(cited_keys_.join(","));
params_["before"] = qstring_to_ucs4(before);
params_["after"] = qstring_to_ucs4(after);
dispatchParams();
}
@ -475,13 +476,13 @@ void GuiCitation::clearSelection()
QString GuiCitation::textBefore()
{
return toqstr(params()["before"]);
return toqstr(params_["before"]);
}
QString GuiCitation::textAfter()
{
return toqstr(params()["after"]);
return toqstr(params_["after"]);
}
@ -492,7 +493,7 @@ void GuiCitation::init()
available_model_.setStringList(all_keys_);
// Ditto for the keys cited in this inset
QString str = toqstr(params()["key"]);
QString str = toqstr(params_["key"]);
if (str.isEmpty())
cited_keys_.clear();
else
@ -586,8 +587,7 @@ void GuiCitation::setCitedKeys()
bool GuiCitation::initialiseParams(string const & data)
{
if (!ControlCommand::initialiseParams(data))
return false;
InsetCommandMailer::string2params(lfun_name_, data, params_);
biblio::CiteEngine const engine = buffer().params().getEngine();
@ -607,10 +607,9 @@ bool GuiCitation::initialiseParams(string const & data)
}
void GuiCitation::clearParams()
{
ControlCommand::clearParams();
params_.clear();
bibkeysInfo_.clear();
}

View File

@ -29,8 +29,7 @@
namespace lyx {
namespace frontend {
class GuiCitation
: public GuiDialog, public Ui::CitationUi, public ControlCommand
class GuiCitation : public GuiCommand, public Ui::CitationUi
{
Q_OBJECT
@ -54,8 +53,6 @@ public Q_SLOTS:
void updateView();
private:
///
ControlCommand & controller() { return *this; }
///
void closeEvent(QCloseEvent * e);
/// prepares a call to GuiCitation::searchKeys when we
@ -101,28 +98,20 @@ private:
///
void init();
/// Available keys
QStringListModel * available() { return &available_model_; }
/// Selected keys
QStringListModel * selected() { return &selected_model_; }
/// Text before cite
QString textBefore();
/// Text after cite
QString textAfter();
/// Get key description
QString getKeyInfo(QString const &);
/// Clear selected keys
void clearSelection();
/// Return a list of available fields
QStringList getFieldsAsQStringList();
/// Return a list of available fields
QStringList getEntriesAsQStringList();

View File

@ -12,8 +12,6 @@
#include "GuiIndex.h"
#include "ControlCommand.h"
#include "debug.h"
#include "qt_helpers.h"
@ -36,12 +34,11 @@ namespace frontend {
GuiIndexDialogBase::GuiIndexDialogBase(LyXView & lv,
docstring const & title, QString const & label, std::string const & name)
: GuiDialog(lv, name)
: GuiCommand(lv, name)
{
label_ = label;
setupUi(this);
setViewTitle(title);
setController(new ControlCommand(*this, name));
connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
@ -75,12 +72,6 @@ GuiIndexDialogBase::GuiIndexDialogBase(LyXView & lv,
}
ControlCommand & GuiIndexDialogBase::controller()
{
return static_cast<ControlCommand &>(GuiDialog::controller());
}
void GuiIndexDialogBase::change_adaptor()
{
changed();
@ -102,7 +93,7 @@ void GuiIndexDialogBase::closeEvent(QCloseEvent * e)
void GuiIndexDialogBase::updateContents()
{
docstring const contents = controller().params()["name"];
docstring const contents = params_["name"];
keywordED->setText(toqstr(contents));
bc().setValid(!contents.empty());
}
@ -110,7 +101,7 @@ void GuiIndexDialogBase::updateContents()
void GuiIndexDialogBase::applyView()
{
controller().params()["name"] = qstring_to_ucs4(keywordED->text());
params_["name"] = qstring_to_ucs4(keywordED->text());
}
@ -127,7 +118,7 @@ bool GuiIndexDialogBase::isValid()
/////////////////////////////////////////////////////////////////
GuiIndexDialog::GuiIndexDialog(LyXView & lv)
GuiIndex::GuiIndex(LyXView & lv)
: GuiIndexDialogBase(lv, _("Index Entry"), qt_("&Keyword:"), "index")
{
keywordED->setWhatsThis( qt_(
@ -148,17 +139,23 @@ GuiIndexDialog::GuiIndexDialog(LyXView & lv)
}
Dialog * createGuiIndex(LyXView & lv) { return new GuiIndex(lv); }
/////////////////////////////////////////////////////////////////
//
// Label Dialog
//
/////////////////////////////////////////////////////////////////
GuiLabelDialog::GuiLabelDialog(LyXView & lv)
GuiLabel::GuiLabel(LyXView & lv)
: GuiIndexDialogBase(lv, _("Label"), qt_("&Label:"), "label")
{}
Dialog * createGuiLabel(LyXView & lv) { return new GuiLabel(lv); }
} // namespace frontend
} // namespace lyx

View File

@ -14,13 +14,12 @@
#define GUIINDEX_H
#include "GuiDialog.h"
#include "ControlCommand.h"
#include "ui_IndexUi.h"
namespace lyx {
namespace frontend {
class GuiIndexDialogBase : public GuiDialog, public Ui::IndexUi
class GuiIndexDialogBase : public GuiCommand, public Ui::IndexUi
{
Q_OBJECT
@ -35,8 +34,6 @@ private Q_SLOTS:
private:
///
void closeEvent(QCloseEvent * e);
/// parent controller
ControlCommand & controller();
///
bool isValid();
/// Apply changes
@ -49,17 +46,17 @@ private:
};
class GuiIndexDialog : public GuiIndexDialogBase
class GuiIndex : public GuiIndexDialogBase
{
public:
GuiIndexDialog(LyXView & lv);
GuiIndex(LyXView & lv);
};
class GuiLabelDialog : public GuiIndexDialogBase
class GuiLabel : public GuiIndexDialogBase
{
public:
GuiLabelDialog(LyXView & lv);
GuiLabel(LyXView & lv);
};