QXRD  0.11.16
qcepimagedataspreadsheetmodel.cpp
Go to the documentation of this file.
2 #include <QModelIndex>
3 
5  (QWeakPointer<QcepImageDataBase> img)
6  : m_Image(img)
7 {
8 
9 }
10 
11 int QcepImageDataSpreadsheetModel::rowCount(const QModelIndex &parent) const
12 {
13  QSharedPointer<QcepImageDataBase> img(m_Image);
14 
15  if (img) {
16  return img->get_Height();
17  } else {
18  return 0;
19  }
20 }
21 
22 int QcepImageDataSpreadsheetModel::columnCount(const QModelIndex &parent) const
23 {
24  QSharedPointer<QcepImageDataBase> img(m_Image);
25 
26  if (img) {
27  return img->get_Width();
28  } else {
29  return 0;
30  }
31 }
32 
33 QVariant QcepImageDataSpreadsheetModel::data(const QModelIndex &index, int role) const
34 {
35  QVariant res = QVariant();
36 
37  if (!index.isValid()) {
38  res = QVariant();
39  } else if (role == Qt::DisplayRole) {
40  QSharedPointer<QcepImageDataBase> img(m_Image);
41 
42  if (img) {
43  double v = img->getImageData(index.column(), index.row());
44  res = v;
45  }
46  }
47 
48  return res;
49 }
50 
int columnCount(const QModelIndex &parent=QModelIndex()) const
QcepImageDataSpreadsheetModel(QWeakPointer< QcepImageDataBase > img)
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const
int rowCount(const QModelIndex &parent=QModelIndex()) const
QWeakPointer< QcepImageDataBase > m_Image