Mercurial > hg > easyhg
comparison changesetitem.cpp @ 56:1394c8cbf991
* Minor layout improvement
author | Chris Cannam |
---|---|
date | Tue, 16 Nov 2010 11:26:51 +0000 |
parents | 261bfb9481fe |
children | f583e44d9d31 |
comparison
equal
deleted
inserted
replaced
55:261bfb9481fe | 56:1394c8cbf991 |
---|---|
54 | 54 |
55 int width = 100; | 55 int width = 100; |
56 if (m_wide) width = 180; | 56 if (m_wide) width = 180; |
57 int x0 = -((width - 50) / 2 - 1); | 57 int x0 = -((width - 50) / 2 - 1); |
58 | 58 |
59 QRectF r(x0, 0, width - 3, 49); | 59 int height = 49; |
60 QRectF r(x0, 0, width - 3, height); | |
60 paint->drawRect(r); | 61 paint->drawRect(r); |
61 | 62 |
62 if (scale < 0.1) { | 63 if (scale < 0.1) { |
63 paint->restore(); | 64 paint->restore(); |
64 return; | 65 return; |
65 } | |
66 | |
67 if (m_changeset->children().empty()) { | |
68 f.setBold(true); | |
69 paint->setFont(f); | |
70 QString branch = m_changeset->branch(); | |
71 int wid = width - 3; | |
72 branch = TextAbbrev::abbreviate(branch, QFontMetrics(f), wid); | |
73 paint->drawText(x0, -fh + fm.ascent() - 4, branch); | |
74 f.setBold(false); | |
75 } | 66 } |
76 | 67 |
77 paint->fillRect(QRectF(x0 + 0.5, 0.5, width - 4, fh - 0.5), | 68 paint->fillRect(QRectF(x0 + 0.5, 0.5, width - 4, fh - 0.5), |
78 QBrush(userColour)); | 69 QBrush(userColour)); |
79 | 70 |
83 QString person = TextAbbrev::abbreviate(m_changeset->authorName(), fm, wid); | 74 QString person = TextAbbrev::abbreviate(m_changeset->authorName(), fm, wid); |
84 paint->drawText(x0 + 3, fm.ascent(), person); | 75 paint->drawText(x0 + 3, fm.ascent(), person); |
85 | 76 |
86 paint->setPen(QPen(Qt::black)); | 77 paint->setPen(QPen(Qt::black)); |
87 | 78 |
88 f.setItalic(true); | 79 if (m_changeset->children().empty()) { |
80 // write branch name | |
81 f.setBold(true); | |
82 paint->setFont(f); | |
83 QString branch = m_changeset->branch(); | |
84 int wid = width - 3; | |
85 branch = TextAbbrev::abbreviate(branch, QFontMetrics(f), wid); | |
86 paint->drawText(x0, -fh + fm.ascent() - 4, branch); | |
87 f.setBold(false); | |
88 } | |
89 | |
90 // f.setItalic(true); | |
89 fm = QFontMetrics(f); | 91 fm = QFontMetrics(f); |
90 fh = fm.height(); | 92 fh = fm.height(); |
91 paint->setFont(f); | 93 paint->setFont(f); |
92 | 94 |
93 QString comment = m_changeset->comment().trimmed(); | 95 QString comment = m_changeset->comment().trimmed(); |
96 comment = comment.replace(QRegExp("\"$"), ""); | 98 comment = comment.replace(QRegExp("\"$"), ""); |
97 comment = comment.replace("\\\"", "\""); | 99 comment = comment.replace("\\\"", "\""); |
98 comment = comment.split('\n')[0]; | 100 comment = comment.split('\n')[0]; |
99 | 101 |
100 wid = width - 5; | 102 wid = width - 5; |
103 int nlines = (height / fh) - 1; | |
104 if (nlines < 1) nlines = 1; | |
101 comment = TextAbbrev::abbreviate(comment, fm, wid, TextAbbrev::ElideEnd, | 105 comment = TextAbbrev::abbreviate(comment, fm, wid, TextAbbrev::ElideEnd, |
102 "...", 2); | 106 "...", nlines); |
103 | 107 |
104 QStringList lines = comment.split('\n'); | 108 QStringList lines = comment.split('\n'); |
105 for (int i = 0; i < lines.size(); ++i) { | 109 for (int i = 0; i < lines.size(); ++i) { |
106 paint->drawText(x0 + 3, i * fh + fh + fm.ascent(), lines[i].trimmed()); | 110 paint->drawText(x0 + 3, i * fh + fh + fm.ascent(), lines[i].trimmed()); |
107 } | 111 } |