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