Also small code cleanup Signed-off-by: Marco Costalba <mcostalba@xxxxxxxxx> --- Still unable to push to public repo :( src/listview.cpp | 239 ++++++++++++++++++++++++++---------------------------- src/listview.h | 4 +- 2 files changed, 115 insertions(+), 128 deletions(-) diff --git a/src/listview.cpp b/src/listview.cpp index 1e33ac0..84a2b4c 100644 --- a/src/listview.cpp +++ b/src/listview.cpp @@ -6,13 +6,9 @@ Copyright: See COPYING file that comes with this distribution */ -#include <qlistview.h> #include <qpainter.h> -#include <qbitmap.h> #include <qapplication.h> -#include <qstatusbar.h> #include <qheader.h> -#include <qpopupmenu.h> #include <qdragobject.h> #include "common.h" #include "domain.h" @@ -406,145 +402,138 @@ void ListViewItem::setDiffTarget(bool b) /* Draw graph part for a lane */ void ListViewItem::paintGraphLane(QPainter* p, int type, int x1, int x2, - const QColor& col, const QBrush& back) { + const QColor& col, const QBrush& back) { - int h = height(); - int r = (x2-x1)/3; + int h = height() / 2; + int m = (x1 + x2) / 2; + int r = (x2 - x1) / 3; + int d = 2 * r; -#define P_CENTER (x1+x2)/2, h/2 -#define P_0 x2, h/2 -#define P_90 (x1+x2)/2, 0 -#define P_180 x1, h/2 -#define P_270 (x1+x2)/2, h -#define R_CENTER (x1+x2)/2-r, h/2-r, 2*r, 2*r + #define P_CENTER m , h + #define P_0 x2, h + #define P_90 m , 0 + #define P_180 x1, h + #define P_270 m , 2 * h + #define R_CENTER m - r, h - r, d, d - p->setPen(QPen(col, 2)); + p->setPen(QPen(col, 2)); // vertical line switch (type) { - case ACTIVE: - case NOT_ACTIVE: - case MERGE_FORK: - case MERGE_FORK_R: - case MERGE_FORK_L: - case JOIN: - case JOIN_R: - case JOIN_L: - p->drawLine(P_90, P_270); - break; - case HEAD: - case HEAD_R: - case HEAD_L: - case BRANCH: - p->drawLine(P_CENTER, P_270); - break; - case TAIL: - case TAIL_R: - case TAIL_L: - case INITIAL: - case BOUNDARY: - case BOUNDARY_C: - case BOUNDARY_R: - case BOUNDARY_L: - p->drawLine(P_90, P_CENTER); - break; - default: - break; + case ACTIVE: + case NOT_ACTIVE: + case MERGE_FORK: + case MERGE_FORK_R: + case MERGE_FORK_L: + case JOIN: + case JOIN_R: + case JOIN_L: + p->drawLine(P_90, P_270); + break; + case HEAD: + case HEAD_R: + case HEAD_L: + case BRANCH: + p->drawLine(P_CENTER, P_270); + break; + case TAIL: + case TAIL_R: + case TAIL_L: + case INITIAL: + case BOUNDARY: + case BOUNDARY_C: + case BOUNDARY_R: + case BOUNDARY_L: + p->drawLine(P_90, P_CENTER); + break; + default: + break; } // horizontal line switch (type) { - case MERGE_FORK: - case JOIN: - case HEAD: - case TAIL: - case CROSS: - case CROSS_EMPTY: - case BOUNDARY_C: - p->drawLine(P_180, P_0); - break; - case MERGE_FORK_R: - case JOIN_R: - case HEAD_R: - case TAIL_R: - case BOUNDARY_R: - p->drawLine(P_180, P_CENTER); - break; - case MERGE_FORK_L: - case JOIN_L: - case HEAD_L: - case TAIL_L: - case BOUNDARY_L: - p->drawLine(P_CENTER, P_0); - break; - default: - break; + case MERGE_FORK: + case JOIN: + case HEAD: + case TAIL: + case CROSS: + case CROSS_EMPTY: + case BOUNDARY_C: + p->drawLine(P_180, P_0); + break; + case MERGE_FORK_R: + case JOIN_R: + case HEAD_R: + case TAIL_R: + case BOUNDARY_R: + p->drawLine(P_180, P_CENTER); + break; + case MERGE_FORK_L: + case JOIN_L: + case HEAD_L: + case TAIL_L: + case BOUNDARY_L: + p->drawLine(P_CENTER, P_0); + break; + default: + break; } // center symbol, e.g. rect or ellipse switch (type) { - case ACTIVE: - case INITIAL: - case BRANCH: - p->setPen(Qt::NoPen); - p->setBrush(col); - p->drawEllipse(R_CENTER); - break; - case MERGE_FORK: - case MERGE_FORK_R: - case MERGE_FORK_L: - p->setPen(Qt::NoPen); - p->setBrush(col); - p->drawRect(R_CENTER); - break; - - case UNAPPLIED: - // Red minus sign - p->setPen(Qt::NoPen); - p->setBrush(red); - p->drawRect( (x1+x2)/2-r, h/2 - 1, 2*r, 2); - break; - - case APPLIED: - // Green plus sign - p->setPen(Qt::NoPen); - p->setBrush(DARK_GREEN); - p->drawRect( (x1+x2)/2-r, h/2 - 1, 2*r, 2); - p->drawRect( (x1+x2)/2-1, h/2-r, 2, 2*r); - break; - - case BOUNDARY: - p->setBrush(back); - p->drawEllipse(R_CENTER); - break; - - case BOUNDARY_C: - case BOUNDARY_R: - case BOUNDARY_L: - p->setBrush(back); - p->drawRect(R_CENTER); - break; - - default: - break; + case ACTIVE: + case INITIAL: + case BRANCH: + p->setPen(Qt::NoPen); + p->setBrush(col); + p->drawEllipse(R_CENTER); + break; + case MERGE_FORK: + case MERGE_FORK_R: + case MERGE_FORK_L: + p->setPen(Qt::NoPen); + p->setBrush(col); + p->drawRect(R_CENTER); + break; + case UNAPPLIED: + // Red minus sign + p->setPen(Qt::NoPen); + p->setBrush(red); + p->drawRect(m - r, h - 1, d, 2); + break; + case APPLIED: + // Green plus sign + p->setPen(Qt::NoPen); + p->setBrush(DARK_GREEN); + p->drawRect(m - r, h - 1, d, 2); + p->drawRect(m - 1, h - r, 2, d); + break; + case BOUNDARY: + p->setBrush(back); + p->drawEllipse(R_CENTER); + break; + case BOUNDARY_C: + case BOUNDARY_R: + case BOUNDARY_L: + p->setBrush(back); + p->drawRect(R_CENTER); + break; + default: + break; } - -#undef P_CENTER -#undef P_0 -#undef P_90 -#undef P_180 -#undef P_270 -#undef R_CENTER - + #undef P_CENTER + #undef P_0 + #undef P_90 + #undef P_180 + #undef P_270 + #undef R_CENTER } -void ListViewItem::paintGraph(const Rev& c, QPainter* p, - const QColorGroup& cg, int width) { - - static QColor colors[COLORS_NUM] = { Qt::black, Qt::red, DARK_GREEN, - Qt::blue, Qt::darkGray, BROWN, - Qt::magenta, ORANGE }; +void ListViewItem::paintGraph(const Rev& c, QPainter* p, const QColorGroup& cg, int width) { + static const QColor colors[COLORS_NUM] = { Qt::black, Qt::red, DARK_GREEN, + Qt::blue, Qt::darkGray, BROWN, + Qt::magenta, ORANGE }; QListView* lv = listView(); if (!lv) return; diff --git a/src/listview.h b/src/listview.h index b1f1011..28d9f60 100644 --- a/src/listview.h +++ b/src/listview.h @@ -8,7 +8,6 @@ #include <qobject.h> #include <qlistview.h> -#include <qptrvector.h> #include "common.h" class QFont; @@ -20,7 +19,7 @@ class FileHistory; class ListViewItem: public QListViewItem { public: ListViewItem(QListView* p, ListViewItem* a, Git* g, SCRef sha, - const int& w, bool e, unsigned long t, FileHistory* f); + const int& w, bool e, unsigned long t, FileHistory* f); SCRef sha() const { return sha_; } int getLaneType(uint pos) const; @@ -102,4 +101,3 @@ private: }; #endif - -- 1.4.3.3.gaf70 - To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html