Warning, file /sdk/cervisia/logtree.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* 0002 * Copyright (C) 1999-2002 Bernd Gehrmann 0003 * bernd@mail.berlios.de 0004 * Copyright (c) 2004 Christian Loose <christian.loose@hamburg.de> 0005 * 0006 * This program is free software; you can redistribute it and/or modify 0007 * it under the terms of the GNU General Public License as published by 0008 * the Free Software Foundation; either version 2 of the License, or 0009 * (at your option) any later version. 0010 * 0011 * This program is distributed in the hope that it will be useful, 0012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0014 * GNU General Public License for more details. 0015 * 0016 * You should have received a copy of the GNU General Public License 0017 * along with this program; if not, write to the Free Software 0018 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 0019 */ 0020 0021 #ifndef LOGTREE_H 0022 #define LOGTREE_H 0023 0024 #include <qlist.h> 0025 0026 #include <QAbstractTableModel> 0027 #include <QStyledItemDelegate> 0028 #include <QTableView> 0029 0030 class LogTreeItem; 0031 class LogTreeConnection; 0032 0033 namespace Cervisia 0034 { 0035 struct LogInfo; 0036 } 0037 0038 using LogTreeItemList = QList<LogTreeItem *>; 0039 using LogTreeConnectionList = QList<LogTreeConnection *>; 0040 0041 enum SelectedRevision { NoRevision, RevisionA, RevisionB }; 0042 0043 class LogTreeView : public QTableView 0044 { 0045 Q_OBJECT 0046 0047 public: 0048 explicit LogTreeView(QWidget *parent = nullptr, const char *name = 0); 0049 0050 ~LogTreeView() override; 0051 0052 void addRevision(const Cervisia::LogInfo &logInfo); 0053 void setSelectedPair(QString selectionA, QString selectionB); 0054 void collectConnections(); 0055 void recomputeCellSizes(); 0056 void paintCell(QPainter *p, int row, int col); 0057 0058 QSize sizeHint() const override; 0059 0060 virtual QString text(int row, int col) const; 0061 0062 signals: 0063 void revisionClicked(QString rev, bool rmb); 0064 0065 private slots: 0066 void mousePressed(const QModelIndex &index); 0067 void slotQueryToolTip(const QPoint &, QRect &, QString &); 0068 0069 private: 0070 QSize computeSize(const Cervisia::LogInfo &, int * = 0, int * = 0) const; 0071 void paintRevisionCell(QPainter *p, int row, int col, const Cervisia::LogInfo &logInfo, bool followed, bool branched, SelectedRevision selected); 0072 void paintConnector(QPainter *p, int row, int col, bool followed, bool branched); 0073 0074 LogTreeItemList items; 0075 LogTreeConnectionList connections; 0076 int rowCount, columnCount; 0077 0078 static const int BORDER; 0079 static const int INSPACE; 0080 0081 friend class LogTreeModel; 0082 0083 class LogTreeModel *model; 0084 }; 0085 0086 class LogTreeModel : public QAbstractTableModel 0087 { 0088 public: 0089 explicit LogTreeModel(LogTreeView *t) 0090 : logView(t) 0091 { 0092 } 0093 0094 int rowCount(const QModelIndex &parent = QModelIndex()) const override 0095 { 0096 Q_UNUSED(parent) 0097 return logView->rowCount; 0098 } 0099 0100 int columnCount(const QModelIndex &parent = QModelIndex()) const override 0101 { 0102 Q_UNUSED(parent) 0103 return logView->columnCount; 0104 } 0105 0106 QVariant data(const QModelIndex &, int) const override 0107 { 0108 return {}; 0109 } 0110 0111 private: 0112 LogTreeView *logView; 0113 0114 friend class LogTreeView; 0115 }; 0116 0117 class LogTreeDelegate : public QStyledItemDelegate 0118 { 0119 Q_OBJECT 0120 0121 public: 0122 explicit LogTreeDelegate(LogTreeView *t) 0123 : logView(t) 0124 { 0125 } 0126 void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override; 0127 0128 private: 0129 LogTreeView *logView; 0130 }; 0131 0132 #endif 0133 0134 // vim: set sw=4 0135 // Local Variables: 0136 // c-basic-offset: 4 0137 // End: