Vidalia  0.3.1
MessageLog.h
Go to the documentation of this file.
1 /*
2 ** This file is part of Vidalia, and is subject to the license terms in the
3 ** LICENSE file, found in the top level directory of this distribution. If you
4 ** did not receive the LICENSE file with this file, you may obtain it from the
5 ** Vidalia source package distributed by the Vidalia Project at
6 ** http://www.torproject.org/projects/vidalia.html. No part of Vidalia,
7 ** including this file, may be copied, modified, propagated, or distributed
8 ** except according to the terms described in the LICENSE file.
9 */
10 
11 /*
12 ** \file MessageLog.h
13 ** \brief Displays log messages and message log settings
14 */
15 
16 #ifndef _MESSAGELOG_H
17 #define _MESSAGELOG_H
18 
19 #include "ui_MessageLog.h"
20 #include "VidaliaTab.h"
21 #include "LogFile.h"
22 #include "TorControl.h"
23 #include "VidaliaSettings.h"
24 
25 class LogTreeItem;
26 class QStringList;
27 
28 class MessageLog : public VidaliaTab
29 {
30  Q_OBJECT
31 
32 public:
33  /** Default constructor **/
34  MessageLog(QStatusBar *st = 0, QWidget *parent = 0);
35  /** Default destructor **/
36  ~MessageLog();
37 
38 protected:
39  /** Called when the user changes the UI translation. */
40  virtual void retranslateUi();
41 
42 private slots:
43  /** Adds the passed message to the message log as the specified type **/
44  void log(tc::Severity severity, const QString &msg);
45  /** Called when the user triggers the "Save All" action. */
46  void saveAll();
47  /** Called when the user triggers "Save Selected" action. */
48  void saveSelected();
49  /** Called when the user triggers the "Select All" action. */
50  void selectAll();
51  /** Called when the user triggers the "Copy" action. */
52  void copy();
53  /** Called when the user triggers the "Clear" action. */
54  void clear();
55  /** Called when the user triggers the "Find" action. This will search
56  * through all currently displayed log entries for text specified by the
57  * user, highlighting the entries that contain a match. */
58  void find();
59  /** Called when user saves settings **/
60  void saveSettings();
61  /** Called when user cancels changed settings **/
62  void cancelChanges();
63  /** Called when the user clicks "Browse" to select a new log file. */
64  void browse();
65  /** Called when the user clicks "Help" to see help info about the log. */
66  void help();
67 
68 private:
69  /** Create and bind actions to events **/
70  void createActions();
71  /** Set Tool Tips for various widgets **/
72  void setToolTips();
73  /** Loads the saved Message Log settings **/
74  void loadSettings();
75  /** Registers the current message filter with Tor */
76  void registerLogEvents();
77  /** Saves the given list of items to a file */
78  void save(const QStringList &messages);
79  /** Rotates the log file based on the filename and the current logging status. */
80  bool rotateLogFile(const QString &filename);
81 
82  /** A pointer to a TorControl object, used to register for log events */
84  /** A VidaliaSettings object that handles getting/saving settings **/
86  /** Stores the current message filter */
87  uint _filter;
88  /** Set to true if we will log all messages to a file. */
90  /* The log file used to store log messages. */
92 
93  QStatusBar *_statusBar;
94 
95  /** Qt Designer generatated QObject **/
96  Ui::MessageLog ui;
97 };
98 
99 #endif
100 
void registerLogEvents()
Definition: MessageLog.cpp:213
void loadSettings()
Definition: MessageLog.cpp:178
VidaliaSettings * _settings
Definition: MessageLog.h:85
TorControl * _torControl
Definition: MessageLog.h:83
uint _filter
Definition: MessageLog.h:87
void saveSelected()
Definition: MessageLog.cpp:368
void log(tc::Severity severity, const QString &msg)
Definition: MessageLog.cpp:447
Ui::MessageLog ui
Definition: MessageLog.h:96
void save(const QStringList &messages)
Definition: MessageLog.cpp:330
void browse()
Definition: MessageLog.cpp:315
void clear()
Definition: MessageLog.cpp:403
void find()
Definition: MessageLog.cpp:414
void copy()
Definition: MessageLog.cpp:388
bool rotateLogFile(const QString &filename)
Definition: MessageLog.cpp:240
void saveAll()
Definition: MessageLog.cpp:375
bool _enableLogging
Definition: MessageLog.h:89
void help()
Definition: MessageLog.cpp:475
void saveSettings()
Definition: MessageLog.cpp:260
void selectAll()
Definition: MessageLog.cpp:381
Severity
Definition: tcglobal.h:69
void cancelChanges()
Definition: MessageLog.cpp:305
QStatusBar * _statusBar
Definition: MessageLog.h:93
MessageLog(QStatusBar *st=0, QWidget *parent=0)
Definition: MessageLog.cpp:59
void setToolTips()
Definition: MessageLog.cpp:151
LogFile _logFile
Definition: MessageLog.h:91
virtual void retranslateUi()
Definition: MessageLog.cpp:169
void createActions()
Definition: MessageLog.cpp:96