File indexing completed on 2024-05-12 05:44:27
0001 /*************************************************************************** 0002 * Copyright (C) 2007 by Rajko Albrecht ral@alwins-world.de * 0003 * https://kde.org/applications/development/org.kde.kdesvn * 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 LOG_ITEM_MODEL_H 0022 #define LOG_ITEM_MODEL_H 0023 0024 #include <QAbstractListModel> 0025 #include <QSortFilterProxyModel> 0026 0027 #include "svnqt/svnqttypes.h" 0028 0029 class SvnLogModelNode; 0030 class QTreeWidget; 0031 0032 typedef QSharedPointer<SvnLogModelNode> SvnLogModelNodePtr; 0033 0034 class SvnLogModel final : public QAbstractListModel 0035 { 0036 Q_OBJECT 0037 public: 0038 SvnLogModel(const svn::LogEntriesMapPtr &_log, const QString &_name, QObject *parent); 0039 void setLogData(const svn::LogEntriesMapPtr &log, const QString &name); 0040 0041 qlonglong toRevision(const QModelIndex &) const; 0042 const QString &fullMessage(const QModelIndex &index) const; 0043 void fillChangedPaths(const QModelIndex &index, QTreeWidget *target); 0044 const QString &realName(const QModelIndex &index); 0045 0046 enum Columns { Author = 0, Revision, Date, Message, Count }; 0047 0048 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; 0049 int rowCount(const QModelIndex &parent = QModelIndex()) const override; 0050 QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override; 0051 int columnCount(const QModelIndex &idx = QModelIndex()) const override; 0052 0053 SvnLogModelNodePtr indexNode(const QModelIndex &) const; 0054 int leftRow() const; 0055 int rightRow() const; 0056 void setLeftRow(int); 0057 void setRightRow(int); 0058 0059 qlonglong min() const; 0060 qlonglong max() const; 0061 0062 private: 0063 QVector<SvnLogModelNodePtr> m_data; 0064 QString m_emptyString; 0065 qlonglong m_min, m_max; 0066 QString m_name; 0067 int m_left, m_right; 0068 0069 friend class SvnLogSortModel; 0070 }; 0071 0072 class SvnLogSortModel final : public QSortFilterProxyModel 0073 { 0074 Q_OBJECT 0075 public: 0076 using QSortFilterProxyModel::QSortFilterProxyModel; 0077 0078 void setSourceModel(QAbstractItemModel *sourceModel) final; 0079 0080 protected: 0081 bool lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const final; 0082 0083 private: 0084 SvnLogModel *m_sourceModel = nullptr; 0085 }; 0086 0087 #endif