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