comparison changesetitem.cpp @ 54:0e5fba6750c2

* Small rendering refinements
author Chris Cannam
date Fri, 12 Nov 2010 17:04:36 +0000
parents 3c46b2ac45d3
children 261bfb9481fe
comparison
equal deleted inserted replaced
53:3c46b2ac45d3 54:0e5fba6750c2
22 22
23 void 23 void
24 ChangesetItem::paint(QPainter *paint, const QStyleOptionGraphicsItem *option, 24 ChangesetItem::paint(QPainter *paint, const QStyleOptionGraphicsItem *option,
25 QWidget *w) 25 QWidget *w)
26 { 26 {
27 QTransform t = paint->worldTransform();
28
29 paint->save(); 27 paint->save();
30 28
31 ColourSet *colourSet = ColourSet::instance(); 29 ColourSet *colourSet = ColourSet::instance();
32 QColor branchColour = colourSet->getColourFor(m_changeset->branch()); 30 QColor branchColour = colourSet->getColourFor(m_changeset->branch());
33 QColor userColour = colourSet->getColourFor(m_changeset->author()); 31 QColor userColour = colourSet->getColourFor(m_changeset->author());
34 32
35 paint->setPen(QPen(branchColour, 2));
36
37 QFont f(m_font); 33 QFont f(m_font);
38 34
35 QTransform t = paint->worldTransform();
39 float scale = std::min(t.m11(), t.m22()); 36 float scale = std::min(t.m11(), t.m22());
40 if (scale > 1.0) { 37 if (scale > 1.0) {
41 int ps = int((f.pixelSize() / scale) + 0.5); 38 int ps = int((f.pixelSize() / scale) + 0.5);
42 if (ps < 8) ps = 8; 39 if (ps < 8) ps = 8;
43 f.setPixelSize(ps); 40 f.setPixelSize(ps);
41 }
42
43 if (scale < 0.1) {
44 paint->setPen(QPen(branchColour, 0));
45 } else {
46 paint->setPen(QPen(branchColour, 2));
44 } 47 }
45 48
46 paint->setFont(f); 49 paint->setFont(f);
47 QFontMetrics fm(f); 50 QFontMetrics fm(f);
48 int fh = fm.height(); 51 int fh = fm.height();
56 } 59 }
57 60
58 if (m_changeset->children().empty()) { 61 if (m_changeset->children().empty()) {
59 f.setBold(true); 62 f.setBold(true);
60 paint->setFont(f); 63 paint->setFont(f);
61 paint->drawText(-24, -fh + fm.ascent() - 4, m_changeset->branch()); 64 QString branch = m_changeset->branch();
65 int wid = 97;
66 branch = TextAbbrev::abbreviate(branch, QFontMetrics(f), wid);
67 paint->drawText(-24, -fh + fm.ascent() - 4, branch);
62 f.setBold(false); 68 f.setBold(false);
63 } 69 }
64 70
65 paint->fillRect(QRectF(-23.5, 0.5, 96, fh - 0.5), QBrush(userColour)); 71 paint->fillRect(QRectF(-23.5, 0.5, 96, fh - 0.5), QBrush(userColour));
66 72