summaryrefslogtreecommitdiffstats
path: root/src/libgui/log_view.h
blob: c84849ee8a8d92329d6a6250a08fa555263594f6 (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
/***************************************************************************
 *   Copyright (C) 2005 Nicolas Hadacek <hadacek@kde.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 LOG_VIEW_H
#define LOG_VIEW_H

#include <qtextedit.h>
#include "common/global/log.h"

namespace Log
{
enum OutputType { GuiOnly = 0, GuiConsole, Nb_OutputTypes };

class Widget : public QTextEdit, public View
{
  Q_OBJECT
public:
  Widget(QWidget *parent = 0, const char *name = 0);
  virtual void appendToLastLine(const QString &text);
  virtual void clear();
  virtual void sorry(const QString &message, const QString &details);
  virtual bool askContinue(const QString &message);

protected:
  QPopupMenu *createPopupMenu(const QPoint &pos);

private slots:
  void toggleVisible(int i);
  void toggleConsoleOutput();
  void saveAs();

private:
  int         _id[DebugLevel::Nb_Types];
  QPopupMenu *_popup;
  QString     _text;

  virtual void updateDebugLevel();
  virtual void doLog(LineType type, const QString &text, Action action = Immediate);
  virtual void doLog(DebugLevel level, const QString &text, Action action = Immediate);
  void doLog(const QString &text, const QString &color, bool bold, Action action = Immediate);
  void logExtra(const QString &text);
};

} // namespace

#endif