Changeset 60470 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Apr 13, 2016 1:26:28 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPortForwardingTable.cpp
r60362 r60470 38 38 # include "UIToolBar.h" 39 39 # include "QITableView.h" 40 # include "QIStyledItemDelegate.h"41 40 42 41 /* Other VBox includes: */ … … 109 108 Q_PROPERTY(NameData name READ name WRITE setName USER true); 110 109 111 signals:112 113 /** Notifies listener about data should be committed. */114 void sigCommitData(QWidget *pThis);115 116 110 public: 117 111 … … 122 116 setAlignment(Qt::AlignLeft | Qt::AlignVCenter); 123 117 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);133 118 } 134 119 … … 154 139 Q_PROPERTY(KNATProtocol protocol READ protocol WRITE setProtocol USER true); 155 140 156 signals:157 158 /** Notifies listener about data should be committed. */159 void sigCommitData(QWidget *pThis);160 161 141 public: 162 142 … … 166 146 addItem(gpConverter->toString(KNATProtocol_UDP), QVariant::fromValue(KNATProtocol_UDP)); 167 147 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);177 148 } 178 149 … … 204 175 Q_OBJECT; 205 176 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);211 177 212 178 public: … … 218 184 setAlignment(Qt::AlignCenter); 219 185 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);229 186 } 230 187 … … 249 206 Q_OBJECT; 250 207 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);256 208 257 209 public: … … 263 215 setAlignment(Qt::AlignCenter); 264 216 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);274 217 } 275 218 … … 295 238 Q_PROPERTY(PortData port READ port WRITE setPort USER true); 296 239 297 signals:298 299 /** Notifies listener about data should be committed. */300 void sigCommitData(QWidget *pThis);301 302 240 public: 303 241 … … 307 245 setFrame(false); 308 246 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);318 247 } 319 248 … … 648 577 } 649 578 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 } 697 623 698 624 /* Retranslate dialog: */
Note:
See TracChangeset
for help on using the changeset viewer.