Changeset 78459 in vbox
- Timestamp:
- May 10, 2019 7:31:41 AM (6 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerSearchPanel.cpp
r78003 r78459 32 32 #include "QIToolButton.h" 33 33 #include "UIIconPool.h" 34 #include "UISearchLineEdit.h" 34 35 #include "UIVMLogPage.h" 35 36 #include "UIVMLogViewerSearchPanel.h" … … 70 71 /* Private member vars */ 71 72 QBrush m_baseBrush; 73 72 74 }; 73 75 … … 80 82 , m_pMatchWholeWordCheckBox(0) 81 83 , m_pHighlightAllCheckBox(0) 82 , m_iSearch Position(0)84 , m_iSearchCursorPosition(0) 83 85 , m_iMatchCount(0) 84 86 { … … 89 91 void UIVMLogViewerSearchPanel::refresh() 90 92 { 91 m_iSearch Position = 0;93 m_iSearchCursorPosition = 0; 92 94 /* We start the search from the end of the doc. assuming log's end is more interesting: */ 93 95 search(BackwardSearch, true); … … 97 99 void UIVMLogViewerSearchPanel::reset() 98 100 { 99 m_iSearch Position = 0;101 m_iSearchCursorPosition = 0; 100 102 m_matchLocationVector.clear(); 101 m_iMatchCount = 0; 103 setMatchCount(0); 104 if (m_pSearchEditor) 105 m_pSearchEditor->reset(); 102 106 } 103 107 … … 112 116 } 113 117 114 int UIVMLogViewerSearchPanel::ma rchCount() const118 int UIVMLogViewerSearchPanel::matchCount() const 115 119 { 116 120 return m_iMatchCount; … … 141 145 { 142 146 /* Reset the position to force the search restart from the document's end: */ 143 m_iSearch Position = 0;147 m_iSearchCursorPosition = 0; 144 148 search(BackwardSearch, true); 145 149 emit sigHighlightingUpdated(); … … 161 165 pBrowser->setTextCursor(cursor); 162 166 } 163 m_iSearch Position = -1;164 m_iMatchCount = 0;167 m_iSearchCursorPosition = -1; 168 setMatchCount(0); 165 169 emit sigSearchUpdated(); 166 170 clearHighlighting(); … … 216 220 217 221 /* Create search-editor: */ 218 m_pSearchEditor = new UI VMLogViewerSearchField(0 /* parent */);222 m_pSearchEditor = new UISearchLineEdit(0 /* parent */); 219 223 if (m_pSearchEditor) 220 224 { … … 409 413 /* Select all the text: */ 410 414 m_pSearchEditor->selectAll(); 415 m_pSearchEditor->setMatchCount(m_iMatchCount); 411 416 } 412 417 } … … 424 429 425 430 const QString &searchString = m_pSearchEditor->text(); 426 m_iMatchCount = countMatches(pDocument, searchString);431 setMatchCount(countMatches(pDocument, searchString)); 427 432 emit sigSearchUpdated(); 428 433 … … 443 448 444 449 QTextCursor resultCursor(pDocument); 445 int startPosition = m_iSearch Position;450 int startPosition = m_iSearchCursorPosition; 446 451 if (direction == BackwardSearch) 447 452 startPosition -= searchString.length(); … … 460 465 if (direction == ForwardSearch) 461 466 { 462 m_iSearch Position = startCursor.position();467 m_iSearchCursorPosition = startCursor.position(); 463 468 search(ForwardSearch, false); 464 469 return; … … 468 473 /* Set the search position away from the end position to be 469 474 able to find the string at the end of the document: */ 470 m_iSearch Position = endCursor.position() + searchString.length();475 m_iSearchCursorPosition = endCursor.position() + searchString.length(); 471 476 search(BackwardSearch, false); 472 477 return; … … 474 479 } 475 480 pTextEdit->setTextCursor(resultCursor); 476 m_iSearch Position = resultCursor.position();481 m_iSearchCursorPosition = resultCursor.position(); 477 482 } 478 483 … … 550 555 } 551 556 557 void UIVMLogViewerSearchPanel::setMatchCount(int iCount) 558 { 559 if (m_iMatchCount == iCount) 560 return; 561 m_iMatchCount = iCount; 562 if (m_pSearchEditor) 563 m_pSearchEditor->setMatchCount(iCount); 564 } 565 552 566 QTextDocument::FindFlags UIVMLogViewerSearchPanel::constructFindFlags(SearchDirection eDirection) const 553 567 { -
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerSearchPanel.h
r77078 r78459 34 34 class QWidget; 35 35 class QIToolButton; 36 class UISearchLineEdit; 36 37 class UIVMLogViewerSearchField; 37 38 class UIVMLogViewerWidget; … … 59 60 virtual QString panelName() const /* override */; 60 61 /** Returns the number of the matches to the current search. */ 61 int ma rchCount() const;62 int matchCount() const; 62 63 63 64 protected: … … 103 104 /** Searches the whole document and return the number of matches to the current search term. */ 104 105 int countMatches(QTextDocument *pDocument, const QString &searchString) const; 106 void setMatchCount(int iCount); 105 107 /** Holds the instance of search-editor we create. */ 106 UI VMLogViewerSearchField*m_pSearchEditor;108 UISearchLineEdit *m_pSearchEditor; 107 109 108 110 QIToolButton *m_pNextButton; … … 114 116 115 117 /** Holds the position where we start the next search. */ 116 int m_iSearch Position;118 int m_iSearchCursorPosition; 117 119 /** Holds the number of the matches for the string. 0 for no matches. */ 118 120 int m_iMatchCount; 121 119 122 /** Stores relative positions of the lines of the matches. The values are [0,1] 120 123 0 being the first line 1 being the last. */ -
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerWidget.cpp
r77078 r78459 312 312 for (int i = 0; i < m_logPageList.size(); ++i) 313 313 if (UIVMLogPage *pPage = qobject_cast<UIVMLogPage*>(m_logPageList[i])) 314 pPage->setSearchMatchCount(m_pSearchPanel->ma rchCount());314 pPage->setSearchMatchCount(m_pSearchPanel->matchCount()); 315 315 } 316 316 … … 768 768 } 769 769 pLogPage->setSearchResultOverlayShowHide(m_pSearchPanel->isVisible()); 770 pLogPage->setSearchMatchCount(m_pSearchPanel->ma rchCount());770 pLogPage->setSearchMatchCount(m_pSearchPanel->matchCount()); 771 771 pLogPage->setScrollBarMarkingsVector(m_pSearchPanel->matchLocationVector()); 772 772 } -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UISearchLineEdit.cpp
r78060 r78459 83 83 } 84 84 85 void UISearchLineEdit::reset() 86 { 87 clear(); 88 m_iMatchCount = 0; 89 m_iScrollToIndex = 0; 90 colorBackground(false); 91 } 92 85 93 void UISearchLineEdit::colorBackground(bool fWarning) 86 94 { -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UISearchLineEdit.h
r78060 r78459 42 42 void setMatchCount(int iMatchCount); 43 43 void setScroolToIndex(int iScrollToIndex); 44 void reset(); 44 45 45 46 protected:
Note:
See TracChangeset
for help on using the changeset viewer.