- Timestamp:
- Oct 2, 2013 5:43:12 PM (11 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/converter/UIConverterBackend.h
r48523 r48826 58 58 59 59 /* Declare global canConvert specializations: */ 60 template<> bool canConvert<SizeSuffix>(); 60 61 template<> bool canConvert<StorageSlot>(); 61 62 template<> bool canConvert<RuntimeMenuType>(); … … 91 92 92 93 /* Declare global conversion specializations: */ 94 template<> QString toString(const SizeSuffix &sizeSuffix); 95 template<> SizeSuffix fromString<SizeSuffix>(const QString &strSizeSuffix); 93 96 template<> QString toString(const StorageSlot &storageSlot); 94 97 template<> StorageSlot fromString<StorageSlot>(const QString &strStorageSlot); -
trunk/src/VBox/Frontends/VirtualBox/src/converter/UIConverterBackendGlobal.cpp
r47595 r48826 31 31 /* Determines if <Object of type X> can be converted to object of other type. 32 32 * These functions returns 'true' for all allowed conversions. */ 33 template<> bool canConvert<SizeSuffix>() { return true; } 33 34 template<> bool canConvert<StorageSlot>() { return true; } 34 35 template<> bool canConvert<RuntimeMenuType>() { return true; } … … 39 40 template<> bool canConvert<IndicatorType>() { return true; } 40 41 template<> bool canConvert<MachineCloseAction>() { return true; } 42 43 /* QString <= SizeSuffix: */ 44 template<> QString toString(const SizeSuffix &sizeSuffix) 45 { 46 QString strResult; 47 switch (sizeSuffix) 48 { 49 case SizeSuffix_Byte: strResult = QApplication::translate("VBoxGlobal", "B", "size suffix Bytes"); break; 50 case SizeSuffix_KiloByte: strResult = QApplication::translate("VBoxGlobal", "KB", "size suffix KBytes=1024 Bytes"); break; 51 case SizeSuffix_MegaByte: strResult = QApplication::translate("VBoxGlobal", "MB", "size suffix MBytes=1024 KBytes"); break; 52 case SizeSuffix_GigaByte: strResult = QApplication::translate("VBoxGlobal", "GB", "size suffix GBytes=1024 MBytes"); break; 53 case SizeSuffix_TeraByte: strResult = QApplication::translate("VBoxGlobal", "TB", "size suffix TBytes=1024 GBytes"); break; 54 case SizeSuffix_PetaByte: strResult = QApplication::translate("VBoxGlobal", "PB", "size suffix PBytes=1024 TBytes"); break; 55 default: 56 { 57 AssertMsgFailed(("No text for size suffix=%d", sizeSuffix)); 58 break; 59 } 60 } 61 return strResult; 62 } 63 64 /* SizeSuffix <= QString: */ 65 template<> SizeSuffix fromString<SizeSuffix>(const QString &strSizeSuffix) 66 { 67 QHash<QString, SizeSuffix> list; 68 list.insert(QApplication::translate("VBoxGlobal", "B", "size suffix Bytes"), SizeSuffix_Byte); 69 list.insert(QApplication::translate("VBoxGlobal", "KB", "size suffix KBytes=1024 Bytes"), SizeSuffix_KiloByte); 70 list.insert(QApplication::translate("VBoxGlobal", "MB", "size suffix MBytes=1024 KBytes"), SizeSuffix_MegaByte); 71 list.insert(QApplication::translate("VBoxGlobal", "GB", "size suffix GBytes=1024 MBytes"), SizeSuffix_GigaByte); 72 list.insert(QApplication::translate("VBoxGlobal", "TB", "size suffix TBytes=1024 GBytes"), SizeSuffix_TeraByte); 73 list.insert(QApplication::translate("VBoxGlobal", "PB", "size suffix PBytes=1024 TBytes"), SizeSuffix_PetaByte); 74 if (!list.contains(strSizeSuffix)) 75 { 76 AssertMsgFailed(("No value for '%s'", strSizeSuffix.toAscii().constData())); 77 } 78 return list.value(strSizeSuffix); 79 } 41 80 42 81 /* QString <= StorageSlot: */ -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIDefs.h
r48301 r48826 228 228 Q_DECLARE_METATYPE(StorageSlot); 229 229 230 /* Common UI size suffixes: */ 231 enum SizeSuffix 232 { 233 SizeSuffix_Byte = 0, 234 SizeSuffix_KiloByte, 235 SizeSuffix_MegaByte, 236 SizeSuffix_GigaByte, 237 SizeSuffix_TeraByte, 238 SizeSuffix_PetaByte, 239 SizeSuffix_Max 240 }; 241 230 242 /* Runtime UI menu types: */ 231 243 enum RuntimeMenuType -
trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp
r48685 r48826 2597 2597 FormatSize aMode /* = FormatSize_Round */) 2598 2598 { 2599 static QString Suffixes [7];2600 Suffixes[0] = tr ("B", "size suffix Bytes");2601 Suffixes[1] = tr ("KB", "size suffix KBytes=1024 Bytes");2602 Suffixes[2] = tr ("MB", "size suffix MBytes=1024 KBytes");2603 Suffixes[3] = tr ("GB", "size suffix GBytes=1024 MBytes");2604 Suffixes[4] = tr ("TB", "size suffix TBytes=1024 GBytes");2605 Suffixes[5] = tr ("PB", "size suffix PBytes=1024 TBytes");2606 Suffixes[6] = (const char *)NULL;2607 AssertCompile(6 < RT_ELEMENTS (Suffixes));2608 2609 2599 quint64 denom = 0; 2610 2600 int suffix = 0; … … 2667 2657 ++ intg; 2668 2658 /* check if we've got 1024 XB after rounding and scale down if so */ 2669 if (intg == 1024 && Suffixes [suffix + 1] != NULL)2659 if (intg == 1024 && suffix + 1 < (int)SizeSuffix_Max) 2670 2660 { 2671 2661 intg /= 1024; … … 2682 2672 } 2683 2673 2684 return QString ("%1 %2").arg (number).arg ( Suffixes [suffix]);2674 return QString ("%1 %2").arg (number).arg (gpConverter->toString(static_cast<SizeSuffix>(suffix))); 2685 2675 } 2686 2676
Note:
See TracChangeset
for help on using the changeset viewer.