VirtualBox

Changeset 38800 in vbox


Ignore:
Timestamp:
Sep 20, 2011 11:51:31 AM (13 years ago)
Author:
vboxsync
Message:

FE/Qt: allow manually sorting of the machine list

Location:
trunk/src/VBox/Frontends/VirtualBox/src/selector
Files:
6 edited

Legend:

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

    r38487 r38800  
    4646    m_Shortcuts[ShowVMInFileManagerShortcut] = UIKeySequence("ShowVMInFileManager");
    4747    m_Shortcuts[CreateVMAliasShortcut]       = UIKeySequence("CreateVMAlias");
     48    m_Shortcuts[ResortVMList]                = UIKeySequence("ResortVMList");
    4849    m_Shortcuts[HelpShortcut]                = UIKeySequence("Help",                QKeySequence::HelpContents);
    4950    m_Shortcuts[WebShortcut]                 = UIKeySequence("Web");
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UISelectorShortcuts.h

    r38487 r38800  
    4848        ShowVMInFileManagerShortcut,
    4949        CreateVMAliasShortcut,
     50        ResortVMList,
    5051        HelpShortcut,
    5152        WebShortcut,
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UIVMListView.cpp

    r38311 r38800  
    149149}
    150150
    151 void UIVMItemModel::sortByIdList(const QStringList &list)
     151void UIVMItemModel::sortByIdList(const QStringList &list, Qt::SortOrder order /* = Qt::AscendingOrder */)
    152152{
    153153    emit layoutAboutToBeChanged();
     
    175175    if (tmpVMItemList.count() > 0)
    176176    {
    177         qSort(tmpVMItemList.begin(), tmpVMItemList.end(), UIVMItemNameCompareLessThan);
     177        qSort(tmpVMItemList.begin(), tmpVMItemList.end(), order == Qt::AscendingOrder ? UIVMItemNameCompareLessThan : UIVMItemNameCompareMoreThan);
    178178        QListIterator<UIVMItem*> it(tmpVMItemList);
    179179        while (it.hasNext())
     
    291291    Assert(aItem2);
    292292    return aItem1->name().toLower() < aItem2->name().toLower();
     293}
     294
     295bool UIVMItemModel::UIVMItemNameCompareMoreThan(UIVMItem* aItem1, UIVMItem* aItem2)
     296{
     297    Assert(aItem1);
     298    Assert(aItem2);
     299    return aItem1->name().toLower() > aItem2->name().toLower();
    293300}
    294301
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UIVMListView.h

    r34096 r38800  
    6363
    6464    QStringList idList() const;
    65     void sortByIdList(const QStringList &list);
     65    void sortByIdList(const QStringList &list, Qt::SortOrder order = Qt::AscendingOrder);
    6666
    6767    int rowCount(const QModelIndex &aParent = QModelIndex()) const;
     
    8282private:
    8383    static bool UIVMItemNameCompareLessThan(UIVMItem* aItem1, UIVMItem* aItem2);
     84    static bool UIVMItemNameCompareMoreThan(UIVMItem* aItem1, UIVMItem* aItem2);
    8485
    8586    /* Private member vars */
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/VBoxSelectorWnd.cpp

    r38487 r38800  
    191191    mVmOpenInFileManagerAction->setIcon(UIIconPool::iconSet(
    192192        ":/vm_open_filemanager_16px.png", ":/vm_open_filemanager_disabled_16px.png"));
    193     mVmCreateShortcut = new QAction(this);
    194     mVmCreateShortcut->setIcon(UIIconPool::iconSet(
     193    mVmCreateShortcutAction = new QAction(this);
     194    mVmCreateShortcutAction->setIcon(UIIconPool::iconSet(
    195195        ":/vm_create_shortcut_16px.png", ":/vm_create_shortcut_disabled_16px.png"));
     196    mVmResortAction = new QAction(this);
    196197
    197198    /* VM list toolbar */
     
    320321    mVMMenu->addSeparator();
    321322    mVMMenu->addAction(mVmOpenInFileManagerAction);
    322     mVMMenu->addAction(mVmCreateShortcut);
     323    mVMMenu->addAction(mVmCreateShortcutAction);
     324    mVMMenu->addSeparator();
     325    mVMMenu->addAction(mVmResortAction);
    323326
    324327#ifdef Q_WS_MAC
     
    341344    mVMCtxtMenu->addSeparator();
    342345    mVMCtxtMenu->addAction(mVmOpenInFileManagerAction);
    343     mVMCtxtMenu->addAction(mVmCreateShortcut);
     346    mVMCtxtMenu->addAction(mVmCreateShortcutAction);
     347    mVMCtxtMenu->addSeparator();
     348    mVMCtxtMenu->addAction(mVmResortAction);
    344349
    345350    /* Make sure every status bar hint from the context menu is cleared when
     
    473478    connect(mVmShowLogsAction, SIGNAL(triggered()), this, SLOT(vmShowLogs()));
    474479    connect(mVmOpenInFileManagerAction, SIGNAL(triggered()), this, SLOT(vmOpenInFileManager()));
    475     connect(mVmCreateShortcut, SIGNAL(triggered()), this, SLOT(vmCreateShortcut()));
     480    connect(mVmCreateShortcutAction, SIGNAL(triggered()), this, SLOT(vmCreateShortcut()));
     481    connect(mVmResortAction, SIGNAL(triggered()), this, SLOT(vmResort()));
    476482
    477483    connect(mVMCloseMenu, SIGNAL(aboutToShow()), this, SLOT(sltCloseMenuAboutToShow()));
     
    10371043    CMachine machine = item->machine();
    10381044    UIDesktopServices::createMachineShortcut(machine.GetSettingsFilePath(), QDesktopServices::storageLocation(QDesktopServices::DesktopLocation), machine.GetName(), machine.GetId());
     1045}
     1046
     1047void VBoxSelectorWnd::vmResort(const QString &aUuid /* = QString::null */)
     1048{
     1049    UIVMItem *item = aUuid.isNull() ? mVMListView->selectedItem() :
     1050                       mVMModel->itemById(aUuid);
     1051    const QString oldId = item->id();
     1052
     1053    AssertMsgReturnVoid(item, ("Item must be always selected here"));
     1054
     1055    mVMModel->sortByIdList(QStringList(),
     1056                           qApp->keyboardModifiers() == Qt::ShiftModifier ? Qt::DescendingOrder : Qt::AscendingOrder);
     1057    /* Select the VM which was selected before */
     1058    mVMListView->selectItemById(oldId);
    10391059}
    10401060
     
    14101430    mVmOpenInFileManagerAction->setText(tr("Show in Finder"));
    14111431    mVmOpenInFileManagerAction->setStatusTip(tr("Show the VirtualBox Machine Definition file in Finder."));
    1412     mVmCreateShortcut->setText(tr("Create Alias on Desktop"));
    1413     mVmCreateShortcut->setStatusTip(tr("Creates an Alias file to the VirtualBox Machine Definition file on your Desktop."));
     1432    mVmCreateShortcutAction->setText(tr("Create Alias on Desktop"));
     1433    mVmCreateShortcutAction->setStatusTip(tr("Creates an Alias file to the VirtualBox Machine Definition file on your Desktop."));
    14141434#elif defined(Q_WS_WIN)
    14151435    mVmOpenInFileManagerAction->setText(tr("Show in Explorer"));
    14161436    mVmOpenInFileManagerAction->setStatusTip(tr("Show the VirtualBox Machine Definition file in Explorer."));
    1417     mVmCreateShortcut->setText(tr("Create Shortcut on Desktop"));
    1418     mVmCreateShortcut->setStatusTip(tr("Creates an Shortcut file to the VirtualBox Machine Definition file on your Desktop."));
     1437    mVmCreateShortcutAction->setText(tr("Create Shortcut on Desktop"));
     1438    mVmCreateShortcutAction->setStatusTip(tr("Creates an Shortcut file to the VirtualBox Machine Definition file on your Desktop."));
    14191439#else
    14201440    mVmOpenInFileManagerAction->setText(tr("Show in File Manager"));
    14211441    mVmOpenInFileManagerAction->setStatusTip(tr("Show the VirtualBox Machine Definition file in the File Manager"));
    1422     mVmCreateShortcut->setText(tr("Create Shortcut on Desktop"));
    1423     mVmCreateShortcut->setStatusTip(tr("Creates an Shortcut file to the VirtualBox Machine Definition file on your Desktop."));
     1442    mVmCreateShortcutAction->setText(tr("Create Shortcut on Desktop"));
     1443    mVmCreateShortcutAction->setStatusTip(tr("Creates an Shortcut file to the VirtualBox Machine Definition file on your Desktop."));
    14241444#endif
    14251445    mVmOpenInFileManagerAction->setShortcut(gSS->keySequence(UISelectorShortcuts::ShowVMInFileManagerShortcut));
    1426     mVmCreateShortcut->setShortcut(gSS->keySequence(UISelectorShortcuts::CreateVMAliasShortcut));
     1446    mVmCreateShortcutAction->setShortcut(gSS->keySequence(UISelectorShortcuts::CreateVMAliasShortcut));
     1447    mVmResortAction->setShortcut(gSS->keySequence(UISelectorShortcuts::ResortVMList));
     1448    mVmResortAction->setText(tr("Sort List"));
     1449    mVmResortAction->setStatusTip(tr("Sort the VM list alphabetically (Shift for descending order)"));
    14271450
    14281451#ifdef Q_WS_MAC
     
    15731596         * legacy xml files. On the other OS's some kind of start up script is
    15741597         * used. */
    1575         mVmCreateShortcut->setEnabled(item->settingsFile().endsWith(".vbox", Qt::CaseInsensitive));
     1598        mVmCreateShortcutAction->setEnabled(item->settingsFile().endsWith(".vbox", Qt::CaseInsensitive));
    15761599#else /* Q_WS_MAC */
    1577         mVmCreateShortcut->setEnabled(true);
     1600        mVmCreateShortcutAction->setEnabled(true);
    15781601#endif /* Q_WS_MAC */
     1602        mVmResortAction->setEnabled(true);
    15791603    }
    15801604    else
     
    16371661        /* Disable the shell interaction features. */
    16381662        mVmOpenInFileManagerAction->setEnabled(false);
    1639         mVmCreateShortcut->setEnabled(false);
     1663        mVmCreateShortcutAction->setEnabled(false);
     1664        /* Disable sorting if there is nothing to sort. */
     1665        mVmResortAction->setEnabled(false);
    16401666    }
    16411667}
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/VBoxSelectorWnd.h

    r38487 r38800  
    8282    void vmOpenInFileManager(const QString &aUuid = QString::null);
    8383    void vmCreateShortcut(const QString &aUuid = QString::null);
     84    void vmResort(const QString &aUuid = QString::null);
    8485    void sltCloseMenuAboutToShow();
    8586
     
    186187    QAction *mVmShowLogsAction;
    187188    QAction *mVmOpenInFileManagerAction;
    188     QAction *mVmCreateShortcut;
     189    QAction *mVmCreateShortcutAction;
     190    QAction *mVmResortAction;
    189191
    190192#ifdef VBOX_GUI_WITH_SYSTRAY
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