]> git.lyx.org Git - lyx.git/blob - src/frontends/qt2/QURL.C
Some string(widget->text()) fixes. Weirdness
[lyx.git] / src / frontends / qt2 / QURL.C
1 /**
2  * \file QURL.C
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 #ifdef __GNUG__
14 #pragma implementation
15 #endif
16
17 #include "ControlUrl.h"
18 #include "debug.h"
19 #include "gettext.h"
20
21 #include "QURL.h"
22 #include "QURLDialog.h"
23 #include "Qt2BC.h"
24
25 #include <qcheckbox.h>
26 #include <qpushbutton.h>
27 #include <qlineedit.h>
28
29 typedef Qt2CB<ControlUrl, Qt2DB<QURLDialog> > base_class;
30
31
32 QURL::QURL()
33         : base_class(_("URL"))
34 {
35 }
36
37
38 void QURL::build_dialog()
39 {
40         dialog_.reset(new QURLDialog(this));
41
42         bc().setOK(dialog_->okPB);
43         bc().setCancel(dialog_->closePB);
44         bc().addReadOnly(dialog_->urlED);
45         bc().addReadOnly(dialog_->nameED);
46         bc().addReadOnly(dialog_->hyperlinkCB);
47 }
48
49
50 void QURL::update_contents()
51 {
52         InsetCommandParams const & params = controller().params();
53
54         dialog_->urlED->setText(params.getContents().c_str());
55         dialog_->nameED->setText(params.getOptions().c_str());
56         dialog_->hyperlinkCB->setChecked(params.getCmdName() != "url");
57 }
58
59
60 void QURL::apply()
61 {
62         InsetCommandParams & params = controller().params();
63
64         params.setContents(dialog_->urlED->text().latin1());
65         params.setOptions(dialog_->nameED->text().latin1());
66
67         if (dialog_->hyperlinkCB->isChecked())
68                 params.setCmdName("htmlurl");
69         else
70                 params.setCmdName("url");
71 }
72
73
74 bool QURL::isValid()
75 {
76         string const u(dialog_->urlED->text().latin1());
77         string const n(dialog_->nameED->text().latin1());
78
79         return !u.empty() && !n.empty();
80 }