[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[vidalia-svn] r1371: Turn message log items into strings before displaying the sa (trunk/src/gui/log)
Author: edmanm
Date: 2006-10-22 03:19:36 -0400 (Sun, 22 Oct 2006)
New Revision: 1371
Modified:
trunk/src/gui/log/logtreewidget.cpp
trunk/src/gui/log/logtreewidget.h
trunk/src/gui/log/messagelog.cpp
trunk/src/gui/log/messagelog.h
Log:
Turn message log items into strings before displaying the save dialog box,
since the items themselves could've been removed while the user is picking a
filename. And then we'd crash.
Modified: trunk/src/gui/log/logtreewidget.cpp
===================================================================
--- trunk/src/gui/log/logtreewidget.cpp 2006-10-22 04:56:44 UTC (rev 1370)
+++ trunk/src/gui/log/logtreewidget.cpp 2006-10-22 07:19:36 UTC (rev 1371)
@@ -126,33 +126,37 @@
}
/** Returns a list of all currently selected items. */
-QList<LogTreeItem *>
+QStringList
LogTreeWidget::selectedMessages()
{
+ QStringList messages;
+
+ /* Get all selected log items */
QList<LogTreeItem *> items =
qlist_cast(selectedItems());
- return qlist_sort(items);
-}
-
-/** Returns a list of all selected items as a formatted string. */
-QString
-LogTreeWidget::selectedMessagesText()
-{
- QString text;
- foreach (LogTreeItem *item, selectedMessages()) {
- text.append(item->toString());
+
+ /* Format the message items as strings and put them in a list */
+ foreach (LogTreeItem *item, qlist_sort(items)) {
+ messages << item->toString();
}
- return text;
+ return messages;
}
/** Returns a list of all items in the tree. */
-QList<LogTreeItem *>
+QStringList
LogTreeWidget::allMessages()
{
+ QStringList messages;
+
/* Find all items */
QList<LogTreeItem *> items =
qlist_cast(findItems("*", Qt::MatchWildcard|Qt::MatchWrap, MessageColumn));
- return qlist_sort(items);
+
+ /* Format the message items as strings and put them in a list */
+ foreach (LogTreeItem *item, qlist_sort(items)) {
+ messages << item->toString();
+ }
+ return messages;
}
/** Returns the number of items currently shown. */
@@ -178,7 +182,7 @@
void
LogTreeWidget::deselectAll()
{
- foreach(LogTreeItem *item, selectedMessages()) {
+ foreach(QTreeWidgetItem *item, selectedItems()) {
setItemSelected(item, false);
}
}
Modified: trunk/src/gui/log/logtreewidget.h
===================================================================
--- trunk/src/gui/log/logtreewidget.h 2006-10-22 04:56:44 UTC (rev 1370)
+++ trunk/src/gui/log/logtreewidget.h 2006-10-22 07:19:36 UTC (rev 1371)
@@ -30,6 +30,7 @@
#include <QList>
#include <QString>
+#include <QStringList>
#include <QTreeWidget>
#include <QHeaderView>
#include <QShowEvent>
@@ -43,7 +44,6 @@
Q_OBJECT
public:
-
/** Log tree column indices. */
enum LogColumns {
TimeColumn = 0, /**< Timestamp column. */
@@ -53,15 +53,12 @@
/** Default constructor. */
LogTreeWidget(QWidget *parent = 0);
-
- /** Returns a list of all currently selected items. */
- QList<LogTreeItem *> selectedMessages();
- /** Returns a list of all selected items as a formatted string. */
- QString selectedMessagesText();
- /** Returns a list of all items in the tree. */
- QList<LogTreeItem *> allMessages();
- /** Deselects all currently selected items. */
+ /** Returns a list of all currently selected messages. */
+ QStringList selectedMessages();
+ /** Returns a list of all messages in the tree. */
+ QStringList allMessages();
+ /** Deselects all currently selected messages. */
void deselectAll();
/** Returns the number of items currently in the tree. */
Modified: trunk/src/gui/log/messagelog.cpp
===================================================================
--- trunk/src/gui/log/messagelog.cpp 2006-10-22 04:56:44 UTC (rev 1370)
+++ trunk/src/gui/log/messagelog.cpp 2006-10-22 07:19:36 UTC (rev 1371)
@@ -289,9 +289,9 @@
* \param items A list of log message items to save.
*/
void
-MessageLog::save(QList<LogTreeItem *> items)
+MessageLog::save(QStringList messages)
{
- if (!items.size()) {
+ if (!messages.size()) {
return;
}
@@ -318,8 +318,8 @@
/* Write out the message log to the file */
QApplication::setOverrideCursor(Qt::WaitCursor);
- foreach (LogTreeItem *item, items) {
- logFile << item->toString();
+ foreach (QString msg, messages) {
+ logFile << msg;
}
QApplication::restoreOverrideCursor();
}
@@ -343,7 +343,7 @@
void
MessageLog::copy()
{
- QString contents = ui.lstMessages->selectedMessagesText();
+ QString contents = ui.lstMessages->selectedMessages().join("");
if (!contents.isEmpty()) {
/* Clear anything on the clipboard */
QApplication::clipboard()->clear();
Modified: trunk/src/gui/log/messagelog.h
===================================================================
--- trunk/src/gui/log/messagelog.h 2006-10-22 04:56:44 UTC (rev 1370)
+++ trunk/src/gui/log/messagelog.h 2006-10-22 07:19:36 UTC (rev 1371)
@@ -29,6 +29,7 @@
#define _MESSAGELOG_H
#include <QMainWindow>
+#include <QStringList>
#include <QResizeEvent>
#include <control/torcontrol.h>
#include <config/vidaliasettings.h>
@@ -87,7 +88,7 @@
/** Registers the current message filter with Tor */
void registerLogEvents();
/** Saves the given list of items to a file */
- void save(QList<LogTreeItem *> items);
+ void save(QStringList messages);
/** Adds the passed message to the message log as the specified type **/
void log(LogEvent::Severity, QString msg);
/** Rotates the log file based on the filename and the current logging status. */