comparison src/changesetitem.cpp @ 508:c43880dfdb78

Show closing commits as simple squares
author Chris Cannam
date Tue, 18 Oct 2011 11:10:20 +0100
parents 470829a21f98
children c623ce6b3104
comparison
equal deleted inserted replaced
507:459aa20d3eee 508:c43880dfdb78
36 QImage *ChangesetItem::m_star = 0; 36 QImage *ChangesetItem::m_star = 0;
37 37
38 ChangesetItem::ChangesetItem(Changeset *cs) : 38 ChangesetItem::ChangesetItem(Changeset *cs) :
39 m_changeset(cs), m_detail(0), 39 m_changeset(cs), m_detail(0),
40 m_showBranch(false), m_column(0), m_row(0), m_wide(false), 40 m_showBranch(false), m_column(0), m_row(0), m_wide(false),
41 m_current(false), m_closed(false), m_new(false) 41 m_current(false), m_closed(false), m_closing(false), m_new(false)
42 { 42 {
43 m_font = QFont(); 43 m_font = QFont();
44 m_font.setPixelSize(11); 44 m_font.setPixelSize(11);
45 m_font.setBold(false); 45 m_font.setBold(false);
46 m_font.setItalic(false); 46 m_font.setItalic(false);
70 m_detail = new ChangesetDetailItem(m_changeset); 70 m_detail = new ChangesetDetailItem(m_changeset);
71 m_detail->setZValue(zValue() + 1); 71 m_detail->setZValue(zValue() + 1);
72 scene()->addItem(m_detail); 72 scene()->addItem(m_detail);
73 int w = 100; 73 int w = 100;
74 if (m_wide) w = 180; 74 if (m_wide) w = 180;
75 if (isMerge()) w = 60; 75 if (isMerge() || isClosingCommit()) w = 60;
76 int h = 80; 76 int h = 80;
77 // m_detail->moveBy(x() - (m_detail->boundingRect().width() - 50) / 2, 77 // m_detail->moveBy(x() - (m_detail->boundingRect().width() - 50) / 2,
78 // y() + 60); 78 // y() + 60);
79 m_detail->moveBy(x() + (w + 50) / 2 + 10 + 0.5, 79 m_detail->moveBy(x() + (w + 50) / 2 + 10 + 0.5,
80 y() - (m_detail->boundingRect().height() - h) / 3 + 0.5); 80 y() - (m_detail->boundingRect().height() - h) / 3 + 0.5);
242 void ChangesetItem::newBranchActivated() { emit newBranch(getId()); } 242 void ChangesetItem::newBranchActivated() { emit newBranch(getId()); }
243 243
244 void 244 void
245 ChangesetItem::paint(QPainter *paint, const QStyleOptionGraphicsItem *, QWidget *) 245 ChangesetItem::paint(QPainter *paint, const QStyleOptionGraphicsItem *, QWidget *)
246 { 246 {
247 if (isMerge()) { 247 if (isClosingCommit() || isMerge()) {
248 paintMerge(paint); 248 paintSimple(paint);
249 } else { 249 } else {
250 paintNormal(paint); 250 paintNormal(paint);
251 } 251 }
252 } 252 }
253 253
431 431
432 paint->restore(); 432 paint->restore();
433 } 433 }
434 434
435 void 435 void
436 ChangesetItem::paintMerge(QPainter *paint) 436 ChangesetItem::paintSimple(QPainter *paint)
437 { 437 {
438 paint->save(); 438 paint->save();
439 439
440 int alpha = 255; 440 int alpha = 255;
441 if (m_closed) alpha = 40; 441 if (m_closed) alpha = 90;
442 442
443 ColourSet *colourSet = ColourSet::instance(); 443 ColourSet *colourSet = ColourSet::instance();
444 QColor branchColour = colourSet->getColourFor(m_changeset->branch()); 444 QColor branchColour = colourSet->getColourFor(m_changeset->branch());
445 QColor userColour = colourSet->getColourFor(m_changeset->author()); 445 QColor userColour = colourSet->getColourFor(m_changeset->author());
446 446
479 } 479 }
480 480
481 if (showProperLines) { 481 if (showProperLines) {
482 482
483 if (m_current) { 483 if (m_current) {
484 paint->drawEllipse(QRectF(x0 - 4, fh - 4, size + 8, size + 8)); 484 if (isClosingCommit()) {
485 485 paint->drawRect(QRectF(x0 - 4, fh - 4, size + 8, size + 8));
486 } else {
487 paint->drawEllipse(QRectF(x0 - 4, fh - 4, size + 8, size + 8));
488 }
489
486 if (m_new) { 490 if (m_new) {
487 paint->save(); 491 paint->save();
488 paint->setPen(Qt::yellow); 492 paint->setPen(Qt::yellow);
489 paint->setBrush(Qt::NoBrush); 493 paint->setBrush(Qt::NoBrush);
490 paint->drawEllipse(QRectF(x0 - 2, fh - 2, size + 4, size + 4)); 494 if (isClosingCommit()) {
495 paint->drawRect(QRectF(x0 - 2, fh - 2, size + 4, size + 4));
496 } else {
497 paint->drawEllipse(QRectF(x0 - 2, fh - 2, size + 4, size + 4));
498 }
491 paint->restore(); 499 paint->restore();
492 } 500 }
493 } 501 }
494 } 502 }
495 503
496 paint->drawEllipse(QRectF(x0, fh, size, size)); 504 if (isClosingCommit()) {
505 paint->drawRect(QRectF(x0, fh, size, size));
506 } else {
507 paint->drawEllipse(QRectF(x0, fh, size, size));
508 }
497 509
498 if (m_showBranch) { 510 if (m_showBranch) {
499 // write branch name 511 // write branch name
500 paint->save(); 512 paint->save();
501 f.setBold(true); 513 f.setBold(true);