- Timestamp:
- May 26, 2017 3:54:23 PM (8 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/selector
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/selector/UISnapshotPane.cpp
r67044 r67119 25 25 # include <QDateTime> 26 26 # include <QHeaderView> 27 # include <QIcon> 27 28 # include <QMenu> 28 29 # include <QPointer> 30 # include <QReadWriteLock> 29 31 # include <QScrollBar> 32 # include <QTimer> 30 33 # include <QWriteLocker> 31 34 … … 344 347 setText(0, m_comSnapshot.GetName()); 345 348 m_fOnline = m_comSnapshot.GetOnline(); 346 setIcon(0, m_pSnapshotWidget->snapshotItemIcon(m_fOnline));349 setIcon(0, *m_pSnapshotWidget->snapshotItemIcon(m_fOnline)); 347 350 m_strDesc = m_comSnapshot.GetDescription(); 348 351 m_timestamp.setTime_t(m_comSnapshot.GetTimeStamp() / 1000); … … 517 520 UISnapshotPane::UISnapshotPane(QWidget *pParent /* = 0 */) 518 521 : QIWithRetranslateUI<QWidget>(pParent) 522 , m_enmSessionState(KSessionState_Null) 519 523 , m_pCurrentSnapshotItem(0) 524 , m_pLockReadWrite(0) 520 525 , m_pActionTakeSnapshot(0) 521 526 , m_pActionRestoreSnapshot(0) … … 523 528 , m_pActionShowSnapshotDetails(0) 524 529 , m_pActionCloneSnapshot(0) 530 , m_pTimerUpdateAge(0) 525 531 , m_fShapshotOperationsAllowed(false) 532 , m_pIconSnapshotOffline(0) 533 , m_pIconSnapshotOnline(0) 526 534 , m_pSnapshotTree(0) 527 535 { 536 /* Create locker: */ 537 m_pLockReadWrite = new QReadWriteLock; 538 528 539 /* Cache pixmaps: */ 529 m_ snapshotIconOffline = UIIconPool::iconSet(":/snapshot_offline_16px.png");530 m_ snapshotIconOnline = UIIconPool::iconSet(":/snapshot_online_16px.png");540 m_pIconSnapshotOffline = new QIcon(UIIconPool::iconSet(":/snapshot_offline_16px.png")); 541 m_pIconSnapshotOnline = new QIcon(UIIconPool::iconSet(":/snapshot_online_16px.png")); 531 542 532 543 /* Create layout: */ … … 627 638 628 639 /* Setup timer: */ 629 m_ageUpdateTimer.setSingleShot(true); 630 connect(&m_ageUpdateTimer, SIGNAL(timeout()), this, SLOT(sltUpdateSnapshotsAge())); 640 m_pTimerUpdateAge = new QTimer; 641 m_pTimerUpdateAge->setSingleShot(true); 642 connect(m_pTimerUpdateAge, SIGNAL(timeout()), this, SLOT(sltUpdateSnapshotsAge())); 631 643 632 644 /* Setup Main event connections: */ … … 642 654 } 643 655 656 UISnapshotPane::~UISnapshotPane() 657 { 658 /* Stop timer if active: */ 659 if (m_pTimerUpdateAge->isActive()) 660 m_pTimerUpdateAge->stop(); 661 /* Destroy timer: */ 662 delete m_pTimerUpdateAge; 663 m_pTimerUpdateAge = 0; 664 665 /* Destroy icons: */ 666 delete m_pIconSnapshotOffline; 667 delete m_pIconSnapshotOnline; 668 m_pIconSnapshotOffline = 0; 669 m_pIconSnapshotOnline = 0; 670 671 /* Destroy read-write locker: */ 672 delete m_pLockReadWrite; 673 m_pLockReadWrite = 0; 674 } 675 644 676 void UISnapshotPane::setMachine(const CMachine &comMachine) 645 677 { … … 663 695 /* Refresh everything: */ 664 696 refreshAll(); 697 } 698 699 const QIcon *UISnapshotPane::snapshotItemIcon(bool fOnline) const 700 { 701 return !fOnline ? m_pIconSnapshotOffline : m_pIconSnapshotOnline; 665 702 } 666 703 … … 791 828 { 792 829 /* Make sure nothing being edited in the meantime: */ 793 if (!m_ lockReadWrite.tryLockForWrite())830 if (!m_pLockReadWrite->tryLockForWrite()) 794 831 return; 795 832 … … 804 841 805 842 /* Allows editing again: */ 806 m_ lockReadWrite.unlock();843 m_pLockReadWrite->unlock(); 807 844 } 808 845 … … 828 865 829 866 /* Prevent snapshot editing in the meantime: */ 830 QWriteLocker locker( &m_lockReadWrite);867 QWriteLocker locker(m_pLockReadWrite); 831 868 832 869 /* Recache state current item: */ … … 841 878 842 879 /* Prevent snapshot editing in the meantime: */ 843 QWriteLocker locker( &m_lockReadWrite);880 QWriteLocker locker(m_pLockReadWrite); 844 881 845 882 /* Recache new machine state: */ … … 855 892 856 893 /* Prevent snapshot editing in the meantime: */ 857 QWriteLocker locker( &m_lockReadWrite);894 QWriteLocker locker(m_pLockReadWrite); 858 895 859 896 /* Recache new session state: */ … … 865 902 { 866 903 /* Stop timer if active: */ 867 if (m_ ageUpdateTimer.isActive())868 m_ ageUpdateTimer.stop();904 if (m_pTimerUpdateAge->isActive()) 905 m_pTimerUpdateAge->stop(); 869 906 870 907 /* Search for smallest snapshot age to optimize timer timeout: */ … … 872 909 switch (age) 873 910 { 874 case SnapshotAgeFormat_InSeconds: m_ ageUpdateTimer.setInterval(5 * 1000); break;875 case SnapshotAgeFormat_InMinutes: m_ ageUpdateTimer.setInterval(60 * 1000); break;876 case SnapshotAgeFormat_InHours: m_ ageUpdateTimer.setInterval(60 * 60 * 1000); break;877 case SnapshotAgeFormat_InDays: m_ ageUpdateTimer.setInterval(24 * 60 * 60 * 1000); break;878 default: m_ ageUpdateTimer.setInterval(0); break;911 case SnapshotAgeFormat_InSeconds: m_pTimerUpdateAge->setInterval(5 * 1000); break; 912 case SnapshotAgeFormat_InMinutes: m_pTimerUpdateAge->setInterval(60 * 1000); break; 913 case SnapshotAgeFormat_InHours: m_pTimerUpdateAge->setInterval(60 * 60 * 1000); break; 914 case SnapshotAgeFormat_InDays: m_pTimerUpdateAge->setInterval(24 * 60 * 60 * 1000); break; 915 default: m_pTimerUpdateAge->setInterval(0); break; 879 916 } 880 917 881 918 /* Restart timer if necessary: */ 882 if (m_ ageUpdateTimer.interval() > 0)883 m_ ageUpdateTimer.start();919 if (m_pTimerUpdateAge->interval() > 0) 920 m_pTimerUpdateAge->start(); 884 921 } 885 922 … … 1177 1214 { 1178 1215 /* Prevent snapshot editing in the meantime: */ 1179 QWriteLocker locker( &m_lockReadWrite);1216 QWriteLocker locker(m_pLockReadWrite); 1180 1217 1181 1218 /* If VM is null, just updated the current itm: */ -
trunk/src/VBox/Frontends/VirtualBox/src/selector/UISnapshotPane.h
r67118 r67119 19 19 #define ___UISnapshotPane_h___ 20 20 21 /* Qt includes: */22 #include <QIcon>23 #include <QTimer>24 #include <QReadWriteLock>25 26 21 /* GUI includes: */ 27 22 #include "QIWithRetranslateUI.h" … … 32 27 33 28 /* Forward declarations: */ 29 class QIcon; 30 class QReadWriteLock; 31 class QTimer; 32 class QTreeWidgetItem; 33 class QITreeWidgetItem; 34 34 class UISnapshotTree; 35 35 class UISnapshotItem; 36 class QTreeWidgetItem;37 class QITreeWidgetItem;38 36 39 37 … … 58 56 /** Constructs snapshot pane passing @a pParent to the base-class. */ 59 57 UISnapshotPane(QWidget *pParent = 0); 58 /** Destructs snapshot pane. */ 59 virtual ~UISnapshotPane() /* override */; 60 60 61 61 /** Defines the @a comMachine object to be parsed. */ … … 63 63 64 64 /** Returns cached snapshot-item icon depending on @a fOnline flag. */ 65 const QIcon &snapshotItemIcon(bool fOnline) const { return !fOnline ? m_snapshotIconOffline : m_snapshotIconOnline; }65 const QIcon *snapshotItemIcon(bool fOnline) const; 66 66 67 67 protected: … … 157 157 UISnapshotItem *m_pCurrentSnapshotItem; 158 158 /** Holds the snapshot item editing protector. */ 159 QReadWriteLock m_lockReadWrite;159 QReadWriteLock *m_pLockReadWrite; 160 160 /** @} */ 161 161 … … 174 174 175 175 /** Holds the snapshot age update timer. */ 176 QTimer m_ageUpdateTimer;176 QTimer *m_pTimerUpdateAge; 177 177 178 178 /** Holds whether the snapshot operations are allowed. */ … … 180 180 181 181 /** Holds the cached snapshot-item pixmap for 'offline' state. */ 182 QIcon m_snapshotIconOffline;182 QIcon *m_pIconSnapshotOffline; 183 183 /** Holds the cached snapshot-item pixmap for 'online' state. */ 184 QIcon m_snapshotIconOnline;184 QIcon *m_pIconSnapshotOnline; 185 185 186 186 /** Holds the snapshot tree instance. */
Note:
See TracChangeset
for help on using the changeset viewer.