QXRD  0.11.16
Public Member Functions | Private Member Functions | Private Attributes | List of all members
QxrdDetectorProxyListModel Class Reference

#include <qxrddetectorproxylistmodel.h>

Inheritance diagram for QxrdDetectorProxyListModel:
Inheritance graph
[legend]
Collaboration diagram for QxrdDetectorProxyListModel:
Collaboration graph
[legend]

Public Member Functions

 QxrdDetectorProxyListModel ()
 
int rowCount (const QModelIndex &parent) const
 
int columnCount (const QModelIndex &parent) const
 
QVariant data (const QModelIndex &index, int role) const
 
QVariant headerData (int section, Qt::Orientation orientation, int role) const
 
Qt::ItemFlags flags (const QModelIndex &index) const
 
bool setData (const QModelIndex &index, const QVariant &value, int role)
 
void append (QxrdDetectorProxyPtr proxy)
 
void removeDetector (int row)
 
void moveDetectorDown (int row)
 
void moveDetectorUp (int row)
 
void configureDetector (int row)
 
QxrdDetectorProxyPtr detectorProxy (int i)
 

Private Member Functions

void renumberDetectors ()
 

Private Attributes

QVector< QxrdDetectorProxyPtrm_DetectorProxies
 

Detailed Description

Definition at line 7 of file qxrddetectorproxylistmodel.h.

Constructor & Destructor Documentation

QxrdDetectorProxyListModel::QxrdDetectorProxyListModel ( )

Definition at line 4 of file qxrddetectorproxylistmodel.cpp.

5 {
6 }

Member Function Documentation

void QxrdDetectorProxyListModel::append ( QxrdDetectorProxyPtr  proxy)

Definition at line 123 of file qxrddetectorproxylistmodel.cpp.

References m_DetectorProxies, and renumberDetectors().

124 {
125  beginInsertRows(QModelIndex(), m_DetectorProxies.count(), m_DetectorProxies.count());
126 
127  m_DetectorProxies.append(proxy);
128 
129  endInsertRows();
130 
132 }
QVector< QxrdDetectorProxyPtr > m_DetectorProxies

Here is the call graph for this function:

int QxrdDetectorProxyListModel::columnCount ( const QModelIndex &  parent) const

Definition at line 13 of file qxrddetectorproxylistmodel.cpp.

14 {
15  return 4;
16 }
void QxrdDetectorProxyListModel::configureDetector ( int  row)

Definition at line 188 of file qxrddetectorproxylistmodel.cpp.

References m_DetectorProxies.

189 {
191 
192  if (p) {
193  p->configureDetector();
194  }
195 }
QSharedPointer< QxrdDetectorProxy > QxrdDetectorProxyPtr
QVector< QxrdDetectorProxyPtr > m_DetectorProxies
QVariant QxrdDetectorProxyListModel::data ( const QModelIndex &  index,
int  role 
) const

Definition at line 18 of file qxrddetectorproxylistmodel.cpp.

References m_DetectorProxies.

19 {
20  int row = index.row();
21  int col = index.column();
23 
24  if (p) {
25  if (role == Qt::EditRole || role == Qt::DisplayRole) {
26  if (col == 0) {
27 // return row;
28  return p->detectorNumber();
29  } else if (col == 2) {
30  return p->detectorTypeName();
31  } else if (col == 3) {
32  return p->detectorName();
33  }
34  } else if (role == Qt::CheckStateRole) {
35  if (col == 1) {
36  if (p->enabled()) {
37  return Qt::Checked;
38  } else {
39  return Qt::Unchecked;
40  }
41  }
42  } else if (role == Qt::TextAlignmentRole) {
43  if (col == 0 || col == 1) {
44  return Qt::AlignHCenter;
45  } else {
46  return Qt::AlignAbsolute;
47  }
48  }
49  }
50 
51  return QVariant();
52 }
QSharedPointer< QxrdDetectorProxy > QxrdDetectorProxyPtr
QVector< QxrdDetectorProxyPtr > m_DetectorProxies
QxrdDetectorProxyPtr QxrdDetectorProxyListModel::detectorProxy ( int  i)

Definition at line 134 of file qxrddetectorproxylistmodel.cpp.

References m_DetectorProxies.

135 {
136  return m_DetectorProxies.value(i);
137 }
QVector< QxrdDetectorProxyPtr > m_DetectorProxies
Qt::ItemFlags QxrdDetectorProxyListModel::flags ( const QModelIndex &  index) const

Definition at line 109 of file qxrddetectorproxylistmodel.cpp.

110 {
111  int row = index.row();
112  int col = index.column();
113 
114  if (col == 1) {
115  return QAbstractListModel::flags(index) | Qt::ItemIsUserCheckable;
116  } else if (col == 3) {
117  return QAbstractListModel::flags(index) | Qt::ItemIsEditable;
118  } else {
119  return QAbstractListModel::flags(index);
120  }
121 }
QVariant QxrdDetectorProxyListModel::headerData ( int  section,
Qt::Orientation  orientation,
int  role 
) const

