VirtualBox

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


Ignore:
Timestamp:
Jan 13, 2018 7:32:04 PM (7 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9072 Filtering tunrs off bookmarking

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

Legend:

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

    r70574 r70578  
    4343    , m_pTextEdit(0)
    4444    , m_tabIndex(tabIndex)
     45    , m_bFiltered(false)
    4546{
    4647    prepare();
     
    193194    for(int i = 0; i < m_bookmarkVector.size(); ++i)
    194195    {
    195         if(m_bookmarkVector.at(i).first)
     196        if(m_bookmarkVector.at(i).first == bookmark.first)
    196197        {
    197198            index = i;
     
    252253}
    253254
    254 // void UIVMLogViewerWidget::sltCreateBookmarkAtCurrent()
    255 // {
    256     // if (!currentTextEdit())
    257     //     return;
    258     // QWidget* viewport = currentTextEdit()->viewport();
    259     // if (!viewport)
    260     //     return;
    261     // QPoint point(0.5 * viewport->width(), 0.5 * viewport->height());
    262     // QTextBlock block = currentTextEdit()->cursorForPosition(point).block();
    263     // LogBookmark bookmark;
    264     // bookmark.first = block.firstLineNumber();
    265     // bookmark.second = block.text();
    266     // sltCreateBookmarkAtLine(bookmark);
    267 //}
     255bool UIVMLogPage::isFiltered() const
     256{
     257    return m_bFiltered;
     258}
     259
     260void UIVMLogPage::setFiltered(bool filtered)
     261{
     262    if(m_bFiltered == filtered)
     263        return;
     264    m_bFiltered = filtered;
     265    if(m_pTextEdit)
     266    {
     267        m_pTextEdit->setShownTextIsFiltered(m_bFiltered);
     268        m_pTextEdit->update();
     269    }
     270    emit sigLogPageFilteredChanged(m_bFiltered);
     271}
  • trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogPage.h

    r70574 r70578  
    4545
    4646    void sigBookmarksUpdated();
     47    void sigLogPageFilteredChanged(bool isFiltered);
    4748
    4849public:
     
    8283
    8384    void deleteBookmark(int index);
    84     void deleteBookmark(LogBookmark bookmark);
    8585
    8686    const QVector<LogBookmark>& bookmarkVector() const;
     
    8989    void scrollToBookmark(int bookmarkIndex);
    9090
    91 protected:
     91    bool isFiltered() const;
     92    void setFiltered(bool filtered);
    9293
    9394private slots:
     
    9798
    9899private:
     100
    99101    void prepare();
    100102    void prepareWidgets();
     
    102104    void retranslateUi();
    103105    void updateTextEditBookmarkLineSet();
     106    void deleteBookmark(LogBookmark bookmark);
    104107
    105108    QHBoxLayout    *m_pMainLayout;
     
    111114    /** This is the index of the tab containing this widget in UIVMLogViewerWidget. */
    112115    int             m_tabIndex;
    113 
     116    /** Stores the bookmarks of the logpage. All other bookmark related containers are updated wrt. this one. */
    114117    QVector<LogBookmark> m_bookmarkVector;
    115 
     118    /** Designates whether currently displayed text is log text or a filtered version of it. That is
     119        if m_bFiltered is false than (m_strLog == m_pTextEdit->text()). */
     120    bool m_bFiltered;
    116121};
    117122
  • trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerFilterPanel.cpp

    r70539 r70578  
    217217    {
    218218        document->setPlainText(*originalLogString);
    219         emit sigFilterApplied();
     219        emit sigFilterApplied(true /* isOriginalLog */);
    220220        m_iFilteredLineCount = document->lineCount();
    221221        return;
     
    245245    pCurrentTextEdit->setTextCursor(cursor);
    246246
    247     emit sigFilterApplied();
     247    emit sigFilterApplied(false /* isOriginalLog */);
    248248}
    249249
  • trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerFilterPanel.h

    r70500 r70578  
    4242signals:
    4343
    44     /* Notifies listeners that the filter has been applied. */
    45     void sigFilterApplied();
     44    /* Notifies listeners that the filter has been applied. @a isOriginalLog is true
     45     if filter function returns early for some reason (no filter term etc.) and log page
     46     content is set to original log file. @a isOriginalLog is false if content is reduced (filtered)*/
     47    void sigFilterApplied(bool isOriginalLog);
    4648
    4749public:
  • trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerTextEdit.cpp

    r70574 r70578  
    153153    , m_pLineNumberArea(0)
    154154    , m_mouseCursorLine(-1)
     155    , m_bShownTextIsFiltered(false)
    155156{
    156157    setMouseTracking(true);
     
    219220        if (block.isVisible() && bottom >= event->rect().top()) {
    220221            QString number = QString::number(blockNumber + 1);
    221             if (m_bookmarkLineSet.contains(blockNumber + 1))
     222            /* Mark this line if it is bookmarked, but only if the text is not filtered. */
     223            if (m_bookmarkLineSet.contains(blockNumber + 1) && !m_bShownTextIsFiltered)
    222224            {
    223225                QPainterPath path;
     
    245247void UIVMLogViewerTextEdit::contextMenuEvent(QContextMenuEvent *pEvent)
    246248{
     249    /* If shown text is filtered, do not create Bookmark action since
     250       we disable all bookmarking related functionalities in this case. */
     251    if(m_bShownTextIsFiltered)
     252    {
     253        QPlainTextEdit::contextMenuEvent(pEvent);
     254        return;
     255    }
     256
    247257    QMenu *menu = createStandardContextMenu();
    248258    QAction *pAction = menu->addAction(tr("Bookmark"));
     
    257267
    258268    delete menu;
     269}
     270
     271void UIVMLogViewerTextEdit::paintEvent(QPaintEvent *pEvent)
     272{
     273    QPlainTextEdit::paintEvent(pEvent);
     274    if (m_bShownTextIsFiltered && viewport())
     275    {
     276        int rectHeight = 24;
     277        int rectWidth = 84;
     278        int rectX = viewport()->width() - rectWidth;
     279        int rectMargin = 4;
     280        if(verticalScrollBar())
     281            rectX -= verticalScrollBar()->width();
     282        QPainter painter(viewport());
     283        painter.fillRect(rectX, 0, rectWidth, rectHeight, QColor(125, 125, 125, 100));
     284        QFont nFont(painter.font());
     285        nFont.setPixelSize(rectHeight- 2 * rectMargin) ;
     286        painter.setFont(nFont);
     287        painter.setPen(QPen(QColor(255, 0, 0, 175), 1.8f));
     288        painter.drawText(rectX + rectMargin, rectMargin, rectWidth, rectHeight,
     289                         Qt::AlignLeft, "Filtered");
     290        viewport()->update();
     291    }
    259292}
    260293
     
    359392void UIVMLogViewerTextEdit::toggleBookmark(const QPair<int, QString>& bookmark)
    360393{
     394    if(m_bShownTextIsFiltered)
     395        return;
     396
    361397    int lineNumber = bookmark.first;
    362398
     
    367403}
    368404
     405void UIVMLogViewerTextEdit::setShownTextIsFiltered(bool warning)
     406{
     407    if(m_bShownTextIsFiltered == warning)
     408        return;
     409    m_bShownTextIsFiltered = warning;
     410}
     411
    369412#include "UIVMLogViewerTextEdit.moc"
  • trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerTextEdit.h

    r70574 r70578  
    2525
    2626/* QPlainTextEdit extension for some addtional context menu items,
    27    a special scrollbar, line number area, and bookmark support: */
     27   a special scrollbar, line number area, and bookmarking support: */
    2828class UIVMLogViewerTextEdit : public QPlainTextEdit
    2929{
     
    4646
    4747    void scrollToLine(int lineNumber);
    48 
    4948    void setBookmarkLineSet(const QSet<int>& lineSet);
     49    void setShownTextIsFiltered(bool warning);
    5050
    5151protected:
    5252
    53     void contextMenuEvent(QContextMenuEvent *pEvent) /* override */;
    54     void resizeEvent(QResizeEvent *pEvent) /* override */;
    55     void mouseMoveEvent(QMouseEvent *pEvent) /* override */;
     53    virtual void paintEvent(QPaintEvent *pEvent) /* override */;
     54    virtual void contextMenuEvent(QContextMenuEvent *pEvent) /* override */;
     55    virtual void resizeEvent(QResizeEvent *pEvent) /* override */;
     56    virtual void mouseMoveEvent(QMouseEvent *pEvent) /* override */;
    5657
    5758private slots:
     
    7980    /** Number of the line under the mouse cursor. */
    8081    int                  m_mouseCursorLine;
    81 
     82    /** If true the we draw a text near the top right corner of the text edit to warn
     83        the user the text edit's content is filtered (as oppesed to whole log file content.
     84        And we dont display bookmarks and adding/deleting bookmarks are disabled. */
     85    bool                 m_bShownTextIsFiltered;
    8286    friend class UILineNumberArea;
    8387};
  • trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerWidget.cpp

    r70559 r70578  
    128128}
    129129
    130 void UIVMLogViewerWidget::sltBoomarksUpdated()
     130void UIVMLogViewerWidget::sltUpdateBookmarkPanel()
    131131{
    132132    if(!currentLogPage() || !m_pBookmarksPanel)
     
    275275}
    276276
    277 void UIVMLogViewerWidget::sltFilterApplied()
    278 {
     277void UIVMLogViewerWidget::sltFilterApplied(bool isOriginal)
     278{
     279    if(currentLogPage())
     280        currentLogPage()->setFiltered(!isOriginal);
    279281    /* Reapply the search to get highlighting etc. correctly */
    280282    if (m_pSearchPanel && m_pSearchPanel->isVisible())
    281283        m_pSearchPanel->refresh();
     284}
     285
     286void UIVMLogViewerWidget::sltLogPageFilteredChanged(bool isFiltered)
     287{
     288    /* Disable bookmark panel since bookmarks are stored as line numbers within
     289       the original log text and does not mean much in a reduced/filtered one. */
     290    if(m_pBookmarksPanel)
     291    {
     292        if(isFiltered)
     293        {
     294            m_pBookmarksPanel->setEnabled(false);
     295            m_pBookmarksPanel->setVisible(false);
     296        }
     297        else
     298            m_pBookmarksPanel->setEnabled(true);
     299    }
    282300}
    283301
     
    743761    /* Create page-container: */
    744762    UIVMLogPage* pLogPage = new UIVMLogPage(this);
    745     connect(pLogPage, &UIVMLogPage::sigBookmarksUpdated, this, &UIVMLogViewerWidget::sltBoomarksUpdated);
     763    connect(pLogPage, &UIVMLogPage::sigBookmarksUpdated, this, &UIVMLogViewerWidget::sltUpdateBookmarkPanel);
     764    connect(pLogPage, &UIVMLogPage::sigLogPageFilteredChanged, this, &UIVMLogViewerWidget::sltLogPageFilteredChanged);
    746765    AssertPtrReturnVoid(pLogPage);
    747766    /* Set the file name only if we really have log file to read. */
  • trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerWidget.h

    r70549 r70578  
    9898        void sltDeleteAllBookmarks();
    9999        /** Manages bookmark panel update when bookmark vector is updated */
    100         void sltBoomarksUpdated();
     100        void sltUpdateBookmarkPanel();
    101101        /* Makes the current UIVMLogPage to goto (scroll) its bookmark with index @a index. */
    102102        void gotoBookmark(int bookmarkIndex);
     
    108108    /** Handles the tab change of the logviewer. */
    109109    void sltTabIndexChange(int tabIndex);
    110     void sltFilterApplied();
     110    /* if @a isOriginal true than the result of the filtering is equal to
     111       the original log file for some reason. */
     112    void sltFilterApplied(bool isOriginal);
     113    /* Handles the UIVMLogPage signal which is emitted when isFiltered property
     114       of UIVMLogPage is changed. */
     115    void sltLogPageFilteredChanged(bool isFiltered);
    111116
    112117private:
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