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);
79 if (index.isValid ()) {
82 return QAbstractTableModel::flags (index) |
83 Qt::ItemIsDragEnabled |
85 Qt::ItemIsSelectable |
91 return QAbstractTableModel::flags (index) |
92 Qt::ItemIsDropEnabled;
99 const QModelIndex &parent)
101 bool skip = (count != 1 || row < 0 || row >
rowCount () || parent.isValid());
103 LOG4CPP_INFO_S ((*mainCat)) <<
"CurveNameList::insertRows"
105 <<
" count=" << count
106 <<
" isRoot=" << (parent.isValid () ?
"no" :
"yes")
107 <<
" skip=" << (skip ?
"yes" :
"no");
115 beginInsertRows (QModelIndex (),
121 m_modelCurvesEntries.insert (row,
131 const QModelIndex &parent)
133 bool skip = (count != 1 || row < 0 || row >
rowCount () || parent.isValid());
135 LOG4CPP_DEBUG_S ((*mainCat)) <<
"CurveNameList::removeRows"
137 <<
" count=" << count
138 <<
" isRoot=" << (parent.isValid () ?
"no" :
"yes")
139 <<
" skip=" << (skip ?
"yes" :
"no");
141 bool success =
false;
143 beginRemoveRows (QModelIndex (),
147 m_modelCurvesEntries.removeAt (row);
156 int count = m_modelCurvesEntries.count ();
158 LOG4CPP_DEBUG_S ((*mainCat)) <<
"CurveNameList::rowCount count=" << count;
164 const QVariant &value,
167 LOG4CPP_INFO_S ((*mainCat)) <<
"CurveNameList::setData"
168 <<
" indexRow=" << index.row ()
169 <<
" value=" << (value.isValid () ?
"valid" :
"invalid")
170 <<
" role=" << roleAsString (role).toLatin1 ().data ();
172 bool success =
false;
174 int row = index.row ();
175 if (row < m_modelCurvesEntries.count ()) {
177 if (!value.isValid () && (role == Qt::EditRole)) {
180 m_modelCurvesEntries.removeAt (row);
187 if (index.column () == 0) {
189 }
else if (index.column () == 1) {
191 }
else if (index.column () == 2) {
194 ENGAUGE_ASSERT (
false);
197 m_modelCurvesEntries [row] = curvesEntry.
toString ();
200 emit dataChanged (index,
211 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.