Krita Source Code Documentation
Loading...
Searching...
No Matches
kundo2view.cpp
Go to the documentation of this file.
1/* This file is part of the KDE project
2 * SPDX-FileCopyrightText: 2010 Matus Talcik <matus.talcik@gmail.com>
3 *
4 * SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6/****************************************************************************
7**
8** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
9** All rights reserved.
10** Contact: Nokia Corporation (qt-info@nokia.com)
11**
12** This file is part of the QtGui module of the Qt Toolkit.
13**
14** $QT_BEGIN_LICENSE:LGPL$
15** No Commercial Usage
16** This file contains pre-release code and may not be distributed.
17** You may use this file in accordance with the terms and conditions
18** contained in the Technology Preview License Agreement accompanying
19** this package.
20**
21** GNU Lesser General Public License Usage
22** Alternatively, this file may be used under the terms of the GNU Lesser
23** General Public License version 2.1 as published by the Free Software
24** Foundation and appearing in the file LICENSE.LGPL included in the
25** packaging of this file. Please review the following information to
26** ensure the GNU Lesser General Public License version 2.1 requirements
27** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
28**
29** In addition, as a special exception, Nokia gives you certain additional
30** rights. These rights are described in the Nokia Qt LGPL Exception
31** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
32**
33** If you have questions regarding the use of this file, please contact
34** Nokia at qt-info@nokia.com.
35**
36**
37**
38**
39**
40**
41**
42**
43** $QT_END_LICENSE$
44**
45****************************************************************************/
46#include "kundo2stack.h"
47#include "kundo2view.h"
48#include "kundo2model.h"
49#include "kundo2group.h"
50
51#ifndef QT_NO_UNDOVIEW
52
53#include <QAbstractItemModel>
54#include <QPointer>
55#include <QIcon>
56
57
78{
79public:
81#ifndef QT_NO_UNDOGROUP
82 group(0),
83#endif
84 model(0) {}
85
86#ifndef QT_NO_UNDOGROUP
88#endif
91
92 void init(KUndo2View* view);
93};
94
96{
97 q = view;
98 model = new KUndo2Model(q);
99 q->setModel(model);
100 q->setSelectionModel(model->selectionModel());
101}
102
107KUndo2View::KUndo2View(QWidget *parent) : QListView(parent), d(new KUndo2ViewPrivate)
108{
109 d->init(this);
110}
111
116KUndo2View::KUndo2View(KUndo2QStack *stack, QWidget *parent) : QListView(parent), d(new KUndo2ViewPrivate)
117{
118 d->init(this);
120}
121
122#ifndef QT_NO_UNDOGROUP
123
130KUndo2View::KUndo2View(KUndo2Group *group, QWidget *parent) : QListView(parent), d(new KUndo2ViewPrivate)
131{
132 d->init(this);
134}
135
136#endif // QT_NO_UNDOGROUP
137
143{
144 delete d;
145}
146
155{
156
157 return d->model->stack();
158}
159
170{
171
172#ifndef QT_NO_UNDOGROUP
173 setGroup(0);
174#endif
176}
177
178#ifndef QT_NO_UNDOGROUP
179
190{
191
192
193 if (d->group == group)
194 return;
195
196 if (d->group != 0) {
197 disconnect(d->group, SIGNAL(activeStackChanged(KUndo2QStack*)),
198 d->model, SLOT(setStack(KUndo2QStack*)));
199 }
200
201 d->group = group;
202
203 if (d->group != 0) {
204 connect(d->group, SIGNAL(activeStackChanged(KUndo2QStack*)),
205 d->model, SLOT(setStack(KUndo2QStack*)));
206 d->model->setStack((KUndo2QStack *)d->group->activeStack());
207 } else {
208 d->model->setStack(0);
209 }
210}
211
221{
222
223 return d->group;
224}
225
226#endif // QT_NO_UNDOGROUP
227
237void KUndo2View::setEmptyLabel(const QString &label)
238{
239
240 d->model->setEmptyLabel(label);
241}
242
244{
245
246 return d->model->emptyLabel();
247}
248
259void KUndo2View::setCleanIcon(const QIcon &icon)
260{
261
262 d->model->setCleanIcon(icon);
263
264}
265
267{
268
269 return d->model->cleanIcon();
270}
271
272#endif // QT_NO_UNDOVIEW
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
The KUndo2Group class is a group of KUndo2QStack objects.
Definition kundo2group.h:57
QString emptyLabel() const
void setEmptyLabel(const QString &label)
void setCleanIcon(const QIcon &icon)
QIcon cleanIcon() const
void setStack(KUndo2QStack *stack)
QItemSelectionModel * selectionModel() const
KUndo2QStack * stack() const
The KUndo2QStack class is a stack of KUndo2Command objects.
QPointer< KUndo2Group > group
KUndo2Model * model
void init(KUndo2View *view)
KUndo2View * q
The KUndo2View class displays the contents of a KUndo2QStack.
Definition kundo2view.h:62
KUndo2ViewPrivate *const d
Definition kundo2view.h:93
void setStack(KUndo2QStack *stack)
~KUndo2View() override
KUndo2Group * group() const
KUndo2QStack * stack() const
KUndo2View(QWidget *parent=0)
void setCleanIcon(const QIcon &icon)
void setEmptyLabel(const QString &label)
void setGroup(KUndo2Group *group)
QString emptyLabel
the label used for the empty state.
Definition kundo2view.h:64
QIcon cleanIcon
the icon used to represent the clean state.
Definition kundo2view.h:65