comparison changesetdetailitem.cpp @ 124:1f27f71a7034

* Fixes to changeset details display; show on right instead of below to avoid disrupting flow
author Chris Cannam
date Mon, 29 Nov 2010 11:38:25 +0000
parents 9734fb0d6fff
children 63c2f3f61c79
comparison
equal deleted inserted replaced
123:3afa1ce339ec 124:1f27f71a7034
44 QRectF 44 QRectF
45 ChangesetDetailItem::boundingRect() const 45 ChangesetDetailItem::boundingRect() const
46 { 46 {
47 int w = 350; 47 int w = 350;
48 m_doc->setTextWidth(w); 48 m_doc->setTextWidth(w);
49 return QRectF(0, -10, w, m_doc->size().height() + 10); 49 return QRectF(-10, -10, w + 10, m_doc->size().height() + 10);
50 } 50 }
51 51
52 void 52 void
53 ChangesetDetailItem::paint(QPainter *paint, 53 ChangesetDetailItem::paint(QPainter *paint,
54 const QStyleOptionGraphicsItem *option, 54 const QStyleOptionGraphicsItem *option,
91 if (scale < 0.1) { 91 if (scale < 0.1) {
92 paint->restore(); 92 paint->restore();
93 return; 93 return;
94 } 94 }
95 95
96 // little triangle connecting to its "owning" changeset item
97 paint->setBrush(branchColour);
98 QVector<QPointF> pts;
99 pts.push_back(QPointF(0, height/3 - 5));
100 pts.push_back(QPointF(0, height/3 + 5));
101 pts.push_back(QPointF(-10, height/3));
102 pts.push_back(QPointF(0, height/3 - 5));
103 paint->drawPolygon(QPolygonF(pts));
104
105 /*
96 paint->setBrush(branchColour); 106 paint->setBrush(branchColour);
97 QVector<QPointF> pts; 107 QVector<QPointF> pts;
98 pts.push_back(QPointF(width/2 - 5, 0)); 108 pts.push_back(QPointF(width/2 - 5, 0));
99 pts.push_back(QPointF(width/2 + 5, 0)); 109 pts.push_back(QPointF(width/2 + 5, 0));
100 pts.push_back(QPointF(width/2, -10)); 110 pts.push_back(QPointF(width/2, -10));
101 pts.push_back(QPointF(width/2 - 5, 0)); 111 pts.push_back(QPointF(width/2 - 5, 0));
102 paint->drawPolygon(QPolygonF(pts)); 112 paint->drawPolygon(QPolygonF(pts));
103 113 */
104 m_doc->drawContents(paint, r); 114 m_doc->drawContents(paint, r);
105 115
106 /*
107 paint->fillRect(QRectF(x0 + 0.5, 0.5, width - 4, fh - 0.5),
108 QBrush(userColour));
109
110 paint->setPen(QPen(Qt::white));
111
112 int wid = width - 5;
113 QString person = TextAbbrev::abbreviate(m_changeset->authorName(), fm, wid);
114 paint->drawText(x0 + 3, fm.ascent(), person);
115
116 paint->setPen(QPen(Qt::black));
117
118 if (m_showBranch) {
119 // write branch name
120 f.setBold(true);
121 paint->setFont(f);
122 QString branch = m_changeset->branch();
123 if (branch == "") branch = "default";
124 int wid = width - 3;
125 branch = TextAbbrev::abbreviate(branch, QFontMetrics(f), wid);
126 paint->drawText(x0, -fh + fm.ascent() - 4, branch);
127 f.setBold(false);
128 }
129
130 // f.setItalic(true);
131 fm = QFontMetrics(f);
132 fh = fm.height();
133 paint->setFont(f);
134
135 wid = width - 5;
136 int nlines = (height / fh) - 1;
137 if (nlines < 1) nlines = 1;
138 comment = TextAbbrev::abbreviate(comment, fm, wid, TextAbbrev::ElideEnd,
139 "...", nlines);
140
141 QStringList lines = comment.split('\n');
142 for (int i = 0; i < lines.size(); ++i) {
143 paint->drawText(x0 + 3, i * fh + fh + fm.ascent(), lines[i].trimmed());
144 }
145 */
146 paint->restore(); 116 paint->restore();
147 } 117 }
148 118
149 void 119 void
150 ChangesetDetailItem::makeDocument() 120 ChangesetDetailItem::makeDocument()