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

#include <qsenormalizermodel.h>

Inheritance diagram for QseNormalizerModel:
Inheritance graph

Public Slots

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

Public Member Functions

 QseNormalizerModel (QseNormalizer *normalizer, QTableView *tableview, 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
 
void setScanExceptions (QItemSelectionModel *s, QseNormalizer::QseScanRole r)
 
void setColumnExceptions (QItemSelectionModel *s, QseNormalizer::QseColumnRole r)
 

Private Types

typedef QAbstractTableModel inherited
 

Private Attributes

QseNormalizerm_Normalizer
 
QTableView * m_TableView
 

Detailed Description

Definition at line 9 of file qsenormalizermodel.h.

Member Typedef Documentation

typedef QAbstractTableModel QseNormalizerModel::inherited
private

Definition at line 11 of file qsenormalizermodel.h.

Constructor & Destructor Documentation

QseNormalizerModel::QseNormalizerModel ( QseNormalizer normalizer,
QTableView *  tableview,
QObject *  parent = 0 
)

Definition at line 11 of file qsenormalizermodel.cpp.

References QseNormalizerUI::m_Normalizer.

12  : inherited(parent),
13  m_Normalizer(normalizer),
14  m_TableView(table)
15 {
16  connect(m_Normalizer -> inputData(), SIGNAL(operationCompleted()),
17  this, SLOT(operationCompleted()));
18 
19  // connect(m_Normalizer -> inputData(), SIGNAL(dataChanged()),
20  // this, SLOT(dataChanged()));
21 
22  // connect(m_Normalizer -> inputData(), SIGNAL(dataCleared()),
23  // this, SLOT(dataCleared()));
24 
25  // connect(m_Normalizer -> inputData(), SIGNAL(dataChanged()),
26  // this, SIGNAL(modelReset()));
27 }
QAbstractTableModel inherited
QseNormalizer * m_Normalizer
QTableView * m_TableView

Member Function Documentation

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

Definition at line 42 of file qsenormalizermodel.cpp.

References m_Normalizer.

Referenced by data().

43 {
44  int res = 3 + m_Normalizer -> inputData() -> maxColumnCount();
45 
46  // printf("QseNormalizerModel::columnCount = %d\n", res);
47 
48  return res;
49 }
QseNormalizer * m_Normalizer
QVariant QseNormalizerModel::data ( const QModelIndex &  index,
int  role 
) const

Definition at line 52 of file qsenormalizermodel.cpp.

References QseEXAFSOperator::backgroundColorForRole(), QseEXAFSOperator::colorForRole(), QseScan::column(), columnCount(), QseNormalizer::exceptionalColumnRole(), m_Normalizer, and QseNormalizer::patternColumnRole().

53 {
54  // printf("QseNormalizerModel::data(%d,%d,%d)\n", index.row(), index.column(), role);
55 
56  if (!index.isValid()) {
57  return QVariant();
58  }
59 
60  if (role == Qt::DisplayRole) {
61 
62  int row = index.row();
63  int col = index.column();
64 
65  QseScan *scan = m_Normalizer -> inputData() -> scan(row);
66 
67  switch (col) {
68  case 0:
69  return scan -> name();
70  break;
71  case 1:
72  return scan -> maxRowCount();
73  break;
74  case 2:
75  return scan -> columnCount();
76  break;
77  default:
78  QseColumn *c = scan->column(col-3);
79 
80  if (c) {
81  return c -> name();
82  } else {
83  return QVariant();
84  }
85  }
86 
87  } else if (role == Qt::BackgroundRole) {
88  int row = index.row();
89  int col = index.column();
90 
91  QseScan *scan = m_Normalizer -> inputData() -> scan(row);
92 
93  switch (col) {
94  case 0:
95  case 1:
96  case 2:
97  if (m_Normalizer -> matchesScanException(row)) {
98  return QColor(230,255,230);
99  } else {
100  return QColor(Qt::white);
101  }
102  break;
103  default:
104  QseColumn *c = scan->column(col-3);
105 
106  if (c) {
108 
110  } else {
111  return QVariant();
112  }
113  }
114  } else if (role == Qt::ForegroundRole) {
115  // printf("Foreground role\n");
116 
117  int row = index.row();
118  int col = index.column();
119 
120  QseScan *scan = m_Normalizer -> inputData() -> scan(row);
121 
122  switch (col) {
123  case 0:
124  case 1:
125  case 2:
126  if (m_Normalizer -> matchesScan(row)) {
127  return QColor(Qt::black);
128  } else {
129  return QColor(Qt::gray);
130  }
131  break;
132  default:
133  QseColumn *c = scan->column(col-3);
134 
135  if (c) {
137 
138  return QseNormalizer::colorForRole(role);
139  } else {
140  return QVariant();
141  }
142  }
143  } else {
144  return QVariant();
145  }
146 }
QseNormalizer * m_Normalizer
static QColor colorForRole(QseColumnRole r)
int columnCount(const QModelIndex &parent=QModelIndex()) const
QseColumnRole exceptionalColumnRole(int s, int c)
QseColumnRole patternColumnRole(int s, int c)
QseColumn * column(int n) const
Definition: qsescan.cpp:104
static QColor backgroundColorForRole(QseColumnRole r)
void QseNormalizerModel::dataChanged ( )
slot

Definition at line 189 of file qsenormalizermodel.cpp.

190 {
191  // m_TableView -> resizeRowsToContents();
192  // m_TableView -> resizeColumnsToContents();
193 
194  // reset();
195 }
void QseNormalizerModel::dataCleared ( )
slot

Definition at line 198 of file qsenormalizermodel.cpp.

199 {
200  // reset();
201 }
QVariant QseNormalizerModel::headerData ( int  section,
Qt::Orientation  orientation,
int  role = Qt::DisplayRole 
) const

Definition at line 150 of file qsenormalizermodel.cpp.

151 {
152  if (orientation == Qt::Horizontal && role == Qt::DisplayRole) {
153  switch (section) {
154  case 0:
155  return "Scan Name";
156  break;
157  case 1:
158  return "Rows";
159  break;
160  case 2:
161  return "Columns";
162  break;
163  default:
164  return tr("Col %1").arg(section-3);
165  }
166  }
167 
168  if (orientation == Qt::Vertical && role == Qt::DisplayRole) {
169  return section;
170  }
171 
172  return QVariant();
173 }
void QseNormalizerModel::operationCompleted ( )
slot

Definition at line 176 of file qsenormalizermodel.cpp.

References m_TableView.

177 {
178  // printf("QseNormalizerModel::operationCompleted()\n");
179 
180 // reset();
181  beginResetModel();
182  endResetModel();
183 
184  m_TableView -> resizeRowsToContents();
185  m_TableView -> resizeColumnsToContents();
186 }
QTableView * m_TableView
int QseNormalizerModel::rowCount ( const QModelIndex &  parent = QModelIndex()) const

Definition at line 30 of file qsenormalizermodel.cpp.

References m_Normalizer.

31 {
32  if (parent.column() > 0) {
33  return 0;
34  }
35 
36  int res = m_Normalizer -> inputData() -> scanCount();
37 
38  return res;
39 }
QseNormalizer * m_Normalizer
void QseNormalizerModel::scanAdded ( int  n)
slot

Definition at line 204 of file qsenormalizermodel.cpp.

205 {
206 }
void QseNormalizerModel::setColumnExceptions ( QItemSelectionModel *  s,
QseNormalizer::QseColumnRole  r 
)

Definition at line 224 of file qsenormalizermodel.cpp.

References QseNormalizerUI::m_Normalizer.

225 {
226  QItemSelection sel = s->selection();
227  QItemSelectionRange range;
228 
229  foreach(range, sel) {
230  for (int i=range.top(); i<=range.bottom(); i++) {
231  for (int c=range.left(); c<=range.right(); c++) {
232  if (c >= 3) {
233  m_Normalizer -> setColumnException(i, c-3, r);
234  }
235  }
236  }
237  }
238 }
QseNormalizer * m_Normalizer
void QseNormalizerModel::setScanExceptions ( QItemSelectionModel *  s,
QseNormalizer::QseScanRole  r 
)

Definition at line 210 of file qsenormalizermodel.cpp.

References QseNormalizerUI::m_Normalizer.

211 {
212  QItemSelection sel = s->selection();
213  QItemSelectionRange range;
214 
215  foreach(range, sel) {
216  for (int i=range.top(); i<=range.bottom(); i++) {
217  m_Normalizer -> setScanException(i, r);
218  }
219  }
220 }
QseNormalizer * m_Normalizer

Member Data Documentation

QseNormalizer* QseNormalizerModel::m_Normalizer
private

Definition at line 36 of file qsenormalizermodel.h.

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

QTableView* QseNormalizerModel::m_TableView
private

Definition at line 37 of file qsenormalizermodel.h.

Referenced by operationCompleted().


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