Definition at line 54 of file qxrddetectorproxylistmodel.cpp.

55 {
56  if (orientation == Qt::Horizontal) {
57  if (role == Qt::DisplayRole) {
58  if (section == 0) {
59  return "#";
60  }
61 
62  if (section == 1) {
63  return "Enabled";
64  }
65 
66  if (section == 2) {
67  return "Type";
68  }
69 
70  if (section == 3) {
71  return "Name";
72  }
73  } else if (role == Qt::TextAlignmentRole) {
74  return Qt::AlignHCenter;
75  }
76  }
77 
78  return QVariant();
79 }
void QxrdDetectorProxyListModel::moveDetectorDown ( int  row)

Definition at line 150 of file qxrddetectorproxylistmodel.cpp.

References m_DetectorProxies, and renumberDetectors().

151 {
152  int nRows = m_DetectorProxies.count();
153 
154  if (row >= 0 && row < (nRows-1)) {
155  beginMoveRows(QModelIndex(), row+1, row+1, QModelIndex(), row);
156 
159 
160  m_DetectorProxies[row] = p2;
161  m_DetectorProxies[row+1] = p1;
162 
163  endMoveRows();
164 
166  }
167 }
QSharedPointer< QxrdDetectorProxy > QxrdDetectorProxyPtr
QVector< QxrdDetectorProxyPtr > m_DetectorProxies

Here is the call graph for this function:

void QxrdDetectorProxyListModel::moveDetectorUp ( int  row)

Definition at line 169 of file qxrddetectorproxylistmodel.cpp.

References m_DetectorProxies, and renumberDetectors().

170 {
171  int nRows = m_DetectorProxies.count();
172 
173  if (row >= 1 && row < nRows) {
174  beginMoveRows(QModelIndex(), row, row, QModelIndex(), row-1);
175 
178 
179  m_DetectorProxies[row-1] = p2;
180  m_DetectorProxies[row] = p1;
181 
182  endMoveRows();
183 
185  }
186 }
QSharedPointer< QxrdDetectorProxy > QxrdDetectorProxyPtr
QVector< QxrdDetectorProxyPtr > m_DetectorProxies

Here is the call graph for this function:

void QxrdDetectorProxyListModel::removeDetector ( int  row)

Definition at line 139 of file qxrddetectorproxylistmodel.cpp.

References m_DetectorProxies, and renumberDetectors().

140 {
141  beginRemoveRows(QModelIndex(), row, row);
142 
143  m_DetectorProxies.remove(row);
144 
145  endRemoveRows();
146 
148 }
QVector< QxrdDetectorProxyPtr > m_DetectorProxies

Here is the call graph for this function:

void QxrdDetectorProxyListModel::renumberDetectors ( )
private

Definition at line 197 of file qxrddetectorproxylistmodel.cpp.

References m_DetectorProxies.

Referenced by append(), moveDetectorDown(), moveDetectorUp(), and removeDetector().

198 {
199  for (int i=0; i<m_DetectorProxies.count(); i++) {
201 
202  if (p) {
203  p->setProperty("detectorNumber", i);
204  }
205  }
206 }
QSharedPointer< QxrdDetectorProxy > QxrdDetectorProxyPtr
QVector< QxrdDetectorProxyPtr > m_DetectorProxies

Here is the caller graph for this function:

int QxrdDetectorProxyListModel::rowCount ( const QModelIndex &  parent) const

Definition at line 8 of file qxrddetectorproxylistmodel.cpp.

References m_DetectorProxies.

9 {
10  return m_DetectorProxies.count();
11 }
QVector< QxrdDetectorProxyPtr > m_DetectorProxies
bool QxrdDetectorProxyListModel::setData ( const QModelIndex &  index,
const QVariant &  value,
int  role 
)

Definition at line 81 of file qxrddetectorproxylistmodel.cpp.

References m_DetectorProxies.

82 {
83  int row = index.row();
84  int col = index.column();
85 
86  QxrdDetectorProxyPtr proxy = m_DetectorProxies.value(row);
87 
88  if (proxy) {
89  if (col == 1 && role == Qt::CheckStateRole) {
90  proxy->setEnabled(!proxy->enabled());
91 
92  emit dataChanged(index, index);
93 
94  return true;
95  } else if (col == 3) {
96  if (role == Qt::EditRole || role == Qt::DisplayRole) {
97  proxy->setDetectorName(value.toString());
98 
99  emit dataChanged(index, index);
100 
101  return true;
102  }
103  }
104  }
105 
106  return false;
107 }
QSharedPointer< QxrdDetectorProxy > QxrdDetectorProxyPtr
QVector< QxrdDetectorProxyPtr > m_DetectorProxies

Member Data Documentation

QVector<QxrdDetectorProxyPtr> QxrdDetectorProxyListModel::m_DetectorProxies
private

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