3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
8 * Full author contact details are available in file CREDITS.
14 #include "QURLDialog.h"
16 #include "qt_helpers.h"
18 #include "controllers/ButtonController.h"
19 #include "controllers/ControlCommand.h"
23 #include <QPushButton>
30 typedef QController< ControlCommand, QView<QURLDialog> > base_class;
32 UrlView::UrlView(Dialog & parent)
33 : base_class(parent, _("URL"))
38 void UrlView::build_dialog()
40 dialog_.reset(new QURLDialog(this));
42 bcview().setOK(dialog_->okPB);
43 bcview().setCancel(dialog_->closePB);
44 bcview().addReadOnly(dialog_->urlED);
45 bcview().addReadOnly(dialog_->nameED);
46 bcview().addReadOnly(dialog_->hyperlinkCB);
50 void UrlView::update_contents()
52 InsetCommandParams const & params = controller().params();
54 dialog_->urlED->setText(toqstr(params["target"]));
55 dialog_->nameED->setText(toqstr(params["name"]));
56 dialog_->hyperlinkCB->setChecked(params.getCmdName() != "url");
58 bc().valid(isValid());
64 InsetCommandParams & params = controller().params();
66 params["target"] = qstring_to_ucs4(dialog_->urlED->text());
67 params["name"] = qstring_to_ucs4(dialog_->nameED->text());
69 if (dialog_->hyperlinkCB->isChecked())
70 params.setCmdName("htmlurl");
72 params.setCmdName("url");
76 bool UrlView::isValid()
78 string const u(fromqstr(dialog_->urlED->text()));
79 string const n(fromqstr(dialog_->nameED->text()));
81 return !u.empty() || !n.empty();
84 } // namespace frontend