Changeset 224
- Timestamp:
- 02/02/06 18:55:23 (3 years ago)
- Location:
- trunk/src/gui/messagelog
- Files:
-
- 3 modified
-
messagelog.cpp (modified) (4 diffs)
-
messagelog.h (modified) (2 diffs)
-
messagelog.ui (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/gui/messagelog/messagelog.cpp
r212 r224 22 22 ****************************************************************/ 23 23 24 #include <QMessageBox> 25 #include <QInputDialog> 26 24 27 #include "../mainwindow.h" 25 28 #include "messagelog.h" … … 104 107 this, SLOT(clear())); 105 108 109 connect(ui.actionFind, SIGNAL(triggered()), 110 this, SLOT(find())); 111 106 112 connect(ui.btnSaveSettings, SIGNAL(clicked()), 107 113 this, SLOT(saveChanges())); … … 387 393 } 388 394 395 /** Prompts the user for a search string. If the search string is not found in 396 * any of the currently displayed log entires, then a message will be 397 * displayed for the user informing them that no matches were found. 398 * \sa search() 399 */ 400 void 401 MessageLog::find() 402 { 403 QString empty; 404 bool ok; 405 QString text = QInputDialog::getText(this, tr("Find in Message Log"), 406 tr("Find:"), QLineEdit::Normal, QString(), &ok); 407 408 if (ok && !text.isEmpty()) { 409 QTreeWidget *tree = ui.lstMessages; 410 QList<QTreeWidgetItem *> results = search(text); 411 if (!results.size()) { 412 QMessageBox::information(this, tr("Not Found"), 413 tr("Search found 0 matches."), 414 QMessageBox::Ok, QMessageBox::NoButton); 415 } else { 416 /* Deselect all currently selected items */ 417 deselectAllItems(); 418 /* Select the new matching items */ 419 foreach(QTreeWidgetItem *item, results) { 420 if (!tree->isItemHidden(item)) { 421 tree->setItemSelected(item, true); 422 } 423 } 424 /* Set the focus to the first match */ 425 tree->scrollToItem(results.at(0)); 426 } 427 } 428 } 429 389 430 /** 390 431 Clears the message list and resets the message counter … … 396 437 ui.lstMessages->setStatusTip(QString("Messages Shown: %1") 397 438 .arg(_messagesShown)); 439 } 440 441 /** Searches the currently displayed log entries for the given search text. 442 * 443 * \param text The text to search for. 444 * \returns A list of all log items containing the search text. 445 */ 446 QList<QTreeWidgetItem *> 447 MessageLog::search(QString text) 448 { 449 QTreeWidget *tree = ui.lstMessages; 450 QList<QTreeWidgetItem *> results; 451 452 /* Search through the messages in the tree, case-insensitively */ 453 return tree->findItems(text, Qt::MatchContains|Qt::MatchWrap, COL_MSG); 454 } 455 456 /** Deselects all currently selected items. */ 457 void 458 MessageLog::deselectAllItems() 459 { 460 QTreeWidget *tree = ui.lstMessages; 461 foreach(QTreeWidgetItem *item, tree->selectedItems()) { 462 tree->setItemSelected(item, false); 463 } 398 464 } 399 465 -
trunk/src/gui/messagelog/messagelog.h
r212 r224 74 74 /** Called when the user selects View->Clear all or Ctrl-E **/ 75 75 void clear(); 76 /** Called when the user selects Edit->Find or Ctrl-F. This will search 77 * through all currently displayed log entries for text specified by the 78 * user, highlighting the entires that contain a match. */ 79 void find(); 76 80 /** Called when the opactity slider changes value **/ 77 81 void setOpacity(int value); … … 96 100 /** Saves the given list of items to a file */ 97 101 void save(QList<QTreeWidgetItem *> items); 98 102 /** Searches the message log for entries that contain the given text. */ 103 QList<QTreeWidgetItem *> search(QString text); 104 /** Deselects all currently selected items. */ 105 void deselectAllItems(); 106 99 107 /** A pointer to a TorControl object, used to register for log events */ 100 108 TorControl* _torControl; -
trunk/src/gui/messagelog/messagelog.ui
r208 r224 293 293 </property> 294 294 <property name="windowIcon" > 295 <iconset resource=".. \res\vidalia.qrc" >:/images/tor_logo16.png</iconset>295 <iconset resource="../res/vidalia.qrc" >:/images/tor_logo16.png</iconset> 296 296 </property> 297 297 <property name="statusTip" > … … 467 467 </property> 468 468 <property name="icon" > 469 <iconset resource=".. \res\vidalia.qrc" >:/images/msg_error.png</iconset>469 <iconset resource="../res/vidalia.qrc" >:/images/msg_error.png</iconset> 470 470 </property> 471 471 </widget> … … 483 483 </property> 484 484 <property name="icon" > 485 <iconset resource=".. \res\vidalia.qrc" >:/images/msg_warn.png</iconset>485 <iconset resource="../res/vidalia.qrc" >:/images/msg_warn.png</iconset> 486 486 </property> 487 487 </widget> … … 499 499 </property> 500 500 <property name="icon" > 501 <iconset resource=".. \res\vidalia.qrc" >:/images/msg_notice.png</iconset>501 <iconset resource="../res/vidalia.qrc" >:/images/msg_notice.png</iconset> 502 502 </property> 503 503 </widget> … … 515 515 </property> 516 516 <property name="icon" > 517 <iconset resource=".. \res\vidalia.qrc" >:/images/msg_info.png</iconset>517 <iconset resource="../res/vidalia.qrc" >:/images/msg_info.png</iconset> 518 518 </property> 519 519 </widget> … … 531 531 </property> 532 532 <property name="icon" > 533 <iconset resource=".. \res\vidalia.qrc" >:/images/msg_debug.png</iconset>533 <iconset resource="../res/vidalia.qrc" >:/images/msg_debug.png</iconset> 534 534 </property> 535 535 </widget> … … 900 900 <y>0</y> 901 901 <width>701</width> 902 <height> 19</height>902 <height>22</height> 903 903 </rect> 904 904 </property> 905 <widget class="QMenu" name="menu_Edit" >906 <property name="title" >907 <string>&Edit</string>908 </property>909 <addaction name="actionCopy" />910 <addaction name="actionSelect_All" />911 </widget>912 905 <widget class="QMenu" name="menu_File" > 913 906 <property name="title" > … … 932 925 <addaction name="actionClear" /> 933 926 </widget> 927 <widget class="QMenu" name="menu_Edit" > 928 <property name="title" > 929 <string>&Edit</string> 930 </property> 931 <addaction name="actionCopy" /> 932 <addaction name="actionSelect_All" /> 933 <addaction name="separator" /> 934 <addaction name="actionFind" /> 935 </widget> 934 936 <addaction name="menu_File" /> 935 937 <addaction name="menu_Edit" /> … … 940 942 <rect> 941 943 <x>0</x> 942 <y>53 6</y>944 <y>538</y> 943 945 <width>701</width> 944 <height>2 2</height>946 <height>20</height> 945 947 </rect> 946 948 </property> … … 1113 1115 </property> 1114 1116 </action> 1117 <action name="actionFind" > 1118 <property name="text" > 1119 <string>Find</string> 1120 </property> 1121 <property name="font" > 1122 <font> 1123 <family>Arial</family> 1124 <pointsize>10</pointsize> 1125 <weight>50</weight> 1126 <italic>false</italic> 1127 <bold>false</bold> 1128 <underline>false</underline> 1129 <strikeout>false</strikeout> 1130 </font> 1131 </property> 1132 <property name="shortcut" > 1133 <string>⌘F</string> 1134 </property> 1135 </action> 1115 1136 </widget> 1116 1137 <pixmapfunction></pixmapfunction> 1117 1138 <resources> 1118 1139 <include location="res/vidalia.qrc" /> 1140 <include location="../res/vidalia.qrc" /> 1119 1141 <include location="../res/vidalia.qrc" /> 1120 1142 </resources>
