Engauge Digitizer 2
Loading...
Searching...
No Matches
CurveNameList.h
Go to the documentation of this file.
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
16typedef QHash<QString, QString> CurrentCurveToOriginalCurve;
17typedef QHash<QString, unsigned int> OriginalCurveToPointCount;
18
19// There is only one column, which is visible
24
27class CurveNameList : public QStandardItemModel
28{
29public:
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
83private:
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
CurveNameListColumns
@ NUMBER_CURVE_NAME_LIST_COLUMNS
@ CURVE_NAME_LIST_COLUMN_CURRENT
QHash< QString, unsigned int > OriginalCurveToPointCount
QHash< QString, QString > CurrentCurveToOriginalCurve
Model for DlgSettingsCurveList and CmdSettingsCurveList.
void reset()
Clear all information.
bool containsCurveNameCurrent(const QString &curveName) const
Return true if specified curve name is already in the list.
virtual int columnCount(const QModelIndex &parent) const
One column.
virtual int rowCount(const QModelIndex &parent=QModelIndex()) const
One row per curve name.
unsigned int currentCurveToPointCount(const QString &currentCurve) const
Return the point count for the specified current curve.
QString currentCurvesAsString() const
For debugging we dump the curve names.
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 QStandardItem * item(int row, int column=0) const
Retrieve data from model.
virtual void setItem(int row, int column, QStandardItem *item)
Store one curve name data.
virtual Qt::ItemFlags flags(const QModelIndex &index) const
Override normal flags with additional editing flags.
virtual bool removeRows(int row, int count, const QModelIndex &parent)
Remove one row.
void insertRow(int row, const QString &curveCurrent, const QString &curveOriginal, unsigned int pointCount)
Create a new entry at the specified row.
CurveNameList()
Default constructor.
QString currentCurveToOriginalCurve(const QString &currentCurve) const
Return the original curve for the specified current curve.
virtual Qt::DropActions supportedDropActions() const
Allow dragging for reordering.
virtual bool setData(const QModelIndex &index, const QVariant &value, int role)
Store data for one curve name.