Vidalia  0.3.1
Public Member Functions | Protected Member Functions | Private Slots | Private Member Functions | Private Attributes | List of all members
MessageLog Class Reference

#include <MessageLog.h>

Inheritance diagram for MessageLog:
VidaliaTab

Public Member Functions

 MessageLog (QStatusBar *st=0, QWidget *parent=0)
 
 ~MessageLog ()
 
- Public Member Functions inherited from VidaliaTab
 VidaliaTab (const QString &title, const QString &name="", QWidget *parent=0)
 
 ~VidaliaTab ()
 
QString getTitle () const
 
void setTitle (const QString &title)
 
void setShortcut (const QString &shortcut, const char *slot)
 
QVariant getSetting (QString name, QVariant defaultValue)
 
void saveSetting (QString name, QVariant value)
 
void setOnTop (bool top)
 

Protected Member Functions

virtual void retranslateUi ()
 
- Protected Member Functions inherited from VidaliaTab
virtual void changeEvent (QEvent *e)
 
virtual void closeEvent (QCloseEvent *event)
 

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
 
QStatusBar * _statusBar
 
Ui::MessageLog ui
 

Additional Inherited Members

- Signals inherited from VidaliaTab
void helpRequested (const QString &topic)
 
void closeTab ()
 
- Protected Attributes inherited from VidaliaTab
bool _onTop
 

Detailed Description

Definition at line 28 of file MessageLog.h.

Constructor & Destructor Documentation

MessageLog::MessageLog ( QStatusBar *  st = 0,
QWidget *  parent = 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.

Parameters
torControlA TorControl object used to register for log events.
parentThe parent widget of this MessageLog object.
flagsAny desired window creation flags.

Definition at line 59 of file MessageLog.cpp.

References _torControl, connect(), 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 89 of file MessageLog.cpp.

References _logFile, and LogFile::close().

Member Function Documentation

void MessageLog::browse ( )
privateslot

Called when the user clicks "Browse" to select a new log file.

Definition at line 315 of file MessageLog.cpp.

References ui.

Referenced by createActions().

void MessageLog::cancelChanges ( )
privateslot

Called when user cancels changed settings

Simply restores the previously saved settings and hides the settings frame.

Definition at line 305 of file MessageLog.cpp.

References loadSettings(), and ui.

Referenced by createActions().

void MessageLog::clear ( )
privateslot

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 403 of file MessageLog.cpp.

References ui.

Referenced by createActions().

void MessageLog::copy ( )
privateslot

Called when the user triggers the "Copy" action.

Copies contents of currently selected messages to the 'clipboard'.

Definition at line 388 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 96 of file MessageLog.cpp.

References browse(), cancelChanges(), clear(), connect(), copy(), Vidalia::createShortcut(), find(), help(), saveAll(), saveSelected(), saveSettings(), selectAll(), and ui.

Referenced by MessageLog().

void MessageLog::find ( )
privateslot

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.

See Also
search()

Definition at line 414 of file MessageLog.cpp.

References VMessageBox::information(), VMessageBox::Ok, p(), and ui.

Referenced by createActions().

void MessageLog::help ( )
privateslot

Called when the user clicks "Help" to see help info about the log.

Displays help information about the message log.

Definition at line 475 of file MessageLog.cpp.

References VidaliaTab::helpRequested().

Referenced by createActions().

void MessageLog::loadSettings ( )
private
void MessageLog::log ( tc::Severity  type,
const QString &  message 
)
privateslot

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.

Parameters
typeThe message's severity type.
messageThe log message to be added.

Definition at line 447 of file MessageLog.cpp.

References _enableLogging, _filter, _logFile, VidaliaTab::_onTop, _statusBar, LogTreeItem::toString(), and ui.

Referenced by MessageLog().

void MessageLog::registerLogEvents ( )
private
void MessageLog::retranslateUi ( )
protectedvirtual

Called when the user changes the UI translation.

Reimplemented from VidaliaTab.

Definition at line 169 of file MessageLog.cpp.

References VidaliaTab::setTitle(), 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 240 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.

Parameters
itemsA list of log message items to save.

Definition at line 330 of file MessageLog.cpp.

References VMessageBox::Ok, LogFile::open(), p(), and VMessageBox::warning().

Referenced by saveAll(), and saveSelected().

void MessageLog::saveAll ( )
privateslot

Called when the user triggers the "Save All" action.

Saves all shown messages to a file.

Definition at line 375 of file MessageLog.cpp.

References save(), and ui.

Referenced by createActions().

void MessageLog::saveSelected ( )
privateslot

Called when the user triggers "Save Selected" action.

Saves currently selected messages to a file.

Definition at line 368 of file MessageLog.cpp.

References save(), and ui.

Referenced by createActions().

void MessageLog::saveSettings ( )
privateslot

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 260 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(), VidaliaTab::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 ( )
privateslot

Called when the user triggers the "Select All" action.

Definition at line 381 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 151 of file MessageLog.cpp.

References ui.

Referenced by MessageLog(), and retranslateUi().

Member Data Documentation

bool MessageLog::_enableLogging
private

Set to true if we will log all messages to a file.

Definition at line 89 of file MessageLog.h.

Referenced by loadSettings(), log(), rotateLogFile(), and saveSettings().

uint MessageLog::_filter
private

Stores the current message filter

Definition at line 87 of file MessageLog.h.

Referenced by loadSettings(), log(), registerLogEvents(), and saveSettings().

LogFile MessageLog::_logFile
private

Definition at line 91 of file MessageLog.h.

Referenced by loadSettings(), log(), rotateLogFile(), saveSettings(), and ~MessageLog().

VidaliaSettings* MessageLog::_settings
private

A VidaliaSettings object that handles getting/saving settings

Definition at line 85 of file MessageLog.h.

QStatusBar* MessageLog::_statusBar
private

Definition at line 93 of file MessageLog.h.

Referenced by log().

TorControl* MessageLog::_torControl
private

A pointer to a TorControl object, used to register for log events

Definition at line 83 of file MessageLog.h.

Referenced by MessageLog(), and registerLogEvents().

Ui::MessageLog MessageLog::ui
private

The documentation for this class was generated from the following files: