VirtualBox

Changeset 72697 in vbox for trunk


Ignore:
Timestamp:
Jun 27, 2018 7:21:20 AM (7 years ago)
Author:
vboxsync
Message:

FE/Qt: Cleanup in UIMediumSelector widget

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumSelector.cpp

    r72696 r72697  
    5656#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
    5757
    58 /*********************************************************************************************************************************
    59 *   UISearchLineEdit definition.                                                                                           *
    60 *********************************************************************************************************************************/
    61 
    62 class UISearchLineEdit : public QILineEdit
    63 {
    64     Q_OBJECT;
    65 
    66 signals:
    67 
    68     void sigFilterTermRemoved(QString removedString);
    69     void sigClearAll();
    70 
    71 public:
    72 
    73     UISearchLineEdit(QWidget *parent = 0);
    74 
    75 protected:
    76 
    77     // /* Delete mouseDoubleClick and mouseMoveEvent implementations of the base class */
    78     // virtual void        mouseDoubleClickEvent(QMouseEvent *) /* override */{}
    79     // virtual void        mouseMoveEvent(QMouseEvent *) /* override */{}
    80     // /* Override the mousePressEvent to control how selection is done: */
    81     // virtual void        mousePressEvent(QMouseEvent * event) /* override */;
    82     // virtual void        mouseReleaseEvent(QMouseEvent *){}
    83     virtual void        paintEvent(QPaintEvent *event) /* override */;
    84 
    85 private slots:
    86 
    87     /* The whole content is removed. Listeners are notified: */
    88     void sltClearAll();
    89 
    90 private:
    91 
    92     void          createButtons();
    93     QIToolButton *m_pClearAllButton;
    94 };
    9558
    9659class UIMediumSearchWidget : public QWidget
     
    12285    void prepareWidgets();
    12386    QIComboBox       *m_pSearchComboxBox;
    124     UISearchLineEdit *m_pSearchTermLineEdit;
     87    QLineEdit        *m_pSearchTermLineEdit;
    12588};
    126 
    127 
    128 /*********************************************************************************************************************************
    129 *   UISearchLineEdit implementation.                                                                                             *
    130 *********************************************************************************************************************************/
    131 
    132 UISearchLineEdit::UISearchLineEdit(QWidget *parent /*= 0*/)
    133     :QILineEdit(parent)
    134     , m_pClearAllButton(0)
    135 {
    136     createButtons();
    137 }
    138 
    139 void UISearchLineEdit::paintEvent(QPaintEvent *event)
    140 {
    141     QLineEdit::paintEvent(event);
    142 
    143     if (!m_pClearAllButton)
    144         createButtons();
    145     int clearButtonSize = height();
    146     m_pClearAllButton->setGeometry(width() - clearButtonSize, 0, clearButtonSize, clearButtonSize);
    147 }
    148 
    149 void UISearchLineEdit::sltClearAll()
    150 {
    151     /* Check if we have some text to avoid recursive calls: */
    152     if (text().isEmpty())
    153         return;
    154 
    155     clear();
    156     emit sigClearAll();
    157 }
    158 
    159 void UISearchLineEdit::createButtons()
    160 {
    161     if (!m_pClearAllButton)
    162     {
    163         m_pClearAllButton = new QIToolButton(this);
    164         if (m_pClearAllButton)
    165         {
    166             m_pClearAllButton->setIcon(m_pClearAllButton->style()->standardIcon(QStyle::SP_LineEditClearButton));
    167             connect(m_pClearAllButton, &QIToolButton::clicked, this, &UISearchLineEdit::sltClearAll);
    168         }
    169     }
    170 }
    171 
    17289
    17390/*********************************************************************************************************************************
     
    203120    }
    204121
    205     m_pSearchTermLineEdit = new UISearchLineEdit;
    206     if (pLayout)
    207     {
     122    m_pSearchTermLineEdit = new QLineEdit;
     123    if (m_pSearchTermLineEdit)
     124    {
     125        m_pSearchTermLineEdit->setClearButtonEnabled(true);
    208126        pLayout->addWidget(m_pSearchTermLineEdit);
    209127        connect(m_pSearchTermLineEdit, &QILineEdit::textChanged,
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