22 printf(
"QcepDatasetModel::indexedObject(%s)\n", qPrintable(
indexDescription(index)));
25 if (index.isValid()) {
29 res = obj->sharedFromThis();
32 printf(
"QcepDatasetModel::indexedObject returns NULL\n");
38 printf(
"QcepDatasetModel::indexedObject(%s)", qPrintable(
indexDescription(index)));
40 printf(
" = %s\n", qPrintable(res->get_Name()));
51 QModelIndex res = QModelIndex();
54 printf(
"QcepDatasetModel::index(%d,%d,%s)\n",
69 res = createIndex(row, column, childItem.data());
75 printf(
"QcepDatasetModel::index(%d,%d,%s) = %s\n", row, column,
91 int n = obj->indexInParent();
94 return createIndex(n, 0, obj.data());
104 QModelIndex res = QModelIndex();
107 printf(
"QcepDatasetModel::parent(%s)\n", qPrintable(
indexDescription(index)));
121 res = createIndex(parentItem->indexInParent(), 0, parentItem.data());
127 printf(
"QcepDatasetModel::parent(%s)", qPrintable(
indexDescription(index)));
139 printf(
"QcepDatasetModel::rowCount(%s)\n", qPrintable(
indexDescription(parent)));
142 if (parent.column() <= 0) {
146 int nrows = parentItem->childCount();
153 res = ds->childCount();
159 printf(
"QcepDatasetModel::rowCount(%s)", qPrintable(
indexDescription(parent)));
160 printf(
" = %d\n", res);
171 printf(
"QcepDatasetModel::columnCount(%s)\n", qPrintable(
indexDescription(parent)));
183 printf(
"QcepDatasetModel::columnCount(%s)", qPrintable(
indexDescription(parent)));
184 printf(
" = %d\n", res);
192 if (orientation==Qt::Horizontal) {
193 if (role==Qt::DisplayRole) {
202 return "Description";
212 QVariant res = QVariant();
215 printf(
"QcepDatasetModel::data(%s,%d)\n", qPrintable(
indexDescription(index)), role);
218 if (!index.isValid()) {
225 if (role == Qt::DisplayRole) {
226 res =
object->columnData(index.column());
227 }
else if (role == Qt::ToolTipRole) {
228 res =
object->pathName() +
"\n" +
229 object->columnData(1).toString() +
"\n" +
230 object->columnData(2).toString();
236 printf(
"QcepDatasetModel::data(%s,%d)", qPrintable(
indexDescription(index)), role);
237 printf(
" = %s\n", qPrintable(res.toString()));
245 Qt::ItemFlags defaultFlags = QAbstractItemModel::flags(index);
247 if (index.isValid()) {
248 return defaultFlags | Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled;
250 return defaultFlags | Qt::ItemIsDropEnabled;
257 printf(
"QcepDatasetModel::mimeTypes\n");
261 types <<
"application/vnd.text.list";
268 QMimeData *
mimeData =
new QMimeData();
271 foreach (
const QModelIndex &
index, indexes) {
272 if (index.isValid()) {
273 QString text =
data(index, Qt::DisplayRole).toString();
279 printf(
"QcepDatasetModel::mimeData = %s\n", qPrintable(textData));
282 mimeData->setText(textData);
289 if (index.isValid()) {
293 return tr(
"(%1,%2,\"%3\")")
294 .arg(index.row()).arg(index.column())
300 return tr(
"(%1,%2,\"%3\")")
301 .arg(index.row()).arg(index.column())
302 .arg(ds->get_Name());
309 return tr(
"(%1,%2,null)").arg(index.row()).arg(index.column());
314 printf(
"QcepDatasetModel::insertRows(row:%d, count:%d, parent:%s)\n", row, count, qPrintable(
indexDescription(parent)));
316 return QAbstractItemModel::insertRows(row, count, parent);
320 (
const QModelIndex &sourceParent,
int sourceRow,
int count,
321 const QModelIndex &destinationParent,
int destinationChild)
323 printf(
"QAbstractItemModel::moveRows(sourceParent:%s, sourceRow:%d, count:%d,\n"
324 " destinationParent:%s, destinationChild:%d)\n",
328 return QAbstractItemModel::moveRows(sourceParent, sourceRow, count,
329 destinationParent, destinationChild);
334 printf(
"QcepDatasetModel::removeRows(row:%d, count:%d, parent:%s)\n", row, count, qPrintable(
indexDescription(parent)));
336 return QAbstractItemModel::removeRows(row, count, parent);
349 QFileInfo info(path);
351 if (info.isAbsolute()) {
352 return info.dir().absolutePath();
354 return info.dir().path();
360 QFileInfo info(path);
362 return info.fileName();
375 return ds->item(path);
394 return qSharedPointerDynamicCast<QcepDataGroup>(
indexedObject(index));
402 return ds->group(path);
431 ds->printMessage(tr(
"Item %1 exists and is not a data group").arg(path));
443 beginInsertRows(
index(sgr), sgr->rowCount(), sgr->rowCount()+1);
460 return qSharedPointerDynamicCast<QcepDataArray>(
indexedObject(index));
468 return ds->array(path);
494 if (ptr && arr == NULL) {
495 ds->printMessage(tr(
"%1 exists but is not an array").arg(path));
497 ds->printMessage(tr(
"Array %1 already exists").arg(path));
502 beginInsertRows(
index(sgr), sgr->rowCount(), sgr->rowCount()+1);
516 return qSharedPointerDynamicCast<QcepDataColumn>(
indexedObject(index));
524 return ds->column(path);
535 return ds->column(n);
550 if (ptr && col == NULL) {
551 ds->printMessage(tr(
"%1 exists but is not a data column").arg(path));
553 ds->printMessage(tr(
"Column %1 already exists").arg(path));
558 beginInsertRows(
index(sgr), sgr->rowCount(), sgr->rowCount()+1);
572 return qSharedPointerDynamicCast<QcepDataColumnScan>(
indexedObject(index));
580 return ds->columnScan(path);
591 return ds->columnScan(n);
606 if (ptr && scan == NULL) {
607 ds->printMessage(tr(
"%1 exists but is not a data column scan").arg(path));
609 ds->printMessage(tr(
"Column Scan %1 already exists").arg(path));
614 beginInsertRows(
index(sgr), sgr->rowCount(), sgr->rowCount()+1);
628 return qSharedPointerDynamicCast<QcepDoubleImageData>(
indexedObject(index));
636 return ds->image(path);
662 if (ptr && img == NULL) {
663 ds->printMessage(tr(
"%1 exists but is not an image").arg(path));
665 ds->printMessage(tr(
"Image %1 already exists").arg(path));
670 beginInsertRows(
index(sgr), sgr->rowCount(), sgr->rowCount()+1);
684 return qSharedPointerDynamicCast<QcepIntegratedData>(
indexedObject(index));
692 return ds->integratedData(path);
703 return ds->integratedData(n);
718 if (ptr && dat == NULL) {
719 ds->printMessage(tr(
"%1 exists but is not an integrated dataset").arg(path));
721 ds->printMessage(tr(
"Integrated dataset %1 already exists").arg(path));
726 beginInsertRows(
index(sgr), sgr->rowCount(), sgr->rowCount()+1);
743 beginInsertRows(QModelIndex(), atRow, atRow+1);
763 int n = obj->indexInParent();
765 if (par && n >= 0 && n < par->childCount()) {
766 beginRemoveRows(
index(par), n, n);
QcepDataColumnScanPtr newColumnScan(QString path, int nRows=0, QStringList cols=QStringList())
QSharedPointer< QcepDataArray > QcepDataArrayPtr
QcepDoubleImageDataPtr newImage(QString path, int width=0, int height=0)
QString groupName(QString path)
void append(const QModelIndex &index, QcepDataObjectPtr obj)
qint64 qcepDebug(int cond)
QcepDataArrayPtr array(const QModelIndex &index)
QSharedPointer< QcepDataGroup > QcepDataGroupPtr
static QSharedPointer< QcepImageData< T > > newImage(QcepSettingsSaverWPtr saver, QString name, int width, int height, QcepObject *parent)
QVariant headerData(int section, Qt::Orientation orientation, int role) const
QSharedPointer< QcepDataColumnScan > QcepDataColumnScanPtr
QcepDataObjectPtr indexedObject(const QModelIndex &index) const
QcepDataGroupPtr group(const QModelIndex &index)
QSharedPointer< QcepDataColumn > QcepDataColumnPtr
QcepIntegratedDataPtr newIntegratedData(QString path, int sz)
void insertGroup(int atRow, QString name)
QSharedPointer< QcepIntegratedData > QcepIntegratedDataPtr
QcepDataColumnPtr column(const QModelIndex &index)
int rowCount(const QModelIndex &parent=QModelIndex()) const
int columnCount(const QModelIndex &parent=QModelIndex()) const
QModelIndex parent(const QModelIndex &index) const
QcepDatasetModel(QcepDatasetWPtr ds)
QcepDataColumnPtr newColumn(QString path, int nRows=0)
void onDataObjectChanged()
QStringList mimeTypes() const
QcepDatasetWPtr m_Dataset
QMimeData * mimeData(const QModelIndexList &indexes) const
QcepDataArrayPtr newArray(QString path, QVector< int > dims=QVector< int >())
QcepIntegratedDataPtr integratedData(const QModelIndex &index)
QcepDoubleImageDataPtr image(const QModelIndex &index)
QString indexDescription(const QModelIndex &index) const
QString objectName(QString path)
QcepDataColumnScanPtr columnScan(const QModelIndex &index)
QcepDataGroupPtr newGroup(QString path)
void remove(QcepDataObjectPtr obj)
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const
static QcepDataColumnScanPtr newDataColumnScan(QcepSettingsSaverWPtr sav, QString name, QStringList cols, int npts, QcepObject *parent)
static QcepIntegratedDataPtr newIntegratedData(QcepSettingsSaverWPtr saver, QString name, int sz, QcepObject *parent)
QcepDataObjectPtr item(const QModelIndex &index)
bool moveRows(const QModelIndex &sourceParent, int sourceRow, int count, const QModelIndex &destinationParent, int destinationChild)
QSharedPointer< QcepDataObject > QcepDataObjectPtr
QWeakPointer< QcepDataset > QcepDatasetWPtr
bool insertRows(int row, int count, const QModelIndex &parent)
bool removeRows(int row, int count, const QModelIndex &parent)
QSharedPointer< QcepDataset > QcepDatasetPtr
Qt::ItemFlags flags(const QModelIndex &index) const
QSharedPointer< QcepDoubleImageData > QcepDoubleImageDataPtr