summaryrefslogtreecommitdiffstats
path: root/parts/outputviews/makeitem.h
blob: 94acc3e2672839dc25fa2305ab1884e70e566157 (plain)
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
/***************************************************************************
 *   Copyright (C) 1999-2001 by Bernd Gehrmann                             *
 *   bernd@kdevelop.org                                                    *
 *                                                                         *
 *   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.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef MakeItem_h
#define MakeItem_h

#include <tqstring.h>

enum EOutputLevel
{
	// appropriate to the ID's in the button group of settingswidget.ui
	eVeryShort = 0
	,eShort
	,eFull
};

class MakeItem
{
public:
	enum Type { Normal, Error, Warning, Diagnostic };
	MakeItem();
	MakeItem( const TQString& text );
	virtual ~MakeItem();

  enum DisplayModes
  {
    DelayedDisplay = 0, // item can be displayed later
    ImmDisplay = 1,     // item has to be displayed ASAP
    Append = 2          // item's text can be appended (append has been overloaded)
  };
  virtual int displayMode() const { return ImmDisplay; }
	virtual bool append( const TQString& ) { return false; }
	virtual Type type() { return Diagnostic; }
	virtual bool visible( EOutputLevel level ) { return level > eVeryShort; }
	virtual TQString text( EOutputLevel );
	virtual TQString formattedText( EOutputLevel, bool bright_bg );
	TQString icon();
	TQString color( bool bright_bg );

	static TQString br();

	TQString m_text;
};

class CommandItem : public MakeItem
{
public:
	CommandItem(const TQString command)
		: MakeItem( command )
	{}

	Type type() { return Diagnostic; }
	virtual bool visible( EOutputLevel ) { return true; }
};

class ExitStatusItem : public MakeItem
{
public:
	ExitStatusItem( bool normalExit, int exitStatus );

	Type type() { return m_normalExit && m_exitStatus == 0 ? Diagnostic : Error; }
	virtual bool visible( EOutputLevel ) { return true; }
	TQString text( EOutputLevel level );

private:
	bool m_normalExit;
	int m_exitStatus;
};

class DirectoryItem : public MakeItem
{
public:
	DirectoryItem( const TQString& dir, const TQString& text )
		: MakeItem( text )
		, directory( dir )
	{}

	Type type() { return Diagnostic; }

	static void setShowDirectoryMessages( bool show ) { m_showDirectoryMessages = show; }
	static bool getShowDirectoryMessages() { return m_showDirectoryMessages; }

	TQString directory;

protected:
	static bool m_showDirectoryMessages;
};

class EnteringDirectoryItem : public DirectoryItem
{
public:
	EnteringDirectoryItem( const TQString& dir, const TQString& text )
		: DirectoryItem( dir, text )
	{}
	bool visible( EOutputLevel )
	{
		return m_showDirectoryMessages;
	}

	virtual TQString text( EOutputLevel );
};

class ExitingDirectoryItem : public DirectoryItem
{
public:
	ExitingDirectoryItem( const TQString& dir, const TQString& text )
		: DirectoryItem( dir, text )
	{}
	bool visible( EOutputLevel level )
	{
		return m_showDirectoryMessages && level > eVeryShort;
	}

	virtual TQString text( EOutputLevel );
};

namespace KTextEditor { class Cursor; class Document; }

class ErrorItem : public MakeItem
{
public:
	ErrorItem( const TQString& fn, int ln, const TQString& tx, const TQString& line, bool isWarning, bool isInstatiationInfo, const TQString& compiler );
	virtual ~ErrorItem();

	virtual bool append( const TQString& text );
  virtual int displayMode() const { return DelayedDisplay | Append; }
	Type type() { return m_isInstatiationInfo ? Diagnostic : (m_isWarning ? Warning : Error); }
	virtual bool visible( EOutputLevel ) { return true; }

	TQString fileName;
	int lineNum;
	TQString m_error;
	bool m_isWarning;
	bool m_isInstatiationInfo; ///this also implies isWarning
	TQString m_compiler;
};

class ActionItem : public MakeItem
{
public:
	ActionItem( const TQString& action, const TQString& file, const TQString& tool, const TQString& line )
		: MakeItem( line )
		, m_action( action )
		, m_file( file )
		, m_tool( tool )
	{}

	virtual bool visible( EOutputLevel ) { return true; }
	virtual TQString text( EOutputLevel level );

	TQString m_action;
	TQString m_file;
	TQString m_tool;
};

#endif