#include <messagelog.h>
Public Member Functions | |
MessageLog (QWidget *parent=0, Qt::WFlags flags=0) | |
~MessageLog () | |
Protected Member Functions | |
void | customEvent (QEvent *event) |
void | resizeEvent (QResizeEvent *event) |
Private Slots | |
void | saveAll () |
void | saveSelected () |
void | copy () |
void | find () |
void | saveSettings () |
void | cancelChanges () |
void | browse () |
void | help () |
Private Member Functions | |
void | createActions () |
void | setToolTips () |
void | loadSettings () |
void | registerLogEvents () |
void | save (QStringList messages) |
void | log (LogEvent::Severity, QString msg) |
bool | rotateLogFile (QString filename) |
Private Attributes | |
TorControl * | _torControl |
VidaliaSettings * | _settings |
uint | _filter |
bool | _enableLogging |
LogFile | _logFile |
Ui::MessageLog | ui |
Definition at line 43 of file messagelog.h.
MessageLog::MessageLog | ( | QWidget * | parent = 0 , |
|
Qt::WFlags | flags = 0 | |||
) |
Default constructor
Constructor. The constructor will load the message log's settings from VidaliSettings and register for log events according to the most recently set severity filter.
torControl | A TorControl object used to register for log events. | |
parent | The parent widget of this MessageLog object. | |
flags | Any desired window creation flags. |
Definition at line 66 of file messagelog.cpp.
References _torControl, createActions(), loadSettings(), setToolTips(), LogTreeWidget::TimeColumn, Vidalia::torControl(), and ui.
MessageLog::~MessageLog | ( | ) |
Default destructor
Default Destructor. Simply frees up any memory allocated for member variables.
Definition at line 91 of file messagelog.cpp.
References _logFile, and LogFile::close().
void MessageLog::customEvent | ( | QEvent * | event | ) | [protected] |
Called to deliver custom event types
Custom event handler. Checks if the event is a log event. If it is, then it will write the message to the message log.
event | The custom log event. |
Definition at line 426 of file messagelog.cpp.
References log(), CustomEventType::LogEvent, LogEvent::message(), and LogEvent::severity().
void MessageLog::saveAll | ( | ) | [private, slot] |
Called when the user triggers the save all action
Saves all shown messages to a file.
Definition at line 349 of file messagelog.cpp.
Referenced by createActions().
void MessageLog::saveSelected | ( | ) | [private, slot] |
Called when the user triggers save selected action
Saves currently selected messages to a file.
Definition at line 342 of file messagelog.cpp.
Referenced by createActions().
void MessageLog::copy | ( | ) | [private, slot] |
Called when the user triggers the copy action
Copies contents of currently selected messages to the 'clipboard'.
Definition at line 356 of file messagelog.cpp.
References ui.
Referenced by createActions().
void MessageLog::find | ( | ) | [private, slot] |
Called when the user triggers the find action. This will search through all currently displayed log entries for text specified by the user, highlighting the entries that contain a match.
Prompts the user for a search string. If the search string is not found in any of the currently displayed log entires, then a message will be displayed for the user informing them that no matches were found.
Definition at line 373 of file messagelog.cpp.
References VMessageBox::information(), VMessageBox::Ok, p(), and ui.
Referenced by createActions().
void MessageLog::saveSettings | ( | ) | [private, slot] |
Called when user saves settings
Saves the Message Log settings, adjusts the message list if required, and then hides the settings frame.
Definition at line 234 of file messagelog.cpp.
References _enableLogging, _filter, _logFile, ADD_TO_FILTER, LogEvent::Debug, LogEvent::Error, LogEvent::Info, LogFile::isOpen(), LogEvent::Notice, VMessageBox::Ok, p(), registerLogEvents(), rotateLogFile(), VidaliaWindow::saveSetting(), SETTING_ENABLE_LOGFILE, SETTING_LOGFILE, SETTING_MAX_MSG_COUNT, SETTING_MSG_FILTER, ui, LogEvent::Warn, and VMessageBox::warning().
Referenced by createActions().
void MessageLog::cancelChanges | ( | ) | [private, slot] |
Called when user cancels changed settings
Simply restores the previously saved settings and hides the settings frame.
Definition at line 279 of file messagelog.cpp.
References loadSettings(), and ui.
Referenced by createActions().
void MessageLog::browse | ( | ) | [private, slot] |
Called when the user clicks "Browse" to select a new log file.
Definition at line 289 of file messagelog.cpp.
References ui.
Referenced by createActions().
void MessageLog::help | ( | ) | [private, slot] |
Called when the user clicks "Help" to see help info about the log.
Displays help information about the message log.
Definition at line 437 of file messagelog.cpp.
References Vidalia::help().
Referenced by createActions().
void MessageLog::resizeEvent | ( | QResizeEvent * | event | ) | [protected] |
Responds to the user resizing the message log.
Definition at line 98 of file messagelog.cpp.
References ui.
void MessageLog::createActions | ( | ) | [private] |
Create and bind actions to events
Binds events (signals) to actions (slots).
Definition at line 108 of file messagelog.cpp.
References browse(), cancelChanges(), copy(), find(), help(), saveAll(), saveSelected(), saveSettings(), and ui.
Referenced by MessageLog().
void MessageLog::setToolTips | ( | ) | [private] |
Set Tool Tips for various widgets
Set tooltips for Message Filter checkboxes in code because they are long and Designer wouldn't let us insert newlines into the text.
Definition at line 145 of file messagelog.cpp.
References ui.
Referenced by MessageLog().
void MessageLog::loadSettings | ( | ) | [private] |
Loads the saved Message Log settings
Definition at line 163 of file messagelog.cpp.
References _enableLogging, _filter, _logFile, LogEvent::Debug, DEFAULT_ENABLE_LOGFILE, DEFAULT_LOGFILE, DEFAULT_MAX_MSG_COUNT, DEFAULT_MSG_FILTER, LogEvent::Error, VidaliaWindow::getSetting(), LogEvent::Info, LogFile::isOpen(), LogEvent::Notice, registerLogEvents(), rotateLogFile(), SETTING_ENABLE_LOGFILE, SETTING_LOGFILE, SETTING_MAX_MSG_COUNT, SETTING_MSG_FILTER, ui, and LogEvent::Warn.
Referenced by cancelChanges(), and MessageLog().
void MessageLog::registerLogEvents | ( | ) | [private] |
Registers the current message filter with Tor
Attempts to register the selected message filter with Tor and displays an error if setting the events fails.
Definition at line 198 of file messagelog.cpp.
References _filter, _torControl, DEFAULT_MSG_FILTER, VidaliaWindow::getSetting(), VMessageBox::Ok, p(), TorControl::setLogEvents(), SETTING_MSG_FILTER, and VMessageBox::warning().
Referenced by loadSettings(), and saveSettings().
void MessageLog::save | ( | QStringList | messages | ) | [private] |
Saves the given list of items to a file
Saves the given list of items to a file.
items | A list of log message items to save. |
Definition at line 304 of file messagelog.cpp.
References VMessageBox::Ok, LogFile::open(), p(), and VMessageBox::warning().
Referenced by saveAll(), and saveSelected().
void MessageLog::log | ( | LogEvent::Severity | type, | |
QString | message | |||
) | [private] |
Adds the passed message to the message log as the specified type
Writes a message to the Message History and tags it with the proper date, time and type.
type | The message's severity type. | |
message | The log message to be added. |
Definition at line 399 of file messagelog.cpp.
References _enableLogging, _filter, _logFile, LogTreeItem::toString(), and ui.
Referenced by customEvent().
bool MessageLog::rotateLogFile | ( | QString | filename | ) | [private] |
Rotates the log file based on the filename and the current logging status.
Opens a log file if necessary, or closes it if logging is disabled. If a log file is already opened and a new filename is specified, then the log file will be rotated to the new filename. In the case that the new filename can not be openend, the old file will remain open and writable.
Definition at line 214 of file messagelog.cpp.
References _enableLogging, _logFile, LogFile::close(), VMessageBox::Ok, LogFile::open(), p(), and VMessageBox::warning().
Referenced by loadSettings(), and saveSettings().
TorControl* MessageLog::_torControl [private] |
A pointer to a TorControl object, used to register for log events
Definition at line 98 of file messagelog.h.
Referenced by MessageLog(), and registerLogEvents().
VidaliaSettings* MessageLog::_settings [private] |
A VidaliaSettings object that handles getting/saving settings
Reimplemented from VidaliaWindow.
Definition at line 100 of file messagelog.h.
uint MessageLog::_filter [private] |
Stores the current message filter
Definition at line 102 of file messagelog.h.
Referenced by loadSettings(), log(), registerLogEvents(), and saveSettings().
bool MessageLog::_enableLogging [private] |
Set to true if we will log all messages to a file.
Definition at line 104 of file messagelog.h.
Referenced by loadSettings(), log(), rotateLogFile(), and saveSettings().
LogFile MessageLog::_logFile [private] |
Definition at line 106 of file messagelog.h.
Referenced by loadSettings(), log(), rotateLogFile(), saveSettings(), and ~MessageLog().
Ui::MessageLog MessageLog::ui [private] |
Qt Designer generatated QObject
Definition at line 109 of file messagelog.h.
Referenced by browse(), cancelChanges(), copy(), createActions(), find(), loadSettings(), log(), MessageLog(), resizeEvent(), saveAll(), saveSelected(), saveSettings(), and setToolTips().