2006-03-05 17:24:44 +00:00
|
|
|
/**
|
2007-10-13 19:06:09 +00:00
|
|
|
* \file GuiHyperlink.cpp
|
2006-03-05 17:24:44 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
2007-10-07 14:19:14 +00:00
|
|
|
* \author Angus Leeming
|
2006-03-05 17:24:44 +00:00
|
|
|
* \author John Levon
|
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
2007-10-13 19:06:09 +00:00
|
|
|
#include "GuiHyperlink.h"
|
2007-09-05 20:33:29 +00:00
|
|
|
|
2007-08-31 22:16:11 +00:00
|
|
|
#include "qt_helpers.h"
|
2007-10-07 14:19:14 +00:00
|
|
|
#include "FuncRequest.h"
|
|
|
|
#include "insets/InsetCommand.h"
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2007-08-31 22:16:11 +00:00
|
|
|
#include <QCheckBox>
|
|
|
|
#include <QCloseEvent>
|
2006-03-05 17:24:44 +00:00
|
|
|
#include <QLineEdit>
|
|
|
|
#include <QPushButton>
|
2007-08-31 22:16:11 +00:00
|
|
|
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
namespace frontend {
|
|
|
|
|
2007-10-13 19:06:09 +00:00
|
|
|
GuiHyperlink::GuiHyperlink(LyXView & lv)
|
|
|
|
: GuiCommand(lv, "href")
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
|
|
|
setupUi(this);
|
2007-10-13 19:06:09 +00:00
|
|
|
setViewTitle( _("Hyperlink"));
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
|
|
|
|
connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
|
2007-08-12 12:40:11 +00:00
|
|
|
connect(urlED, SIGNAL(textChanged(const QString &)),
|
|
|
|
this, SLOT(changed_adaptor()));
|
|
|
|
connect(nameED, SIGNAL(textChanged(const QString &)),
|
|
|
|
this, SLOT(changed_adaptor()));
|
2007-03-28 20:14:50 +00:00
|
|
|
|
|
|
|
setFocusProxy(urlED);
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
bc().setOK(okPB);
|
|
|
|
bc().setCancel(closePB);
|
|
|
|
bc().addReadOnly(urlED);
|
|
|
|
bc().addReadOnly(nameED);
|
2006-03-05 17:24:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-13 19:06:09 +00:00
|
|
|
void GuiHyperlink::changed_adaptor()
|
2007-08-31 22:16:11 +00:00
|
|
|
{
|
2007-09-05 20:33:29 +00:00
|
|
|
changed();
|
2007-08-31 22:16:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-13 19:06:09 +00:00
|
|
|
void GuiHyperlink::closeEvent(QCloseEvent * e)
|
2007-08-31 22:16:11 +00:00
|
|
|
{
|
2007-09-11 17:06:15 +00:00
|
|
|
slotClose();
|
2007-09-05 20:33:29 +00:00
|
|
|
e->accept();
|
2007-08-31 22:16:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-13 19:06:09 +00:00
|
|
|
void GuiHyperlink::updateContents()
|
2007-08-31 22:16:11 +00:00
|
|
|
{
|
2007-10-07 14:19:14 +00:00
|
|
|
urlED->setText(toqstr(params_["target"]));
|
|
|
|
nameED->setText(toqstr(params_["name"]));
|
2007-09-03 05:59:32 +00:00
|
|
|
bc().setValid(isValid());
|
2007-08-31 22:16:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-13 19:06:09 +00:00
|
|
|
void GuiHyperlink::applyView()
|
2007-08-31 22:16:11 +00:00
|
|
|
{
|
2007-10-07 14:19:14 +00:00
|
|
|
params_["target"] = qstring_to_ucs4(urlED->text());
|
|
|
|
params_["name"] = qstring_to_ucs4(nameED->text());
|
2007-10-13 19:06:09 +00:00
|
|
|
params_.setCmdName("href");
|
2007-08-31 22:16:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-13 19:06:09 +00:00
|
|
|
bool GuiHyperlink::isValid()
|
2007-08-31 22:16:11 +00:00
|
|
|
{
|
2007-09-05 20:33:29 +00:00
|
|
|
QString const u = urlED->text();
|
|
|
|
QString const n = nameED->text();
|
2007-08-31 22:16:11 +00:00
|
|
|
|
|
|
|
return !u.isEmpty() || !n.isEmpty();
|
|
|
|
}
|
|
|
|
|
2007-10-07 14:19:14 +00:00
|
|
|
|
2007-10-13 19:06:09 +00:00
|
|
|
Dialog * createGuiHyperlink(LyXView & lv) { return new GuiHyperlink(lv); }
|
2007-10-07 14:19:14 +00:00
|
|
|
|
|
|
|
|
2006-03-05 17:24:44 +00:00
|
|
|
} // namespace frontend
|
|
|
|
} // namespace lyx
|
2006-05-18 08:51:12 +00:00
|
|
|
|
2007-08-31 22:37:05 +00:00
|
|
|
|
2007-10-13 19:06:09 +00:00
|
|
|
#include "GuiHyperlink_moc.cpp"
|