VirtualBox

Changeset 76296 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Dec 19, 2018 4:17:39 PM (6 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:6699. Refactoring some classes to improve decoupling. I will need those in viso creator dialog.

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

Legend:

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

    r76177 r76296  
    281281        m_panelActionMap.insert(m_pOptionsPanel, m_pActionPool->action(UIActionIndex_M_FileManager_T_Options));
    282282        connect(m_pOptionsPanel, &UIFileManagerOptionsPanel::sigOptionsChanged,
    283                 this, &UIFileManager::sltListDirectoriesBeforeChanged);
     283                this, &UIFileManager::sltHandleOptionsUpdated);
    284284        pTopLayout->addWidget(m_pOptionsPanel);
    285285    }
     
    519519}
    520520
    521 void UIFileManager::sltListDirectoriesBeforeChanged()
    522 {
    523     if (m_pGuestFileTable)
    524         m_pGuestFileTable->relist();
    525     if (m_pHostFileTable)
    526         m_pHostFileTable->relist();
    527 }
    528 
    529521void UIFileManager::sltReceieveNewFileOperation(const CProgress &comProgress)
    530522{
     
    549541        m_pOptionsPanel->update();
    550542    }
     543
     544    if (m_pGuestFileTable)
     545        m_pGuestFileTable->optionsUpdated();
     546    if (m_pHostFileTable)
     547        m_pHostFileTable->optionsUpdated();
    551548}
    552549
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManager.h

    r76177 r76296  
    116116    void sltCopyHostToGuest();
    117117    void sltPanelActionToggled(bool fChecked);
    118     void sltListDirectoriesBeforeChanged();
    119118    void sltReceieveNewFileOperation(const CProgress &comProgress);
    120119    void sltFileOperationComplete(QUuid progressId);
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerModel.cpp

    r76177 r76296  
    2929# include "UIFileManagerTable.h"
    3030# include "UIFileManager.h"
    31 
     31# include "VBoxGlobal.h"
    3232
    3333#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
     
    3737UIGuestControlFileProxyModel::UIGuestControlFileProxyModel(QObject *parent /* = 0 */)
    3838    :QSortFilterProxyModel(parent)
    39 {
     39    , m_fListDirectoriesOnTop(false)
     40{
     41}
     42
     43void UIGuestControlFileProxyModel::setListDirectoriesOnTop(bool fListDirectoriesOnTop)
     44{
     45    m_fListDirectoriesOnTop = fListDirectoriesOnTop;
     46}
     47
     48bool UIGuestControlFileProxyModel::listDirectoriesOnTop() const
     49{
     50    return m_fListDirectoriesOnTop;
    4051}
    4152
     
    4556    UIFileTableItem *pRightItem = static_cast<UIFileTableItem*>(right.internalPointer());
    4657
    47     UIFileManagerOptions *pOptions = UIFileManagerOptions::instance();
    48 
    4958    if (pLeftItem && pRightItem)
    5059    {
    5160        /* List the directories before the files if options say so: */
    52         if (pOptions && pOptions->bListDirectoriesOnTop)
     61        if (m_fListDirectoriesOnTop)
    5362        {
    5463            if ((pLeftItem->isDirectory() || pLeftItem->isSymLinkToADirectory()) && !pRightItem->isDirectory())
     
    8796    : QAbstractItemModel(parent)
    8897    , m_pParent(qobject_cast<UIFileManagerTable*>(parent))
     98    , m_fShowHumanReadableSizes(false)
    8999{
    90100}
     
    161171        if (index.column() == UIFileManagerModelColumn_Size)
    162172        {
    163             UIFileManagerOptions* pOptions =
    164                 UIFileManagerOptions::instance();
    165             if (pOptions && pOptions->bShowHumanReadableSizes)
     173            if (m_fShowHumanReadableSizes)
    166174            {
    167175                qulonglong size = item->data(index.column()).toULongLong();
    168                 return UIFileManagerTable::humanReadableSize(size);
     176                return vboxGlobal().formatSize(size);
    169177            }
    170178            else
     
    305313    endResetModel();
    306314}
     315
     316void UIFileManagerModel::setShowHumanReadableSizes(bool fShowHumanReadableSizes)
     317{
     318    m_fShowHumanReadableSizes = fShowHumanReadableSizes;
     319}
     320
     321bool UIFileManagerModel::showHumanReadableSizes() const
     322{
     323    return m_fShowHumanReadableSizes;
     324}
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerModel.h

    r76177 r76296  
    5151    UIGuestControlFileProxyModel(QObject *parent = 0);
    5252
     53    void setListDirectoriesOnTop(bool fListDirectoriesOnTop);
     54    bool listDirectoriesOnTop() const;
     55
    5356protected:
    5457
    5558    bool lessThan(const QModelIndex &left, const QModelIndex &right) const /* override */;
     59
     60private:
     61
     62    bool m_fListDirectoriesOnTop;
    5663};
    5764
     
    8794    void           beginReset();
    8895    void           endReset();
     96    void           setShowHumanReadableSizes(bool fShowHumanReadableSizes);
     97    bool           showHumanReadableSizes() const;
     98
    8999    static const char* strUpDirectoryString;
    90100
     
    95105    UIFileManagerTable *m_pParent;
    96106    UIFileTableItem    *m_pRootItem;
     107    bool                m_fShowHumanReadableSizes;
     108
    97109};
    98110
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerTable.cpp

    r76177 r76296  
    822822                this, &UIFileManagerTable::sltSearchTextChanged);
    823823    }
     824    optionsUpdated();
    824825}
    825826
     
    14811482}
    14821483
     1484void UIFileManagerTable::optionsUpdated()
     1485{
     1486    UIFileManagerOptions *pOptions = UIFileManagerOptions::instance();
     1487    if (pOptions)
     1488    {
     1489        if (m_pProxyModel)
     1490            m_pProxyModel->setListDirectoriesOnTop(pOptions->bListDirectoriesOnTop);
     1491        if (m_pModel)
     1492            m_pModel->setShowHumanReadableSizes(pOptions->bShowHumanReadableSizes);
     1493    }
     1494    relist();
     1495}
     1496
     1497
    14831498void UIFileManagerTable::sltReceiveDirectoryStatistics(UIDirectoryStatistics statistics)
    14841499{
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerTable.h

    r76177 r76296  
    263263    QStringList selectedItemPathList();
    264264    virtual void refresh();
    265     void         relist();
    266265    static const unsigned    m_iKiloByte;
    267266    static QString humanReadableSize(ULONG64 size);
     267    /** Peroforms whatever is necessary after a UIFileManagerOptions change. */
     268    void optionsUpdated();
    268269
    269270public slots:
     
    370371private:
    371372
     373    void             relist();
    372374    void             prepareObjects();
    373375    /** @p itemIndex is assumed to be 'model' index not 'proxy model' index */
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