QXRD  0.11.16
Public Slots | Public Member Functions | Private Slots | Private Member Functions | Private Attributes | List of all members
QcepDatasetModel Class Reference

#include <qcepdatasetmodel.h>

Inheritance diagram for QcepDatasetModel:
Inheritance graph
[legend]
Collaboration diagram for QcepDatasetModel:
Collaboration graph
[legend]

Public Slots

QModelIndex index (int row, int column, const QModelIndex &parent=QModelIndex()) const
 
QModelIndex index (const QcepDataObjectPtr &obj) const
 
QModelIndex parent (const QModelIndex &index) const
 
int rowCount (const QModelIndex &parent=QModelIndex()) const
 
int columnCount (const QModelIndex &parent=QModelIndex()) const
 
QVariant data (const QModelIndex &index, int role=Qt::DisplayRole) const
 
QVariant headerData (int section, Qt::Orientation orientation, int role) const
 
Qt::ItemFlags flags (const QModelIndex &index) const
 
QcepDataObjectPtr indexedObject (const QModelIndex &index) const
 
QStringList mimeTypes () const
 
QMimeData * mimeData (const QModelIndexList &indexes) const
 
bool insertRows (int row, int count, const QModelIndex &parent)
 
bool moveRows (const QModelIndex &sourceParent, int sourceRow, int count, const QModelIndex &destinationParent, int destinationChild)
 
bool removeRows (int row, int count, const QModelIndex &parent)
 
QcepDataObjectPtr item (const QModelIndex &index)
 
QcepDataObjectPtr item (QString path)
 
QcepDataObjectPtr item (int n)
 
QcepDataGroupPtr group (const QModelIndex &index)
 
QcepDataGroupPtr group (QString path)
 
QcepDataGroupPtr group (int n)
 
QcepDataGroupPtr newGroup (QString path)
 
QcepDataArrayPtr array (const QModelIndex &index)
 
QcepDataArrayPtr array (QString path)
 
QcepDataArrayPtr array (int n)
 
QcepDataArrayPtr newArray (QString path, QVector< int > dims=QVector< int >())
 
QcepDataColumnPtr column (const QModelIndex &index)
 
QcepDataColumnPtr column (QString path)
 
QcepDataColumnPtr column (int n)
 
QcepDataColumnPtr newColumn (QString path, int nRows=0)
 
QcepDataColumnScanPtr columnScan (const QModelIndex &index)
 
QcepDataColumnScanPtr columnScan (QString path)
 
QcepDataColumnScanPtr columnScan (int n)
 
QcepDataColumnScanPtr newColumnScan (QString path, int nRows=0, QStringList cols=QStringList())
 
QcepDoubleImageDataPtr image (const QModelIndex &index)
 
QcepDoubleImageDataPtr image (QString path)
 
QcepDoubleImageDataPtr image (int n)
 
QcepDoubleImageDataPtr newImage (QString path, int width=0, int height=0)
 
QcepIntegratedDataPtr integratedData (const QModelIndex &index)
 
QcepIntegratedDataPtr integratedData (QString path)
 
QcepIntegratedDataPtr integratedData (int n)
 
QcepIntegratedDataPtr newIntegratedData (QString path, int sz)
 
void append (const QModelIndex &index, QcepDataObjectPtr obj)
 
void append (QString path, QcepDataObjectPtr obj)
 
void remove (QcepDataObjectPtr obj)
 
void remove (const QModelIndex &index)
 
void remove (QString path)
 
void insertGroup (int atRow, QString name)
 

Public Member Functions

 QcepDatasetModel (QcepDatasetWPtr ds)
 

Private Slots

void onDataObjectChanged ()
 

Private Member Functions

QString indexDescription (const QModelIndex &index) const
 
QString groupName (QString path)
 
QString objectName (QString path)
 

Private Attributes

QcepDatasetWPtr m_Dataset
 

Detailed Description

Definition at line 22 of file qcepdatasetmodel.h.

Constructor & Destructor Documentation

QcepDatasetModel::QcepDatasetModel ( QcepDatasetWPtr  ds)

Definition at line 11 of file qcepdatasetmodel.cpp.

References onDataObjectChanged().

11  :
12  m_Dataset(ds)
13 {
14  connect(ds.data(), SIGNAL(dataObjectChanged()), this, SLOT(onDataObjectChanged()));
15 }
QcepDatasetWPtr m_Dataset

Here is the call graph for this function:

Member Function Documentation

void QcepDatasetModel::append ( const QModelIndex &  index,
QcepDataObjectPtr  obj 
)
slot

Definition at line 751 of file qcepdatasetmodel.cpp.

Referenced by newArray(), newColumn(), newColumnScan(), newImage(), and newIntegratedData().

752 {
753 }

Here is the caller graph for this function:

void QcepDatasetModel::append ( QString  path,
QcepDataObjectPtr  obj 
)
slot

Definition at line 755 of file qcepdatasetmodel.cpp.

756 {
757 }
QcepDataArrayPtr QcepDatasetModel::array ( const QModelIndex &  index)
slot

Definition at line 458 of file qcepdatasetmodel.cpp.

References indexedObject().

Referenced by newArray().

459 {
460  return qSharedPointerDynamicCast<QcepDataArray>(indexedObject(index));
461 }
QcepDataObjectPtr indexedObject(const QModelIndex &index) const
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const

Here is the call graph for this function:

Here is the caller graph for this function:

QcepDataArrayPtr QcepDatasetModel::array ( QString  path)
slot

Definition at line 463 of file qcepdatasetmodel.cpp.

References m_Dataset.

