VirtualBox

Changeset 67119 in vbox for trunk/src/VBox


Ignore:
Timestamp:
May 26, 2017 3:54:23 PM (8 years ago)
Author:
vboxsync
Message:

FE/Qt: Selector UI: Tools pane: Snapshot pane: Get rid of Qt deps in header.

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  
    2525# include <QDateTime>
    2626# include <QHeaderView>
     27# include <QIcon>
    2728# include <QMenu>
    2829# include <QPointer>
     30# include <QReadWriteLock>
    2931# include <QScrollBar>
     32# include <QTimer>
    3033# include <QWriteLocker>
    3134
     
    344347        setText(0, m_comSnapshot.GetName());
    345348        m_fOnline = m_comSnapshot.GetOnline();
    346         setIcon(0, m_pSnapshotWidget->snapshotItemIcon(m_fOnline));
     349        setIcon(0, *m_pSnapshotWidget->snapshotItemIcon(m_fOnline));
    347350        m_strDesc = m_comSnapshot.GetDescription();
    348351        m_timestamp.setTime_t(m_comSnapshot.GetTimeStamp() / 1000);
     
    517520UISnapshotPane::UISnapshotPane(QWidget *pParent /* = 0 */)
    518521    : QIWithRetranslateUI<QWidget>(pParent)
     522    , m_enmSessionState(KSessionState_Null)
    519523    , m_pCurrentSnapshotItem(0)
     524    , m_pLockReadWrite(0)
    520525    , m_pActionTakeSnapshot(0)
    521526    , m_pActionRestoreSnapshot(0)
     
    523528    , m_pActionShowSnapshotDetails(0)
    524529    , m_pActionCloneSnapshot(0)
     530    , m_pTimerUpdateAge(0)
    525531    , m_fShapshotOperationsAllowed(false)
     532    , m_pIconSnapshotOffline(0)
     533    , m_pIconSnapshotOnline(0)
    526534    , m_pSnapshotTree(0)
    527535{
     536    /* Create locker: */
     537    m_pLockReadWrite = new QReadWriteLock;
     538
    528539    /* 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"));
    531542
    532543    /* Create layout: */
     
    627638
    628639    /* 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()));
    631643
    632644    /* Setup Main event connections: */
     
    642654}
    643655
     656UISnapshotPane::~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
    644676void UISnapshotPane::setMachine(const CMachine &comMachine)
    645677{
     
    663695    /* Refresh everything: */
    664696    refreshAll();
     697}
     698
     699const QIcon *UISnapshotPane::snapshotItemIcon(bool fOnline) const
     700{
     701    return !fOnline ? m_pIconSnapshotOffline : m_pIconSnapshotOnline;
    665702}
    666703
     
    791828{
    792829    /* Make sure nothing being edited in the meantime: */
    793     if (!m_lockReadWrite.tryLockForWrite())
     830    if (!m_pLockReadWrite->tryLockForWrite())
    794831        return;
    795832
     
    804841
    805842    /* Allows editing again: */
    806     m_lockReadWrite.unlock();
     843    m_pLockReadWrite->unlock();
    807844}
    808845
     
    828865
    829866    /* Prevent snapshot editing in the meantime: */
    830     QWriteLocker locker(&m_lockReadWrite);
     867    QWriteLocker locker(m_pLockReadWrite);
    831868
    832869    /* Recache state current item: */
     
    841878
    842879    /* Prevent snapshot editing in the meantime: */
    843     QWriteLocker locker(&m_lockReadWrite);
     880    QWriteLocker locker(m_pLockReadWrite);
    844881
    845882    /* Recache new machine state: */
     
    855892
    856893    /* Prevent snapshot editing in the meantime: */
    857     QWriteLocker locker(&m_lockReadWrite);
     894    QWriteLocker locker(m_pLockReadWrite);
    858895
    859896    /* Recache new session state: */
     
    865902{
    866903    /* Stop timer if active: */
    867     if (m_ageUpdateTimer.isActive())
    868         m_ageUpdateTimer.stop();
     904    if (m_pTimerUpdateAge->isActive())
     905        m_pTimerUpdateAge->stop();
    869906
    870907    /* Search for smallest snapshot age to optimize timer timeout: */
     
    872909    switch (age)
    873910    {
    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;
    879916    }
    880917
    881918    /* Restart timer if necessary: */
    882     if (m_ageUpdateTimer.interval() > 0)
    883         m_ageUpdateTimer.start();
     919    if (m_pTimerUpdateAge->interval() > 0)
     920        m_pTimerUpdateAge->start();
    884921}
    885922
     
    11771214{
    11781215    /* Prevent snapshot editing in the meantime: */
    1179     QWriteLocker locker(&m_lockReadWrite);
     1216    QWriteLocker locker(m_pLockReadWrite);
    11801217
    11811218    /* If VM is null, just updated the current itm: */
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UISnapshotPane.h

    r67118 r67119  
    1919#define ___UISnapshotPane_h___
    2020
    21 /* Qt includes: */
    22 #include <QIcon>
    23 #include <QTimer>
    24 #include <QReadWriteLock>
    25 
    2621/* GUI includes: */
    2722#include "QIWithRetranslateUI.h"
     
    3227
    3328/* Forward declarations: */
     29class QIcon;
     30class QReadWriteLock;
     31class QTimer;
     32class QTreeWidgetItem;
     33class QITreeWidgetItem;
    3434class UISnapshotTree;
    3535class UISnapshotItem;
    36 class QTreeWidgetItem;
    37 class QITreeWidgetItem;
    3836
    3937
     
    5856    /** Constructs snapshot pane passing @a pParent to the base-class. */
    5957    UISnapshotPane(QWidget *pParent = 0);
     58    /** Destructs snapshot pane. */
     59    virtual ~UISnapshotPane() /* override */;
    6060
    6161    /** Defines the @a comMachine object to be parsed. */
     
    6363
    6464    /** 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;
    6666
    6767protected:
     
    157157        UISnapshotItem *m_pCurrentSnapshotItem;
    158158        /** Holds the snapshot item editing protector. */
    159         QReadWriteLock m_lockReadWrite;
     159        QReadWriteLock *m_pLockReadWrite;
    160160    /** @} */
    161161
     
    174174
    175175        /** Holds the snapshot age update timer. */
    176         QTimer m_ageUpdateTimer;
     176        QTimer *m_pTimerUpdateAge;
    177177
    178178        /** Holds whether the snapshot operations are allowed. */
     
    180180
    181181        /** Holds the cached snapshot-item pixmap for 'offline' state. */
    182         QIcon m_snapshotIconOffline;
     182        QIcon *m_pIconSnapshotOffline;
    183183        /** Holds the cached snapshot-item pixmap for 'online' state. */
    184         QIcon m_snapshotIconOnline;
     184        QIcon *m_pIconSnapshotOnline;
    185185
    186186        /** Holds the snapshot tree instance. */
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette