File indexing completed on 2024-05-12 15:56:14
0001 /* This file is part of the KDE project 0002 * SPDX-FileCopyrightText: 2010 Matus Talcik <matus.talcik@gmail.com> 0003 * 0004 * SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 /**************************************************************************** 0007 ** 0008 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). 0009 ** All rights reserved. 0010 ** Contact: Nokia Corporation (qt-info@nokia.com) 0011 ** 0012 ** This file is part of the QtGui module of the Qt Toolkit. 0013 ** 0014 ** $QT_BEGIN_LICENSE:LGPL$ 0015 ** No Commercial Usage 0016 ** This file contains pre-release code and may not be distributed. 0017 ** You may use this file in accordance with the terms and conditions 0018 ** contained in the Technology Preview License Agreement accompanying 0019 ** this package. 0020 ** 0021 ** GNU Lesser General Public License Usage 0022 ** Alternatively, this file may be used under the terms of the GNU Lesser 0023 ** General Public License version 2.1 as published by the Free Software 0024 ** Foundation and appearing in the file LICENSE.LGPL included in the 0025 ** packaging of this file. Please review the following information to 0026 ** ensure the GNU Lesser General Public License version 2.1 requirements 0027 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 0028 ** 0029 ** In addition, as a special exception, Nokia gives you certain additional 0030 ** rights. These rights are described in the Nokia Qt LGPL Exception 0031 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 0032 ** 0033 ** If you have questions regarding the use of this file, please contact 0034 ** Nokia at qt-info@nokia.com. 0035 ** 0036 ** 0037 ** 0038 ** 0039 ** 0040 ** 0041 ** 0042 ** 0043 ** $QT_END_LICENSE$ 0044 ** 0045 ****************************************************************************/ 0046 #ifndef K_UNDO_2_MODEL 0047 #define K_UNDO_2_MODEL 0048 #include <QAbstractItemModel> 0049 0050 #include "kundo2stack.h" 0051 #include <QItemSelectionModel> 0052 #include <QIcon> 0053 0054 class KUndo2Model : public QAbstractItemModel 0055 { 0056 Q_OBJECT 0057 public: 0058 explicit KUndo2Model(QObject *parent = 0); 0059 0060 KUndo2QStack *stack() const; 0061 0062 QModelIndex index(int row, int column, 0063 const QModelIndex &parent = QModelIndex()) const override; 0064 QModelIndex parent(const QModelIndex &child) const override; 0065 int rowCount(const QModelIndex &parent = QModelIndex()) const override; 0066 int columnCount(const QModelIndex &parent = QModelIndex()) const override; 0067 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; 0068 0069 QModelIndex selectedIndex() const; 0070 QItemSelectionModel *selectionModel() const; 0071 0072 QString emptyLabel() const; 0073 void setEmptyLabel(const QString &label); 0074 0075 void setCleanIcon(const QIcon &icon); 0076 QIcon cleanIcon() const; 0077 0078 public Q_SLOTS: 0079 void setStack(KUndo2QStack *stack); 0080 0081 private Q_SLOTS: 0082 void stackChanged(); 0083 void stackDestroyed(QObject *obj); 0084 void setStackCurrentIndex(const QModelIndex &index); 0085 0086 private: 0087 KUndo2QStack *m_stack; 0088 QItemSelectionModel *m_sel_model; 0089 QString m_emty_label; 0090 QIcon m_clean_icon; 0091 }; 0092 #endif