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 {
|
|
|
|
|
|
|
|
typedef QController< ControlCommand, QView<QURLDialog> > base_class;
|
|
|
|
|
2006-06-28 12:09:25 +00:00
|
|
|
UrlView::UrlView(Dialog & parent)
|
2006-10-09 10:35:14 +00:00
|
|
|
: 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();
|
|
|
|
|
|
|
|
dialog_->urlED->setText(toqstr(params.getContents()));
|
|
|
|
dialog_->nameED->setText(toqstr(params.getOptions()));
|
|
|
|
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();
|
|
|
|
|
|
|
|
params.setContents(fromqstr(dialog_->urlED->text()));
|
|
|
|
params.setOptions(fromqstr(dialog_->nameED->text()));
|
|
|
|
|
|
|
|
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
|