Mercurial > hg > easyhg
comparison src/changesetitem.cpp @ 555:a1d210c767ab find
Implement basic search function in both work and history tabs
author | Chris Cannam |
---|---|
date | Wed, 22 Feb 2012 14:54:30 +0000 |
parents | b5a342a71218 |
children | 533519ebc0cb |
comparison
equal
deleted
inserted
replaced
554:930462068dcc | 555:a1d210c767ab |
---|---|
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_closing(false), m_new(false) | 41 m_current(false), m_closing(false), m_new(false), m_searchMatches(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); |
88 scene()->removeItem(m_detail); | 88 scene()->removeItem(m_detail); |
89 delete m_detail; | 89 delete m_detail; |
90 m_detail = 0; | 90 m_detail = 0; |
91 emit detailHidden(); | 91 emit detailHidden(); |
92 } | 92 } |
93 | |
94 bool | |
95 ChangesetItem::setSearchText(QString text) | |
96 { | |
97 m_searchText = text; | |
98 m_searchMatches = (m_changeset->comment().contains | |
99 (text, Qt::CaseInsensitive)); | |
100 return m_searchMatches; | |
101 } | |
93 | 102 |
94 void | 103 void |
95 ChangesetItem::mousePressEvent(QGraphicsSceneMouseEvent *e) | 104 ChangesetItem::mousePressEvent(QGraphicsSceneMouseEvent *e) |
96 { | 105 { |
97 DEBUG << "ChangesetItem::mousePressEvent" << endl; | 106 DEBUG << "ChangesetItem::mousePressEvent" << endl; |
294 } | 303 } |
295 | 304 |
296 bool showText = (scale >= 0.2); | 305 bool showText = (scale >= 0.2); |
297 bool showProperLines = (scale >= 0.1); | 306 bool showProperLines = (scale >= 0.1); |
298 | 307 |
308 if (m_searchText != "") { | |
309 if (m_searchMatches) { | |
310 userColour = QColor("#008400"); | |
311 showProperLines = true; | |
312 showText = true; | |
313 } else { | |
314 branchColour = Qt::gray; | |
315 userColour = Qt::gray; | |
316 } | |
317 } | |
318 | |
299 if (!showProperLines) { | 319 if (!showProperLines) { |
300 paint->setPen(QPen(branchColour, 0)); | 320 paint->setPen(QPen(branchColour, 0)); |
301 } else { | 321 } else { |
302 paint->setPen(QPen(branchColour, 2)); | 322 paint->setPen(QPen(branchColour, 2)); |
303 } | 323 } |
449 -fh, starSize, starSize), | 469 -fh, starSize, starSize), |
450 *m_star); | 470 *m_star); |
451 } | 471 } |
452 | 472 |
453 paint->setFont(f); | 473 paint->setFont(f); |
474 | |
475 if (m_searchMatches) paint->setPen(userColour); | |
454 | 476 |
455 for (int i = 0; i < lines.size(); ++i) { | 477 for (int i = 0; i < lines.size(); ++i) { |
456 paint->drawText(x0 + 3, i * fh + fh + fm.ascent(), lines[i].trimmed()); | 478 paint->drawText(x0 + 3, i * fh + fh + fm.ascent(), lines[i].trimmed()); |
457 } | 479 } |
458 | 480 |