File indexing completed on 2024-05-19 05:45:02
0001 /*************************************************************************** 0002 * Copyright (C) 2005-2009 by Rajko Albrecht * 0003 * ral@alwins-world.de * 0004 * * 0005 * This program is free software; you can redistribute it and/or modify * 0006 * it under the terms of the GNU General Public License as published by * 0007 * the Free Software Foundation; either version 2 of the License, or * 0008 * (at your option) any later version. * 0009 * * 0010 * This program is distributed in the hope that it will be useful, * 0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0013 * GNU General Public License for more details. * 0014 * * 0015 * You should have received a copy of the GNU General Public License * 0016 * along with this program; if not, write to the * 0017 * Free Software Foundation, Inc., * 0018 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * 0019 ***************************************************************************/ 0020 0021 #ifndef COMMITMODEL_H 0022 #define COMMITMODEL_H 0023 0024 #include "commitmodelfwd.h" 0025 #include "commitmodelhelper.h" 0026 #include "svnqt/svnqttypes.h" 0027 0028 #include <QAbstractItemModel> 0029 #include <QSortFilterProxyModel> 0030 0031 class CommitModel : public QAbstractItemModel 0032 { 0033 Q_OBJECT 0034 protected: 0035 explicit CommitModel(const CommitActionEntries &, const CommitActionEntries &, QObject *parent = nullptr); 0036 void setCommitData(const CommitActionEntries &, const CommitActionEntries &); 0037 0038 public: 0039 explicit CommitModel(const svn::CommitItemList &, QObject *parent = nullptr); 0040 void setCommitData(const svn::CommitItemList &); 0041 0042 QModelIndex index(int row, int column = 0, const QModelIndex &parent = QModelIndex()) const override; 0043 QModelIndex parent(const QModelIndex &) const override; 0044 QVariant data(const QModelIndex &index, int role) const override; 0045 0046 int rowCount(const QModelIndex &) const override; 0047 int columnCount(const QModelIndex &) const override; 0048 0049 QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override; 0050 0051 virtual int ActionColumn() const; 0052 virtual int ItemColumn() const; 0053 0054 CommitModelNodePtr node(const QModelIndex &); 0055 CommitActionEntries checkedEntries() const; 0056 void markItems(bool mark, CommitActionEntry::ACTION_TYPE _type); 0057 void removeEntries(const QStringList &_items); 0058 0059 const CommitModelNodePtr dataForRow(int row) const; 0060 0061 protected: 0062 CommitModelNodeList m_List; 0063 }; 0064 0065 class CommitModelCheckitem : public CommitModel 0066 { 0067 Q_OBJECT 0068 public: 0069 CommitModelCheckitem(const CommitActionEntries &, const CommitActionEntries &, QObject *parent = nullptr); 0070 0071 Qt::ItemFlags flags(const QModelIndex &index) const override; 0072 QVariant data(const QModelIndex &index, int role) const override; 0073 0074 bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override; 0075 int ActionColumn() const override; 0076 int ItemColumn() const override; 0077 }; 0078 0079 class CommitFilterModel final : public QSortFilterProxyModel 0080 { 0081 Q_OBJECT 0082 public: 0083 using QSortFilterProxyModel::QSortFilterProxyModel; 0084 0085 void setSourceModel(QAbstractItemModel *sourceModel) override; 0086 void hideItems(bool bHide, CommitActionEntry::ACTION_TYPE aType); 0087 0088 protected: 0089 bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override; 0090 0091 private: 0092 CommitModel *m_sourceModel = nullptr; 0093 CommitActionEntry::ActionTypes m_visibleTypes = CommitActionEntry::ALL; 0094 }; 0095 0096 #endif