464 {
466 
467  if (ds) {
468  return ds->array(path);
469  } else {
470  return QcepDataArrayPtr();
471  }
472 }
QSharedPointer< QcepDataArray > QcepDataArrayPtr
QcepDatasetWPtr m_Dataset
QSharedPointer< QcepDataset > QcepDatasetPtr
QcepDataArrayPtr QcepDatasetModel::array ( int  n)
slot

Definition at line 474 of file qcepdatasetmodel.cpp.

References m_Dataset.

475 {
477 
478  if (ds) {
479  return ds->array(n);
480  } else {
481  return QcepDataArrayPtr();
482  }
483 }
QSharedPointer< QcepDataArray > QcepDataArrayPtr
QcepDatasetWPtr m_Dataset
QSharedPointer< QcepDataset > QcepDatasetPtr
QcepDataColumnPtr QcepDatasetModel::column ( const QModelIndex &  index)
slot

Definition at line 514 of file qcepdatasetmodel.cpp.

References indexedObject().

Referenced by newColumn().

515 {
516  return qSharedPointerDynamicCast<QcepDataColumn>(indexedObject(index));
517 }
QcepDataObjectPtr indexedObject(const QModelIndex &index) const
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const

Here is the call graph for this function:

Here is the caller graph for this function:

QcepDataColumnPtr QcepDatasetModel::column ( QString  path)
slot

Definition at line 519 of file qcepdatasetmodel.cpp.

References m_Dataset.

520 {
522 
523  if (ds) {
524  return ds->column(path);
525  } else {
526  return QcepDataColumnPtr();
527  }
528 }
QSharedPointer< QcepDataColumn > QcepDataColumnPtr
QcepDatasetWPtr m_Dataset
QSharedPointer< QcepDataset > QcepDatasetPtr
QcepDataColumnPtr QcepDatasetModel::column ( int  n)
slot

Definition at line 530 of file qcepdatasetmodel.cpp.

References m_Dataset.

531 {
533 
534  if (ds) {
535  return ds->column(n);
536  } else {
537  return QcepDataColumnPtr();
538  }
539 }
QSharedPointer< QcepDataColumn > QcepDataColumnPtr
QcepDatasetWPtr m_Dataset
QSharedPointer< QcepDataset > QcepDatasetPtr
int QcepDatasetModel::columnCount ( const QModelIndex &  parent = QModelIndex()) const
slot

Definition at line 166 of file qcepdatasetmodel.cpp.

References DEBUG_DATABROWSER, indexDescription(), indexedObject(), and qcepDebug().

Referenced by onDataObjectChanged().

167 {
168  int res = 0;
169 
171  printf("QcepDatasetModel::columnCount(%s)\n", qPrintable(indexDescription(parent)));
172  }
173 
174  QcepDataObjectPtr parentItem = indexedObject(parent);
175 
176  if (parentItem) {
177  res = 3;
178  } else {
179  res = 3;
180  }
181 
183  printf("QcepDatasetModel::columnCount(%s)", qPrintable(indexDescription(parent)));
184  printf(" = %d\n", res);
185  }
186 
187  return res;
188 }
qint64 qcepDebug(int cond)
Definition: qcepdebug.cpp:26
QcepDataObjectPtr indexedObject(const QModelIndex &index) const
QModelIndex parent(const QModelIndex &index) const
QString indexDescription(const QModelIndex &index) const
QSharedPointer< QcepDataObject > QcepDataObjectPtr

Here is the call graph for this function:

Here is the caller graph for this function:

QcepDataColumnScanPtr QcepDatasetModel::columnScan ( const QModelIndex &  index)
slot

Definition at line 570 of file qcepdatasetmodel.cpp.

References indexedObject().

Referenced by newColumnScan().

571 {
572  return qSharedPointerDynamicCast<QcepDataColumnScan>(indexedObject(index));
573 }
QcepDataObjectPtr indexedObject(const QModelIndex &index) const
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const

Here is the call graph for this function:

Here is the caller graph for this function:

QcepDataColumnScanPtr QcepDatasetModel::columnScan ( QString  path)
slot

Definition at line 575 of file qcepdatasetmodel.cpp.

References m_Dataset.

576 {
578 
579  if (ds) {
580  return ds->columnScan(path);
581  } else {
582  return QcepDataColumnScanPtr();
583  }
584 }
QSharedPointer< QcepDataColumnScan > QcepDataColumnScanPtr
QcepDatasetWPtr m_Dataset
QSharedPointer< QcepDataset > QcepDatasetPtr
QcepDataColumnScanPtr QcepDatasetModel::columnScan ( int  n)
slot

Definition at line 586 of file qcepdatasetmodel.cpp.

References m_Dataset.

587 {
589 
590  if (ds) {
591  return ds->columnScan(n);
592  } else {
593  return QcepDataColumnScanPtr();
594  }
595 }
QSharedPointer< QcepDataColumnScan > QcepDataColumnScanPtr
QcepDatasetWPtr m_Dataset
QSharedPointer< QcepDataset > QcepDatasetPtr
QVariant QcepDatasetModel::data ( const QModelIndex &  index,
int  role = Qt::DisplayRole 
) const
slot

Definition at line 210 of file qcepdatasetmodel.cpp.

References DEBUG_DATABROWSER, indexDescription(), indexedObject(), and qcepDebug().

Referenced by mimeData().

211 {
212  QVariant res = QVariant();
213 
215  printf("QcepDatasetModel::data(%s,%d)\n", qPrintable(indexDescription(index)), role);
216  }
217 
218  if (!index.isValid()) {
219  res = QVariant();
220  } else {
221 
223 
224  if (object) {
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();
231  }
232  }
233  }
234 
236  printf("QcepDatasetModel::data(%s,%d)", qPrintable(indexDescription(index)), role);
237  printf(" = %s\n", qPrintable(res.toString()));
238  }
239 
240  return res;
241 }
qint64 qcepDebug(int cond)
Definition: qcepdebug.cpp:26
QcepDataObjectPtr indexedObject(const QModelIndex &index) const
QString indexDescription(const QModelIndex &index) const
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const
QSharedPointer< QcepDataObject > QcepDataObjectPtr

