Changeset 6724 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Feb 1, 2008 4:58:20 PM (17 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/ui
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/ui/VBoxSharedFoldersSettings.ui
r6384 r6724 75 75 <property name="text"> 76 76 <string>Path</string> 77 </property> 78 <property name="clickable"> 79 <bool>true</bool> 80 </property> 81 <property name="resizable"> 82 <bool>true</bool> 83 </property> 84 </column> 85 <column> 86 <property name="text"> 87 <string>Access</string> 77 88 </property> 78 89 <property name="clickable"> … … 227 238 <variable access="private">CMachine mMachine;</variable> 228 239 <variable access="private">CConsole mConsole;</variable> 240 <variable access="private">QString mTrFull;</variable> 241 <variable access="private">QString mTrReadOnly;</variable> 229 242 </variables> 230 243 <slots> … … 232 245 <slot>tbEditPressed()</slot> 233 246 <slot>tbRemovePressed()</slot> 234 <slot>processOnItem( QListViewItem* )</slot>235 247 <slot>processCurrentChanged( QListViewItem* )</slot> 236 248 <slot>processDoubleClick( QListViewItem* )</slot> … … 238 250 <functions> 239 251 <function access="private">init()</function> 252 <function returnType="bool" access="private">eventFilter( QObject*, QEvent* )</function> 240 253 <function>setDialogType( int )</function> 241 254 <function returnType="int">dialogType() {return mDialogType;}</function> -
trunk/src/VBox/Frontends/VirtualBox/ui/VBoxSharedFoldersSettings.ui.h
r6656 r6724 50 50 51 51 VBoxRichListItem (FormatType aFormat, QListView *aParent, 52 const QString& aName, const QString& aNull ,53 const QString& a Key) :54 QListViewItem (aParent, aName, aNull , aKey), mFormat (aFormat)52 const QString& aName, const QString& aNull1, 53 const QString& aNull2, const QString& aKey) : 54 QListViewItem (aParent, aName, aNull1, aNull2, aKey), mFormat (aFormat) 55 55 { 56 56 } … … 58 58 VBoxRichListItem (FormatType aFormat, QListViewItem *aParent, 59 59 const QString& aName, const QString& aPath, 60 const QString& a Edited, const QString& aWritable) :61 QListViewItem (aParent, aName, aPath, a Edited, aWritable), mFormat (aFormat)62 { 63 mTextList << aName << aPath << a Edited << aWritable;60 const QString& aAccess, const QString& aEdited) : 61 QListViewItem (aParent, aName, aPath, aAccess, aEdited), mFormat (aFormat) 62 { 63 mTextList << aName << aPath << aAccess << aEdited; 64 64 } 65 65 … … 73 73 /* Sorting the root items always by key: */ 74 74 else if (!parent() && !aItem->parent()) 75 return QListViewItem::compare (aItem, 2, aAscending);75 return QListViewItem::compare (aItem, 3, aAscending); 76 76 else 77 77 return QListViewItem::compare (aItem, aColumn, aAscending); … … 223 223 inputLayout->addMultiCellWidget (mLeName, 1, 1, 1, 2); 224 224 225 225 QHBoxLayout *cbLayout = new QHBoxLayout (0, "cbLayout"); 226 226 inputLayout->addMultiCellLayout (cbLayout, 2, 2, 0, 2); 227 227 mCbReadonly = new QCheckBox (tr ("&Read-only"), this); 228 228 QWhatsThis::add (mCbReadonly, 229 229 tr ("When checked, the guest OS will not be able to write to the " … … 244 244 QHBoxLayout *buttonLayout = new QHBoxLayout (mainLayout, 10, "buttonLayout"); 245 245 mBtOk = new QPushButton (tr ("&OK"), this, "btOk"); 246 QSpacerItem *spacer = new QSpacerItem (0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum);246 QSpacerItem *spacer = new QSpacerItem (0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum); 247 247 QPushButton *btCancel = new QPushButton (tr ("Cancel"), this, "btCancel"); 248 248 connect (mBtOk, SIGNAL (clicked()), this, SLOT (accept())); … … 265 265 return mCbPermanent ? mCbPermanent->isChecked() : true; 266 266 } 267 267 bool getWritable() { return !mCbReadonly->isChecked(); } 268 268 269 269 void setPath (const QString &aPath) { mLePath->setText (aPath); } … … 277 277 } 278 278 } 279 279 void setWritable (bool aWritable) { mCbReadonly->setChecked (!aWritable); } 280 280 281 281 private slots: … … 365 365 connect (listView, SIGNAL (currentChanged (QListViewItem *)), 366 366 this, SLOT (processCurrentChanged (QListViewItem *))); 367 connect (listView, SIGNAL (onItem (QListViewItem *)),368 this, SLOT (processOnItem (QListViewItem *)));369 367 370 368 mIsListViewChanged = false; 369 370 listView->viewport()->installEventFilter (this); 371 372 mTrFull = tr ("Full"); 373 mTrReadOnly = tr ("Read-only"); 374 } 375 376 bool VBoxSharedFoldersSettings::eventFilter (QObject *aObject, QEvent *aEvent) 377 { 378 /* Process & show auto Tool-Tip for partially hidden listview items. */ 379 if (aObject == listView->viewport() && aEvent->type() == QEvent::MouseMove) 380 { 381 QMouseEvent *e = static_cast<QMouseEvent*> (aEvent); 382 QListViewItem *i = listView->itemAt (e->pos()); 383 VBoxRichListItem *item = i && i->rtti() == VBoxRichListItem::QIRichListItemId ? 384 static_cast<VBoxRichListItem*> (i) : 0; 385 if (item) 386 { 387 int delta = e->pos().x(); 388 int id = 0; 389 for (; id < listView->columns(); ++ id) 390 { 391 if (delta < listView->columnWidth (id)) 392 break; 393 delta -= listView->columnWidth (id); 394 } 395 396 QString curText = QToolTip::textFor (listView->viewport()); 397 QString newText = item->text (id) != item->getText (id) ? 398 item->getText (id) : QString::null; 399 400 if (newText != curText) 401 { 402 QToolTip::remove (listView->viewport()); 403 QToolTip::add (listView->viewport(), newText); 404 } 405 } 406 else 407 QToolTip::remove (listView->viewport()); 408 } 409 410 return QWidget::eventFilter (aObject, aEvent); 371 411 } 372 412 … … 462 502 QString key (QString::number (GlobalType)); 463 503 VBoxRichListItem *root = new VBoxRichListItem (VBoxRichListItem::EllipsisEnd, 464 listView, name, QString::null, key);504 listView, name, QString::null, QString::null, key); 465 505 getFrom (vboxGlobal().virtualBox().GetSharedFolders().Enumerate(), root); 466 506 */ … … 473 513 QString key (QString::number (MachineType)); 474 514 VBoxRichListItem *root = new VBoxRichListItem (VBoxRichListItem::EllipsisEnd, 475 listView, name, QString::null, key);515 listView, name, QString::null, QString::null, key); 476 516 getFrom (mMachine.GetSharedFolders().Enumerate(), root); 477 517 } … … 483 523 QString key (QString::number (ConsoleType)); 484 524 VBoxRichListItem *root = new VBoxRichListItem (VBoxRichListItem::EllipsisEnd, 485 listView, name, QString::null, key);525 listView, name, QString::null, QString::null, key); 486 526 getFrom (mConsole.GetSharedFolders().Enumerate(), root); 487 527 } … … 495 535 CSharedFolder sf = aEn.GetNext(); 496 536 new VBoxRichListItem (VBoxRichListItem::EllipsisFile, aRoot, 497 sf.GetName(), sf.GetHostPath(), "not edited", 498 sf.GetWritable() ? "writable" : "readonly"); 537 sf.GetName(), sf.GetHostPath(), 538 sf.GetWritable() ? mTrFull : mTrReadOnly, 539 "not edited"); 499 540 } 500 541 listView->setOpen (aRoot, true); … … 514 555 Assert (mDialogType == GlobalType); 515 556 // Searching for GlobalType item's root 516 QListViewItem *root = listView->findItem (QString::number (GlobalType), 2);557 QListViewItem *root = listView->findItem (QString::number (GlobalType), 3); 517 558 Assert (root); 518 559 CSharedFolderEnumerator en = vboxGlobal().virtualBox().GetSharedFolders().Enumerate(); … … 529 570 Assert (mDialogType & MachineType); 530 571 /* Searching for MachineType item's root */ 531 QListViewItem *root = listView->findItem (QString::number (MachineType), 2);572 QListViewItem *root = listView->findItem (QString::number (MachineType), 3); 532 573 Assert (root); 533 574 CSharedFolderEnumerator en = mMachine.GetSharedFolders().Enumerate(); … … 543 584 Assert (mDialogType & ConsoleType); 544 585 /* Searching for ConsoleType item's root */ 545 QListViewItem *root = listView->findItem (QString::number (ConsoleType), 2);586 QListViewItem *root = listView->findItem (QString::number (ConsoleType), 3); 546 587 Assert (root); 547 588 CSharedFolderEnumerator en = mConsole.GetSharedFolders().Enumerate(); … … 552 593 QListViewItem *aRoot) 553 594 { 554 Assert (!aRoot->text ( 2).isNull());555 SFDialogType type = (SFDialogType)aRoot->text ( 2).toInt();595 Assert (!aRoot->text (3).isNull()); 596 SFDialogType type = (SFDialogType)aRoot->text (3).toInt(); 556 597 557 598 /* deleting all changed folders of the list */ … … 569 610 if (item->getText (0) == sf.GetName() && 570 611 item->getText (1) == sf.GetHostPath() && 571 item->getText ( 2) == "not edited")612 item->getText (3) == "not edited") 572 613 break; 573 614 item = item->nextSibling(); … … 586 627 item = static_cast<VBoxRichListItem*> (iterator); 587 628 if (item && !item->getText (0).isNull() && !item->getText (1).isNull() 588 && item->getText ( 2) == "edited")629 && item->getText (3) == "edited") 589 630 createSharedFolder (item->getText (0), item->getText (1), 590 item->getText (3) == "writable"? true : false, type);631 item->getText (2) == mTrFull ? true : false, type); 591 632 iterator = iterator->nextSibling(); 592 633 } … … 597 638 { 598 639 if (!aIsPermanent) 599 return listView->findItem (QString::number (ConsoleType), 2);640 return listView->findItem (QString::number (ConsoleType), 3); 600 641 else if (mDialogType & MachineType) 601 return listView->findItem (QString::number (MachineType), 2);642 return listView->findItem (QString::number (MachineType), 3); 602 643 else 603 return listView->findItem (QString::number (GlobalType), 2);644 return listView->findItem (QString::number (GlobalType), 3); 604 645 } 605 646 … … 614 655 { 615 656 VBoxRichListItem *item = static_cast<VBoxRichListItem*> (*it); 616 SFDialogType type = (SFDialogType)item->parent()->text ( 2).toInt();657 SFDialogType type = (SFDialogType)item->parent()->text (3).toInt(); 617 658 usedList << qMakePair (item->getText (0), type); 618 659 } … … 635 676 /* Appending a new listview item to the root */ 636 677 VBoxRichListItem *item = new VBoxRichListItem ( 637 VBoxRichListItem::EllipsisFile, root, name, path, "edited",638 dlg.getWritable() ? "writable" : "readonly");678 VBoxRichListItem::EllipsisFile, root, name, path, 679 dlg.getWritable() ? mTrFull : mTrReadOnly, "edited"); 639 680 /* Make the created item selected */ 640 681 listView->ensureItemVisible (item); … … 657 698 { 658 699 VBoxRichListItem *item = static_cast<VBoxRichListItem*> (*it); 659 SFDialogType type = (SFDialogType)item->parent()->text ( 2).toInt();700 SFDialogType type = (SFDialogType)item->parent()->text (3).toInt(); 660 701 usedList << qMakePair (item->getText (0), type); 661 702 } … … 675 716 dlg.setPath (item->getText (1)); 676 717 dlg.setName (item->getText (0)); 677 dlg.setPermanent ((SFDialogType)item->parent()->text ( 2).toInt()718 dlg.setPermanent ((SFDialogType)item->parent()->text (3).toInt() 678 719 != ConsoleType); 679 dlg.setWritable (item->getText ( 3) == "writable");720 dlg.setWritable (item->getText (2) == mTrFull); 680 721 if (dlg.exec() != QDialog::Accepted) 681 722 return; … … 689 730 Assert (root); 690 731 /* Updating an edited listview item */ 691 item->updateText (3, dlg.getWritable() ? "writable" : "readonly");692 item->updateText (2, "edited");732 item->updateText (3, "edited"); 733 item->updateText (2, dlg.getWritable() ? mTrFull : mTrReadOnly); 693 734 item->updateText (1, path); 694 735 item->updateText (0, name); … … 705 746 listView->setFocus(); 706 747 } 748 item->repaint(); 707 749 708 750 mIsListViewChanged = true; … … 717 759 718 760 719 void VBoxSharedFoldersSettings::processOnItem (QListViewItem *aItem)720 {721 VBoxRichListItem *item = 0;722 if (aItem->rtti() == VBoxRichListItem::QIRichListItemId)723 item = static_cast<VBoxRichListItem*> (aItem);724 Assert (item);725 QString tip = tr ("<nobr>Name: %1</nobr><br>"726 "<nobr>Path: %2</nobr><br>"727 "<nobr>Access: %3</nobr>")728 .arg (item->getText (0)).arg (item->getText (1)).arg (item->getText (3));729 if (!item->getText (0).isNull() && !item->getText (1).isNull())730 QToolTip::add (listView->viewport(), listView->itemRect (aItem), tip);731 else732 QToolTip::remove (listView->viewport());733 }734 735 761 void VBoxSharedFoldersSettings::processCurrentChanged (QListViewItem *aItem) 736 762 { … … 738 764 listView->setSelected (aItem, true); 739 765 bool addEnabled = aItem && 740 (isEditable (aItem->text ( 2)) ||741 (aItem->parent() && isEditable (aItem->parent()->text ( 2))));766 (isEditable (aItem->text (3)) || 767 (aItem->parent() && isEditable (aItem->parent()->text (3)))); 742 768 bool removeEnabled = aItem && aItem->parent() && 743 isEditable (aItem->parent()->text ( 2));769 isEditable (aItem->parent()->text (3)); 744 770 tbAdd->setEnabled (addEnabled); 745 771 tbEdit->setEnabled (removeEnabled); … … 750 776 { 751 777 bool editEnabled = aItem && aItem->parent() && 752 isEditable (aItem->parent()->text ( 2));778 isEditable (aItem->parent()->text (3)); 753 779 if (editEnabled) 754 780 tbEditPressed();
Note:
See TracChangeset
for help on using the changeset viewer.