VirtualBox

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


Ignore:
Timestamp:
Jan 3, 2019 9:18:50 PM (6 years ago)
Author:
vboxsync
Message:

FE/Qt: 6699: Add an option to show/hide hidden file objects

Location:
trunk/src/VBox/Frontends/VirtualBox/src
Files:
14 edited

Legend:

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

    r76606 r76626  
    203203const char *UIExtraDataDefs::GUI_GuestControl_FileManagerShowDeleteConfirmation = "ShowDeleteConfimation";
    204204const char *UIExtraDataDefs::GUI_GuestControl_FileManagerShowHumanReadableSizes = "ShowHumanReadableSizes";
     205const char *UIExtraDataDefs::GUI_GuestControl_FileManagerShowHiddenObjects = "ShowHiddenObjects";
    205206
    206207/* Virtual Machine: Close dialog: */
  • trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataDefs.h

    r76581 r76626  
    374374        extern const char *GUI_GuestControl_FileManagerShowDeleteConfirmation;
    375375        extern const char *GUI_GuestControl_FileManagerShowHumanReadableSizes;
     376        extern const char *GUI_GuestControl_FileManagerShowHiddenObjects;
    376377    /** @} */
    377378
  • trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.cpp

    r76606 r76626  
    42404240
    42414241void UIExtraDataManager::setFileManagerOptions(bool fListDirectoriesFirst,
    4242                                                bool fShowDeleteConfirmation, bool fShowHumanReadableSizes)
     4242                                               bool fShowDeleteConfirmation,
     4243                                               bool fShowHumanReadableSizes,
     4244                                               bool fShowHiddenObjects)
    42434245{
    42444246    /* Serialize passed values: */
     
    42514253    if (fShowHumanReadableSizes)
    42524254        data << GUI_GuestControl_FileManagerShowHumanReadableSizes;
    4253 
     4255    if (fShowHiddenObjects)
     4256        data << GUI_GuestControl_FileManagerShowHiddenObjects;
    42544257    /* Re-cache corresponding extra-data: */
    42554258    setExtraDataStringList(GUI_GuestControl_FileManagerOptions, data);
     
    42844287    {
    42854288        if (data[i] == GUI_GuestControl_FileManagerShowHumanReadableSizes)
     4289            return true;
     4290    }
     4291    return false;
     4292}
     4293
     4294bool UIExtraDataManager::fileManagerShowHiddenObjects()
     4295{
     4296    const QStringList data = extraDataStringList(GUI_GuestControl_FileManagerOptions);
     4297    for (int i = 0; i < data.size(); ++i)
     4298    {
     4299        if (data[i] == GUI_GuestControl_FileManagerShowHiddenObjects)
    42864300            return true;
    42874301    }
  • trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.h

    r76581 r76626  
    654654      * @{ */
    655655        void setFileManagerOptions(bool fListDirectoriesFirst,
    656                                    bool fShowDeleteConfirmation, bool fshowHumanReadableSizes);
     656                                   bool fShowDeleteConfirmation,
     657                                   bool fshowHumanReadableSizes,
     658                                   bool fShowHiddenObjects);
    657659        bool fileManagerListDirectoriesFirst();
    658660        bool fileManagerShowDeleteConfirmation();
    659661        bool fileManagerShowHumanReadableSizes();
     662        bool fileManagerShowHiddenObjects();
    660663    /** @} */
    661664
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UICustomFileSystemModel.cpp

    r76621 r76626  
    3737    : m_parentItem(parent)
    3838    , m_bIsOpened(false)
    39     , m_isTargetADirectory(false)
     39    , m_fIsTargetADirectory(false)
    4040    , m_type(type)
    41     , m_isDriveItem(false)
     41    , m_fIsDriveItem(false)
     42    , m_fIsHidden(false)
    4243{
    4344    for (int i = static_cast<int>(UICustomFileSystemModelColumn_Name);
     
    201202bool UICustomFileSystemItem::isSymLinkToADirectory() const
    202203{
    203     return m_isTargetADirectory;
     204    return m_fIsTargetADirectory;
    204205}
    205206
    206207void UICustomFileSystemItem::setIsSymLinkToADirectory(bool flag)
    207208{
    208     m_isTargetADirectory = flag;
     209    m_fIsTargetADirectory = flag;
    209210}
    210211
    211212bool UICustomFileSystemItem::isSymLinkToAFile() const
    212213{
    213     return isSymLink() && !m_isTargetADirectory;
     214    return isSymLink() && !m_fIsTargetADirectory;
    214215}
    215216
    216217void UICustomFileSystemItem::setIsDriveItem(bool flag)
    217218{
    218     m_isDriveItem = flag;
     219    m_fIsDriveItem = flag;
    219220}
    220221
    221222bool UICustomFileSystemItem::isDriveItem() const
    222223{
    223     return m_isDriveItem;
     224    return m_fIsDriveItem;
     225}
     226
     227void UICustomFileSystemItem::setIsHidden(bool flag)
     228{
     229    m_fIsHidden = flag;
     230}
     231
     232bool UICustomFileSystemItem::isHidden() const
     233{
     234    return m_fIsHidden;
    224235}
    225236
     
    229240*********************************************************************************************************************************/
    230241
    231 bool UICustomFileSystemProxyModel::listDirectoriesOnTop() const
    232 {
    233     return m_fListDirectoriesOnTop;
     242UICustomFileSystemProxyModel::UICustomFileSystemProxyModel(QObject *parent /* = 0 */)
     243    :QSortFilterProxyModel(parent)
     244    , m_fListDirectoriesOnTop(false)
     245    , m_fShowHiddenObjects(true)
     246{
    234247}
    235248
     
    276289}
    277290
    278 UICustomFileSystemProxyModel::UICustomFileSystemProxyModel(QObject *parent /* = 0 */)
    279     :QSortFilterProxyModel(parent)
    280     , m_fListDirectoriesOnTop(false)
    281 {
     291bool UICustomFileSystemProxyModel::filterAcceptsRow(int iSourceRow, const QModelIndex &sourceParent) const
     292{
     293    if (m_fShowHiddenObjects)
     294        return true;
     295
     296    QModelIndex itemIndex = sourceModel()->index(iSourceRow, 0, sourceParent);
     297    if (!itemIndex.isValid())
     298        return false;
     299
     300    UICustomFileSystemItem *item = static_cast<UICustomFileSystemItem*>(itemIndex.internalPointer());
     301    if (!item)
     302        return false;
     303
     304    if (item->isHidden())
     305        return false;
     306
     307    return true;
    282308}
    283309
     
    285311{
    286312    m_fListDirectoriesOnTop = fListDirectoriesOnTop;
     313}
     314
     315bool UICustomFileSystemProxyModel::listDirectoriesOnTop() const
     316{
     317    return m_fListDirectoriesOnTop;
     318}
     319
     320void UICustomFileSystemProxyModel::setShowHiddenObjects(bool fShowHiddenObjects)
     321{
     322    m_fShowHiddenObjects = fShowHiddenObjects;
     323}
     324
     325bool UICustomFileSystemProxyModel::showHiddenObjects() const
     326{
     327    return m_fShowHiddenObjects;
    287328}
    288329
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UICustomFileSystemModel.h

    r76621 r76626  
    9898    bool isDriveItem() const;
    9999
     100    void setIsHidden(bool flag);
     101    bool isHidden() const;
     102
    100103private:
    101104    void appendChild(UICustomFileSystemItem *child);
     
    110113    QString          m_strTargetPath;
    111114    /** True if this is a symlink and the target is a directory */
    112     bool             m_isTargetADirectory;
     115    bool             m_fIsTargetADirectory;
    113116    KFsObjType  m_type;
    114117    /** True if only this item represents a DOS style drive letter item */
    115     bool             m_isDriveItem;
     118    bool             m_fIsDriveItem;
     119    /** True if the file object is hidden in the file system. */
     120    bool             m_fIsHidden;
    116121};
    117122
     
    126131
    127132    UICustomFileSystemProxyModel(QObject *parent = 0);
     133
    128134    void setListDirectoriesOnTop(bool fListDirectoriesOnTop);
    129135    bool listDirectoriesOnTop() const;
    130136
     137    void setShowHiddenObjects(bool fShowHiddenObjects);
     138    bool showHiddenObjects() const;
     139
    131140protected:
    132141
    133     bool lessThan(const QModelIndex &left, const QModelIndex &right) const /* override */;
     142    virtual bool lessThan(const QModelIndex &left, const QModelIndex &right) const /* override */;
     143    /** Currently filters out hidden objects if options is set to "not showing them". */
     144    virtual bool filterAcceptsRow(int iSourceRow, const QModelIndex &sourceParent) const /* override */;
    134145
    135146private:
    136147
    137148    bool m_fListDirectoriesOnTop;
     149    bool m_fShowHiddenObjects;
    138150};
    139151
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManager.cpp

    r76606 r76626  
    108108    , bAskDeleteConfirmation(false)
    109109    , bShowHumanReadableSizes(true)
     110    , bShowHiddenObjects(true)
    110111{
    111112}
     
    700701    {
    701702        gEDataManager->setFileManagerOptions(pOptions->bListDirectoriesOnTop,
    702                                                          pOptions->bAskDeleteConfirmation,
    703                                                          pOptions->bShowHumanReadableSizes);
     703                                             pOptions->bAskDeleteConfirmation,
     704                                             pOptions->bShowHumanReadableSizes,
     705                                             pOptions->bShowHiddenObjects);
    704706    }
    705707}
     
    740742        pOptions->bAskDeleteConfirmation = gEDataManager->fileManagerShowDeleteConfirmation();
    741743        pOptions->bShowHumanReadableSizes = gEDataManager->fileManagerShowHumanReadableSizes();
     744        pOptions->bShowHiddenObjects = gEDataManager->fileManagerShowHiddenObjects();
    742745    }
    743746}
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManager.h

    r76581 r76626  
    7373    bool bAskDeleteConfirmation;
    7474    bool bShowHumanReadableSizes;
     75    bool bShowHiddenObjects;
    7576
    7677private:
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerGuestTable.cpp

    r76606 r76626  
    211211                item->setPath(UIPathOperations::mergePaths(strPath, fsInfo.GetName()));
    212212                item->setIsOpened(false);
     213                item->setIsHidden(isFileObjectHidden(fsInfo));
    213214                fileObjects.insert(fsInfo.GetName(), item);
    214215                /* @todo. We will need to wait a fully implemented SymlinkRead function
     
    738739}
    739740
     741bool UIFileManagerGuestTable::isFileObjectHidden(const CFsObjInfo &fsInfo)
     742{
     743    QString strAttributes = fsInfo.GetFileAttributes();
     744
     745    if (strAttributes.isEmpty())
     746        return false;
     747
     748    int offSpace = strAttributes.indexOf(' ');
     749    if (offSpace < 0)
     750        offSpace = strAttributes.length();
     751    QString strRight(strAttributes.mid(offSpace + 1).trimmed());
     752
     753    if (strRight.indexOf('H', Qt::CaseSensitive) == -1)
     754        return false;
     755    return true;
     756}
     757
    740758#include "UIFileManagerGuestTable.moc"
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerGuestTable.h

    r76581 r76626  
    8383    bool checkGuestSession();
    8484    QString permissionString(const CFsObjInfo &fsInfo);
     85    bool isFileObjectHidden(const CFsObjInfo &fsInfo);
     86
    8587    mutable CGuestSession     m_comGuestSession;
    8688};
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerHostTable.cpp

    r76621 r76626  
    162162            item->setIsSymLinkToADirectory(QFileInfo(fileInfo.symLinkTarget()).isDir());
    163163        }
     164        item->setIsHidden(fileInfo.isHidden());
    164165        fileObjects.insert(fileInfo.fileName(), item);
    165166        item->setIsOpened(false);
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerOptionsPanel.cpp

    r76606 r76626  
    3838    , m_pDeleteConfirmationCheckBox(0)
    3939    , m_pHumanReabableSizesCheckBox(0)
     40    , m_pShowHiddenObjectsCheckBox(0)
    4041    , m_pFileManagerOptions(pFileManagerOptions)
    4142{
     
    7374        m_pHumanReabableSizesCheckBox->blockSignals(false);
    7475    }
     76
     77    if (m_pShowHiddenObjectsCheckBox)
     78    {
     79        m_pShowHiddenObjectsCheckBox->blockSignals(true);
     80        m_pShowHiddenObjectsCheckBox->setChecked(m_pFileManagerOptions->bShowHiddenObjects);
     81        m_pShowHiddenObjectsCheckBox->blockSignals(false);
     82    }
    7583}
    7684
     
    97105        mainLayout()->addWidget(m_pHumanReabableSizesCheckBox, 0, Qt::AlignLeft);
    98106    }
     107
     108    m_pShowHiddenObjectsCheckBox = new QCheckBox;
     109    if (m_pShowHiddenObjectsCheckBox)
     110    {
     111        mainLayout()->addWidget(m_pShowHiddenObjectsCheckBox, 0, Qt::AlignLeft);
     112    }
     113
    99114    /* Set initial checkbox status wrt. options: */
    100115    if (m_pFileManagerOptions)
     
    106121        if (m_pHumanReabableSizesCheckBox)
    107122            m_pHumanReabableSizesCheckBox->setChecked(m_pFileManagerOptions->bShowHumanReadableSizes);
     123        if (m_pShowHiddenObjectsCheckBox)
     124            m_pShowHiddenObjectsCheckBox->setChecked(m_pFileManagerOptions->bShowHiddenObjects);
     125
    108126    }
    109127    retranslateUi();
     
    135153}
    136154
     155void UIFileManagerOptionsPanel::sltShowHiddenObjectsCheckBoxToggled(bool bChecked)
     156{
     157    if (!m_pFileManagerOptions)
     158        return;
     159    m_pFileManagerOptions->bShowHiddenObjects = bChecked;
     160    emit sigOptionsChanged();
     161}
     162
    137163void UIFileManagerOptionsPanel::prepareConnections()
    138164{
     
    146172        connect(m_pHumanReabableSizesCheckBox, &QCheckBox::toggled,
    147173                this, &UIFileManagerOptionsPanel::sltHumanReabableSizesCheckBoxToogled);
     174
     175    if (m_pShowHiddenObjectsCheckBox)
     176        connect(m_pShowHiddenObjectsCheckBox, &QCheckBox::toggled,
     177                this, &UIFileManagerOptionsPanel::sltShowHiddenObjectsCheckBoxToggled);
     178
    148179}
    149180
     
    170201                                                                                "readable format rather than in bytes"));
    171202    }
    172 }
     203
     204    if (m_pShowHiddenObjectsCheckBox)
     205    {
     206        m_pShowHiddenObjectsCheckBox->setText(UIFileManager::tr("Show hidden objects"));
     207        m_pShowHiddenObjectsCheckBox->setToolTip(UIFileManager::tr("Show hidden files/directories"));
     208    }
     209}
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerOptionsPanel.h

    r76581 r76626  
    6464    void sltDeleteConfirmationCheckBoxToogled(bool bChecked);
    6565    void sltHumanReabableSizesCheckBoxToogled(bool bChecked);
     66    void sltShowHiddenObjectsCheckBoxToggled(bool bChecked);
    6667
    6768private:
     
    7071    QCheckBox  *m_pDeleteConfirmationCheckBox;
    7172    QCheckBox  *m_pHumanReabableSizesCheckBox;
     73    QCheckBox  *m_pShowHiddenObjectsCheckBox;
    7274    UIFileManagerOptions *m_pFileManagerOptions;
    7375};
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerTable.cpp

    r76606 r76626  
    11601160    {
    11611161        if (m_pProxyModel)
     1162        {
    11621163            m_pProxyModel->setListDirectoriesOnTop(pOptions->bListDirectoriesOnTop);
     1164            m_pProxyModel->setShowHiddenObjects(pOptions->bShowHiddenObjects);
     1165        }
    11631166        if (m_pModel)
    11641167            m_pModel->setShowHumanReadableSizes(pOptions->bShowHumanReadableSizes);
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