Here is the call graph for this function:

Here is the caller graph for this function:

Qt::ItemFlags QcepDatasetModel::flags ( const QModelIndex &  index) const
slot

Definition at line 243 of file qcepdatasetmodel.cpp.

244 {
245  Qt::ItemFlags defaultFlags = QAbstractItemModel::flags(index);
246 
247  if (index.isValid()) {
248  return defaultFlags | Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled;
249  } else {
250  return defaultFlags | Qt::ItemIsDropEnabled;
251  }
252 }
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const
QcepDataGroupPtr QcepDatasetModel::group ( const QModelIndex &  index)
slot

Definition at line 392 of file qcepdatasetmodel.cpp.

References indexedObject().

Referenced by newGroup().

393 {
394  return qSharedPointerDynamicCast<QcepDataGroup>(indexedObject(index));
395 }
QcepDataObjectPtr indexedObject(const QModelIndex &index) const
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const

Here is the call graph for this function:

Here is the caller graph for this function:

QcepDataGroupPtr QcepDatasetModel::group ( QString  path)
slot

Definition at line 397 of file qcepdatasetmodel.cpp.

References m_Dataset.

398 {
400 
401  if (ds) {
402  return ds->group(path);
403  } else {
404  return QcepDataGroupPtr();
405  }
406 }
QSharedPointer< QcepDataGroup > QcepDataGroupPtr
QcepDatasetWPtr m_Dataset
QSharedPointer< QcepDataset > QcepDatasetPtr
QcepDataGroupPtr QcepDatasetModel::group ( int  n)
slot

Definition at line 408 of file qcepdatasetmodel.cpp.

References m_Dataset.

409 {
411 
412  if (ds) {
413  return ds->group(n);
414  } else {
415  return QcepDataGroupPtr();
416  }
417 }
QSharedPointer< QcepDataGroup > QcepDataGroupPtr
QcepDatasetWPtr m_Dataset
QSharedPointer< QcepDataset > QcepDatasetPtr
QString QcepDatasetModel::groupName ( QString  path)
private

Definition at line 347 of file qcepdatasetmodel.cpp.

Referenced by newArray(), newColumn(), newColumnScan(), newGroup(), newImage(), and newIntegratedData().

348 {
349  QFileInfo info(path);
350 
351  if (info.isAbsolute()) {
352  return info.dir().absolutePath();
353  } else {
354  return info.dir().path();
355  }
356 }

Here is the caller graph for this function:

QVariant QcepDatasetModel::headerData ( int  section,
Qt::Orientation  orientation,
int  role 
) const
slot

Definition at line 190 of file qcepdatasetmodel.cpp.

191 {
192  if (orientation==Qt::Horizontal) {
193  if (role==Qt::DisplayRole) {
194  switch (section) {
195  case 0:
196  return "Name";
197 
198  case 1:
199  return "Type";
200 
201  case 2:
202  return "Description";
203  }
204  }
205  }
206 
207  return QVariant();
208 }
QcepDoubleImageDataPtr QcepDatasetModel::image ( const QModelIndex &  index)
slot

Definition at line 626 of file qcepdatasetmodel.cpp.

References indexedObject().

Referenced by newImage().

627 {
628  return qSharedPointerDynamicCast<QcepDoubleImageData>(indexedObject(index));
629 }
QcepDataObjectPtr indexedObject(const QModelIndex &index) const
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const

Here is the call graph for this function:

Here is the caller graph for this function:

QcepDoubleImageDataPtr QcepDatasetModel::image ( QString  path)
slot

Definition at line 631 of file qcepdatasetmodel.cpp.

References m_Dataset.

632 {
634 
635  if (ds) {
636  return ds->image(path);
637  } else {
638  return QcepDoubleImageDataPtr();
639  }
640 }
QcepDatasetWPtr m_Dataset
QSharedPointer< QcepDataset > QcepDatasetPtr
QSharedPointer< QcepDoubleImageData > QcepDoubleImageDataPtr
QcepDoubleImageDataPtr QcepDatasetModel::image ( int  n)
slot

Definition at line 642 of file qcepdatasetmodel.cpp.

References m_Dataset.

643 {
645 
646  if (ds) {
647  return ds->image(n);
648  } else {
649  return QcepDoubleImageDataPtr();
650  }
651 }
QcepDatasetWPtr m_Dataset
QSharedPointer< QcepDataset > QcepDatasetPtr
QSharedPointer< QcepDoubleImageData > QcepDoubleImageDataPtr
QModelIndex QcepDatasetModel::index ( int  row,
int  column,
const QModelIndex &  parent = QModelIndex() 
) const
slot

Definition at line 49 of file qcepdatasetmodel.cpp.

References DEBUG_DATABROWSER, indexDescription(), indexedObject(), m_Dataset, and qcepDebug().

Referenced by mimeData(), newArray(), newColumn(), newColumnScan(), newGroup(), newImage(), newIntegratedData(), onDataObjectChanged(), and remove().

