Changeset 24789 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Nov 19, 2009 1:33:42 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/VBoxSnapshotsWgt.cpp
r24784 r24789 46 46 SnapshotWgtItem (QTreeWidget *aTreeWidget, const CSnapshot &aSnapshot) 47 47 : QTreeWidgetItem (aTreeWidget, ItemType) 48 , mIsCurrentState (false) 48 49 , mSnapshot (aSnapshot) 49 50 { … … 53 54 SnapshotWgtItem (QTreeWidgetItem *aRootItem, const CSnapshot &aSnapshot) 54 55 : QTreeWidgetItem (aRootItem, ItemType) 56 , mIsCurrentState (false) 55 57 , mSnapshot (aSnapshot) 56 58 { … … 60 62 SnapshotWgtItem (QTreeWidget *aTreeWidget, const CMachine &aMachine) 61 63 : QTreeWidgetItem (aTreeWidget, ItemType) 64 , mIsCurrentState (true) 62 65 , mMachine (aMachine) 63 66 { … … 68 71 SnapshotWgtItem (QTreeWidgetItem *aRootItem, const CMachine &aMachine) 69 72 : QTreeWidgetItem (aRootItem, ItemType) 73 , mIsCurrentState (true) 70 74 , mMachine (aMachine) 71 75 { … … 78 82 { 79 83 case Qt::DisplayRole: 80 return QVariant (QString ("%1%2").arg (QTreeWidgetItem::data (aColumn, aRole).toString()).arg (mAge)); 84 return mIsCurrentState ? QTreeWidgetItem::data (aColumn, aRole) : 85 QVariant (QString ("%1%2").arg (QTreeWidgetItem::data (aColumn, aRole).toString()).arg (mAge)); 81 86 default: 82 87 break; … … 130 135 void recache() 131 136 { 132 if (!mSnapshot.isNull()) 133 { 134 mId = mSnapshot.GetId(); 135 setText (0, mSnapshot.GetName()); 136 mOnline = mSnapshot.GetOnline(); 137 setIcon (0, vboxGlobal().snapshotIcon (mOnline)); 138 mDesc = mSnapshot.GetDescription(); 139 mTimestamp.setTime_t (mSnapshot.GetTimeStamp() / 1000); 140 mCurStateModified = false; 141 } 142 else 137 if (mIsCurrentState) 143 138 { 144 139 Assert (!mMachine.isNull()); … … 153 148 QString::null; 154 149 } 150 else 151 { 152 Assert (!mSnapshot.isNull()); 153 mId = mSnapshot.GetId(); 154 setText (0, mSnapshot.GetName()); 155 mOnline = mSnapshot.GetOnline(); 156 setIcon (0, vboxGlobal().snapshotIcon (mOnline)); 157 mDesc = mSnapshot.GetDescription(); 158 mTimestamp.setTime_t (mSnapshot.GetTimeStamp() / 1000); 159 mCurStateModified = false; 160 } 155 161 adjustText(); 156 162 recacheToolTip(); … … 175 181 if (mTimestamp.daysTo (QDateTime::currentDateTime()) > 30) 176 182 { 177 mAge = VBoxSnapshotsWgt::tr (" [%1]").arg (mTimestamp.toString (Qt::LocalDate));183 mAge = VBoxSnapshotsWgt::tr (" (%1)").arg (mTimestamp.toString (Qt::LocalDate)); 178 184 ageFormat = AgeMax; 179 185 } 180 186 else if (mTimestamp.secsTo (QDateTime::currentDateTime()) > 60 * 60 * 24) 181 187 { 182 mAge = VBoxSnapshotsWgt::tr (" [%1d ago]").arg (mTimestamp.secsTo (QDateTime::currentDateTime()) / 60 / 60 / 24);188 mAge = VBoxSnapshotsWgt::tr (" (%n day(s) ago)", "", mTimestamp.secsTo (QDateTime::currentDateTime()) / 60 / 60 / 24); 183 189 ageFormat = AgeInDays; 184 190 } 185 191 else if (mTimestamp.secsTo (QDateTime::currentDateTime()) > 60 * 60) 186 192 { 187 mAge = VBoxSnapshotsWgt::tr (" [%1h ago]").arg (mTimestamp.secsTo (QDateTime::currentDateTime()) / 60 / 60);193 mAge = VBoxSnapshotsWgt::tr (" (%n hour(s) ago)", "", mTimestamp.secsTo (QDateTime::currentDateTime()) / 60 / 60); 188 194 ageFormat = AgeInHours; 189 195 } 190 196 else if (mTimestamp.secsTo (QDateTime::currentDateTime()) > 60) 191 197 { 192 mAge = VBoxSnapshotsWgt::tr (" [%1min ago]").arg (mTimestamp.secsTo (QDateTime::currentDateTime()) / 60);198 mAge = VBoxSnapshotsWgt::tr (" (%n minute(s) ago)", "", mTimestamp.secsTo (QDateTime::currentDateTime()) / 60); 193 199 ageFormat = AgeInMinutes; 194 200 } 195 201 else 196 202 { 197 mAge = VBoxSnapshotsWgt::tr (" [%1sec ago]").arg (mTimestamp.secsTo (QDateTime::currentDateTime()));203 mAge = VBoxSnapshotsWgt::tr (" (%n second(s) ago)", "", mTimestamp.secsTo (QDateTime::currentDateTime())); 198 204 ageFormat = AgeInSeconds; 199 205 } … … 262 268 setToolTip (0, toolTip); 263 269 } 270 271 bool mIsCurrentState; 264 272 265 273 CSnapshot mSnapshot;
Note:
See TracChangeset
for help on using the changeset viewer.