VirtualBox

Changeset 24791 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
Nov 19, 2009 2:36:21 PM (15 years ago)
Author:
vboxsync
Message:

FE/Qt4: Snapshot tree-widget: data-update fix.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxSnapshotsWgt.cpp

    r24789 r24791  
    8282        {
    8383            case Qt::DisplayRole:
    84                 return mIsCurrentState ? QTreeWidgetItem::data (aColumn, aRole) :
    85                        QVariant (QString ("%1%2").arg (QTreeWidgetItem::data (aColumn, aRole).toString()).arg (mAge));
     84                return mIsCurrentState ? QTreeWidgetItem::data (aColumn, aRole) : QVariant (QString ("%1%2")
     85                                         .arg (QTreeWidgetItem::data (aColumn, Qt::DisplayRole).toString())
     86                                         .arg (QTreeWidgetItem::data (aColumn, Qt::UserRole).toString()));
    8687            default:
    8788                break;
     
    175176    SnapshotAgeFormat updateAge()
    176177    {
    177         QString oldAge (mAge);
     178        QString age;
    178179
    179180        /* Age: [date time|%1d ago|%1h ago|%1min ago|%1sec ago] */
     
    181182        if (mTimestamp.daysTo (QDateTime::currentDateTime()) > 30)
    182183        {
    183             mAge = VBoxSnapshotsWgt::tr (" (%1)").arg (mTimestamp.toString (Qt::LocalDate));
     184            age = VBoxSnapshotsWgt::tr (" (%1)").arg (mTimestamp.toString (Qt::LocalDate));
    184185            ageFormat = AgeMax;
    185186        }
    186187        else if (mTimestamp.secsTo (QDateTime::currentDateTime()) > 60 * 60 * 24)
    187188        {
    188             mAge = VBoxSnapshotsWgt::tr (" (%n day(s) ago)", "", mTimestamp.secsTo (QDateTime::currentDateTime()) / 60 / 60 / 24);
     189            age = VBoxSnapshotsWgt::tr (" (%n day(s) ago)", "", mTimestamp.secsTo (QDateTime::currentDateTime()) / 60 / 60 / 24);
    189190            ageFormat = AgeInDays;
    190191        }
    191192        else if (mTimestamp.secsTo (QDateTime::currentDateTime()) > 60 * 60)
    192193        {
    193             mAge = VBoxSnapshotsWgt::tr (" (%n hour(s) ago)", "", mTimestamp.secsTo (QDateTime::currentDateTime()) / 60 / 60);
     194            age = VBoxSnapshotsWgt::tr (" (%n hour(s) ago)", "", mTimestamp.secsTo (QDateTime::currentDateTime()) / 60 / 60);
    194195            ageFormat = AgeInHours;
    195196        }
    196197        else if (mTimestamp.secsTo (QDateTime::currentDateTime()) > 60)
    197198        {
    198             mAge = VBoxSnapshotsWgt::tr (" (%n minute(s) ago)", "", mTimestamp.secsTo (QDateTime::currentDateTime()) / 60);
     199            age = VBoxSnapshotsWgt::tr (" (%n minute(s) ago)", "", mTimestamp.secsTo (QDateTime::currentDateTime()) / 60);
    199200            ageFormat = AgeInMinutes;
    200201        }
    201202        else
    202203        {
    203             mAge = VBoxSnapshotsWgt::tr (" (%n second(s) ago)", "", mTimestamp.secsTo (QDateTime::currentDateTime()));
     204            age = VBoxSnapshotsWgt::tr (" (%n second(s) ago)", "", mTimestamp.secsTo (QDateTime::currentDateTime()));
    204205            ageFormat = AgeInSeconds;
    205206        }
    206207
    207 #if 0
    208         if (mAge != oldAge)
    209             emitDataChanged();
    210 #endif
     208        /* Update data */
     209        setData (0, Qt::UserRole, age);
    211210
    212211        return ageFormat;
     
    278277    QString mDesc;
    279278    QDateTime mTimestamp;
    280     QString mAge;
    281279
    282280    bool mCurStateModified;
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