]> git.lyx.org Git - lyx.git/blob - src/frontends/qt2/QURL.C
ref dialog, more updates (BC stuff should now be OK along with the coming
[lyx.git] / src / frontends / qt2 / QURL.C
1 /**
2  * \file QURL.C
3  * Copyright 2001 the LyX Team
4  * Read the file COPYING
5  *
6  * \author John Levon
7  */
8
9 #include <config.h>
10
11 #include "QURLDialog.h"
12 #include <qcheckbox.h>
13 #include <qpushbutton.h>
14 #include <qlineedit.h>
15  
16 #include "ControlUrl.h"
17 #include "Qt2BC.h"
18 #include "QURL.h"
19 #include "debug.h"
20 #include "gettext.h"
21
22 typedef Qt2CB<ControlUrl, Qt2DB<QURLDialog> > base_class;
23  
24 QURL::QURL(ControlUrl & c)
25         : base_class(c, _("URL"))
26 {
27 }
28
29
30 void QURL::build_dialog()
31 {
32         dialog_.reset(new QURLDialog(this));
33
34         bc().setOK(dialog_->okPB);
35         bc().setCancel(dialog_->closePB);
36         bc().addReadOnly(dialog_->urlED);
37         bc().addReadOnly(dialog_->nameED);
38         bc().addReadOnly(dialog_->hyperlinkCB);
39 }
40
41  
42 void QURL::update_contents()
43 {
44         lyxerr << "update_contents URL" << std::endl;
45         lyxerr << dialog_->okPB << std::endl;
46         dialog_->urlED->setText(controller().params().getContents().c_str());
47         dialog_->nameED->setText(controller().params().getOptions().c_str());
48         dialog_->hyperlinkCB->setChecked(controller().params().getCmdName() != "url");
49 }
50
51  
52 void QURL::apply()
53 {
54         controller().params().setContents(dialog_->urlED->text().latin1());
55         controller().params().setOptions(dialog_->nameED->text().latin1());
56
57         if (dialog_->hyperlinkCB->isChecked())
58                 controller().params().setCmdName("htmlurl");
59         else
60                 controller().params().setCmdName("url");
61 }
62
63
64 bool QURL::isValid()
65 {
66         string const u(dialog_->urlED->text().latin1());
67         string const n(dialog_->nameED->text().latin1());
68
69         return !u.empty() && !n.empty(); 
70