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

#include <qsescanaveragermodel.h>

Inheritance diagram for QseScanAveragerModel:
Inheritance graph

Public Slots

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

Public Member Functions

 QseScanAveragerModel (QseScanAverager *averager, QTableView *table, 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

QseScanAveragerm_ScanAverager
 
QTableView * m_TableView
 
int m_PrevRowCount
 
int m_PrevColumnCount
 

Detailed Description

Definition at line 9 of file qsescanaveragermodel.h.

Member Typedef Documentation

typedef QAbstractTableModel QseScanAveragerModel::inherited
private

Definition at line 11 of file qsescanaveragermodel.h.

Constructor & Destructor Documentation

QseScanAveragerModel::QseScanAveragerModel ( QseScanAverager averager,
QTableView *  table,
QObject *  parent = 0 
)

Definition at line 11 of file qsescanaveragermodel.cpp.

References QseScanAveragerUI::m_ScanAverager.

12  : inherited(parent),
13  m_ScanAverager(scanaverager),
14  m_TableView(table),
15  m_PrevRowCount(0),
17 {
18  connect(m_ScanAverager -> inputData(), SIGNAL(operationCompleted()),
19  this, SLOT(operationCompleted()));
20 
21 // connect(m_ScanAverager -> inputData(), SIGNAL(dataChanged()),
22 // this, SLOT(dataChanged()));
23 
24 // connect(m_ScanAverager -> inputData(), SIGNAL(dataCleared()),
25 // this, SLOT(dataCleared()));
26 
27 // connect(m_ScanAverager -> inputData(), SIGNAL(dataChanged()),
28 // this, SIGNAL(modelReset()));
29 }
QAbstractTableModel inherited
QseScanAverager * m_ScanAverager

Member Function Documentation

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

Definition at line 52 of file qsescanaveragermodel.cpp.

References m_PrevColumnCount.

Referenced by data().

53 {
54  int res = 3 // + m_ScanAverager -> inputData() -> maxColumnCount()
55  ;
56 
57 // printf("QseScanAveragerModel::columnCount = %d\n", res);
58 
59 // if (res > m_PrevColumnCount) {
60 // printf("QseScanAveragerModel::columnCount(%d>%d)\n", res, m_PrevColumnCount);
61 // } else if (res < m_PrevColumnCount) {
62 // printf("QseScanAveragerModel::columnCount(%d<%d)\n", res, m_PrevColumnCount);
63 // }
64 
65  m_PrevColumnCount = res;
66 
67  return res;
68 }
QVariant QseScanAveragerModel::data ( const QModelIndex &  index,
int  role 
) const

Definition at line 71 of file qsescanaveragermodel.cpp.

References QseScan::column(), columnCount(), and m_ScanAverager.

72 {
73 // printf("QseScanAveragerModel::data(%d,%d,%d)\n", index.row(), index.column(), role);
74 
75  if (!index.isValid()) {
76  return QVariant();
77  }
78 
79  if (role == Qt::DisplayRole) {
80 
81  int row = index.row();
82  int col = index.column();
83 
84  QseScan *scan = m_ScanAverager -> inputData() -> scan(row);
85 
86  switch (col) {
87  case 0:
88  return scan -> name();
89  break;
90  case 1:
91  return scan -> maxRowCount();
92  break;
93  case 2:
94  return scan -> columnCount();
95  break;
96  default:
97  QseColumn *c = scan->column(col-3);
98 
99  if (c) {
100  return c -> name();
101  } else {
102  return QVariant();
103  }
104  }
105  } else {
106  return QVariant();
107  }
108 }
int columnCount(const QModelIndex &parent=QModelIndex()) const
QseScanAverager * m_ScanAverager
QseColumn * column(int n) const
Definition: qsescan.cpp:104
void QseScanAveragerModel::dataChanged ( )
slot

Definition at line 151 of file qsescanaveragermodel.cpp.

152 {
153 // reset();
154  beginResetModel();
155  endResetModel();
156 
157 // m_TableView -> resizeRowsToContents();
158 // m_TableView -> resizeColumnsToContents();
159 }
void QseScanAveragerModel::dataCleared ( )
slot

Definition at line 162 of file qsescanaveragermodel.cpp.

163 {
164 // reset();
165  beginResetModel();
166  endResetModel();
167 }
QVariant QseScanAveragerModel::headerData ( int  section,
Qt::Orientation  orientation,
int  role = Qt::DisplayRole 
) const

Definition at line 112 of file qsescanaveragermodel.cpp.

113 {
114  if (orientation == Qt::Horizontal && role == Qt::DisplayRole) {
115  switch (section) {
116  case 0:
117  return "Scan Name";
118  break;
119  case 1:
120  return "Rows";
121  break;
122  case 2:
123  return "Columns";
124  break;
125  default:
126  return tr("Col %1").arg(section-3);
127  }
128  }
129 
130  if (orientation == Qt::Vertical && role == Qt::DisplayRole) {
131  return section;
132  }
133 
134  return QVariant();
135 }
void QseScanAveragerModel::operationCompleted ( )
slot

Definition at line 138 of file qsescanaveragermodel.cpp.

139 {
140 // printf("QseScanAveragerModel::operationCompleted\n");
141 
142 // reset();
143  beginResetModel();
144  endResetModel();
145 
146 // m_TableView -> resizeRowsToContents();
147 // m_TableView -> resizeColumnsToContents();
148 }
int QseScanAveragerModel::rowCount ( const QModelIndex &  parent = QModelIndex()) const

Definition at line 32 of file qsescanaveragermodel.cpp.

References m_PrevRowCount, and m_ScanAverager.

33 {
34  if (parent.column() > 0) {
35  return 0;
36  }
37 
38  int res = m_ScanAverager -> inputData() -> scanCount();
39 
40 // if (res > m_PrevRowCount) {
41 // printf("QseScanAveragerModel::rowCount(%d>%d)\n", res, m_PrevRowCount);
42 // } else if (res < m_PrevRowCount) {
43 // printf("QseScanAveragerModel::rowCount(%d<%d)\n", res, m_PrevRowCount);
44 // }
45 
46  m_PrevRowCount = res;
47 
48  return res;
49 }
QseScanAverager * m_ScanAverager
void QseScanAveragerModel::scanAdded ( int  n)
slot

Definition at line 170 of file qsescanaveragermodel.cpp.

171 {
172 }

Member Data Documentation

int QseScanAveragerModel::m_PrevColumnCount
mutableprivate

Definition at line 34 of file qsescanaveragermodel.h.

Referenced by columnCount().

int QseScanAveragerModel::m_PrevRowCount
mutableprivate

Definition at line 33 of file qsescanaveragermodel.h.

Referenced by rowCount().

QseScanAverager* QseScanAveragerModel::m_ScanAverager
private

Definition at line 31 of file qsescanaveragermodel.h.

Referenced by data(), and rowCount().

QTableView* QseScanAveragerModel::m_TableView
private

Definition at line 32 of file qsescanaveragermodel.h.


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