#include <MessageLog.h>
Public Member Functions | |
MessageLog (QWidget *parent=0, Qt::WFlags flags=0) | |
~MessageLog () | |
Protected Member Functions | |
virtual void | retranslateUi () |
Private Slots | |
void | log (tc::Severity severity, const QString &msg) |
void | saveAll () |
void | saveSelected () |
void | selectAll () |
void | copy () |
void | clear () |
void | find () |
void | saveSettings () |
void | cancelChanges () |
void | browse () |
void | help () |
Private Member Functions | |
void | createActions () |
void | setToolTips () |
void | loadSettings () |
void | registerLogEvents () |
void | save (const QStringList &messages) |
bool | rotateLogFile (const QString &filename) |
Private Attributes | |
TorControl * | _torControl |
VidaliaSettings * | _settings |
uint | _filter |
bool | _enableLogging |
LogFile | _logFile |
Ui::MessageLog | ui |
Definition at line 29 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 58 of file MessageLog.cpp.
References _torControl, createActions(), loadSettings(), log(), 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 86 of file MessageLog.cpp.
References _logFile, and LogFile::close().
void MessageLog::browse | ( | ) | [private, slot] |
Called when the user clicks "Browse" to select a new log file.
Definition at line 300 of file MessageLog.cpp.
References ui.
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 290 of file MessageLog.cpp.
References loadSettings(), and ui.
Referenced by createActions().
void MessageLog::clear | ( | ) | [private, slot] |
Called when the user triggers the "Clear" action.
Clears all log messages or status notifications, depending on which tab is currently visible.
Definition at line 400 of file MessageLog.cpp.
References ui.
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 382 of file MessageLog.cpp.
References ui.
Referenced by createActions().
void MessageLog::createActions | ( | ) | [private] |
Create and bind actions to events
Binds events (signals) to actions (slots).
Definition at line 93 of file MessageLog.cpp.
References browse(), cancelChanges(), clear(), copy(), Vidalia::createShortcut(), find(), help(), saveAll(), saveSelected(), saveSettings(), selectAll(), and ui.
Referenced by MessageLog().
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 414 of file MessageLog.cpp.
References VMessageBox::information(), VMessageBox::Ok, p(), and 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 479 of file MessageLog.cpp.
References VidaliaWindow::helpRequested().
Referenced by createActions().
void MessageLog::loadSettings | ( | ) | [private] |
Loads the saved Message Log settings
Definition at line 161 of file MessageLog.cpp.
References _enableLogging, _filter, _logFile, tc::DebugSeverity, DEFAULT_ENABLE_LOGFILE, DEFAULT_LOGFILE, DEFAULT_MAX_MSG_COUNT, DEFAULT_MSG_FILTER, tc::ErrorSeverity, VidaliaWindow::getSetting(), tc::InfoSeverity, LogFile::isOpen(), tc::NoticeSeverity, registerLogEvents(), rotateLogFile(), SETTING_ENABLE_LOGFILE, SETTING_LOGFILE, SETTING_MAX_MSG_COUNT, SETTING_MSG_FILTER, ui, and tc::WarnSeverity.
Referenced by cancelChanges(), and MessageLog().
void MessageLog::log | ( | tc::Severity | type, | |
const QString & | message | |||
) | [private, slot] |
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 455 of file MessageLog.cpp.
References _enableLogging, _filter, _logFile, LogTreeItem::toString(), and ui.
Referenced by 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 197 of file MessageLog.cpp.
References _filter, _torControl, tc::DebugSeverity, DEFAULT_MSG_FILTER, tc::ErrorSeverity, VidaliaWindow::getSetting(), tc::InfoSeverity, TorControl::isConnected(), TorEvents::LogDebug, TorEvents::LogError, TorEvents::LogInfo, TorEvents::LogNotice, TorEvents::LogWarn, tc::NoticeSeverity, VMessageBox::Ok, p(), TorControl::setEvent(), TorControl::setEvents(), SETTING_MSG_FILTER, VMessageBox::warning(), and tc::WarnSeverity.
Referenced by loadSettings(), and saveSettings().
void MessageLog::retranslateUi | ( | ) | [protected, virtual] |
Called when the user changes the UI translation.
Reimplemented from VidaliaWindow.
Definition at line 153 of file MessageLog.cpp.
References setToolTips(), and ui.
bool MessageLog::rotateLogFile | ( | const 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 224 of file MessageLog.cpp.
References _enableLogging, _logFile, LogFile::close(), VMessageBox::Ok, LogFile::open(), p(), and VMessageBox::warning().
Referenced by loadSettings(), and saveSettings().
void MessageLog::save | ( | const 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 315 of file MessageLog.cpp.
References VMessageBox::Ok, LogFile::open(), p(), and VMessageBox::warning().
Referenced by saveAll(), and saveSelected().
void MessageLog::saveAll | ( | ) | [private, slot] |
Called when the user triggers the "Save All" action.
Saves all shown messages to a file.
Definition at line 363 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 353 of file MessageLog.cpp.
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 244 of file MessageLog.cpp.
References _enableLogging, _filter, _logFile, ADD_TO_FILTER, tc::DebugSeverity, tc::ErrorSeverity, tc::InfoSeverity, LogFile::isOpen(), tc::NoticeSeverity, VMessageBox::Ok, p(), registerLogEvents(), rotateLogFile(), VidaliaWindow::saveSetting(), SETTING_ENABLE_LOGFILE, SETTING_LOGFILE, SETTING_MAX_MSG_COUNT, SETTING_MSG_FILTER, ui, VMessageBox::warning(), and tc::WarnSeverity.
Referenced by createActions().
void MessageLog::selectAll | ( | ) | [private, slot] |
Called when the user triggers the "Select All" action.
Definition at line 372 of file MessageLog.cpp.
References ui.
Referenced by createActions().
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 135 of file MessageLog.cpp.
References ui.
Referenced by MessageLog(), and retranslateUi().
bool MessageLog::_enableLogging [private] |
Set to true if we will log all messages to a file.
Definition at line 90 of file MessageLog.h.
Referenced by loadSettings(), log(), rotateLogFile(), and saveSettings().
uint MessageLog::_filter [private] |
Stores the current message filter
Definition at line 88 of file MessageLog.h.
Referenced by loadSettings(), log(), registerLogEvents(), and saveSettings().
LogFile MessageLog::_logFile [private] |
Definition at line 92 of file MessageLog.h.
Referenced by loadSettings(), log(), rotateLogFile(), saveSettings(), and ~MessageLog().
VidaliaSettings* MessageLog::_settings [private] |
A VidaliaSettings object that handles getting/saving settings
Reimplemented from VidaliaWindow.
Definition at line 86 of file MessageLog.h.
TorControl* MessageLog::_torControl [private] |
A pointer to a TorControl object, used to register for log events
Definition at line 84 of file MessageLog.h.
Referenced by MessageLog(), and registerLogEvents().
Ui::MessageLog MessageLog::ui [private] |
Qt Designer generatated QObject
Definition at line 95 of file MessageLog.h.
Referenced by browse(), cancelChanges(), clear(), copy(), createActions(), find(), loadSettings(), log(), MessageLog(), retranslateUi(), saveAll(), saveSelected(), saveSettings(), selectAll(), and setToolTips().