{"thread":{"id":"6004","subject":"[PATCH qgit 2/2] Remove old drawing code for graph part pixmaps","startedAt":"2006-10-22T20:44:15Z","lastAt":"2006-10-22T20:44:15Z","messageCount":1,"participants":["Josef Weidendorfer"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"29670","messageId":"200610222244.15156.Josef.Weidendorfer@gmx.de","threadId":"6004","inReplyTo":null,"subject":"[PATCH qgit 2/2] Remove old drawing code for graph part pixmaps","fromName":"Josef Weidendorfer","fromEmail":"josef.weidendorfer@gmx.de","sentAt":"2006-10-22T20:44:15Z","receivedAt":"2006-10-22T20:44:15Z","isPatch":true,"sender":{"key":"josef.weidendorfer@gmx.de","avatar":null},"body":"The laneWidth is now explicitly set in GraphMetrics, and\nshared with the ListViewItem's via reference.\n\nSigned-off-by: Josef Weidendorfer <Josef.Weidendorfer@gmx.de>\n---\n src/listview.cpp |  187 ++----------------------------------------------------\n src/listview.h   |    4 +-\n src/mainimpl.cpp |    3 +-\n src/mainimpl.h   |    6 +--\n 4 files changed, 10 insertions(+), 190 deletions(-)\n\ndiff --git a/src/listview.cpp b/src/listview.cpp\nindex a947564..7251b97 100644\n--- a/src/listview.cpp\n+++ b/src/listview.cpp\n@@ -222,11 +222,10 @@ void ListView::on_newRevsAdded(const Fil\n \tif (lv->childCount() == 0)\n \t\tlastItem = NULL;\n \n-\tconst QPtrVector<QPixmap>& pm = d->m()->gm.pixmaps;\n-\n \tfor (uint i = lv->childCount(); i < shaVec.count(); i++) {\n-\t\tlastItem = new ListViewItem(lv, lastItem, git, shaVec[i], pm,\n-\t\t                            evenLine, secs, fh);\n+\t\tlastItem = new ListViewItem(lv, lastItem, git, shaVec[i],\n+\t\t                            d->m()->gm.laneWidth,\n+\t\t\t\t\t    evenLine, secs, fh);\n \t\tevenLine = !evenLine;\n \t}\n }\n@@ -344,7 +343,7 @@ bool ListView::filterRightButtonPressed(\n \n bool ListView::getLaneParentsChilds(ListViewItem* item, int x, SList p, SList c) {\n \n-\tuint lane = x / d->m()->gm.width();\n+\tuint lane = x / d->m()->gm.laneWidth;\n \tint t = item->getLaneType(lane);\n \tif (t == EMPTY || t == -1)\n \t\treturn false;\n@@ -387,8 +386,8 @@ bool ListView::filterDropEvent(QDropEven\n // ****************************** ListViewItem *****************************\n \n ListViewItem::ListViewItem(QListView* p, ListViewItem* a, Git* g, SCRef s,\n-              const QPtrVector<QPixmap>& pm, bool e, unsigned long t, FileHistory* f) :\n-              QListViewItem(p, a), git(g), fh(f), sha_(s), pms(pm), secs(t), isEvenLine(e) {\n+              const int& w, bool e, unsigned long t, FileHistory* f) :\n+              QListViewItem(p, a), git(g), fh(f), sha_(s), laneWidth(w), secs(t), isEvenLine(e) {\n \n \tpopulated = isDiffTarget = isHighlighted = false;\n }\n@@ -568,7 +567,6 @@ void ListViewItem::paintGraph(const Rev&\n \t\t\tbreak;\n \t\t}\n \n-\tint laneWidth = pms[0]->width();\n \tint x1 = 0, x2;\n \tfor (uint i = 0; i < laneNum && x1 < width; i++, x1 = x2) {\n \t        x2 = x1 + laneWidth;\n@@ -743,176 +741,3 @@ const QString ListViewItem::timeDiff(uns\n }\n \n \n-// ***************** GraphMetrics related methods *********************\n-\n-#define P_OR  pw/2, ph/2\n-#define P_0   pw,   ph/2\n-#define P_90  pw/2, 0\n-#define P_180 0,    ph/2\n-#define P_270 pw/2, ph\n-\n-void MainImpl::GraphMetrics::setupPixmaps(int ph) {\n-\n-\t// set dimensions\n-\tint pw = 3 * ph / 4;\n-\tint r = ph / 4; // radius of dots\n-\n-\t// create cross line mask\n-\tQPixmap cm(pw, ph);\n-\tcm.fill();\n-\tQPainter p;\n-\tp.begin(&cm);\n-\tp.setPen(QPen(Qt::black, 2));\n-\tp.drawLine(P_180, P_0);\n-\tp.end();\n-\tQBitmap crossMask = cm.createHeuristicMask();\n-\n-\tQBrush myWhiteBrush(ODD_LINE_COL, Qt::SolidPattern);\n-\tQColor colors[COLORS_NUM] = {Qt::black, Qt::red, DARK_GREEN, Qt::blue,\n-\t                             Qt::darkGray, BROWN, Qt::magenta, ORANGE};\n-\tpixmaps.clear();\n-\tpixmaps.resize(LANE_TYPES_NUM * COLORS_NUM);\n-\n-\tfor (int i = 0; i < LANE_TYPES_NUM * COLORS_NUM; i++) {\n-\n-\t\tint type = (i / COLORS_NUM) + 1;\n-\t\tQColor myColorNum(colors[i % COLORS_NUM]);\n-\t\tQBrush myBrush(myColorNum, Qt::SolidPattern);\n-\n-\t\tQPixmap* pm = new QPixmap(pw, ph);\n-\t\tpm->fill(ODD_LINE_COL);\n-\t\tp.begin(pm);\n-\t\tp.setPen(QPen(myColorNum, 2));\n-\n-\t\tswitch (type) {\n-\t\tcase ACTIVE:\n-\t\t\tp.drawLine(P_90, P_270);\n-\t\t\tp.save();\n-\t\t\tp.setPen(Qt::NoPen);\n-\t\t\tp.setBrush(myBrush);\n-\t\t\tp.drawEllipse(pw/2 - r, ph/2 - r, 2*r, 2*r);\n-\t\t\tp.restore();\n-\t\t\tbreak;\n-\t\tcase NOT_ACTIVE:\n-\t\t\tp.drawLine(P_90, P_270);\n-\t\t\tbreak;\n-\t\tcase MERGE_FORK:\n-\t\t\tp.drawLine(P_90, P_270);\n-\t\t\tp.drawLine(P_180, P_0);\n-\t\t\tp.fillRect(pw/2 - r, ph/2 - r, 2*r, 2*r, myBrush);\n-\t\t\tbreak;\n-\t\tcase MERGE_FORK_R:\n-\t\t\tp.drawLine(P_90, P_270);\n-\t\t\tp.drawLine(P_180, P_OR);\n-\t\t\tp.fillRect(pw/2 - r, ph/2 - r, 2*r, 2*r, myBrush);\n-\t\t\tbreak;\n-\t\tcase MERGE_FORK_L:\n-\t\t\tp.drawLine(P_90, P_270);\n-\t\t\tp.drawLine(P_OR, P_0);\n-\t\t\tp.fillRect(pw/2 - r, ph/2 - r, 2*r, 2*r, myBrush);\n-\t\t\tbreak;\n-\t\tcase JOIN:\n-\t\t\tp.drawLine(P_90, P_270);\n-\t\t\tp.drawLine(P_180, P_0);\n-\t\t\tbreak;\n-\t\tcase JOIN_R:\n-\t\t\tp.drawLine(P_90, P_270);\n-\t\t\tp.drawLine(P_180, P_OR);\n-\t\t\tbreak;\n-\t\tcase JOIN_L:\n-\t\t\tp.drawLine(P_90, P_270);\n-\t\t\tp.drawLine(P_OR, P_0);\n-\t\t\tbreak;\n-\t\tcase HEAD:\n-\t\t\tp.drawLine(P_OR, P_270);\n-\t\t\tp.drawLine(P_180, P_0);\n-\t\t\tbreak;\n-\t\tcase HEAD_R:\n-\t\t\tp.drawLine(P_OR, P_270);\n-\t\t\tp.drawLine(P_180, P_OR);\n-\t\t\tbreak;\n-\t\tcase HEAD_L:\n-\t\t\tp.drawLine(P_OR, P_270);\n-\t\t\tp.drawLine(P_OR, P_0);\n-\t\t\tbreak;\n-\t\tcase TAIL:\n-\t\t\tp.drawLine(P_90, P_OR);\n-\t\t\tp.drawLine(P_180, P_0);\n-\t\t\tbreak;\n-\t\tcase TAIL_R:\n-\t\t\tp.drawLine(P_90, P_OR);\n-\t\t\tp.drawLine(P_180, P_OR);\n-\t\t\tbreak;\n-\t\tcase TAIL_L:\n-\t\t\tp.drawLine(P_90, P_OR);\n-\t\t\tp.drawLine(P_OR, P_0);\n-\t\t\tbreak;\n-\t\tcase CROSS:\n-\t\t\tpm->setMask(crossMask);\n-\t\t\tpm->fill(p.pen().color());\n-\t\t\tbreak;\n-\t\tcase CROSS_EMPTY:\n-\t\t\tp.drawLine(P_180, P_0);\n-\t\t\tbreak;\n-\t\tcase INITIAL:\n-\t\t\tp.drawLine(P_90, P_OR);\n-\t\t\tp.save();\n-\t\t\tp.setPen(Qt::NoPen);\n-\t\t\tp.setBrush(QBrush(myColorNum, Qt::SolidPattern));\n-\t\t\tp.drawEllipse(pw/2 - r, ph/2 - r, 2*r, 2*r);\n-\t\t\tp.restore();\n-\t\t\tbreak;\n-\t\tcase BRANCH:\n-\t\t\tp.drawLine(P_OR, P_270);\n-\t\t\tp.save();\n-\t\t\tp.setPen(Qt::NoPen);\n-\t\t\tp.setBrush(QBrush(myColorNum, Qt::SolidPattern));\n-\t\t\tp.drawEllipse(pw/2 - r, ph/2 - r, 2*r, 2*r);\n-\t\t\tp.restore();\n-\t\t\tbreak;\n-\t\tcase UNAPPLIED:\n-\t\t\tp.save();\n-\t\t\tp.setPen(Qt::NoPen);\n-\t\t\tp.setBrush(QBrush(Qt::red, Qt::SolidPattern));\n-\t\t\tp.drawRect(pw/2 - r, ph/2 - 1, 2*r, 2);\n-\t\t\tp.restore();\n-\t\t\tbreak;\n-\t\tcase APPLIED:\n-\t\t\tp.save();\n-\t\t\tp.setPen(Qt::NoPen);\n-\t\t\tp.setBrush(QBrush(DARK_GREEN, Qt::SolidPattern));\n-\t\t\tp.drawRect(pw/2 - r, ph/2 - 1, 2*r, 2);\n-\t\t\tp.drawRect(pw/2 - 1, ph/2 - r, 2, 2*r);\n-\t\t\tp.restore();\n-\t\t\tbreak;\n-\t\tcase BOUNDARY:\n-\t\t\tp.drawLine(P_90, P_OR);\n-\t\t\tp.save();\n-\t\t\tp.setBrush(myWhiteBrush);\n-\t\t\tp.drawEllipse(pw/2 - r, ph/2 - r, 2*r, 2*r);\n-\t\t\tp.restore();\n-\t\t\tp.drawEllipse(pw/2 - r, ph/2 - r, 2*r, 2*r);\n-\t\t\tbreak;\n-\t\tcase BOUNDARY_C:\n-\t\t\tp.drawLine(P_90, P_OR);\n-\t\t\tp.drawLine(P_180, P_0);\n-\t\t\tp.fillRect(pw/2 - r, ph/2 - r, 2*r, 2*r, myWhiteBrush);\n-\t\t\tp.drawRect(pw/2 - r, ph/2 - r, 2*r, 2*r);\n-\t\t\tbreak;\n-\t\tcase BOUNDARY_R:\n-\t\t\tp.drawLine(P_90, P_OR);\n-\t\t\tp.drawLine(P_180, P_OR);\n-\t\t\tp.fillRect(pw/2 - r, ph/2 - r, 2*r, 2*r, myWhiteBrush);\n-\t\t\tp.drawRect(pw/2 - r, ph/2 - r, 2*r, 2*r);\n-\t\t\tbreak;\n-\t\tcase BOUNDARY_L:\n-\t\t\tp.drawLine(P_90, P_OR);\n-\t\t\tp.drawLine(P_OR, P_0);\n-\t\t\tp.fillRect(pw/2 - r, ph/2 - r, 2*r, 2*r, myWhiteBrush);\n-\t\t\tp.drawRect(pw/2 - r, ph/2 - r, 2*r, 2*r);\n-\t\t\tbreak;\n-\t\t}\n-\t\tp.end();\n-\t\tpixmaps.insert(i, pm); // pixmaps has autoDelete set\n-\t}\n-}\ndiff --git a/src/listview.h b/src/listview.h\nindex 7e52e9a..eafb7c2 100644\n--- a/src/listview.h\n+++ b/src/listview.h\n@@ -20,7 +20,7 @@ class FileHistory;\n class ListViewItem: public QListViewItem {\n public:\n \tListViewItem(QListView* p, ListViewItem* a, Git* g, SCRef sha,\n-\t\t     const QPtrVector<QPixmap>& pm, bool e, unsigned long t, FileHistory* f);\n+\t\t     const int& w, bool e, unsigned long t, FileHistory* f);\n \n \tSCRef sha() const { return sha_; }\n \tint getLaneType(uint pos) const;\n@@ -45,7 +45,7 @@ private:\n \tGit* git;\n \tFileHistory* fh;\n \tconst QString sha_;\n-\tconst QPtrVector<QPixmap>& pms;\n+\tconst int& laneWidth;\n \tunsigned long secs;\n \tbool populated, isEvenLine, isHighlighted, isDiffTarget;\n };\ndiff --git a/src/mainimpl.cpp b/src/mainimpl.cpp\nindex 0a1efb4..620b3e8 100644\n--- a/src/mainimpl.cpp\n+++ b/src/mainimpl.cpp\n@@ -109,7 +109,6 @@ MainImpl::MainImpl(const QString& cd, QW\n \tlineEditSHA->setMinimumWidth(wd);\n \n \t// gm is now set to application's default font\n-\tgm.pixmaps.setAutoDelete(true);\n \tadjustFontSize(0); // create pixmaps\n \n \tconnect(git, SIGNAL(newRevsAdded(const FileHistory*, const QValueVector<QString>&)),\n@@ -945,7 +944,7 @@ void MainImpl::adjustFontSize(int delta)\n \tint h = item->height();\n \tdelete item;\n \n-\tgm.setupPixmaps(h); // (re)create the pixmaps\n+\tgm.laneWidth = 3 * h / 4;\n \n \temit repaintListViews(gm.font);\n }\ndiff --git a/src/mainimpl.h b/src/mainimpl.h\nindex 0dbc38a..3446806 100644\n--- a/src/mainimpl.h\n+++ b/src/mainimpl.h\n@@ -155,11 +155,7 @@ private:\n \tint recentRepoMenuPos;\n \n \tstruct GraphMetrics {\n-\t\tvoid setupPixmaps(int height);\n-\t\tint height() const { return pixmaps[0]->height(); }\n-\t\tint width () const { return pixmaps[0]->width(); }\n-\n-\t\tQPtrVector<QPixmap> pixmaps;\n+\t        int laneWidth;\n \t\tQFont font;\n \t};\n \tGraphMetrics gm;\n-- \n1.4.3.rc2.gf8ffb\n"}]}