[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: kdevelop/parts/grepview
From: Harald Fernengel <harald () kdevelop ! org>
Date: 2003-03-06 19:50:06
[Download RAW message or body]
CVS commit by harald:
applied patch by Stephane ANCELOT <sancelot@free.fr>, show filename only once
M +30 -13 grepviewwidget.cpp 1.14
--- kdevelop/parts/grepview/grepviewwidget.cpp #1.13:1.14
@@ -31,5 +31,5 @@ class GrepListBoxItem : public ProcessLi
{
public:
- GrepListBoxItem(const QString &s1, const QString &s2, const QString &s3);
+ GrepListBoxItem(const QString &s1, const QString &s2, const QString &s3, bool \
showFilename); QString filename()
{ return str1; }
@@ -41,4 +41,5 @@ private:
virtual void paint(QPainter *p);
QString str1, str2, str3;
+ bool show;
};
@@ -46,10 +47,12 @@ private:
GrepListBoxItem::GrepListBoxItem(const QString &s1,
const QString &s2,
- const QString &s3)
+ const QString &s3,
+ bool showFilename)
: ProcessListBoxItem(s1+s2+s3, Normal)
{
- str1 = s1;
+ str1 = s1; // filename
str2 = s2;
str3 = s3;
+ show = showFilename;
}
@@ -64,11 +67,14 @@ void GrepListBoxItem::paint(QPainter *p)
{
QFontMetrics fm = p->fontMetrics();
+ QString stx = str2.right(str2.length()-1);
int y = fm.ascent()+fm.leading()/2;
int x = 3;
-
+ if (show)
+ {
p->setPen(Qt::darkGreen);
p->drawText(x, y, str1);
x += fm.width(str1);
-
+ }
+ else {
p->setPen(Qt::black);
QFont font1(p->font());
@@ -76,10 +82,11 @@ void GrepListBoxItem::paint(QPainter *p)
font2.setBold(true);
p->setFont(font2);
- p->drawText(x, y, str2);
+ p->drawText(x, y, stx);
p->setFont(font1);
- x += fm.width(str2);
+ x += fm.width(stx);
p->setPen(Qt::blue);
p->drawText(x, y, str3);
+ }
}
@@ -221,5 +228,15 @@ void GrepViewWidget::insertStdoutLine(co
linenumber = str.left(pos);
str.remove(0, pos);
- insertItem(new GrepListBoxItem(filename, linenumber, str));
+ // filename will be displayed only once
+ // selecting filename will display line 1 of file,
+ // otherwise, line of requested search
+ if (findItem(filename,BeginsWith|ExactMatch) == 0)
+ {
+ insertItem(new \
GrepListBoxItem(filename, "1", str, true)); + \
insertItem(new GrepListBoxItem(filename, linenumber, str, false)); +
+ }
+ else insertItem(new \
GrepListBoxItem(filename, linenumber, str, false)); +
}
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic