VirtualBox

Changeset 63821 in vbox


Ignore:
Timestamp:
Sep 13, 2016 6:35:33 PM (8 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:6899: Accessibility support (step 26): Selector UI: Overal coding-style cleanup for UISnapshotPane.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/selector
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UISnapshotPane.cpp

    r63818 r63821  
    6161
    6262    /** Constructs normal snapshot item (child of tree-widget). */
    63     SnapshotWgtItem (UISnapshotPane *pSnapshotWidget, QTreeWidget *aTreeWidget, const CSnapshot &aSnapshot)
    64         : QTreeWidgetItem (aTreeWidget, ItemType)
     63    SnapshotWgtItem(UISnapshotPane *pSnapshotWidget, QTreeWidget *pTreeWidget, const CSnapshot &comSnapshot)
     64        : QTreeWidgetItem(pTreeWidget, ItemType)
    6565        , m_pSnapshotWidget(pSnapshotWidget)
    66         , mIsCurrentState (false)
    67         , mSnapshot (aSnapshot)
     66        , m_fCurrentState(false)
     67        , m_comSnapshot(comSnapshot)
    6868    {
    6969    }
    7070
    7171    /** Constructs normal snapshot item (child of tree-widget-item). */
    72     SnapshotWgtItem (UISnapshotPane *pSnapshotWidget, QTreeWidgetItem *aRootItem, const CSnapshot &aSnapshot)
    73         : QTreeWidgetItem (aRootItem, ItemType)
     72    SnapshotWgtItem(UISnapshotPane *pSnapshotWidget, QTreeWidgetItem *pRootItem, const CSnapshot &comSnapshot)
     73        : QTreeWidgetItem(pRootItem, ItemType)
    7474        , m_pSnapshotWidget(pSnapshotWidget)
    75         , mIsCurrentState (false)
    76         , mSnapshot (aSnapshot)
     75        , m_fCurrentState(false)
     76        , m_comSnapshot(comSnapshot)
    7777    {
    7878    }
    7979
    8080    /** Constructs "current state" item (child of tree-widget). */
    81     SnapshotWgtItem (UISnapshotPane *pSnapshotWidget, QTreeWidget *aTreeWidget, const CMachine &aMachine)
    82         : QTreeWidgetItem (aTreeWidget, ItemType)
     81    SnapshotWgtItem(UISnapshotPane *pSnapshotWidget, QTreeWidget *pTreeWidget, const CMachine &comMachine)
     82        : QTreeWidgetItem(pTreeWidget, ItemType)
    8383        , m_pSnapshotWidget(pSnapshotWidget)
    84         , mIsCurrentState (true)
    85         , mMachine (aMachine)
     84        , m_fCurrentState(true)
     85        , m_comMachine(comMachine)
    8686    {
    8787        /* Fetch current machine state: */
    88         updateCurrentState (mMachine.GetState());
     88        updateCurrentState(m_comMachine.GetState());
    8989    }
    9090
    9191    /** Constructs "current state" item (child of tree-widget-item). */
    92     SnapshotWgtItem (UISnapshotPane *pSnapshotWidget, QTreeWidgetItem *aRootItem, const CMachine &aMachine)
    93         : QTreeWidgetItem (aRootItem, ItemType)
     92    SnapshotWgtItem(UISnapshotPane *pSnapshotWidget, QTreeWidgetItem *pRootItem, const CMachine &comMachine)
     93        : QTreeWidgetItem(pRootItem, ItemType)
    9494        , m_pSnapshotWidget(pSnapshotWidget)
    95         , mIsCurrentState (true)
    96         , mMachine (aMachine)
     95        , m_fCurrentState(true)
     96        , m_comMachine(comMachine)
    9797    {
    9898        /* Fetch current machine state: */
    99         updateCurrentState (mMachine.GetState());
     99        updateCurrentState(m_comMachine.GetState());
    100100    }
    101101
    102102    /** Returns item data for corresponding @a iColumn and @a iRole. */
    103     QVariant data (int aColumn, int aRole) const
    104     {
    105         switch (aRole)
     103    QVariant data(int iColumn, int iRole) const
     104    {
     105        switch (iRole)
    106106        {
    107107            case Qt::DisplayRole:
    108108            {
    109109                /* Call to the base-class for "current state" item, compose ourselves otherwise: */
    110                 return mIsCurrentState ? QTreeWidgetItem::data (aColumn, aRole) : QVariant (QString ("%1%2")
    111                                          .arg (QTreeWidgetItem::data (aColumn, Qt::DisplayRole).toString())
    112                                          .arg (QTreeWidgetItem::data (aColumn, Qt::UserRole).toString()));
     110                return m_fCurrentState ? QTreeWidgetItem::data(iColumn, iRole) : QVariant(QString("%1%2")
     111                                         .arg(QTreeWidgetItem::data(iColumn, Qt::DisplayRole).toString())
     112                                         .arg(QTreeWidgetItem::data(iColumn, Qt::UserRole).toString()));
    113113            }
    114114            case Qt::SizeHintRole:
     
    118118                const int iIconMetric = pStyle->pixelMetric(QStyle::PM_SmallIconSize);
    119119                /* Determine the minimum size-hint for this tree-widget-item: */
    120                 const QSize baseSizeHint = QTreeWidgetItem::data(aColumn, aRole).toSize();
     120                const QSize baseSizeHint = QTreeWidgetItem::data(iColumn, iRole).toSize();
    121121                /* Determine the effective height-hint for this tree-widget-item: */
    122122                const int iEffectiveHeightHint = qMax(baseSizeHint.height(),
     
    130130
    131131        /* Call to base-class: */
    132         return QTreeWidgetItem::data (aColumn, aRole);
     132        return QTreeWidgetItem::data(iColumn, iRole);
    133133    }
    134134
    135135    /** Returns item text for corresponding @a iColumn. */
    136     QString text (int aColumn) const
    137     {
    138         return QTreeWidgetItem::data (aColumn, Qt::DisplayRole).toString();
     136    QString text(int iColumn) const
     137    {
     138        return QTreeWidgetItem::data(iColumn, Qt::DisplayRole).toString();
    139139    }
    140140
     
    142142    bool isCurrentStateItem() const
    143143    {
    144         return mSnapshot.isNull();
     144        return m_comSnapshot.isNull();
    145145    }
    146146
    147147    /** Calculates and returns the current item level. */
    148     int level()
    149     {
    150         QTreeWidgetItem *item = this;
    151         int result = 0;
    152         while (item->parent())
    153         {
    154             ++ result;
    155             item = item->parent();
    156         }
    157         return result;
     148    int level() const
     149    {
     150        const QTreeWidgetItem *pItem = this;
     151        int iResult = 0;
     152        while (pItem->parent())
     153        {
     154            ++iResult;
     155            pItem = pItem->parent();
     156        }
     157        return iResult;
    158158    }
    159159
     
    161161    bool bold() const { return font (0).bold(); }
    162162    /** Defines whether the font is @a fBold. */
    163     void setBold (bool aBold)
     163    void setBold(bool fBold)
    164164    {
    165165        /* Update font: */
    166         QFont myFont = font (0);
    167         myFont.setBold (aBold);
    168         setFont (0, myFont);
     166        QFont myFont = font(0);
     167        myFont.setBold(fBold);
     168        setFont(0, myFont);
    169169
    170170        /* Adjust text: */
     
    175175    bool italic() const { return font (0).italic(); }
    176176    /** Defines whether the font is @a fItalic. */
    177     void setItalic (bool aItalic)
     177    void setItalic(bool fItalic)
    178178    {
    179179        /* Update font: */
    180         QFont myFont = font (0);
    181         myFont.setItalic (aItalic);
    182         setFont (0, myFont);
     180        QFont myFont = font(0);
     181        myFont.setItalic(fItalic);
     182        setFont(0, myFont);
    183183
    184184        /* Adjust text: */
     
    187187
    188188    /** Returns item machine. */
    189     CMachine machine() const { return mMachine; }
     189    CMachine machine() const { return m_comMachine; }
    190190    /** Returns item snapshot. */
    191     CSnapshot snapshot() const { return mSnapshot; }
     191    CSnapshot snapshot() const { return m_comSnapshot; }
    192192    /** Returns item snapshot ID. */
    193     QString snapshotId() const { return mId; }
     193    QString snapshotID() const { return m_strSnapshotID; }
    194194
    195195    /** Recaches the item's contents. */
     
    197197    {
    198198        /* For "current state" item: */
    199         if (mIsCurrentState)
    200         {
    201             Assert (!mMachine.isNull());
    202             mCurStateModified = mMachine.GetCurrentStateModified();
    203             setText (0, mCurStateModified ?
    204                         UISnapshotPane::tr ("Current State (changed)", "Current State (Modified)") :
    205                         UISnapshotPane::tr ("Current State", "Current State (Unmodified)"));
    206             mDesc = mCurStateModified ?
    207                     UISnapshotPane::tr ("The current state differs from the state stored in the current snapshot") :
    208                     parent() != 0 ?
    209                     UISnapshotPane::tr ("The current state is identical to the state stored in the current snapshot") :
    210                     QString::null;
     199        if (m_fCurrentState)
     200        {
     201            AssertReturnVoid(!m_comMachine.isNull());
     202            m_fCurrentStateModified = m_comMachine.GetCurrentStateModified();
     203            setText(0, m_fCurrentStateModified ?
     204                       UISnapshotPane::tr("Current State (changed)", "Current State (Modified)") :
     205                       UISnapshotPane::tr("Current State", "Current State (Unmodified)"));
     206            m_strDesc = m_fCurrentStateModified ?
     207                        UISnapshotPane::tr("The current state differs from the state stored in the current snapshot") :
     208                        parent() != 0 ?
     209                        UISnapshotPane::tr("The current state is identical to the state stored in the current snapshot") :
     210                        QString();
    211211        }
    212212        /* For others: */
    213213        else
    214214        {
    215             Assert (!mSnapshot.isNull());
    216             mId = mSnapshot.GetId();
    217             setText (0, mSnapshot.GetName());
    218             mOnline = mSnapshot.GetOnline();
    219             setIcon(0, m_pSnapshotWidget->snapshotItemIcon(mOnline));
    220             mDesc = mSnapshot.GetDescription();
    221             mTimestamp.setTime_t (mSnapshot.GetTimeStamp() / 1000);
    222             mCurStateModified = false;
     215            AssertReturnVoid(!m_comSnapshot.isNull());
     216            m_strSnapshotID = m_comSnapshot.GetId();
     217            setText(0, m_comSnapshot.GetName());
     218            m_fOnline = m_comSnapshot.GetOnline();
     219            setIcon(0, m_pSnapshotWidget->snapshotItemIcon(m_fOnline));
     220            m_strDesc = m_comSnapshot.GetDescription();
     221            m_timestamp.setTime_t(m_comSnapshot.GetTimeStamp() / 1000);
     222            m_fCurrentStateModified = false;
    223223        }
    224224
     
    230230
    231231    /** Returns current machine state. */
    232     KMachineState getCurrentState()
     232    KMachineState getCurrentState() const
    233233    {
    234234        /* Make sure machine is valid: */
    235         if (mMachine.isNull())
     235        if (m_comMachine.isNull())
    236236            return KMachineState_Null;
    237237
    238238        /* Return cached state: */
    239         return mMachineState;
     239        return m_enmMachineState;
    240240    }
    241241
    242242    /** Recaches current machine state. */
    243     void updateCurrentState (KMachineState aState)
     243    void updateCurrentState(KMachineState enmState)
    244244    {
    245245        /* Make sure machine is valid: */
    246         if (mMachine.isNull())
     246        if (m_comMachine.isNull())
    247247            return;
    248248
    249249        /* Set corresponding icon: */
    250         setIcon(0, gpConverter->toIcon(aState));
     250        setIcon(0, gpConverter->toIcon(enmState));
    251251        /* Cache new state: */
    252         mMachineState = aState;
     252        m_enmMachineState = enmState;
    253253        /* Update timestamp: */
    254         mTimestamp.setTime_t (mMachine.GetLastStateChange() / 1000);
     254        m_timestamp.setTime_t(m_comMachine.GetLastStateChange() / 1000);
    255255    }
    256256
     
    259259    {
    260260        /* Prepare age: */
    261         QString age;
     261        QString strAge;
    262262
    263263        /* Age: [date time|%1d ago|%1h ago|%1min ago|%1sec ago] */
    264         SnapshotAgeFormat ageFormat;
    265         QDateTime now = QDateTime::currentDateTime();
    266         QDateTime then = mTimestamp;
     264        SnapshotAgeFormat enmAgeFormat;
     265        const QDateTime now = QDateTime::currentDateTime();
     266        QDateTime then = m_timestamp;
    267267        if (then > now)
    268268            then = now; /* can happen if the host time is wrong */
    269         if (then.daysTo (now) > 30)
    270         {
    271             age = UISnapshotPane::tr (" (%1)").arg (then.toString (Qt::LocalDate));
    272             ageFormat = AgeMax;
    273         }
    274         else if (then.secsTo (now) > 60 * 60 * 24)
    275         {
    276             age = UISnapshotPane::tr (" (%1 ago)").arg(VBoxGlobal::daysToString(then.secsTo (now) / 60 / 60 / 24));
    277             ageFormat = AgeInDays;
    278         }
    279         else if (then.secsTo (now) > 60 * 60)
    280         {
    281             age = UISnapshotPane::tr (" (%1 ago)").arg(VBoxGlobal::hoursToString(then.secsTo (now) / 60 / 60));
    282             ageFormat = AgeInHours;
    283         }
    284         else if (then.secsTo (now) > 60)
    285         {
    286             age = UISnapshotPane::tr (" (%1 ago)").arg(VBoxGlobal::minutesToString(then.secsTo (now) / 60));
    287             ageFormat = AgeInMinutes;
     269        if (then.daysTo(now) > 30)
     270        {
     271            strAge = UISnapshotPane::tr(" (%1)").arg(then.toString(Qt::LocalDate));
     272            enmAgeFormat = SnapshotAgeFormat_Max;
     273        }
     274        else if (then.secsTo(now) > 60 * 60 * 24)
     275        {
     276            strAge = UISnapshotPane::tr(" (%1 ago)").arg(VBoxGlobal::daysToString(then.secsTo(now) / 60 / 60 / 24));
     277            enmAgeFormat = SnapshotAgeFormat_InDays;
     278        }
     279        else if (then.secsTo(now) > 60 * 60)
     280        {
     281            strAge = UISnapshotPane::tr(" (%1 ago)").arg(VBoxGlobal::hoursToString(then.secsTo(now) / 60 / 60));
     282            enmAgeFormat = SnapshotAgeFormat_InHours;
     283        }
     284        else if (then.secsTo(now) > 60)
     285        {
     286            strAge = UISnapshotPane::tr(" (%1 ago)").arg(VBoxGlobal::minutesToString(then.secsTo(now) / 60));
     287            enmAgeFormat = SnapshotAgeFormat_InMinutes;
    288288        }
    289289        else
    290290        {
    291             age = UISnapshotPane::tr (" (%1 ago)").arg(VBoxGlobal::secondsToString(then.secsTo (now)));
    292             ageFormat = AgeInSeconds;
     291            strAge = UISnapshotPane::tr(" (%1 ago)").arg(VBoxGlobal::secondsToString(then.secsTo(now)));
     292            enmAgeFormat = SnapshotAgeFormat_InSeconds;
    293293        }
    294294
    295295        /* Update data: */
    296         setData (0, Qt::UserRole, age);
     296        setData(0, Qt::UserRole, strAge);
    297297
    298298        /* Return age: */
    299         return ageFormat;
    300     }
    301 
    302 private:
     299        return enmAgeFormat;
     300    }
     301
     302protected:
    303303
    304304    /** Adjusts item text. */
     
    306306    {
    307307        if (!treeWidget()) return; /* only for initialised items */
    308         QFontMetrics metrics (font (0));
    309         int hei0 = (metrics.height() > 16 ?
    310                    metrics.height() /* text */ : 16 /* icon */) +
    311                    2 * 2 /* 2 pixel per margin */;
    312         int wid0 = metrics.width (text (0)) /* text */ +
    313                    treeWidget()->indentation() /* indent */ +
    314                    16 /* icon */;
     308        QFontMetrics metrics(font(0));
     309        int iHei0 = (metrics.height() > 16 ?
     310                     metrics.height() /* text */ : 16 /* icon */) +
     311                    2 * 2 /* 2 pixel per margin */;
     312        int iWid0 = metrics.width(text(0)) /* text */ +
     313                    treeWidget()->indentation() /* indent */ +
     314                    16 /* icon */;
    315315
    316316        /* Adjust size finally: */
    317         setSizeHint (0, QSize (wid0, hei0));
     317        setSizeHint(0, QSize(iWid0, iHei0));
    318318    }
    319319
     
    322322    {
    323323        /* Is the saved date today? */
    324         QString name = text (0);
     324        const QString strName = text(0);
    325325
    326326        /* Compose date time: */
    327         bool dateTimeToday = mTimestamp.date() == QDate::currentDate();
    328         QString dateTime = dateTimeToday ?
    329                            mTimestamp.time().toString (Qt::LocalDate) :
    330                            mTimestamp.toString (Qt::LocalDate);
     327        const bool fDateTimeToday = m_timestamp.date() == QDate::currentDate();
     328        QString strDateTime = fDateTimeToday ?
     329                              m_timestamp.time().toString(Qt::LocalDate) :
     330                              m_timestamp.toString(Qt::LocalDate);
    331331
    332332        /* Prepare details: */
    333         QString details;
     333        QString strDetails;
    334334
    335335        /* For snapshot item: */
    336         if (!mSnapshot.isNull())
    337         {
    338             /* The current snapshot is always bold */
     336        if (!m_comSnapshot.isNull())
     337        {
     338            /* The current snapshot is always bold: */
    339339            if (bold())
    340                 details = UISnapshotPane::tr (" (current, ", "Snapshot details");
     340                strDetails = UISnapshotPane::tr(" (current, ", "Snapshot details");
    341341            else
    342                 details = " (";
     342                strDetails = " (";
    343343
    344344            /* Add online/offline information: */
    345             details += mOnline ? UISnapshotPane::tr ("online)", "Snapshot details")
    346                                : UISnapshotPane::tr ("offline)", "Snapshot details");
     345            strDetails += m_fOnline ? UISnapshotPane::tr("online)", "Snapshot details")
     346                                    : UISnapshotPane::tr("offline)", "Snapshot details");
    347347
    348348            /* Add date/time information: */
    349             if (dateTimeToday)
    350                 dateTime = UISnapshotPane::tr ("Taken at %1", "Snapshot (time)").arg (dateTime);
     349            if (fDateTimeToday)
     350                strDateTime = UISnapshotPane::tr("Taken at %1", "Snapshot (time)").arg(strDateTime);
    351351            else
    352                 dateTime = UISnapshotPane::tr ("Taken on %1", "Snapshot (date + time)").arg (dateTime);
     352                strDateTime = UISnapshotPane::tr("Taken on %1", "Snapshot (date + time)").arg(strDateTime);
    353353        }
    354354        /* For "current state" item: */
    355355        else
    356356        {
    357             dateTime = UISnapshotPane::tr ("%1 since %2", "Current State (time or date + time)")
    358                 .arg (gpConverter->toString (mMachineState)).arg (dateTime);
     357            strDateTime = UISnapshotPane::tr("%1 since %2", "Current State (time or date + time)")
     358                          .arg(gpConverter->toString(m_enmMachineState)).arg(strDateTime);
    359359        }
    360360
    361361        /* Prepare tool-tip: */
    362         QString toolTip = QString ("<nobr><b>%1</b>%2</nobr><br><nobr>%3</nobr>")
    363             .arg (name) .arg (details).arg (dateTime);
     362        QString strToolTip = QString("<nobr><b>%1</b>%2</nobr><br><nobr>%3</nobr>")
     363                             .arg(strName).arg(strDetails).arg(strDateTime);
    364364
    365365        /* Append description if any: */
    366         if (!mDesc.isEmpty())
    367             toolTip += "<hr>" + mDesc;
     366        if (!m_strDesc.isEmpty())
     367            strToolTip += "<hr>" + m_strDesc;
    368368
    369369        /* Assign tool-tip finally: */
    370         setToolTip (0, toolTip);
    371     }
     370        setToolTip(0, strToolTip);
     371    }
     372
     373private:
    372374
    373375    /** Holds the pointer to the snapshot-widget this item belongs to. */
     
    375377
    376378    /** Holds whether this is a "current state" item. */
    377     bool mIsCurrentState;
     379    bool                     m_fCurrentState;
    378380
    379381    /** Holds the snapshot COM wrapper. */
    380     CSnapshot mSnapshot;
     382    CSnapshot                m_comSnapshot;
    381383    /** Holds the machine COM wrapper. */
    382     CMachine mMachine;
     384    CMachine                 m_comMachine;
    383385
    384386    /** Holds the current snapshot ID. */
    385     QString mId;
     387    QString                  m_strSnapshotID;
    386388    /** Holds whether the current snapshot is online one. */
    387     bool mOnline;
     389    bool                     m_fOnline;
    388390
    389391    /** Holds the item description. */
    390     QString mDesc;
     392    QString                  m_strDesc;
    391393    /** Holds the item timestamp. */
    392     QDateTime mTimestamp;
     394    QDateTime                m_timestamp;
    393395
    394396    /** Holds whether the current state is modified. */
    395     bool mCurStateModified;
     397    bool                     m_fCurrentStateModified;
    396398    /** Holds the cached machine state. */
    397     KMachineState mMachineState;
     399    KMachineState            m_enmMachineState;
    398400};
    399401
     
    407409
    408410    /** Constructs edit blocker. */
    409     SnapshotEditBlocker (bool &aProtector)
    410         : mProtector (aProtector)
    411     {
    412         mProtector = true;
     411    SnapshotEditBlocker(bool &fProtector)
     412        : m_fProtector(fProtector)
     413    {
     414        m_fProtector = true;
    413415    }
    414416
    415417    /** Destructs edit blocker. */
    416    ~SnapshotEditBlocker()
    417     {
    418         mProtector = false;
     418    virtual ~SnapshotEditBlocker()
     419    {
     420        m_fProtector = false;
    419421    }
    420422
     
    422424
    423425    /** Holds the protector flag reference. */
    424     bool &mProtector;
     426    bool &m_fProtector;
    425427};
    426428
    427429
    428 UISnapshotPane::UISnapshotPane (QWidget *aParent)
    429     : QIWithRetranslateUI <QWidget> (aParent)
    430     , mCurSnapshotItem (0)
    431     , mEditProtector (false)
    432     , mSnapshotActionGroup (new QActionGroup (this))
    433     , mCurStateActionGroup (new QActionGroup (this))
    434     , mRestoreSnapshotAction (new QAction (mSnapshotActionGroup))
    435     , mDeleteSnapshotAction (new QAction (mSnapshotActionGroup))
    436     , mShowSnapshotDetailsAction (new QAction (mSnapshotActionGroup))
    437     , mTakeSnapshotAction (new QAction (mCurStateActionGroup))
    438     , mCloneSnapshotAction(new QAction(mCurStateActionGroup))
     430UISnapshotPane::UISnapshotPane(QWidget *pParent)
     431    : QIWithRetranslateUI<QWidget>(pParent)
     432    , m_pCurrentSnapshotItem(0)
     433    , m_fEditProtector(false)
     434    , m_pSnapshotItemActionGroup(new QActionGroup(this))
     435    , m_pCurrentStateItemActionGroup(new QActionGroup(this))
     436    , m_pActionRestoreSnapshot(new QAction(m_pSnapshotItemActionGroup))
     437    , m_pActionDeleteSnapshot(new QAction(m_pSnapshotItemActionGroup))
     438    , m_pActionShowSnapshotDetails(new QAction(m_pSnapshotItemActionGroup))
     439    , m_pActionTakeSnapshot(new QAction(m_pCurrentStateItemActionGroup))
     440    , m_pActionCloneSnapshot(new QAction(m_pCurrentStateItemActionGroup))
    439441    , m_fShapshotOperationsAllowed(false)
    440442{
    441443    /* Apply UI decorations: */
    442     Ui::UISnapshotPane::setupUi (this);
     444    Ui::UISnapshotPane::setupUi(this);
    443445
    444446    /* No header: */
    445     mTreeWidget->header()->hide();
     447    m_pTreeWidget->header()->hide();
    446448
    447449#if QT_VERSION < 0x050000
     
    455457    // draws required thing like we want. */
    456458// #if defined(RT_OS_DARWIN) || defined(RT_OS_LINUX) || defined(RT_OS_SOLARIS)
    457     QWindowsStyle *treeWidgetStyle = new QWindowsStyle;
    458     mTreeWidget->setStyle (treeWidgetStyle);
    459     connect (mTreeWidget, SIGNAL (destroyed (QObject *)), treeWidgetStyle, SLOT (deleteLater()));
     459    QWindowsStyle *pTreeWidgetStyle = new QWindowsStyle;
     460    m_pTreeWidget->setStyle(pTreeWidgetStyle);
     461    connect(m_pTreeWidget, SIGNAL(destroyed(QObject *)), pTreeWidgetStyle, SLOT(deleteLater()));
    460462// #endif
    461463#endif /* QT_VERSION < 0x050000 */
    462464
    463465    /* Cache pixmaps: */
    464     m_offlineSnapshotIcon = UIIconPool::iconSet(":/snapshot_offline_16px.png");
    465     m_onlineSnapshotIcon = UIIconPool::iconSet(":/snapshot_online_16px.png");
     466    m_snapshotIconOffline = UIIconPool::iconSet(":/snapshot_offline_16px.png");
     467    m_snapshotIconOnline = UIIconPool::iconSet(":/snapshot_online_16px.png");
    466468
    467469    /* Determine icon metric: */
     
    470472
    471473    /* Create tool-bar: */
    472     UIToolBar *toolBar = new UIToolBar (this);
    473     toolBar->setIconSize (QSize (iIconMetric, iIconMetric));
    474     toolBar->setSizePolicy (QSizePolicy::Fixed, QSizePolicy::Fixed);
     474    UIToolBar *pToolBar = new UIToolBar(this);
     475    pToolBar->setIconSize(QSize(iIconMetric, iIconMetric));
     476    pToolBar->setSizePolicy (QSizePolicy::Fixed, QSizePolicy::Fixed);
    475477    /* Add actions into tool-bar: */
    476     toolBar->addAction (mTakeSnapshotAction);
    477     toolBar->addSeparator();
    478     toolBar->addAction (mRestoreSnapshotAction);
    479     toolBar->addAction (mDeleteSnapshotAction);
    480     toolBar->addAction (mShowSnapshotDetailsAction);
    481     toolBar->addSeparator();
    482     toolBar->addAction(mCloneSnapshotAction);
     478    pToolBar->addAction(m_pActionTakeSnapshot);
     479    pToolBar->addSeparator();
     480    pToolBar->addAction(m_pActionRestoreSnapshot);
     481    pToolBar->addAction(m_pActionDeleteSnapshot);
     482    pToolBar->addAction(m_pActionShowSnapshotDetails);
     483    pToolBar->addSeparator();
     484    pToolBar->addAction(m_pActionCloneSnapshot);
    483485    /* Add tool-bar into layout: */
    484     ((QVBoxLayout*)layout())->insertWidget (0, toolBar);
     486    ((QVBoxLayout*)layout())->insertWidget(0, pToolBar);
    485487
    486488    /* Setup action icons: */
    487     mRestoreSnapshotAction->setIcon(UIIconPool::iconSetFull(
     489    m_pActionRestoreSnapshot->setIcon(UIIconPool::iconSetFull(
    488490        ":/snapshot_restore_22px.png", ":/snapshot_restore_16px.png",
    489491        ":/snapshot_restore_disabled_22px.png", ":/snapshot_restore_disabled_16px.png"));
    490     mDeleteSnapshotAction->setIcon(UIIconPool::iconSetFull(
     492    m_pActionDeleteSnapshot->setIcon(UIIconPool::iconSetFull(
    491493        ":/snapshot_delete_22px.png", ":/snapshot_delete_16px.png",
    492494        ":/snapshot_delete_disabled_22px.png", ":/snapshot_delete_disabled_16px.png"));
    493     mShowSnapshotDetailsAction->setIcon(UIIconPool::iconSetFull(
     495    m_pActionShowSnapshotDetails->setIcon(UIIconPool::iconSetFull(
    494496        ":/snapshot_show_details_22px.png", ":/snapshot_show_details_16px.png",
    495497        ":/snapshot_show_details_disabled_22px.png", ":/snapshot_details_show_disabled_16px.png"));
    496     mTakeSnapshotAction->setIcon(UIIconPool::iconSetFull(
     498    m_pActionTakeSnapshot->setIcon(UIIconPool::iconSetFull(
    497499        ":/snapshot_take_22px.png", ":/snapshot_take_16px.png",
    498500        ":/snapshot_take_disabled_22px.png", ":/snapshot_take_disabled_16px.png"));
    499     mCloneSnapshotAction->setIcon(UIIconPool::iconSetFull(
     501    m_pActionCloneSnapshot->setIcon(UIIconPool::iconSetFull(
    500502        ":/vm_clone_22px.png", ":/vm_clone_16px.png",
    501503        ":/vm_clone_disabled_22px.png", ":/vm_clone_disabled_16px.png"));
    502504    /* Setup action shortcuts: */
    503     mRestoreSnapshotAction->setShortcut (QString ("Ctrl+Shift+R"));
    504     mDeleteSnapshotAction->setShortcut (QString ("Ctrl+Shift+D"));
    505     mShowSnapshotDetailsAction->setShortcut (QString ("Ctrl+Space"));
    506     mTakeSnapshotAction->setShortcut (QString ("Ctrl+Shift+S"));
    507     mCloneSnapshotAction->setShortcut(QString ("Ctrl+Shift+C"));
     505    m_pActionRestoreSnapshot->setShortcut(QString("Ctrl+Shift+R"));
     506    m_pActionDeleteSnapshot->setShortcut(QString("Ctrl+Shift+D"));
     507    m_pActionShowSnapshotDetails->setShortcut(QString("Ctrl+Space"));
     508    m_pActionTakeSnapshot->setShortcut(QString("Ctrl+Shift+S"));
     509    m_pActionCloneSnapshot->setShortcut(QString("Ctrl+Shift+C"));
    508510
    509511    /* Setup timer: */
    510     mAgeUpdateTimer.setSingleShot (true);
     512    m_ageUpdateTimer.setSingleShot(true);
    511513
    512514    /* Setup tree-widget connections: */
    513     connect (mTreeWidget, SIGNAL (currentItemChanged (QTreeWidgetItem*, QTreeWidgetItem*)),
    514              this, SLOT (onCurrentChanged (QTreeWidgetItem*)));
    515     connect (mTreeWidget, SIGNAL (customContextMenuRequested (const QPoint&)),
    516              this, SLOT (onContextMenuRequested (const QPoint&)));
    517     connect (mTreeWidget, SIGNAL (itemChanged (QTreeWidgetItem*, int)),
    518              this, SLOT (onItemChanged (QTreeWidgetItem*)));
    519     connect(mTreeWidget, SIGNAL(itemDoubleClicked(QTreeWidgetItem*, int)),
    520             this, SLOT (sltItemDoubleClicked(QTreeWidgetItem*)));
     515    connect(m_pTreeWidget, SIGNAL(currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)),
     516            this, SLOT(sltCurrentItemChanged(QTreeWidgetItem *)));
     517    connect(m_pTreeWidget, SIGNAL(customContextMenuRequested(const QPoint &)),
     518            this, SLOT(sltContextMenuRequested(const QPoint &)));
     519    connect(m_pTreeWidget, SIGNAL(itemChanged(QTreeWidgetItem *, int)),
     520            this, SLOT(sltItemChanged(QTreeWidgetItem *)));
     521    connect(m_pTreeWidget, SIGNAL(itemDoubleClicked(QTreeWidgetItem *, int)),
     522            this, SLOT(sltItemDoubleClicked(QTreeWidgetItem *)));
    521523    /* Setup snapshot operation connections: */
    522     connect (mTakeSnapshotAction, SIGNAL (triggered()), this, SLOT (sltTakeSnapshot()));
    523     connect (mRestoreSnapshotAction, SIGNAL (triggered()), this, SLOT (sltRestoreSnapshot()));
    524     connect (mDeleteSnapshotAction, SIGNAL (triggered()), this, SLOT (sltDeleteSnapshot()));
    525     connect (mShowSnapshotDetailsAction, SIGNAL (triggered()), this, SLOT (sltShowSnapshotDetails()));
    526     connect (mCloneSnapshotAction, SIGNAL(triggered()), this, SLOT(sltCloneSnapshot()));
     524    connect(m_pActionTakeSnapshot, SIGNAL(triggered()), this, SLOT(sltTakeSnapshot()));
     525    connect(m_pActionRestoreSnapshot, SIGNAL(triggered()), this, SLOT(sltRestoreSnapshot()));
     526    connect(m_pActionDeleteSnapshot, SIGNAL(triggered()), this, SLOT(sltDeleteSnapshot()));
     527    connect(m_pActionShowSnapshotDetails, SIGNAL(triggered()), this, SLOT(sltShowSnapshotDetails()));
     528    connect(m_pActionCloneSnapshot, SIGNAL(triggered()), this, SLOT(sltCloneSnapshot()));
    527529    /* Setup Main event connections: */
    528     connect (gVBoxEvents, SIGNAL(sigMachineDataChange(QString)),
    529              this, SLOT(machineDataChanged(QString)));
    530     connect (gVBoxEvents, SIGNAL(sigMachineStateChange(QString, KMachineState)),
    531              this, SLOT(machineStateChanged(QString, KMachineState)));
    532     connect (gVBoxEvents, SIGNAL(sigSessionStateChange(QString, KSessionState)),
    533              this, SLOT(sessionStateChanged(QString, KSessionState)));
     530    connect(gVBoxEvents, SIGNAL(sigMachineDataChange(QString)),
     531            this, SLOT(sltMachineDataChange(QString)));
     532    connect(gVBoxEvents, SIGNAL(sigMachineStateChange(QString, KMachineState)),
     533            this, SLOT(sltMachineStateChange(QString, KMachineState)));
     534    connect(gVBoxEvents, SIGNAL(sigSessionStateChange(QString, KSessionState)),
     535            this, SLOT(sltSessionStateChange(QString, KSessionState)));
    534536    /* Setup timer event connections: */
    535     connect (&mAgeUpdateTimer, SIGNAL (timeout()), this, SLOT (updateSnapshotsAge()));
     537    connect(&m_ageUpdateTimer, SIGNAL(timeout()), this, SLOT(sltUpdateSnapshotsAge()));
    536538
    537539    /* Translate finally: */
     
    539541}
    540542
    541 void UISnapshotPane::setMachine (const CMachine &aMachine)
     543void UISnapshotPane::setMachine(const CMachine &comMachine)
    542544{
    543545    /* Cache passed machine: */
    544     mMachine = aMachine;
     546    m_comMachine = comMachine;
    545547
    546548    /* Cache machine details: */
    547     if (aMachine.isNull())
    548     {
    549         mMachineId = QString::null;
    550         mSessionState = KSessionState_Null;
     549    if (m_comMachine.isNull())
     550    {
     551        m_strMachineID = QString();
     552        m_enmSessionState = KSessionState_Null;
    551553        m_fShapshotOperationsAllowed = false;
    552554    }
    553555    else
    554556    {
    555         mMachineId = aMachine.GetId();
    556         mSessionState = aMachine.GetSessionState();
    557         m_fShapshotOperationsAllowed = gEDataManager->machineSnapshotOperationsEnabled(mMachineId);
     557        m_strMachineID = comMachine.GetId();
     558        m_enmSessionState = comMachine.GetSessionState();
     559        m_fShapshotOperationsAllowed = gEDataManager->machineSnapshotOperationsEnabled(m_strMachineID);
    558560    }
    559561
     
    568570
    569571    /* Translate actions names: */
    570     mRestoreSnapshotAction->setText(tr("&Restore Snapshot"));
    571     mDeleteSnapshotAction->setText(tr("&Delete Snapshot"));
    572     mShowSnapshotDetailsAction->setText(tr("S&how Details"));
    573     mTakeSnapshotAction->setText(tr("Take &Snapshot"));
    574     mCloneSnapshotAction->setText(tr("&Clone..."));
     572    m_pActionRestoreSnapshot->setText(tr("&Restore Snapshot"));
     573    m_pActionDeleteSnapshot->setText(tr("&Delete Snapshot"));
     574    m_pActionShowSnapshotDetails->setText(tr("S&how Details"));
     575    m_pActionTakeSnapshot->setText(tr("Take &Snapshot"));
     576    m_pActionCloneSnapshot->setText(tr("&Clone..."));
    575577    /* Translate actions status-tips: */
    576     mRestoreSnapshotAction->setStatusTip(tr("Restore selected snapshot of the virtual machine"));
    577     mDeleteSnapshotAction->setStatusTip(tr("Delete selected snapshot of the virtual machine"));
    578     mShowSnapshotDetailsAction->setStatusTip(tr("Display a window with selected snapshot details"));
    579     mTakeSnapshotAction->setStatusTip(tr("Take a snapshot of the current virtual machine state"));
    580     mCloneSnapshotAction->setStatusTip(tr("Clone selected virtual machine"));
     578    m_pActionRestoreSnapshot->setStatusTip(tr("Restore selected snapshot of the virtual machine"));
     579    m_pActionDeleteSnapshot->setStatusTip(tr("Delete selected snapshot of the virtual machine"));
     580    m_pActionShowSnapshotDetails->setStatusTip(tr("Display a window with selected snapshot details"));
     581    m_pActionTakeSnapshot->setStatusTip(tr("Take a snapshot of the current virtual machine state"));
     582    m_pActionCloneSnapshot->setStatusTip(tr("Clone selected virtual machine"));
    581583    /* Translate actions tool-tips: */
    582     mRestoreSnapshotAction->setToolTip(mRestoreSnapshotAction->statusTip() +
    583         QString(" (%1)").arg(mRestoreSnapshotAction->shortcut().toString()));
    584     mDeleteSnapshotAction->setToolTip(mDeleteSnapshotAction->statusTip() +
    585         QString(" (%1)").arg(mDeleteSnapshotAction->shortcut().toString()));
    586     mShowSnapshotDetailsAction->setToolTip(mShowSnapshotDetailsAction->statusTip() +
    587         QString(" (%1)").arg(mShowSnapshotDetailsAction->shortcut().toString()));
    588     mTakeSnapshotAction->setToolTip(mTakeSnapshotAction->statusTip() +
    589         QString(" (%1)").arg(mTakeSnapshotAction->shortcut().toString()));
    590     mCloneSnapshotAction->setToolTip(mCloneSnapshotAction->statusTip() +
    591         QString(" (%1)").arg(mCloneSnapshotAction->shortcut().toString()));
    592 }
    593 
    594 void UISnapshotPane::onCurrentChanged (QTreeWidgetItem *aItem)
    595 {
    596     /* Make the selected item visible */
    597     SnapshotWgtItem *item = aItem ? static_cast <SnapshotWgtItem*> (aItem) : 0;
    598     if (item)
    599     {
    600         mTreeWidget->horizontalScrollBar()->setValue (0);
    601         mTreeWidget->scrollToItem (item);
    602         mTreeWidget->horizontalScrollBar()->setValue (mTreeWidget->indentation() * item->level());
     584    m_pActionRestoreSnapshot->setToolTip(m_pActionRestoreSnapshot->statusTip() +
     585        QString(" (%1)").arg(m_pActionRestoreSnapshot->shortcut().toString()));
     586    m_pActionDeleteSnapshot->setToolTip(m_pActionDeleteSnapshot->statusTip() +
     587        QString(" (%1)").arg(m_pActionDeleteSnapshot->shortcut().toString()));
     588    m_pActionShowSnapshotDetails->setToolTip(m_pActionShowSnapshotDetails->statusTip() +
     589        QString(" (%1)").arg(m_pActionShowSnapshotDetails->shortcut().toString()));
     590    m_pActionTakeSnapshot->setToolTip(m_pActionTakeSnapshot->statusTip() +
     591        QString(" (%1)").arg(m_pActionTakeSnapshot->shortcut().toString()));
     592    m_pActionCloneSnapshot->setToolTip(m_pActionCloneSnapshot->statusTip() +
     593        QString(" (%1)").arg(m_pActionCloneSnapshot->shortcut().toString()));
     594}
     595
     596void UISnapshotPane::sltCurrentItemChanged(QTreeWidgetItem *pItem)
     597{
     598    /* Make the selected item visible: */
     599    const SnapshotWgtItem *pSnapshotItem = pItem ? static_cast<const SnapshotWgtItem*>(pItem) : 0;
     600    if (pSnapshotItem)
     601    {
     602        m_pTreeWidget->horizontalScrollBar()->setValue(0);
     603        m_pTreeWidget->scrollToItem(pSnapshotItem);
     604        m_pTreeWidget->horizontalScrollBar()->setValue(m_pTreeWidget->indentation() * pSnapshotItem->level());
    603605    }
    604606
    605607    /* Whether another direct session is open or not: */
    606     bool busy = mSessionState != KSessionState_Unlocked;
     608    const bool fBusy = m_enmSessionState != KSessionState_Unlocked;
    607609
    608610    /* Acquire machine state of the "current state" item: */
    609     KMachineState s = KMachineState_Null;
    610     if (curStateItem())
    611         s = curStateItem()->getCurrentState();
     611    KMachineState enmState = KMachineState_Null;
     612    if (currentStateItem())
     613        enmState = currentStateItem()->getCurrentState();
    612614
    613615    /* Whether taking or deleting snapshots is possible right now: */
    614     bool canTakeDeleteSnapshot =    !busy
    615                                  || s == KMachineState_PoweredOff
    616                                  || s == KMachineState_Saved
    617                                  || s == KMachineState_Aborted
    618                                  || s == KMachineState_Running
    619                                  || s == KMachineState_Paused;
     616    const bool canTakeDeleteSnapshot =    !fBusy
     617                                       || enmState == KMachineState_PoweredOff
     618                                       || enmState == KMachineState_Saved
     619                                       || enmState == KMachineState_Aborted
     620                                       || enmState == KMachineState_Running
     621                                       || enmState == KMachineState_Paused;
    620622
    621623    /* Enable/disable snapshot operations: */
    622     mRestoreSnapshotAction->setEnabled (!busy && mCurSnapshotItem && item && !item->isCurrentStateItem());
    623     mDeleteSnapshotAction->setEnabled (m_fShapshotOperationsAllowed &&
    624                                        canTakeDeleteSnapshot && mCurSnapshotItem && item && !item->isCurrentStateItem());
    625     mShowSnapshotDetailsAction->setEnabled (mCurSnapshotItem && item && !item->isCurrentStateItem());
    626     mTakeSnapshotAction->setEnabled (m_fShapshotOperationsAllowed &&
    627                                      ((canTakeDeleteSnapshot && mCurSnapshotItem && item && item->isCurrentStateItem()) ||
    628                                       (item && !mCurSnapshotItem)));
    629     mCloneSnapshotAction->setEnabled(!busy && item);
    630 }
    631 
    632 void UISnapshotPane::onContextMenuRequested (const QPoint &aPoint)
     624    m_pActionRestoreSnapshot->setEnabled(!fBusy && m_pCurrentSnapshotItem && pSnapshotItem && !pSnapshotItem->isCurrentStateItem());
     625    m_pActionDeleteSnapshot->setEnabled(m_fShapshotOperationsAllowed &&
     626                                        canTakeDeleteSnapshot && m_pCurrentSnapshotItem && pSnapshotItem && !pSnapshotItem->isCurrentStateItem());
     627    m_pActionShowSnapshotDetails->setEnabled(m_pCurrentSnapshotItem && pSnapshotItem && !pSnapshotItem->isCurrentStateItem());
     628    m_pActionTakeSnapshot->setEnabled(m_fShapshotOperationsAllowed &&
     629                                      ((canTakeDeleteSnapshot && m_pCurrentSnapshotItem && pSnapshotItem && pSnapshotItem->isCurrentStateItem()) ||
     630                                      (pSnapshotItem && !m_pCurrentSnapshotItem)));
     631    m_pActionCloneSnapshot->setEnabled(!fBusy && pSnapshotItem);
     632}
     633
     634void UISnapshotPane::sltContextMenuRequested(const QPoint &point)
    633635{
    634636    /* Search for corresponding snapshot item: */
    635     QTreeWidgetItem *item = mTreeWidget->itemAt (aPoint);
    636     SnapshotWgtItem *snapshotItem = item ? static_cast <SnapshotWgtItem*> (item) : 0;
    637     if (!snapshotItem)
     637    const QTreeWidgetItem *pItem = m_pTreeWidget->itemAt(point);
     638    const SnapshotWgtItem *pSnapshotItem = pItem ? static_cast<const SnapshotWgtItem*>(pItem) : 0;
     639    if (!pSnapshotItem)
    638640        return;
    639641
     
    641643    QMenu menu;
    642644    /* For snapshot item: */
    643     if (mCurSnapshotItem && !snapshotItem->isCurrentStateItem())
    644     {
    645         menu.addAction (mRestoreSnapshotAction);
    646         menu.addAction (mDeleteSnapshotAction);
    647         menu.addAction (mShowSnapshotDetailsAction);
     645    if (m_pCurrentSnapshotItem && !pSnapshotItem->isCurrentStateItem())
     646    {
     647        menu.addAction(m_pActionRestoreSnapshot);
     648        menu.addAction(m_pActionDeleteSnapshot);
     649        menu.addAction(m_pActionShowSnapshotDetails);
    648650        menu.addSeparator();
    649         menu.addAction(mCloneSnapshotAction);
     651        menu.addAction(m_pActionCloneSnapshot);
    650652    }
    651653    /* For "current state" item: */
    652654    else
    653655    {
    654         menu.addAction (mTakeSnapshotAction);
     656        menu.addAction(m_pActionTakeSnapshot);
    655657        menu.addSeparator();
    656         menu.addAction(mCloneSnapshotAction);
     658        menu.addAction(m_pActionCloneSnapshot);
    657659    }
    658660
    659661    /* Show menu: */
    660     menu.exec (mTreeWidget->viewport()->mapToGlobal (aPoint));
    661 }
    662 
    663 void UISnapshotPane::onItemChanged (QTreeWidgetItem *aItem)
     662    menu.exec(m_pTreeWidget->viewport()->mapToGlobal(point));
     663}
     664
     665void UISnapshotPane::sltItemChanged(QTreeWidgetItem *pItem)
    664666{
    665667    /* Make sure nothing is being edited currently: */
    666     if (mEditProtector)
     668    if (m_fEditProtector)
    667669        return;
    668670
    669671    /* Make sure snapshot item was changed: */
    670     SnapshotWgtItem *item = aItem ? static_cast <SnapshotWgtItem*> (aItem) : 0;
    671 
    672     if (item)
     672    const SnapshotWgtItem *pSnapshotItem = pItem ? static_cast<const SnapshotWgtItem*>(pItem) : 0;
     673
     674    if (pSnapshotItem)
    673675    {
    674676        /* Rename corresponding snapshot: */
    675         CSnapshot snap = item->snapshotId().isNull()    ? CSnapshot() : mMachine.FindSnapshot(item->snapshotId());
    676         if (!snap.isNull() && snap.isOk() && snap.GetName() != item->text (0))
    677             snap.SetName (item->text (0));
     677        CSnapshot comSnapshot = pSnapshotItem->snapshotID().isNull() ? CSnapshot() : m_comMachine.FindSnapshot(pSnapshotItem->snapshotID());
     678        if (!comSnapshot.isNull() && comSnapshot.isOk() && comSnapshot.GetName() != pSnapshotItem->text(0))
     679            comSnapshot.SetName(pSnapshotItem->text(0));
    678680    }
    679681}
     
    682684{
    683685    /* Make sure nothing is being edited currently: */
    684     if (mEditProtector)
     686    if (m_fEditProtector)
    685687        return;
    686688
    687689    /* Make sure snapshot item was double-clicked: */
    688     SnapshotWgtItem *pValidItem = pItem ? static_cast<SnapshotWgtItem*>(pItem) : 0;
    689     if (!pValidItem)
     690    const SnapshotWgtItem *pSnapshotItem = pItem ? static_cast<const SnapshotWgtItem*>(pItem) : 0;
     691    if (!pSnapshotItem)
    690692        return;
    691693
     
    703705}
    704706
    705 void UISnapshotPane::sltRestoreSnapshot(bool fSuppressNonCriticalWarnings /* = false*/)
     707void UISnapshotPane::sltRestoreSnapshot(bool fSuppressNonCriticalWarnings /* = false */)
    706708{
    707709    /* Get currently chosen item: */
    708     SnapshotWgtItem *pItem = mTreeWidget->currentItem() ? static_cast<SnapshotWgtItem*>(mTreeWidget->currentItem()) : 0;
    709     AssertReturn(pItem, (void)0);
     710    const SnapshotWgtItem *pSnapshotItem = m_pTreeWidget->currentItem() ? static_cast<const SnapshotWgtItem*>(m_pTreeWidget->currentItem()) : 0;
     711    AssertReturnVoid(pSnapshotItem);
    710712
    711713    /* Detemine snapshot id: */
    712     QString strSnapshotId = pItem->snapshotId();
    713     AssertReturn(!strSnapshotId.isNull(), (void)0);
     714    const QString strSnapshotID = pSnapshotItem->snapshotID();
     715    AssertReturnVoid(!strSnapshotID.isNull());
    714716    /* Get currently desired snapshot: */
    715     CSnapshot snapshot = mMachine.FindSnapshot(strSnapshotId);
     717    const CSnapshot comSnapshot = m_comMachine.FindSnapshot(strSnapshotID);
    716718
    717719    /* Ask the user if he really wants to restore the snapshot: */
    718720    int iResultCode = AlertButton_Ok;
    719     if (!fSuppressNonCriticalWarnings || mMachine.GetCurrentStateModified())
    720     {
    721         iResultCode = msgCenter().confirmSnapshotRestoring(snapshot.GetName(), mMachine.GetCurrentStateModified());
     721    if (!fSuppressNonCriticalWarnings || m_comMachine.GetCurrentStateModified())
     722    {
     723        iResultCode = msgCenter().confirmSnapshotRestoring(comSnapshot.GetName(), m_comMachine.GetCurrentStateModified());
    722724        if (iResultCode & AlertButton_Cancel)
    723725            return;
     
    728730    {
    729731        /* Take snapshot of changed current state: */
    730         mTreeWidget->setCurrentItem(curStateItem());
     732        m_pTreeWidget->setCurrentItem(currentStateItem());
    731733        if (!takeSnapshot())
    732734            return;
     
    734736
    735737    /* Open a direct session (this call will handle all errors): */
    736     CSession session = vboxGlobal().openSession(mMachineId);
    737     if (session.isNull())
     738    CSession comSession = vboxGlobal().openSession(m_strMachineID);
     739    if (comSession.isNull())
    738740        return;
    739741
    740742    /* Restore chosen snapshot: */
    741     CMachine machine = session.GetMachine();
    742     CProgress progress = machine.RestoreSnapshot(snapshot);
    743     if (machine.isOk())
    744     {
    745         msgCenter().showModalProgressDialog(progress, mMachine.GetName(), ":/progress_snapshot_restore_90px.png");
    746         if (progress.GetResultCode() != 0)
    747             msgCenter().cannotRestoreSnapshot(progress, snapshot.GetName(), mMachine.GetName());
     743    CMachine comMachine = comSession.GetMachine();
     744    CProgress comProgress = comMachine.RestoreSnapshot(comSnapshot);
     745    if (comMachine.isOk())
     746    {
     747        msgCenter().showModalProgressDialog(comProgress, m_comMachine.GetName(), ":/progress_snapshot_restore_90px.png");
     748        if (comProgress.GetResultCode() != 0)
     749            msgCenter().cannotRestoreSnapshot(comProgress, comSnapshot.GetName(), m_comMachine.GetName());
    748750    }
    749751    else
    750         msgCenter().cannotRestoreSnapshot(machine, snapshot.GetName(), mMachine.GetName());
     752        msgCenter().cannotRestoreSnapshot(comMachine, comSnapshot.GetName(), m_comMachine.GetName());
    751753
    752754    /* Unlock machine finally: */
    753     session.UnlockMachine();
     755    comSession.UnlockMachine();
    754756}
    755757
     
    757759{
    758760    /* Get currently chosen item: */
    759     SnapshotWgtItem *item = !mTreeWidget->currentItem() ? 0 :
    760         static_cast <SnapshotWgtItem*> (mTreeWidget->currentItem());
    761     AssertReturn (item, (void) 0);
     761    const SnapshotWgtItem *pSnapshotItem = !m_pTreeWidget->currentItem() ? 0 :
     762        static_cast<const SnapshotWgtItem*>(m_pTreeWidget->currentItem());
     763    AssertReturnVoid(pSnapshotItem);
    762764
    763765    /* Detemine snapshot id: */
    764     QString snapId = item->snapshotId();
    765     AssertReturn (!snapId.isNull(), (void) 0);
     766    const QString strSnapshotID = pSnapshotItem->snapshotID();
     767    AssertReturnVoid(!strSnapshotID.isNull());
    766768    /* Get currently desired snapshot: */
    767     CSnapshot snapshot = mMachine.FindSnapshot(snapId);
     769    const CSnapshot comSnapshot = m_comMachine.FindSnapshot(strSnapshotID);
    768770
    769771    /* Confirm snapshot removal: */
    770     if (!msgCenter().confirmSnapshotRemoval(snapshot.GetName()))
     772    if (!msgCenter().confirmSnapshotRemoval(comSnapshot.GetName()))
    771773        return;
    772774
    773775    /** @todo check available space on the target filesystem etc etc. */
    774776#if 0
    775     if (!msgCenter().warnAboutSnapshotRemovalFreeSpace(snapshot.GetName(),
     777    if (!msgCenter().warnAboutSnapshotRemovalFreeSpace(comSnapshot.GetName(),
    776778                                                       "/home/juser/.VirtualBox/Machines/SampleVM/Snapshots/{01020304-0102-0102-0102-010203040506}.vdi",
    777779                                                       "59 GiB",
     
    781783
    782784    /* Open a session (this call will handle all errors): */
    783     bool busy = mSessionState != KSessionState_Unlocked;
    784     CSession session;
    785     if (busy)
    786         session = vboxGlobal().openExistingSession(mMachineId);
     785    bool fBusy = m_enmSessionState != KSessionState_Unlocked;
     786    CSession comSession;
     787    if (fBusy)
     788        comSession = vboxGlobal().openExistingSession(m_strMachineID);
    787789    else
    788         session = vboxGlobal().openSession(mMachineId);
    789     if (session.isNull())
     790        comSession = vboxGlobal().openSession(m_strMachineID);
     791    if (comSession.isNull())
    790792        return;
    791793
    792794    /* Remove chosen snapshot: */
    793     CMachine machine = session.GetMachine();
    794     CProgress progress = machine.DeleteSnapshot(snapId);
    795     if (machine.isOk())
    796     {
    797         msgCenter().showModalProgressDialog(progress, mMachine.GetName(), ":/progress_snapshot_discard_90px.png");
    798         if (progress.GetResultCode() != 0)
    799             msgCenter().cannotRemoveSnapshot(progress,  snapshot.GetName(), mMachine.GetName());
     795    CMachine comMachine = comSession.GetMachine();
     796    CProgress comProgress = comMachine.DeleteSnapshot(strSnapshotID);
     797    if (comMachine.isOk())
     798    {
     799        msgCenter().showModalProgressDialog(comProgress, m_comMachine.GetName(), ":/progress_snapshot_discard_90px.png");
     800        if (comProgress.GetResultCode() != 0)
     801            msgCenter().cannotRemoveSnapshot(comProgress,  comSnapshot.GetName(), m_comMachine.GetName());
    800802    }
    801803    else
    802         msgCenter().cannotRemoveSnapshot(machine,  snapshot.GetName(), mMachine.GetName());
     804        msgCenter().cannotRemoveSnapshot(comMachine,  comSnapshot.GetName(), m_comMachine.GetName());
    803805
    804806    /* Unlock machine finally: */
    805     session.UnlockMachine();
     807    comSession.UnlockMachine();
    806808}
    807809
     
    809811{
    810812    /* Get currently chosen item: */
    811     SnapshotWgtItem *item = !mTreeWidget->currentItem() ? 0 :
    812         static_cast <SnapshotWgtItem*> (mTreeWidget->currentItem());
    813     AssertReturn (item, (void) 0);
     813    const SnapshotWgtItem *pSnapshotItem = !m_pTreeWidget->currentItem() ? 0 :
     814        static_cast<const SnapshotWgtItem*>(m_pTreeWidget->currentItem());
     815    AssertReturnVoid(pSnapshotItem);
    814816
    815817    /* Get desired snapshot: */
    816     CSnapshot snap = item->snapshot();
    817     AssertReturn (!snap.isNull(), (void) 0);
    818 
    819     CMachine snapMachine = snap.GetMachine();
     818    const CSnapshot comSnapshot = pSnapshotItem->snapshot();
     819    AssertReturnVoid(!comSnapshot.isNull());
     820
     821    // WTF?
     822    CMachine comMachine = comSnapshot.GetMachine();
    820823
    821824    /* Show Snapshot Details dialog: */
    822     VBoxSnapshotDetailsDlg dlg (this);
    823     dlg.getFromSnapshot (snap);
    824 
    825     if (dlg.exec() == QDialog::Accepted)
    826         dlg.putBackToSnapshot();
     825    VBoxSnapshotDetailsDlg pDlg(this);
     826    pDlg.getFromSnapshot(comSnapshot);
     827
     828    if (pDlg.exec() == QDialog::Accepted)
     829        pDlg.putBackToSnapshot();
    827830}
    828831
     
    830833{
    831834    /* Get currently chosen item: */
    832     SnapshotWgtItem *item = !mTreeWidget->currentItem() ? 0 :
    833         static_cast <SnapshotWgtItem*> (mTreeWidget->currentItem());
    834     AssertReturn (item, (void) 0);
     835    const SnapshotWgtItem *pSnapshotItem = !m_pTreeWidget->currentItem() ? 0 :
     836        static_cast<const SnapshotWgtItem*>(m_pTreeWidget->currentItem());
     837    AssertReturnVoid(pSnapshotItem);
    835838
    836839    /* Get desired machine/snapshot: */
    837     CMachine machine;
    838     CSnapshot snapshot;
    839     if (item->isCurrentStateItem())
    840         machine = item->machine();
     840    CMachine comMachine;
     841    CSnapshot comSnapshot;
     842    if (pSnapshotItem->isCurrentStateItem())
     843        comMachine = pSnapshotItem->machine();
    841844    else
    842845    {
    843         snapshot = item->snapshot();
    844         AssertReturn(!snapshot.isNull(), (void)0);
    845         machine = snapshot.GetMachine();
    846     }
    847     AssertReturn(!machine.isNull(), (void)0);
     846        comSnapshot = pSnapshotItem->snapshot();
     847        AssertReturnVoid(!comSnapshot.isNull());
     848        comMachine = comSnapshot.GetMachine();
     849    }
     850    AssertReturnVoid(!comMachine.isNull());
    848851
    849852    /* Show Clone VM wizard: */
    850     UISafePointerWizard pWizard = new UIWizardCloneVM(this, machine, snapshot);
     853    UISafePointerWizard pWizard = new UIWizardCloneVM(this, comMachine, comSnapshot);
    851854    pWizard->prepare();
    852855    pWizard->exec();
     
    855858}
    856859
    857 void UISnapshotPane::machineDataChanged(QString strId)
     860void UISnapshotPane::sltMachineDataChange(QString strMachineID)
    858861{
    859862    /* Prevent snapshot editing in the meantime: */
    860     SnapshotEditBlocker guardBlock (mEditProtector);
     863    SnapshotEditBlocker guardBlock(m_fEditProtector);
    861864
    862865    /* Make sure it's our VM: */
    863     if (strId != mMachineId)
     866    if (strMachineID != m_strMachineID)
    864867        return;
    865868
    866869    /* Recache state current item: */
    867     curStateItem()->recache();
    868 }
    869 
    870 void UISnapshotPane::machineStateChanged(QString strId, KMachineState state)
     870    currentStateItem()->recache();
     871}
     872
     873void UISnapshotPane::sltMachineStateChange(QString strMachineID, KMachineState enmState)
    871874{
    872875    /* Prevent snapshot editing in the meantime: */
    873     SnapshotEditBlocker guardBlock (mEditProtector);
     876    SnapshotEditBlocker guardBlock(m_fEditProtector);
    874877
    875878    /* Make sure it's our VM: */
    876     if (strId != mMachineId)
     879    if (strMachineID != m_strMachineID)
    877880        return;
    878881
    879882    /* Recache new machine state: */
    880     curStateItem()->recache();
    881     curStateItem()->updateCurrentState(state);
    882 }
    883 
    884 void UISnapshotPane::sessionStateChanged(QString strId, KSessionState state)
     883    currentStateItem()->recache();
     884    currentStateItem()->updateCurrentState(enmState);
     885}
     886
     887void UISnapshotPane::sltSessionStateChange(QString strMachineID, KSessionState enmState)
    885888{
    886889    /* Prevent snapshot editing in the meantime: */
    887     SnapshotEditBlocker guardBlock (mEditProtector);
     890    SnapshotEditBlocker guardBlock(m_fEditProtector);
    888891
    889892    /* Make sure it's our VM: */
    890     if (strId != mMachineId)
     893    if (strMachineID != m_strMachineID)
    891894        return;
    892895
    893896    /* Recache new session state: */
    894     mSessionState = state;
    895     onCurrentChanged (mTreeWidget->currentItem());
    896 }
    897 
    898 void UISnapshotPane::updateSnapshotsAge()
     897    m_enmSessionState = enmState;
     898    sltCurrentItemChanged(m_pTreeWidget->currentItem());
     899}
     900
     901void UISnapshotPane::sltUpdateSnapshotsAge()
    899902{
    900903    /* Stop timer if active: */
    901     if (mAgeUpdateTimer.isActive())
    902         mAgeUpdateTimer.stop();
     904    if (m_ageUpdateTimer.isActive())
     905        m_ageUpdateTimer.stop();
    903906
    904907    /* Search for smallest snapshot age to optimize timer timeout: */
    905     SnapshotAgeFormat age = traverseSnapshotAge (mTreeWidget->invisibleRootItem());
     908    const SnapshotAgeFormat age = traverseSnapshotAge(m_pTreeWidget->invisibleRootItem());
    906909    switch (age)
    907910    {
    908         case AgeInSeconds:
    909             mAgeUpdateTimer.setInterval (5 * 1000);
     911        case SnapshotAgeFormat_InSeconds:
     912            m_ageUpdateTimer.setInterval(5 * 1000);
    910913            break;
    911         case AgeInMinutes:
    912             mAgeUpdateTimer.setInterval (60 * 1000);
     914        case SnapshotAgeFormat_InMinutes:
     915            m_ageUpdateTimer.setInterval(60 * 1000);
    913916            break;
    914         case AgeInHours:
    915             mAgeUpdateTimer.setInterval (60 * 60 * 1000);
     917        case SnapshotAgeFormat_InHours:
     918            m_ageUpdateTimer.setInterval(60 * 60 * 1000);
    916919            break;
    917         case AgeInDays:
    918             mAgeUpdateTimer.setInterval (24 * 60 * 60 * 1000);
     920        case SnapshotAgeFormat_InDays:
     921            m_ageUpdateTimer.setInterval(24 * 60 * 60 * 1000);
    919922            break;
    920923        default:
    921             mAgeUpdateTimer.setInterval (0);
     924            m_ageUpdateTimer.setInterval(0);
    922925            break;
    923926    }
    924927
    925928    /* Restart timer if necessary: */
    926     if (mAgeUpdateTimer.interval() > 0)
    927         mAgeUpdateTimer.start();
     929    if (m_ageUpdateTimer.interval() > 0)
     930        m_ageUpdateTimer.start();
    928931}
    929932
     
    933936    bool fIsValid = true;
    934937
    935     /* Get currently chosen item: */
    936     SnapshotWgtItem *pItem = mTreeWidget->currentItem() ? static_cast<SnapshotWgtItem*>(mTreeWidget->currentItem()) : 0;
    937     AssertReturn(pItem, (bool)0);
     938    // WTF?
     939    const SnapshotWgtItem *pSnapshotItem = m_pTreeWidget->currentItem() ? static_cast<const SnapshotWgtItem*>(m_pTreeWidget->currentItem()) : 0;
     940    AssertReturn(pSnapshotItem, (bool)0);
    938941
    939942    /* Open a session (this call will handle all errors): */
    940     CSession session;
    941     if (mSessionState != KSessionState_Unlocked)
    942         session = vboxGlobal().openExistingSession(mMachineId);
     943    CSession comSession;
     944    if (m_enmSessionState != KSessionState_Unlocked)
     945        comSession = vboxGlobal().openExistingSession(m_strMachineID);
    943946    else
    944         session = vboxGlobal().openSession(mMachineId);
    945     fIsValid = !session.isNull();
     947        comSession = vboxGlobal().openSession(m_strMachineID);
     948    fIsValid = !comSession.isNull();
    946949
    947950    if (fIsValid)
    948951    {
    949952        /* Get corresponding machine object also: */
    950         CMachine machine = session.GetMachine();
     953        CMachine comMachine = comSession.GetMachine();
    951954
    952955        /* Create take-snapshot dialog: */
    953956        QWidget *pDlgParent = windowManager().realParentWindow(this);
    954         QPointer<VBoxTakeSnapshotDlg> pDlg = new VBoxTakeSnapshotDlg(pDlgParent, mMachine);
     957        QPointer<VBoxTakeSnapshotDlg> pDlg = new VBoxTakeSnapshotDlg(pDlgParent, m_comMachine);
    955958        windowManager().registerNewParent(pDlg, pDlgParent);
    956959
    957960        // TODO: Assign corresponding icon through sub-dialog API: */
    958         pDlg->mLbIcon->setPixmap(vboxGlobal().vmGuestOSTypeIcon(mMachine.GetOSTypeId()));
     961        pDlg->mLbIcon->setPixmap(vboxGlobal().vmGuestOSTypeIcon(m_comMachine.GetOSTypeId()));
    959962
    960963        /* Search for the max available snapshot index: */
    961964        int iMaxSnapShotIndex = 0;
    962         QString snapShotName = tr("Snapshot %1");
    963         QRegExp regExp(QString("^") + snapShotName.arg("([0-9]+)") + QString("$"));
    964         QTreeWidgetItemIterator iterator(mTreeWidget);
     965        QString strSnapshotName = tr("Snapshot %1");
     966        QRegExp regExp(QString("^") + strSnapshotName.arg("([0-9]+)") + QString("$"));
     967        QTreeWidgetItemIterator iterator(m_pTreeWidget);
    965968        while (*iterator)
    966969        {
    967             QString snapShot = static_cast<SnapshotWgtItem*>(*iterator)->text(0);
    968             int pos = regExp.indexIn(snapShot);
    969             if (pos != -1)
     970            QString strSnapshot = static_cast<SnapshotWgtItem*>(*iterator)->text(0);
     971            int iPos = regExp.indexIn(strSnapshot);
     972            if (iPos != -1)
    970973                iMaxSnapShotIndex = regExp.cap(1).toInt() > iMaxSnapShotIndex ? regExp.cap(1).toInt() : iMaxSnapShotIndex;
    971974            ++iterator;
    972975        }
    973976        // TODO: Assign corresponding snapshot name through sub-dialog API: */
    974         pDlg->mLeName->setText(snapShotName.arg(iMaxSnapShotIndex + 1));
     977        pDlg->mLeName->setText(strSnapshotName.arg(iMaxSnapShotIndex + 1));
    975978
    976979        /* Show Take Snapshot dialog: */
     
    981984        {
    982985            /* Acquire snapshot name/description: */
    983             QString strSnapshotName = pDlg->mLeName->text().trimmed();
    984             QString strSnapshotDescription = pDlg->mTeDescription->toPlainText();
     986            const QString strSnapshotName = pDlg->mLeName->text().trimmed();
     987            const QString strSnapshotDescription = pDlg->mTeDescription->toPlainText();
    985988
    986989            /* Destroy dialog early: */
     
    991994            {
    992995                /* Take snapshot: */
    993                 QString strSnapshotId;
    994                 CProgress progress = machine.TakeSnapshot(strSnapshotName, strSnapshotDescription, true, strSnapshotId);
    995                 if (machine.isOk())
     996                QString strSnapshotID;
     997                CProgress comProgress = comMachine.TakeSnapshot(strSnapshotName, strSnapshotDescription, true, strSnapshotID);
     998                if (comMachine.isOk())
    996999                {
    997                     msgCenter().showModalProgressDialog(progress, mMachine.GetName(), ":/progress_snapshot_create_90px.png");
    998                     if (!progress.isOk() || progress.GetResultCode() != 0)
     1000                    msgCenter().showModalProgressDialog(comProgress, m_comMachine.GetName(), ":/progress_snapshot_create_90px.png");
     1001                    if (!comProgress.isOk() || comProgress.GetResultCode() != 0)
    9991002                    {
    1000                         msgCenter().cannotTakeSnapshot(progress, mMachine.GetName());
     1003                        msgCenter().cannotTakeSnapshot(comProgress, m_comMachine.GetName());
    10011004                        fIsValid = false;
    10021005                    }
     
    10041007                else
    10051008                {
    1006                     msgCenter().cannotTakeSnapshot(machine, mMachine.GetName());
     1009                    msgCenter().cannotTakeSnapshot(comMachine, m_comMachine.GetName());
    10071010                    fIsValid = false;
    10081011                }
     
    10151018
    10161019        /* Unlock machine finally: */
    1017         session.UnlockMachine();
     1020        comSession.UnlockMachine();
    10181021    }
    10191022
     
    10251028{
    10261029    /* Prevent snapshot editing in the meantime: */
    1027     SnapshotEditBlocker guardBlock (mEditProtector);
     1030    SnapshotEditBlocker guardBlock(m_fEditProtector);
    10281031
    10291032    /* If VM is null, just updated the current itm: */
    1030     if (mMachine.isNull())
    1031     {
    1032         onCurrentChanged();
     1033    if (m_comMachine.isNull())
     1034    {
     1035        sltCurrentItemChanged();
    10331036        return;
    10341037    }
    10351038
    10361039    /* Remember the selected item and it's first child: */
    1037     QString selectedItem, firstChildOfSelectedItem;
    1038     SnapshotWgtItem *cur = !mTreeWidget->currentItem() ? 0 :
    1039         static_cast <SnapshotWgtItem*> (mTreeWidget->currentItem());
    1040     if (cur)
    1041     {
    1042         selectedItem = cur->snapshotId();
    1043         if (cur->child (0))
    1044             firstChildOfSelectedItem = static_cast <SnapshotWgtItem*> (cur->child (0))->snapshotId();
     1040    QString strSelectedItem, strFirstChildOfSelectedItem;
     1041    const SnapshotWgtItem *pSnapshotItem = !m_pTreeWidget->currentItem() ? 0 :
     1042        static_cast<const SnapshotWgtItem*>(m_pTreeWidget->currentItem());
     1043    if (pSnapshotItem)
     1044    {
     1045        strSelectedItem = pSnapshotItem->snapshotID();
     1046        if (pSnapshotItem->child(0))
     1047            strFirstChildOfSelectedItem = static_cast<const SnapshotWgtItem*>(pSnapshotItem->child(0))->snapshotID();
    10451048    }
    10461049
    10471050    /* Clear the tree: */
    1048     mTreeWidget->clear();
     1051    m_pTreeWidget->clear();
    10491052
    10501053    /* If machine has snapshots: */
    1051     if (mMachine.GetSnapshotCount() > 0)
     1054    if (m_comMachine.GetSnapshotCount() > 0)
    10521055    {
    10531056        /* Get the first snapshot: */
    1054         CSnapshot snapshot = mMachine.FindSnapshot(QString::null);
     1057        const CSnapshot comSnapshot = m_comMachine.FindSnapshot(QString());
    10551058
    10561059        /* Populate snapshot tree: */
    1057         populateSnapshots (snapshot, 0);
     1060        populateSnapshots(comSnapshot, 0);
    10581061        /* And make sure it has current snapshot item: */
    1059         Assert (mCurSnapshotItem);
     1062        Assert(m_pCurrentSnapshotItem);
    10601063
    10611064        /* Add the "current state" item as a child to current snapshot item: */
    1062         SnapshotWgtItem *csi = new SnapshotWgtItem(this, mCurSnapshotItem, mMachine);
    1063         csi->setBold (true);
    1064         csi->recache();
     1065        SnapshotWgtItem *pCsi = new SnapshotWgtItem(this, m_pCurrentSnapshotItem, m_comMachine);
     1066        pCsi->setBold(true);
     1067        pCsi->recache();
    10651068
    10661069        /* Search for a previously selected item: */
    1067         SnapshotWgtItem *cur = findItem (selectedItem);
    1068         if (cur == 0)
    1069             cur = findItem (firstChildOfSelectedItem);
    1070         if (cur == 0)
    1071             cur = curStateItem();
     1070        SnapshotWgtItem *pCurrentItem = findItem(strSelectedItem);
     1071        if (pCurrentItem == 0)
     1072            pCurrentItem = findItem(strFirstChildOfSelectedItem);
     1073        if (pCurrentItem == 0)
     1074            pCurrentItem = currentStateItem();
    10721075
    10731076        /* Choose current item: */
    1074         mTreeWidget->scrollToItem (cur);
    1075         mTreeWidget->setCurrentItem (cur);
    1076         onCurrentChanged (cur);
     1077        m_pTreeWidget->scrollToItem(pCurrentItem);
     1078        m_pTreeWidget->setCurrentItem(pCurrentItem);
     1079        sltCurrentItemChanged(pCurrentItem);
    10771080    }
    10781081    /* If machine has no snapshots: */
     
    10801083    {
    10811084        /* There is no current snapshot item: */
    1082         mCurSnapshotItem = 0;
     1085        m_pCurrentSnapshotItem = 0;
    10831086
    10841087        /* Add the "current state" item as a child of tree-widget: */
    1085         SnapshotWgtItem *csi = new SnapshotWgtItem(this, mTreeWidget, mMachine);
    1086         csi->setBold (true);
    1087         csi->recache();
     1088        SnapshotWgtItem *pCsi = new SnapshotWgtItem(this, m_pTreeWidget, m_comMachine);
     1089        pCsi->setBold(true);
     1090        pCsi->recache();
    10881091
    10891092        /* Choose current item: */
    1090         mTreeWidget->setCurrentItem (csi);
    1091         onCurrentChanged (csi);
     1093        m_pTreeWidget->setCurrentItem(pCsi);
     1094        sltCurrentItemChanged(pCsi);
    10921095    }
    10931096
    10941097    /* Update age: */
    1095     updateSnapshotsAge();
     1098    sltUpdateSnapshotsAge();
    10961099
    10971100    /* Adjust tree-widget: */
    1098     mTreeWidget->resizeColumnToContents (0);
    1099 }
    1100 
    1101 SnapshotWgtItem* UISnapshotPane::findItem (const QString &aSnapshotId)
     1101    m_pTreeWidget->resizeColumnToContents(0);
     1102}
     1103
     1104SnapshotWgtItem *UISnapshotPane::findItem(const QString &strSnapshotID) const
    11021105{
    11031106    /* Search for the first item with required ID: */
    1104     QTreeWidgetItemIterator it (mTreeWidget);
     1107    QTreeWidgetItemIterator it(m_pTreeWidget);
    11051108    while (*it)
    11061109    {
    1107         SnapshotWgtItem *lvi = static_cast <SnapshotWgtItem*> (*it);
    1108         if (lvi->snapshotId() == aSnapshotId)
    1109             return lvi;
    1110         ++ it;
     1110        SnapshotWgtItem *pSnapshotItem = static_cast<SnapshotWgtItem*>(*it);
     1111        if (pSnapshotItem->snapshotID() == strSnapshotID)
     1112            return pSnapshotItem;
     1113        ++it;
    11111114    }
    11121115
     
    11151118}
    11161119
    1117 SnapshotWgtItem *UISnapshotPane::curStateItem()
     1120SnapshotWgtItem *UISnapshotPane::currentStateItem() const
    11181121{
    11191122    /* Last child of the current snapshot item if any or first child of invisible root item otherwise: */
    1120     QTreeWidgetItem *csi = mCurSnapshotItem ?
    1121                            mCurSnapshotItem->child (mCurSnapshotItem->childCount() - 1) :
    1122                            mTreeWidget->invisibleRootItem()->child (0);
    1123     return static_cast <SnapshotWgtItem*> (csi);
    1124 }
    1125 
    1126 void UISnapshotPane::populateSnapshots (const CSnapshot &aSnapshot, QTreeWidgetItem *aItem)
     1123    QTreeWidgetItem *pCsi = m_pCurrentSnapshotItem ?
     1124                            m_pCurrentSnapshotItem->child(m_pCurrentSnapshotItem->childCount() - 1) :
     1125                            m_pTreeWidget->invisibleRootItem()->child(0);
     1126    return static_cast<SnapshotWgtItem*>(pCsi);
     1127}
     1128
     1129void UISnapshotPane::populateSnapshots(const CSnapshot &comSnapshot, QTreeWidgetItem *pItem)
    11271130{
    11281131    /* Create a child of passed item: */
    1129     SnapshotWgtItem *item = aItem ? new SnapshotWgtItem(this, aItem, aSnapshot) :
    1130                                     new SnapshotWgtItem(this, mTreeWidget, aSnapshot);
     1132    SnapshotWgtItem *pSnapshotItem = pItem ? new SnapshotWgtItem(this, pItem, comSnapshot) :
     1133                                             new SnapshotWgtItem(this, m_pTreeWidget, comSnapshot);
    11311134    /* And recache it's content: */
    1132     item->recache();
     1135    pSnapshotItem->recache();
    11331136
    11341137    /* Mark current snapshot item bold and remember it: */
    1135     CSnapshot curSnapshot = mMachine.GetCurrentSnapshot();
    1136     if (!curSnapshot.isNull() && curSnapshot.GetId() == aSnapshot.GetId())
    1137     {
    1138         item->setBold (true);
    1139         mCurSnapshotItem = item;
     1138    CSnapshot comCurrentSnapshot = m_comMachine.GetCurrentSnapshot();
     1139    if (!comCurrentSnapshot.isNull() && comCurrentSnapshot.GetId() == comSnapshot.GetId())
     1140    {
     1141        pSnapshotItem->setBold(true);
     1142        m_pCurrentSnapshotItem = pSnapshotItem;
    11401143    }
    11411144
    11421145    /* Walk through the children recursively: */
    1143     CSnapshotVector snapshots = aSnapshot.GetChildren();
    1144     foreach (const CSnapshot &snapshot, snapshots)
    1145         populateSnapshots (snapshot, item);
     1146    const CSnapshotVector snapshots = comSnapshot.GetChildren();
     1147    foreach (const CSnapshot &comIteratedSnapshot, snapshots)
     1148        populateSnapshots(comIteratedSnapshot, pSnapshotItem);
    11461149
    11471150    /* Expand the newly created item: */
    1148     item->setExpanded (true);
     1151    pSnapshotItem->setExpanded(true);
    11491152    /* And mark it as editable: */
    1150     item->setFlags (item->flags() | Qt::ItemIsEditable);
    1151 }
    1152 
    1153 SnapshotAgeFormat UISnapshotPane::traverseSnapshotAge (QTreeWidgetItem *aParentItem)
     1153    pSnapshotItem->setFlags(pSnapshotItem->flags() | Qt::ItemIsEditable);
     1154}
     1155
     1156SnapshotAgeFormat UISnapshotPane::traverseSnapshotAge(QTreeWidgetItem *pItem) const
    11541157{
    11551158    /* Make sure passed root is of valid type: */
    1156     SnapshotWgtItem *parentItem = aParentItem->type() == SnapshotWgtItem::ItemType ?
    1157                                   static_cast <SnapshotWgtItem*> (aParentItem) : 0;
     1159    SnapshotWgtItem *pSnapshotItem = pItem->type() == SnapshotWgtItem::ItemType ?
     1160                                     static_cast<SnapshotWgtItem*>(pItem) : 0;
    11581161
    11591162    /* Fetch the snapshot age of the root if it's valid: */
    1160     SnapshotAgeFormat age = parentItem ? parentItem->updateAge() : AgeMax;
     1163    SnapshotAgeFormat age = pSnapshotItem ? pSnapshotItem->updateAge() : SnapshotAgeFormat_Max;
    11611164
    11621165    /* Walk through the children recursively: */
    1163     for (int i = 0; i < aParentItem->childCount(); ++ i)
     1166    for (int i = 0; i < pItem->childCount(); ++i)
    11641167    {
    11651168        /* Fetch the smallest snapshot age of the children: */
    1166         SnapshotAgeFormat newAge = traverseSnapshotAge (aParentItem->child (i));
     1169        const SnapshotAgeFormat newAge = traverseSnapshotAge(pItem->child(i));
    11671170        /* Remember the smallest snapshot age among existing: */
    11681171        age = newAge < age ? newAge : age;
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UISnapshotPane.h

    r63818 r63821  
    3838enum SnapshotAgeFormat
    3939{
    40     AgeInSeconds,
    41     AgeInMinutes,
    42     AgeInHours,
    43     AgeInDays,
    44     AgeMax
     40    SnapshotAgeFormat_InSeconds,
     41    SnapshotAgeFormat_InMinutes,
     42    SnapshotAgeFormat_InHours,
     43    SnapshotAgeFormat_InDays,
     44    SnapshotAgeFormat_Max
    4545};
    4646
     
    5353public:
    5454
    55     /** Constructs snapshot pane passing @a aParent to the base-class. */
    56     UISnapshotPane(QWidget *aParent);
     55    /** Constructs snapshot pane passing @a pParent to the base-class. */
     56    UISnapshotPane(QWidget *pParent);
    5757
    58     /** Defines the @a aMachine to be parsed. */
    59     void setMachine (const CMachine &aMachine);
     58    /** Defines the @a comMachine to be parsed. */
     59    void setMachine(const CMachine &comMachine);
    6060
    6161    /** Returns cached snapshot-item icon depending on @a fOnline flag. */
    62     const QIcon& snapshotItemIcon(bool fOnline) { return !fOnline ? m_offlineSnapshotIcon : m_onlineSnapshotIcon; }
     62    const QIcon &snapshotItemIcon(bool fOnline) const { return !fOnline ? m_snapshotIconOffline : m_snapshotIconOnline; }
    6363
    6464protected:
    6565
    6666    /** Handles translation event. */
    67     void retranslateUi();
     67    virtual void retranslateUi() /* override */;
    6868
    6969private slots:
     
    7171    /** @name Tree-view handlers
    7272      * @{ */
    73         /** Handles cursor change to @a aItem. */
    74         void onCurrentChanged (QTreeWidgetItem *aItem = 0);
    75         /** Handles context menu request for @a aPoint. */
    76         void onContextMenuRequested (const QPoint &aPoint);
    77         /** Handles modification for @a aItem. */
    78         void onItemChanged (QTreeWidgetItem *aItem);
     73        /** Handles cursor change to @a pItem. */
     74        void sltCurrentItemChanged(QTreeWidgetItem *pItem = 0);
     75        /** Handles context menu request for @a point. */
     76        void sltContextMenuRequested(const QPoint &point);
     77        /** Handles modification for @a pItem. */
     78        void sltItemChanged(QTreeWidgetItem *pItem);
    7979        /** Handles double-click for @a pItem. */
    8080        void sltItemDoubleClicked(QTreeWidgetItem *pItem);
     
    9797    /** @name Main event handlers
    9898      * @{ */
    99         /** Handles machine data change for machine with @a strId. */
    100         void machineDataChanged(QString strId);
    101         /** Handles machine @a state change for machine with @a strId. */
    102         void machineStateChanged(QString strId, KMachineState state);
    103         /** Handles session @a state change for machine with @a strId. */
    104         void sessionStateChanged(QString strId, KSessionState state);
     99        /** Handles machine data change for machine with @a strMachineID. */
     100        void sltMachineDataChange(QString strMachineID);
     101        /** Handles machine @a enmState change for machine with @a strMachineID. */
     102        void sltMachineStateChange(QString strMachineID, KMachineState enmState);
     103        /** Handles session @a enmState change for machine with @a strMachineID. */
     104        void sltSessionStateChange(QString strMachineID, KSessionState enmState);
    105105    /** @} */
    106106
     
    108108      * @{ */
    109109        /** Updates snapshots age. */
    110         void updateSnapshotsAge();
     110        void sltUpdateSnapshotsAge();
    111111    /** @} */
    112112
     
    130130    void refreshAll();
    131131
    132     /** Searches for an item with corresponding @a aSnapshotId. */
    133     SnapshotWgtItem* findItem (const QString &aSnapshotId);
     132    /** Searches for an item with corresponding @a strSnapshotID. */
     133    SnapshotWgtItem *findItem(const QString &strSnapshotID) const;
    134134    /** Returns the "current state" item. */
    135     SnapshotWgtItem* curStateItem();
     135    SnapshotWgtItem *currentStateItem() const;
    136136
    137     /** Populates snapshot items for corresponding @a aSnapshot using @a aItem as parent. */
    138     void populateSnapshots (const CSnapshot &aSnapshot, QTreeWidgetItem *aItem);
     137    /** Populates snapshot items for corresponding @a comSnapshot using @a pItem as parent. */
     138    void populateSnapshots(const CSnapshot &comSnapshot, QTreeWidgetItem *pItem);
    139139
    140     /** Searches for smallest snapshot age starting with @a aParentItem as parent. */
    141     SnapshotAgeFormat traverseSnapshotAge (QTreeWidgetItem *aParentItem);
     140    /** Searches for smallest snapshot age starting with @a pItem as parent. */
     141    SnapshotAgeFormat traverseSnapshotAge(QTreeWidgetItem *pItem) const;
    142142
    143143    /** Holds the machine COM wrapper. */
    144     CMachine         mMachine;
     144    CMachine         m_comMachine;
    145145    /** Holds the machine ID. */
    146     QString          mMachineId;
     146    QString          m_strMachineID;
    147147    /** Holds the cached session state. */
    148     KSessionState    mSessionState;
     148    KSessionState    m_enmSessionState;
    149149    /** Holds the current snapshot item reference. */
    150     SnapshotWgtItem *mCurSnapshotItem;
     150    SnapshotWgtItem *m_pCurrentSnapshotItem;
    151151    /** Holds the snapshot item editing protector. */
    152     bool             mEditProtector;
     152    bool             m_fEditProtector;
    153153
    154154    /** Holds the snapshot item action group instance. */
    155     QActionGroup    *mSnapshotActionGroup;
     155    QActionGroup    *m_pSnapshotItemActionGroup;
    156156    /** Holds the current item action group instance. */
    157     QActionGroup    *mCurStateActionGroup;
     157    QActionGroup    *m_pCurrentStateItemActionGroup;
    158158
    159159    /** Holds the snapshot restore action instance. */
    160     QAction         *mRestoreSnapshotAction;
     160    QAction         *m_pActionRestoreSnapshot;
    161161    /** Holds the snapshot delete action instance. */
    162     QAction         *mDeleteSnapshotAction;
     162    QAction         *m_pActionDeleteSnapshot;
    163163    /** Holds the show snapshot details action instance. */
    164     QAction         *mShowSnapshotDetailsAction;
     164    QAction         *m_pActionShowSnapshotDetails;
    165165    /** Holds the snapshot take action instance. */
    166     QAction         *mTakeSnapshotAction;
     166    QAction         *m_pActionTakeSnapshot;
    167167    /** Holds the snapshot clone action instance. */
    168     QAction         *mCloneSnapshotAction;
     168    QAction         *m_pActionCloneSnapshot;
    169169
    170170    /** Holds the snapshot age update timer. */
    171     QTimer           mAgeUpdateTimer;
     171    QTimer           m_ageUpdateTimer;
    172172
    173173    /** Holds whether the snapshot operations are allowed. */
     
    175175
    176176    /** Holds the cached snapshot-item pixmap for 'offline' state. */
    177     QIcon            m_offlineSnapshotIcon;
     177    QIcon            m_snapshotIconOffline;
    178178    /** Holds the cached snapshot-item pixmap for 'online' state. */
    179     QIcon            m_onlineSnapshotIcon;
     179    QIcon            m_snapshotIconOnline;
    180180};
    181181
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UISnapshotPane.ui

    r63804 r63821  
    4040   </property>
    4141   <item>
    42     <widget class="QTreeWidget" name="mTreeWidget" >
     42    <widget class="QTreeWidget" name="m_pTreeWidget" >
    4343     <property name="contextMenuPolicy" >
    4444      <enum>Qt::CustomContextMenu</enum>
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