VirtualBox

Changeset 31240 in vbox


Ignore:
Timestamp:
Jul 30, 2010 12:07:44 PM (14 years ago)
Author:
vboxsync
Message:

FE/Qt4: cleaned up session/machine state mess; added session state to the cache key

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

Legend:

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

    r31008 r31240  
    12521252    if (m_pVMItem)
    12531253    {
    1254         bool saved = m_pVMItem->state() == KMachineState_Saved;
     1254        bool saved = m_pVMItem->machineState() == KMachineState_Saved;
    12551255        bool busy = m_pVMItem->sessionState() != KSessionState_Unlocked;
    12561256        m_pEditBtn->setEnabled(!saved && !busy);
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UIVMItem.cpp

    r30868 r31240  
    149149////////////////////////////////////////////////////////////////////////////////
    150150
     151QString UIVMItem::machineStateName() const
     152{
     153    return m_fAccessible ? vboxGlobal().toString(m_machineState) :
     154           QApplication::translate("UIVMListView", "Inaccessible");
     155}
     156
    151157QString UIVMItem::sessionStateName() const
    152158{
    153     return m_fAccessible ? vboxGlobal().toString(m_state) :
     159    return m_fAccessible ? vboxGlobal().toString(m_sessionState) :
    154160           QApplication::translate("UIVMListView", "Inaccessible");
    155161}
     
    174180            "VM tooltip (name, last state change, session state)")
    175181            .arg(toolTip)
    176             .arg(vboxGlobal().toString(m_state))
     182            .arg(vboxGlobal().toString(m_machineState))
    177183            .arg(dateTime)
    178184            .arg(vboxGlobal().toString(m_sessionState));
     
    208214        m_strName = name;
    209215
    210         m_state = m_machine.GetState();
     216        m_machineState = m_machine.GetState();
    211217        m_lastStateChange.setTime_t(m_machine.GetLastStateChange() / 1000);
    212218        m_sessionState = m_machine.GetSessionState();
     
    214220        m_cSnaphot = m_machine.GetSnapshotCount();
    215221
    216         if (   m_state == KMachineState_PoweredOff
    217             || m_state == KMachineState_Saved
    218             || m_state == KMachineState_Teleported
    219             || m_state == KMachineState_Aborted
     222        if (   m_machineState == KMachineState_PoweredOff
     223            || m_machineState == KMachineState_Saved
     224            || m_machineState == KMachineState_Teleported
     225            || m_machineState == KMachineState_Aborted
    220226           )
    221227        {
     
    246252        needsResort = name != m_strName;
    247253        m_strName = name;
    248         m_state = KMachineState_Null;
     254        m_machineState = KMachineState_Null;
    249255        m_sessionState = KSessionState_Null;
    250256        m_lastStateChange = QDateTime::currentDateTime();
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UIVMItem.h

    r30868 r31240  
    4040    QString id() const { return m_strId; }
    4141
     42    QString machineStateName() const;
     43    QIcon machineStateIcon() const { return m_fAccessible ? vboxGlobal().toIcon(m_machineState) : QPixmap(":/state_aborted_16px.png"); }
     44
    4245    QString sessionStateName() const;
    43     QIcon sessionStateIcon() const { return m_fAccessible ? vboxGlobal().toIcon(m_state) : QPixmap(":/state_aborted_16px.png"); }
    4446
    4547    QString snapshotName() const { return m_strSnapshotName; }
     
    5052    bool accessible() const { return m_fAccessible; }
    5153    const CVirtualBoxErrorInfo &accessError() const { return m_accessError; }
    52     KMachineState state() const { return m_state; }
     54    KMachineState machineState() const { return m_machineState; }
    5355    KSessionState sessionState() const { return m_sessionState; }
    5456
     
    7274    QString m_strName;
    7375    QString m_strSnapshotName;
    74     KMachineState m_state;
    7576    QDateTime m_lastStateChange;
     77    KMachineState m_machineState;
    7678    KSessionState m_sessionState;
    7779    QString m_strOSTypeId;
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UIVMListView.cpp

    r31008 r31240  
    187187                         .arg(item->name())
    188188                         .arg(item->snapshotName())
    189                          .arg(item->sessionStateName());
     189                         .arg(item->machineStateName());
    190190            break;
    191191        }
     
    201201            break;
    202202        }
    203         case SessionStateDisplayRole:
    204         {
    205             v = m_VMItemList.at(aIndex.row())->sessionStateName();
    206             break;
    207         }
    208         case SessionStateDecorationRole:
    209         {
    210             v = m_VMItemList.at(aIndex.row())->sessionStateIcon();
    211             break;
    212         }
    213         case SessionStateFontRole:
     203        case MachineStateDisplayRole:
     204        {
     205            v = m_VMItemList.at(aIndex.row())->machineStateName();
     206            break;
     207        }
     208        case MachineStateDecorationRole:
     209        {
     210            v = m_VMItemList.at(aIndex.row())->machineStateIcon();
     211            break;
     212        }
     213        case MachineStateFontRole:
    214214        {
    215215            QFont f = qApp->font();
     
    218218                f.setItalic(true);
    219219            v = f;
     220            break;
     221        }
     222        case SessionStateDisplayRole:
     223        {
     224            v = m_VMItemList.at(aIndex.row())->sessionStateName();
    220225            break;
    221226        }
     
    394399    QRect vmNameRT = rect(aOption, aIndex, Qt::DisplayRole);
    395400    QRect shotRT = rect(aOption, aIndex, UIVMItemModel::SnapShotDisplayRole);
    396     QRect stateIconRT = rect(aOption, aIndex, UIVMItemModel::SessionStateDecorationRole);
    397     QRect stateRT = rect(aOption, aIndex, UIVMItemModel::SessionStateDisplayRole);
     401    QRect stateIconRT = rect(aOption, aIndex, UIVMItemModel::MachineStateDecorationRole);
     402    QRect stateRT = rect(aOption, aIndex, UIVMItemModel::MachineStateDisplayRole);
    398403    /* Calculate the position for every item */
    399404    calcLayout(aIndex, &osTypeRT, &vmNameRT, &shotRT, &stateIconRT, &stateRT);
     
    409414    /* Generate the key used in the pixmap cache. Needs to be composed with all
    410415     * values which might be changed. */
    411     QString key = QString("vbox:%1:%2:%3:%4:%5:%6")
     416    QString key = QString("vbox:%1:%2:%3:%4:%5:%6:%7")
    412417        .arg(index.data(Qt::DisplayRole).toString())
    413418        .arg(index.data(UIVMItemModel::OSTypeIdRole).toString())
    414419        .arg(index.data(UIVMItemModel::SnapShotDisplayRole).toString())
     420        .arg(index.data(UIVMItemModel::MachineStateDisplayRole).toString())
    415421        .arg(index.data(UIVMItemModel::SessionStateDisplayRole).toString())
    416422        .arg(option.state)
     
    468474    const QFont shotFont = index.data(UIVMItemModel::SnapShotFontRole).value<QFont>();
    469475
    470     const QString state = index.data(UIVMItemModel::SessionStateDisplayRole).toString();
    471     const QFont stateFont = index.data(UIVMItemModel::SessionStateFontRole).value<QFont>();
    472     const QPixmap stateIcon = index.data(UIVMItemModel::SessionStateDecorationRole).value<QIcon>().pixmap(QSize(16, 16), iconMode(option.state), iconState(option.state));
     476    const QString state = index.data(UIVMItemModel::MachineStateDisplayRole).toString();
     477    const QFont stateFont = index.data(UIVMItemModel::MachineStateFontRole).value<QFont>();
     478    const QPixmap stateIcon = index.data(UIVMItemModel::MachineStateDecorationRole).value<QIcon>().pixmap(QSize(16, 16), iconMode(option.state), iconState(option.state));
    473479
    474480    /* Get the sizes for all items */
     
    476482    QRect vmNameRT = rect(option, index, Qt::DisplayRole);
    477483    QRect shotRT = rect(option, index, UIVMItemModel::SnapShotDisplayRole);
    478     QRect stateIconRT = rect(option, index, UIVMItemModel::SessionStateDecorationRole);
    479     QRect stateRT = rect(option, index, UIVMItemModel::SessionStateDisplayRole);
     484    QRect stateIconRT = rect(option, index, UIVMItemModel::MachineStateDecorationRole);
     485    QRect stateRT = rect(option, index, UIVMItemModel::MachineStateDisplayRole);
    480486
    481487    /* Calculate the positions for all items */
     
    595601                break;
    596602            }
    597         case UIVMItemModel::SessionStateDisplayRole:
     603        case UIVMItemModel::MachineStateDisplayRole:
    598604            {
    599                 QString text = aIndex.data(UIVMItemModel::SessionStateDisplayRole).toString();
    600                 QFontMetrics fm(fontMetric(aIndex, UIVMItemModel::SessionStateFontRole));
     605                QString text = aIndex.data(UIVMItemModel::MachineStateDisplayRole).toString();
     606                QFontMetrics fm(fontMetric(aIndex, UIVMItemModel::MachineStateFontRole));
    601607                return QRect(QPoint(0, 0), fm.size(0, text));
    602608                break;
    603609            }
    604         case UIVMItemModel::SessionStateDecorationRole:
     610        case UIVMItemModel::MachineStateDecorationRole:
    605611            {
    606                 QIcon icon = aIndex.data(UIVMItemModel::SessionStateDecorationRole).value<QIcon>();
     612                QIcon icon = aIndex.data(UIVMItemModel::MachineStateDecorationRole).value<QIcon>();
    607613                return QRect(QPoint(0, 0), icon.actualSize(QSize(16, 16), iconMode(aOption.state), iconState(aOption.state)));
    608614                break;
     
    617623{
    618624    const int nameSpaceWidth = fontMetric(aIndex, Qt::FontRole).width(' ');
    619     const int stateSpaceWidth = fontMetric(aIndex, UIVMItemModel::SessionStateFontRole).width(' ');
     625    const int stateSpaceWidth = fontMetric(aIndex, UIVMItemModel::MachineStateFontRole).width(' ');
    620626    /* Really basic layout managment.
    621627     * First layout as usual */
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UIVMListView.h

    r30868 r31240  
    3535    enum { SnapShotDisplayRole = Qt::UserRole,
    3636           SnapShotFontRole,
     37           MachineStateDisplayRole,
     38           MachineStateDecorationRole,
     39           MachineStateFontRole,
    3740           SessionStateDisplayRole,
    38            SessionStateDecorationRole,
    39            SessionStateFontRole,
    4041           OSTypeIdRole,
    4142           UIVMItemPtrRole };
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/VBoxSelectorWnd.cpp

    r31220 r31240  
    724724    }
    725725
    726     AssertMsg (   item->state() == KMachineState_PoweredOff
    727                || item->state() == KMachineState_Saved
    728                || item->state() == KMachineState_Teleported
    729                || item->state() == KMachineState_Aborted
    730                , ("Machine must be PoweredOff/Saved/Aborted (%d)", item->state()));
     726    AssertMsg (   item->machineState() == KMachineState_PoweredOff
     727               || item->machineState() == KMachineState_Saved
     728               || item->machineState() == KMachineState_Teleported
     729               || item->machineState() == KMachineState_Aborted
     730               , ("Machine must be PoweredOff/Saved/Aborted (%d)", item->machineState()));
    731731
    732732    QString id = item->id();
     
    11901190        CMachine m = item->machine();
    11911191
    1192         KMachineState state = item->state();
     1192        KMachineState state = item->machineState();
    11931193        bool running = item->sessionState() != KSessionState_Unlocked;
    11941194        bool modifyEnabled = !running && state != KMachineState_Saved;
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