]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiHyperlink.cpp
Fix the tab ordering of PanelStack and PrefsUi.
[lyx.git] / src / frontends / qt4 / GuiHyperlink.cpp
1 /**
2  * \file GuiHyperlink.cpp
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Angus Leeming
7  * \author John Levon
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #include <config.h>
13
14 #include "GuiHyperlink.h"
15
16 #include "qt_helpers.h"
17
18 #include "insets/InsetHyperlink.h"
19
20 #if defined(LYX_MERGE_FILES) && !defined(Q_CC_MSVC)
21 // GCC couldn't find operator==
22 namespace lyx {
23         bool operator==(lyx::docstring const & d, char const * c);
24         namespace frontend {
25                 bool operator==(lyx::docstring const & d, char const * c)
26                   { return lyx::operator ==(d, c); }
27         }
28 }
29 #endif
30
31
32 namespace lyx {
33 namespace frontend {
34
35 GuiHyperlink::GuiHyperlink(QWidget * parent) : InsetParamsWidget(parent)
36 {
37         setupUi(this);
38
39         connect(targetED, SIGNAL(textChanged(const QString &)),
40                 this, SIGNAL(changed()));
41         connect(nameED, SIGNAL(textChanged(const QString &)),
42                 this, SIGNAL(changed()));
43         connect(webRB, SIGNAL(clicked()),
44                 this, SIGNAL(changed()));
45         connect(emailRB, SIGNAL(clicked()),
46                 this, SIGNAL(changed()));
47         connect(fileRB, SIGNAL(clicked()),
48                 this, SIGNAL(changed()));
49
50         setFocusProxy(targetED);
51 }
52
53
54 void GuiHyperlink::paramsToDialog(Inset const * inset)
55 {
56         InsetHyperlink const * hlink = static_cast<InsetHyperlink const *>(inset);
57         InsetCommandParams const & params = hlink->params();
58
59         targetED->setText(toqstr(params["target"]));
60         nameED->setText(toqstr(params["name"]));
61         docstring const & type = params["type"];
62         if (type.empty())
63                 webRB->setChecked(true);
64         else if (type == "mailto:")
65                 emailRB->setChecked(true);
66         else if (type == "file:")
67                 fileRB->setChecked(true);
68 }
69
70
71 docstring GuiHyperlink::dialogToParams() const
72 {
73         InsetCommandParams params(insetCode());
74
75         params["target"] = qstring_to_ucs4(targetED->text());
76         params["name"] = qstring_to_ucs4(nameED->text());
77         if (webRB->isChecked())
78                 params["type"] = qstring_to_ucs4("");
79         else if (emailRB->isChecked())
80                 params["type"] = qstring_to_ucs4("mailto:");
81         else if (fileRB->isChecked())
82                 params["type"] = qstring_to_ucs4("file:");
83         params.setCmdName("href");
84         return from_utf8(InsetHyperlink::params2string(params));
85 }
86
87
88 bool GuiHyperlink::checkWidgets() const
89 {
90         if (!InsetParamsWidget::checkWidgets())
91                 return false;
92         return !targetED->text().isEmpty() || !nameED->text().isEmpty();
93 }
94
95
96 } // namespace frontend
97 } // namespace lyx
98
99
100 #include "moc_GuiHyperlink.cpp"