50 {
51  QModelIndex res = QModelIndex();
52 
54  printf("QcepDatasetModel::index(%d,%d,%s)\n",
55  row, column, qPrintable(indexDescription(parent)));
56  }
57 
58 // if (hasIndex(row, column, parent)) {
60 
61  if (!parentItem) {
62  parentItem = m_Dataset;
63  }
64 
65  if (parentItem) {
66  QcepDataObjectPtr childItem = parentItem->item(row);
67 
68  if (childItem) {
69  res = createIndex(row, column, childItem.data());
70  }
71  }
72  // }
73 
75  printf("QcepDatasetModel::index(%d,%d,%s) = %s\n", row, column,
76  qPrintable(indexDescription(parent)),
77  qPrintable(indexDescription(res)));
78  }
79 
80  return res;
81 }
qint64 qcepDebug(int cond)
Definition: qcepdebug.cpp:26
QcepDataObjectPtr indexedObject(const QModelIndex &index) const
QcepDataColumnPtr column(const QModelIndex &index)
QModelIndex parent(const QModelIndex &index) const
QcepDatasetWPtr m_Dataset
QString indexDescription(const QModelIndex &index) const
QSharedPointer< QcepDataObject > QcepDataObjectPtr

Here is the call graph for this function:

Here is the caller graph for this function:

QModelIndex QcepDatasetModel::index ( const QcepDataObjectPtr obj) const
slot

Definition at line 83 of file qcepdatasetmodel.cpp.

References m_Dataset, and parent().

84 {
85  if (obj == NULL || obj == m_Dataset) {
86  return QModelIndex();
87  } else {
88  QcepDataGroupPtr parent = obj->parentItem();
89 
90  if (parent) {
91  int n = obj->indexInParent();
92 
93  if (n >= 0) {
94  return createIndex(n, 0, obj.data());
95  }
96  }
97 
98  return QModelIndex();
99  }
100 }
QSharedPointer< QcepDataGroup > QcepDataGroupPtr
QModelIndex parent(const QModelIndex &index) const
QcepDatasetWPtr m_Dataset

Here is the call graph for this function:

QString QcepDatasetModel::indexDescription ( const QModelIndex &  index) const
private

Definition at line 287 of file qcepdatasetmodel.cpp.

References QcepObject::get_Name(), and m_Dataset.

Referenced by columnCount(), data(), index(), indexedObject(), insertRows(), moveRows(), parent(), removeRows(), and rowCount().

288 {
289  if (index.isValid()) {
290  QcepDataObject* obj = static_cast<QcepDataObject*>(index.internalPointer());
291 
292  if (obj) {
293  return tr("(%1,%2,\"%3\")")
294  .arg(index.row()).arg(index.column())
295  .arg(obj->get_Name());
296  } else {
298 
299  if (ds) {
300  return tr("(%1,%2,\"%3\")")
301  .arg(index.row()).arg(index.column())
302  .arg(ds->get_Name());
303  } else {
304  return "";
305  }
306  }
307  }
308 
309  return tr("(%1,%2,null)").arg(index.row()).arg(index.column());
310 }
QString get_Name() const
Definition: qcepobject.cpp:72
QcepDatasetWPtr m_Dataset
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const
QSharedPointer< QcepDataset > QcepDatasetPtr

Here is the call graph for this function:

Here is the caller graph for this function:

QcepDataObjectPtr QcepDatasetModel::indexedObject ( const QModelIndex &  index) const
slot

Definition at line 17 of file qcepdatasetmodel.cpp.

References DEBUG_DATABROWSER, indexDescription(), and qcepDebug().

Referenced by array(), column(), columnCount(), columnScan(), data(), group(), image(), index(), integratedData(), item(), parent(), remove(), and rowCount().

18 {
20 
22  printf("QcepDatasetModel::indexedObject(%s)\n", qPrintable(indexDescription(index)));
23  }
24 
25  if (index.isValid()) {
26  QcepDataObject *obj = static_cast<QcepDataObject*>(index.internalPointer());
27 
28  if (obj) {
29  res = obj->sharedFromThis();
30 
31  if (!res) {
32  printf("QcepDatasetModel::indexedObject returns NULL\n");
33  }
34  }
35  }
36 
38  printf("QcepDatasetModel::indexedObject(%s)", qPrintable(indexDescription(index)));
39  if (res) {
40  printf(" = %s\n", qPrintable(res->get_Name()));
41  } else {
42  printf(" = null\n");
43  }
44  }
45 
46  return res;
47 }
qint64 qcepDebug(int cond)
Definition: qcepdebug.cpp:26
QString indexDescription(const QModelIndex &index) const
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const
QSharedPointer< QcepDataObject > QcepDataObjectPtr

Here is the call graph for this function:

Here is the caller graph for this function:

void QcepDatasetModel::insertGroup ( int  atRow,
QString  name 
)
slot

Definition at line 738 of file qcepdatasetmodel.cpp.

References m_Dataset.

739 {
741 
742  if (ds) {
743  beginInsertRows(QModelIndex(), atRow, atRow+1);
744 
745  ds->insert(atRow, QcepDataGroupPtr(new QcepDataGroup(ds->saver(), name, ds.data())));
746 
747  endInsertRows();
748  }
749 }
QSharedPointer< QcepDataGroup > QcepDataGroupPtr
QcepDatasetWPtr m_Dataset
QSharedPointer< QcepDataset > QcepDatasetPtr
bool QcepDatasetModel::insertRows ( int  row,
int  count,
const QModelIndex &  parent 
)
slot

Definition at line 312 of file qcepdatasetmodel.cpp.

References indexDescription().

313 {
314  printf("QcepDatasetModel::insertRows(row:%d, count:%d, parent:%s)\n", row, count, qPrintable(indexDescription(parent)));
315 
316  return QAbstractItemModel::insertRows(row, count, parent);
317 }
QModelIndex parent(const QModelIndex &index) const
QString indexDescription(const QModelIndex &index) const

Here is the call graph for this function:

QcepIntegratedDataPtr QcepDatasetModel::integratedData ( const QModelIndex &  index)
slot

Definition at line 682 of file qcepdatasetmodel.cpp.

References indexedObject().

Referenced by newIntegratedData().

