VirtualBox

Changeset 88707 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
Apr 26, 2021 4:17:35 PM (4 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9930. Re-implementing tab refresh

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  
    789789void UIHelpViewer::highlightFinds(int iSearchTermLength)
    790790{
    791     QTextDocument* pDocument = document();
    792     AssertReturnVoid(pDocument);
    793 
    794791    QList<QTextEdit::ExtraSelection> extraSelections;
    795 
    796792    for (int i = 0; i < m_matchedCursorPosition.size(); ++i)
    797793    {
  • trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogPage.h

    r88703 r88707  
    6464
    6565    void setLogContent(const QString &strLogContent, bool fError);
    66     /* Only to be called when log file is re-read. */
    67     // void setLogString(const QString &strLog);
    6866    const QString& logString() const;
    6967
     
    137135    QHBoxLayout    *m_pMainLayout;
    138136    UIVMLogViewerTextEdit *m_pTextEdit;
    139     /** Stores the log file (unmodified) content. */
     137    /** Stores the log file (unmodified by filtering etc) content. */
    140138    QString         m_strLog;
    141139    /** Stores full path and name of the log file. */
  • trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerFilterPanel.cpp

    r82968 r88707  
    284284    /* Check if we have to reapply the filter. If not
    285285       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    // }
    293293
    294294
  • trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerSearchPanel.cpp

    r88018 r88707  
    149149        if (searchString.isEmpty())
    150150            return;
    151         highlightAll(pDocument, searchString);
     151        highlightAll(searchString);
    152152    }
    153153    else
     
    410410    }
    411411    if (m_pHighlightAllCheckBox->isChecked())
    412         highlightAll(pDocument, searchString);
     412        highlightAll(searchString);
    413413}
    414414
    415415void UIVMLogViewerSearchPanel::clearHighlighting()
    416416{
    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>());
    422426    emit sigHighlightingUpdated();
    423427}
    424428
    425 void UIVMLogViewerSearchPanel::highlightAll(QTextDocument *pDocument,
    426                                             const QString &searchString)
     429void UIVMLogViewerSearchPanel::highlightAll(const QString &searchString)
    427430{
    428431    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;
    439459    for (int i = 0; i < m_matchedCursorPosition.size(); ++i)
    440460    {
    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
    450474}
    451475
  • trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerSearchPanel.h

    r86814 r88707  
    9595                               thus we avoid calling highlighting for the same string repeatedly. */
    9696    void performSearch(SearchDirection eDirection, bool highlight);
    97     void highlightAll(QTextDocument *pDocument, const QString &searchString);
     97    void highlightAll(const QString &searchString);
    9898    void findAll(QTextDocument *pDocument, const QString &searchString);
    9999    void selectMatch(int iMatchIndex, const QString &searchString);
  • trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerWidget.cpp

    r88703 r88707  
    275275
    276276    UIVMLogPage *pCurrentPage = currentLogPage();
    277     if (!pCurrentPage)
     277    if (!pCurrentPage || pCurrentPage->logFileId() == -1)
    278278        return;
    279279
     
    282282        return;
    283283
    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();
    358293}
    359294
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette