- Timestamp:
- Mar 23, 2009 11:16:29 AM (16 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/include/VBoxExportApplianceWzd.h
r17450 r18132 29 29 30 30 class QIWidgetValidator; 31 class CAppliance; 31 32 32 33 class VBoxExportApplianceWzd : public QIWithRetranslateUI<QIAbstractWizard>, … … 52 53 private: 53 54 void addListViewVMItems (const QString& aSelectName); 54 bool exportVMs(); 55 bool prepareForExportVMs (CAppliance &aAppliance); 56 bool exportVMs (CAppliance &aAppliance); 55 57 56 58 /* Private member vars */ -
trunk/src/VBox/Frontends/VirtualBox/include/VBoxProblemReporter.h
r18033 r18132 148 148 /* Generic problem handlers */ 149 149 bool askForOverridingFileIfExists (const QString& path, QWidget *aParent = NULL) const; 150 bool askForOverridingFilesIfExists (const QStringList& aPaths, QWidget *aParent /* = NULL */) const; 150 151 151 152 /* Special problem handlers */ -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxExportApplianceWzd.cpp
r17867 r18132 131 131 void VBoxExportApplianceWzd::accept() 132 132 { 133 /* Check if the file exists already, if yes get confirmation for 134 * overwriting from the user. */ 135 if (!vboxProblem().askForOverridingFileIfExists (mFileSelector->path(), this)) 136 return; 137 /* Export the VMs, on success we are finished */ 138 if (exportVMs()) 139 QIAbstractWizard::accept(); 133 CAppliance appliance; 134 /* Prepare the export of the VM's. */ 135 if (prepareForExportVMs (appliance)) 136 { 137 QFileInfo fi (mFileSelector->path()); 138 QStringList files; 139 files << mFileSelector->path(); 140 /* We need to know every filename which will be created, so that we can 141 * ask the user for confirmation of overwriting. For that we iterating 142 * over all virtual systems & fetch all descriptions of the type 143 * HardDiskImage. */ 144 CVirtualSystemDescriptionVector vsds = appliance.GetVirtualSystemDescriptions(); 145 for (int i=0; i < vsds.size(); ++i) 146 { 147 QVector<KVirtualSystemDescriptionType> types; 148 QVector<QString> refs, origValues, configValues, extraConfigValues; 149 150 vsds[i].GetDescriptionByType (KVirtualSystemDescriptionType_HardDiskImage, types, refs, origValues, configValues, extraConfigValues); 151 foreach (const QString &s, origValues) 152 files << QString ("%1/%2").arg (fi.absolutePath()).arg (s); 153 } 154 /* Check if the file exists already, if yes get confirmation for 155 * overwriting from the user. */ 156 if (!vboxProblem().askForOverridingFilesIfExists (files, this)) 157 return; 158 /* Export the VMs, on success we are finished */ 159 if (exportVMs(appliance)) 160 QIAbstractWizard::accept(); 161 } 140 162 } 141 163 … … 214 236 } 215 237 216 bool VBoxExportApplianceWzd:: exportVMs()238 bool VBoxExportApplianceWzd::prepareForExportVMs (CAppliance &aAppliance) 217 239 { 218 240 CVirtualBox vbox = vboxGlobal().virtualBox(); 219 241 /* Create a appliance object */ 220 CAppliance appliance = vbox.CreateAppliance();221 bool fResult = a ppliance.isOk();242 aAppliance = vbox.CreateAppliance(); 243 bool fResult = aAppliance.isOk(); 222 244 if (fResult) 223 245 { … … 234 256 { 235 257 /* Add the export description to our appliance object */ 236 m.Export (a ppliance);258 m.Export (aAppliance); 237 259 fResult = m.isOk(); 238 260 if (!fResult) 239 261 { 240 vboxProblem().cannotExportAppliance (m, &a ppliance, this);262 vboxProblem().cannotExportAppliance (m, &aAppliance, this); 241 263 return false; 242 264 } … … 245 267 break; 246 268 } 247 /* Proceed if there where no errors */248 if (fResult)249 {250 /* Write the appliance */251 CProgress progress = appliance.Write (mFileSelector->path());252 fResult = appliance.isOk();253 if (fResult)254 {255 /* Show some progress, so the user know whats going on */256 vboxProblem().showModalProgressDialog (progress, tr ("Exporting Appliance ..."), this);257 if (!progress.isOk() || progress.GetResultCode() != 0)258 {259 vboxProblem().cannotExportAppliance (progress, &appliance, this);260 return false;261 }262 else263 return true;264 }265 }266 269 } 267 270 if (!fResult) 268 vboxProblem().cannotExportAppliance (&appliance, this); 269 271 vboxProblem().cannotExportAppliance (&aAppliance, this); 272 return fResult; 273 } 274 275 bool VBoxExportApplianceWzd::exportVMs (CAppliance &aAppliance) 276 { 277 /* Write the appliance */ 278 CProgress progress = aAppliance.Write (mFileSelector->path()); 279 bool fResult = aAppliance.isOk(); 280 if (fResult) 281 { 282 /* Show some progress, so the user know whats going on */ 283 vboxProblem().showModalProgressDialog (progress, tr ("Exporting Appliance ..."), this); 284 if (!progress.isOk() || progress.GetResultCode() != 0) 285 { 286 vboxProblem().cannotExportAppliance (progress, &aAppliance, this); 287 return false; 288 } 289 else 290 return true; 291 } 292 if (!fResult) 293 vboxProblem().cannotExportAppliance (&aAppliance, this); 270 294 return false; 271 295 } -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxProblemReporter.cpp
r18071 r18132 452 452 } 453 453 454 bool VBoxProblemReporter::askForOverridingFilesIfExists (const QStringList& aPaths, QWidget *aParent /* = NULL */) const 455 { 456 QStringList existingFiles; 457 foreach (const QString &file, aPaths) 458 { 459 QFileInfo fi (file); 460 if (fi.exists()) 461 existingFiles << fi.absoluteFilePath(); 462 } 463 if (existingFiles.size() == 1) 464 /* If it is only one file use the single question versions above */ 465 return askForOverridingFileIfExists (existingFiles.at (0), aParent); 466 else if (existingFiles.size() > 1) 467 return messageYesNo (aParent, Question, tr ("The following files exists already:<br /><br />%1<br /><br />Are you sure you want to replace them? Replacing them will overwrite there contents.").arg (existingFiles.join ("<br />"))); 468 else 469 return true; 470 } 454 471 // Special Problem handlers 455 472 /////////////////////////////////////////////////////////////////////////////
Note:
See TracChangeset
for help on using the changeset viewer.