683 {
684  return qSharedPointerDynamicCast<QcepIntegratedData>(indexedObject(index));
685 }
QcepDataObjectPtr indexedObject(const QModelIndex &index) const
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const

Here is the call graph for this function:

Here is the caller graph for this function:

QcepIntegratedDataPtr QcepDatasetModel::integratedData ( QString  path)
slot

Definition at line 687 of file qcepdatasetmodel.cpp.

References m_Dataset.

688 {
690 
691  if (ds) {
692  return ds->integratedData(path);
693  } else {
694  return QcepIntegratedDataPtr();
695  }
696 }
QSharedPointer< QcepIntegratedData > QcepIntegratedDataPtr
QcepDatasetWPtr m_Dataset
QSharedPointer< QcepDataset > QcepDatasetPtr
QcepIntegratedDataPtr QcepDatasetModel::integratedData ( int  n)
slot

Definition at line 698 of file qcepdatasetmodel.cpp.

References m_Dataset.

699 {
701 
702  if (ds) {
703  return ds->integratedData(n);
704  } else {
705  return QcepIntegratedDataPtr();
706  }
707 }
QSharedPointer< QcepIntegratedData > QcepIntegratedDataPtr
QcepDatasetWPtr m_Dataset
QSharedPointer< QcepDataset > QcepDatasetPtr
QcepDataObjectPtr QcepDatasetModel::item ( const QModelIndex &  index)
slot

Definition at line 365 of file qcepdatasetmodel.cpp.

References indexedObject().

Referenced by newArray(), newColumn(), newColumnScan(), newGroup(), newImage(), newIntegratedData(), and remove().

366 {
367  return indexedObject(index);
368 }
QcepDataObjectPtr indexedObject(const QModelIndex &index) const
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const

Here is the call graph for this function:

Here is the caller graph for this function:

QcepDataObjectPtr QcepDatasetModel::item ( QString  path)
slot

Definition at line 370 of file qcepdatasetmodel.cpp.

References m_Dataset.

371 {
373 
374  if (ds) {
375  return ds->item(path);
376  } else {
377  return QcepDataObjectPtr();
378  }
379 }
QcepDatasetWPtr m_Dataset
QSharedPointer< QcepDataObject > QcepDataObjectPtr
QSharedPointer< QcepDataset > QcepDatasetPtr
QcepDataObjectPtr QcepDatasetModel::item ( int  n)
slot

Definition at line 381 of file qcepdatasetmodel.cpp.

References m_Dataset.

382 {
384 
385  if (ds) {
386  return ds->item(n);
387  } else {
388  return QcepDataObjectPtr();
389  }
390 }
QcepDatasetWPtr m_Dataset
QSharedPointer< QcepDataObject > QcepDataObjectPtr
QSharedPointer< QcepDataset > QcepDatasetPtr
QMimeData * QcepDatasetModel::mimeData ( const QModelIndexList &  indexes) const
slot

Definition at line 266 of file qcepdatasetmodel.cpp.

References data(), DEBUG_DRAGDROP, index(), and qcepDebug().

267 {
268  QMimeData *mimeData = new QMimeData();
269  QString textData;
270 
271  foreach (const QModelIndex &index, indexes) {
272  if (index.isValid()) {
273  QString text = data(index, Qt::DisplayRole).toString();
274  textData += text;
275  }
276  }
277 
278  if (qcepDebug(DEBUG_DRAGDROP)) {
279  printf("QcepDatasetModel::mimeData = %s\n", qPrintable(textData));
280  }
281 
282  mimeData->setText(textData);
283 // mimeData->setData("text/plain", encodedData);
284  return mimeData;
285 }
qint64 qcepDebug(int cond)
Definition: qcepdebug.cpp:26
QMimeData * mimeData(const QModelIndexList &indexes) const
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const

Here is the call graph for this function:

QStringList QcepDatasetModel::mimeTypes ( ) const
slot

Definition at line 254 of file qcepdatasetmodel.cpp.

255 {
256 // if (qcepDebug(DEBUG_DRAGDROP)) {
257  printf("QcepDatasetModel::mimeTypes\n");
258 // }
259 
260  QStringList types;
261  types << "application/vnd.text.list";
262 // types << "text/plain";
263  return types;
264 }
bool QcepDatasetModel::moveRows ( const QModelIndex &  sourceParent,
int  sourceRow,
int  count,
const QModelIndex &  destinationParent,
int  destinationChild 
)
slot

Definition at line 320 of file qcepdatasetmodel.cpp.

References indexDescription().

322 {
323  printf("QAbstractItemModel::moveRows(sourceParent:%s, sourceRow:%d, count:%d,\n"
324  " destinationParent:%s, destinationChild:%d)\n",
325  qPrintable(indexDescription(sourceParent)), sourceRow, count,
326  qPrintable(indexDescription(destinationParent)), destinationChild);
327 
328  return QAbstractItemModel::moveRows(sourceParent, sourceRow, count,
329  destinationParent, destinationChild);
330 }
QString indexDescription(const QModelIndex &index) const

Here is the call graph for this function:

QcepDataArrayPtr QcepDatasetModel::newArray ( QString  path,
QVector< int >  dims = QVector<int>() 
)
slot

Definition at line 485 of file qcepdatasetmodel.cpp.

References append(), array(), groupName(), index(), item(), m_Dataset, newGroup(), and objectName().

