1 | /**************************************************************************** |
2 | ** |
3 | ** Copyright (C) 2011 Patrick von Reth <patrick.vonreth@gmail.com> |
4 | ** Copyright (C) 2011 Ralf Habacker <ralf.habacker@freenet.de> |
5 | ** All rights reserved. |
6 | ** |
7 | ** This file is part of the KDE installer for windows |
8 | ** |
9 | ** This library is free software; you can redistribute it and/or |
10 | ** modify it under the terms of the GNU Library General Public |
11 | ** License version 2 as published by the Free Software Foundation. |
12 | ** |
13 | ** This library is distributed in the hope that it will be useful, |
14 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
16 | ** Library General Public License for more details. |
17 | ** |
18 | ** You should have received a copy of the GNU Library General Public License |
19 | ** along with this library; see the file COPYING.LIB. If not, write to |
20 | ** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
21 | ** Boston, MA 02110-1301, USA. |
22 | ** |
23 | ****************************************************************************/ |
24 | |
25 | #ifndef TYPEHELPER_H |
26 | #define TYPEHELPER_H |
27 | |
28 | #include <QFlags> |
29 | #include <QList> |
30 | #include <QString> |
31 | #include <QStringList> |
32 | |
33 | class QRegExp; |
34 | |
35 | /** |
36 | holds a set of supported compilers |
37 | and type conversation methods |
38 | */ |
39 | class CompilerTypes { |
40 | public: |
41 | // Please do not change the constants, they are used in installation config files |
42 | enum Type { |
43 | Unspecified=0, |
44 | MinGW=1, |
45 | MSVC=2, |
46 | MSVC8=2, |
47 | MSVC9=3, |
48 | MSVC10=4, |
49 | MinGW4=5, |
50 | MSVC10_X64=6, |
51 | MinGW4_W32=7, |
52 | MinGW4_W64=8 |
53 | }; |
54 | enum Scope { |
55 | allCompiler, |
56 | supportedCompiler, |
57 | }; |
58 | |
59 | CompilerTypes(Scope scope=supportedCompiler); |
60 | ~CompilerTypes(); |
61 | |
62 | /** |
63 | returns a list of string with support compilers |
64 | */ |
65 | const QStringList &values(); |
66 | |
67 | /** |
68 | returns description of specific compiler |
69 | @param type compiler type |
70 | @return description usable in gui |
71 | */ |
72 | const QString description(Type type); |
73 | |
74 | /** |
75 | returns state if the requested compiler is supported |
76 | @param type type of compiler |
77 | @return true if compiler is suppoprted |
78 | */ |
79 | bool contains(Type type); |
80 | |
81 | /** |
82 | returns regular expression of supported compilers |
83 | which could be used to match package file names. |
84 | @return regular expression instance |
85 | */ |
86 | QRegExp ®ex(); |
87 | |
88 | /** |
89 | returns regular expression of supported compilers which could |
90 | be used to match the end of a package file names. |
91 | @return regular expression instance |
92 | */ |
93 | QRegExp &endswith(); |
94 | |
95 | // convert a string to compiler type |
96 | Type fromString(const QString &type); |
97 | |
98 | // convert a compiler type to a string |
99 | const QString toString(Type compilerType); |
100 | |
101 | protected: |
102 | QList<Type> m_types; |
103 | QStringList m_typeStrings; |
104 | QStringList m_descriptions; |
105 | QRegExp *m_containsRegExp; |
106 | QRegExp *m_endsRegExp; |
107 | }; |
108 | |
109 | extern CompilerTypes supportedCompilers; |
110 | extern CompilerTypes allCompilers; |
111 | |
112 | class FileTypes { |
113 | public: |
114 | enum Type { |
115 | NONE = 0, BIN = 1 ,LIB = 2 ,DOC = 4 ,SRC = 8, DBG = 16, ALL = 31, ANY = 32, META = 95 |
116 | }; |
117 | Q_DECLARE_FLAGS(Types,Type); |
118 | static Type fromString(const QString &type); |
119 | static const QString toString(Type type); |
120 | static const QStringList values(); |
121 | static QRegExp ®ex(); |
122 | static QRegExp &endswith(); |
123 | }; |
124 | Q_DECLARE_OPERATORS_FOR_FLAGS(FileTypes::Types); |
125 | |
126 | #endif |
127 | |