Changeset 88707 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Apr 26, 2021 4:17:35 PM (4 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/helpbrowser/UIHelpViewer.cpp
r88526 r88707 789 789 void UIHelpViewer::highlightFinds(int iSearchTermLength) 790 790 { 791 QTextDocument* pDocument = document();792 AssertReturnVoid(pDocument);793 794 791 QList<QTextEdit::ExtraSelection> extraSelections; 795 796 792 for (int i = 0; i < m_matchedCursorPosition.size(); ++i) 797 793 { -
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogPage.h
r88703 r88707 64 64 65 65 void setLogContent(const QString &strLogContent, bool fError); 66 /* Only to be called when log file is re-read. */67 // void setLogString(const QString &strLog);68 66 const QString& logString() const; 69 67 … … 137 135 QHBoxLayout *m_pMainLayout; 138 136 UIVMLogViewerTextEdit *m_pTextEdit; 139 /** Stores the log file (unmodified ) content. */137 /** Stores the log file (unmodified by filtering etc) content. */ 140 138 QString m_strLog; 141 139 /** Stores full path and name of the log file. */ -
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerFilterPanel.cpp
r82968 r88707 284 284 /* Check if we have to reapply the filter. If not 285 285 restore line counts etc. and return */ 286 if (!logPage->shouldFilterBeApplied(m_filterTermSet, (int)m_eFilterOperatorButton))287 {288 m_iFilteredLineCount = logPage->filteredLineCount();289 m_iUnfilteredLineCount = logPage->unfilteredLineCount();290 emit sigFilterApplied(!logPage->isFiltered() /* isOriginalLog */);291 return;292 }286 // if (!logPage->shouldFilterBeApplied(m_filterTermSet, (int)m_eFilterOperatorButton)) 287 // { 288 // m_iFilteredLineCount = logPage->filteredLineCount(); 289 // m_iUnfilteredLineCount = logPage->unfilteredLineCount(); 290 // emit sigFilterApplied(!logPage->isFiltered() /* isOriginalLog */); 291 // return; 292 // } 293 293 294 294 -
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerSearchPanel.cpp
r88018 r88707 149 149 if (searchString.isEmpty()) 150 150 return; 151 highlightAll( pDocument,searchString);151 highlightAll(searchString); 152 152 } 153 153 else … … 410 410 } 411 411 if (m_pHighlightAllCheckBox->isChecked()) 412 highlightAll( pDocument,searchString);412 highlightAll(searchString); 413 413 } 414 414 415 415 void UIVMLogViewerSearchPanel::clearHighlighting() 416 416 { 417 if (!viewer()) 418 return; 419 QTextDocument* pDocument = textDocument(); 420 if (pDocument) 421 pDocument->undo(); 417 // if (!viewer()) 418 // return; 419 // QTextDocument* pDocument = textDocument(); 420 // if (pDocument) 421 // pDocument->undo(); 422 423 QPlainTextEdit *pTextEdit = textEdit(); 424 if (pTextEdit) 425 pTextEdit->setExtraSelections(QList<QTextEdit::ExtraSelection>()); 422 426 emit sigHighlightingUpdated(); 423 427 } 424 428 425 void UIVMLogViewerSearchPanel::highlightAll(QTextDocument *pDocument, 426 const QString &searchString) 429 void UIVMLogViewerSearchPanel::highlightAll(const QString &searchString) 427 430 { 428 431 clearHighlighting(); 429 if (!pDocument) 430 return; 431 if (searchString.isEmpty()) 432 return; 433 434 QTextCursor highlightCursor(pDocument); 435 QTextCharFormat colorFormat(highlightCursor.charFormat()); 436 QTextCursor cursor(pDocument); 437 cursor.beginEditBlock(); 438 colorFormat.setBackground(Qt::yellow); 432 // if (!pDocument) 433 // return; 434 // if (searchString.isEmpty()) 435 // return; 436 437 // QTextCursor highlightCursor(pDocument); 438 // QTextCharFormat colorFormat(highlightCursor.charFormat()); 439 // QTextCursor cursor(pDocument); 440 // cursor.beginEditBlock(); 441 // colorFormat.setBackground(Qt::yellow); 442 // for (int i = 0; i < m_matchedCursorPosition.size(); ++i) 443 // { 444 // highlightCursor.setPosition(m_matchedCursorPosition[i]); 445 // highlightCursor.setPosition(m_matchedCursorPosition[i] + searchString.length(), QTextCursor::KeepAnchor); 446 447 // if (!highlightCursor.isNull()) 448 // { 449 // highlightCursor.mergeCharFormat(colorFormat); 450 // } 451 // } 452 // cursor.endEditBlock(); 453 QPlainTextEdit *pTextEdit = textEdit(); 454 455 if (!pTextEdit) 456 return; 457 458 QList<QTextEdit::ExtraSelection> extraSelections; 439 459 for (int i = 0; i < m_matchedCursorPosition.size(); ++i) 440 460 { 441 highlightCursor.setPosition(m_matchedCursorPosition[i]); 442 highlightCursor.setPosition(m_matchedCursorPosition[i] + searchString.length(), QTextCursor::KeepAnchor); 443 444 if (!highlightCursor.isNull()) 445 { 446 highlightCursor.mergeCharFormat(colorFormat); 447 } 448 } 449 cursor.endEditBlock(); 461 QTextEdit::ExtraSelection selection; 462 QTextCursor cursor = pTextEdit->textCursor(); 463 cursor.setPosition(m_matchedCursorPosition[i]); 464 cursor.setPosition(m_matchedCursorPosition[i] + searchString.length(), QTextCursor::KeepAnchor); 465 QTextCharFormat format = cursor.charFormat(); 466 format.setBackground(Qt::yellow); 467 468 selection.cursor = cursor; 469 selection.format = format; 470 extraSelections.append(selection); 471 } 472 pTextEdit->setExtraSelections(extraSelections); 473 450 474 } 451 475 -
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerSearchPanel.h
r86814 r88707 95 95 thus we avoid calling highlighting for the same string repeatedly. */ 96 96 void performSearch(SearchDirection eDirection, bool highlight); 97 void highlightAll( QTextDocument *pDocument,const QString &searchString);97 void highlightAll(const QString &searchString); 98 98 void findAll(QTextDocument *pDocument, const QString &searchString); 99 99 void selectMatch(int iMatchIndex, const QString &searchString); -
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerWidget.cpp
r88703 r88707 275 275 276 276 UIVMLogPage *pCurrentPage = currentLogPage(); 277 if (!pCurrentPage )277 if (!pCurrentPage || pCurrentPage->logFileId() == -1) 278 278 return; 279 279 … … 282 282 return; 283 283 284 285 286 287 /* Disconnect this connection to avoid initial signals during page creation/deletion: */ 288 // disconnect(m_pTabWidget, &QITabWidget::currentChanged, m_pFilterPanel, &UIVMLogViewerFilterPanel::applyFilter); 289 // disconnect(m_pTabWidget, &QITabWidget::currentChanged, this, &UIVMLogViewerWidget::sltTabIndexChange); 290 291 // m_logPageList.clear(); 292 // m_pTabWidget->setEnabled(true); 293 // int currentTabIndex = m_pTabWidget->currentIndex(); 294 // /* Hide the container widget during updates to avoid flickering: */ 295 // m_pTabWidget->hide(); 296 // QVector<QVector<LogBookmark> > logPageBookmarks; 297 // /* Clear the tab widget. This might be an overkill but most secure way to deal with the case where 298 // number of the log files changes. Store the bookmark vectors before deleting the pages*/ 299 // while (m_pTabWidget->count()) 300 // { 301 // QWidget *pFirstPage = m_pTabWidget->widget(0); 302 // UIVMLogPage *pLogPage = qobject_cast<UIVMLogPage*>(pFirstPage); 303 // if (pLogPage) 304 // logPageBookmarks.push_back(pLogPage->bookmarkVector()); 305 // m_pTabWidget->removeTab(0); 306 // delete pFirstPage; 307 // } 308 309 // bool noLogsToShow = createLogViewerPages(); 310 311 // /* Apply the filter settings: */ 312 // if (m_pFilterPanel) 313 // m_pFilterPanel->applyFilter(); 314 315 // /* Restore the bookmarks: */ 316 // if (!noLogsToShow) 317 // { 318 // for (int i = 0; i < m_pTabWidget->count(); ++i) 319 // { 320 // UIVMLogPage *pLogPage = qobject_cast<UIVMLogPage*>(m_pTabWidget->widget(i)); 321 // if (pLogPage && i < logPageBookmarks.size()) 322 // pLogPage->setBookmarkVector(logPageBookmarks[i]); 323 // } 324 // } 325 326 // /* Setup this connection after refresh to avoid initial signals during page creation: */ 327 // if (m_pFilterPanel) 328 // connect(m_pTabWidget, &QITabWidget::currentChanged, m_pFilterPanel, &UIVMLogViewerFilterPanel::applyFilter); 329 // connect(m_pTabWidget, &QITabWidget::currentChanged, this, &UIVMLogViewerWidget::sltTabIndexChange); 330 331 // /* Show the first tab widget's page after the refresh: */ 332 // int tabIndex = (currentTabIndex < m_pTabWidget->count()) ? currentTabIndex : 0; 333 // m_pTabWidget->setCurrentIndex(tabIndex); 334 // sltTabIndexChange(tabIndex); 335 336 // /* Enable/Disable toolbar actions (except Refresh) & tab widget according log presence: */ 337 // m_pActionPool->action(UIActionIndex_M_Log_T_Find)->setEnabled(!noLogsToShow); 338 // m_pActionPool->action(UIActionIndex_M_Log_T_Filter)->setEnabled(!noLogsToShow); 339 // m_pActionPool->action(UIActionIndex_M_Log_S_Save)->setEnabled(!noLogsToShow); 340 // m_pActionPool->action(UIActionIndex_M_Log_T_Bookmark)->setEnabled(!noLogsToShow); 341 // m_pActionPool->action(UIActionIndex_M_Log_T_Options)->setEnabled(!noLogsToShow); 342 343 // m_pTabWidget->show(); 344 // if (m_pSearchPanel && m_pSearchPanel->isVisible()) 345 // m_pSearchPanel->refresh(); 346 347 // /* If there are no log files to show the hide all the open panels: */ 348 // if (noLogsToShow) 349 // { 350 // for (QMap<UIDialogPanel*, QAction*>::iterator iterator = m_panelActionMap.begin(); 351 // iterator != m_panelActionMap.end(); ++iterator) 352 // { 353 // if (iterator.key()) 354 // hidePanel(iterator.key()); 355 // } 356 // } 357 284 QString strLogContent = readLogFile(comMachine, pCurrentPage->logFileId()); 285 pCurrentPage->setLogContent(strLogContent, false); 286 287 if (m_pSearchPanel && m_pSearchPanel->isVisible()) 288 m_pSearchPanel->refresh(); 289 290 /* Re-Apply the filter settings: */ 291 if (m_pFilterPanel) 292 m_pFilterPanel->applyFilter(); 358 293 } 359 294
Note:
See TracChangeset
for help on using the changeset viewer.