Changeset 70308 in vbox for trunk/src/VBox
- Timestamp:
- Dec 22, 2017 11:44:17 AM (7 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/logviewer
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerFilterPanel.cpp
r70098 r70308 56 56 AssertReturnVoid(pCurrentPage); 57 57 QString strInputText = m_pViewer->currentLog(); 58 if (!strInputText.isNull()) 58 if (strInputText.isNull()) 59 return; 60 61 /* Prepare filter-data: */ 62 QString strFilteredText; 63 const QRegExp rxFilterExp(m_strFilterText, Qt::CaseInsensitive); 64 65 /* If filter regular-expression is not empty and valid, filter the log: */ 66 if (!rxFilterExp.isEmpty() && rxFilterExp.isValid()) 59 67 { 60 /* Prepare filter-data: */ 61 QString strFilteredText; 62 const QRegExp rxFilterExp(m_strFilterText, Qt::CaseInsensitive); 63 64 /* If filter regular-expression is not empty and valid, filter the log: */ 65 if (!rxFilterExp.isEmpty() && rxFilterExp.isValid()) 66 { 67 while (!strInputText.isEmpty()) 68 while (!strInputText.isEmpty()) 69 { 70 /* Read each line and check if it matches regular-expression: */ 71 const int index = strInputText.indexOf('\n'); 72 if (index > 0) 68 73 { 69 /* Read each line and check if it matches regular-expression: */ 70 const int index = strInputText.indexOf('\n'); 71 if (index > 0) 72 { 73 QString strLine = strInputText.left(index + 1); 74 if (strLine.contains(rxFilterExp)) 75 strFilteredText.append(strLine); 76 } 77 strInputText.remove(0, index + 1); 74 QString strLine = strInputText.left(index + 1); 75 if (strLine.contains(rxFilterExp)) 76 strFilteredText.append(strLine); 78 77 } 79 pCurrentPage->setPlainText(strFilteredText); 80 } 81 /* Restore entire log when filter regular expression is empty or not valid: */ 82 else 83 pCurrentPage->setPlainText(strInputText); 84 85 /* Move the cursor position to end: */ 86 QTextCursor cursor = pCurrentPage->textCursor(); 87 cursor.movePosition(QTextCursor::End, QTextCursor::MoveAnchor); 88 pCurrentPage->setTextCursor(cursor); 78 strInputText.remove(0, index + 1); 79 } 80 QTextDocument *document = pCurrentPage->document(); 81 if(document) 82 document->setPlainText(strFilteredText); 89 83 } 84 /* Restore entire log when filter regular expression is empty or not valid: */ 85 else 86 pCurrentPage->setPlainText(strInputText); 87 88 /* Move the cursor position to end: */ 89 QTextCursor cursor = pCurrentPage->textCursor(); 90 cursor.movePosition(QTextCursor::End, QTextCursor::MoveAnchor); 91 pCurrentPage->setTextCursor(cursor); 92 93 emit sigFilterApplied(); 90 94 } 91 95 … … 161 165 { 162 166 /* Prepare connections: */ 163 connect(m_pCloseButton, SIGNAL(clicked()), this, SLOT(hide())); 164 connect(m_pFilterComboBox, SIGNAL(editTextChanged(const QString &)), 165 this, SLOT(filter(const QString &))); 167 connect(m_pCloseButton, &UIMiniCancelButton::clicked, this, &UIVMLogViewerFilterPanel::hide); 168 connect(m_pFilterComboBox, &QComboBox::editTextChanged, this, &UIVMLogViewerFilterPanel::filter); 166 169 } 167 170 -
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerFilterPanel.h
r70027 r70308 38 38 Q_OBJECT; 39 39 40 signals: 41 42 /* Notifies listeners that the filter has been applied. */ 43 void sigFilterApplied(); 44 40 45 public: 41 46 … … 49 54 * @param iCurrentIndex Specifies index of current log-page, but it is actually not used in the method. */ 50 55 void applyFilter(const int iCurrentIndex = 0); 56 51 57 private slots: 52 58 … … 76 82 UIVMLogViewerWidget *m_pViewer; 77 83 /** Holds the instance of main-layout we create. */ 78 QHBoxLayout *m_pMainLayout;84 QHBoxLayout *m_pMainLayout; 79 85 /** Holds the instance of close-button we create. */ 80 UIMiniCancelButton *m_pCloseButton;86 UIMiniCancelButton *m_pCloseButton; 81 87 /** Holds the instance of filter-label we create. */ 82 QLabel *m_pFilterLabel;88 QLabel *m_pFilterLabel; 83 89 /** Holds instance of filter combo-box we create. */ 84 QComboBox *m_pFilterComboBox;90 QComboBox *m_pFilterComboBox; 85 91 /** Holds the filter text. */ 86 QString m_strFilterText;92 QString m_strFilterText; 87 93 }; 88 94 -
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerSearchPanel.h
r70272 r70308 43 43 44 44 signals: 45 45 46 void sigHighlightingUpdated(); 46 47 … … 70 71 71 72 private: 73 72 74 enum SearchDirection { ForwardSearch, BackwardSearch }; 73 75 /** Prepares search-panel. */ … … 141 143 142 144 #endif /* !___UIVMLogViewerSearchPanel_h___ */ 143 -
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerWidget.cpp
r70281 r70308 174 174 { 175 175 /* Disconnect this connection to avoid initial signals during page creation/deletion: */ 176 disconnect(m_pViewerContainer, SIGNAL(currentChanged(int)), m_pFilterPanel, SLOT(applyFilter(int)));176 disconnect(m_pViewerContainer, &QITabWidget::currentChanged, m_pFilterPanel, &UIVMLogViewerFilterPanel::applyFilter); 177 177 disconnect(m_pViewerContainer, &QITabWidget::currentChanged, this, &UIVMLogViewerWidget::sltTabIndexChange); 178 178 … … 228 228 229 229 /* Setup this connection after refresh to avoid initial signals during page creation: */ 230 connect(m_pViewerContainer, SIGNAL(currentChanged(int)), m_pFilterPanel, SLOT(applyFilter(int)));230 connect(m_pViewerContainer, &QITabWidget::currentChanged, m_pFilterPanel, &UIVMLogViewerFilterPanel::applyFilter); 231 231 connect(m_pViewerContainer, &QITabWidget::currentChanged, this, &UIVMLogViewerWidget::sltTabIndexChange); 232 232 … … 304 304 } 305 305 306 void UIVMLogViewerWidget:: 307 sltFilterApplied() 308 { 309 /* Reapply the search to get highlighting etc. correctly */ 310 if (m_pSearchPanel && m_pSearchPanel->isVisible()) 311 m_pSearchPanel->refresh(); 312 } 313 306 314 void UIVMLogViewerWidget::setMachine(const CMachine &machine) 307 315 { … … 372 380 /* Add VM Log-Viewer filter-panel to main-layout: */ 373 381 m_pMainLayout->insertWidget(3, m_pFilterPanel); 382 connect(m_pFilterPanel, &UIVMLogViewerFilterPanel::sigFilterApplied, 383 this, &UIVMLogViewerWidget::sltFilterApplied); 374 384 } 375 385 } -
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerWidget.h
r70281 r70308 93 93 void sltTabIndexChange(int tabIndex); 94 94 95 void sltFilterApplied(); 96 95 97 private: 96 98
Note:
See TracChangeset
for help on using the changeset viewer.