VirtualBox

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


Ignore:
Timestamp:
Apr 17, 2018 1:49:21 PM (7 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9049: Full cleanup for QIStyledItemDelegate and move it to VBoxGlobal library.

Location:
trunk/src/VBox/Frontends/VirtualBox
Files:
2 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk

    r71871 r71874  
    443443        src/extensions/QIMenu.h \
    444444        src/extensions/QIStatusBar.h \
    445         src/extensions/QIStyledItemDelegate.h \
    446445        src/extensions/QITabWidget.h \
    447446        src/extensions/QITableView.h \
     
    666665        src/extensions/QISplitter.h \
    667666        src/extensions/QIStatusBarIndicator.h \
     667        src/extensions/QIStyledItemDelegate.h \
    668668        src/extensions/QIToolButton.h \
    669669        src/extensions/QIWidgetValidator.h \
     
    744744        src/extensions/QISplitter.h \
    745745        src/extensions/QIStatusBarIndicator.h \
     746        src/extensions/QIStyledItemDelegate.h \
    746747        src/extensions/QIToolButton.h \
    747748        src/extensions/QIWidgetValidator.h \
     
    11681169        src/extensions/QISplitter.cpp \
    11691170        src/extensions/QIStatusBarIndicator.cpp \
     1171        src/extensions/QIStyledItemDelegate.cpp \
    11701172        src/extensions/QIToolButton.cpp \
    11711173        src/extensions/QIWidgetValidator.cpp \
     
    12731275        src/extensions/QISplitter.cpp \
    12741276        src/extensions/QIStatusBarIndicator.cpp \
     1277        src/extensions/QIStyledItemDelegate.cpp \
    12751278        src/extensions/QIToolButton.cpp \
    12761279        src/extensions/QIWidgetValidator.cpp \
  • trunk/src/VBox/Frontends/VirtualBox/src/extensions/QIStyledItemDelegate.cpp

    r71850 r71874  
    11/* $Id$ */
    22/** @file
    3  * VBox Qt GUI - QIStyledItemDelegate class declaration.
     3 * VBox Qt GUI - Qt extensions: QIStyledItemDelegate class implementation.
    44 */
    55
    66/*
    7  * Copyright (C) 2006-2017 Oracle Corporation
     7 * Copyright (C) 2006-2018 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    1616 */
    1717
    18 #ifndef ___QIStyledItemDelegate_h___
    19 #define ___QIStyledItemDelegate_h___
    20 
    21 /* Qt includes: */
    22 # include <QStyledItemDelegate>
     18/* GUI includes: */
     19#include "QIStyledItemDelegate.h"
    2320
    2421
    25 /** QStyledItemDelegate subclass extending standard functionality. */
    26 class QIStyledItemDelegate : public QStyledItemDelegate
     22QIStyledItemDelegate::QIStyledItemDelegate(QObject *pParent)
     23    : QStyledItemDelegate(pParent)
     24    , m_fWatchForEditorDataCommits(false)
     25    , m_fWatchForEditorEnterKeyTriggering(false)
    2726{
    28     Q_OBJECT;
     27}
    2928
    30 signals:
     29void QIStyledItemDelegate::setWatchForEditorDataCommits(bool fWatch)
     30{
     31    m_fWatchForEditorDataCommits = fWatch;
     32}
    3133
    32     /** Notifies listeners about @a pEditor created for particular model @a index. */
    33     void sigEditorCreated(QWidget *pEditor, const QModelIndex &index) const;
     34void QIStyledItemDelegate::setWatchForEditorEnterKeyTriggering(bool fWatch)
     35{
     36    m_fWatchForEditorEnterKeyTriggering = fWatch;
     37}
    3438
    35     /** Notifies listeners about editor's Enter key triggering. */
    36     void sigEditorEnterKeyTriggered();
     39QWidget *QIStyledItemDelegate::createEditor(QWidget *pParent,
     40                                            const QStyleOptionViewItem &option,
     41                                            const QModelIndex &index) const
     42{
     43    /* Call to base-class to get actual editor created: */
     44    QWidget *pEditor = QStyledItemDelegate::createEditor(pParent, option, index);
    3745
    38 public:
     46    /* Watch for editor data commits, redirect to listeners: */
     47    if (m_fWatchForEditorDataCommits)
     48        connect(pEditor, SIGNAL(sigCommitData(QWidget *)), this, SIGNAL(commitData(QWidget *)));
    3949
    40     /** Constructs delegate passing @a pParent to the base-class. */
    41     QIStyledItemDelegate(QObject *pParent)
    42         : QStyledItemDelegate(pParent)
    43         , m_fWatchForEditorDataCommits(false)
    44         , m_fWatchForEditorEnterKeyTriggering(false)
    45     {}
     50    /* Watch for editor Enter key triggering, redirect to listeners: */
     51    if (m_fWatchForEditorEnterKeyTriggering)
     52        connect(pEditor, SIGNAL(sigEnterKeyTriggered()), this, SIGNAL(sigEditorEnterKeyTriggered()));
    4653
    47     /** Defines whether delegate should watch for the editor's data commits. */
    48     void setWatchForEditorDataCommits(bool fWatch) { m_fWatchForEditorDataCommits = fWatch; }
    49     /** Defines whether delegate should watch for the editor's Enter key triggering. */
    50     void setWatchForEditorEnterKeyTriggering(bool fWatch) { m_fWatchForEditorEnterKeyTriggering = fWatch; }
     54    /* Notify listeners about editor created: */
     55    emit sigEditorCreated(pEditor, index);
    5156
    52 protected:
    53 
    54     /** Returns the widget used to edit the item specified by @a index.
    55       * The @a pParent widget and style @a option are used to control how the editor widget appears. */
    56     virtual QWidget *createEditor(QWidget *pParent, const QStyleOptionViewItem &option, const QModelIndex &index) const /* override */
    57     {
    58         /* Call to base-class to get actual editor created: */
    59         QWidget *pEditor = QStyledItemDelegate::createEditor(pParent, option, index);
    60 
    61         /* Watch for editor data commits, redirect to listeners: */
    62         if (m_fWatchForEditorDataCommits)
    63             connect(pEditor, SIGNAL(sigCommitData(QWidget *)), this, SIGNAL(commitData(QWidget *)));
    64 
    65         /* Watch for editor Enter key triggering, redirect to listeners: */
    66         if (m_fWatchForEditorEnterKeyTriggering)
    67             connect(pEditor, SIGNAL(sigEnterKeyTriggered()), this, SIGNAL(sigEditorEnterKeyTriggered()));
    68 
    69         /* Notify listeners about editor created: */
    70         emit sigEditorCreated(pEditor, index);
    71 
    72         /* Return actual editor: */
    73         return pEditor;
    74     }
    75 
    76 private:
    77 
    78     /** Holds whether delegate should watch for the editor's data commits. */
    79     bool m_fWatchForEditorDataCommits : 1;
    80     /** Holds whether delegate should watch for the editor's Enter key triggering. */
    81     bool m_fWatchForEditorEnterKeyTriggering : 1;
    82 };
    83 
    84 #endif /* !___QIStyledItemDelegate_h___ */
    85 
     57    /* Return actual editor: */
     58    return pEditor;
     59}
  • trunk/src/VBox/Frontends/VirtualBox/src/extensions/QIStyledItemDelegate.h

    r71027 r71874  
    11/* $Id$ */
    22/** @file
    3  * VBox Qt GUI - QIStyledItemDelegate class declaration.
     3 * VBox Qt GUI - Qt extensions: QIStyledItemDelegate class declaration.
    44 */
    55
    66/*
    7  * Copyright (C) 2006-2017 Oracle Corporation
     7 * Copyright (C) 2006-2018 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2020
    2121/* Qt includes: */
    22 # include <QStyledItemDelegate>
     22#include <QStyledItemDelegate>
    2323
     24/* GUI includes: */
     25#include "UILibraryDefs.h"
    2426
    2527/** QStyledItemDelegate subclass extending standard functionality. */
    26 class QIStyledItemDelegate : public QStyledItemDelegate
     28class SHARED_LIBRARY_STUFF QIStyledItemDelegate : public QStyledItemDelegate
    2729{
    2830    Q_OBJECT;
     
    3941
    4042    /** Constructs delegate passing @a pParent to the base-class. */
    41     QIStyledItemDelegate(QObject *pParent)
    42         : QStyledItemDelegate(pParent)
    43         , m_fWatchForEditorDataCommits(false)
    44         , m_fWatchForEditorEnterKeyTriggering(false)
    45     {}
     43    QIStyledItemDelegate(QObject *pParent);
    4644
    4745    /** Defines whether delegate should watch for the editor's data commits. */
    48     void setWatchForEditorDataCommits(bool fWatch) { m_fWatchForEditorDataCommits = fWatch; }
     46    void setWatchForEditorDataCommits(bool fWatch);
    4947    /** Defines whether delegate should watch for the editor's Enter key triggering. */
    50     void setWatchForEditorEnterKeyTriggering(bool fWatch) { m_fWatchForEditorEnterKeyTriggering = fWatch; }
     48    void setWatchForEditorEnterKeyTriggering(bool fWatch);
    5149
    5250protected:
     
    5452    /** Returns the widget used to edit the item specified by @a index.
    5553      * The @a pParent widget and style @a option are used to control how the editor widget appears. */
    56     virtual QWidget *createEditor(QWidget *pParent, const QStyleOptionViewItem &option, const QModelIndex &index) const /* override */
    57     {
    58         /* Call to base-class to get actual editor created: */
    59         QWidget *pEditor = QStyledItemDelegate::createEditor(pParent, option, index);
    60 
    61         /* Watch for editor data commits, redirect to listeners: */
    62         if (m_fWatchForEditorDataCommits)
    63             connect(pEditor, SIGNAL(sigCommitData(QWidget *)), this, SIGNAL(commitData(QWidget *)));
    64 
    65         /* Watch for editor Enter key triggering, redirect to listeners: */
    66         if (m_fWatchForEditorEnterKeyTriggering)
    67             connect(pEditor, SIGNAL(sigEnterKeyTriggered()), this, SIGNAL(sigEditorEnterKeyTriggered()));
    68 
    69         /* Notify listeners about editor created: */
    70         emit sigEditorCreated(pEditor, index);
    71 
    72         /* Return actual editor: */
    73         return pEditor;
    74     }
     54    virtual QWidget *createEditor(QWidget *pParent,
     55                                  const QStyleOptionViewItem &option,
     56                                  const QModelIndex &index) const /* override */;
    7557
    7658private:
     
    8365
    8466#endif /* !___QIStyledItemDelegate_h___ */
    85 
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