1 #include "CurveNameListEntry.h"
2 #include "CurveNameList.h"
3 #include "DocumentSerialize.h"
4 #include "EngaugeAssert.h"
6 #include "QtToString.h"
8 #include <QXmlStreamWriter>
21 LOG4CPP_INFO_S ((*mainCat)) <<
"CurveNameList::containsCurveNameCurrent"
22 <<
" entryCount=" << m_modelCurvesEntries.count();
25 QStringList::const_iterator itr;
26 for (itr = m_modelCurvesEntries.begin (); itr != m_modelCurvesEntries.end (); itr++) {
41 LOG4CPP_DEBUG_S ((*mainCat)) <<
"CurveNameList::data"
42 <<
" isRoot=" << (index.isValid () ?
"no" :
"yes")
43 <<
" role=" << roleAsString (role).toLatin1 ().data ();
45 if (!index.isValid ()) {
50 int row = index.row ();
51 if (row < 0 || row >= m_modelCurvesEntries.count ()) {
55 if ((role != Qt::DisplayRole) &&
56 (role != Qt::EditRole)) {
62 if (index.column () == 0) {
64 }
else if (index.column () == 1) {
65 return curvesEntry.curveNameOriginal();
66 }
else if (index.column () == 2) {
67 return curvesEntry.numPoints ();
69 ENGAUGE_ASSERT (
false);
70 return curvesEntry.curveNameOriginal();
80 if (index.isValid ()) {
83 return QAbstractTableModel::flags (index) |
84 Qt::ItemIsDragEnabled |
86 Qt::ItemIsSelectable |
92 return QAbstractTableModel::flags (index) |
93 Qt::ItemIsDropEnabled;
100 const QModelIndex &parent)
102 bool skip = (count != 1 || row < 0 || row >
rowCount () || parent.isValid());
104 LOG4CPP_INFO_S ((*mainCat)) <<
"CurveNameList::insertRows"
106 <<
" count=" << count
107 <<
" isRoot=" << (parent.isValid () ?
"no" :
"yes")
108 <<
" skip=" << (skip ?
"yes" :
"no");
116 beginInsertRows (QModelIndex (),
122 m_modelCurvesEntries.insert (row,
132 const QModelIndex &parent)
134 bool skip = (count != 1 || row < 0 || row >
rowCount () || parent.isValid());
136 LOG4CPP_DEBUG_S ((*mainCat)) <<
"CurveNameList::removeRows"
138 <<
" count=" << count
139 <<
" isRoot=" << (parent.isValid () ?
"no" :
"yes")
140 <<
" skip=" << (skip ?
"yes" :
"no");
142 bool success =
false;
144 beginRemoveRows (QModelIndex (),
148 m_modelCurvesEntries.removeAt (row);
157 int count = m_modelCurvesEntries.count ();
159 LOG4CPP_DEBUG_S ((*mainCat)) <<
"CurveNameList::rowCount count=" << count;
165 const QVariant &value,
168 LOG4CPP_INFO_S ((*mainCat)) <<
"CurveNameList::setData"
169 <<
" indexRow=" << index.row ()
170 <<
" value=" << (value.isValid () ?
"valid" :
"invalid")
171 <<
" role=" << roleAsString (role).toLatin1 ().data ();
173 bool success =
false;
175 int row = index.row ();
176 if (row < m_modelCurvesEntries.count ()) {
178 if (!value.isValid () && (role == Qt::EditRole)) {
181 m_modelCurvesEntries.removeAt (row);
188 if (index.column () == 0) {
190 }
else if (index.column () == 1) {
192 }
else if (index.column () == 2) {
195 ENGAUGE_ASSERT (
false);
198 m_modelCurvesEntries [row] = curvesEntry.
toString ();
201 emit dataChanged (index,
212 return Qt::MoveAction;
bool containsCurveNameCurrent(const QString &curveName) const
Return true if specified curve name is already in the list.
virtual bool insertRows(int row, int count, const QModelIndex &parent=QModelIndex())
Insert one row.
Utility class for converting the QVariant in CurveNameList to/from the curve names as QStrings...
virtual Qt::DropActions supportedDropActions() const
Allow dragging for reordering.
void setCurveNameCurrent(const QString &curveNameCurrent)
Set method for current curve name.
virtual Qt::ItemFlags flags(const QModelIndex &index) const
Override normal flags with additional editing flags.
QString toString() const
QString for creating QVariant.
virtual bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole)
Store one curve name data.
virtual QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const
Retrieve data from model.
virtual bool removeRows(int row, int count, const QModelIndex &parent)
Remove one row.
void setCurveNameOriginal(const QString &curveNameOriginal)
Set method for original curve name.
virtual int rowCount(const QModelIndex &parent=QModelIndex()) const
One row per curve name.
virtual int columnCount(const QModelIndex &parent=QModelIndex()) const
Columns are current curve name in first column, and original curve name in second column...
QString curveNameCurrent() const
Curve name displayed in DlgSettingsCurveAddRemove.
CurveNameList()
Default constructor.
void setNumPoints(int numPoints)
Set method for point count.