CoreWidgetLogging.cc 2.8 KB
Newer Older
Jan Möbius's avatar
 
Jan Möbius committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
//=============================================================================
//
//                               OpenFlipper
//        Copyright (C) 2008 by Computer Graphics Group, RWTH Aachen
//                           www.openflipper.org
//
//-----------------------------------------------------------------------------
//
//                                License
//
//  OpenFlipper is free software: you can redistribute it and/or modify
//  it under the terms of the GNU Lesser General Public License as published by
//  the Free Software Foundation, either version 3 of the License, or
//  (at your option) any later version.
15
//
Jan Möbius's avatar
 
Jan Möbius committed
16
17
18
19
//  OpenFlipper is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//  GNU Lesser General Public License for more details.
20
//
Jan Möbius's avatar
 
Jan Möbius committed
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
//  You should have received a copy of the GNU Lesser General Public License
//  along with OpenFlipper.  If not, see <http://www.gnu.org/licenses/>.
//
//-----------------------------------------------------------------------------
//
//   $Revision$
//   $Author$
//   $Date$
//
//=============================================================================




//=============================================================================
//
//  CLASS MViewWidget - IMPLEMENTATION
//
//=============================================================================


//== INCLUDES =================================================================

// -------------------- mview
#include "CoreWidget.hh"
// -------------------- ACG
#include "OpenFlipper/common/GlobalOptions.hh"

// -------------------- Qt
#include <QScrollBar>
#include <QApplication>

53
//== IMPLEMENTATION ==========================================================
Jan Möbius's avatar
 
Jan Möbius committed
54
55

/** \brief Slot writing everything to the Logger widget
56
 *
Jan Möbius's avatar
 
Jan Möbius committed
57
58
 * This slot has to be called by all loggers. It is used to serialize
 * and color the Output.
59
 *
Jan Möbius's avatar
 
Jan Möbius committed
60
61
62
 * @param _type Logtype (defines the color of the output)
 * @param _message The message for output
 **/
63
void
Jan Möbius's avatar
 
Jan Möbius committed
64
65
CoreWidget::
slotLog(Logtype _type, QString _message) {
Dirk Wilden's avatar
Dirk Wilden committed
66
67
68

  QColor textColor;

Jan Möbius's avatar
 
Jan Möbius committed
69
70
  switch (_type) {
    case LOGINFO:
Dirk Wilden's avatar
Dirk Wilden committed
71
      textColor = QColor(0,160,0);
Jan Möbius's avatar
 
Jan Möbius committed
72
73
      break;
    case LOGOUT:
Dirk Wilden's avatar
Dirk Wilden committed
74
      textColor = QColor(0,0,0);
Jan Möbius's avatar
 
Jan Möbius committed
75
76
      break;
    case LOGWARN:
Dirk Wilden's avatar
Dirk Wilden committed
77
      textColor = QColor(160,160,0);
Jan Möbius's avatar
 
Jan Möbius committed
78
79
      break;
    case LOGERR:
Dirk Wilden's avatar
Dirk Wilden committed
80
      textColor = QColor(250,0,0);
Jan Möbius's avatar
 
Jan Möbius committed
81
82
      break;
  }
83

Dirk Wilden's avatar
Dirk Wilden committed
84
  logWidget_->setTextColor( textColor );
85
86
87
  logWidget_->append(_message);

  QScrollBar* bar = logWidget_->verticalScrollBar();
Jan Möbius's avatar
 
Jan Möbius committed
88
  bar->setValue(bar->maximum());
89

Dirk Wilden's avatar
Dirk Wilden committed
90
91
92
  if (_type == LOGERR)
    statusBar_->showMessage(_message,textColor, 4000);

Jan Möbius's avatar
 
Jan Möbius committed
93
  // Make shure, we see the message
94
//   QApplication::processEvents();
Jan Möbius's avatar
 
Jan Möbius committed
95
96
97
}

//=============================================================================