2006-03-05 17:24:44 +00:00
|
|
|
/**
|
2006-06-28 12:09:25 +00:00
|
|
|
* \file UrlView.C
|
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.
|
|
|
|
*
|
|
|
|
* \author John Levon
|
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
2006-06-28 12:09:25 +00:00
|
|
|
#include "UrlView.h"
|
2006-03-05 17:24:44 +00:00
|
|
|
#include "QURLDialog.h"
|
|
|
|
#include "Qt2BC.h"
|
|
|
|
#include "qt_helpers.h"
|
|
|
|
|
|
|
|
#include "controllers/ButtonController.h"
|
|
|
|
#include "controllers/ControlCommand.h"
|
|
|
|
|
|
|
|
#include <QCheckBox>
|
|
|
|
#include <QLineEdit>
|
|
|
|
#include <QPushButton>
|
|
|
|
|
|
|
|
using std::string;
|
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
namespace frontend {
|
|
|
|
|
2007-03-22 23:07:24 +00:00
|
|
|
typedef QController< ControlCommand, QView<QURLDialog> > urlview_base_class;
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2006-06-28 12:09:25 +00:00
|
|
|
UrlView::UrlView(Dialog & parent)
|
2007-03-22 23:07:24 +00:00
|
|
|
: urlview_base_class(parent, _("URL"))
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-06-28 12:09:25 +00:00
|
|
|
void UrlView::build_dialog()
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
|
|
|
dialog_.reset(new QURLDialog(this));
|
|
|
|
|
|
|
|
bcview().setOK(dialog_->okPB);
|
|
|
|
bcview().setCancel(dialog_->closePB);
|
|
|
|
bcview().addReadOnly(dialog_->urlED);
|
|
|
|
bcview().addReadOnly(dialog_->nameED);
|
|
|
|
bcview().addReadOnly(dialog_->hyperlinkCB);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-06-28 12:09:25 +00:00
|
|
|
void UrlView::update_contents()
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
|
|
|
InsetCommandParams const & params = controller().params();
|
|
|
|
|
2006-10-20 13:53:43 +00:00
|
|
|
dialog_->urlED->setText(toqstr(params["target"]));
|
|
|
|
dialog_->nameED->setText(toqstr(params["name"]));
|
2006-03-05 17:24:44 +00:00
|
|
|
dialog_->hyperlinkCB->setChecked(params.getCmdName() != "url");
|
|
|
|
|
|
|
|
bc().valid(isValid());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-06-28 12:09:25 +00:00
|
|
|
void UrlView::apply()
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
|
|
|
InsetCommandParams & params = controller().params();
|
|
|
|
|
2006-10-20 13:53:43 +00:00
|
|
|
params["target"] = qstring_to_ucs4(dialog_->urlED->text());
|
|
|
|
params["name"] = qstring_to_ucs4(dialog_->nameED->text());
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
if (dialog_->hyperlinkCB->isChecked())
|
|
|
|
params.setCmdName("htmlurl");
|
|
|
|
else
|
|
|
|
params.setCmdName("url");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-06-28 12:09:25 +00:00
|
|
|
bool UrlView::isValid()
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
|
|
|
string const u(fromqstr(dialog_->urlED->text()));
|
|
|
|
string const n(fromqstr(dialog_->nameED->text()));
|
|
|
|
|
|
|
|
return !u.empty() || !n.empty();
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace frontend
|
|
|
|
} // namespace lyx
|