tuchulcha  0.10.1
Graphical Workflow Configuration Editor
ParameterFileModel.h
Go to the documentation of this file.
1 /* Copyright (C) 2009 Jens-Malte Gottfried
2 
3  This file is part of Tuchulcha.
4 
5  Tuchulcha is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License, or
8  (at your option) any later version.
9 
10  Tuchulcha is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with Tuchulcha. If not, see <http://www.gnu.org/licenses/>.
17 */
24 #ifndef PARAMETERFILEMODEL_H_
25 #define PARAMETERFILEMODEL_H_
26 
27 #include <QAbstractTableModel>
28 #include <QStringList>
29 
30 class QParameterFile;
31 class QMutex;
32 class MetaData;
33 class PrefixValidator;
34 
37 class ParameterFileModel: public QAbstractTableModel {
38  Q_OBJECT
39  Q_PROPERTY(QString _fileName READ fileName WRITE setFileName)
40  Q_PROPERTY(QString _prefix READ prefix WRITE setPrefix)
41  Q_PROPERTY(bool _useMetaInfo READ useMetaInfo WRITE setUseMetaInfo)
42  Q_PROPERTY(bool _onlyParams READ onlyParams WRITE setOnlyParams)
43  Q_PROPERTY(int _minPriority READ minPriority WRITE setMinPriority)
44 
45 public:
47 
53  QString fileName = "", QObject* parent = 0, QString metaFile = "");
54 
56  virtual ~ParameterFileModel();
57 
59  // \{
60 
62 
65  virtual int rowCount(const QModelIndex& parent = QModelIndex()) const;
66 
68 
71  virtual int columnCount(const QModelIndex& parent = QModelIndex()) const;
72 
74 
79  virtual QVariant data(
80  const QModelIndex& index, int role = Qt::DisplayRole) const;
81 
83 
90  virtual bool setData (
91  const QModelIndex& index, const QVariant& value,
92  int role = Qt::EditRole);
93 
95 
98  virtual Qt::ItemFlags flags (const QModelIndex& index) const;
99 
101 
106  virtual QVariant headerData (
107  int section, Qt::Orientation orientation,
108  int role = Qt::DisplayRole) const;
109 
111 
117  virtual bool insertRows (
118  int row, int count,
119  const QModelIndex& parent = QModelIndex());
120 
122 
128  virtual bool removeRows (
129  int row, int count,
130  const QModelIndex& parent = QModelIndex());
131 
132  virtual Qt::DropActions supportedDropActions() const;
133 
134  virtual QStringList mimeTypes() const;
135 
136  virtual bool dropMimeData(const QMimeData *data, Qt::DropAction action,
137  int row, int column, const QModelIndex &parent);
138 
139  // \} // model/view interface
140 
143 
145  void deactivate();
146 
148  void reactivate();
149 
151  bool active() const;
152 
154  QString fileName() const;
155 
157  QString prefix() const;
158 
160  bool useMetaInfo() const;
161 
163  bool onlyParams() const;
164 
166  int minPriority() const;
167 
169  const QParameterFile& parameterFile() const;
170 
172  bool prefixValid() const;
173 
175  // \{
177  bool metaInfoValid() const;
178 
180  QStringList getClasses() const;
181 
183 
187  QString getClass(QString objName, bool fixCase = false) const;
188 
190 
195  QString getType(QString parName, bool applyTmplType = true) const;
196 
198  QString getDefault(QString parName) const;
199 
201  QString getDoc(QString parName) const;
202 
204 
207  QStringList getInputs(QString objName) const;
208 
210 
213  QStringList getInputDisplayNames(QString objName) const;
214 
216 
219  QStringList getOutputs(QString objName) const;
220 
222 
225  QStringList getOutputDisplayNames(QString objName) const;
226 
228 
231  QStringList getParameters(QString objName) const;
232 
234 
237  bool isParameter(QString name) const;
238 
240 
243  bool isInputSlot(QString name) const;
244 
246 
249  bool isOutputSlot(QString name) const;
250 
252 
255  bool isMultiSlot(QString name) const;
256  // \}
257 
259  // \{
261 
264  QString getValue(QString parName) const;
265 
267 
270  void setValue(QString parName, QString value);
271 
273  bool isSet(QString parName) const;
274 
276 
278  void erase(QString parName);
279 
281 
282  bool rename(QString oldPrefix, QString newPrefix);
283  // \}
284 
285 signals:
287 
288  void fileNameChanged(QString fileName);
289 
291 
292  void prefixChanged(const QString& prefix);
293 
295 
296  void metaInfoChanged(bool valid);
297 
299 
300  void useMetaInfoChanged(bool value);
301 
303 
304  void onlyParamsChanged(bool value);
305 
307 
308  void minPriorityChanged(int value);
309 
311 
312  void statusMessage(const QString& msg);
313 
315  void modified(bool val );
316 
318  void commentChanged(QString comment);
319 
321  void dynamicUpdate();
322 
323 public slots:
325 
326  virtual void setFileName(const QString& fileName);
327 
329 
332  virtual QString setPrefix(const QString& prefix);
333 
335  void setHandleDynamics(bool);
336 
338 
339  virtual void loadMetaInfo(const QString& fileName);
340 
342 
343  void setUseMetaInfo(bool value);
344 
346 
347  void setOnlyParams(bool value);
348 
350 
351  void setMinPriority(int value);
352 
354 
358  virtual bool load(const QString& fName = "");
359 
361  virtual void clear();
362 
364 
368  virtual void save(const QString& fileName = "");
369 
370 protected slots:
372 
373  virtual bool _load();
374 
376  virtual void _update();
377 
379  virtual void _updatePriority(const QModelIndex &topLeft,
380  const QModelIndex &bottomRight);
381 
382 protected:
384  QMutex* _resetMutex;
385 
386 private:
389 
391  QStringList _keys;
392 
394  QString _fileName;
395 
397  QString _prefix;
398 
401 
403  QMap<QString,QString> _classCaseMap;
404 
406  bool _useMetaInfo;
407 
409  bool _onlyParams;
410 
412  int _minPriority;
413 
416 
418  void _updateDynamics();
419 
421 
424  QStringList _collectObjects(QStringList list) const;
425 
427 
430  QStringList _prefixFilter(QStringList list) const;
431 
433 
436  QStringList _paramFilter(QStringList list) const;
437 
439 
442  QStringList _priorityTagFilter(QStringList list) const;
443 
445 
448  QStringList _priorityFilter(QStringList list) const;
449 
451  QString _getDynamicMetaFile(QString objName) const;
452 };
453 
454 #endif /* PARAMETERFILEMODEL_H_ */
bool _handleDynamics
handle dynamics by calling update-dynamics process
void setOnlyParams(bool value)
Set property _onlyparams.
void reactivate()
Reactivate all following plugins.
void commentChanged(QString comment)
inform about editor comment change
void statusMessage(const QString &msg)
send status message
void erase(QString parName)
Delete a parameter from the the underlying parameter file.
virtual void save(const QString &fileName="")
Save model content to a text file.
void setMinPriority(int value)
Set property _minPriority.
virtual void _update()
Update content (e.g. when prefix has changed)
QParameterFile * _parameterFile
Pointer to the ParameterFile instance storing the model content.
virtual QString setPrefix(const QString &prefix)
Change prefix.
void setHandleDynamics(bool)
set _handleDynamics
bool rename(QString oldPrefix, QString newPrefix)
rename prefix
bool _useMetaInfo
toggle usage of metadata
void dynamicUpdate()
inform about dynamic plugin update
QStringList getClasses() const
get classes contained in metadata file
bool metaInfoValid() const
check for available metaInfos
QString getValue(QString parName) const
Get a parameter from the underlying parameter file.
void fileNameChanged(QString fileName)
Property _fileName has changed.
QString _fileName
Store filename of the model data file.
const QParameterFile & parameterFile() const
Get const pointer of ParameterFile.
QMutex * _resetMutex
avoid multiple reset model calls
QString getDefault(QString parName) const
pass to metaInfo, use dynamic metadata if needed
Handle metadata management for ParameterFileModel classes.
Definition: MetaData.h:31
int _minPriority
minimum priority to be listed
void _updateDynamics()
update dynamic objects
QStringList getInputs(QString objName) const
Get input slots of object.
QString prefix() const
Get property _prefix.
QMap< QString, QString > _classCaseMap
map to fix class name cases
QStringList getOutputs(QString objName) const
Get output slots of object.
QStringList getOutputDisplayNames(QString objName) const
Get output slots of object.
virtual void loadMetaInfo(const QString &fileName)
load metaFile
QStringList _keys
Cache stored parameter names.
virtual void _updatePriority(const QModelIndex &topLeft, const QModelIndex &bottomRight)
Update filter if priority changed.
QString getClass(QString objName, bool fixCase=false) const
get class of some given object
virtual int rowCount(const QModelIndex &parent=QModelIndex()) const
Return number of table rows.
virtual bool insertRows(int row, int count, const QModelIndex &parent=QModelIndex())
Add data to the model.
bool isMultiSlot(QString name) const
Check if some slot is a multi slot.
const MetaData * _metaInfos
ParameterFile describing classes and in-/output slots.
QStringList getInputDisplayNames(QString objName) const
Get input slots of object.
bool isParameter(QString name) const
Check if some parameter/slot is a parameter.
Qt implementation for ParameterFile class.
This model serves to provide a model frontend to access a ParameterFile instance. ...
virtual QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const
Access to item content.
virtual QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const
Data for the table headers.
bool isSet(QString parName) const
pass to QParameterFile::isSet
bool _onlyParams
only show configurable parameters
bool prefixValid() const
Check prefix.
void deactivate()
Deactivate all following plugins.
void useMetaInfoChanged(bool value)
Property _useMetadata changed.
virtual void setFileName(const QString &fileName)
Set new value for Property _fileName.
QStringList _prefixFilter(QStringList list) const
filter keys starting with the given prefix
void prefixChanged(const QString &prefix)
Property _prefix has changed.
virtual bool load(const QString &fName="")
Load model content from parameterFile.
QString fileName() const
Get property _fileName.
QString getDoc(QString parName) const
pass to metaInfo, use dynamic metadata if needed
bool active() const
Returns the bool value of the Active Parameter.
QStringList _collectObjects(QStringList list) const
Return set of objects contained in given parameter list.
virtual Qt::ItemFlags flags(const QModelIndex &index) const
Item flags (editable etc).
bool isOutputSlot(QString name) const
Check if some parameter/slot is an output slot.
void minPriorityChanged(int value)
Property _minPriority changed.
void reactivatePreviousPlugins()
Reactivates all previous plugins.
void setValue(QString parName, QString value)
Set a parameter in the underlying parameter file.
Validator for prefix edit widgets.
virtual int columnCount(const QModelIndex &parent=QModelIndex()) const
Return number of table columns.
bool useMetaInfo() const
Get property _useMetadata;.
void metaInfoChanged(bool valid)
New metadata have been loaded.
void modified(bool val)
inform about modifications
virtual bool _load()
Load data without showing OpenFile Dialog.
bool onlyParams() const
Get property _onlyparams.
void setUseMetaInfo(bool value)
Set property _useMetadata.
void onlyParamsChanged(bool value)
Property _onlyParams changed.
virtual void clear()
Clear ParameterFile content.
QString _getDynamicMetaFile(QString objName) const
creates path to dynamic meta info file for object
QStringList _paramFilter(QStringList list) const
filter keys listed in the classes parameter section
QString getType(QString parName, bool applyTmplType=true) const
Get type of some parameter or slot.
QStringList getParameters(QString objName) const
Get parameters of object.
virtual bool removeRows(int row, int count, const QModelIndex &parent=QModelIndex())
Remove data from the model.
int minPriority() const
Get property _minPriority.
bool isInputSlot(QString name) const
Check if some parameter/slot is an input slot.
virtual bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole)
Set item content.
QStringList _priorityTagFilter(QStringList list) const
filter keys containing priority information
QStringList _priorityFilter(QStringList list) const
filter keys depending on their priority
QString _prefix
Parameter prefix.