qse  0.5.4
Public Slots | Public Member Functions | Private Types | Private Attributes | List of all members
QseDataSetModel Class Reference

#include <qsedatasetmodel.h>

Inheritance diagram for QseDataSetModel:
Inheritance graph

Public Slots

void dataChanged ()
 
void dataCleared ()
 
void scanAdded (int n)
 

Public Member Functions

 QseDataSetModel (QseDataSet *dataSet, QObject *parent=0)
 
int rowCount (const QModelIndex &parent=QModelIndex()) const
 
int columnCount (const QModelIndex &parent=QModelIndex()) const
 
QVariant data (const QModelIndex &index, int role) const
 
QVariant headerData (int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const
 

Private Types

typedef QAbstractTableModel inherited
 

Private Attributes

QseDataSetm_DataSet
 
int m_NScans
 

Detailed Description

Definition at line 9 of file qsedatasetmodel.h.

Member Typedef Documentation

typedef QAbstractTableModel QseDataSetModel::inherited
private

Definition at line 11 of file qsedatasetmodel.h.

Constructor & Destructor Documentation

QseDataSetModel::QseDataSetModel ( QseDataSet dataSet,
QObject *  parent = 0 
)

Definition at line 7 of file qsedatasetmodel.cpp.

8  : QAbstractTableModel(parent),
9  m_DataSet(dataSet)
10 {
11 // printf("Dataset Model Constructed %p, Model Thread %p\n", dataSet->thread(), this->thread());
12 
13  connect(dataSet, SIGNAL(operationCompleted()),
14  this, SLOT(operationCompleted()));
15 
16 // connect(dataSet, SIGNAL(dataChanged()),
17 // this, SLOT(dataChanged()));
18 
19 // connect(dataSet, SIGNAL(dataCleared()),
20 // this, SLOT(dataCleared()));
21 
22 // connect(dataSet, SIGNAL(dataChanged()),
23 // this, SIGNAL(modelReset()));
24 
25 // connect(dataSet, SIGNAL(scanAdded(int)),
26 // this, SLOT(scanAdded(int)));
27 }
QseDataSet * m_DataSet

Member Function Documentation

int QseDataSetModel::columnCount ( const QModelIndex &  parent = QModelIndex()) const

Definition at line 54 of file qsedatasetmodel.cpp.

References m_DataSet, and QseDataSet::maxColumnCount().

Referenced by data().

55 {
56  int res = 3 + m_DataSet->maxColumnCount();
57 
58 // printf("QseDataSetModel::columnCount = %d\n", res);
59 
60  return res;
61 }
QseDataSet * m_DataSet
int maxColumnCount() const
Definition: qsedataset.cpp:82
QVariant QseDataSetModel::data ( const QModelIndex &  index,
int  role 
) const

Definition at line 64 of file qsedatasetmodel.cpp.

References QseScan::column(), columnCount(), m_DataSet, and QseDataSet::scan().

65 {
66  if (!index.isValid()) {
67  return QVariant();
68  }
69 
70  if (role != Qt::DisplayRole) {
71  return QVariant();
72  }
73 
74  int row = index.row();
75  int col = index.column();
76 
77  QseScan *scan = m_DataSet->scan(row);
78 
79  switch (col) {
80  case 0:
81  return scan -> name();
82  break;
83  case 1:
84  return scan -> maxRowCount();
85  break;
86  case 2:
87  return scan -> columnCount();
88  break;
89  default:
90  QseColumn *c = scan->column(col-3);
91 
92  if (c) {
93  return c -> name();
94  } else {
95  return QVariant();
96  }
97  }
98 }
QseScan * scan(int n) const
Definition: qsedataset.cpp:70
QseDataSet * m_DataSet
int columnCount(const QModelIndex &parent=QModelIndex()) const
QseColumn * column(int n) const
Definition: qsescan.cpp:104
void QseDataSetModel::dataChanged ( )
slot

Definition at line 145 of file qsedatasetmodel.cpp.

146 {
147 // printf("QseDataSetModel::dataChanged\n");
148 // reset();
149  beginResetModel();
150  endResetModel();
151 }
void QseDataSetModel::dataCleared ( )
slot

Definition at line 154 of file qsedatasetmodel.cpp.

155 {
156 // printf("QseDataSetModel::dataCleared\n");
157 
158 // reset();
159  beginResetModel();
160  endResetModel();
161 }
QVariant QseDataSetModel::headerData ( int  section,
Qt::Orientation  orientation,
int  role = Qt::DisplayRole 
) const

Definition at line 102 of file qsedatasetmodel.cpp.

103 {
104  if (orientation == Qt::Horizontal && role == Qt::DisplayRole) {
105  switch (section) {
106  case 0:
107  return "Scan Name";
108  break;
109  case 1:
110  return "Rows";
111  break;
112  case 2:
113  return "Columns";
114  break;
115  default:
116  return tr("Col %1").arg(section-3);
117  }
118  }
119 
120  if (orientation == Qt::Vertical && role == Qt::DisplayRole) {
121  return section;
122  }
123 
124  return QVariant();
125 }
int QseDataSetModel::rowCount ( const QModelIndex &  parent = QModelIndex()) const

Definition at line 30 of file qsedatasetmodel.cpp.

References m_DataSet.

31 {
32  if (parent.column() > 0) {
33  return 0;
34  }
35 
36  int res = m_DataSet -> scanCount();
37 
38 // printf("QseDataSetModel::rowCount = %d\n", res);
39 
40  return res;
41 }
QseDataSet * m_DataSet
void QseDataSetModel::scanAdded ( int  n)
slot

Definition at line 164 of file qsedatasetmodel.cpp.

165 {
166 // printf("%s: QseDataSetModel::scanAdded(%d)\n", qPrintable(m_DataSet->objectName()), n);
167 
168 // insertRows(n, 1, QModelIndex());
169 
170 // printf("Row Count = %d\n", rowCount());
171 }

Member Data Documentation

QseDataSet* QseDataSetModel::m_DataSet
private

Definition at line 47 of file qsedatasetmodel.h.

Referenced by columnCount(), data(), and rowCount().

int QseDataSetModel::m_NScans
private

Definition at line 48 of file qsedatasetmodel.h.


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