Changeset 31535 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Aug 10, 2010 2:46:54 PM (14 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxProblemReporter.cpp
r31494 r31535 2347 2347 } 2348 2348 2349 void VBoxProblemReporter::warnAboutIncorrectPort(QWidget *pParent) const 2350 { 2351 message(pParent, Error, 2352 tr("The current port forwarding rules are not valid. " 2353 "None of the host or guest port values may be set to zero.")); 2354 } 2355 2349 2356 void VBoxProblemReporter::showRuntimeError (const CConsole &aConsole, bool fatal, 2350 2357 const QString &errorID, -
trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxProblemReporter.h
r31385 r31535 369 369 void cannotExportAppliance (const CProgress &aProgress, CAppliance *aAppliance, QWidget *aParent = NULL) const; 370 370 371 void warnAboutIncorrectPort(QWidget *pParent) const; 372 371 373 void showRuntimeError (const CConsole &console, bool fatal, 372 374 const QString &errorID, -
trunk/src/VBox/Frontends/VirtualBox/src/settings/vm/VBoxVMSettingsNetwork.cpp
r31533 r31535 189 189 UIPortForwardingData redirectData = mPortForwardingRules[i]; 190 190 mAdapter.GetNatDriver().AddRedirect(redirectData.name, redirectData.protocol, 191 redirectData.hostIp, redirectData.hostPort ,192 redirectData.guestIp, redirectData.guestPort );191 redirectData.hostIp, redirectData.hostPort.value(), 192 redirectData.guestIp, redirectData.guestPort.value()); 193 193 } 194 194 } -
trunk/src/VBox/Frontends/VirtualBox/src/settings/vm/VBoxVMSettingsPortForwardingDlg.cpp
r31533 r31535 26 26 #include <QComboBox> 27 27 #include <QLineEdit> 28 #include <QSpinBox> 28 29 #include <QTimer> 29 30 … … 31 32 #include "VBoxVMSettingsPortForwardingDlg.h" 32 33 #include "VBoxGlobal.h" 34 #include "VBoxProblemReporter.h" 33 35 #include "VBoxToolBar.h" 34 36 #include "QITableView.h" … … 36 38 #include "UIIconPool.h" 37 39 #include <iprt/cidr.h> 40 #include <math.h> 38 41 39 42 /* IP validator: */ … … 149 152 { 150 153 return text(); 154 } 155 }; 156 157 /* Port editor: */ 158 class PortEditor : public QSpinBox 159 { 160 Q_OBJECT; 161 Q_PROPERTY(PortData port READ port WRITE setPort USER true); 162 163 public: 164 165 PortEditor(QWidget *pParent = 0) : QSpinBox(pParent) 166 { 167 setFrame(false); 168 setRange(0, pow(2, 8 * sizeof(ushort)) - 1); 169 } 170 171 private: 172 173 void setPort(PortData port) 174 { 175 setValue(port.value()); 176 } 177 178 PortData port() const 179 { 180 return value(); 151 181 } 152 182 }; … … 247 277 case UIPortForwardingDataType_Protocol: return vboxGlobal().toString(m_dataList[index.row()].protocol); 248 278 case UIPortForwardingDataType_HostIp: return m_dataList[index.row()].hostIp; 249 case UIPortForwardingDataType_HostPort: return m_dataList[index.row()].hostPort ;279 case UIPortForwardingDataType_HostPort: return m_dataList[index.row()].hostPort.value(); 250 280 case UIPortForwardingDataType_GuestIp: return m_dataList[index.row()].guestIp; 251 case UIPortForwardingDataType_GuestPort: return m_dataList[index.row()].guestPort ;281 case UIPortForwardingDataType_GuestPort: return m_dataList[index.row()].guestPort.value(); 252 282 default: return QVariant(); 253 283 } … … 262 292 case UIPortForwardingDataType_Protocol: return QVariant::fromValue(m_dataList[index.row()].protocol); 263 293 case UIPortForwardingDataType_HostIp: return QVariant::fromValue(m_dataList[index.row()].hostIp); 264 case UIPortForwardingDataType_HostPort: return m_dataList[index.row()].hostPort;294 case UIPortForwardingDataType_HostPort: return QVariant::fromValue(m_dataList[index.row()].hostPort); 265 295 case UIPortForwardingDataType_GuestIp: return QVariant::fromValue(m_dataList[index.row()].guestIp); 266 case UIPortForwardingDataType_GuestPort: return m_dataList[index.row()].guestPort;296 case UIPortForwardingDataType_GuestPort: return QVariant::fromValue(m_dataList[index.row()].guestPort); 267 297 default: return QVariant(); 268 298 } … … 324 354 return true; 325 355 case UIPortForwardingDataType_HostPort: 326 m_dataList[index.row()].hostPort = value. toUInt();356 m_dataList[index.row()].hostPort = value.value<PortData>(); 327 357 emit dataChanged(index, index); 328 358 return true; … … 332 362 return true; 333 363 case UIPortForwardingDataType_GuestPort: 334 m_dataList[index.row()].guestPort = value. toUInt();364 m_dataList[index.row()].guestPort = value.value<PortData>(); 335 365 emit dataChanged(index, index); 336 366 return true; … … 476 506 pNewItemEditorFactory->registerEditor((QVariant::Type)iIpId, pIpEditorItemCreator); 477 507 508 /* Register port type: */ 509 int iPortId = qRegisterMetaType<PortData>(); 510 /* Register port editor: */ 511 QStandardItemEditorCreator<PortEditor> *pPortEditorItemCreator = new QStandardItemEditorCreator<PortEditor>(); 512 /* Link port type & editor: */ 513 pNewItemEditorFactory->registerEditor((QVariant::Type)iPortId, pPortEditorItemCreator); 514 478 515 /* Set newly created item editor factory for table delegate: */ 479 516 pStyledItemDelegate->setItemEditorFactory(pNewItemEditorFactory); … … 579 616 } 580 617 m_pTableView->horizontalHeader()->setStretchLastSection(true); 618 } 619 620 void VBoxVMSettingsPortForwardingDlg::accept() 621 { 622 /* Validate table: */ 623 for (int i = 0; i < m_pModel->rowCount(); ++i) 624 { 625 if (m_pModel->data(m_pModel->index(i, UIPortForwardingModel::UIPortForwardingDataType_HostPort), Qt::EditRole).value<PortData>().value() == 0 || 626 m_pModel->data(m_pModel->index(i, UIPortForwardingModel::UIPortForwardingDataType_GuestPort), Qt::EditRole).value<PortData>().value() == 0) 627 { 628 vboxProblem().warnAboutIncorrectPort(this); 629 return; 630 } 631 } 632 /* Base class accept() slot: */ 633 QIWithRetranslateUI<QIDialog>::accept(); 581 634 } 582 635 -
trunk/src/VBox/Frontends/VirtualBox/src/settings/vm/VBoxVMSettingsPortForwardingDlg.h
r31533 r31535 51 51 Q_DECLARE_METATYPE(IpData); 52 52 53 /* Port data: */ 54 class PortData 55 { 56 public: 57 58 PortData() : m_uValue(0) {} 59 PortData(ushort uValue) : m_uValue(uValue) {} 60 PortData(const PortData &other) : m_uValue(other.value()) {} 61 ushort value() const { return m_uValue; } 62 63 private: 64 65 ushort m_uValue; 66 }; 67 Q_DECLARE_METATYPE(PortData); 68 53 69 /* Port forwarding data: */ 54 70 struct UIPortForwardingData 55 71 { 56 72 UIPortForwardingData(const NameData &strName, KNATProtocol eProtocol, 57 const IpData &strHostIp, uintuHostPort,58 const IpData &strGuestIp, uintuGuestPort)73 const IpData &strHostIp, PortData uHostPort, 74 const IpData &strGuestIp, PortData uGuestPort) 59 75 : name(strName), protocol(eProtocol) 60 76 , hostIp(strHostIp), hostPort(uHostPort) … … 63 79 KNATProtocol protocol; 64 80 IpData hostIp; 65 uinthostPort;81 PortData hostPort; 66 82 IpData guestIp; 67 uintguestPort;83 PortData guestPort; 68 84 }; 69 85 … … 99 115 void sltAdjustTable(); 100 116 117 /* Dialog slots: */ 118 void accept(); 119 101 120 private: 102 121
Note:
See TracChangeset
for help on using the changeset viewer.