486 {
487  QcepDataGroupPtr sgr = newGroup(groupName(path));
489 
490  if (sgr && ds) {
491  QcepDataObjectPtr ptr = item(path);
492  QcepDataArrayPtr arr = array(path);
493 
494  if (ptr && arr == NULL) {
495  ds->printMessage(tr("%1 exists but is not an array").arg(path));
496  } else if (arr) {
497  ds->printMessage(tr("Array %1 already exists").arg(path));
498  } else {
499  QcepDataArrayPtr arr(new QcepDataArray(ds->saver(), objectName(path), dims, sgr.data()));
500 
501  if (arr) {
502  beginInsertRows(index(sgr), sgr->rowCount(), sgr->rowCount()+1);
503  sgr -> append(arr);
504  endInsertRows();
505 
506  return arr;
507  }
508  }
509  }
510 
511  return QcepDataArrayPtr();
512 }
QSharedPointer< QcepDataArray > QcepDataArrayPtr
QString groupName(QString path)
void append(const QModelIndex &index, QcepDataObjectPtr obj)
QcepDataArrayPtr array(const QModelIndex &index)
QSharedPointer< QcepDataGroup > QcepDataGroupPtr
QcepDatasetWPtr m_Dataset
QString objectName(QString path)
QcepDataGroupPtr newGroup(QString path)
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const
QcepDataObjectPtr item(const QModelIndex &index)
QSharedPointer< QcepDataObject > QcepDataObjectPtr
QSharedPointer< QcepDataset > QcepDatasetPtr

Here is the call graph for this function:

QcepDataColumnPtr QcepDatasetModel::newColumn ( QString  path,
int  nRows = 0 
)
slot

Definition at line 541 of file qcepdatasetmodel.cpp.

References append(), column(), groupName(), index(), item(), m_Dataset, newGroup(), and objectName().

542 {
543  QcepDataGroupPtr sgr = newGroup(groupName(path));
545 
546  if (sgr && ds) {
547  QcepDataObjectPtr ptr = item(path);
548  QcepDataColumnPtr col = column(path);
549 
550  if (ptr && col == NULL) {
551  ds->printMessage(tr("%1 exists but is not a data column").arg(path));
552  } else if (col) {
553  ds->printMessage(tr("Column %1 already exists").arg(path));
554  } else {
555  QcepDataColumnPtr col(new QcepDataColumn(ds->saver(), objectName(path), nRows, sgr.data()));
556 
557  if (col) {
558  beginInsertRows(index(sgr), sgr->rowCount(), sgr->rowCount()+1);
559  sgr -> append(col);
560  endInsertRows();
561 
562  return col;
563  }
564  }
565  }
566 
567  return QcepDataColumnPtr();
568 }
QString groupName(QString path)
void append(const QModelIndex &index, QcepDataObjectPtr obj)
QSharedPointer< QcepDataGroup > QcepDataGroupPtr
QSharedPointer< QcepDataColumn > QcepDataColumnPtr
QcepDataColumnPtr column(const QModelIndex &index)
QcepDatasetWPtr m_Dataset
QString objectName(QString path)
QcepDataGroupPtr newGroup(QString path)
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const
QcepDataObjectPtr item(const QModelIndex &index)
QSharedPointer< QcepDataObject > QcepDataObjectPtr
QSharedPointer< QcepDataset > QcepDatasetPtr

Here is the call graph for this function:

QcepDataColumnScanPtr QcepDatasetModel::newColumnScan ( QString  path,
int  nRows = 0,
QStringList  cols = QStringList() 
)
slot

Definition at line 597 of file qcepdatasetmodel.cpp.

References append(), columnScan(), groupName(), index(), item(), m_Dataset, QcepDataColumnScan::newDataColumnScan(), newGroup(), and objectName().

598 {
599  QcepDataGroupPtr sgr = newGroup(groupName(path));
601 
602  if (sgr && ds) {
603  QcepDataObjectPtr ptr = item(path);
604  QcepDataColumnScanPtr scan = columnScan(path);
605 
606  if (ptr && scan == NULL) {
607  ds->printMessage(tr("%1 exists but is not a data column scan").arg(path));
608  } else if (scan) {
609  ds->printMessage(tr("Column Scan %1 already exists").arg(path));
610  } else {
611  QcepDataColumnScanPtr scan(QcepDataColumnScan::newDataColumnScan(ds->saver(), objectName(path), cols, nRows, sgr.data()));
612 
613  if (scan) {
614  beginInsertRows(index(sgr), sgr->rowCount(), sgr->rowCount()+1);
615  sgr -> append(scan);
616  endInsertRows();
617 
618  return scan;
619  }
620  }
621  }
622 
623  return QcepDataColumnScanPtr();
624 }
QString groupName(QString path)
void append(const QModelIndex &index, QcepDataObjectPtr obj)
QSharedPointer< QcepDataGroup > QcepDataGroupPtr
QSharedPointer< QcepDataColumnScan > QcepDataColumnScanPtr
QcepDatasetWPtr m_Dataset
QString objectName(QString path)
QcepDataColumnScanPtr columnScan(const QModelIndex &index)
QcepDataGroupPtr newGroup(QString path)
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const
static QcepDataColumnScanPtr newDataColumnScan(QcepSettingsSaverWPtr sav, QString name, QStringList cols, int npts, QcepObject *parent)
QcepDataObjectPtr item(const QModelIndex &index)
QSharedPointer< QcepDataObject > QcepDataObjectPtr
QSharedPointer< QcepDataset > QcepDatasetPtr

Here is the call graph for this function:

QcepDataGroupPtr QcepDatasetModel::newGroup ( QString  path)
slot

Definition at line 419 of file qcepdatasetmodel.cpp.

References group(), groupName(), index(), item(), m_Dataset, and objectName().

Referenced by newArray(), newColumn(), newColumnScan(), newImage(), and newIntegratedData().

