Manual for OpenFLUID 2.1.10

WareSrcFiletypeManager.hpp
Go to the documentation of this file.
1 /*
2 
3  This file is part of OpenFLUID software
4  Copyright(c) 2007, INRA - Montpellier SupAgro
5 
6 
7  == GNU General Public License Usage ==
8 
9  OpenFLUID is free software: you can redistribute it and/or modify
10  it under the terms of the GNU General Public License as published by
11  the Free Software Foundation, either version 3 of the License, or
12  (at your option) any later version.
13 
14  OpenFLUID is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU General Public License for more details.
18 
19  You should have received a copy of the GNU General Public License
20  along with OpenFLUID. If not, see <http://www.gnu.org/licenses/>.
21 
22 
23  == Other Usage ==
24 
25  Other Usage means a use of OpenFLUID that is inconsistent with the GPL
26  license, and requires a written agreement between You and INRA.
27  Licensees for Other Usage of OpenFLUID may use this file in accordance
28  with the terms contained in the written agreement between You and INRA.
29 
30  */
31 
32 
33 /**
34  @file WareSrcFiletypeManager.hpp
35  @brief Header of ...
36 
37  @author Aline LIBRES <aline.libres@gmail.com>
38  @author Jean-Christophe Fabre <jean-christophe.fabre@inra.fr>
39 */
40 
41 
42 #ifndef __OPENFLUID_UIWARESDEV_WARESRCFILETYPEMANAGER_HPP__
43 #define __OPENFLUID_UIWARESDEV_WARESRCFILETYPEMANAGER_HPP__
44 
45 
46 #include <QTextCharFormat>
47 #include <QMap>
48 #include <QRegExp>
49 #include <QDomElement>
50 #include <QFile>
51 
52 #include <openfluid/dllexport.hpp>
55 
56 
57 namespace openfluid { namespace ui { namespace waresdev {
58 
59 
60 class WareSrcFiletype;
61 
62 
64 {
65 
67 
68  public:
69 
71  {
72  QString StyleName;
73 
74  QRegExp Pattern;
75 
76  QRegExp EndPattern;
77 
78  QTextCharFormat Format;
79 
81  { }
82 
83  HighlightingRule(const QString& AStyleName, QRegExp APattern, QTextCharFormat AFormat) :
84  StyleName(AStyleName), Pattern(APattern), EndPattern(QRegExp()), Format(AFormat)
85  { }
86 
87  HighlightingRule(const QString& AStyleName, QRegExp ABeginPattern, QRegExp AnEndPattern,
88  QTextCharFormat AFormat) :
89  StyleName(AStyleName), Pattern(ABeginPattern), EndPattern(AnEndPattern), Format(AFormat)
90  { }
91  };
92 
93  typedef QVector<HighlightingRule> HighlightingRules_t;
94 
95 
96  private:
97 
98  struct WareSrcFiletype
99  {
100  QString m_Extensions;
101 
102  QString m_LangCode;
103 
104  QString m_IconPath;
105 
106  QString m_HlFilename;
107 
108  QString m_CompFilename;
109 
111  };
112 
113  QMap<QString, QTextCharFormat> m_Formats;
114 
115  QMap<QString, QString> m_IconsByFileExtensionList;
116 
117  QMap<QString, WareSrcFiletype> m_WareSrcFiletypes;
118 
120 
122 
123  /**
124  @throw openfluid::base::FrameworkException
125  */
126  QDomElement openWaresdevFile(const QString& FilePath);
127 
128  void initializeFileTypes();
129 
130  /**
131  @throw openfluid::base::FrameworkException
132  */
133  HighlightingRules_t parseSyntaxFile(const QString& FilePath);
134 
135 
136  public:
137 
138  void updateStyles();
139 
140  QMap<QString, QString> getIconsByFileExtensionList() const;
141 
142  HighlightingRules_t getHighlightingRules(const QString& FilePath) const;
143 
144  QString getFileType(const QString& FilePath) const;
145 
146  QString getFileLanguage(const QString& FilePath) const;
147 
148 };
149 
150 
151 } } } // namespaces
152 
153 
154 #endif /* __OPENFLUID_UIWARESDEV_WARESRCFILETYPEMANAGER_HPP__ */
Definition: WareSrcFiletypeManager.hpp:63
Definition: ApplicationException.hpp:47
#define OPENFLUID_SINGLETON_DEFINITION(T)
Definition: SingletonMacros.hpp:55
QRegExp EndPattern
Definition: WareSrcFiletypeManager.hpp:76
QString StyleName
Definition: WareSrcFiletypeManager.hpp:72
QTextCharFormat Format
Definition: WareSrcFiletypeManager.hpp:78
Header of ...
HighlightingRule(const QString &AStyleName, QRegExp APattern, QTextCharFormat AFormat)
Definition: WareSrcFiletypeManager.hpp:83
QVector< HighlightingRule > HighlightingRules_t
Definition: WareSrcFiletypeManager.hpp:93
QRegExp Pattern
Definition: WareSrcFiletypeManager.hpp:74
HighlightingRule(const QString &AStyleName, QRegExp ABeginPattern, QRegExp AnEndPattern, QTextCharFormat AFormat)
Definition: WareSrcFiletypeManager.hpp:87
#define OPENFLUID_API
Definition: dllexport.hpp:86
HighlightingRule()
Definition: WareSrcFiletypeManager.hpp:80