Frapper  1.0a
Log.h
Go to the documentation of this file.
1 /*
2 -----------------------------------------------------------------------------
3 This source file is part of FRAPPER
4 research.animationsinstitut.de
5 sourceforge.net/projects/frapper
6 
7 Copyright (c) 2008-2009 Filmakademie Baden-Wuerttemberg, Institute of Animation
8 
9 This program is free software; you can redistribute it and/or modify it under
10 the terms of the GNU Lesser General Public License as published by the Free Software
11 Foundation; version 2.1 of the License.
12 
13 This program is distributed in the hope that it will be useful, but WITHOUT
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
16 
17 You should have received a copy of the GNU Lesser General Public License along with
18 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
19 Place - Suite 330, Boston, MA 02111-1307, USA, or go to
20 http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
21 -----------------------------------------------------------------------------
22 */
23 
33 
34 #ifndef LOG_H
35 #define LOG_H
36 
37 #include "FrapperPrerequisites.h"
38 #include <QtGui/QTableView>
39 #include <QtGui/QStandardItemModel>
40 #include <QtGui/QSortFilterProxyModel>
41 #include <QtGui/QIcon>
42 
43 namespace Frapper {
44 
49 {
50 
51 public: // nested enumerations
52 
56  enum MessageType {
57  MT_Info = 1,
58  MT_Warning = 2,
59  MT_Error = 4,
60  MT_Debug = 8,
61  MT_Qt = 16,
62  MT_Ogre = 32
63  };
64 
65 private: // type definitions
66 
70  typedef QMap<int, QStandardItemModel *> MessageModelMap;
71 
75  typedef QMap<int, QSortFilterProxyModel *> ProxyModelMap;
76 
81  typedef QMap<Log::MessageType, bool> MessageFilters;
82 
87  typedef QPair<bool, MessageFilters> FilterSettings;
88 
93  typedef QMap<QTableView *, FilterSettings> TableViewMap;
94 
95 public: // static functions
96 
102  static void initialize ( bool useStandardStreams );
103 
108  static void finalize ();
109 
113  static void loadIcons ();
114 
120  static void registerView ( QTableView *tableView );
121 
127  static void unregisterView ( QTableView *tableView );
128 
135  static void info ( const QString &message, const QString &function = "" );
136 
143  static void warning ( const QString &message, const QString &function = "" );
144 
151  static void error ( const QString &message, const QString &function = "" );
152 
159  static void debug ( const QString &message, const QString &function = "" );
160 
167  static void na ( const QString &function = "" );
168 
175  static void addQtLogMessage ( QtMsgType qtMessageType, const char *qtMessage );
176 
183  static void addOgreLogMessage ( const QString &message, const QString &logMessageLevel );
184 
191  static void setFilterEnabled ( QTableView *tableView, bool enabled );
192 
201  static void filter ( QTableView *tableView, MessageType type, bool visible );
202 
209  static void filter ( QTableView *tableView, const QString &searchText);
210 
214  static void clear ();
215 
222  static QString getMessage ( QStandardItemModel *model, int row );
223 
224 private: // static functions
225 
233  static void addMessage ( MessageType messageType, const QString &message, const QString &function = "" );
234 
241  static void updateModel ( QTableView *tableView );
242 
251  static void printToStandardOutput ( const QString &header, const QString &message, const QString &function );
252 
261  static void printToStandardError ( const QString &header, const QString &message, const QString &function );
262 
263 private: // static data
264 
269  static bool s_useStandardStreams;
270 
274  static bool s_initialized;
275 
279  static QStringList s_headerLabels;
280 
286 
292 
298 
302  static QMap<MessageType, QIcon> s_messageIcons;
303 
304 };
305 
306 } // end namespace Frapper
307 
308 #endif