comparison src/changesetitem.cpp @ 583:e40e3ebe9f2e fswatcher

Merge from default branch
author Chris Cannam
date Mon, 12 Mar 2012 14:58:40 +0000
parents 1e76d1009167
children 641ccce7c771
comparison
equal deleted inserted replaced
547:9f91d1b2ed51 583:e40e3ebe9f2e
3 /* 3 /*
4 EasyMercurial 4 EasyMercurial
5 5
6 Based on HgExplorer by Jari Korhonen 6 Based on HgExplorer by Jari Korhonen
7 Copyright (c) 2010 Jari Korhonen 7 Copyright (c) 2010 Jari Korhonen
8 Copyright (c) 2011 Chris Cannam 8 Copyright (c) 2012 Chris Cannam
9 Copyright (c) 2011 Queen Mary, University of London 9 Copyright (c) 2012 Queen Mary, University of London
10 10
11 This program is free software; you can redistribute it and/or 11 This program is free software; you can redistribute it and/or
12 modify it under the terms of the GNU General Public License as 12 modify it under the terms of the GNU General Public License as
13 published by the Free Software Foundation; either version 2 of the 13 published by the Free Software Foundation; either version 2 of the
14 License, or (at your option) any later version. See the file 14 License, or (at your option) any later version. See the file
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::matchSearchText(QString text)
96 {
97 m_searchText = text;
98 m_searchMatches = false;
99 if (m_showBranch) {
100 m_searchMatches = (m_changeset->branch().contains
101 (text, Qt::CaseInsensitive));
102 }
103 if (!m_searchMatches) {
104 m_searchMatches = (m_changeset->comment().contains
105 (text, Qt::CaseInsensitive));
106 }
107 return m_searchMatches;
108 }
93 109
94 void 110 void
95 ChangesetItem::mousePressEvent(QGraphicsSceneMouseEvent *e) 111 ChangesetItem::mousePressEvent(QGraphicsSceneMouseEvent *e)
96 { 112 {
97 DEBUG << "ChangesetItem::mousePressEvent" << endl; 113 DEBUG << "ChangesetItem::mousePressEvent" << endl;
294 } 310 }
295 311
296 bool showText = (scale >= 0.2); 312 bool showText = (scale >= 0.2);
297 bool showProperLines = (scale >= 0.1); 313 bool showProperLines = (scale >= 0.1);
298 314
315 if (m_searchText != "") {
316 if (m_searchMatches) {
317 userColour = QColor("#008400");
318 showProperLines = true;
319 showText = true;
320 } else {
321 branchColour = Qt::gray;
322 userColour = Qt::gray;
323 }
324 }
325
299 if (!showProperLines) { 326 if (!showProperLines) {
300 paint->setPen(QPen(branchColour, 0)); 327 paint->setPen(QPen(branchColour, 0));
301 } else { 328 } else {
302 paint->setPen(QPen(branchColour, 2)); 329 paint->setPen(QPen(branchColour, 2));
303 } 330 }
449 -fh, starSize, starSize), 476 -fh, starSize, starSize),
450 *m_star); 477 *m_star);
451 } 478 }
452 479
453 paint->setFont(f); 480 paint->setFont(f);
481
482 if (m_searchMatches) paint->setPen(userColour);
454 483
455 for (int i = 0; i < lines.size(); ++i) { 484 for (int i = 0; i < lines.size(); ++i) {
456 paint->drawText(x0 + 3, i * fh + fh + fm.ascent(), lines[i].trimmed()); 485 paint->drawText(x0 + 3, i * fh + fh + fm.ascent(), lines[i].trimmed());
457 } 486 }
458 487