VirtualBox

Changeset 45049 in vbox


Ignore:
Timestamp:
Mar 15, 2013 12:52:34 PM (12 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
84300
Message:

FE/Qt: 6644: Per-VM extra-data option to hide VM from VM selector.

Location:
trunk/src/VBox/Frontends/VirtualBox/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIDefs.cpp

    r45040 r45049  
    4545const char* UIDefs::GUI_LastItemSelected = "GUI/LastItemSelected";
    4646const char* UIDefs::GUI_GroupDefinitions = "GUI/GroupDefinitions";
     47const char* UIDefs::GUI_HideFromManager = "GUI/HideFromManager";
    4748
    4849/* Machine-window definitions: */
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIDefs.h

    r45040 r45049  
    122122    extern const char* GUI_LastItemSelected;
    123123    extern const char* GUI_GroupDefinitions;
     124    extern const char* GUI_HideFromManager;
    124125
    125126    /* Machine-window declarations: */
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp

    r44948 r45049  
    39173917        return tr("QCOW (QEMU Copy-On-Write)");
    39183918    return strBaseMediumFormatName;
     3919}
     3920
     3921/* static */
     3922bool VBoxGlobal::isApprovedByExtraData(CMachine &machine, const QString &strExtraDataKey)
     3923{
     3924    /* Load corresponding extra-data value: */
     3925    QString strExtraDataValue(machine.GetExtraData(strExtraDataKey));
     3926
     3927    /* 'false' if value was not set: */
     3928    if (strExtraDataValue.isEmpty())
     3929        return false;
     3930
     3931    /* Handle particular values: */
     3932    return    strExtraDataValue.compare("true", Qt::CaseInsensitive) == 0
     3933           || strExtraDataValue.compare("yes", Qt::CaseInsensitive) == 0
     3934           || strExtraDataValue.compare("on", Qt::CaseInsensitive) == 0
     3935           || strExtraDataValue == "1";
     3936}
     3937
     3938/* static */
     3939bool VBoxGlobal::shouldWeShowMachine(CMachine &machine)
     3940{
     3941    /* 'false' for null machines: */
     3942    if (machine.isNull())
     3943        return false;
     3944
     3945    /* 'true' for inaccessible machines,
     3946     * because we can't verify anything in that case: */
     3947    if (!machine.GetAccessible())
     3948        return true;
     3949
     3950    /* 'true' if hiding is not approved by the extra-data: */
     3951    return !isApprovedByExtraData(machine, GUI_HideFromManager);
    39193952}
    39203953
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h

    r44528 r45049  
    393393    /* Returns full medium-format name for the given base medium-format name: */
    394394    static QString fullMediumFormatName(const QString &strBaseMediumFormatName);
     395
     396    /* Extra-data settings stuff: */
     397    static bool isApprovedByExtraData(CMachine &machine, const QString &strExtraDataKey);
     398    static bool shouldWeShowMachine(CMachine &machine);
    395399
    396400signals:
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserModel.cpp

    r45040 r45049  
    602602        /* Search for corresponding machine: */
    603603        CMachine machine = vboxGlobal().virtualBox().FindMachine(strId);
    604         /* Machine was found? */
    605         if (!machine.isNull())
     604        /* Should we show this machine? */
     605        if (VBoxGlobal::shouldWeShowMachine(machine))
    606606        {
    607607            /* Add new machine-item: */
     
    884884    /* Remove all the items first: */
    885885    mainRoot()->removeAll(strId);
    886 
    887     /* Check if such machine still present: */
     886    /* Wipe out empty groups: */
     887    cleanupGroupTree();
     888
     889    /* Show machine if we should: */
    888890    CMachine machine = vboxGlobal().virtualBox().FindMachine(strId);
    889     if (machine.isNull())
    890         return;
    891 
    892     /* Add machine into the tree: */
    893     addMachineIntoTheTree(machine);
     891    if (VBoxGlobal::shouldWeShowMachine(machine))
     892        addMachineIntoTheTree(machine);
    894893
    895894    /* And update model: */
    896     cleanupGroupTree();
    897895    updateNavigation();
    898896    updateLayout();
     
    16161614void UIGChooserModel::loadGroupTree()
    16171615{
    1618     /* Add all the machines we have into the group-tree: */
     1616    /* Add all the approved machines we have into the group-tree: */
    16191617    LogRel(("Loading VMs started...\n"));
    1620     foreach (const CMachine &machine, vboxGlobal().virtualBox().GetMachines())
    1621         addMachineIntoTheTree(machine);
     1618    foreach (CMachine machine, vboxGlobal().virtualBox().GetMachines())
     1619        if (VBoxGlobal::shouldWeShowMachine(machine))
     1620            addMachineIntoTheTree(machine);
    16221621    LogRel(("Loading VMs finished.\n"));
    16231622}
Note: See TracChangeset for help on using the changeset viewer.

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