VirtualBox

Changeset 9079 in vbox for trunk/src


Ignore:
Timestamp:
May 23, 2008 12:57:29 PM (17 years ago)
Author:
vboxsync
Message:

VBoxMediaComboBox: Merging alphabetical order and some ordering fixes into qt4 front-end.

Location:
trunk/src/VBox/Frontends/VirtualBox4
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox4/include/VBoxMediaComboBox.h

    r8155 r9079  
    4545    void  setUseEmptyItem (bool);
    4646    void  setBelongsTo (const QUuid &);
    47     QUuid getId();
     47    QUuid getId (int aId = -1);
    4848    QUuid getBelongsTo();
    4949    void  setCurrentItem (const QUuid &);
  • trunk/src/VBox/Frontends/VirtualBox4/src/VBoxMediaComboBox.cpp

    r8155 r9079  
    258258}
    259259
    260 QUuid VBoxMediaComboBox::getId()
    261 {
    262     return mUuidList.isEmpty() ? QUuid() : QUuid (mUuidList [currentItem()]);
     260QUuid VBoxMediaComboBox::getId (int aId)
     261{
     262    return mUuidList.isEmpty() ? QUuid() :
     263           aId == -1 ? QUuid (mUuidList [currentItem()]) :
     264           QUuid (mUuidList [aId]);
    263265}
    264266
     
    268270                                    QPixmap       *aPixmap)
    269271{
    270     aPixmap ? insertItem (*aPixmap, aName) : insertItem (aName);
    271     mUuidList << aId;
    272     mTipList  << aTip;
     272    int currentIndex = currentItem();
     273
     274    int insertPosition = -1;
     275    for (int i = 0; i < count(); ++ i)
     276        /* Searching for the first real (non-null) vdi item
     277           which have name greater than the item to be inserted.
     278           This is necessary for sorting items alphabetically. */
     279        if (text (i).localeAwareCompare (aName) > 0 &&
     280            !getId (i).isNull())
     281        {
     282            insertPosition = i;
     283            break;
     284        }
     285
     286    insertPosition == -1 ? mUuidList.append (aId) :
     287        mUuidList.insert (insertPosition, aId);
     288
     289    insertPosition == -1 ? mTipList.append (aId) :
     290        mTipList.insert (insertPosition, aTip);
     291
     292    aPixmap ? insertItem (*aPixmap, aName, insertPosition) :
     293              insertItem (aName, insertPosition);
     294
     295    if (insertPosition != -1 && currentIndex >= insertPosition)
     296        QComboBox::setCurrentItem (currentIndex + 1);
    273297}
    274298
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