Changeset 24564 in vbox
- Timestamp:
- Nov 10, 2009 7:08:40 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleWnd.cpp
r24559 r24564 212 212 }; 213 213 Q_DECLARE_METATYPE (MountTarget); 214 215 int searchMaxSnapshotIndex (const CMachine &aMachine, const CSnapshot &aSnapshot, const QString &aNameTemplate) 216 { 217 int maxIndex = 0; 218 QRegExp regExp (QString ("^") + aNameTemplate.arg ("([0-9]+)") + QString ("$")); 219 if (!aSnapshot.isNull()) 220 { 221 /* Check the current snapshot name */ 222 QString name = aSnapshot.GetName(); 223 int pos = regExp.indexIn (name); 224 if (pos != -1) 225 maxIndex = regExp.cap (1).toInt() > maxIndex ? regExp.cap (1).toInt() : maxIndex; 226 /* Traversing all the snapshot children */ 227 foreach (const CSnapshot &child, aSnapshot.GetChildren()) 228 { 229 int maxIndexOfChildren = searchMaxSnapshotIndex (aMachine, child, aNameTemplate); 230 maxIndex = maxIndexOfChildren > maxIndex ? maxIndexOfChildren : maxIndex; 231 } 232 } 233 return maxIndex; 234 } 214 235 215 236 /** \class VBoxConsoleWnd … … 2010 2031 2011 2032 /* search for the max available filter index */ 2012 int maxSnapShotIndex = 0; 2013 QString snapShotName = tr ("Snapshot %1"); 2014 QRegExp regExp (QString ("^") + snapShotName.arg ("([0-9]+)") + QString ("$")); 2015 CSnapshot index = machine.GetSnapshot (QString::null); 2016 while (!index.isNull()) 2017 { 2018 /* Check the current snapshot name */ 2019 QString name = index.GetName(); 2020 int pos = regExp.indexIn (name); 2021 if (pos != -1) 2022 maxSnapShotIndex = regExp.cap (1).toInt() > maxSnapShotIndex ? 2023 regExp.cap (1).toInt() : maxSnapShotIndex; 2024 /* Traversing to the next child */ 2025 CSnapshotVector c = index.GetChildren(); 2026 if (c.size() > 0) 2027 index = c [0]; 2028 else 2029 break; 2030 } 2031 dlg.mLeName->setText (snapShotName.arg (maxSnapShotIndex + 1)); 2033 QString nameTemplate = tr ("Snapshot %1"); 2034 int maxSnapshotIndex = searchMaxSnapshotIndex (machine, machine.GetSnapshot (QString()), nameTemplate); 2035 dlg.mLeName->setText (nameTemplate.arg (++ maxSnapshotIndex)); 2032 2036 2033 2037 if (dlg.exec() == QDialog::Accepted)
Note:
See TracChangeset
for help on using the changeset viewer.