#include <KisSnapshotModel.h>
Definition at line 16 of file KisSnapshotModel.h.
◆ KisSnapshotModel()
| KisSnapshotModel::KisSnapshotModel |
( |
| ) |
|
Definition at line 76 of file KisSnapshotModel.cpp.
77 : QAbstractListModel()
79{
80}
QScopedPointer< Private > m_d
◆ ~KisSnapshotModel()
| KisSnapshotModel::~KisSnapshotModel |
( |
| ) |
|
|
override |
◆ data()
| QVariant KisSnapshotModel::data |
( |
const QModelIndex & | index, |
|
|
int | role ) const |
|
override |
Definition at line 95 of file KisSnapshotModel.cpp.
96{
97 if (!index.isValid() || index.row() >=
rowCount(QModelIndex())) {
98 return QVariant();
99 }
100 int i = index.row();
101 switch (role) {
102 case Qt::DisplayRole:
103 case Qt::EditRole:
104 return m_d->curDocList[i].first;
105 break;
106 }
107 return QVariant();
108}
int rowCount(const QModelIndex &parent) const override
References m_d, and rowCount().
◆ flags()
| Qt::ItemFlags KisSnapshotModel::flags |
( |
const QModelIndex & | index | ) |
const |
|
override |
Definition at line 127 of file KisSnapshotModel.cpp.
128{
129 if (!index.isValid()) {
130 return Qt::ItemIsEnabled;
131 }
132
133 return QAbstractListModel::flags(index) | Qt::ItemIsEditable;
134}
◆ rowCount()
| int KisSnapshotModel::rowCount |
( |
const QModelIndex & | parent | ) |
const |
|
override |
Definition at line 86 of file KisSnapshotModel.cpp.
87{
89 return 0;
90 } else {
91 return m_d->curDocList.size();
92 }
93}
ChildIterator< value_type, is_const > parent(const ChildIterator< value_type, is_const > &it)
References m_d.
◆ setCanvas()
Definition at line 136 of file KisSnapshotModel.cpp.
137{
138 if (
m_d->curCanvas == canvas) {
139 return;
140 }
141
142 m_d->curNameServer.reset();
143
144 if (
m_d->curDocument()) {
145 m_d->documentGroups.insert(
m_d->curDocument(),
m_d->curDocList);
146 } else {
147 Q_FOREACH (
auto const &i,
m_d->curDocList) {
148 delete i.second.data();
149 }
150 }
151
152 if (!
m_d->curDocList.isEmpty()) {
153 beginRemoveRows(QModelIndex(), 0,
m_d->curDocList.size() - 1);
154 m_d->curDocList.clear();
155 endRemoveRows();
156 }
157 m_d->curCanvas = canvas;
158
160 if (curDoc) {
162 beginInsertRows(QModelIndex(), docList.size(), docList.size());
163 m_d->curDocList = docList;
164 endInsertRows();
165
167 if (!nameServer) {
169 m_d->nameServers.insert(curDoc, nameServer);
170 }
171 m_d->curNameServer = nameServer;
172 }
173
174}
QList< QPair< QString, QPointer< KisDocument > > > DocPList
References m_d.
◆ setData()
| bool KisSnapshotModel::setData |
( |
const QModelIndex & | index, |
|
|
const QVariant & | value, |
|
|
int | role ) |
|
override |
Definition at line 110 of file KisSnapshotModel.cpp.
111{
112 if (!index.isValid() || index.row() >=
rowCount(QModelIndex())) {
113 return false;
114 }
115 int i = index.row();
116 switch (role) {
117 case Qt::DisplayRole:
118 case Qt::EditRole:
119 m_d->curDocList[i].first =
value.toString();
120 Q_EMIT dataChanged(index, index);
121 return true;
122 break;
123 }
124 return false;
125}
float value(const T *src, size_t ch)
References m_d, rowCount(), and value().
◆ slotCreateSnapshot
| bool KisSnapshotModel::slotCreateSnapshot |
( |
| ) |
|
|
slot |
Definition at line 176 of file KisSnapshotModel.cpp.
177{
178 if (!
m_d->curDocument()) {
179 return false;
180 }
182 if (clonedDoc) {
183 beginInsertRows(QModelIndex(),
m_d->curDocList.size(),
m_d->curDocList.size());
184 m_d->curDocList << qMakePair(i18nc(
"snapshot names, e.g. \"Snapshot 1\"",
"Snapshot %1",
m_d->curNameServer->number()), clonedDoc);
185 endInsertRows();
186 return true;
187 }
188 return false;
189}
References m_d.
◆ slotRemoveSnapshot
| bool KisSnapshotModel::slotRemoveSnapshot |
( |
const QModelIndex & | index | ) |
|
|
slot |
Definition at line 191 of file KisSnapshotModel.cpp.
192{
193 if (!index.isValid() || index.row() >=
m_d->curDocList.size()) {
194 return false;
195 }
196 int i = index.row();
197 beginRemoveRows(QModelIndex(), i, i);
198 QPair<QString, QPointer<KisDocument> > pair =
m_d->curDocList.takeAt(i);
199 endRemoveRows();
200 delete pair.second.data();
201 return true;
202}
References m_d.
◆ slotSwitchToSnapshot
| bool KisSnapshotModel::slotSwitchToSnapshot |
( |
const QModelIndex & | index | ) |
|
|
slot |
Definition at line 204 of file KisSnapshotModel.cpp.
205{
206 if (!index.isValid() || index.row() >=
m_d->curDocList.size()) {
207 return false;
208 }
209
210 return m_d->switchToDocument(
m_d->curDocList[index.row()].second);
211}
References m_d.
◆ m_d
| QScopedPointer<Private> KisSnapshotModel::m_d |
|
private |
The documentation for this class was generated from the following files: