Engauge Digitizer  2
CurveNameList.h
1 /******************************************************************************************************
2  * (C) 2014 markummitchell@github.com. This file is part of Engauge Digitizer, which is released *
3  * under GNU General Public License version 2 (GPLv2) or (at your option) any later version. See file *
4  * LICENSE or go to gnu.org/licenses for details. Distribution requires prior written permission. *
5  ******************************************************************************************************/
6 
7 #ifndef CURVE_NAME_LIST_H
8 #define CURVE_NAME_LIST_H
9 
10 #include <QHash>
11 #include <QStandardItemModel>
12 #include <QString>
13 #include <QVector>
14 
15 // Data associated with the current curve names in the QStandardItemModel
16 typedef QHash<QString, QString> CurrentCurveToOriginalCurve;
17 typedef QHash<QString, unsigned int> OriginalCurveToPointCount;
18 
19 // There is only one column, which is visible
20 enum CurveNameListColumns {
21  CURVE_NAME_LIST_COLUMN_CURRENT,
22  NUMBER_CURVE_NAME_LIST_COLUMNS
23 };
24 
27 class CurveNameList : public QStandardItemModel
28 {
29 public:
31  CurveNameList();
32 
34  virtual int columnCount (const QModelIndex &parent) const;
35 
37  bool containsCurveNameCurrent (const QString &curveName) const;
38 
40  QString currentCurvesAsString () const;
41 
43  QString currentCurveToOriginalCurve (const QString &currentCurve) const;
44 
46  unsigned int currentCurveToPointCount (const QString &currentCurve) const;
47 
49  virtual Qt::ItemFlags flags (const QModelIndex &index) const;
50 
52  void insertRow (int row,
53  const QString &curveCurrent,
54  const QString &curveOriginal,
55  unsigned int pointCount);
56 
58  virtual QStandardItem *item(int row, int column = 0) const;
59 
61  unsigned int numPointsForSelectedCurves (const QList<unsigned int> &rowsSelected) const;
62 
64  virtual bool removeRows (int row, int count, const QModelIndex &parent);
65 
67  void reset ();
68 
70  virtual int rowCount (const QModelIndex & parent = QModelIndex()) const;
71 
73  virtual bool setData (const QModelIndex &index,
74  const QVariant &value,
75  int role);
76 
78  virtual void setItem(int row, int column, QStandardItem *item);
79 
81  virtual Qt::DropActions supportedDropActions () const;
82 
83 private:
84 
86  bool curveNameIsAcceptable (const QString &curveNameNew,
87  int row) const;
88 
89  // Data from original curves
90  CurrentCurveToOriginalCurve m_currentCurveToOriginalCurve;
91  OriginalCurveToPointCount m_originalCurveToPointCount;
92 };
93 
94 #endif // CURVE_NAME_LIST_H
virtual int columnCount(const QModelIndex &parent) const
One column.
bool containsCurveNameCurrent(const QString &curveName) const
Return true if specified curve name is already in the list.
QString currentCurvesAsString() const
For debugging we dump the curve names.
virtual Qt::ItemFlags flags(const QModelIndex &index) const
Override normal flags with additional editing flags.
virtual void setItem(int row, int column, QStandardItem *item)
Store one curve name data.
QString currentCurveToOriginalCurve(const QString &currentCurve) const
Return the original curve for the specified current curve.
unsigned int numPointsForSelectedCurves(const QList< unsigned int > &rowsSelected) const
Return the number of points associated with the selected curves, as specified by their row numbers...
virtual bool removeRows(int row, int count, const QModelIndex &parent)
Remove one row.
unsigned int currentCurveToPointCount(const QString &currentCurve) const
Return the point count for the specified current curve.
virtual int rowCount(const QModelIndex &parent=QModelIndex()) const
One row per curve name.
virtual bool setData(const QModelIndex &index, const QVariant &value, int role)
Store data for one curve name.
virtual QStandardItem * item(int row, int column=0) const
Retrieve data from model.
virtual Qt::DropActions supportedDropActions() const
Allow dragging for reordering.
void insertRow(int row, const QString &curveCurrent, const QString &curveOriginal, unsigned int pointCount)
Create a new entry at the specified row.
Model for DlgSettingsCurveAddRemove and CmdSettingsCurveAddRemove.
Definition: CurveNameList.h:27
CurveNameList()
Default constructor.
void reset()
Clear all information.