MorphoGraphX  2.0-1-227
ProcessParmsModel.hpp
Go to the documentation of this file.
1 //
2 // This file is part of MorphoGraphX - http://www.MorphoGraphX.org
3 // Copyright (C) 2012-2019 Richard S. Smith and collaborators.
4 //
5 // If you use MorphoGraphX in your work, please cite:
6 // http://dx.doi.org/10.7554/eLife.05864
7 //
8 // MorphoGraphX is free software, and is licensed under under the terms of the
9 // GNU General (GPL) Public License version 2.0, http://www.gnu.org/licenses.
10 //
11 #ifndef PROCESS_PARMS_MODEL_HPP
12 #define PROCESS_PARMS_MODEL_HPP
13 
14 #include <Process.hpp>
15 
16 #include <QAbstractTableModel>
17 #include <QStyledItemDelegate>
18 
19 class FreeFloatDelegate : public QStyledItemDelegate
20 {
21  Q_OBJECT
22 public:
23  FreeFloatDelegate(QObject* parent = 0);
24  QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const;
25  void setEditorData(QWidget* editor, const QModelIndex& index) const;
26  void setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const;
27  void updateEditorGeometry(QWidget* editor, const QStyleOptionViewItem& option, const QModelIndex& index) const;
28 };
29 
30 class ProcessParmsModel : public QAbstractTableModel
31 {
32  Q_OBJECT
33 public:
34  ProcessParmsModel(QObject* parent = 0) : QAbstractTableModel(parent) {}
35  void setParms(const mgx::ProcessDefinition& def);
36  void setParms(const QStringList &parms);
37  void clear();
38 
39  int rowCount(const QModelIndex& /*parent*/ = QModelIndex()) const {
40  return names.size();
41  }
42  int columnCount(const QModelIndex& /*parent*/ = QModelIndex()) const {
43  return 2;
44  }
45  QVariant data(const QModelIndex& index, int role) const;
46  QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
47  Qt::ItemFlags flags(const QModelIndex& index) const;
48  bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole);
49  const QStringList &parms() const { return _parms; }
50 
51  QStringList parmChoice(int pos) const;
52 
53 signals:
54  void valuesChanged();
55 
56 protected:
57  QStringList names;
58  QStringList descs;
59  QStringList _parms;
61 };
62 #endif
FreeFloatDelegate::updateEditorGeometry
void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const
FreeFloatDelegate
Definition: ProcessParmsModel.hpp:19
Process.hpp
ProcessParmsModel::headerData
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const
ProcessParmsModel::clear
void clear()
FreeFloatDelegate::createEditor
QWidget * createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const
ProcessParmsModel::descs
QStringList descs
Definition: ProcessParmsModel.hpp:58
ProcessParmsModel::setData
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole)
ProcessParmsModel::parmChoice
QStringList parmChoice(int pos) const
FreeFloatDelegate::setEditorData
void setEditorData(QWidget *editor, const QModelIndex &index) const
ProcessParmsModel::_parmChoice
mgx::ParmChoiceList _parmChoice
Definition: ProcessParmsModel.hpp:60
ProcessParmsModel::parms
const QStringList & parms() const
Definition: ProcessParmsModel.hpp:49
mgx::ParmChoiceList
QList< QStringList > ParmChoiceList
Type of the dictionary giving the list of possible strings for each argument.
Definition: ProcessParms.hpp:31
ProcessParmsModel::names
QStringList names
Definition: ProcessParmsModel.hpp:57
ProcessParmsModel::ProcessParmsModel
ProcessParmsModel(QObject *parent=0)
Definition: ProcessParmsModel.hpp:34
ProcessParmsModel::setParms
void setParms(const mgx::ProcessDefinition &def)
ProcessParmsModel::rowCount
int rowCount(const QModelIndex &=QModelIndex()) const
Definition: ProcessParmsModel.hpp:39
ProcessParmsModel::valuesChanged
void valuesChanged()
ProcessParmsModel
Definition: ProcessParmsModel.hpp:30
FreeFloatDelegate::setModelData
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
ProcessParmsModel::_parms
QStringList _parms
Definition: ProcessParmsModel.hpp:59
FreeFloatDelegate::FreeFloatDelegate
FreeFloatDelegate(QObject *parent=0)
ProcessParmsModel::columnCount
int columnCount(const QModelIndex &=QModelIndex()) const
Definition: ProcessParmsModel.hpp:42
ProcessParmsModel::data
QVariant data(const QModelIndex &index, int role) const
ProcessParmsModel::flags
Qt::ItemFlags flags(const QModelIndex &index) const
mgx::ProcessDefinition
Definition: Process.hpp:873