All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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  */
39 
40 
41 #ifndef __OPENFLUID_UIWARESDEV_WARESRCFILETYPEMANAGER_HPP__
42 #define __OPENFLUID_UIWARESDEV_WARESRCFILETYPEMANAGER_HPP__
43 
44 #include <openfluid/dllexport.hpp>
45 
46 #include <QTextCharFormat>
47 #include <QMap>
48 #include <QRegExp>
49 #include <QDomElement>
50 #include <QFile>
51 
53 
54 
55 namespace openfluid { namespace ui { namespace waresdev {
56 
57 class WareSrcFiletype;
58 
60 {
61  public:
62 
64  {
65  QString StyleName;
66  QRegExp Pattern;
67  QRegExp EndPattern;
68  QTextCharFormat Format;
70  {
71  }
72  HighlightingRule(const QString& AStyleName, QRegExp APattern, QTextCharFormat AFormat) :
73  StyleName(AStyleName), Pattern(APattern), EndPattern(QRegExp()), Format(AFormat)
74  {
75  }
76  HighlightingRule(const QString& AStyleName, QRegExp ABeginPattern, QRegExp AnEndPattern,
77  QTextCharFormat AFormat) :
78  StyleName(AStyleName), Pattern(ABeginPattern), EndPattern(AnEndPattern), Format(AFormat)
79  {
80  }
81  };
82 
83  typedef QVector<HighlightingRule> HighlightingRules_t;
84 
86  {
87  QString MenuPath;
88  QString Title;
89  QString Content;
91  QString IconPath;
93  IsForCompletion(false)
94  {
95  }
96  CompletionRule(const QString& AMenuPath, const QString& ATitle, const QString& AContent, bool AIsForCompletion,
97  const QString& AIconPath) :
98  MenuPath(AMenuPath), Title(ATitle), Content(AContent), IsForCompletion(AIsForCompletion),
99  IconPath(AIconPath)
100  {
101  }
102  };
103 
104  typedef QVector<CompletionRule> CompletionRules_t;
105  typedef QMap<openfluid::waresdev::WareSrcManager::WareType, CompletionRules_t> CompletionRulesByWareType_t;
106 
107  private:
108 
109  struct WareSrcFiletype
110  {
111  QString m_Extensions;
112 
113  QString m_IconPath;
114 
115  QString m_HlFilename;
116  QString m_CompFilename;
117 
120  };
121 
122  static WareSrcFiletypeManager* mp_Instance;
123 
124  QMap<QString, QTextCharFormat> m_Formats;
125 
126  QMap<QString, QString> m_IconsByFileExtensionList;
127 
128  QMap<QString, WareSrcFiletype> m_WareSrcFiletypes;
129 
131 
132  /**
133  * @throw openfluid::base::FrameworkException
134  */
135  QDomElement openWaresdevFile(const QString& FilePath);
136 
137  /**
138  * @throw openfluid::base::FrameworkException
139  */
140  void parseFiletypeFile(const QString& FilePath);
141 
142  /**
143  * @throw openfluid::base::FrameworkException
144  */
145  HighlightingRules_t parseSyntaxFile(const QString& FilePath);
146 
147  /**
148  * @throw openfluid::base::FrameworkException
149  */
150  CompletionRulesByWareType_t parseCompletionFile(const QString& FilePath);
151 
152  QString getFileType(const QString& FileName) const;
153 
154 
155  public:
156 
158 
159  static WareSrcFiletypeManager* instance();
160 
161  void updateStyles();
162 
163  QMap<QString, QString> getIconsByFileExtensionList() const;
164 
165  HighlightingRules_t getHighlightingRules(const QString& FilePath) const;
166 
167  CompletionRules_t getCompletionRules(const QString& FilePath) const;
168 };
169 
170 
171 // =====================================================================
172 // =====================================================================
173 
174 
175 } } } // namespaces
176 
177 #endif /* __OPENFLUID_UIWARESDEV_WARESRCFILETYPEMANAGER_HPP__ */
QString Content
Definition: WareSrcFiletypeManager.hpp:89
QString StyleName
Definition: WareSrcFiletypeManager.hpp:65
QMap< openfluid::waresdev::WareSrcManager::WareType, CompletionRules_t > CompletionRulesByWareType_t
Definition: WareSrcFiletypeManager.hpp:105
HighlightingRule(const QString &AStyleName, QRegExp APattern, QTextCharFormat AFormat)
Definition: WareSrcFiletypeManager.hpp:72
CompletionRule()
Definition: WareSrcFiletypeManager.hpp:92
QVector< HighlightingRule > HighlightingRules_t
Definition: WareSrcFiletypeManager.hpp:83
QVector< CompletionRule > CompletionRules_t
Definition: WareSrcFiletypeManager.hpp:104
Definition: WareSrcFiletypeManager.hpp:59
CompletionRule(const QString &AMenuPath, const QString &ATitle, const QString &AContent, bool AIsForCompletion, const QString &AIconPath)
Definition: WareSrcFiletypeManager.hpp:96
QRegExp EndPattern
Definition: WareSrcFiletypeManager.hpp:67
QString MenuPath
Definition: WareSrcFiletypeManager.hpp:87
bool IsForCompletion
Definition: WareSrcFiletypeManager.hpp:90
QString Title
Definition: WareSrcFiletypeManager.hpp:88
HighlightingRule(const QString &AStyleName, QRegExp ABeginPattern, QRegExp AnEndPattern, QTextCharFormat AFormat)
Definition: WareSrcFiletypeManager.hpp:76
#define OPENFLUID_API
Definition: dllexport.hpp:87
QRegExp Pattern
Definition: WareSrcFiletypeManager.hpp:66
QString IconPath
Definition: WareSrcFiletypeManager.hpp:91
QTextCharFormat Format
Definition: WareSrcFiletypeManager.hpp:68
Header of ...
HighlightingRule()
Definition: WareSrcFiletypeManager.hpp:69