VirtualBox

Changeset 70473 in vbox


Ignore:
Timestamp:
Jan 6, 2018 6:46:16 PM (7 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9072 Some improvements to log viewer's filter pane

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

Legend:

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

    r70469 r70473  
    2323# include <QButtonGroup>
    2424# include <QComboBox>
     25# include <QFrame>
    2526# include <QHBoxLayout>
    2627# if defined(RT_OS_SOLARIS)
     
    178179    , m_pAndRadioButton(0)
    179180    , m_pOrRadioButton(0)
     181    , m_pRadioButtonContainer(0)
    180182    , m_pAddFilterTermButton(0)
    181183    , m_eFilterOperatorButton(AndButton)
    182184    , m_pFilterTermsLineEdit(0)
     185    , m_pResultLabel(0)
     186    , m_iUnfilteredLineCount(0)
     187    , m_iFilteredLineCount(0)
    183188{
    184189    prepare();
     
    188193{
    189194    Q_UNUSED(iCurrentIndex);
     195    filter();
     196    retranslateUi();
     197}
     198
     199void UIVMLogViewerFilterPanel::filter()
     200{
    190201    QPlainTextEdit *pCurrentPage = m_pViewer->currentLogPage();
    191202    AssertReturnVoid(pCurrentPage);
    192203    const QString& strInputText = m_pViewer->currentLog();
     204    m_iUnfilteredLineCount = 0;
     205    m_iFilteredLineCount = 0;
    193206    if (strInputText.isNull())
    194207        return;
     208    QTextDocument *document = pCurrentPage->document();
     209    if (!document)
     210        return;
     211    QStringList stringLines = strInputText.split("\n");
     212    m_iUnfilteredLineCount = stringLines.size();
    195213    if (m_filterTermList.empty())
    196214    {
    197         QTextDocument *document = pCurrentPage->document();
    198         if (document)
    199             document->setPlainText(strInputText);
     215        document->setPlainText(strInputText);
    200216        emit sigFilterApplied();
    201         return;
    202     }
    203     QStringList stringLines = strInputText.split("\n");
     217        m_iFilteredLineCount = document->lineCount();
     218        return;
     219    }
     220
    204221    /* Prepare filter-data: */
    205222    QString strFilteredText;
     
    217234    }
    218235
    219     QTextDocument *document = pCurrentPage->document();
    220     if (document)
    221         document->setPlainText(strFilteredText);
     236    document->setPlainText(strFilteredText);
     237    m_iFilteredLineCount = document->lineCount();
    222238
    223239    /* Move the cursor position to end: */
     
    328344    m_pCloseButton = new UIMiniCancelButton(this);
    329345    AssertPtrReturnVoid(m_pCloseButton);
    330     {
    331         m_pMainLayout->addWidget(m_pCloseButton);
    332     }
    333 
    334     m_pFilterTermsLineEdit = new UIVMFilterLineEdit(this);
    335     AssertPtrReturnVoid(m_pFilterTermsLineEdit);
    336     {
    337         m_pMainLayout->addWidget(m_pFilterTermsLineEdit, 4);
    338         m_pFilterTermsLineEdit->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum /*vertical */);
    339     }
    340 
    341     m_pButtonGroup = new QButtonGroup(this);
    342     AssertPtrReturnVoid(m_pButtonGroup);
    343     {
    344         m_pAndRadioButton = new QRadioButton(this);
    345         m_pOrRadioButton =  new QRadioButton(this);
    346         AssertPtrReturnVoid(m_pAndRadioButton);
    347         AssertPtrReturnVoid(m_pOrRadioButton);
    348         m_pButtonGroup->addButton(m_pAndRadioButton, static_cast<int>(AndButton));
    349         m_pButtonGroup->addButton(m_pOrRadioButton, static_cast<int>(OrButton));
    350 
    351         m_pOrRadioButton->setText("Or");
    352         m_pAndRadioButton->setText("And");
    353 
    354         m_pOrRadioButton->setChecked(true);
    355         m_eFilterOperatorButton = OrButton;
    356 
    357         m_pMainLayout->addWidget(m_pOrRadioButton);
    358         m_pMainLayout->addWidget(m_pAndRadioButton);
    359     }
     346    m_pMainLayout->addWidget(m_pCloseButton);
     347
     348    prepareRadioButtonGroup();
    360349
    361350    m_pFilterComboBox = new QComboBox(this);
     
    374363    AssertPtrReturnVoid(m_pAddFilterTermButton);
    375364    {
     365        m_pAddFilterTermButton->setIcon(UIIconPool::defaultIcon(UIIconPool::UIDefaultIconType_ArrowForward, this));
    376366        m_pMainLayout->addWidget(m_pAddFilterTermButton,0);
    377367    }
    378368
     369    m_pFilterTermsLineEdit = new UIVMFilterLineEdit(this);
     370    AssertPtrReturnVoid(m_pFilterTermsLineEdit);
     371    {
     372        m_pMainLayout->addWidget(m_pFilterTermsLineEdit, 4);
     373        m_pFilterTermsLineEdit->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum /*vertical */);
     374    }
     375
     376    m_pResultLabel = new QLabel(this);
     377    AssertPtrReturnVoid(m_pResultLabel);
     378    {
     379        m_pMainLayout->addWidget(m_pResultLabel,0);
     380    }
    379381        /* Create filter-label: */
    380382//         m_pFilterLabel = new QLabel(this);
     
    393395}
    394396
     397void UIVMLogViewerFilterPanel::prepareRadioButtonGroup()
     398{
     399    m_pButtonGroup = new QButtonGroup(this);
     400    AssertPtrReturnVoid(m_pButtonGroup);
     401
     402    m_pRadioButtonContainer = new QFrame(this);
     403    m_pRadioButtonContainer->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken);
     404    AssertPtrReturnVoid(m_pRadioButtonContainer);
     405
     406    QHBoxLayout* containerLayout = (new QHBoxLayout(m_pRadioButtonContainer));
     407    AssertPtrReturnVoid(containerLayout);
     408    containerLayout->setContentsMargins(0, 0, 0, 0);
     409    containerLayout->setSpacing(0);
     410
     411    m_pAndRadioButton = new QRadioButton(this);
     412    m_pOrRadioButton =  new QRadioButton(this);
     413    AssertPtrReturnVoid(m_pAndRadioButton);
     414    AssertPtrReturnVoid(m_pOrRadioButton);
     415
     416    m_pButtonGroup->addButton(m_pAndRadioButton, static_cast<int>(AndButton));
     417    m_pButtonGroup->addButton(m_pOrRadioButton, static_cast<int>(OrButton));
     418    m_pOrRadioButton->setText("Or");
     419    m_pAndRadioButton->setText("And");
     420    m_pOrRadioButton->setChecked(true);
     421    m_eFilterOperatorButton = OrButton;
     422
     423    containerLayout->addWidget(m_pOrRadioButton);
     424    containerLayout->addWidget(m_pAndRadioButton);
     425    m_pMainLayout->addWidget(m_pRadioButtonContainer);
     426}
     427
    395428void UIVMLogViewerFilterPanel::prepareConnections()
    396429{
     
    407440}
    408441
     442
    409443void UIVMLogViewerFilterPanel::retranslateUi()
    410444{
    411     m_pCloseButton->setToolTip(UIVMLogViewerWidget::tr("Close the search panel"));
    412     //m_pFilterLabel->setText(UIVMLogViewerWidget::tr("Filter"));
    413     m_pFilterComboBox->setToolTip(UIVMLogViewerWidget::tr("Enter filtering string here"));
    414     m_pAddFilterTermButton->setText(UIVMLogViewerWidget::tr("Add"));
    415     m_pAddFilterTermButton->setToolTip(UIVMLogViewerWidget::tr("Add filter term"));
     445    m_pCloseButton->setToolTip(UIVMLogViewerWidget::tr("Close the search panel."));
     446    m_pFilterComboBox->setToolTip(UIVMLogViewerWidget::tr("Enter filtering string here."));
     447    m_pAddFilterTermButton->setToolTip(UIVMLogViewerWidget::tr("Add filter term."));
     448    m_pResultLabel->setText(UIVMLogViewerWidget::tr("Showing %1/%2").arg(m_iFilteredLineCount).arg(m_iUnfilteredLineCount));
     449    m_pFilterTermsLineEdit->setToolTip(UIVMLogViewerWidget::tr("The filter terms list. Select one to remove or click the button on the right side to remove them all."));
     450    m_pRadioButtonContainer->setToolTip(UIVMLogViewerWidget::tr("The type of boolean operator for filter operation."));
    416451}
    417452
  • trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerFilterPanel.h

    r70466 r70473  
    2828class QButtonGroup;
    2929class QComboBox;
     30class QFrame;
    3031class QHBoxLayout;
    3132class QLabel;
     
    7980    /** Prepares filter-panel. */
    8081    void prepare();
    81     /** Prepares widgets. */
    8282    void prepareWidgets();
    83     /** Prepares connections. */
     83    void prepareRadioButtonGroup();
    8484    void prepareConnections();
    8585
     
    9595
    9696    bool applyFilterTermsToString(const QString& string);
     97    void filter();
    9798
    9899    /** Holds the reference to VM Log-Viewer this filter-panel belongs to. */
     
    110111    QRadioButton        *m_pAndRadioButton;
    111112    QRadioButton        *m_pOrRadioButton;
     113    QFrame              *m_pRadioButtonContainer;
    112114    QPushButton         *m_pAddFilterTermButton;
    113115    QStringList          m_filterTermList;
    114116    FilterOperatorButton m_eFilterOperatorButton;
    115117    UIVMFilterLineEdit  *m_pFilterTermsLineEdit;
     118    QLabel              *m_pResultLabel;
     119    int                  m_iUnfilteredLineCount;
     120    int                  m_iFilteredLineCount;
    116121};
    117122
  • trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerWidget.cpp

    r70308 r70473  
    698698        /* Create Log-Viewer: */
    699699        QPlainTextEdit *pLogViewer = new QPlainTextEdit(pPageContainer);
     700
    700701        AssertPtrReturn(pLogViewer, 0);
    701702        {
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