1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
/***************************************************************************
messageoutput.cpp - description
-------------------
begin : Jan 12 2001
copyright : (C) 2001 by Dmitry Poplavsky <[email protected]>
(C) 2002-2005 Andras Mantia <[email protected]>
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "messageitem.h"
#include <tqregexp.h>
#include <tdelocale.h>
MessageItem::MessageItem( TQListBox * listbox, const TQString &text, int line, int column, const TQString &fname )
:TQListBoxText(listbox,text),lineNumber(line),columnNumber(column),filename(fname)
{
}
int MessageItem::line()
{
if ( lineNumber != -1 ) {
return lineNumber;
}
else { // try to find first number in text
TQString s = text();
int pos = s.find( TQRegExp("[0-9]"));
if ( pos == -1 )
return lineNumber;
int pos2 = pos;
while ( s[pos2].isDigit() ) pos2++;
TQString snum = s.mid(pos, pos2-pos);
return snum.toInt();
}
}
int MessageItem::column()
{
if (columnNumber != -1)
{
return columnNumber;
} else
{
TQString s = text();
TQRegExp exp("(?:\\D|^)(\\d{1,4})(?:\\D|$)");
int pos = exp.search(s);
if ( pos == -1 )
return 0;
pos = exp.search(s, pos + exp.cap(1).length());
if ( pos == -1 )
return 0;
s = exp.cap(1);
return s.toInt();
}
}
TQString MessageItem::fileName()
{
if (filename.isEmpty())
{
TQString fname;
TQString s = text();
int pos = s.find(i18n("File: "));
if (pos != -1)
{
int pos2 = s.find(i18n(", "), pos);
if (pos2 != -1)
fname = s.mid(pos, pos2-pos);
else
fname = s.mid(pos);
fname.remove(i18n("File: "));
}
return fname;
} else
return filename;
}
void MessageItem::addText(const TQString &t)
{
setText( text() + t );
}
|