]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiURL.cpp
renaming of some methods that hurt the eyes + removal of:
[lyx.git] / src / frontends / qt4 / GuiURL.cpp
1 /**
2  * \file GuiURL.cpp
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author John Levon
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "GuiURL.h"
14 #include "qt_helpers.h"
15
16 #include <QCheckBox>
17 #include <QCloseEvent>
18 #include <QLineEdit>
19 #include <QPushButton>
20
21
22 namespace lyx {
23 namespace frontend {
24
25 GuiURLDialog::GuiURLDialog(UrlView * form)
26         : form_(form)
27 {
28         setupUi(this);
29
30         connect(okPB, SIGNAL(clicked()), form_, SLOT(slotOK()));
31         connect(closePB, SIGNAL(clicked()), form_, SLOT(slotClose()));
32         connect(urlED, SIGNAL(textChanged(const QString &)),
33                 this, SLOT(changed_adaptor()));
34         connect(hyperlinkCB, SIGNAL(clicked()),
35                 this, SLOT(changed_adaptor()));
36         connect(nameED, SIGNAL(textChanged(const QString &)),
37                 this, SLOT(changed_adaptor()));
38
39         setFocusProxy(urlED);
40 }
41
42
43 void GuiURLDialog::changed_adaptor()
44 {
45         form_->changed();
46 }
47
48
49 void GuiURLDialog::closeEvent(QCloseEvent * e)
50 {
51         form_->slotWMHide();
52         e->accept();
53 }
54
55
56
57 UrlView::UrlView(GuiDialog & parent)
58         : GuiView<GuiURLDialog>(parent, _("URL"))
59 {
60 }
61
62
63 void UrlView::build_dialog()
64 {
65         dialog_.reset(new GuiURLDialog(this));
66
67         bc().setOK(dialog_->okPB);
68         bc().setCancel(dialog_->closePB);
69         bc().addReadOnly(dialog_->urlED);
70         bc().addReadOnly(dialog_->nameED);
71         bc().addReadOnly(dialog_->hyperlinkCB);
72 }
73
74
75 void UrlView::update_contents()
76 {
77         InsetCommandParams const & params = controller().params();
78
79         dialog_->urlED->setText(toqstr(params["target"]));
80         dialog_->nameED->setText(toqstr(params["name"]));
81         dialog_->hyperlinkCB->setChecked(params.getCmdName() != "url");
82
83         bc().setValid(isValid());
84 }
85
86
87 void UrlView::applyView()
88 {
89         InsetCommandParams & params = controller().params();
90
91         params["target"] = qstring_to_ucs4(dialog_->urlED->text());
92         params["name"] = qstring_to_ucs4(dialog_->nameED->text());
93
94         if (dialog_->hyperlinkCB->isChecked())
95                 params.setCmdName("htmlurl");
96         else
97                 params.setCmdName("url");
98 }
99
100
101 bool UrlView::isValid()
102 {
103         QString const u = dialog_->urlED->text();
104         QString const n = dialog_->nameED->text();
105
106         return !u.isEmpty() || !n.isEmpty();
107 }
108
109 } // namespace frontend
110 } // namespace lyx
111
112
113 #include "GuiURL_moc.cpp"