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@supagro.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 
96  {
97  QString MenuPath;
98 
99  QString Title;
100 
101  QString Content;
102 
104 
105  QString IconPath;
106 
108  IsForCompletion(false)
109  { }
110 
111  CompletionRule(const QString& AMenuPath, const QString& ATitle, const QString& AContent, bool AIsForCompletion,
112  const QString& AIconPath) :
113  MenuPath(AMenuPath), Title(ATitle), Content(AContent), IsForCompletion(AIsForCompletion), IconPath(AIconPath)
114  { }
115  };
116 
117  typedef QVector<CompletionRule> CompletionRules_t;
118  typedef QMap<openfluid::ware::WareType, CompletionRules_t> CompletionRulesByWareType_t;
119 
120 
121  private:
122 
123  struct WareSrcFiletype
124  {
125  QString m_Extensions;
126 
127  QString m_IconPath;
128 
129  QString m_HlFilename;
130 
131  QString m_CompFilename;
132 
134 
136  };
137 
138  QMap<QString, QTextCharFormat> m_Formats;
139 
140  QMap<QString, QString> m_IconsByFileExtensionList;
141 
142  QMap<QString, WareSrcFiletype> m_WareSrcFiletypes;
143 
145 
147 
148  /**
149  @throw openfluid::base::FrameworkException
150  */
151  QDomElement openWaresdevFile(const QString& FilePath);
152 
153  /**
154  @throw openfluid::base::FrameworkException
155  */
156  void parseFiletypeFile(const QString& FilePath);
157 
158  /**
159  @throw openfluid::base::FrameworkException
160  */
161  HighlightingRules_t parseSyntaxFile(const QString& FilePath);
162 
163  /**
164  @throw openfluid::base::FrameworkException
165  */
166  CompletionRulesByWareType_t parseCompletionFile(const QString& FilePath);
167 
168  QString getFileType(const QString& FileName) const;
169 
170 
171  public:
172 
173  void updateStyles();
174 
175  QMap<QString, QString> getIconsByFileExtensionList() const;
176 
177  HighlightingRules_t getHighlightingRules(const QString& FilePath) const;
178 
179  CompletionRules_t getCompletionRules(const QString& FilePath) const;
180 
181 };
182 
183 
184 } } } // namespaces
185 
186 
187 #endif /* __OPENFLUID_UIWARESDEV_WARESRCFILETYPEMANAGER_HPP__ */
Definition: WareSrcFiletypeManager.hpp:63
HighlightingRule(const QString &AStyleName, QRegExp ABeginPattern, QRegExp AnEndPattern, QTextCharFormat AFormat)
Definition: WareSrcFiletypeManager.hpp:87
QRegExp EndPattern
Definition: WareSrcFiletypeManager.hpp:76
HighlightingRule(const QString &AStyleName, QRegExp APattern, QTextCharFormat AFormat)
Definition: WareSrcFiletypeManager.hpp:83
QTextCharFormat Format
Definition: WareSrcFiletypeManager.hpp:78
QString Title
Definition: WareSrcFiletypeManager.hpp:99
QMap< openfluid::ware::WareType, CompletionRules_t > CompletionRulesByWareType_t
Definition: WareSrcFiletypeManager.hpp:118
CompletionRule()
Definition: WareSrcFiletypeManager.hpp:107
CompletionRule(const QString &AMenuPath, const QString &ATitle, const QString &AContent, bool AIsForCompletion, const QString &AIconPath)
Definition: WareSrcFiletypeManager.hpp:111
QString Content
Definition: WareSrcFiletypeManager.hpp:101
QString IconPath
Definition: WareSrcFiletypeManager.hpp:105
#define OPENFLUID_SINGLETON_DEFINITION(T)
Definition: SingletonMacros.hpp:78
Definition: ApplicationException.hpp:47
HighlightingRule()
Definition: WareSrcFiletypeManager.hpp:80
Header of ...
#define OPENFLUID_API
Definition: dllexport.hpp:87
QRegExp Pattern
Definition: WareSrcFiletypeManager.hpp:74
QVector< HighlightingRule > HighlightingRules_t
Definition: WareSrcFiletypeManager.hpp:93
QVector< CompletionRule > CompletionRules_t
Definition: WareSrcFiletypeManager.hpp:117
QString StyleName
Definition: WareSrcFiletypeManager.hpp:72
QString MenuPath
Definition: WareSrcFiletypeManager.hpp:97
bool IsForCompletion
Definition: WareSrcFiletypeManager.hpp:103