1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
|
/*
Author: Marco Costalba (C) 2005-2007
Copyright: See COPYING file that comes with this distribution
*/
#ifndef LISTVIEW_H
#define LISTVIEW_H
#include <QTreeView>
#include <QItemDelegate>
#include <QSortFilterProxyModel>
#include <QRegExp>
#include "common.h"
class Git;
class StateInfo;
class Domain;
class FileHistory;
class ListViewProxy;
class ListView: public QTreeView {
Q_OBJECT
public:
ListView(QWidget* parent);
~ListView();
void setup(Domain* d, Git* g);
const QString shaFromAnnId(uint id);
void showIdValues();
void scrollToCurrent(ScrollHint hint = EnsureVisible);
void scrollToNextHighlighted(int direction);
void getSelectedItems(QStringList& selectedItems);
bool update();
void addNewRevs(const QVector<QString>& shaVec);
const QString currentText(int col);
int filterRows(bool, bool, SCRef = QString(), int = -1, ShaSet* = NULL);
const QString sha(int row) const;
int row(SCRef sha) const;
signals:
void lanesContextMenuRequested(const QStringList&, const QStringList&);
void revisionsDragged(const QStringList&);
void revisionsDropped(const QStringList&);
void contextMenu(const QString&, int);
void diffTargetChanged(int); // used by new model_view integration
public slots:
void on_changeFont(const QFont& f);
void on_keyUp();
void on_keyDown();
protected:
virtual void mousePressEvent(QMouseEvent* e);
virtual void mouseMoveEvent(QMouseEvent* e);
virtual void mouseReleaseEvent(QMouseEvent* e);
virtual void dragEnterEvent(QDragEnterEvent* e);
virtual void dragMoveEvent(QDragMoveEvent* e);
virtual void dropEvent(QDropEvent* e);
private slots:
void on_customContextMenuRequested(const QPoint&);
virtual void currentChanged(const QModelIndex&, const QModelIndex&);
private:
void setupGeometry();
bool filterRightButtonPressed(QMouseEvent* e);
bool getLaneParentsChilds(SCRef sha, int x, SList p, SList c);
int getLaneType(SCRef sha, int pos) const;
Domain* d;
Git* git;
StateInfo* st;
FileHistory* fh;
ListViewProxy* lp;
unsigned long secs;
bool filterNextContextMenuRequest;
};
class ListViewDelegate : public QItemDelegate {
Q_OBJECT
public:
ListViewDelegate(Git* git, ListViewProxy* lp, QObject* parent);
virtual void paint(QPainter* p, const QStyleOptionViewItem& o, const QModelIndex &i) const;
virtual QSize sizeHint(const QStyleOptionViewItem& o, const QModelIndex &i) const;
int laneWidth() const { return 3 * laneHeight / 4; }
void setLaneHeight(int h) { laneHeight = h; }
signals:
void updateView();
public slots:
void diffTargetChanged(int);
private:
const Rev* revLookup(int row, FileHistory** fhPtr = NULL) const;
void paintLog(QPainter* p, const QStyleOptionViewItem& o, const QModelIndex &i) const;
void paintGraph(QPainter* p, const QStyleOptionViewItem& o, const QModelIndex &i) const;
void paintGraphLane(QPainter* p, int type, int x1, int x2, const QColor& col, const QColor& activeCol, const QBrush& back) const;
QPixmap* getTagMarks(SCRef sha, const QStyleOptionViewItem& opt) const;
void addRefPixmap(QPixmap** pp, SCRef sha, int type, QStyleOptionViewItem opt) const;
void addTextPixmap(QPixmap** pp, SCRef txt, const QStyleOptionViewItem& opt) const;
bool changedFiles(SCRef sha) const;
Git* git;
ListViewProxy* lp;
int laneHeight;
int diffTargetRow;
};
class ListViewProxy : public QSortFilterProxyModel {
Q_OBJECT
public:
ListViewProxy(QObject* parent, Domain* d, Git* g);
int setFilter(bool isOn, bool highlight, SCRef filter, int colNum, ShaSet* s);
bool isHighlighted(int row) const;
protected:
virtual bool filterAcceptsRow(int sourceRow, const QModelIndex& sourceParent) const;
private:
bool isMatch(int row) const;
bool isMatch(SCRef sha) const;
Domain* d;
Git* git;
bool isHighLight;
QRegExp filter;
int colNum;
ShaSet shaSet;
};
#endif
|