VirtualBox

Changeset 84424 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
May 20, 2020 5:29:53 PM (5 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9653: VirtualBox Manager: Chooser pane: Light cleanup in machine group definitions saving functionality.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserAbstractModel.cpp

    r84423 r84424  
    189189    // Currently we are not saving group descriptors
    190190    // (which reflecting group toggle-state) on-the-fly,
    191     // so for now we are additionally save group orders
     191    // so for now we are additionally save group definitions
    192192    // when exiting application:
    193     saveGroupOrders();
     193    saveGroupDefinitions();
    194194
    195195    /* Make sure all saving steps complete: */
    196196    makeSureGroupSettingsSaveIsFinished();
    197     makeSureGroupOrdersSaveIsFinished();
     197    makeSureGroupDefinitionsSaveIsFinished();
    198198
    199199    /* Delete tree: */
     
    307307{
    308308    return    UIThreadGroupSettingsSave::instance()
    309            || UIThreadGroupOrderSave::instance();
     309           || UIThreadGroupDefinitionsSave::instance();
    310310}
    311311
     
    470470{
    471471    saveGroupSettings();
    472     saveGroupOrders();
     472    saveGroupDefinitions();
    473473}
    474474
     
    532532}
    533533
    534 void UIChooserAbstractModel::sltGroupOrdersSaveComplete()
    535 {
    536     makeSureGroupOrdersSaveIsFinished();
     534void UIChooserAbstractModel::sltGroupDefinitionsSaveComplete()
     535{
     536    makeSureGroupDefinitionsSaveIsFinished();
    537537    emit sigGroupSavingStateChanged();
    538538}
     
    10121012}
    10131013
    1014 void UIChooserAbstractModel::saveGroupOrders()
    1015 {
    1016     /* Make sure there is no group save activity: */
    1017     if (UIThreadGroupOrderSave::instance())
     1014void UIChooserAbstractModel::saveGroupDefinitions()
     1015{
     1016    /* Make sure there is no group definitions save activity: */
     1017    if (UIThreadGroupDefinitionsSave::instance())
    10181018        return;
    10191019
    10201020    /* Prepare full group map: */
    10211021    QMap<QString, QStringList> groups;
    1022     gatherGroupOrders(groups, invisibleRoot());
     1022    gatherGroupDefinitions(groups, invisibleRoot());
    10231023
    10241024    /* Save information in other thread: */
    1025     UIThreadGroupOrderSave::prepare();
     1025    UIThreadGroupDefinitionsSave::prepare();
    10261026    emit sigGroupSavingStateChanged();
    1027     UIThreadGroupOrderSave::instance()->configure(this, groups);
    1028     UIThreadGroupOrderSave::instance()->start();
     1027    UIThreadGroupDefinitionsSave::instance()->configure(this, groups);
     1028    UIThreadGroupDefinitionsSave::instance()->start();
    10291029}
    10301030
     
    10491049}
    10501050
    1051 void UIChooserAbstractModel::gatherGroupOrders(QMap<QString, QStringList> &orders,
    1052                                                UIChooserNode *pParentGroup)
     1051void UIChooserAbstractModel::gatherGroupDefinitions(QMap<QString, QStringList> &definitions,
     1052                                                    UIChooserNode *pParentGroup)
    10531053{
    10541054    /* Prepare extra-data key for current group: */
     
    10591059        /* Append node definition: */
    10601060        AssertPtrReturnVoid(pNode);
    1061         orders[strExtraDataKey] << pNode->definition(true /* full */);
     1061        definitions[strExtraDataKey] << pNode->definition(true /* full */);
    10621062    }
    10631063    /* Iterate over all the group-nodes: */
     
    10661066        /* Append node definition: */
    10671067        AssertPtrReturnVoid(pNode);
    1068         orders[strExtraDataKey] << pNode->definition(true /* full */);
     1068        definitions[strExtraDataKey] << pNode->definition(true /* full */);
    10691069        /* Go recursively through children: */
    1070         gatherGroupOrders(orders, pNode);
     1070        gatherGroupDefinitions(definitions, pNode);
    10711071    }
    10721072    /* Iterate over all the machine-nodes: */
     
    10801080        if (   pMachineNode->cacheType() == UIVirtualMachineItemType_Local
    10811081            || pMachineNode->cacheType() == UIVirtualMachineItemType_CloudReal)
    1082             orders[strExtraDataKey] << pNode->definition(true /* full */);
     1082            definitions[strExtraDataKey] << pNode->definition(true /* full */);
    10831083    }
    10841084}
     
    10911091}
    10921092
    1093 void UIChooserAbstractModel::makeSureGroupOrdersSaveIsFinished()
     1093void UIChooserAbstractModel::makeSureGroupDefinitionsSaveIsFinished()
    10941094{
    10951095    /* Cleanup if necessary: */
    1096     if (UIThreadGroupOrderSave::instance())
    1097         UIThreadGroupOrderSave::cleanup();
     1096    if (UIThreadGroupDefinitionsSave::instance())
     1097        UIThreadGroupDefinitionsSave::cleanup();
    10981098}
    10991099
     
    11401140    m_oldLists = oldLists;
    11411141    m_newLists = newLists;
    1142     UIChooserAbstractModel* pChooserAbstractModel = qobject_cast<UIChooserAbstractModel*>(pParent);
     1142    UIChooserAbstractModel *pChooserAbstractModel = qobject_cast<UIChooserAbstractModel*>(pParent);
    11431143    AssertPtrReturnVoid(pChooserAbstractModel);
    11441144    {
     
    12321232
    12331233/*********************************************************************************************************************************
    1234 *   Class UIThreadGroupOrderSave implementation.                                                                                 *
     1234*   Class UIThreadGroupDefinitionsSave implementation.                                                                           *
    12351235*********************************************************************************************************************************/
    12361236
    12371237/* static */
    1238 UIThreadGroupOrderSave *UIThreadGroupOrderSave::s_pInstance = 0;
     1238UIThreadGroupDefinitionsSave *UIThreadGroupDefinitionsSave::s_pInstance = 0;
    12391239
    12401240/* static */
    1241 UIThreadGroupOrderSave *UIThreadGroupOrderSave::instance()
     1241UIThreadGroupDefinitionsSave *UIThreadGroupDefinitionsSave::instance()
    12421242{
    12431243    return s_pInstance;
     
    12451245
    12461246/* static */
    1247 void UIThreadGroupOrderSave::prepare()
    1248 {
    1249     /* Make sure instance not prepared: */
     1247void UIThreadGroupDefinitionsSave::prepare()
     1248{
     1249    /* Make sure instance is not prepared: */
    12501250    if (s_pInstance)
    12511251        return;
    12521252
    12531253    /* Crate instance: */
    1254     new UIThreadGroupOrderSave;
     1254    new UIThreadGroupDefinitionsSave;
    12551255}
    12561256
    12571257/* static */
    1258 void UIThreadGroupOrderSave::cleanup()
    1259 {
    1260     /* Make sure instance prepared: */
     1258void UIThreadGroupDefinitionsSave::cleanup()
     1259{
     1260    /* Make sure instance is prepared: */
    12611261    if (!s_pInstance)
    12621262        return;
    12631263
    1264     /* Crate instance: */
     1264    /* Delete instance: */
    12651265    delete s_pInstance;
    12661266}
    12671267
    1268 void UIThreadGroupOrderSave::configure(QObject *pParent,
    1269                                        const QMap<QString, QStringList> &groups)
    1270 {
    1271     m_groups = groups;
     1268void UIThreadGroupDefinitionsSave::configure(QObject *pParent,
     1269                                             const QMap<QString, QStringList> &groups)
     1270{
     1271    m_lists = groups;
    12721272    UIChooserAbstractModel *pChooserAbstractModel = qobject_cast<UIChooserAbstractModel*>(pParent);
    12731273    AssertPtrReturnVoid(pChooserAbstractModel);
    12741274    {
    1275         connect(this, &UIThreadGroupOrderSave::sigComplete,
    1276                 pChooserAbstractModel, &UIChooserAbstractModel::sltGroupOrdersSaveComplete);
    1277     }
    1278 }
    1279 
    1280 UIThreadGroupOrderSave::UIThreadGroupOrderSave()
     1275        connect(this, &UIThreadGroupDefinitionsSave::sigComplete,
     1276                pChooserAbstractModel, &UIChooserAbstractModel::sltGroupDefinitionsSaveComplete);
     1277    }
     1278}
     1279
     1280UIThreadGroupDefinitionsSave::UIThreadGroupDefinitionsSave()
    12811281{
    12821282    /* Assign instance: */
     
    12841284}
    12851285
    1286 UIThreadGroupOrderSave::~UIThreadGroupOrderSave()
    1287 {
    1288     /* Wait: */
     1286UIThreadGroupDefinitionsSave::~UIThreadGroupDefinitionsSave()
     1287{
     1288    /* Make sure thread work is complete: */
    12891289    wait();
    12901290
     
    12931293}
    12941294
    1295 void UIThreadGroupOrderSave::run()
     1295void UIThreadGroupDefinitionsSave::run()
    12961296{
    12971297    /* COM prepare: */
     
    13011301    gEDataManager->clearSelectorWindowGroupsDefinitions();
    13021302    /* For every particular group definition: */
    1303     foreach (const QString &strId, m_groups.keys())
    1304         gEDataManager->setSelectorWindowGroupsDefinitions(strId, m_groups[strId]);
     1303    foreach (const QString &strId, m_lists.keys())
     1304        gEDataManager->setSelectorWindowGroupsDefinitions(strId, m_lists[strId]);
    13051305
    13061306    /* Notify listeners about completeness: */
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserAbstractModel.h

    r84423 r84424  
    130130        /** Handles group settings saving complete. */
    131131        void sltGroupSettingsSaveComplete();
    132         /** Handles group order saving complete. */
    133         void sltGroupOrdersSaveComplete();
     132        /** Handles group definitions saving complete. */
     133        void sltGroupDefinitionsSaveComplete();
    134134    /** @} */
    135135
     
    227227        /** Saves group settings. */
    228228        void saveGroupSettings();
    229         /** Saves group orders. */
    230         void saveGroupOrders();
     229        /** Saves group definitions. */
     230        void saveGroupDefinitions();
    231231
    232232        /** Gathers group @a settings of @a pParentGroup. */
    233233        void gatherGroupSettings(QMap<QString, QStringList> &settings, UIChooserNode *pParentGroup);
    234         /** Gathers group @a orders of @a pParentGroup. */
    235         void gatherGroupOrders(QMap<QString, QStringList> &orders, UIChooserNode *pParentGroup);
     234        /** Gathers group @a definitions of @a pParentGroup. */
     235        void gatherGroupDefinitions(QMap<QString, QStringList> &definitions, UIChooserNode *pParentGroup);
    236236
    237237        /** Makes sure group settings saving is finished. */
    238238        void makeSureGroupSettingsSaveIsFinished();
    239         /** Makes sure group orders saving is finished. */
    240         void makeSureGroupOrdersSaveIsFinished();
     239        /** Makes sure group definitions saving is finished. */
     240        void makeSureGroupDefinitionsSaveIsFinished();
    241241    /** @} */
    242242
     
    261261    /** @name Group saving stuff.
    262262      * @{ */
    263         /** Holds the consolidated map of group settings/orders. */
     263        /** Holds the consolidated map of group settings/definitions. */
    264264        QMap<QString, QStringList>  m_groups;
    265265    /** @} */
     
    316316
    317317
    318 /** QThread subclass allowing to save group order asynchronously. */
    319 class UIThreadGroupOrderSave : public QThread
     318/** QThread subclass allowing to save group definitions asynchronously. */
     319class UIThreadGroupDefinitionsSave : public QThread
    320320{
    321321    Q_OBJECT;
     
    328328public:
    329329
    330     /** Returns group saving thread instance. */
    331     static UIThreadGroupOrderSave *instance();
    332     /** Prepares group saving thread instance. */
     330    /** Returns group definitions saving thread instance. */
     331    static UIThreadGroupDefinitionsSave *instance();
     332    /** Prepares group definitions saving thread instance. */
    333333    static void prepare();
    334     /** Cleanups group saving thread instance. */
     334    /** Cleanups group definitions saving thread instance. */
    335335    static void cleanup();
    336336
    337     /** Configures group saving thread with corresponding @a pListener.
    338       * @param  groups  Brings the groups to be saved. */
     337    /** Configures group definitions saving thread with corresponding @a pListener.
     338      * @param  lists  Brings definitions lists to be saved. */
    339339    void configure(QObject *pListener,
    340                    const QMap<QString, QStringList> &groups);
     340                   const QMap<QString, QStringList> &lists);
    341341
    342342protected:
    343343
    344     /** Constructs group saving thread. */
    345     UIThreadGroupOrderSave();
    346     /** Destructs group saving thread. */
    347     virtual ~UIThreadGroupOrderSave() /* override */;
     344    /** Constructs group definitions saving thread. */
     345    UIThreadGroupDefinitionsSave();
     346    /** Destructs group definitions saving thread. */
     347    virtual ~UIThreadGroupDefinitionsSave() /* override */;
    348348
    349349    /** Contains a thread task to be executed. */
     
    351351
    352352    /** Holds the singleton instance. */
    353     static UIThreadGroupOrderSave *s_pInstance;
    354 
    355     /** Holds the map of groups to be saved. */
    356     QMap<QString, QStringList>  m_groups;
     353    static UIThreadGroupDefinitionsSave *s_pInstance;
     354
     355    /** Holds the map of group definitions to be saved. */
     356    QMap<QString, QStringList>  m_lists;
    357357};
    358358
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