VirtualBox

Changeset 70617 in vbox


Ignore:
Timestamp:
Jan 18, 2018 7:50:33 AM (7 years ago)
Author:
vboxsync
Message:

FE/Qt bugref:9072 Deleting a bookmark does not result in scrolling to the next one in text editor

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

Legend:

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

    r70598 r70617  
    4343    , m_pTextEdit(0)
    4444    , m_tabIndex(tabIndex)
     45    , m_iSelectedBookmarkIndex(-1)
    4546    , m_bFiltered(false)
    4647    , m_bShowLineNumbers(true)
     
    143144void UIVMLogPage::setTextEdit(const QString &strText)
    144145{
    145     if(!m_pTextEdit)
     146    if (!m_pTextEdit)
    146147        return;
    147148
     
    156157void UIVMLogPage::setTextEditAsHtml(const QString &strText)
    157158{
    158     if(!m_pTextEdit)
     159    if (!m_pTextEdit)
    159160        return;
    160161    m_pTextEdit->appendHtml(strText);
     
    164165void UIVMLogPage::markForError()
    165166{
    166     if(!m_pTextEdit)
     167    if (!m_pTextEdit)
    167168        return;
    168169    m_pTextEdit->setWrapLines(true);
     
    242243void UIVMLogPage::showEvent(QShowEvent *pEvent)
    243244{
    244     if(m_pTextEdit)
     245    if (m_pTextEdit)
    245246        m_pTextEdit->setFocus();
    246247    QWidget::showEvent(pEvent);
     
    293294void UIVMLogPage::setShowLineNumbers(bool bShowLineNumbers)
    294295{
    295     if(m_bShowLineNumbers == bShowLineNumbers)
     296    if (m_bShowLineNumbers == bShowLineNumbers)
    296297        return;
    297298    m_bShowLineNumbers = bShowLineNumbers;
    298     if(m_pTextEdit)
     299    if (m_pTextEdit)
    299300        m_pTextEdit->setShowLineNumbers(m_bShowLineNumbers);
    300301    update();
     
    303304void UIVMLogPage::setWrapLines(bool bWrapLines)
    304305{
    305     if(m_bWrapLines == bWrapLines)
     306    if (m_bWrapLines == bWrapLines)
    306307        return;
    307308    m_bWrapLines = bWrapLines;
    308     if(m_pTextEdit)
     309    if (m_pTextEdit)
    309310        m_pTextEdit->setWrapLines(m_bWrapLines);
    310311    update();
  • trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogPage.h

    r70598 r70617  
    124124    /** Stores the bookmarks of the logpage. All other bookmark related containers are updated wrt. this one. */
    125125    QVector<LogBookmark> m_bookmarkVector;
     126    use following two variables
     127    /** Keeps the index of the selected bookmark. Used especially when moving from one tab to another. */
     128    int                  m_iSelectedBookmarkIndex;
     129    /** Keeps the scrolled line number. Used when switching between tabs. */
     130    int                  m_iScrolledLineNumber;
    126131    /** Designates whether currently displayed text is log text or a filtered version of it. That is
    127132        if m_bFiltered is false than (m_strLog == m_pTextEdit->text()). */
  • trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerBookmarksPanel.cpp

    r70610 r70617  
    3030/* GUI includes: */
    3131# include "QIToolButton.h"
     32# include "UIIconPool.h"
     33# include "UISpecialControls.h"
    3234# include "UIVMLogViewerBookmarksPanel.h"
    3335# include "UIVMLogViewerWidget.h"
     
    3739
    3840UIVMLogViewerBookmarksPanel::UIVMLogViewerBookmarksPanel(QWidget *pParent, UIVMLogViewerWidget *pViewer)
    39 : UIVMLogViewerPanel(pParent, pViewer)
     41    : UIVMLogViewerPanel(pParent, pViewer)
    4042    , m_iMaxBookmarkTextLength(60)
    4143    , m_pBookmarksComboBox(0)
     44    , m_pGotoSelectedBookmark(0)
    4245    , m_pDeleteAllButton(0)
    4346    , m_pDeleteCurrentButton(0)
     47    , m_pNextPrevButtons(0)
    4448{
    4549    prepare();
     
    5357    m_pBookmarksComboBox->clear();
    5458    QStringList bList;
    55     bList << "Bookmarks List";
     59    bList << "";
    5660    for (int i = 0; i < bookmarkVector.size(); ++i)
    5761    {
     
    6771    }
    6872    m_pBookmarksComboBox->addItems(bList);
    69     /* Goto last item of the combobox: */
     73    /* Goto last item of the combobox. Avoid emitting sigBookmarkSelected since we dont want text edit to scroll to there: */
     74    disconnect(m_pBookmarksComboBox, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
     75               this, &UIVMLogViewerBookmarksPanel::sltBookmarkSelected);
    7076    m_pBookmarksComboBox->setCurrentIndex(m_pBookmarksComboBox->count()-1);
     77    connect(m_pBookmarksComboBox, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
     78            this, &UIVMLogViewerBookmarksPanel::sltBookmarkSelected);
    7179}
    7280
     
    96104    m_pBookmarksComboBox->setMaximumWidth(fontMetrics.width('a') * (m_iMaxBookmarkTextLength + 2));
    97105    /* Make sure we have 0th item in our combo box. */
    98     m_pBookmarksComboBox->insertItem(0, "Bookmarks List");
    99 
    100 
    101     mainLayout()->addWidget(m_pBookmarksComboBox, 2/*, Qt::AlignLeft*/);
     106    m_pBookmarksComboBox->insertItem(0, "");
     107    mainLayout()->addWidget(m_pBookmarksComboBox, 2);
     108
     109    m_pGotoSelectedBookmark = new QIToolButton(this);
     110    AssertPtrReturnVoid(m_pGotoSelectedBookmark);
     111    mainLayout()->addWidget(m_pGotoSelectedBookmark, 0);
     112    m_pGotoSelectedBookmark->setIcon(UIIconPool::defaultIcon(UIIconPool::UIDefaultIconType_ArrowForward, this));
     113
     114
     115    m_pNextPrevButtons = new UIRoundRectSegmentedButton(this, 2);
     116    AssertPtrReturnVoid(m_pNextPrevButtons);
     117    m_pNextPrevButtons->setEnabled(0, false);
     118    m_pNextPrevButtons->setEnabled(1, false);
     119#ifndef VBOX_WS_MAC
     120    /* No icons on the Mac: */
     121    m_pNextPrevButtons->setIcon(0, UIIconPool::defaultIcon(UIIconPool::UIDefaultIconType_ArrowBack, this));
     122    m_pNextPrevButtons->setIcon(1, UIIconPool::defaultIcon(UIIconPool::UIDefaultIconType_ArrowForward, this));
     123#endif /* !VBOX_WS_MAC */
     124    mainLayout()->addWidget(m_pNextPrevButtons);
     125    m_pNextPrevButtons->setEnabled(0, true);
     126    m_pNextPrevButtons->setEnabled(1, true);
    102127
    103128    m_pDeleteCurrentButton = new QIToolButton(this);
     129    AssertPtrReturnVoid(m_pDeleteCurrentButton);
     130    mainLayout()->addWidget(m_pDeleteCurrentButton, 0);
    104131    m_pDeleteCurrentButton->setIcon(m_pDeleteCurrentButton->style()->standardIcon(QStyle::SP_TitleBarCloseButton));
    105 
    106     AssertPtrReturnVoid(m_pBookmarksComboBox);
    107     mainLayout()->addWidget(m_pDeleteCurrentButton, 0);
    108132
    109133    m_pDeleteAllButton = new QIToolButton(this);
     
    118142    connect(m_pBookmarksComboBox, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
    119143            this, &UIVMLogViewerBookmarksPanel::sltBookmarkSelected);
     144
     145    connect(m_pGotoSelectedBookmark, &QIToolButton::clicked, this, &UIVMLogViewerBookmarksPanel::sltGotoSelectedBookmark);
     146    connect(m_pNextPrevButtons, &UIRoundRectSegmentedButton::clicked, this, &UIVMLogViewerBookmarksPanel::sltGotoNextPreviousBookmark);
     147
    120148    connect(m_pDeleteAllButton, &QIToolButton::clicked, this, &UIVMLogViewerBookmarksPanel::sigDeleteAllBookmarks);
    121149    connect(m_pDeleteCurrentButton, &QIToolButton::clicked, this, &UIVMLogViewerBookmarksPanel::sltDeleteCurrentBookmark);
     
    127155    if (m_pDeleteCurrentButton)
    128156        m_pDeleteCurrentButton->setToolTip(UIVMLogViewerWidget::tr("Delete the current bookmark."));
     157
    129158    if (m_pDeleteAllButton)
    130159    {
     
    132161        m_pDeleteAllButton->setText(UIVMLogViewerWidget::tr("Delete all"));
    133162    }
     163
     164    if (m_pNextPrevButtons)
     165    {
     166        m_pNextPrevButtons->setToolTip(0, UIVMLogViewerWidget::tr("Goto the previous bookmark"));
     167        m_pNextPrevButtons->setToolTip(1, UIVMLogViewerWidget::tr("Goto the next bookmark"));
     168    }
     169
     170    if (m_pGotoSelectedBookmark)
     171        m_pGotoSelectedBookmark->setToolTip(UIVMLogViewerWidget::tr("Goto selected bookmark."));
     172
    134173    UIVMLogViewerPanel::retranslateUi();
    135174}
     
    150189    if (index <= 0)
    151190        return;
    152    emit sigBookmarkSelected(index - 1);
    153 }
     191    emit sigBookmarkSelected(index - 1);
     192}
     193
     194void UIVMLogViewerBookmarksPanel::sltGotoNextPreviousBookmark(int buttonIndex)
     195{
     196    if (!m_pBookmarksComboBox || m_pBookmarksComboBox->count() <= 1)
     197        return;
     198
     199    /* go to previous bookmark or wrap around to the end of the list: */
     200    if (buttonIndex == 0)
     201    {
     202        if (m_pBookmarksComboBox->currentIndex() <= 1)
     203            m_pBookmarksComboBox->setCurrentIndex(m_pBookmarksComboBox->count() - 1);
     204        else
     205            m_pBookmarksComboBox->setCurrentIndex(m_pBookmarksComboBox->currentIndex() - 1);
     206    }
     207    /* go to next bookmark or wrap around to the beginning of the list: */
     208    else if (buttonIndex == 1)
     209    {
     210        if (m_pBookmarksComboBox->currentIndex() == m_pBookmarksComboBox->count()-1)
     211            m_pBookmarksComboBox->setCurrentIndex(1);
     212        else
     213            m_pBookmarksComboBox->setCurrentIndex(m_pBookmarksComboBox->currentIndex() + 1);
     214    }
     215}
     216
     217void UIVMLogViewerBookmarksPanel::sltGotoSelectedBookmark()
     218{
     219    if (!m_pBookmarksComboBox || m_pBookmarksComboBox->count() <= 1)
     220        return;
     221    emit sigBookmarkSelected(m_pBookmarksComboBox->currentIndex() - 1);
     222}
  • trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerBookmarksPanel.h

    r70610 r70617  
    2525class QComboBox;
    2626class QIToolButton;
     27class UIRoundRectSegmentedButton;
    2728
    2829/** UIVMLogViewerPanel extension providing GUI for bookmark management. Show a list of bookmarks currently set
     
    6465    void sltDeleteCurrentBookmark();
    6566    void sltBookmarkSelected(int index);
     67    void sltGotoNextPreviousBookmark(int buttonIndex);
     68    void sltGotoSelectedBookmark();
    6669
    6770private:
     
    7275    const int     m_iMaxBookmarkTextLength;
    7376    QComboBox    *m_pBookmarksComboBox;
     77    QIToolButton *m_pGotoSelectedBookmark;
    7478    QIToolButton *m_pDeleteAllButton;
    7579    QIToolButton *m_pDeleteCurrentButton;
     80    UIRoundRectSegmentedButton *m_pNextPrevButtons;
    7681};
    7782
  • trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerSettingsPanel.cpp

    r70581 r70617  
    4646void UIVMLogViewerSettingsPanel::setShowLineNumbers(bool bShowLineNumbers)
    4747{
    48     if(!m_pLineNumberCheckBox)
     48    if (!m_pLineNumberCheckBox)
    4949        return;
    50     if(m_pLineNumberCheckBox->isChecked() == bShowLineNumbers)
     50    if (m_pLineNumberCheckBox->isChecked() == bShowLineNumbers)
    5151        return;
    5252    m_pLineNumberCheckBox->setChecked(bShowLineNumbers);
     
    5555void UIVMLogViewerSettingsPanel::setWrapLines(bool bWrapLines)
    5656{
    57     if(!m_pWrapLinesCheckBox)
     57    if (!m_pWrapLinesCheckBox)
    5858        return;
    59     if(m_pWrapLinesCheckBox->isChecked() == bWrapLines)
     59    if (m_pWrapLinesCheckBox->isChecked() == bWrapLines)
    6060        return;
    6161    m_pWrapLinesCheckBox->setChecked(bWrapLines);
  • trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerTextEdit.cpp

    r70598 r70617  
    208208int UIVMLogViewerTextEdit::lineNumberAreaWidth()
    209209{
    210     if(!m_bShowLineNumbers)
     210    if (!m_bShowLineNumbers)
    211211        return 0;
    212212
     
    225225void UIVMLogViewerTextEdit::lineNumberAreaPaintEvent(QPaintEvent *event)
    226226{
    227     if(!m_bShowLineNumbers)
     227    if (!m_bShowLineNumbers)
    228228        return;
    229229    QPainter painter(m_pLineNumberArea);
     
    436436void UIVMLogViewerTextEdit::setShowLineNumbers(bool bShowLineNumbers)
    437437{
    438     if(m_bShowLineNumbers == bShowLineNumbers)
     438    if (m_bShowLineNumbers == bShowLineNumbers)
    439439        return;
    440440    m_bShowLineNumbers = bShowLineNumbers;
     
    444444void UIVMLogViewerTextEdit::setWrapLines(bool bWrapLines)
    445445{
    446     if(m_bWrapLines == bWrapLines)
     446    if (m_bWrapLines == bWrapLines)
    447447        return;
    448448    m_bWrapLines = bWrapLines;
    449     if(m_bWrapLines)
     449    if (m_bWrapLines)
    450450    {
    451451        setLineWrapMode(QPlainTextEdit::WidgetWidth);
  • trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerWidget.cpp

    r70598 r70617  
    136136    if (!currentLogPage() || !m_pBookmarksPanel)
    137137        return;
    138     disconnect(m_pBookmarksPanel, &UIVMLogViewerBookmarksPanel::sigBookmarkSelected,
    139             this, &UIVMLogViewerWidget::gotoBookmark);
    140138    m_pBookmarksPanel->updateBookmarkList(currentLogPage()->bookmarkVector());
    141     connect(m_pBookmarksPanel, &UIVMLogViewerBookmarksPanel::sigBookmarkSelected,
    142             this, &UIVMLogViewerWidget::gotoBookmark);
    143139}
    144140
  • trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerWidget.h

    r70581 r70617  
    4444class UIVMLogViewerSettingsPanel;
    4545
    46 /* Type definitions: */
    47 /** value is the content of the log file */
    48 //typedef QMap<QPlainTextEdit*, QString> VMLogMap;
    49 /** first is line number, second is block text */
    50 //typedef QPair<int, QString> LogBookmark;
    51 /** key is log file name, value is a vector of bookmarks. */
    52 //typedef QMap<QString, QVector<LogBookmark> > BookmarkMap;
    53 
    5446
    5547/** QWidget extension providing GUI for VirtualBox LogViewer. It
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