VirtualBox

Changeset 60930 in vbox for trunk/src


Ignore:
Timestamp:
May 10, 2016 3:28:15 PM (9 years ago)
Author:
vboxsync
Message:

FE/Qt: ​​​​​​​​​bugref:6769: Rework for New VM wizard (part 03): Moving machine filename composition code into separate function for reusing.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageBasic1.cpp

    r60839 r60930  
    218218    }
    219219
    220     /* Get VBox: */
    221     CVirtualBox vbox = vboxGlobal().virtualBox();
    222     /* Get default machine folder: */
    223     const QString strDefaultMachineFolder = vbox.GetSystemProperties().GetDefaultMachineFolder();
    224     /* Fetch user's machine location: */
    225     const QString strUserMachineLocation = m_pNameAndSystemEditor->name();
    226     const QString strUserMachineFolder = QFileInfo(strUserMachineLocation).absolutePath();
    227     const QString strUserMachineBaseName = QFileInfo(strUserMachineLocation).fileName();
    228     const bool fUseDefaultPath = strUserMachineLocation == strUserMachineBaseName;
    229     /* Compose machine filename: */
    230     const QString strMachineFilePath = vbox.ComposeMachineFilename(strUserMachineBaseName,
    231                                                                    fUseDefaultPath ? m_strGroup : QString() /* no group in that case */,
    232                                                                    QString(),
    233                                                                    fUseDefaultPath ? strDefaultMachineFolder : strUserMachineFolder);
    234     /* Compose machine folder/basename: */
    235     const QFileInfo fileInfo(strMachineFilePath);
    236     const QString strMachineFolder = fileInfo.absolutePath();
    237     const QString strMachineBaseName = fileInfo.completeBaseName();
     220    /* Compose machine file-path, parse it to folder and base-name: */
     221    const QString strMachineFilePath = composeMachineFilePath(m_pNameAndSystemEditor->name());
     222    const QString strMachineFolder = QDir::toNativeSeparators(QFileInfo(strMachineFilePath).absolutePath());
     223    const QString strMachineBaseName = QFileInfo(strMachineFilePath).completeBaseName();
    238224
    239225    /* Make sure that folder doesn't exists: */
     
    273259}
    274260
     261QString UIWizardNewVMPage1::composeMachineFilePath(const QString &strUserMachineLocation)
     262{
     263    /* Get VBox: */
     264    CVirtualBox vbox = vboxGlobal().virtualBox();
     265    /* Get default machine folder: */
     266    const QString strDefaultMachineFolder = vbox.GetSystemProperties().GetDefaultMachineFolder();
     267    /* Fetch user's machine location: */
     268    const QString strUserMachineFolder = QFileInfo(strUserMachineLocation).absolutePath();
     269    const QString strUserMachineBaseName = QFileInfo(strUserMachineLocation).fileName();
     270    const bool fUseDefaultPath = strUserMachineLocation == strUserMachineBaseName;
     271    /* Compose machine filename: */
     272    return vbox.ComposeMachineFilename(strUserMachineBaseName,
     273                                       fUseDefaultPath ? m_strGroup : QString() /* no group in that case */,
     274                                       QString(),
     275                                       fUseDefaultPath ? strDefaultMachineFolder : strUserMachineFolder);
     276}
     277
    275278UIWizardNewVMPageBasic1::UIWizardNewVMPageBasic1(const QString &strGroup)
    276279    : UIWizardNewVMPage1(strGroup)
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageBasic1.h

    r60839 r60930  
    4242    bool createMachineFolder();
    4343    bool cleanupMachineFolder();
     44
     45    /** Composes and returns machine file-path on the basis of passed @a strUserMachineLocation. */
     46    QString composeMachineFilePath(const QString &strUserMachineLocation);
    4447
    4548    /** Returns the machine folder value. */
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