7#include "CurveNameListEntry.h"
8#include "CurveNameList.h"
9#include "DocumentSerialize.h"
10#include "EngaugeAssert.h"
12#include "QtToString.h"
14#include <QXmlStreamWriter>
27 LOG4CPP_INFO_S ((*mainCat)) <<
"CurveNameList::containsCurveNameCurrent"
28 <<
" entryCount=" << m_modelCurvesEntries.count();
31 QStringList::const_iterator itr;
32 for (itr = m_modelCurvesEntries.begin (); itr != m_modelCurvesEntries.end (); itr++) {
44bool CurveNameList::curveNameIsAcceptable (
const QString &curveNameNew,
48 bool success = (!curveNameNew.isEmpty ());
54 for (
int row1 = 0; row1 < m_modelCurvesEntries.count(); row1++) {
58 QString curveNameCurrent1 = (row1 == row ?
60 curvesEntry1.curveNameCurrent());
62 for (
int row2 = row1 + 1; row2 < m_modelCurvesEntries.count(); row2++) {
66 QString curveNameCurrent2 = (row2 == row ?
68 curvesEntry2.curveNameCurrent());
70 if (curveNameCurrent1 == curveNameCurrent2) {
86 LOG4CPP_DEBUG_S ((*mainCat)) <<
"CurveNameList::data"
87 <<
" isRoot=" << (index.isValid () ?
"no" :
"yes")
88 <<
" role=" << roleAsString (role).toLatin1 ().data ();
90 if (!index.isValid ()) {
95 int row = index.row ();
96 if (row < 0 || row >= m_modelCurvesEntries.count ()) {
100 if ((role != Qt::DisplayRole) &&
101 (role != Qt::EditRole)) {
107 if (index.column () == 0) {
109 }
else if (index.column () == 1) {
111 }
else if (index.column () == 2) {
114 ENGAUGE_ASSERT (
false);
125 if (index.isValid ()) {
128 return QAbstractTableModel::flags (index) |
129 Qt::ItemIsDragEnabled |
131 Qt::ItemIsSelectable |
137 return QAbstractTableModel::flags (index) |
138 Qt::ItemIsDropEnabled;
145 const QModelIndex &parent)
147 bool skip = (count != 1 || row < 0 || row >
rowCount () || parent.isValid());
149 LOG4CPP_INFO_S ((*mainCat)) <<
"CurveNameList::insertRows"
151 <<
" count=" << count
152 <<
" isRoot=" << (parent.isValid () ?
"no" :
"yes")
153 <<
" skip=" << (skip ?
"yes" :
"no");
161 beginInsertRows (QModelIndex (),
167 m_modelCurvesEntries.insert (row,
177 const QModelIndex &parent)
179 bool skip = (count != 1 || row < 0 || row >
rowCount () || parent.isValid());
181 LOG4CPP_DEBUG_S ((*mainCat)) <<
"CurveNameList::removeRows"
183 <<
" count=" << count
184 <<
" isRoot=" << (parent.isValid () ?
"no" :
"yes")
185 <<
" skip=" << (skip ?
"yes" :
"no");
187 bool success =
false;
189 beginRemoveRows (QModelIndex (),
193 m_modelCurvesEntries.removeAt (row);
202 int count = m_modelCurvesEntries.count ();
204 LOG4CPP_DEBUG_S ((*mainCat)) <<
"CurveNameList::rowCount count=" << count;
210 const QVariant &value,
213 LOG4CPP_INFO_S ((*mainCat)) <<
"CurveNameList::setData"
214 <<
" indexRow=" << index.row ()
215 <<
" value=" << (value.isValid () ?
"valid" :
"invalid")
216 <<
" role=" << roleAsString (role).toLatin1 ().data ();
218 bool success =
false;
220 int row = index.row ();
221 if (row < m_modelCurvesEntries.count ()) {
225 if (!value.isValid () && (role == Qt::EditRole)) {
228 m_modelCurvesEntries.removeAt (row);
235 if (index.column () == 0) {
237 success = curveNameIsAcceptable (value.toString (),
239 }
else if (index.column () == 1) {
241 }
else if (index.column () == 2) {
244 ENGAUGE_ASSERT (
false);
248 m_modelCurvesEntries [row] = curvesEntry.
toString ();
253 emit dataChanged (index,
263 return Qt::MoveAction;
Utility class for converting the QVariant in CurveNameList to/from the curve names as QStrings,...
QString curveNameOriginal() const
Original curve name in document. Empty if there was no original curve.
void setNumPoints(int numPoints)
Set method for point count.
QString toString() const
QString for creating QVariant.
void setCurveNameCurrent(const QString &curveNameCurrent)
Set method for current curve name.
QString curveNameCurrent() const
Curve name displayed in DlgSettingsCurveAddRemove.
int numPoints() const
Number of points in curve.
void setCurveNameOriginal(const QString &curveNameOriginal)
Set method for original curve name.
virtual QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const
Retrieve data from model.
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.
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.
virtual bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole)
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.
CurveNameList()
Default constructor.
virtual Qt::DropActions supportedDropActions() const
Allow dragging for reordering.