VirtualBox

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


Ignore:
Timestamp:
Mar 6, 2014 4:32:05 PM (11 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
92682
Message:

FE/Qt: Medium Manager rework/cleanup: Rework medium-item *modify* method to be polymorphic call.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumManager.cpp

    r50716 r50717  
    7474    { refresh(); }
    7575
    76     /** Removes UIMedium wrapped by <i>this</i> item. */
    77     virtual bool remove() = 0;
    7876    /** Copy UIMedium wrapped by <i>this</i> item. */
    7977    virtual bool copy() = 0;
     78    /** Modify UIMedium wrapped by <i>this</i> item. */
     79    virtual bool modify() = 0;
     80    /** Remove UIMedium wrapped by <i>this</i> item. */
     81    virtual bool remove() = 0;
    8082
    8183    /** Refreshes item fully. */
     
    172174protected:
    173175
    174     /** Removes UIMedium wrapped by <i>this</i> item. */
    175     bool remove()
    176     {
    177         /* Confirm medium removal: */
    178         if (!msgCenter().confirmMediumRemoval(medium(), treeWidget()))
    179             return false;
    180 
    181         /* Remember some of hard-disk attributes: */
    182         CMedium hardDisk = medium().medium();
    183         QString strMediumID = id();
    184 
    185         /* Propose to remove medium storage: */
    186         if (!maybeRemoveStorage())
    187             return false;
    188 
    189         /* Close hard-disk: */
    190         hardDisk.Close();
    191         if (!hardDisk.isOk())
    192         {
    193             msgCenter().cannotCloseMedium(medium(), hardDisk, treeWidget());
    194             return false;
    195         }
    196 
    197         /* Remove UIMedium finally: */
    198         vboxGlobal().deleteMedium(strMediumID);
    199 
    200         /* True by default: */
    201         return true;
    202     }
    203 
    204176    /** Copy UIMedium wrapped by <i>this</i> item. */
    205177    bool copy()
     
    213185        if (pWizard)
    214186            delete pWizard;
     187
     188        /* True by default: */
     189        return true;
     190    }
     191
     192    /** Modify UIMedium wrapped by <i>this</i> item. */
     193    bool modify()
     194    {
     195        /* False by default: */
     196        bool fResult = false;
     197
     198        /* Show Modify VD dialog: */
     199        UISafePointerDialog pDialog = new UIMediumTypeChangeDialog(treeWidget(), id());
     200        if (pDialog->exec() == QDialog::Accepted)
     201        {
     202            /* Update medium-item: */
     203            refreshAll();
     204            /* Change to passed: */
     205            fResult = true;
     206        }
     207
     208        /* Delete if still exists: */
     209        if (pDialog)
     210            delete pDialog;
     211
     212        /* Return result: */
     213        return fResult;
     214    }
     215
     216    /** Remove UIMedium wrapped by <i>this</i> item. */
     217    bool remove()
     218    {
     219        /* Confirm medium removal: */
     220        if (!msgCenter().confirmMediumRemoval(medium(), treeWidget()))
     221            return false;
     222
     223        /* Remember some of hard-disk attributes: */
     224        CMedium hardDisk = medium().medium();
     225        QString strMediumID = id();
     226
     227        /* Propose to remove medium storage: */
     228        if (!maybeRemoveStorage())
     229            return false;
     230
     231        /* Close hard-disk: */
     232        hardDisk.Close();
     233        if (!hardDisk.isOk())
     234        {
     235            msgCenter().cannotCloseMedium(medium(), hardDisk, treeWidget());
     236            return false;
     237        }
     238
     239        /* Remove UIMedium finally: */
     240        vboxGlobal().deleteMedium(strMediumID);
    215241
    216242        /* True by default: */
     
    281307protected:
    282308
    283     /** Removes UIMedium wrapped by <i>this</i> item. */
     309    /** Copy UIMedium wrapped by <i>this</i> item. */
     310    bool copy()
     311    {
     312        AssertMsgFailedReturn(("That functionality in not supported!\n"), false);
     313    }
     314
     315    /** Modify UIMedium wrapped by <i>this</i> item. */
     316    bool modify()
     317    {
     318        AssertMsgFailedReturn(("That functionality in not supported!\n"), false);
     319    }
     320
     321    /** Remove UIMedium wrapped by <i>this</i> item. */
    284322    bool remove()
    285323    {
     
    305343        /* True by default: */
    306344        return true;
    307     }
    308 
    309     /** Copy UIMedium wrapped by <i>this</i> item. */
    310     bool copy()
    311     {
    312         AssertMsgFailedReturn(("That functionality in not supported!\n"), false);
    313345    }
    314346};
     
    326358protected:
    327359
    328     /** Removes UIMedium wrapped by <i>this</i> item. */
     360    /** Copy UIMedium wrapped by <i>this</i> item. */
     361    bool copy()
     362    {
     363        AssertMsgFailedReturn(("That functionality in not supported!\n"), false);
     364    }
     365
     366    /** Modify UIMedium wrapped by <i>this</i> item. */
     367    bool modify()
     368    {
     369        AssertMsgFailedReturn(("That functionality in not supported!\n"), false);
     370    }
     371
     372    /** Remove UIMedium wrapped by <i>this</i> item. */
    329373    bool remove()
    330374    {
     
    350394        /* True by default: */
    351395        return true;
    352     }
    353 
    354     /** Copy UIMedium wrapped by <i>this</i> item. */
    355     bool copy()
    356     {
    357         AssertMsgFailedReturn(("That functionality in not supported!\n"), false);
    358396    }
    359397};
     
    606644    AssertReturnVoid(!pMediumItem->id().isNull());
    607645
    608     /* Show Modify VD dialog: */
    609     UISafePointerDialog pDialog = new UIMediumTypeChangeDialog(this, pMediumItem->id());
    610     if (pDialog->exec() == QDialog::Accepted)
    611     {
    612         /* Update medium-item: */
    613         pMediumItem->refreshAll();
    614         /* Update HD information-panes: */
     646    /* Modify current medium-item: */
     647    bool fResult = pMediumItem->modify();
     648
     649    /* Update HD information-panes: */
     650    if (fResult)
    615651        updateInformationPanesHD();
    616     }
    617 
    618     /* Delete if still exists: */
    619     if (pDialog)
    620         delete pDialog;
    621652}
    622653
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