VirtualBox

Changeset 78459 in vbox


Ignore:
Timestamp:
May 10, 2019 7:31:41 AM (6 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9072. Using UISearchLineEdit in the log viewer.

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  
    3232#include "QIToolButton.h"
    3333#include "UIIconPool.h"
     34#include "UISearchLineEdit.h"
    3435#include "UIVMLogPage.h"
    3536#include "UIVMLogViewerSearchPanel.h"
     
    7071    /* Private member vars */
    7172    QBrush m_baseBrush;
     73
    7274};
    7375
     
    8082    , m_pMatchWholeWordCheckBox(0)
    8183    , m_pHighlightAllCheckBox(0)
    82     , m_iSearchPosition(0)
     84    , m_iSearchCursorPosition(0)
    8385    , m_iMatchCount(0)
    8486{
     
    8991void UIVMLogViewerSearchPanel::refresh()
    9092{
    91     m_iSearchPosition = 0;
     93    m_iSearchCursorPosition = 0;
    9294    /* We start the search from the end of the doc. assuming log's end is more interesting: */
    9395    search(BackwardSearch, true);
     
    9799void UIVMLogViewerSearchPanel::reset()
    98100{
    99     m_iSearchPosition = 0;
     101    m_iSearchCursorPosition = 0;
    100102    m_matchLocationVector.clear();
    101     m_iMatchCount = 0;
     103    setMatchCount(0);
     104    if (m_pSearchEditor)
     105        m_pSearchEditor->reset();
    102106}
    103107
     
    112116}
    113117
    114 int UIVMLogViewerSearchPanel::marchCount() const
     118int UIVMLogViewerSearchPanel::matchCount() const
    115119{
    116120    return m_iMatchCount;
     
    141145    {
    142146        /* Reset the position to force the search restart from the document's end: */
    143         m_iSearchPosition = 0;
     147        m_iSearchCursorPosition = 0;
    144148        search(BackwardSearch, true);
    145149        emit sigHighlightingUpdated();
     
    161165        pBrowser->setTextCursor(cursor);
    162166    }
    163     m_iSearchPosition = -1;
    164     m_iMatchCount = 0;
     167    m_iSearchCursorPosition = -1;
     168    setMatchCount(0);
    165169    emit sigSearchUpdated();
    166170    clearHighlighting();
     
    216220
    217221        /* Create search-editor: */
    218         m_pSearchEditor = new UIVMLogViewerSearchField(0 /* parent */);
     222        m_pSearchEditor = new UISearchLineEdit(0 /* parent */);
    219223        if (m_pSearchEditor)
    220224        {
     
    409413        /* Select all the text: */
    410414        m_pSearchEditor->selectAll();
     415        m_pSearchEditor->setMatchCount(m_iMatchCount);
    411416    }
    412417}
     
    424429
    425430    const QString &searchString = m_pSearchEditor->text();
    426     m_iMatchCount = countMatches(pDocument, searchString);
     431    setMatchCount(countMatches(pDocument, searchString));
    427432    emit sigSearchUpdated();
    428433
     
    443448
    444449    QTextCursor resultCursor(pDocument);
    445     int startPosition = m_iSearchPosition;
     450    int startPosition = m_iSearchCursorPosition;
    446451    if (direction == BackwardSearch)
    447452        startPosition -= searchString.length();
     
    460465        if (direction == ForwardSearch)
    461466        {
    462             m_iSearchPosition = startCursor.position();
     467            m_iSearchCursorPosition = startCursor.position();
    463468            search(ForwardSearch, false);
    464469            return;
     
    468473            /* Set the search position away from the end position to be
    469474               able to find the string at the end of the document: */
    470             m_iSearchPosition = endCursor.position() + searchString.length();
     475            m_iSearchCursorPosition = endCursor.position() + searchString.length();
    471476            search(BackwardSearch, false);
    472477            return;
     
    474479    }
    475480    pTextEdit->setTextCursor(resultCursor);
    476     m_iSearchPosition = resultCursor.position();
     481    m_iSearchCursorPosition = resultCursor.position();
    477482}
    478483
     
    550555}
    551556
     557void 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
    552566QTextDocument::FindFlags UIVMLogViewerSearchPanel::constructFindFlags(SearchDirection eDirection) const
    553567{
  • trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerSearchPanel.h

    r77078 r78459  
    3434class QWidget;
    3535class QIToolButton;
     36class UISearchLineEdit;
    3637class UIVMLogViewerSearchField;
    3738class UIVMLogViewerWidget;
     
    5960    virtual QString panelName() const /* override */;
    6061    /** Returns the number of the matches to the current search. */
    61     int marchCount() const;
     62    int matchCount() const;
    6263
    6364protected:
     
    103104    /** Searches the whole document and return the number of matches to the current search term. */
    104105    int countMatches(QTextDocument *pDocument, const QString &searchString) const;
     106    void setMatchCount(int iCount);
    105107    /** Holds the instance of search-editor we create. */
    106     UIVMLogViewerSearchField *m_pSearchEditor;
     108    UISearchLineEdit *m_pSearchEditor;
    107109
    108110    QIToolButton *m_pNextButton;
     
    114116
    115117    /** Holds the position where we start the next search. */
    116     int          m_iSearchPosition;
     118    int          m_iSearchCursorPosition;
    117119    /** Holds the number of the matches for the string. 0 for no matches. */
    118120    int          m_iMatchCount;
     121
    119122    /** Stores relative positions of the lines of the matches. The values are [0,1]
    120123        0 being the first line 1 being the last. */
  • trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerWidget.cpp

    r77078 r78459  
    312312    for (int i = 0; i < m_logPageList.size(); ++i)
    313313        if (UIVMLogPage *pPage = qobject_cast<UIVMLogPage*>(m_logPageList[i]))
    314             pPage->setSearchMatchCount(m_pSearchPanel->marchCount());
     314            pPage->setSearchMatchCount(m_pSearchPanel->matchCount());
    315315}
    316316
     
    768768        }
    769769        pLogPage->setSearchResultOverlayShowHide(m_pSearchPanel->isVisible());
    770         pLogPage->setSearchMatchCount(m_pSearchPanel->marchCount());
     770        pLogPage->setSearchMatchCount(m_pSearchPanel->matchCount());
    771771        pLogPage->setScrollBarMarkingsVector(m_pSearchPanel->matchLocationVector());
    772772    }
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UISearchLineEdit.cpp

    r78060 r78459  
    8383}
    8484
     85void UISearchLineEdit::reset()
     86{
     87    clear();
     88    m_iMatchCount = 0;
     89    m_iScrollToIndex = 0;
     90    colorBackground(false);
     91}
     92
    8593void UISearchLineEdit::colorBackground(bool fWarning)
    8694{
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UISearchLineEdit.h

    r78060 r78459  
    4242    void setMatchCount(int iMatchCount);
    4343    void setScroolToIndex(int iScrollToIndex);
     44    void reset();
    4445
    4546protected:
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