Changeset 3802 in vbox for trunk/src/VBox/Frontends/VirtualBox/ui/VBoxSharedFoldersSettings.ui.h
- Timestamp:
- Jul 24, 2007 9:12:30 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/ui/VBoxSharedFoldersSettings.ui.h
r2981 r3802 154 154 public: 155 155 156 enum DialogType { AddDType, EditDType }; 157 158 VBoxAddSFDialog (QWidget *aParent, VBoxAddSFDialog::DialogType aType) : 156 enum DialogType { AddDialogType, EditDialogType }; 157 158 VBoxAddSFDialog (QWidget *aParent, VBoxAddSFDialog::DialogType aType, 159 bool aEnableSelector /* for "permanent" checkbox */) : 159 160 QDialog (aParent, "VBoxAddSFDialog", true /* modal */), 160 mLePath (0), mLeName (0) 161 mLePath (0), mLeName (0), mCbPermanent (0) 161 162 { 162 163 switch (aType) 163 164 { 164 case AddD Type:165 case AddDialogType: 165 166 setCaption (tr ("Add Share")); 166 167 break; 167 case EditD Type:168 case EditDialogType: 168 169 setCaption (tr ("Edit Share")); 169 170 break; … … 174 175 175 176 /* Setup Input layout */ 176 QGridLayout *inputLayout = new QGridLayout (mainLayout, 2, 3, 10, "inputLayout");177 QGridLayout *inputLayout = new QGridLayout (mainLayout, 3, 3, 10, "inputLayout"); 177 178 QLabel *lbPath = new QLabel (tr ("Folder Path"), this); 178 179 mLePath = new QLineEdit (this); … … 199 200 inputLayout->addMultiCellWidget (mLeName, 1, 1, 1, 2); 200 201 202 if (aEnableSelector) 203 { 204 mCbPermanent = new QCheckBox ("&Make Permanent", this); 205 mCbPermanent->setChecked (true); 206 inputLayout->addMultiCellWidget (mCbPermanent, 2, 2, 0, 2); 207 } 208 201 209 /* Setup Button layout */ 202 210 QHBoxLayout *buttonLayout = new QHBoxLayout (mainLayout, 10, "buttonLayout"); … … 219 227 QString getPath() { return mLePath->text(); } 220 228 QString getName() { return mLeName->text(); } 229 bool getPermanent() 230 { 231 return mCbPermanent ? mCbPermanent->isChecked() : true; 232 } 221 233 222 234 void setPath (const QString &aPath) { mLePath->setText (aPath); } 223 235 void setName (const QString &aName) { mLeName->setText (aName); } 236 void setPermanent (bool aPermanent) 237 { 238 if (mCbPermanent) 239 { 240 mCbPermanent->setChecked (aPermanent); 241 mCbPermanent->setEnabled (!aPermanent); 242 } 243 } 224 244 225 245 private slots: … … 272 292 QLineEdit *mLePath; 273 293 QLineEdit *mLeName; 294 QCheckBox *mCbPermanent; 274 295 }; 275 296 … … 301 322 } 302 323 303 void VBoxSharedFoldersSettings::setDialogType ( 304 VBoxSharedFoldersSettings::SFDialogType aType) 324 void VBoxSharedFoldersSettings::setDialogType (int aType) 305 325 { 306 326 mDialogType = aType; … … 456 476 457 477 /* This function is only available for MachineType dialog */ 458 Assert (mDialogType ==MachineType);478 Assert (mDialogType & MachineType); 459 479 /* Searching for MachineType item's root */ 460 480 QListViewItem *root = listView->findItem (QString::number (MachineType), 2); … … 470 490 471 491 /* This function is only available for ConsoleType dialog */ 472 Assert (mDialogType ==ConsoleType);492 Assert (mDialogType & ConsoleType); 473 493 /* Searching for ConsoleType item's root */ 474 494 QListViewItem *root = listView->findItem (QString::number (ConsoleType), 2); … … 507 527 508 528 529 QListViewItem* VBoxSharedFoldersSettings::searchRoot (bool aIsPermanent) 530 { 531 if (!aIsPermanent) 532 return listView->findItem (QString::number (ConsoleType), 2); 533 else if (mDialogType & MachineType) 534 return listView->findItem (QString::number (MachineType), 2); 535 else 536 return listView->findItem (QString::number (GlobalType), 2); 537 } 538 509 539 void VBoxSharedFoldersSettings::tbAddPressed() 510 540 { 511 541 /* Invoke Add-Box Dialog */ 512 VBoxAddSFDialog dlg (this, VBoxAddSFDialog::AddDType); 542 VBoxAddSFDialog dlg (this, VBoxAddSFDialog::AddDialogType, 543 mDialogType & ConsoleType); 513 544 if (dlg.exec() != QDialog::Accepted) 514 545 return; 515 546 QString name = dlg.getName(); 516 547 QString path = dlg.getPath(); 548 bool isPermanent = dlg.getPermanent(); 517 549 /* Shared folder's name & path could not be empty */ 518 550 Assert (!name.isEmpty() && !path.isEmpty()); 519 551 /* Searching root for the new listview item */ 520 QListViewItem *root = listView->findItem (QString::number (mDialogType), 2);552 QListViewItem *root = searchRoot (isPermanent); 521 553 Assert (root); 522 554 /* Appending a new listview item to the root */ 523 VBoxRichListItem *item = new VBoxRichListItem (VBoxRichListItem::EllipsisFile, 524 root, name, path); 555 VBoxRichListItem *item = new VBoxRichListItem ( 556 VBoxRichListItem::EllipsisFile, root, name, path); 557 /* Make the created item selected */ 525 558 listView->ensureItemVisible (item); 526 559 listView->setCurrentItem (item); 527 560 processCurrentChanged (item); 528 561 listView->setFocus(); 562 529 563 mIsListViewChanged = true; 530 564 } … … 534 568 /* Check selected item */ 535 569 QListViewItem *selectedItem = listView->selectedItem(); 536 VBoxRichListItem *item = 0;537 if (selectedItem->rtti() == VBoxRichListItem::QIRichListItemId)538 item = static_cast<VBoxRichListItem*> (selectedItem);570 VBoxRichListItem *item = 571 selectedItem->rtti() == VBoxRichListItem::QIRichListItemId ? 572 static_cast<VBoxRichListItem*> (selectedItem) : 0; 539 573 Assert (item); 540 /* Invoke Add-Box Dialog */ 541 VBoxAddSFDialog dlg (this, VBoxAddSFDialog::EditDType); 574 Assert (item->parent()); 575 /* Invoke Edit-Box Dialog */ 576 VBoxAddSFDialog dlg (this, VBoxAddSFDialog::EditDialogType, 577 mDialogType & ConsoleType); 542 578 dlg.setPath (item->getText (1)); 543 579 dlg.setName (item->getText (0)); 580 dlg.setPermanent ((SFDialogType)item->parent()->text (2).toInt() 581 != ConsoleType); 544 582 if (dlg.exec() != QDialog::Accepted) 545 583 return; 546 584 QString name = dlg.getName(); 547 585 QString path = dlg.getPath(); 586 bool isPermanent = dlg.getPermanent(); 548 587 /* Shared folder's name & path could not be empty */ 549 588 Assert (!name.isEmpty() && !path.isEmpty()); 589 /* Searching new root for the selected listview item */ 590 QListViewItem *root = searchRoot (isPermanent); 591 Assert (root); 550 592 /* Updating an edited listview item */ 551 593 item->updateText (1, path); 552 594 item->updateText (0, name); 595 if (item->parent() != root) 596 { 597 /* Move the selected item into new location */ 598 item->parent()->takeItem (item); 599 root->insertItem (item); 600 601 /* Make the created item selected */ 602 listView->ensureItemVisible (item); 603 listView->setCurrentItem (item); 604 processCurrentChanged (item); 605 listView->setFocus(); 606 } 607 553 608 mIsListViewChanged = true; 554 609 } … … 591 646 } 592 647 648 void VBoxSharedFoldersSettings::processDoubleClick (QListViewItem *aItem) 649 { 650 bool editEnabled = aItem && aItem->parent() && 651 isEditable (aItem->parent()->text (2)); 652 if (editEnabled) 653 tbEditPressed(); 654 } 655 593 656 bool VBoxSharedFoldersSettings::isEditable (const QString &aKey) 594 657 { … … 601 664 if (!type) 602 665 AssertMsgFailed (("Incorrect listview item key value\n")); 603 return type == mDialogType;666 return mDialogType & type; 604 667 } 605 668
Note:
See TracChangeset
for help on using the changeset viewer.