diff src/changesetitem.cpp @ 559:95877ad67d3e

Merge from branch "find"
author Chris Cannam
date Mon, 27 Feb 2012 17:08:47 +0000
parents a1d210c767ab
children 533519ebc0cb
line wrap: on
line diff
--- a/src/changesetitem.cpp	Fri Feb 17 10:58:41 2012 +0000
+++ b/src/changesetitem.cpp	Mon Feb 27 17:08:47 2012 +0000
@@ -38,7 +38,7 @@
 ChangesetItem::ChangesetItem(Changeset *cs) :
     m_changeset(cs), m_detail(0),
     m_showBranch(false), m_column(0), m_row(0), m_wide(false),
-    m_current(false), m_closing(false), m_new(false)
+    m_current(false), m_closing(false), m_new(false), m_searchMatches(false)
 {
     m_font = QFont();
     m_font.setPixelSize(11);
@@ -91,6 +91,15 @@
     emit detailHidden();
 }    
 
+bool
+ChangesetItem::setSearchText(QString text)
+{
+    m_searchText = text;
+    m_searchMatches = (m_changeset->comment().contains
+                       (text, Qt::CaseInsensitive));
+    return m_searchMatches;
+}
+
 void
 ChangesetItem::mousePressEvent(QGraphicsSceneMouseEvent *e)
 {
@@ -296,6 +305,17 @@
     bool showText = (scale >= 0.2);
     bool showProperLines = (scale >= 0.1);
 
+    if (m_searchText != "") {
+        if (m_searchMatches) {
+            userColour = QColor("#008400");
+            showProperLines = true;
+            showText = true;
+        } else {
+            branchColour = Qt::gray;
+            userColour = Qt::gray;
+        }
+    }
+
     if (!showProperLines) {
 	paint->setPen(QPen(branchColour, 0));
     } else {
@@ -452,6 +472,8 @@
 
     paint->setFont(f);
 
+    if (m_searchMatches) paint->setPen(userColour);
+
     for (int i = 0; i < lines.size(); ++i) {
 	paint->drawText(x0 + 3, i * fh + fh + fm.ascent(), lines[i].trimmed());
     }