VirtualBox

Changeset 74947 in vbox


Ignore:
Timestamp:
Oct 19, 2018 3:03:34 PM (6 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:6699. Improving sort/filter functionality of the guest control file manager

Location:
trunk/src/VBox/Frontends/VirtualBox/src/runtime
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/guestctrl/UIGuestControlFileManager.cpp

    r71693 r74947  
    5858#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
    5959
     60UIGuestControlFileManagerSettings *UIGuestControlFileManagerSettings::m_pInstance = 0;
     61
     62UIGuestControlFileManagerSettings* UIGuestControlFileManagerSettings::instance()
     63{
     64    return m_pInstance;
     65}
     66
     67void UIGuestControlFileManagerSettings::create()
     68{
     69    if (m_pInstance)
     70        return;
     71    m_pInstance = new UIGuestControlFileManagerSettings;
     72}
     73
     74void UIGuestControlFileManagerSettings::destroy()
     75{
     76    delete m_pInstance;
     77}
     78
     79UIGuestControlFileManagerSettings::UIGuestControlFileManagerSettings()
     80    : bListDirectoriesOnTop(true)
     81{
     82}
     83
    6084/*********************************************************************************************************************************
    6185*   UIFileOperationsList definition.                                                                                   *
     
    284308    retranslateUi();
    285309    loadSettings();
     310    UIGuestControlFileManagerSettings::create();
    286311}
    287312
     
    293318        cleanupListener(m_pQtSessionListener, m_comSessionListener, m_comGuestSession.GetEventSource());
    294319    saveSettings();
     320    UIGuestControlFileManagerSettings::destroy();
    295321}
    296322
     
    364390            m_pFileTableContainerLayout->setSpacing(0);
    365391            m_pFileTableContainerLayout->setContentsMargins(0, 0, 0, 0);
    366             m_pGuestFileTable = new UIGuestFileTable;
     392            m_pGuestFileTable = new  UIGuestFileTable;
    367393            m_pGuestFileTable->setEnabled(false);
    368394
     
    713739
    714740#include "UIGuestControlFileManager.moc"
    715 
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/guestctrl/UIGuestControlFileManager.h

    r72151 r74947  
    4848class UIToolBar;
    4949
     50class UIGuestControlFileManagerSettings
     51{
     52public:
     53    static UIGuestControlFileManagerSettings* instance();
     54    static void create();
     55    static void destroy();
     56
     57    bool bListDirectoriesOnTop;
     58private:
     59    UIGuestControlFileManagerSettings();
     60
     61
     62    static UIGuestControlFileManagerSettings *m_pInstance;
     63};
    5064
    5165/** A QWidget extension. it includes a QWidget extension for initiating a guest session
     
    6074    UIGuestControlFileManager(QWidget *pParent, const CGuest &comGuest);
    6175    ~UIGuestControlFileManager();
     76    //const UIGuestControlFileManagerSettings& settings() const;
    6277
    6378protected:
     
    127142    CEventListener m_comSessionListener;
    128143    CEventListener m_comGuestListener;
     144    //UIGuestControlFileManagerSettings m_settings;
    129145};
    130146
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/guestctrl/UIGuestControlFileModel.cpp

    r72086 r74947  
    2828# include "UIGuestControlFileModel.h"
    2929# include "UIGuestControlFileTable.h"
     30# include "UIGuestControlFileManager.h"
    3031
    3132
     
    4142bool UIGuestControlFileProxyModel::lessThan(const QModelIndex &left, const QModelIndex &right) const
    4243{
    43     QVariant leftData = sourceModel()->data(left);
    44     QVariant rightData = sourceModel()->data(right);
    45 
    46     if (leftData.canConvert(QMetaType::QString) && rightData.canConvert(QMetaType::QString))
    47     {
    48 
    49         if (leftData == UIGuestControlFileModel::strUpDirectoryString)
     44    UIFileTableItem *pLeftItem = static_cast<UIFileTableItem*>(left.internalPointer());
     45    UIFileTableItem *pRightItem = static_cast<UIFileTableItem*>(right.internalPointer());
     46
     47    UIGuestControlFileManagerSettings *settings = UIGuestControlFileManagerSettings::instance();
     48
     49    if (pLeftItem && pRightItem)
     50    {
     51        /* List the directories before the files if settings say so: */
     52        if (settings && settings->bListDirectoriesOnTop)
     53        {
     54            if (pLeftItem->isDirectory() && !pRightItem->isDirectory())
     55                return true && (sortOrder() == Qt::AscendingOrder);
     56            if (!pLeftItem->isDirectory() && pRightItem->isDirectory())
     57                return false && (sortOrder() == Qt::AscendingOrder);
     58        }
     59        /* Up directory item should be always the first item: */
     60        if (pLeftItem->isUpDirectory())
    5061            return true && (sortOrder() == Qt::AscendingOrder);
    51         else if (rightData == UIGuestControlFileModel::strUpDirectoryString)
     62        else if (pRightItem->isUpDirectory())
    5263            return false && (sortOrder() == Qt::AscendingOrder);
    5364    }
    54 
    5565    return QSortFilterProxyModel::lessThan(left, right);
    5666}
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/guestctrl/UIGuestControlFileModel.h

    r72086 r74947  
    6161    ~UIGuestControlFileModel();
    6262
    63     QVariant data(const QModelIndex &index, int role) const /* override */;
    64     bool setData(const QModelIndex &index, const QVariant &value, int role);
     63    QVariant       data(const QModelIndex &index, int role) const /* override */;
     64    bool           setData(const QModelIndex &index, const QVariant &value, int role);
    6565
    66     Qt::ItemFlags flags(const QModelIndex &index) const /* override */;
    67     QVariant headerData(int section, Qt::Orientation orientation,
     66    Qt::ItemFlags  flags(const QModelIndex &index) const /* override */;
     67    QVariant       headerData(int section, Qt::Orientation orientation,
    6868    int role = Qt::DisplayRole) const /* override */;
    69     QModelIndex index(int row, int column,
     69    QModelIndex    index(int row, int column,
    7070                      const QModelIndex &parent = QModelIndex()) const /* override */;
    71     QModelIndex index(UIFileTableItem* item);
    72     QModelIndex parent(const QModelIndex &index) const /* override */;
    73     int rowCount(const QModelIndex &parent = QModelIndex()) const /* override */;
    74     int columnCount(const QModelIndex &parent = QModelIndex()) const /* override */;
    75     void signalUpdate();
    76     QModelIndex rootIndex() const;
    77     void beginReset();
    78     void endReset();
    79     bool insertRows(int position, int rows, const QModelIndex &parent);
     71    QModelIndex    index(UIFileTableItem* item);
     72    QModelIndex    parent(const QModelIndex &index) const /* override */;
     73    int            rowCount(const QModelIndex &parent = QModelIndex()) const /* override */;
     74    int            columnCount(const QModelIndex &parent = QModelIndex()) const /* override */;
     75    void           signalUpdate();
     76    QModelIndex    rootIndex() const;
     77    void           beginReset();
     78    void           endReset();
     79    bool           insertRows(int position, int rows, const QModelIndex &parent);
    8080    static const char* strUpDirectoryString;
    8181
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/guestctrl/UIGuestFileTable.cpp

    r72086 r74947  
    11/* $Id$ */
    22/** @file
    3  * VBox Qt GUI - UIGuestControlFileTable class implementation.
     3 * VBox Qt GUI - UIGuestFileTable class implementation.
    44 */
    55
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/guestctrl/UIGuestFileTable.h

    r72086 r74947  
    11/* $Id$ */
    22/** @file
    3  * VBox Qt GUI - UIGuestControlFileTable class declaration.
     3 * VBox Qt GUI - UIGuestFileTable class declaration.
    44 */
    55
     
    6262};
    6363
    64 #endif /* !___UIGuestControlFileTable_h___ */
     64#endif /* !___UIGuestFileTable_h___ */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/guestctrl/UIHostFileTable.h

    r72151 r74947  
    11/* $Id$ */
    22/** @file
    3  * VBox Qt GUI - UIGuestControlFileTable class declaration.
     3 * VBox Qt GUI - UIHostFileTable class declaration.
    44 */
    55
     
    5151};
    5252
    53 #endif /* !___UIGuestControlFileTable_h___ */
     53#endif /* !___UIHostFileTable_h___ */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/UIVMInformationDialog.cpp

    r74940 r74947  
    121121    m_pTabWidget->setTabText(0, tr("Configuration &Details"));
    122122    m_pTabWidget->setTabText(1, tr("&Runtime Information"));
    123     m_pTabWidget->setTabText(2, tr("&Guest Session Manager"));
    124     m_pTabWidget->setTabText(3, tr("&Guest File Manager"));
     123    m_pTabWidget->setTabText(2, tr("Guest &Session Manager"));
     124    m_pTabWidget->setTabText(3, tr("Guest &File Manager"));
    125125}
    126126
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