00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
#include "makeitem.h"
00013
00014
#include <qstylesheet.h>
00015
00016
#include <klocale.h>
00017
00018
#include "ktexteditor/cursorinterface.h"
00019
00020 MakeItem::MakeItem()
00021 {
00022 }
00023
00024 MakeItem::MakeItem(
const QString& text )
00025 : m_text(
text )
00026 {
00027 }
00028
00029 MakeItem::~MakeItem()
00030 {
00031 }
00032
00033 QString MakeItem::color(
bool bright_bg )
00034 {
00035
switch (
type() )
00036 {
00037
case Error:
00038
return bright_bg ?
"maroon" :
"red";
00039
case Warning:
00040
return bright_bg ?
"#666" :
"#999";
00041
case Diagnostic:
00042
return bright_bg ?
"black" :
"white";
00043
default:
00044
return bright_bg ?
"navy" :
"blue";
00045 }
00046 }
00047
00048 QString MakeItem::icon()
00049 {
00050
switch (
type() )
00051 {
00052
case Error:
00053
case Warning:
00054
return "<img src=\"error\"></img><nobr> </nobr>";
00055
case Diagnostic:
00056
return "<img src=\"warning\"></img><nobr> </nobr>";
00057
default:
00058
return "<img src=\"message\"></img><nobr> </nobr>";
00059 }
00060 }
00061
00062 QString MakeItem::text( EOutputLevel )
00063 {
00064
return QStyleSheet::escape(
m_text );
00065 }
00066
00067 QString MakeItem::formattedText( EOutputLevel level,
bool bright_bg )
00068 {
00069
if (
m_text.isEmpty())
00070
return "<br>";
00071
return QString(
"<code>").append(
icon() ).append(
"<font color=\"").append(
color( bright_bg) ).append(
00072
"\">").append(
text(level) ).append(
"</font></code>").append(
br() );
00073 }
00074
00075 QString MakeItem::br()
00076 {
00077
00078
#if QT_VERSION < 0x040000
00079
static const QString br = QString::fromLatin1( qVersion() ).section(
".", 1, 1 ).toInt() > 0 ?
"" :
"<br>";
00080
#else
00081
static const QString br;
00082
#endif
00083
return br;
00084 }
00085
00086 ErrorItem::ErrorItem(
const QString& fn,
int ln,
const QString& tx,
const QString& line,
bool isWarning,
const QString& compiler )
00087 :
MakeItem( line )
00088 , fileName(fn)
00089 , lineNum(ln)
00090 , m_error(tx)
00091 , m_cursor(0L)
00092 , m_doc(0L)
00093 , m_isWarning(isWarning)
00094 , m_compiler(compiler)
00095 {}
00096
00097 ErrorItem::~ErrorItem()
00098 {
00099
if (
m_cursor)
m_cursor->
setPosition(uint(-2), uint(-2));
00100 }
00101
00102 bool ErrorItem::append(
const QString& text )
00103 {
00104
if ( !
text.startsWith(
" ") )
00105
return false;
00106
if (
text.startsWith(
" ") && (
m_compiler ==
"intel") )
00107
return false;
00108 m_text +=
text;
00109
m_error +=
text;
00110
m_error =
m_error.simplifyWhiteSpace();
00111 m_text = m_text.simplifyWhiteSpace();
00112
return true;
00113 }
00114
00115 ExitStatusItem::ExitStatusItem(
bool normalExit,
int exitStatus )
00116 : m_normalExit( normalExit )
00117 , m_exitStatus( exitStatus )
00118 {
00119 }
00120
00121 QString ExitStatusItem::text( EOutputLevel )
00122 {
00123
if (
m_normalExit &&
m_exitStatus )
00124
return i18n(
"*** Exited with status: %1 ***").arg(
m_exitStatus );
00125
if (
m_normalExit )
00126
return i18n(
"*** Success ***");
00127
return i18n(
"*** Compilation aborted ***");
00128 }
00129
00130 bool DirectoryItem::m_showDirectoryMessages =
true;
00131
00132 QString EnteringDirectoryItem::text( EOutputLevel outputLevel )
00133 {
00134
if ( outputLevel <
eFull )
00135
return i18n(
"Entering directory %1").arg( directory );
00136
return m_text;
00137 }
00138
00139 QString ExitingDirectoryItem::text( EOutputLevel outputLevel )
00140 {
00141
if ( outputLevel <
eFull )
00142
return i18n(
"Leaving directory %1").arg( directory );
00143
return m_text;
00144 }
00145
00146 QString ActionItem::text( EOutputLevel outputLevel )
00147 {
00148
if ( outputLevel <
eFull )
00149 {
00150
if (
m_tool.isEmpty() )
00151
return QString(
m_action).append(
" <b>").append(
m_file).append(
"</b>");
00152
return QString(
m_action).append(
" <b>").append(
m_file).append(
"</b>").append(
" (").append(
m_tool).append(
")");
00153 }
00154
return MakeItem::text( outputLevel );
00155 }