git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20817 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2007-10-07 14:19:14 +00:00
parent c0fb3ecae2
commit 7e30f47252
3 changed files with 62 additions and 35 deletions

View File

@ -21,7 +21,6 @@
#include "GuiMathMatrix.h"
#include "GuiNomencl.h"
#include "GuiView.h"
#include "GuiURL.h"
// Uncomment this if you prefer dock widget
//#define USE_DOCK_WIDGET
@ -202,7 +201,7 @@ Dialog * Dialogs::build(string const & name)
if (name == "toc")
return createGuiToc(lyxview_);
if (name == "url")
return new GuiURLDialog(lyxview_);
return createGuiURL(lyxview_);
if (name == "vspace")
return createGuiVSpace(lyxview_);
if (name == "wrap")

View File

@ -3,6 +3,7 @@
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
* \author Angus Leeming
* \author John Levon
*
* Full author contact details are available in file CREDITS.
@ -12,8 +13,10 @@
#include "GuiURL.h"
#include "ControlCommand.h"
#include "GuiURL.h"
#include "qt_helpers.h"
#include "FuncRequest.h"
#include "insets/InsetCommand.h"
#include <QCheckBox>
#include <QCloseEvent>
@ -24,12 +27,12 @@
namespace lyx {
namespace frontend {
GuiURLDialog::GuiURLDialog(LyXView & lv)
: GuiDialog(lv, "url")
GuiURL::GuiURL(LyXView & lv)
: GuiDialog(lv, "url"), Controller(this), params_("url")
{
setupUi(this);
setViewTitle( _("URL"));
setController(new ControlCommand(*this, "url"));
setController(this, false);
connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
@ -51,19 +54,13 @@ GuiURLDialog::GuiURLDialog(LyXView & lv)
}
ControlCommand & GuiURLDialog::controller()
{
return static_cast<ControlCommand &>(GuiDialog::controller());
}
void GuiURLDialog::changed_adaptor()
void GuiURL::changed_adaptor()
{
changed();
}
void GuiURLDialog::closeEvent(QCloseEvent * e)
void GuiURL::closeEvent(QCloseEvent * e)
{
slotClose();
e->accept();
@ -71,33 +68,29 @@ void GuiURLDialog::closeEvent(QCloseEvent * e)
void GuiURLDialog::updateContents()
void GuiURL::updateContents()
{
InsetCommandParams const & params = controller().params();
urlED->setText(toqstr(params["target"]));
nameED->setText(toqstr(params["name"]));
hyperlinkCB->setChecked(params.getCmdName() != "url");
urlED->setText(toqstr(params_["target"]));
nameED->setText(toqstr(params_["name"]));
hyperlinkCB->setChecked(params_.getCmdName() != "url");
bc().setValid(isValid());
}
void GuiURLDialog::applyView()
void GuiURL::applyView()
{
InsetCommandParams & params = controller().params();
params["target"] = qstring_to_ucs4(urlED->text());
params["name"] = qstring_to_ucs4(nameED->text());
params_["target"] = qstring_to_ucs4(urlED->text());
params_["name"] = qstring_to_ucs4(nameED->text());
if (hyperlinkCB->isChecked())
params.setCmdName("htmlurl");
params_.setCmdName("htmlurl");
else
params.setCmdName("url");
params_.setCmdName("url");
}
bool GuiURLDialog::isValid()
bool GuiURL::isValid()
{
QString const u = urlED->text();
QString const n = nameED->text();
@ -105,6 +98,27 @@ bool GuiURLDialog::isValid()
return !u.isEmpty() || !n.isEmpty();
}
bool GuiURL::initialiseParams(std::string const & data)
{
// The name passed with LFUN_INSET_APPLY is also the name
// used to identify the mailer.
InsetCommandMailer::string2params("name", data, params_);
return true;
}
void GuiURL::dispatchParams()
{
std::string const lfun =
InsetCommandMailer::params2string("url", params_);
dispatch(FuncRequest(getLfun(), lfun));
}
Dialog * createGuiURL(LyXView & lv) { return new GuiURL(lv); }
} // namespace frontend
} // namespace lyx

View File

@ -1,30 +1,32 @@
// -*- C++ -*-
/**
* \file GuiURLDialog.h
* \file GuiURL.h
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
* \author John Levon
* \author Angus Leeming
*
* Full author contact details are available in file CREDITS.
*/
#ifndef GUIURLDIALOG_H
#define GUIURLDIALOG_H
#ifndef GUIURL_H
#define GUIURL_H
#include "GuiDialog.h"
#include "ControlCommand.h"
#include "ui_URLUi.h"
#include "insets/InsetCommandParams.h"
namespace lyx {
namespace frontend {
class GuiURLDialog : public GuiDialog, public Ui::URLUi
class GuiURL : public GuiDialog, public Ui::URLUi, public Controller
{
Q_OBJECT
public:
GuiURLDialog(LyXView & lv);
GuiURL(LyXView & lv);
public Q_SLOTS:
void changed_adaptor();
@ -32,16 +34,28 @@ public Q_SLOTS:
private:
void closeEvent(QCloseEvent *);
/// parent controller
ControlCommand & controller();
Controller & controller() { return *this; }
///
bool isValid();
/// apply dialog
void applyView();
/// update dialog
void updateContents();
///
bool initialiseParams(std::string const & data);
/// clean-up on hide.
void clearParams() { params_.clear(); }
/// clean-up on hide.
void dispatchParams();
///
bool isBufferDependent() const { return true; }
private:
///
InsetCommandParams params_;
};
} // namespace frontend
} // namespace lyx
#endif // GUIURLDIALOG_H
#endif // GUIURL_H