listview.h

Go to the documentation of this file.
00001 /*
00002         Author: Marco Costalba (C) 2005-2006
00003 
00004         Copyright: See COPYING file that comes with this distribution
00005 */
00006 #ifndef LISTVIEW_H
00007 #define LISTVIEW_H
00008 
00009 #include <qobject.h>
00010 #include <qlistview.h>
00011 #include "common.h"
00012 
00013 class Git;
00014 class StateInfo;
00015 class Domain;
00016 class FileHistory;
00017 
00018 class ListViewItem: public QListViewItem {
00019 public:
00020         ListViewItem(QListView* p, ListViewItem* a, Git* g, SCRef sha,
00021                      bool e, unsigned long t, FileHistory* f);
00022 
00023         SCRef sha() const { return _sha; }
00024         int getLaneType(uint pos) const;
00025         void setDiffTarget(bool b);
00026         virtual void paintCell(QPainter* p, const QColorGroup& cg, int c, int w, int a);
00027         void setEven(bool b) { isEvenLine = b; }
00028         void setHighlighted(bool b) { isHighlighted = b; }
00029         bool highlighted() const { return isHighlighted; }
00030         int laneWidth() const { return 3 * myListView()->fontMetrics().height() / 4; }
00031 
00032 private:
00033         void setupData(const Rev& c);
00034         void paintGraphLane(QPainter* p, int t, int x1, int x2, const QColor& c, const QBrush& b);
00035         void paintGraph(const Rev& c, QPainter *p, const QColorGroup& cg, int width);
00036         void paintTagMarks(int col);
00037         void addBranchPixmap(QPixmap** pp);
00038         void addRefPixmap(QPixmap** pp, SCList refs, const QColor& color);
00039         void addTextPixmap(QPixmap** pp, SCRef text, const QColor& color, bool bold);
00040         const QString timeDiff(unsigned long secs) const;
00041         bool changedFiles(SCRef c);
00042         QListView* myListView() const { return listView_; } // QListViewItem::listView() traverses the
00043                                                             // items to the root to find the listview
00044         QListView* listView_;
00045         Git* git;
00046         FileHistory* fh;
00047         const QString _sha;
00048         unsigned long secs;
00049         bool populated, isEvenLine, isHighlighted, isDiffTarget;
00050 };
00051 
00052 class ListView: public QObject {
00053 Q_OBJECT
00054 public:
00055         ListView(Domain* d, Git* g, QListView* l, FileHistory* f, const QFont& fnt);
00056         ~ListView();
00057         void clear();
00058         const QString getSha(int id);
00059         void updateIdValues();
00060         void getSelectedItems(QStringList& selectedItems);
00061         bool update();
00062         void addNewRevs(const QValueVector<QString>& shaVec);
00063 
00064         bool filterNextContextMenuRequest;
00065 
00066 signals:
00067         void lanesContextMenuRequested(const QStringList&, const QStringList&);
00068         void droppedRevisions(const QStringList&);
00069         void contextMenu(const QString&, int);
00070 
00071 public slots:
00072         void on_newRevsAdded(const FileHistory* fh, const QValueVector<QString>& shaVec);
00073         void on_repaintListViews(const QFont& f);
00074 
00075 protected:
00076         virtual bool eventFilter(QObject* obj, QEvent* ev);
00077 
00078 private slots:
00079         void on_contextMenuRequested(QListViewItem*);
00080         void on_currentChanged(QListViewItem* item);
00081         void on_mouseButtonPressed(int, QListViewItem*, const QPoint&, int);
00082         void on_clicked(QListViewItem*);
00083         void on_onItem(QListViewItem*);
00084 
00085 private:
00086         void setupListView(const QFont& fnt);
00087         bool filterRightButtonPressed(QMouseEvent* e);
00088         bool filterDropEvent(QDropEvent* e);
00089         bool getLaneParentsChilds(ListViewItem* item, int x, SList p, SList c);
00090         const QString getRefs(QListViewItem* item);
00091         void setHighlight(SCRef diffToSha);
00092         ListViewItem* findItemSha(SCRef sha) const;
00093 
00094         Domain* d;
00095         Git* git;
00096         QListView* lv;
00097         StateInfo* st;
00098         FileHistory* fh;
00099         ListViewItem* lastItem;   // QListView::lastItem() is slow
00100         ListViewItem* diffTarget; // cannot use QGuardedPtr, not QObject inherited
00101         unsigned long secs;
00102         bool currentChangedEmitted;
00103 };
00104 
00105 #endif

Generated on Fri Dec 7 21:57:37 2007 for QGit by  doxygen 1.5.3