1 /*************************************************************************** 2 * Copyright (C) 2007 by Rajko Albrecht ral@alwins-world.de * 3 * http://kdesvn.alwins-world.de/ * 4 * * 5 * This program is free software; you can redistribute it and/or modify * 6 * it under the terms of the GNU General Public License as published by * 7 * the Free Software Foundation; either version 2 of the License, or * 8 * (at your option) any later version. * 9 * * 10 * This program is distributed in the hope that it will be useful, * 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 13 * GNU General Public License for more details. * 14 * * 15 * You should have received a copy of the GNU General Public License * 16 * along with this program; if not, write to the * 17 * Free Software Foundation, Inc., * 18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * 19 ***************************************************************************/ 20 21 #ifndef LOG_ITEM_MODEL_H 22 #define LOG_ITEM_MODEL_H 23 24 #include <QAbstractListModel> 25 #include <QSortFilterProxyModel> 26 27 #include "svnqt/svnqttypes.h" 28 29 class SvnLogModelNode; 30 class QTreeWidget; 31 32 typedef QSharedPointer<SvnLogModelNode> SvnLogModelNodePtr; 33 34 class SvnLogModel: public QAbstractListModel 35 { 36 Q_OBJECT 37 public: 38 SvnLogModel(const svn::LogEntriesMapPtr &_log, const QString &_name, QObject *parent); 39 void setLogData(const svn::LogEntriesMapPtr &log, const QString &name); 40 41 qlonglong toRevision(const QModelIndex &)const; 42 const QString &fullMessage(const QModelIndex &index)const; 43 void fillChangedPaths(const QModelIndex &index, QTreeWidget *target); 44 const QString &realName(const QModelIndex &index); 45 46 enum Columns { 47 Author = 0, 48 Revision, 49 Date, 50 Message, 51 Count 52 }; 53 54 QVariant data(const QModelIndex &index, int role) const Q_DECL_OVERRIDE; 55 int rowCount(const QModelIndex &parent) const Q_DECL_OVERRIDE; 56 QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE; 57 int columnCount(const QModelIndex &) const Q_DECL_OVERRIDE; 58 59 SvnLogModelNodePtr indexNode(const QModelIndex &)const; 60 int leftRow() const; 61 int rightRow() const; 62 void setLeftRow(int); 63 void setRightRow(int); 64 65 qlonglong min() const; 66 qlonglong max() const; 67 68 private: 69 QVector<SvnLogModelNodePtr> m_data; 70 QString m_emptyString; 71 qlonglong m_min, m_max; 72 QString m_name; 73 int m_left, m_right; 74 75 friend class SvnLogSortModel; 76 }; 77 78 class SvnLogSortModel final : public QSortFilterProxyModel 79 { 80 Q_OBJECT 81 public: 82 using QSortFilterProxyModel::QSortFilterProxyModel; 83 84 void setSourceModel(QAbstractItemModel *sourceModel) override final; 85 protected: 86 bool lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const override final; 87 private: 88 SvnLogModel *m_sourceModel = nullptr; 89 }; 90 91 #endif 92