Krita Source Code Documentation
Loading...
Searching...
No Matches
KisUndoModel.h
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** $QT_END_LICENSE$
37**
38****************************************************************************/
39#ifndef KIS_UNDO_MODEL_H
40#define KIS_UNDO_MODEL_H
41#include <QAbstractItemModel>
42
43#include <kundo2qstack.h>
44#include <QItemSelectionModel>
45#include <QIcon>
46#include <QPointer>
47
48#include <kundo2command.h>
49
50#include "kis_types.h"
51#include "kis_canvas2.h"
52#include "KisViewManager.h"
53#include "kis_image.h"
54#include "kis_paint_device.h"
55
56class KisUndoModel : public QAbstractItemModel
57{
58 Q_OBJECT
59public:
60 KisUndoModel(QObject *parent = 0);
61
62 KUndo2QStack *stack() const;
63
64 QModelIndex index(int row, int column,
65 const QModelIndex &parent = QModelIndex()) const override;
66 QModelIndex parent(const QModelIndex &child) const override;
67 int rowCount(const QModelIndex &parent = QModelIndex()) const override;
68 int columnCount(const QModelIndex &parent = QModelIndex()) const override;
69 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
70
71 QModelIndex selectedIndex() const;
72 QItemSelectionModel *selectionModel() const;
73
74 QString emptyLabel() const;
75 void setEmptyLabel(const QString &label);
76
77 void setCleanIcon(const QIcon &icon);
78 QIcon cleanIcon() const;
79
80 void setCanvas(KisCanvas2* canvas);
81 bool checkMergedCommand(int index);
82
83 // It's a bit weird to have "setDevicePixelRatio"
84 // in a model class, but it's needed for
85 // QImages inside, because there is no
86 // ItemDelegate for the items,
87 // so it's better to initialize QImages already
88 // devicePixelRatio-corrected.
89 void setDevicePixelRatio(qreal devicePixelRatio);
90
91public Q_SLOTS:
93 void addImage(int idx);
94
95private Q_SLOTS:
96 void stackChanged();
97 void stackDestroyed(QObject *obj);
98 void setStackCurrentIndex(const QModelIndex &index);
99
100private:
103 QItemSelectionModel *m_sel_model {0};
107 QMap<const KUndo2Command*, QImage> m_imageMap;
109};
110#endif
The KUndo2QStack class is a stack of KUndo2Command objects.
bool m_blockOutgoingHistoryChange
KUndo2QStack * stack() const
QIcon cleanIcon() const
QPointer< KisCanvas2 > m_canvas
qreal m_devicePixelRatioF
void setDevicePixelRatio(qreal devicePixelRatio)
void setStackCurrentIndex(const QModelIndex &index)
QString m_empty_label
QModelIndex parent(const QModelIndex &child) const override
QMap< const KUndo2Command *, QImage > m_imageMap
KisUndoModel(QObject *parent=0)
KUndo2QStack * m_stack
void addImage(int idx)
QItemSelectionModel * selectionModel() const
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
void stackDestroyed(QObject *obj)
void setCleanIcon(const QIcon &icon)
void setEmptyLabel(const QString &label)
QString emptyLabel() const
int columnCount(const QModelIndex &parent=QModelIndex()) const override
void setCanvas(KisCanvas2 *canvas)
int rowCount(const QModelIndex &parent=QModelIndex()) const override
bool checkMergedCommand(int index)
QModelIndex selectedIndex() const
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
void setStack(KUndo2QStack *stack)
QItemSelectionModel * m_sel_model