Documentation for OpenFLUID 2.2.0
CompletionProvider.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 CompletionProvider.hpp
35 
36  @author Jean-Christophe Fabre <jean-christophe.fabre@inra.fr>
37 */
38 
39 
40 #ifndef __OPENFLUID_UIWARESDEV_COMPLETIONPROVIDER_HPP__
41 #define __OPENFLUID_UIWARESDEV_COMPLETIONPROVIDER_HPP__
42 
43 
44 #include <QObject>
45 #include <QString>
46 #include <QMap>
47 #include <QVector>
48 #include <QFlags>
49 #include <QStringList>
50 
51 #include <openfluid/dllexport.hpp>
52 #include <openfluid/ware/TypeDefs.hpp>
54 
55 
56 namespace openfluid { namespace ui { namespace waresdev {
57 
58 
59 class OPENFLUID_API CompletionProvider : public QObject
60 {
61  Q_OBJECT
62 
64 
65 
66  public:
67 
68  enum class Origin
69  {
70  OPENFLUID,
71  CPP,
72  UNDEFINED
73  };
74 
75  enum class ContextFlags
76  {
77  ANYWARE = 1 << 0,
78  SIMULATOR = 1 << 2,
79  OBSERVER = 1 << 3,
80  BUILDEREXT = 1 << 4
81  };
82  Q_DECLARE_FLAGS(Context, ContextFlags)
83 
84  struct Rule
85  {
86  QString ProgLangCode;
87 
89 
90  Context DevContext;
91 
92  QStringList MenuPath;
93 
94  QString Title;
95 
96  QString Content;
97 
98 
99  Rule() = default;
100 
101  Rule(QString LangCode, Origin O, Context Ctxt,
102  const QStringList& M, const QString& T, const QString& C) :
103  ProgLangCode(LangCode), Orig(O), DevContext(Ctxt), MenuPath(M), Title(T), Content(C)
104  { }
105 
106  };
107 
108  using Rules = QVector<Rule>;
109 
110  using RulesByWareType = QMap<openfluid::ware::WareType,Rules>;
111 
112  using RulesByLanguageByWareType = QMap<QString,RulesByWareType>;
113 
114 
115  private:
116 
118 
119  Rules m_NoRule;
120 
121  void addRule(const Rule& R);
122 
123  void initializeCppRules();
124 
125 
126  public:
127 
129 
131  { }
132 
133  const Rules& getRules(QString LangCode, openfluid::ware::WareType Wtype);
134 };
135 
136 
137 Q_DECLARE_OPERATORS_FOR_FLAGS(CompletionProvider::Context)
138 
139 
140 } } } // namespaces
141 
142 
143 #endif /* __OPENFLUID_UIWARESDEV_COMPLETIONPROVIDER_HPP__ */
#define OPENFLUID_SINGLETON_DEFINITION(T)
Definition: SingletonMacros.hpp:55
Definition: CompletionProvider.hpp:60
ContextFlags
Definition: CompletionProvider.hpp:76
QMap< openfluid::ware::WareType, Rules > RulesByWareType
Definition: CompletionProvider.hpp:110
Origin
Definition: CompletionProvider.hpp:69
QVector< Rule > Rules
Definition: CompletionProvider.hpp:108
QMap< QString, RulesByWareType > RulesByLanguageByWareType
Definition: CompletionProvider.hpp:112
const Rules & getRules(QString LangCode, openfluid::ware::WareType Wtype)
virtual ~CompletionProvider()
Definition: CompletionProvider.hpp:130
#define OPENFLUID_API
Definition: dllexport.hpp:86
WareType
Definition: TypeDefs.hpp:61
Definition: ApplicationException.hpp:47
Definition: CompletionProvider.hpp:85
QString Title
Definition: CompletionProvider.hpp:94
QStringList MenuPath
Definition: CompletionProvider.hpp:92
QString Content
Definition: CompletionProvider.hpp:96
Rule(QString LangCode, Origin O, Context Ctxt, const QStringList &M, const QString &T, const QString &C)
Definition: CompletionProvider.hpp:101
Origin Orig
Definition: CompletionProvider.hpp:88
QString ProgLangCode
Definition: CompletionProvider.hpp:86
Context DevContext
Definition: CompletionProvider.hpp:90