[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[vidalia-svn] r4090: Add the ability to search the status event list based on eve (vidalia/trunk/src/vidalia/log)
Author: edmanm
Date: 2009-08-29 21:48:36 -0400 (Sat, 29 Aug 2009)
New Revision: 4090
Modified:
vidalia/trunk/src/vidalia/log/MessageLog.cpp
vidalia/trunk/src/vidalia/log/StatusEventWidget.cpp
vidalia/trunk/src/vidalia/log/StatusEventWidget.h
Log:
Add the ability to search the status event list based on event title and
description.
Modified: vidalia/trunk/src/vidalia/log/MessageLog.cpp
===================================================================
--- vidalia/trunk/src/vidalia/log/MessageLog.cpp 2009-08-30 01:46:25 UTC (rev 4089)
+++ vidalia/trunk/src/vidalia/log/MessageLog.cpp 2009-08-30 01:48:36 UTC (rev 4090)
@@ -15,6 +15,7 @@
*/
#include "MessageLog.h"
+#include "StatusEventItem.h"
#include "Vidalia.h"
#include "VMessageBox.h"
@@ -167,7 +168,6 @@
ui.actionSave_Selected->setEnabled(isAdvancedTabVisible);
ui.actionSave_All->setEnabled(isAdvancedTabVisible);
- ui.actionFind->setEnabled(isAdvancedTabVisible);
}
/** Loads the saved Message Log settings */
@@ -426,15 +426,30 @@
tr("Find:"), QLineEdit::Normal, QString(), &ok);
if (ok && !text.isEmpty()) {
- /* Search for the user-specified text */
- QList<LogTreeItem *> results = ui.listMessages->find(text);
- if (!results.size()) {
+ QTreeWidget *tree;
+ QTreeWidgetItem *firstItem = 0;
+
+ /* Pick the right tree widget to search based on the current tab */
+ if (ui.tabWidget->currentIndex() == 0) {
+ QList<StatusEventItem *> results = ui.listNotifications->find(text, true);
+ if (results.size() > 0) {
+ tree = ui.listNotifications;
+ firstItem = dynamic_cast<QTreeWidgetItem *>(results.at(0));
+ }
+ } else {
+ QList<LogTreeItem *> results = ui.listMessages->find(text, true);
+ if (results.size() > 0) {
+ tree = ui.listMessages;
+ firstItem = dynamic_cast<QTreeWidgetItem *>(results.at(0));
+ }
+ }
+
+ if (! firstItem) {
VMessageBox::information(this, tr("Not Found"),
p(tr("Search found 0 matches.")),
VMessageBox::Ok);
} else {
- /* Set the focus to the first match */
- ui.listMessages->scrollToItem(results.at(0));
+ tree->scrollToItem(firstItem);
}
}
}
Modified: vidalia/trunk/src/vidalia/log/StatusEventWidget.cpp
===================================================================
--- vidalia/trunk/src/vidalia/log/StatusEventWidget.cpp 2009-08-30 01:46:25 UTC (rev 4089)
+++ vidalia/trunk/src/vidalia/log/StatusEventWidget.cpp 2009-08-30 01:48:36 UTC (rev 4090)
@@ -139,6 +139,28 @@
return out;
}
+QList<StatusEventItem *>
+StatusEventWidget::find(const QString &text, bool highlight)
+{
+ QList<StatusEventItem *> items;
+
+ for (int i = 0; i < topLevelItemCount(); i++) {
+ StatusEventItem *item = dynamic_cast<StatusEventItem *>(topLevelItem(i));
+ if (! item)
+ continue;
+
+ if (item->title().contains(text, Qt::CaseInsensitive)
+ || item->description().contains(text, Qt::CaseInsensitive)) {
+ items.append(item);
+ if (highlight)
+ item->setSelected(true);
+ } else if (highlight) {
+ item->setSelected(false);
+ }
+ }
+ return items;
+}
+
void
StatusEventWidget::addNotification(const QPixmap &icon,
const QString &title,
Modified: vidalia/trunk/src/vidalia/log/StatusEventWidget.h
===================================================================
--- vidalia/trunk/src/vidalia/log/StatusEventWidget.h 2009-08-30 01:46:25 UTC (rev 4089)
+++ vidalia/trunk/src/vidalia/log/StatusEventWidget.h 2009-08-30 01:48:36 UTC (rev 4090)
@@ -21,10 +21,14 @@
#include "TorControl.h"
+#include <QList>
+
class QPixmap;
class QString;
class QStringList;
+class StatusEventItem;
+
class StatusEventWidget : public QTreeWidget
{
Q_OBJECT
@@ -51,6 +55,14 @@
*/
QStringList selectedEvents() const;
+ /** Searches the list of current status event items for any items that
+ * contain <b>text</b> in either the event title or description. Searching
+ * is done case-insensitively. If <b>highlight</b> is true, any previously
+ * selected items will be deselected and the matching items will be
+ * highlighted. Returns a (possibly empty) list of matching items.
+ */
+ QList<StatusEventItem *> find(const QString &text, bool highlight = true);
+
protected:
/** Called when the user has changed the UI display language in Vidalia
* indicating all the displayed text widgets need to be updated to