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

#include <qsegraphcolumnsmodel.h>

Inheritance diagram for QseGraphColumnsModel:
Inheritance graph

Public Member Functions

 QseGraphColumnsModel (QseGraphController *controller, 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
 
void columnsChanged ()
 
void emitDataChanged (const QModelIndex &topLeft, const QModelIndex &bottomRight)
 

Private Types

typedef QAbstractTableModel inherited
 

Private Attributes

QseGraphControllerm_Controller
 
QseDataSetm_DataSet
 
QTableView * m_TableView
 

Detailed Description

Definition at line 10 of file qsegraphcolumnsmodel.h.

Member Typedef Documentation

typedef QAbstractTableModel QseGraphColumnsModel::inherited
private

Definition at line 12 of file qsegraphcolumnsmodel.h.

Constructor & Destructor Documentation

QseGraphColumnsModel::QseGraphColumnsModel ( QseGraphController controller,
QTableView *  table,
QObject *  parent = 0 
)

Definition at line 7 of file qsegraphcolumnsmodel.cpp.

8  : QAbstractTableModel(parent),
9  m_Controller(controller),
10  m_DataSet(NULL),
11  m_TableView(table)
12 {
13  if (m_Controller) {
15  }
16 }
QseGraphController * m_Controller
QseDataSet * dataSet() const

Member Function Documentation

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

Definition at line 54 of file qsegraphcolumnsmodel.cpp.

55 {
56  return 4;
57 }
void QseGraphColumnsModel::columnsChanged ( )

Definition at line 31 of file qsegraphcolumnsmodel.cpp.

References m_TableView.

32 {
33 // reset();
34  beginResetModel();
35  endResetModel();
36 
37  m_TableView -> resizeRowsToContents();
38  m_TableView -> resizeColumnsToContents();
39 }
QVariant QseGraphColumnsModel::data ( const QModelIndex &  index,
int  role 
) const

Definition at line 60 of file qsegraphcolumnsmodel.cpp.

References m_Controller, QseGraphController::selectedColumn(), QseGraphController::selectedPlotX(), QseGraphController::selectedPlotY(), and QseGraphController::selectedPlotY2().

61 {
62  if (!index.isValid()) {
63  return QVariant();
64  }
65 
66 // if (role != Qt::DisplayRole) {
67 // return QVariant();
68 // }
69 
70  int row = index.row();
71  int col = index.column();
72 
73  switch (role) {
74  case Qt::DisplayRole:
75  switch (col) {
76  case 0:
77  return m_Controller->selectedColumn(row);
78  break;
79  case 1: // X?
80  return m_Controller->selectedPlotX(row) ? "X" : " ";
81  break;
82  case 2: // Y1?
83  return m_Controller->selectedPlotY(row) ? "Y" : " ";
84  break;
85  case 3: // Y2?
86  return m_Controller->selectedPlotY2(row) ? "Y2" : " ";
87  break;
88 // case 4: // NRM?
89 // return m_Controller->selectedPlotNorm(row) ? "NRM" : " ";
90 // break;
91  default:
92  return QVariant();
93  }
94 
95  case Qt::DecorationRole:
96  switch (col) {
97  case 2:
98  return m_Controller->selectedPlotY(row) ? QIcon(":/images/ok.png") : QIcon(":/images/up.png");
99  break;
100  default:
101  return QVariant();
102  }
103  break;
104 
105  default:
106  return QVariant();
107  }
108 }
QString selectedColumn(int i) const
QseGraphController * m_Controller
bool selectedPlotY(int i) const
bool selectedPlotX(int i) const
bool selectedPlotY2(int i) const
void QseGraphColumnsModel::emitDataChanged ( const QModelIndex &  topLeft,
const QModelIndex &  bottomRight 
)

Definition at line 25 of file qsegraphcolumnsmodel.cpp.

26 {
27  emit dataChanged(topLeft, bottomRight);
28 }
QVariant QseGraphColumnsModel::headerData ( int  section,
Qt::Orientation  orientation,
int  role = Qt::DisplayRole 
) const

Definition at line 112 of file qsegraphcolumnsmodel.cpp.

113 {
114  if (orientation == Qt::Horizontal && role == Qt::DisplayRole) {
115  switch (section) {
116  case 0:
117  return "Col";
118  break;
119  case 1:
120  return "X";
121  break;
122  case 2:
123  return "Y1";
124  break;
125  case 3:
126  return "Y2";
127  break;
128 // case 4:
129 // return "NRM";
130 // break;
131  default:
132  return QVariant();
133  }
134  }
135 
136  if (orientation == Qt::Vertical && role == Qt::DisplayRole) {
137  return section;
138  }
139 
140  return QVariant();
141 }
int QseGraphColumnsModel::rowCount ( const QModelIndex &  parent = QModelIndex()) const

Definition at line 42 of file qsegraphcolumnsmodel.cpp.

References m_Controller, and QseGraphController::selectedColumnCount().

Referenced by QseGraphController::columnsCellClicked().

43 {
44  if (parent.column() > 0) {
45  return 0;
46  }
47 
48  int res = m_Controller->selectedColumnCount();
49 
50  return res;
51 }
QseGraphController * m_Controller
int selectedColumnCount() const

Member Data Documentation

QseGraphController* QseGraphColumnsModel::m_Controller
private

Definition at line 36 of file qsegraphcolumnsmodel.h.

Referenced by data(), and rowCount().

QseDataSet* QseGraphColumnsModel::m_DataSet
private

Definition at line 37 of file qsegraphcolumnsmodel.h.

QTableView* QseGraphColumnsModel::m_TableView
private

Definition at line 38 of file qsegraphcolumnsmodel.h.

Referenced by columnsChanged().


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