Changeset 67147 in vbox for trunk/src/VBox
- Timestamp:
- May 30, 2017 3:54:09 PM (8 years ago)
- svn:sync-xref-src-repo-rev:
- 115823
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/VBoxSnapshotDetailsDlg.cpp
r67146 r67147 266 266 } 267 267 268 void VBoxSnapshotDetailsDlg::setData(const CSnapshot &comSnapshot) 269 { 268 void VBoxSnapshotDetailsDlg::setData(const UIDataSnapshot &data, const CSnapshot &comSnapshot) 269 { 270 /* Cache old/new data: */ 271 m_oldData = data; 272 m_newData = m_oldData; 273 270 274 /* Cache snapshot: */ 271 275 m_comSnapshot = comSnapshot; 272 276 277 /* Load general snapshot properties: */ 278 mLeName->setText(m_newData.m_strName); 279 mTeDescription->setText(m_newData.m_strDescription); 280 273 281 /* If there is really a snapshot: */ 274 282 if (m_comSnapshot.isNotNull()) 275 283 { 276 /* Read general snapshot properties: */277 mLeName->setText(m_comSnapshot.GetName());278 mTeDescription->setText(m_comSnapshot.GetDescription());279 280 284 /* Calculate snapshot timestamp info: */ 281 285 QDateTime timestamp; … … 364 368 365 369 /* Save snapshot name: */ 366 m_comSnapshot.SetName(m LeName->text());370 m_comSnapshot.SetName(m_newData.m_strName); 367 371 /* Save snapshot description: */ 368 m_comSnapshot.SetDescription(m TeDescription->toPlainText());372 m_comSnapshot.SetDescription(m_newData.m_strDescription); 369 373 370 374 /* Close the session again. */ … … 451 455 void VBoxSnapshotDetailsDlg::sltHandleNameChange(const QString &strName) 452 456 { 457 /* Recache snapshot name: */ 458 m_newData.m_strName = strName; 453 459 /* Perform snapshot name sanity check: */ 454 460 mButtonBox->button(QDialogButtonBox::Ok)->setEnabled(!strName.trimmed().isEmpty()); 461 } 462 463 void VBoxSnapshotDetailsDlg::sltHandleDescriptionChange() 464 { 465 /* Recache snapshot description: */ 466 m_newData.m_strDescription = mTeDescription->toPlainText(); 455 467 } 456 468 … … 470 482 } 471 483 484 /* Description editor created in the .ui file: */ 485 AssertPtrReturnVoid(mTeDescription); 486 { 487 /* Configure editor: */ 488 connect(mTeDescription, &QTextEdit::textChanged, 489 this, &VBoxSnapshotDetailsDlg::sltHandleDescriptionChange); 490 } 491 472 492 /* Thumbnail label created in the .ui file: */ 473 493 AssertPtrReturnVoid(mLbThumbnail); -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxSnapshotDetailsDlg.h
r67146 r67147 27 27 28 28 29 /** Snapshot pane: Snapshot data structure. */ 30 struct UIDataSnapshot 31 { 32 /** Constructs data. */ 33 UIDataSnapshot() 34 : m_strName(QString()) 35 , m_strDescription(QString()) 36 {} 37 38 /** Returns whether the @a other passed data is equal to this one. */ 39 bool equal(const UIDataSnapshot &other) const 40 { 41 return true 42 && (m_strName == other.m_strName) 43 && (m_strDescription == other.m_strDescription) 44 ; 45 } 46 47 /** Returns whether the @a other passed data is equal to this one. */ 48 bool operator==(const UIDataSnapshot &other) const { return equal(other); } 49 /** Returns whether the @a other passed data is different from this one. */ 50 bool operator!=(const UIDataSnapshot &other) const { return !equal(other); } 51 52 /** Holds the snapshot name. */ 53 QString m_strName; 54 /** Holds the snapshot description. */ 55 QString m_strDescription; 56 }; 57 58 29 59 /** QDialog extension providing GUI with snapshot details dialog. */ 30 60 class VBoxSnapshotDetailsDlg : public QIWithRetranslateUI<QDialog>, public Ui::VBoxSnapshotDetailsDlg … … 38 68 39 69 /** Defines the snapshot @a data. */ 40 void setData(const CSnapshot &comSnapshot);70 void setData(const UIDataSnapshot &data, const CSnapshot &comSnapshot); 41 71 /** Saves the snapshot data. */ 42 72 void saveData(); … … 59 89 /** Handles snapshot @a strName change. */ 60 90 void sltHandleNameChange(const QString &strName); 91 /** Handles snapshot description change. */ 92 void sltHandleDescriptionChange(); 61 93 62 94 private: … … 71 103 CSnapshot m_comSnapshot; 72 104 105 /** Holds the old data copy. */ 106 UIDataSnapshot m_oldData; 107 /** Holds the new data copy. */ 108 UIDataSnapshot m_newData; 109 73 110 /** Holds the cached thumbnail. */ 74 111 QPixmap m_pixmapThumbnail; -
trunk/src/VBox/Frontends/VirtualBox/src/selector/UISnapshotPane.cpp
r67146 r67147 59 59 60 60 /** QITreeWidgetItem subclass for snapshots items. */ 61 class UISnapshotItem : public QITreeWidgetItem 61 class UISnapshotItem : public QITreeWidgetItem, public UIDataSnapshot 62 62 { 63 63 Q_OBJECT; … … 147 147 bool m_fOnline; 148 148 149 /** Holds the item description. */150 QString m_strDesc;151 149 /** Holds the item timestamp. */ 152 150 QDateTime m_timestamp; … … 330 328 AssertReturnVoid(!m_comMachine.isNull()); 331 329 m_fCurrentStateModified = m_comMachine.GetCurrentStateModified(); 332 setText(0, m_fCurrentStateModified ? 333 UISnapshotPane::tr("Current State (changed)", "Current State (Modified)") : 334 UISnapshotPane::tr("Current State", "Current State (Unmodified)")); 335 m_strDesc = m_fCurrentStateModified ? 336 UISnapshotPane::tr("The current state differs from the state stored in the current snapshot") : 337 QTreeWidgetItem::parent() != 0 ? 338 UISnapshotPane::tr("The current state is identical to the state stored in the current snapshot") : 339 QString(); 330 m_strName = m_fCurrentStateModified ? 331 UISnapshotPane::tr("Current State (changed)", "Current State (Modified)") : 332 UISnapshotPane::tr("Current State", "Current State (Unmodified)"); 333 setText(0, m_strName); 334 m_strDescription = m_fCurrentStateModified ? 335 UISnapshotPane::tr("The current state differs from the state stored in the current snapshot") : 336 QTreeWidgetItem::parent() != 0 ? 337 UISnapshotPane::tr("The current state is identical to the state stored in the current snapshot") : 338 QString(); 340 339 } 341 340 /* For others: */ … … 345 344 AssertReturnVoid(!m_comSnapshot.isNull()); 346 345 m_strSnapshotID = m_comSnapshot.GetId(); 347 setText(0, m_comSnapshot.GetName()); 346 m_strName = m_comSnapshot.GetName(); 347 setText(0, m_strName); 348 348 m_fOnline = m_comSnapshot.GetOnline(); 349 349 setIcon(0, *m_pSnapshotWidget->snapshotItemIcon(m_fOnline)); 350 m_strDesc = m_comSnapshot.GetDescription();350 m_strDescription = m_comSnapshot.GetDescription(); 351 351 m_timestamp.setTime_t(m_comSnapshot.GetTimeStamp() / 1000); 352 352 m_fCurrentStateModified = false; … … 490 490 491 491 /* Append description if any: */ 492 if (!m_strDesc .isEmpty())493 strToolTip += "<hr>" + m_strDesc ;492 if (!m_strDescription.isEmpty()) 493 strToolTip += "<hr>" + m_strDescription; 494 494 495 495 /* Assign tool-tip finally: */ … … 585 585 m_pActionCloneSnapshot->setText(tr("&Clone...")); 586 586 /* Translate actions tool-tips: */ 587 m_pActionTakeSnapshot->setToolTip(tr("Take Snapshot (%1)").arg(m_pActionTakeSnapshot->shortcut().toString())); 588 m_pActionDeleteSnapshot->setToolTip(tr("Delete Snapshot (%1)").arg(m_pActionDeleteSnapshot->shortcut().toString())); 589 m_pActionRestoreSnapshot->setToolTip(tr("Restore Snapshot (%1)").arg(m_pActionRestoreSnapshot->shortcut().toString())); 590 m_pActionShowSnapshotDetails->setToolTip(tr("Show Snapshot Details (%1)").arg(m_pActionShowSnapshotDetails->shortcut().toString())); 591 m_pActionCloneSnapshot->setToolTip(tr("Clone Virtual Machine (%1)").arg(m_pActionCloneSnapshot->shortcut().toString())); 587 m_pActionTakeSnapshot->setToolTip(tr("Take Snapshot (%1)") 588 .arg(m_pActionTakeSnapshot->shortcut().toString())); 589 m_pActionDeleteSnapshot->setToolTip(tr("Delete Snapshot (%1)") 590 .arg(m_pActionDeleteSnapshot->shortcut().toString())); 591 m_pActionRestoreSnapshot->setToolTip(tr("Restore Snapshot (%1)") 592 .arg(m_pActionRestoreSnapshot->shortcut().toString())); 593 m_pActionShowSnapshotDetails->setToolTip(tr("Show Snapshot Details (%1)") 594 .arg(m_pActionShowSnapshotDetails->shortcut().toString())); 595 m_pActionCloneSnapshot->setToolTip(tr("Clone Virtual Machine (%1)") 596 .arg(m_pActionCloneSnapshot->shortcut().toString())); 592 597 /* Translate actions status-tips: */ 593 598 m_pActionTakeSnapshot->setStatusTip(tr("Take a snapshot of the current virtual machine state")); … … 618 623 QWriteLocker locker(m_pLockReadWrite); 619 624 620 /* Recache state current item: */625 /* Recache current item data: */ 621 626 currentStateItem()->recache(); 622 627 } … … 631 636 QWriteLocker locker(m_pLockReadWrite); 632 637 633 /* Recache new machinestate: */638 /* Recache current item data and machine-state: */ 634 639 currentStateItem()->recache(); 635 640 currentStateItem()->updateCurrentState(enmState); … … 645 650 QWriteLocker locker(m_pLockReadWrite); 646 651 647 /* Recache new sessionstate: */652 /* Recache current session-state: */ 648 653 m_enmSessionState = enmState; 649 slt CurrentItemChanged(m_pSnapshotTree->currentItem());654 sltHandleCurrentItemChange(); 650 655 } 651 656 … … 657 662 658 663 /* Search for smallest snapshot age to optimize timer timeout: */ 659 const SnapshotAgeFormat age = traverseSnapshotAge(m_pSnapshotTree->invisibleRootItem());660 switch ( age)664 const SnapshotAgeFormat enmAge = traverseSnapshotAge(m_pSnapshotTree->invisibleRootItem()); 665 switch (enmAge) 661 666 { 662 667 case SnapshotAgeFormat_InSeconds: m_pTimerUpdateAge->setInterval(5 * 1000); break; … … 672 677 } 673 678 674 void UISnapshotPane::slt CurrentItemChanged(QTreeWidgetItem *pItem)679 void UISnapshotPane::sltHandleCurrentItemChange() 675 680 { 676 681 /* Acquire corresponding snapshot item: */ 677 const UISnapshotItem *pSnapshotItem = UISnapshotItem::toSnapshotItem( pItem);682 const UISnapshotItem *pSnapshotItem = UISnapshotItem::toSnapshotItem(m_pSnapshotTree->currentItem()); 678 683 679 684 /* Make the selected item visible: */ … … 736 741 } 737 742 738 void UISnapshotPane::slt ContextMenuRequested(const QPoint &point)743 void UISnapshotPane::sltHandleContextMenuRequest(const QPoint &position) 739 744 { 740 745 /* Search for corresponding item: */ 741 const QTreeWidgetItem *pItem = m_pSnapshotTree->itemAt(po int);746 const QTreeWidgetItem *pItem = m_pSnapshotTree->itemAt(position); 742 747 if (!pItem) 743 748 return; … … 768 773 769 774 /* Show menu: */ 770 menu.exec(m_pSnapshotTree->viewport()->mapToGlobal(po int));771 } 772 773 void UISnapshotPane::slt ItemChanged(QTreeWidgetItem *pItem)775 menu.exec(m_pSnapshotTree->viewport()->mapToGlobal(position)); 776 } 777 778 void UISnapshotPane::sltHandleItemChange(QTreeWidgetItem *pItem) 774 779 { 775 780 /* Make sure nothing being edited in the meantime: */ … … 782 787 783 788 /* Rename corresponding snapshot: */ 784 CSnapshot comSnapshot = pSnapshotItem->snapshotID().isNull() ? CSnapshot() : m_comMachine.FindSnapshot(pSnapshotItem->snapshotID()); 789 CSnapshot comSnapshot = pSnapshotItem->snapshotID().isNull() 790 ? CSnapshot() 791 : m_comMachine.FindSnapshot(pSnapshotItem->snapshotID()); 785 792 if (!comSnapshot.isNull() && comSnapshot.isOk() && comSnapshot.GetName() != pSnapshotItem->text(0)) 786 793 comSnapshot.SetName(pSnapshotItem->text(0)); … … 790 797 } 791 798 792 void UISnapshotPane::slt ItemDoubleClicked(QTreeWidgetItem *pItem)799 void UISnapshotPane::sltHandleItemDoubleClick(QTreeWidgetItem *pItem) 793 800 { 794 801 /* Acquire corresponding snapshot item: */ … … 862 869 /* Create snapshot toolbar: */ 863 870 m_pToolBar = new UIToolBar(this); 871 AssertPtrReturnVoid(m_pToolBar); 864 872 { 865 873 /* Configure toolbar: */ … … 873 881 ":/snapshot_take_disabled_22px.png", 874 882 ":/snapshot_take_disabled_16px.png"), 875 QString(), this, &UISnapshotPane::sltTakeSnapshot);883 QString(), this, &UISnapshotPane::sltTakeSnapshot); 876 884 { 877 885 m_pActionTakeSnapshot->setShortcut(QString("Ctrl+Shift+S")); … … 883 891 ":/snapshot_delete_disabled_22px.png", 884 892 ":/snapshot_delete_disabled_16px.png"), 885 QString(), this, &UISnapshotPane::sltDeleteSnapshot);893 QString(), this, &UISnapshotPane::sltDeleteSnapshot); 886 894 { 887 895 m_pActionDeleteSnapshot->setShortcut(QString("Ctrl+Shift+D")); … … 895 903 ":/snapshot_restore_disabled_22px.png", 896 904 ":/snapshot_restore_disabled_16px.png"), 897 QString(), this, &UISnapshotPane::sltRestoreSnapshot);905 QString(), this, &UISnapshotPane::sltRestoreSnapshot); 898 906 { 899 907 m_pActionRestoreSnapshot->setShortcut(QString("Ctrl+Shift+R")); … … 905 913 ":/snapshot_show_details_disabled_22px.png", 906 914 ":/snapshot_details_show_disabled_16px.png"), 907 QString(), this, &UISnapshotPane::sltShowSnapshotDetails);915 QString(), this, &UISnapshotPane::sltShowSnapshotDetails); 908 916 { 909 917 m_pActionShowSnapshotDetails->setShortcut(QString("Ctrl+Space")); … … 917 925 ":/vm_clone_disabled_22px.png", 918 926 ":/vm_clone_disabled_16px.png"), 919 QString(), this, &UISnapshotPane::sltCloneSnapshot);927 QString(), this, &UISnapshotPane::sltCloneSnapshot); 920 928 { 921 929 m_pActionCloneSnapshot->setShortcut(QString("Ctrl+Shift+C")); … … 931 939 /* Create snapshot tree: */ 932 940 m_pSnapshotTree = new UISnapshotTree(this); 941 AssertPtrReturnVoid(m_pSnapshotTree); 933 942 { 934 943 /* Configure tree: */ 935 944 connect(m_pSnapshotTree, &UISnapshotTree::currentItemChanged, 936 this, &UISnapshotPane::slt CurrentItemChanged);945 this, &UISnapshotPane::sltHandleCurrentItemChange); 937 946 connect(m_pSnapshotTree, &UISnapshotTree::customContextMenuRequested, 938 this, &UISnapshotPane::slt ContextMenuRequested);947 this, &UISnapshotPane::sltHandleContextMenuRequest); 939 948 connect(m_pSnapshotTree, &UISnapshotTree::itemChanged, 940 this, &UISnapshotPane::slt ItemChanged);949 this, &UISnapshotPane::sltHandleItemChange); 941 950 connect(m_pSnapshotTree, &UISnapshotTree::itemDoubleClicked, 942 this, &UISnapshotPane::slt ItemDoubleClicked);951 this, &UISnapshotPane::sltHandleItemDoubleClick); 943 952 944 953 /* Add into layout: */ … … 955 964 if (m_comMachine.isNull()) 956 965 { 957 slt CurrentItemChanged();966 sltHandleCurrentItemChange(); 958 967 return; 959 968 } … … 998 1007 m_pSnapshotTree->scrollToItem(pCurrentItem); 999 1008 m_pSnapshotTree->setCurrentItem(pCurrentItem); 1000 slt CurrentItemChanged(pCurrentItem);1009 sltHandleCurrentItemChange(); 1001 1010 } 1002 1011 /* If machine has no snapshots: */ … … 1013 1022 /* Choose current item: */ 1014 1023 m_pSnapshotTree->setCurrentItem(pCsi); 1015 slt CurrentItemChanged(pCsi);1024 sltHandleCurrentItemChange(); 1016 1025 } 1017 1026 … … 1325 1334 /* Show Snapshot Details dialog: */ 1326 1335 QPointer<VBoxSnapshotDetailsDlg> pDlg = new VBoxSnapshotDetailsDlg(this); 1327 pDlg->setData( comSnapshot);1336 pDlg->setData(*pSnapshotItem, comSnapshot); 1328 1337 if (pDlg->exec() == QDialog::Accepted) 1329 1338 pDlg->saveData(); -
trunk/src/VBox/Frontends/VirtualBox/src/selector/UISnapshotPane.h
r67121 r67147 105 105 /** @name Tree-widget handlers. 106 106 * @{ */ 107 /** Handles cursor change to @a pItem. */108 void slt CurrentItemChanged(QTreeWidgetItem *pItem = 0);109 /** Handles context menu request for @a point. */110 void slt ContextMenuRequested(const QPoint &point);111 /** Handles modification for @a pItem. */112 void slt ItemChanged(QTreeWidgetItem *pItem);113 /** Handles double-click for @a pItem. */114 void slt ItemDoubleClicked(QTreeWidgetItem *pItem);107 /** Handles tree-widget current item change. */ 108 void sltHandleCurrentItemChange(); 109 /** Handles context menu request for tree-widget @a position. */ 110 void sltHandleContextMenuRequest(const QPoint &position); 111 /** Handles tree-widget @a pItem change. */ 112 void sltHandleItemChange(QTreeWidgetItem *pItem); 113 /** Handles tree-widget @a pItem double-click. */ 114 void sltHandleItemDoubleClick(QTreeWidgetItem *pItem); 115 115 /** @} */ 116 116
Note:
See TracChangeset
for help on using the changeset viewer.