VirtualBox

Ignore:
Timestamp:
Apr 13, 2016 1:26:28 PM (9 years ago)
Author:
vboxsync
Message:

FE/Qt: ​bugref:7456: Port Forwarding UI: Partially reverting r96874 as it seems not needed anymore and causes regression (keyboard cursor moves to the end of embedded editors after each change).

File:
1 edited

Legend:

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

    r60362 r60470  
    3838# include "UIToolBar.h"
    3939# include "QITableView.h"
    40 # include "QIStyledItemDelegate.h"
    4140
    4241/* Other VBox includes: */
     
    109108    Q_PROPERTY(NameData name READ name WRITE setName USER true);
    110109
    111 signals:
    112 
    113     /** Notifies listener about data should be committed. */
    114     void sigCommitData(QWidget *pThis);
    115 
    116110public:
    117111
     
    122116        setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
    123117        setValidator(new QRegExpValidator(QRegExp("[^,:]*"), this));
    124         connect(this, SIGNAL(textEdited(const QString&)), this, SLOT(sltTextEdited(const QString&)));
    125     }
    126 
    127 private slots:
    128 
    129     /** Drops the changed data to listener. */
    130     void sltTextEdited(const QString&)
    131     {
    132         emit sigCommitData(this);
    133118    }
    134119
     
    154139    Q_PROPERTY(KNATProtocol protocol READ protocol WRITE setProtocol USER true);
    155140
    156 signals:
    157 
    158     /** Notifies listener about data should be committed. */
    159     void sigCommitData(QWidget *pThis);
    160 
    161141public:
    162142
     
    166146        addItem(gpConverter->toString(KNATProtocol_UDP), QVariant::fromValue(KNATProtocol_UDP));
    167147        addItem(gpConverter->toString(KNATProtocol_TCP), QVariant::fromValue(KNATProtocol_TCP));
    168         connect(this, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(sltTextEdited(const QString&)));
    169     }
    170 
    171 private slots:
    172 
    173     /** Drops the changed data to listener. */
    174     void sltTextEdited(const QString&)
    175     {
    176         emit sigCommitData(this);
    177148    }
    178149
     
    204175    Q_OBJECT;
    205176    Q_PROPERTY(IpData ip READ ip WRITE setIp USER true);
    206 
    207 signals:
    208 
    209     /** Notifies listener about data should be committed. */
    210     void sigCommitData(QWidget *pThis);
    211177
    212178public:
     
    218184        setAlignment(Qt::AlignCenter);
    219185        setValidator(new IPv4Validator(this));
    220         connect(this, SIGNAL(textEdited(const QString&)), this, SLOT(sltTextEdited(const QString&)));
    221     }
    222 
    223 private slots:
    224 
    225     /** Drops the changed data to listener. */
    226     void sltTextEdited(const QString&)
    227     {
    228         emit sigCommitData(this);
    229186    }
    230187
     
    249206    Q_OBJECT;
    250207    Q_PROPERTY(IpData ip READ ip WRITE setIp USER true);
    251 
    252 signals:
    253 
    254     /** Notifies listener about data should be committed. */
    255     void sigCommitData(QWidget *pThis);
    256208
    257209public:
     
    263215        setAlignment(Qt::AlignCenter);
    264216        setValidator(new IPv6Validator(this));
    265         connect(this, SIGNAL(textEdited(const QString&)), this, SLOT(sltTextEdited(const QString&)));
    266     }
    267 
    268 private slots:
    269 
    270     /** Drops the changed data to listener. */
    271     void sltTextEdited(const QString&)
    272     {
    273         emit sigCommitData(this);
    274217    }
    275218
     
    295238    Q_PROPERTY(PortData port READ port WRITE setPort USER true);
    296239
    297 signals:
    298 
    299     /** Notifies listener about data should be committed. */
    300     void sigCommitData(QWidget *pThis);
    301 
    302240public:
    303241
     
    307245        setFrame(false);
    308246        setRange(0, (1 << (8 * sizeof(ushort))) - 1);
    309         connect(this, SIGNAL(valueChanged(const QString&)), this, SLOT(sltTextEdited(const QString&)));
    310     }
    311 
    312 private slots:
    313 
    314     /** Drops the changed data to listener. */
    315     void sltTextEdited(const QString&)
    316     {
    317         emit sigCommitData(this);
    318247    }
    319248
     
    648577    }
    649578
    650     /* Reinstall delegate: */
    651     delete m_pTableView->itemDelegate();
    652     QIStyledItemDelegate *pStyledItemDelegate = new QIStyledItemDelegate(this);
    653     m_pTableView->setItemDelegate(pStyledItemDelegate);
    654 
    655     /* Create new item editor factory: */
    656     QItemEditorFactory *pNewItemEditorFactory = new QItemEditorFactory;
    657 
    658     /* Register name type: */
    659     int iNameId = qRegisterMetaType<NameData>();
    660     /* Register name editor: */
    661     QStandardItemEditorCreator<NameEditor> *pNameEditorItemCreator = new QStandardItemEditorCreator<NameEditor>();
    662     /* Link name type & editor: */
    663     pNewItemEditorFactory->registerEditor((QVariant::Type)iNameId, pNameEditorItemCreator);
    664 
    665     /* Register protocol type: */
    666     int iProtocolId = qRegisterMetaType<KNATProtocol>();
    667     /* Register protocol editor: */
    668     QStandardItemEditorCreator<ProtocolEditor> *pProtocolEditorItemCreator = new QStandardItemEditorCreator<ProtocolEditor>();
    669     /* Link protocol type & editor: */
    670     pNewItemEditorFactory->registerEditor((QVariant::Type)iProtocolId, pProtocolEditorItemCreator);
    671 
    672     /* Register ip type: */
    673     int iIpId = qRegisterMetaType<IpData>();
    674     /* Register ip editor: */
    675     if (!fIPv6)
    676     {
    677         QStandardItemEditorCreator<IPv4Editor> *pIPv4EditorItemCreator = new QStandardItemEditorCreator<IPv4Editor>();
    678         /* Link ip type & editor: */
    679         pNewItemEditorFactory->registerEditor((QVariant::Type)iIpId, pIPv4EditorItemCreator);
    680     }
    681     else
    682     {
    683         QStandardItemEditorCreator<IPv6Editor> *pIPv6EditorItemCreator = new QStandardItemEditorCreator<IPv6Editor>();
    684         /* Link ip type & editor: */
    685         pNewItemEditorFactory->registerEditor((QVariant::Type)iIpId, pIPv6EditorItemCreator);
    686     }
    687 
    688     /* Register port type: */
    689     int iPortId = qRegisterMetaType<PortData>();
    690     /* Register port editor: */
    691     QStandardItemEditorCreator<PortEditor> *pPortEditorItemCreator = new QStandardItemEditorCreator<PortEditor>();
    692     /* Link port type & editor: */
    693     pNewItemEditorFactory->registerEditor((QVariant::Type)iPortId, pPortEditorItemCreator);
    694 
    695     /* Set newly created item editor factory for table delegate: */
    696     pStyledItemDelegate->setItemEditorFactory(pNewItemEditorFactory);
     579    /* We do have abstract item delegate: */
     580    QAbstractItemDelegate *pAbstractItemDelegate = m_pTableView->itemDelegate();
     581    if (pAbstractItemDelegate)
     582    {
     583        /* But do we have styled item delegate? */
     584        QStyledItemDelegate *pStyledItemDelegate = qobject_cast<QStyledItemDelegate*>(pAbstractItemDelegate);
     585        if (pStyledItemDelegate)
     586        {
     587            /* Create new item editor factory: */
     588            QItemEditorFactory *pNewItemEditorFactory = new QItemEditorFactory;
     589            {
     590                /* Register NameEditor as the NameData editor: */
     591                int iNameId = qRegisterMetaType<NameData>();
     592                QStandardItemEditorCreator<NameEditor> *pNameEditorItemCreator = new QStandardItemEditorCreator<NameEditor>();
     593                pNewItemEditorFactory->registerEditor((QVariant::Type)iNameId, pNameEditorItemCreator);
     594
     595                /* Register ProtocolEditor as the KNATProtocol editor: */
     596                int iProtocolId = qRegisterMetaType<KNATProtocol>();
     597                QStandardItemEditorCreator<ProtocolEditor> *pProtocolEditorItemCreator = new QStandardItemEditorCreator<ProtocolEditor>();
     598                pNewItemEditorFactory->registerEditor((QVariant::Type)iProtocolId, pProtocolEditorItemCreator);
     599
     600                /* Register IPv4Editor/IPv6Editor as the IpData editor: */
     601                int iIpId = qRegisterMetaType<IpData>();
     602                if (!fIPv6)
     603                {
     604                    QStandardItemEditorCreator<IPv4Editor> *pIPv4EditorItemCreator = new QStandardItemEditorCreator<IPv4Editor>();
     605                    pNewItemEditorFactory->registerEditor((QVariant::Type)iIpId, pIPv4EditorItemCreator);
     606                }
     607                else
     608                {
     609                    QStandardItemEditorCreator<IPv6Editor> *pIPv6EditorItemCreator = new QStandardItemEditorCreator<IPv6Editor>();
     610                    pNewItemEditorFactory->registerEditor((QVariant::Type)iIpId, pIPv6EditorItemCreator);
     611                }
     612
     613                /* Register PortEditor as the PortData editor: */
     614                int iPortId = qRegisterMetaType<PortData>();
     615                QStandardItemEditorCreator<PortEditor> *pPortEditorItemCreator = new QStandardItemEditorCreator<PortEditor>();
     616                pNewItemEditorFactory->registerEditor((QVariant::Type)iPortId, pPortEditorItemCreator);
     617
     618                /* Set newly created item editor factory for table delegate: */
     619                pStyledItemDelegate->setItemEditorFactory(pNewItemEditorFactory);
     620            }
     621        }
     622    }
    697623
    698624    /* Retranslate dialog: */
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