Changeset 18832 in vbox
- Timestamp:
- Apr 7, 2009 3:59:10 PM (16 years ago)
- svn:sync-xref-src-repo-rev:
- 45838
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/include/VBoxVMSettingsNetwork.h
r17901 r18832 81 81 VBoxVMSettingsNetworkPage(); 82 82 83 QStringList netList() const; 84 QStringList intList (KHostNetworkInterfaceType aType) const; 83 QStringList intList (bool aRefresh = false); 84 QStringList brgList (bool aRefresh = false); 85 QStringList hoiList (bool aRefresh = false); 85 86 86 87 protected: … … 98 99 QIWidgetValidator *mValidator; 99 100 QTabWidget *mTwAdapters; 101 102 QStringList mIntList; 103 QStringList mBrgList; 104 QStringList mHoiList; 100 105 }; 101 106 -
trunk/src/VBox/Frontends/VirtualBox/include/VBoxVMSettingsNetworkDetails.h
r18733 r18832 61 61 62 62 void populateComboboxes(); 63 void saveAlternative(); 63 64 QComboBox* comboBox() const; 64 65 -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxVMSettingsNetwork.cpp
r18591 r18832 177 177 void VBoxVMSettingsNetwork::updateAttachmentInfo() 178 178 { 179 KNetworkAttachmentType type = attachmentType(); 180 181 /* Reload alternate list */ 182 switch (type) 183 { 184 case KNetworkAttachmentType_Bridged: 185 mDetails->loadList (type, mParent->brgList()); 186 break; 187 case KNetworkAttachmentType_Internal: 188 mDetails->loadList (type, mParent->intList()); 189 break; 190 case KNetworkAttachmentType_HostOnly: 191 mDetails->loadList (type, mParent->hoiList()); 192 break; 193 default: 194 break; 195 } 196 197 /* Update information */ 179 198 QString line ("<tr><td><i><b><nobr><font color=grey>%1: </font></nobr></b></i></td>" 180 199 "<td><i><font color=grey>%2</font></i></td></tr>"); … … 182 201 183 202 /* Append alternative information */ 184 KNetworkAttachmentType type = attachmentType();185 203 switch (type) 186 204 { … … 234 252 /* Lock the button to avoid double-click bug */ 235 253 mTbDetails->setEnabled (false); 236 /* Reload alternate list */ 237 KNetworkAttachmentType type = attachmentType(); 238 QStringList list; 239 switch (type) 240 { 241 case KNetworkAttachmentType_Bridged: 242 list = mParent->intList (KHostNetworkInterfaceType_Bridged); 243 break; 244 case KNetworkAttachmentType_Internal: 245 list = mParent->netList(); 246 break; 247 case KNetworkAttachmentType_HostOnly: 248 list = mParent->intList (KHostNetworkInterfaceType_HostOnly); 249 break; 250 default: 251 break; 252 } 253 mDetails->loadList (type, list); 254 255 /* Show details sub-dialog */ 254 256 mDetails->activateWindow(); 255 257 mDetails->exec(); 256 258 updateAttachmentInfo(); 259 257 260 /* Unlock the previously locked button */ 258 261 mTbDetails->setEnabled (true); … … 367 370 } 368 371 369 QStringList VBoxVMSettingsNetworkPage::netList() const 370 { 371 QStringList list; 372 373 /* Load total network list of all VMs */ 374 CVirtualBox vbox = vboxGlobal().virtualBox(); 375 ulong count = qMin ((ULONG) 4, vbox.GetSystemProperties().GetNetworkAdapterCount()); 376 CMachineVector vec = vbox.GetMachines(); 377 for (CMachineVector::ConstIterator m = vec.begin(); m != vec.end(); ++ m) 378 { 379 if (m->GetAccessible()) 380 { 381 for (ulong slot = 0; slot < count; ++ slot) 372 QStringList VBoxVMSettingsNetworkPage::intList (bool aRefresh) 373 { 374 if (aRefresh) 375 { 376 /* Load total network list of all VMs */ 377 mIntList.clear(); 378 CVirtualBox vbox = vboxGlobal().virtualBox(); 379 ulong count = qMin ((ULONG) 4, vbox.GetSystemProperties().GetNetworkAdapterCount()); 380 CMachineVector vec = vbox.GetMachines(); 381 for (CMachineVector::ConstIterator m = vec.begin(); m != vec.end(); ++ m) 382 { 383 if (m->GetAccessible()) 382 384 { 383 QString name = m->GetNetworkAdapter (slot).GetInternalNetwork(); 384 if (!name.isEmpty() && !list.contains (name)) 385 list << name; 385 for (ulong slot = 0; slot < count; ++ slot) 386 { 387 QString name = m->GetNetworkAdapter (slot).GetInternalNetwork(); 388 if (!name.isEmpty() && !mIntList.contains (name)) 389 mIntList << name; 390 } 386 391 } 387 392 } … … 389 394 390 395 /* Append network list with names from all the pages */ 396 QStringList list (mIntList); 391 397 for (int index = 0; index < mTwAdapters->count(); ++ index) 392 398 { … … 404 410 } 405 411 406 QStringList VBoxVMSettingsNetworkPage::intList (KHostNetworkInterfaceType aType) const 407 { 408 QStringList list; 409 410 /* Load total interfaces list */ 411 CHostNetworkInterfaceVector interfaces = 412 vboxGlobal().virtualBox().GetHost().GetNetworkInterfaces(); 413 for (CHostNetworkInterfaceVector::ConstIterator it = interfaces.begin(); 414 it != interfaces.end(); ++ it) 415 { 416 if (it->GetInterfaceType() == aType) 417 list << it->GetName(); 418 } 419 420 return list; 412 QStringList VBoxVMSettingsNetworkPage::brgList (bool aRefresh) 413 { 414 if (aRefresh) 415 { 416 mBrgList.clear(); 417 CHostNetworkInterfaceVector interfaces = 418 vboxGlobal().virtualBox().GetHost().GetNetworkInterfaces(); 419 for (CHostNetworkInterfaceVector::ConstIterator it = interfaces.begin(); 420 it != interfaces.end(); ++ it) 421 { 422 if (it->GetInterfaceType() == KHostNetworkInterfaceType_Bridged) 423 mBrgList << it->GetName(); 424 } 425 } 426 427 return mBrgList; 428 } 429 430 QStringList VBoxVMSettingsNetworkPage::hoiList (bool aRefresh) 431 { 432 if (aRefresh) 433 { 434 mHoiList.clear(); 435 CHostNetworkInterfaceVector interfaces = 436 vboxGlobal().virtualBox().GetHost().GetNetworkInterfaces(); 437 for (CHostNetworkInterfaceVector::ConstIterator it = interfaces.begin(); 438 it != interfaces.end(); ++ it) 439 { 440 if (it->GetInterfaceType() == KHostNetworkInterfaceType_HostOnly) 441 mHoiList << it->GetName(); 442 } 443 } 444 445 return mHoiList; 421 446 } 422 447 … … 427 452 setTabOrder (mFirstWidget, mTwAdapters->focusProxy()); 428 453 QWidget *lastFocusWidget = mTwAdapters->focusProxy(); 454 455 /* Cache data */ 456 intList (true); 457 brgList (true); 458 hoiList (true); 429 459 430 460 /* Creating Tab Pages */ -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxVMSettingsNetworkDetails.cpp
r18829 r18832 133 133 { 134 134 comboBox()->clear(); 135 comboBox()->insertItems (comboBox()->count(), aList); 135 136 populateComboboxes(); 136 comboBox()->insertItems (comboBox()->count(), aList);137 137 int pos = comboBox()->findText (currentName()); 138 138 comboBox()->setCurrentIndex (pos == -1 ? 0 : pos); 139 saveAlternative(); 139 140 } 140 141 … … 253 254 { 254 255 /* Save temporary attributes as dynamic properties */ 255 switch (mType) 256 { 257 case KNetworkAttachmentType_Bridged: 258 setProperty ("BRG_Name", 259 QVariant (mCbBRG->itemData (mCbBRG->currentIndex()).toString() == QString (emptyItemCode) ? 260 QString::null : mCbBRG->currentText())); 261 break; 262 case KNetworkAttachmentType_Internal: 263 setProperty ("INT_Name", 264 QVariant (mCbINT->itemData (mCbINT->currentIndex()).toString() == QString (emptyItemCode) && 265 mCbINT->currentText() == mCbINT->itemText (mCbINT->currentIndex()) ? 266 QString::null : mCbINT->currentText())); 267 break; 268 case KNetworkAttachmentType_HostOnly: 269 setProperty ("HOI_Name", 270 QVariant (mCbHOI->itemData (mCbHOI->currentIndex()).toString() == QString (emptyItemCode) ? 271 QString::null : mCbHOI->currentText())); 272 break; 273 default: 274 break; 275 } 256 saveAlternative(); 276 257 setProperty ("MAC_Address", QVariant (mLeMAC->text())); 277 258 setProperty ("Cable_Connected", QVariant (mCbCable->isChecked())); … … 288 269 void VBoxVMSettingsNetworkDetails::populateComboboxes() 289 270 { 290 { /* Bridged adapters combo-box */ 271 if (mCbBRG->count() == 0) 272 { 273 /* Bridged adapters combo-box */ 291 274 int pos = mCbBRG->findData (emptyItemCode); 292 275 if (pos == -1) … … 297 280 mCbBRG->setItemText (pos, 298 281 VBoxVMSettingsNetwork::tr ("Not selected", "adapter")); 299 } /* Bridged adapters combo-box */ 300 301 { /* Internal networks combo-box */ 302 int pos = mCbINT->findData (emptyItemCode); 303 if (pos == -1) 304 mCbINT->insertItem (0, 305 VBoxVMSettingsNetwork::tr ("Not selected", "network"), 306 emptyItemCode); 307 else 308 mCbINT->setItemText (pos, 309 VBoxVMSettingsNetwork::tr ("Not selected", "network")); 310 } /* Internal networks combo-box */ 311 312 { /* Host-only adapters combo-box */ 282 } 283 284 if (mCbINT->count() == 0) 285 { 286 /* Internal networks combo-box default value */ 287 if (mCbINT->findText ("intnet") == -1) 288 mCbINT->insertItem (0, "intnet"); 289 } 290 291 if (mCbHOI->count() == 0) 292 { 293 /* Host-only adapters combo-box */ 313 294 int pos = mCbHOI->findData (emptyItemCode); 314 295 if (pos == -1) … … 319 300 mCbHOI->setItemText (pos, 320 301 VBoxVMSettingsNetwork::tr ("Not selected", "adapter")); 321 } /* Host-only adapters combo-box */ 302 } 303 } 304 305 void VBoxVMSettingsNetworkDetails::saveAlternative() 306 { 307 /* Save alternative attributes as temporary dynamic properties */ 308 switch (mType) 309 { 310 case KNetworkAttachmentType_Bridged: 311 setProperty ("BRG_Name", 312 QVariant (mCbBRG->itemData (mCbBRG->currentIndex()).toString() == QString (emptyItemCode) ? 313 QString::null : mCbBRG->currentText())); 314 break; 315 case KNetworkAttachmentType_Internal: 316 setProperty ("INT_Name", 317 QVariant (mCbINT->itemData (mCbINT->currentIndex()).toString() == QString (emptyItemCode) && 318 mCbINT->currentText() == mCbINT->itemText (mCbINT->currentIndex()) ? 319 QString::null : mCbINT->currentText())); 320 break; 321 case KNetworkAttachmentType_HostOnly: 322 setProperty ("HOI_Name", 323 QVariant (mCbHOI->itemData (mCbHOI->currentIndex()).toString() == QString (emptyItemCode) ? 324 QString::null : mCbHOI->currentText())); 325 break; 326 default: 327 break; 328 } 322 329 } 323 330
Note:
See TracChangeset
for help on using the changeset viewer.