VirtualBox

Ignore:
Timestamp:
Apr 5, 2018 1:07:14 PM (7 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9072 Handle logviewer bookmarks a bit better in case of log viewer page refresh

Location:
trunk/src/VBox/Frontends/VirtualBox/src/logviewer
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogPage.cpp

    r71638 r71683  
    244244}
    245245
     246void UIVMLogPage::setBookmarkVector(const QVector<LogBookmark>& bookmarks)
     247{
     248    m_bookmarkVector = bookmarks;
     249    updateTextEditBookmarkLineSet();
     250}
     251
    246252void UIVMLogPage::showEvent(QShowEvent *pEvent)
    247253{
  • trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogPage.h

    r71638 r71683  
    3939
    4040/** UIVMLogPage defines data and functionalities of the each tab page of a UIVMLogViewerWidget.
    41     It stores the original log file content , a list of bookmarks, etc */
     41 *  It stores the original log file content , a list of bookmarks, etc */
    4242class UIVMLogPage  : public QIWithRetranslateUI<QWidget>
    4343{
     
    7171
    7272    /** Set plaintextEdit's text. Note that the text we
    73         show currently might be different than
    74         m_strLog. For example during filtering. */
     73     *  show currently might be different than
     74     *  m_strLog. For example during filtering. */
    7575    void setTextEditText(const QString &strText);
    7676    void setTextEditTextAsHtml(const QString &strText);
     
    8888
    8989    const QVector<LogBookmark>& bookmarkVector() const;
     90    void setBookmarkVector(const QVector<LogBookmark>& booksmarks);
     91
    9092    void deleteAllBookmarks();
    9193    /** Scrolls the plain text edit to the bookmark with index @a bookmarkIndex. */
     
    99101
    100102    /** setFilterParameters is called at the end of filtering operation to store the parameter etc.
    101         these parameters are used to decide whether we have to reapply the filter, and if not to
    102         update filter panel with correct line counts etc.*/
     103     *  these parameters are used to decide whether we have to reapply the filter, and if not to
     104     *  update filter panel with correct line counts etc.*/
    103105    void setFilterParameters(const QSet<QString> &filterTermSet, int filterOperationType,
    104106                             int iFilteredLineCount, int iUnfilteredLineCount);
     
    106108    int  unfilteredLineCount() const;
    107109    /** Compares filter parameters with previous filter operation's parameters to decide if the
    108         filter should be applied again. */
     110     *  filter should be applied again. */
    109111    bool shouldFilterBeApplied(const QSet<QString> &filterTermSet, int filterOperationType) const;
    110112
  • trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerBookmarksPanel.h

    r71638 r71683  
    2828
    2929/** UIVMLogViewerPanel extension providing GUI for bookmark management. Show a list of bookmarks currently set
    30   for displayed log page. It has controls to navigate and clear bookmarks. */
     30 * for displayed log page. It has controls to navigate and clear bookmarks. */
    3131class UIVMLogViewerBookmarksPanel : public UIVMLogViewerPanel
    3232{
     
    4444
    4545    /** Adds a single bookmark to an existing list of bookmarks. Possibly called
    46        by UIVMLogViewerWidget when user adds a bookmark thru context menu etc. */
     46     *  by UIVMLogViewerWidget when user adds a bookmark thru context menu etc. */
    4747    void addBookmark(const QPair<int, QString> &newBookmark);
    4848    /** Clear the bookmark list and show this list instead. Probably done after
    49        user switches to another log page tab etc. */
     49     *  user switches to another log page tab etc. */
    5050    void setBookmarksList(const QVector<QPair<int, QString> > &bookmarkList);
    5151    void updateBookmarkList(const QVector<QPair<int, QString> > &bookmarkVector);
  • trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerWidget.cpp

    r71669 r71683  
    180180    m_logPageList.clear();
    181181    m_pTabWidget->setEnabled(true);
     182    int currentTabIndex = m_pTabWidget->currentIndex();
    182183    /* Hide the container widget during updates to avoid flickering: */
    183184    m_pTabWidget->hide();
     185    QVector<QVector<LogBookmark> > logPageBookmarks;
    184186    /* Clear the tab widget. This might be an overkill but most secure way to deal with the case where
    185        number of the log files changes. */
     187       number of the log files changes. Store the bookmark vectors before deleting the pages*/
    186188    while (m_pTabWidget->count())
    187189    {
    188190        QWidget *pFirstPage = m_pTabWidget->widget(0);
     191        UIVMLogPage *pLogPage = qobject_cast<UIVMLogPage*>(pFirstPage);
     192        if (pLogPage)
     193            logPageBookmarks.push_back(pLogPage->bookmarkVector());
    189194        m_pTabWidget->removeTab(0);
    190195        delete pFirstPage;
     
    192197
    193198    bool noLogsToShow = createLogViewerPages();
    194 
    195     /* Show the first tab widget's page after the refresh: */
    196     m_pTabWidget->setCurrentIndex(0);
    197199
    198200    /* Apply the filter settings: */
    199201    if (m_pFilterPanel)
    200202        m_pFilterPanel->applyFilter();
     203    /* Restore the bookmarks: */
     204    for (int i = 0; i < !noLogsToShow && m_pTabWidget->count(); ++i)
     205    {
     206        UIVMLogPage *pLogPage = qobject_cast<UIVMLogPage*>(m_pTabWidget->widget(i));
     207        if (pLogPage && i < logPageBookmarks.size())
     208            pLogPage->setBookmarkVector(logPageBookmarks[i]);
     209    }
    201210
    202211    /* Setup this connection after refresh to avoid initial signals during page creation: */
     
    205214    connect(m_pTabWidget, &QITabWidget::currentChanged, this, &UIVMLogViewerWidget::sltTabIndexChange);
    206215
     216    /* Show the first tab widget's page after the refresh: */
     217    int tabIndex = (currentTabIndex < m_pTabWidget->count()) ? currentTabIndex : 0;
     218    m_pTabWidget->setCurrentIndex(tabIndex);
     219    sltTabIndexChange(tabIndex);
    207220    /* Enable/Disable toolbar actions (except Refresh) & tab widget according log presence: */
    208221    if (m_pActionFind)
     
    220233    if (m_pSearchPanel && m_pSearchPanel->isVisible())
    221234        m_pSearchPanel->refresh();
     235
     236    /* If there are no log files to show the hide all the open panels: */
     237    if (noLogsToShow)
     238    {
     239        for(QMap<UIVMLogViewerPanel*, QAction*>::iterator iterator = m_panelActionMap.begin();
     240            iterator != m_panelActionMap.end(); ++iterator)
     241        {
     242            if (iterator.key())
     243            hidePanel(iterator.key());
     244        }
     245    }
    222246}
    223247
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