]> git.lyx.org Git - lyx.git/blob - src/frontends/qt2/qt_helpers.C
Some string(widget->text()) fixes. Weirdness
[lyx.git] / src / frontends / qt2 / qt_helpers.C
1 /**
2  * \file qt_helpers.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Dekel Tsur
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 "qt_helpers.h"
18
19 #include <qglobal.h>
20
21 using std::pair;
22 using std::make_pair;
23
24 string makeFontName(string const & family, string const & foundry)
25 {
26         if (foundry.empty())
27                 return family;
28 #if QT_VERSION  >= 300
29         return family + " [" + foundry + ']';
30 #else
31         return foundry + '-' + family;
32 #endif
33 }
34
35
36 pair<string,string> parseFontName(string const & name)
37 {
38 #if QT_VERSION  >= 300
39         string::size_type const idx = name.find('[');
40         if (idx == string::npos || idx == 0)
41                 return make_pair(name, string());
42         return make_pair(name.substr(0, idx - 1),
43                          name.substr(idx + 1, name.size() - idx - 2));
44 #else
45         string::size_type const idx = name.find('-');
46         if (idx == string::npos || idx == 0)
47                 return make_pair(name, string());
48         return make_pair(name.substr(idx + 1),
49                          name.substr(0, idx));
50 #endif
51 }