420 {
421  QcepDataGroupPtr gr = group(path);
422 
423  if (gr) {
424  return gr;
425  } else {
426  QcepDataObjectPtr obj = item(path);
428 
429  if (obj) {
430  if (ds) {
431  ds->printMessage(tr("Item %1 exists and is not a data group").arg(path));
432  }
433  } else {
434  QcepDataGroupPtr sgr = newGroup(groupName(path));
435 
436  if (sgr && ds) {
437  QcepDataGroupPtr par = sgr->parentItem();
438 
439  QcepDataGroupPtr ng =
440  QcepDataGroupPtr(new QcepDataGroup(ds->saver(), objectName(path), sgr.data()));
441 
442  if (ng) {
443  beginInsertRows(index(sgr), sgr->rowCount(), sgr->rowCount()+1);
444 
445  sgr->append(ng);
446 
447  endInsertRows();
448 
449  return ng;
450  }
451  }
452  }
453  }
454 
455  return QcepDataGroupPtr();
456 }
QString groupName(QString path)
QSharedPointer< QcepDataGroup > QcepDataGroupPtr
QcepDataGroupPtr group(const QModelIndex &index)
QcepDatasetWPtr m_Dataset
QString objectName(QString path)
QcepDataGroupPtr newGroup(QString path)
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const
QcepDataObjectPtr item(const QModelIndex &index)
QSharedPointer< QcepDataObject > QcepDataObjectPtr
QSharedPointer< QcepDataset > QcepDatasetPtr

Here is the call graph for this function:

Here is the caller graph for this function:

QcepDoubleImageDataPtr QcepDatasetModel::newImage ( QString  path,
int  width = 0,
int  height = 0 
)
slot

Definition at line 653 of file qcepdatasetmodel.cpp.

References append(), groupName(), image(), index(), item(), m_Dataset, newGroup(), QcepImageData< T >::newImage(), and objectName().

654 {
655  QcepDataGroupPtr sgr = newGroup(groupName(path));
657 
658  if (sgr && ds) {
659  QcepDataObjectPtr ptr = item(path);
660  QcepDoubleImageDataPtr img = image(path);
661 
662  if (ptr && img == NULL) {
663  ds->printMessage(tr("%1 exists but is not an image").arg(path));
664  } else if (img) {
665  ds->printMessage(tr("Image %1 already exists").arg(path));
666  } else {
667  QcepDoubleImageDataPtr img(QcepDoubleImageData::newImage(ds->saver(), objectName(path), width, height, sgr.data()));
668 
669  if (img) {
670  beginInsertRows(index(sgr), sgr->rowCount(), sgr->rowCount()+1);
671  sgr -> append(img);
672  endInsertRows();
673 
674  return img;
675  }
676  }
677  }
678 
679  return QcepDoubleImageDataPtr();
680 }
QString groupName(QString path)
void append(const QModelIndex &index, QcepDataObjectPtr obj)
QSharedPointer< QcepDataGroup > QcepDataGroupPtr
static QSharedPointer< QcepImageData< T > > newImage(QcepSettingsSaverWPtr saver, QString name, int width, int height, QcepObject *parent)
QcepDatasetWPtr m_Dataset
QcepDoubleImageDataPtr image(const QModelIndex &index)
QString objectName(QString path)
QcepDataGroupPtr newGroup(QString path)
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const
QcepDataObjectPtr item(const QModelIndex &index)
QSharedPointer< QcepDataObject > QcepDataObjectPtr
QSharedPointer< QcepDataset > QcepDatasetPtr
QSharedPointer< QcepDoubleImageData > QcepDoubleImageDataPtr

Here is the call graph for this function:

QcepIntegratedDataPtr QcepDatasetModel::newIntegratedData ( QString  path,
int  sz 
)
slot

Definition at line 709 of file qcepdatasetmodel.cpp.

References append(), groupName(), index(), integratedData(), item(), m_Dataset, newGroup(), QcepIntegratedData::newIntegratedData(), and objectName().

710 {
711  QcepDataGroupPtr sgr = newGroup(groupName(path));
713 
714  if (sgr && ds) {
715  QcepDataObjectPtr ptr = item(path);
717 
718  if (ptr && dat == NULL) {
719  ds->printMessage(tr("%1 exists but is not an integrated dataset").arg(path));
720  } else if (dat) {
721  ds->printMessage(tr("Integrated dataset %1 already exists").arg(path));
722  } else {
723  QcepIntegratedDataPtr dat(QcepIntegratedData::newIntegratedData(ds->saver(), objectName(path), sz, sgr.data()));
724 
725  if (dat) {
726  beginInsertRows(index(sgr), sgr->rowCount(), sgr->rowCount()+1);
727  sgr -> append(dat);
728  endInsertRows();
729 
730  return dat;
731  }
732  }
733  }
734 
735  return QcepIntegratedDataPtr();
736 }
QString groupName(QString path)
void append(const QModelIndex &index, QcepDataObjectPtr obj)
QSharedPointer< QcepDataGroup > QcepDataGroupPtr
QSharedPointer< QcepIntegratedData > QcepIntegratedDataPtr
QcepDatasetWPtr m_Dataset
QcepIntegratedDataPtr integratedData(const QModelIndex &index)
QString objectName(QString path)
QcepDataGroupPtr newGroup(QString path)
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const
static QcepIntegratedDataPtr newIntegratedData(QcepSettingsSaverWPtr saver, QString name, int sz, QcepObject *parent)
QcepDataObjectPtr item(const QModelIndex &index)
QSharedPointer< QcepDataObject > QcepDataObjectPtr
QSharedPointer< QcepDataset > QcepDatasetPtr

Here is the call graph for this function:

QString QcepDatasetModel::objectName ( QString  path)
private

Definition at line 358 of file qcepdatasetmodel.cpp.

Referenced by newArray(), newColumn(), newColumnScan(), newGroup(), newImage(), and newIntegratedData().

