]> git.lyx.org Git - features.git/blob - src/frontends/qt2/QAbout.C
Changes due to the removal of using directives from support/std_sstream.h.
[features.git] / src / frontends / qt2 / QAbout.C
1 /**
2  * \file QAbout.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Kalle Dalheimer
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "support/lstrings.h"
14 #include "support/std_sstream.h"
15 #include "qt_helpers.h"
16 #include "ButtonController.h"
17 #include "ControlAboutlyx.h"
18
19 #include <qlabel.h>
20 #include <qpushbutton.h>
21 #include <qtextview.h>
22
23 #include "QAboutDialog.h"
24 #include "Qt2BC.h"
25 #include "QAbout.h"
26
27 using namespace lyx::support;
28
29 using std::getline;
30 using std::istringstream;
31 using std::ostringstream;
32
33
34 typedef QController<ControlAboutlyx, QView<QAboutDialog> > base_class;
35
36 QAbout::QAbout(Dialog & parent)
37         : base_class(parent, _("About LyX"))
38 {
39 }
40
41
42 void QAbout::build_dialog()
43 {
44         dialog_.reset(new QAboutDialog);
45         connect(dialog_.get()->closePB, SIGNAL(clicked()),
46                 this, SLOT(slotClose()));
47
48         dialog_->copyright->setText(toqstr(controller().getCopyright()));
49         dialog_->copyright->append("\n");
50         dialog_->copyright->append(toqstr(controller().getLicense()));
51         dialog_->copyright->append("\n");
52         dialog_->copyright->append(toqstr(controller().getDisclaimer()));
53
54         dialog_->versionLA->setText(toqstr(controller().getVersion()));
55
56         // The code below should depend on a autoconf test. (Lgb)
57 #if 1
58         // There are a lot of buggy stringstream implementations..., but the
59         // code below will work on all of them (I hope). The drawback with
60         // this solutions os the extra copying. (Lgb)
61
62         ostringstream in;
63         controller().getCredits(in);
64
65         istringstream ss(in.str());
66
67         string s;
68         ostringstream out;
69
70         while (getline(ss, s)) {
71                 if (prefixIs(s, "@b"))
72                         out << "<b>" << s.substr(2) << "</b>";
73                 else if (prefixIs(s, "@i"))
74                         out << "<i>" << s.substr(2) << "</i>";
75                 else
76                         out << s;
77                 out << "<br>";
78         }
79 #else
80         // Good stringstream implementations can handle this. It avoids
81         // some copying, and should thus be faster and use less memory. (Lgb)
82         // I'll make this the default for a short while to see if anyone
83         // see the error...
84         stringstream in;
85         controller().getCredits(in);
86         in.seekg(0);
87         string s;
88         ostringstream out;
89
90         while (getline(in, s)) {
91                 if (prefixIs(s, "@b"))
92                         out << "<b>" << s.substr(2) << "</b>";
93                 else if (prefixIs(s, "@i"))
94                         out << "<i>" << s.substr(2) << "</i>";
95                 else
96                         out << s;
97                 out << "<br>";
98         }
99 #endif
100
101         dialog_->creditsTV->setText(toqstr(STRCONV(out.str())));
102
103         // try to resize to a good size
104         dialog_->copyright->hide();
105         dialog_->setMinimumSize(dialog_->copyright->sizeHint());
106         dialog_->copyright->show();
107         dialog_->setMinimumSize(dialog_->sizeHint());
108
109         // Manage the cancel/close button
110         bcview().setCancel(dialog_->closePB);
111         bc().refresh();
112 }