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

#include <qxrdmasklistmodel.h>

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

Public Types

enum  { VisibilityColumn, ThumbnailColumn, TitleColumn, NumColumns }
 

Public Slots

void onMaskChanged ()
 

Public Member Functions

 QxrdMaskListModel (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 qxrdmasklistmodel.h.

Member Enumeration Documentation

anonymous enum
Enumerator
VisibilityColumn 
ThumbnailColumn 
TitleColumn 
NumColumns 

Definition at line 27 of file qxrdmasklistmodel.h.

Constructor & Destructor Documentation

QxrdMaskListModel::QxrdMaskListModel ( QxrdMaskStackPtr  masks)

Definition at line 3 of file qxrdmasklistmodel.cpp.

References onMaskChanged().

3  :
4  m_MaskStack(masks)
5 {
6  connect(masks, SIGNAL(maskChanged()), this, SLOT(onMaskChanged()));
7 }
QxrdMaskStackPtr m_MaskStack

Here is the call graph for this function:

Member Function Documentation

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

Definition at line 18 of file qxrdmasklistmodel.cpp.

References NumColumns.

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

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

Here is the caller graph for this function:

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

Definition at line 27 of file qxrdmasklistmodel.cpp.

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

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

Here is the call graph for this function:

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

Definition at line 99 of file qxrdmasklistmodel.cpp.

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

Definition at line 75 of file qxrdmasklistmodel.cpp.

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

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

Here is the call graph for this function:

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

Definition at line 108 of file qxrdmasklistmodel.cpp.

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

Definition at line 188 of file qxrdmasklistmodel.cpp.

References m_MaskStack.

189 {
190  return m_MaskStack;
191 }
QxrdMaskStackPtr m_MaskStack
void QxrdMaskListModel::onMaskChanged ( )
slot

Definition at line 202 of file qxrdmasklistmodel.cpp.

Referenced by QxrdMaskListModel().

203 {
204  emit beginResetModel();
205 
206  emit endResetModel();
207 }

Here is the caller graph for this function:

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

Definition at line 115 of file qxrdmasklistmodel.cpp.

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

Definition at line 9 of file qxrdmasklistmodel.cpp.

References m_MaskStack.

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

Definition at line 122 of file qxrdmasklistmodel.cpp.

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

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

Here is the call graph for this function:

void QxrdMaskListModel::setMaskStack ( QxrdMaskStackPtr  masks)

Definition at line 193 of file qxrdmasklistmodel.cpp.

References m_MaskStack.

194 {
195  emit beginResetModel();
196 
197  m_MaskStack = masks;
198 
199  emit endResetModel();
200 }
QxrdMaskStackPtr m_MaskStack
Qt::DropActions QxrdMaskListModel::supportedDropActions ( ) const
virtual

Definition at line 183 of file qxrdmasklistmodel.cpp.

184 {
185  return QAbstractItemModel::supportedDropActions() | Qt::MoveAction;
186 }

Member Data Documentation

QxrdMaskStackPtr QxrdMaskListModel::m_MaskStack
private

Definition at line 38 of file qxrdmasklistmodel.h.

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


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