359 {
360  QFileInfo info(path);
361 
362  return info.fileName();
363 }

Here is the caller graph for this function:

void QcepDatasetModel::onDataObjectChanged ( )
privateslot

Definition at line 339 of file qcepdatasetmodel.cpp.

References columnCount(), index(), and rowCount().

Referenced by QcepDatasetModel().

340 {
341 // beginResetModel();
342 // endResetModel();
343 
344  emit dataChanged(index(0,0), index(rowCount(), columnCount()));
345 }
int rowCount(const QModelIndex &parent=QModelIndex()) const
int columnCount(const QModelIndex &parent=QModelIndex()) const
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const

Here is the call graph for this function:

Here is the caller graph for this function:

QModelIndex QcepDatasetModel::parent ( const QModelIndex &  index) const
slot

Definition at line 102 of file qcepdatasetmodel.cpp.

References DEBUG_DATABROWSER, indexDescription(), indexedObject(), m_Dataset, and qcepDebug().

Referenced by index().

103 {
104  QModelIndex res = QModelIndex();
105 
107  printf("QcepDatasetModel::parent(%s)\n", qPrintable(indexDescription(index)));
108  }
109 
111 
112  if (childItem) {
113 // if (qcepDebug(DEBUG_DATABROWSER)) {
114 // printf("of object %s\n", qPrintable(childItem->get_Name()));
115 // }
116 
117  QcepDataObjectPtr parentItem = childItem->parentItem();
118 
119  if (parentItem) {
120  if (parentItem != m_Dataset.data()) {
121  res = createIndex(parentItem->indexInParent(), 0, parentItem.data());
122  }
123  }
124  }
125 
127  printf("QcepDatasetModel::parent(%s)", qPrintable(indexDescription(index)));
128  printf(" = (%s)\n", qPrintable(indexDescription(res)));
129  }
130 
131  return res;
132 }
qint64 qcepDebug(int cond)
Definition: qcepdebug.cpp:26
QcepDataObjectPtr indexedObject(const QModelIndex &index) const
QcepDatasetWPtr m_Dataset
QString indexDescription(const QModelIndex &index) const
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const
QSharedPointer< QcepDataObject > QcepDataObjectPtr

Here is the call graph for this function:

Here is the caller graph for this function:

void QcepDatasetModel::remove ( QcepDataObjectPtr  obj)
slot

Definition at line 759 of file qcepdatasetmodel.cpp.

References index().

760 {
761  if (obj) {
762  QcepDataGroupPtr par = obj->parentItem();
763  int n = obj->indexInParent();
764 
765  if (par && n >= 0 && n < par->childCount()) {
766  beginRemoveRows(index(par), n, n);
767  par->remove(n);
768  endRemoveRows();
769  }
770  }
771 }
QSharedPointer< QcepDataGroup > QcepDataGroupPtr
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const

Here is the call graph for this function:

void QcepDatasetModel::remove ( const QModelIndex &  index)
slot

Definition at line 773 of file qcepdatasetmodel.cpp.

References indexedObject().

774 {
776 
777  remove(obj);
778 }
QcepDataObjectPtr indexedObject(const QModelIndex &index) const
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const
QSharedPointer< QcepDataObject > QcepDataObjectPtr

Here is the call graph for this function:

void QcepDatasetModel::remove ( QString  path)
slot

Definition at line 780 of file qcepdatasetmodel.cpp.

References item().

781 {
782  QcepDataObjectPtr obj = item(path);
783 
784  remove(obj);
785 }
QcepDataObjectPtr item(const QModelIndex &index)
QSharedPointer< QcepDataObject > QcepDataObjectPtr

Here is the call graph for this function:

bool QcepDatasetModel::removeRows ( int  row,
int  count,
const QModelIndex &  parent 
)
slot

Definition at line 332 of file qcepdatasetmodel.cpp.

References indexDescription().

333 {
334  printf("QcepDatasetModel::removeRows(row:%d, count:%d, parent:%s)\n", row, count, qPrintable(indexDescription(parent)));
335 
336  return QAbstractItemModel::removeRows(row, count, parent);
337 }
QModelIndex parent(const QModelIndex &index) const
QString indexDescription(const QModelIndex &index) const

Here is the call graph for this function:

int QcepDatasetModel::rowCount ( const QModelIndex &  parent = QModelIndex()) const
slot

Definition at line 134 of file qcepdatasetmodel.cpp.

References DEBUG_DATABROWSER, indexDescription(), indexedObject(), m_Dataset, and qcepDebug().

Referenced by onDataObjectChanged().

135 {
136  int res = 0;
137 
139  printf("QcepDatasetModel::rowCount(%s)\n", qPrintable(indexDescription(parent)));
140  }
141 
142  if (parent.column() <= 0) {
143  QcepDataObjectPtr parentItem = indexedObject(parent);
144 
145  if (parentItem) {
146  int nrows = parentItem->childCount();
147 
148  res = nrows;
149  } else {
151 
152  if (ds) {
153  res = ds->childCount();
154  }
155  }
156  }
157 
159  printf("QcepDatasetModel::rowCount(%s)", qPrintable(indexDescription(parent)));
160  printf(" = %d\n", res);
161  }
162 
163  return res;
164 }
qint64 qcepDebug(int cond)
Definition: qcepdebug.cpp:26
QcepDataObjectPtr indexedObject(const QModelIndex &index) const
QModelIndex parent(const QModelIndex &index) const
QcepDatasetWPtr m_Dataset
QString indexDescription(const QModelIndex &index) const
QSharedPointer< QcepDataObject > QcepDataObjectPtr
QSharedPointer< QcepDataset > QcepDatasetPtr

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

QcepDatasetWPtr QcepDatasetModel::m_Dataset
private

The documentation for this class was generated from the following files: