VirtualBox

Changeset 79720 in vbox


Ignore:
Timestamp:
Jul 12, 2019 8:10:01 AM (5 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9495: Form Editor wizard: Using QIStyledItemDelegate allowing choice-editor to commit data on-the-fly.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIFormEditorWidget.cpp

    r79365 r79720  
    2525#include <QSortFilterProxyModel>
    2626#include <QSpinBox>
    27 #include <QStyledItemDelegate>
    2827#include <QTextEdit>
    2928#include <QVBoxLayout>
     
    3231#include "QIDialog.h"
    3332#include "QIDialogButtonBox.h"
     33#include "QIStyledItemDelegate.h"
    3434#include "QITableView.h"
    3535#include "QIWithRetranslateUI.h"
     
    202202    Q_PROPERTY(TextData text READ text WRITE setText USER true);
    203203
     204signals:
     205
     206    /** Notifies listener about data should be committed. */
     207    void sigCommitData(QWidget *pThis);
     208
    204209public:
    205210
     
    242247    Q_PROPERTY(ChoiceData choice READ choice WRITE setChoice USER true);
    243248
     249signals:
     250
     251    /** Notifies listener about data should be committed. */
     252    void sigCommitData(QWidget *pThis);
     253
    244254public:
    245255
    246256    /** Constructs ChoiceData editor passing @a pParent to the base-class. */
    247257    ChoiceEditor(QWidget *pParent = 0);
     258
     259private slots:
     260
     261    /** Handles current index change. */
     262    void sltCurrentIndexChanged();
    248263
    249264private:
     
    261276    Q_OBJECT;
    262277    Q_PROPERTY(RangedIntegerData rangedInteger READ rangedInteger WRITE setRangedInteger USER true);
     278
     279signals:
     280
     281    /** Notifies listener about data should be committed. */
     282    void sigCommitData(QWidget *pThis);
    263283
    264284public:
     
    584604    : QComboBox(pParent)
    585605{
     606    connect(this, static_cast<void(ChoiceEditor::*)(int)>(&ChoiceEditor::currentIndexChanged),
     607            this, &ChoiceEditor::sltCurrentIndexChanged);
     608}
     609
     610void ChoiceEditor::sltCurrentIndexChanged()
     611{
     612    emit sigCommitData(this);
    586613}
    587614
    588615void ChoiceEditor::setChoice(const ChoiceData &choice)
    589616{
     617    clear();
    590618    addItems(choice.values().toList());
    591619    setCurrentIndex(choice.selectedIndex());
     
    14371465            {
    14381466                /* But is this also styled item delegate? */
    1439                 QStyledItemDelegate *pStyledItemDelegate = qobject_cast<QStyledItemDelegate*>(pAbstractItemDelegate);
     1467                QIStyledItemDelegate *pStyledItemDelegate = qobject_cast<QIStyledItemDelegate*>(pAbstractItemDelegate);
    14401468                if (pStyledItemDelegate)
    14411469                {
     1470                    /* Configure item delegate: */
     1471                    pStyledItemDelegate->setWatchForEditorDataCommits(true);
     1472
    14421473                    /* Create new item editor factory: */
    14431474                    QItemEditorFactory *pNewItemEditorFactory = new QItemEditorFactory;
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