QXRD  0.11.16
Public Types | Public Slots | Public Member Functions | Private Attributes | List of all members
QxrdMaskStackModel Class Reference

#include <qxrdmaskstackmodel.h>

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

Public Types

enum  { VisibilityColumn, ThumbnailColumn, TitleColumn, NumColumns }
 

Public Slots

void onMaskChanged ()
 

Public Member Functions

 QxrdMaskStackModel (QxrdMaskStackPtr masks)
 
QxrdMaskStackPtr maskStack ()
 
void setMaskStack (QxrdMaskStackPtr masks)
 
virtual QVariant data (const QModelIndex &index, int role) const
 
virtual QVariant headerData (int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const
 
virtual Qt::ItemFlags flags (const QModelIndex &index) const
 
virtual bool insertRows (int row, int count, const QModelIndex &parent=QModelIndex())
 
virtual bool removeRows (int row, int count, const QModelIndex &parent=QModelIndex())
 
virtual int rowCount (const QModelIndex &parent=QModelIndex()) const
 
virtual int columnCount (const QModelIndex &parent=QModelIndex()) const
 
virtual bool setData (const QModelIndex &index, const QVariant &value, int role=Qt::EditRole)
 
virtual Qt::DropActions supportedDropActions () const
 

Private Attributes

QxrdMaskStackPtr m_MaskStack
 

Detailed Description

Definition at line 7 of file qxrdmaskstackmodel.h.

Member Enumeration Documentation

anonymous enum
Enumerator
VisibilityColumn 
ThumbnailColumn 
TitleColumn 
NumColumns 

Definition at line 27 of file qxrdmaskstackmodel.h.

Constructor & Destructor Documentation

QxrdMaskStackModel::QxrdMaskStackModel ( QxrdMaskStackPtr  masks)

Definition at line 5 of file qxrdmaskstackmodel.cpp.

References QxrdMaskStack::maskChanged(), and onMaskChanged().

5  :
6  m_MaskStack(masks)
7 {
9 }
QxrdMaskStackPtr m_MaskStack
void maskChanged()

Here is the call graph for this function:

Member Function Documentation

int QxrdMaskStackModel::columnCount ( const QModelIndex &  parent = QModelIndex()) const
virtual

Definition at line 20 of file qxrdmaskstackmodel.cpp.

References NumColumns.

Referenced by data(), headerData(), and setData().

21 {
22  if (parent.isValid()) {
23  return 0;
24  }
25 
26  return NumColumns;
27 }

Here is the caller graph for this function:

QVariant QxrdMaskStackModel::data ( const QModelIndex &  index,
int  role 
) const
virtual

Definition at line 29 of file qxrdmaskstackmodel.cpp.

References columnCount(), m_MaskStack, ThumbnailColumn, TitleColumn, and VisibilityColumn.

30 {
31  if (index.row() < 0 || index.row() >= m_MaskStack->count()) {
32  return QVariant();
33  }
34 
35  QcepMaskDataPtr p = m_MaskStack->at(index.row());
36 
37  if (p) {
38  int col = index.column();
39 
40  if (columnCount()==1) {
41  if (col == 0) {
42  if (role == Qt::DecorationRole) {
43  return p->thumbnailImage();
44  } else if (role == Qt::CheckStateRole) {
45  return (p->get_Used()?Qt::Checked:Qt::Unchecked);
46  } else if (role == Qt::DisplayRole || role == Qt::EditRole) {
47  // return tr("%1 : %2").arg(m_MaskStack->stackLevelName(index.row())).arg(p->get_Title());
48  return p->get_Title();
49  }
50  }
51  } else {
52  if (col == ThumbnailColumn) {
53  if (role == Qt::DecorationRole) {
54  return p->thumbnailImage();
55  } else if (role == Qt::SizeHintRole) {
56  return p->thumbnailImageSize();
57  }
58  } else if (col == VisibilityColumn) {
59  if (role == Qt::CheckStateRole) {
60  return (p->get_Used()?Qt::Checked:Qt::Unchecked);
61  } else if (role == Qt::SizeHintRole) {
62  return 30;
63  }
64  } else if (col == TitleColumn) {
65  if (role == Qt::DisplayRole || role == Qt::EditRole) {
66  return p->get_Title();
67  } else if (role==Qt::SizeHintRole) {
68  return 120;
69  }
70  }
71  }
72  }
73 
74  return QVariant();
75 }
QxrdMaskStackPtr m_MaskStack
virtual int columnCount(const QModelIndex &parent=QModelIndex()) const
QSharedPointer< QcepMaskData > QcepMaskDataPtr

Here is the call graph for this function:

Qt::ItemFlags QxrdMaskStackModel::flags ( const QModelIndex &  index) const
virtual

Definition at line 101 of file qxrdmaskstackmodel.cpp.

102 {
103  if (!index.isValid()) {
104  return QAbstractItemModel::flags(index) | Qt::ItemIsDropEnabled;
105  }
106 
107  return QAbstractItemModel::flags(index) | Qt::ItemIsSelectable |Qt::ItemIsEditable | Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled | Qt::ItemIsUserCheckable;
108 }
QVariant QxrdMaskStackModel::headerData ( int  section,
Qt::Orientation  orientation,
int  role = Qt::DisplayRole 
) const
virtual

Definition at line 77 of file qxrdmaskstackmodel.cpp.

References columnCount(), QxrdMaskStack::stackLevelName(), ThumbnailColumn, TitleColumn, and VisibilityColumn.

78 {
79  if (columnCount() == 1) {
80  return QVariant();
81  } else {
82  if (orientation==Qt::Horizontal && role==Qt::DisplayRole) {
83  switch (section) {
84  case VisibilityColumn:
85  return "Vis";
86 
87  case ThumbnailColumn:
88  return "";
89 
90  case TitleColumn:
91  return "Name";
92  }
93  } else if (orientation==Qt::Vertical && role==Qt::DisplayRole) {
94  return QxrdMaskStack::stackLevelName(section);
95  }
96  }
97 
98  return QVariant();
99 }
virtual int columnCount(const QModelIndex &parent=QModelIndex()) const
static QString stackLevelName(int n)

Here is the call graph for this function:

bool QxrdMaskStackModel::insertRows ( int  row,
int  count,
const QModelIndex &  parent = QModelIndex() 
)
virtual

Definition at line 110 of file qxrdmaskstackmodel.cpp.

111 {
112  printf("QxrdMaskStackModel::insertRows(%d,%d,...)\n", row, count);
113 
114  return false;
115 }
QxrdMaskStackPtr QxrdMaskStackModel::maskStack ( )

Definition at line 190 of file qxrdmaskstackmodel.cpp.

References m_MaskStack.

191 {
192  return m_MaskStack;
193 }
QxrdMaskStackPtr m_MaskStack
void QxrdMaskStackModel::onMaskChanged ( )
slot

Definition at line 204 of file qxrdmaskstackmodel.cpp.

Referenced by QxrdMaskStackModel().

205 {
206  emit beginResetModel();
207 
208  emit endResetModel();
209 }

Here is the caller graph for this function:

bool QxrdMaskStackModel::removeRows ( int  row,
int  count,
const QModelIndex &  parent = QModelIndex() 
)
virtual

Definition at line 117 of file qxrdmaskstackmodel.cpp.

118 {
119  printf("QxrdMaskStackModel::removeRows(%d,%d,...)\n", row, count);
120 
121  return false;
122 }
int QxrdMaskStackModel::rowCount ( const QModelIndex &  parent = QModelIndex()) const
virtual

Definition at line 11 of file qxrdmaskstackmodel.cpp.

References m_MaskStack.

12 {
13  if (parent.isValid()) {
14  return 0;
15  }
16 
17  return m_MaskStack->count();
18 }
QxrdMaskStackPtr m_MaskStack
bool QxrdMaskStackModel::setData ( const QModelIndex &  index,
const QVariant &  value,
int  role = Qt::EditRole 
)
virtual

Definition at line 124 of file qxrdmaskstackmodel.cpp.

References columnCount(), m_MaskStack, TitleColumn, and VisibilityColumn.

125 {
126  if (columnCount() == 1) {
127  if (index.column() == 0) {
128  if ((index.row() >= 0) && (index.row() < m_MaskStack->count())) {
129  QcepMaskDataPtr p = m_MaskStack->at(index.row());
130 
131  if ((role == Qt::EditRole || role == Qt::DisplayRole)) {
132  if (p) {
133  p->set_Title(value.toString());
134  }
135 
136  emit dataChanged(index, index);
137 
138  return true;
139  }
140 
141  if (role == Qt::CheckStateRole) {
142  if (p) {
143  p->set_Used(!(p->get_Used()));
144  }
145 
146  emit dataChanged(index, index);
147 
148  return true;
149  }
150  }
151  }
152  } else {
153  if ((index.row() >= 0) && (index.row() < m_MaskStack->count())) {
154  QcepMaskDataPtr p = m_MaskStack->at(index.row());
155 
156  if (index.column() == TitleColumn && (role == Qt::EditRole || role == Qt::DisplayRole)) {
157  if (p) {
158  p->set_Title(value.toString());
159  }
160 
161  emit dataChanged(index, index);
162 
163  return true;
164  }
165 
166  if (index.column() == VisibilityColumn && (role == Qt::CheckStateRole)) {
167  if (p) {
168  p->set_Used(!(p->get_Used()));
169  }
170 
171  emit dataChanged(index, index);
172 
173  return true;
174  }
175  }
176  }
177 
178  return false;
179 }
QxrdMaskStackPtr m_MaskStack
virtual int columnCount(const QModelIndex &parent=QModelIndex()) const
QSharedPointer< QcepMaskData > QcepMaskDataPtr

Here is the call graph for this function:

void QxrdMaskStackModel::setMaskStack ( QxrdMaskStackPtr  masks)

Definition at line 195 of file qxrdmaskstackmodel.cpp.

References m_MaskStack.

196 {
197  emit beginResetModel();
198 
199  m_MaskStack = masks;
200 
201  emit endResetModel();
202 }
QxrdMaskStackPtr m_MaskStack
Qt::DropActions QxrdMaskStackModel::supportedDropActions ( ) const
virtual

Definition at line 185 of file qxrdmaskstackmodel.cpp.

186 {
187  return QAbstractItemModel::supportedDropActions() | Qt::MoveAction;
188 }

Member Data Documentation

QxrdMaskStackPtr QxrdMaskStackModel::m_MaskStack
private

Definition at line 38 of file qxrdmaskstackmodel.h.

Referenced by data(), maskStack(), rowCount(), setData(), and setMaskStack().


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