VirtualBox

Changeset 102485 in vbox


Ignore:
Timestamp:
Dec 5, 2023 5:37:02 PM (12 months ago)
Author:
vboxsync
Message:

FE/Qt: bugref:10561. Some refactoring.

Location:
trunk/src/VBox/Frontends/VirtualBox
Files:
1 deleted
9 edited
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk

    r102402 r102485  
    820820        src/globals/UIAnimationFramework.h \
    821821        src/globals/UICommon.h \
    822         src/globals/UICustomFileSystemModel.h \
     822        src/globals/UIFileSystemModel.h \
    823823        src/globals/UIDesktopWidgetWatchdog.h \
    824824        src/globals/UIMainEventListener.h \
     
    13891389        src/globals/UICommon.cpp \
    13901390        src/globals/UICursor.cpp \
    1391         src/globals/UICustomFileSystemModel.cpp \
     1391        src/globals/UIFileSystemModel.cpp \
    13921392        src/globals/UIDefs.cpp \
    13931393        src/globals/UIDesktopWidgetWatchdog.cpp \
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIFileSystemModel.h

    r102484 r102485  
    11/* $Id$ */
    22/** @file
    3  * VBox Qt GUI - UICustomFileSystemModel class declaration.
     3 * VBox Qt GUI - UIFileSystemModel class declaration.
    44 */
    55
     
    2626 */
    2727
    28 #ifndef FEQT_INCLUDED_SRC_globals_UICustomFileSystemModel_h
    29 #define FEQT_INCLUDED_SRC_globals_UICustomFileSystemModel_h
     28#ifndef FEQT_INCLUDED_SRC_globals_UIFileSystemModel_h
     29#define FEQT_INCLUDED_SRC_globals_UIFileSystemModel_h
    3030#ifndef RT_WITHOUT_PRAGMA_ONCE
    3131# pragma once
     
    4242
    4343class QMimeData;
    44 class UICustomFileSystemModel;
    45 
    46 enum UICustomFileSystemModelData
    47 {
    48     UICustomFileSystemModelData_Name = 0,
    49     UICustomFileSystemModelData_Size,
    50     UICustomFileSystemModelData_ChangeTime,
    51     UICustomFileSystemModelData_Owner,
    52     UICustomFileSystemModelData_Permissions,
    53     UICustomFileSystemModelData_LocalPath,
    54     UICustomFileSystemModelData_ISOFilePath, /* in case of import-iso this contains full path of the container iso file. */
    55     UICustomFileSystemModelData_RemovedFromVISO,
    56     UICustomFileSystemModelData_DescendantRemovedFromVISO,
    57     UICustomFileSystemModelData_Max
    58 };
    59 
    60 /** A UICustomFileSystemItem instance is a tree node representing a file object (file, directory, etc). The tree contructed
    61     by these instances is the data source for the UICustomFileSystemModel. */
    62 class SHARED_LIBRARY_STUFF UICustomFileSystemItem
     44class UIFileSystemModel;
     45
     46enum UIFileSystemModelData
     47{
     48    UIFileSystemModelData_Name = 0,
     49    UIFileSystemModelData_Size,
     50    UIFileSystemModelData_ChangeTime,
     51    UIFileSystemModelData_Owner,
     52    UIFileSystemModelData_Permissions,
     53    UIFileSystemModelData_LocalPath,
     54    UIFileSystemModelData_ISOFilePath, /* in case of import-iso this contains full path of the container iso file. */
     55    UIFileSystemModelData_RemovedFromVISO,
     56    UIFileSystemModelData_DescendantRemovedFromVISO,
     57    UIFileSystemModelData_Max
     58};
     59
     60/** A UIFileSystemItem instance is a tree node representing a file object (file, directory, etc). The tree contructed
     61    by these instances is the data source for the UIFileSystemModel. */
     62class SHARED_LIBRARY_STUFF UIFileSystemItem
    6363{
    6464
     
    6666
    6767    /** @p strName contains file object name which is assumed to be unique among a parent object's children. */
    68     UICustomFileSystemItem(const QString &strFileObjectName, UICustomFileSystemItem *parentItem, KFsObjType type);
    69     virtual ~UICustomFileSystemItem();
     68    UIFileSystemItem(const QString &strFileObjectName, UIFileSystemItem *parentItem, KFsObjType type);
     69    virtual ~UIFileSystemItem();
    7070
    7171    void reset();
    72     virtual UICustomFileSystemItem *child(int row) const;
     72    virtual UIFileSystemItem *child(int row) const;
    7373    /** Searches for the child by file object name and returns it if found. */
    74     UICustomFileSystemItem *child(const QString &strFileObjectName) const;
     74    UIFileSystemItem *child(const QString &strFileObjectName) const;
    7575    int childCount() const;
    76     QList<UICustomFileSystemItem*> children() const;
     76    QList<UIFileSystemItem*> children() const;
    7777    /** Removes the item from the list of children and !!DELETES!! the item. */
    78     void removeChild(UICustomFileSystemItem *pItem);
     78    void removeChild(UIFileSystemItem *pItem);
    7979    void removeChildren();
    8080    int columnCount() const;
    8181    QVariant data(int column) const;
    8282    void setData(const QVariant &data, int index);
    83     void setData(const QVariant &data, UICustomFileSystemModelData enmColumn);
     83    void setData(const QVariant &data, UIFileSystemModelData enmColumn);
    8484    int row() const;
    85     UICustomFileSystemItem *parentItem();
    86     UICustomFileSystemItem *parentItem() const;
     85    UIFileSystemItem *parentItem();
     86    UIFileSystemItem *parentItem() const;
    8787
    8888    bool isDirectory() const;
     
    128128private:
    129129
    130     void appendChild(UICustomFileSystemItem *child);
    131     void setParentModel(UICustomFileSystemModel *pModel);
    132     UICustomFileSystemModel *parentModel();
    133 
    134     QList<UICustomFileSystemItem*>               m_childItems;
    135     QMap<UICustomFileSystemModelData, QVariant>  m_itemData;
    136     UICustomFileSystemItem *m_parentItem;
     130    void appendChild(UIFileSystemItem *child);
     131    void setParentModel(UIFileSystemModel *pModel);
     132    UIFileSystemModel *parentModel();
     133
     134    QList<UIFileSystemItem*>               m_childItems;
     135    QMap<UIFileSystemModelData, QVariant>  m_itemData;
     136    UIFileSystemItem *m_parentItem;
    137137    bool             m_bIsOpened;
    138138    /** If this is a symlink m_targetPath keeps the absolute path of the target */
     
    147147    QString          m_strToolTip;
    148148    /** Pointer to the parent model. */
    149     UICustomFileSystemModel *m_pParentModel;
    150     friend UICustomFileSystemModel;
     149    UIFileSystemModel *m_pParentModel;
     150    friend UIFileSystemModel;
    151151};
    152152
    153153/** A QSortFilterProxyModel extension used in file tables. Modifies some
    154154 *  of the base class behavior like lessThan(..) */
    155 class SHARED_LIBRARY_STUFF UICustomFileSystemProxyModel : public QSortFilterProxyModel
     155class SHARED_LIBRARY_STUFF UIFileSystemProxyModel : public QSortFilterProxyModel
    156156{
    157157
     
    160160public:
    161161
    162     UICustomFileSystemProxyModel(QObject *parent = 0);
     162    UIFileSystemProxyModel(QObject *parent = 0);
    163163
    164164    void setListDirectoriesOnTop(bool fListDirectoriesOnTop);
     
    180180};
    181181
    182 /** UICustomFileSystemModel serves as the model for a file structure.
     182/** UIFileSystemModel serves as the model for a file structure.
    183183 *  it supports a tree level hierarchy which can be displayed with
    184184 *  QTableView and/or QTreeView.*/
    185 class SHARED_LIBRARY_STUFF UICustomFileSystemModel : public QAbstractItemModel
     185class SHARED_LIBRARY_STUFF UIFileSystemModel : public QAbstractItemModel
    186186{
    187187
     
    190190signals:
    191191
    192     void sigItemRenamed(UICustomFileSystemItem *pItem, const QString &strOldPath,
     192    void sigItemRenamed(UIFileSystemItem *pItem, const QString &strOldPath,
    193193                        const QString &strOldName, const QString &strNewName);
    194194
    195195public:
    196196
    197     explicit UICustomFileSystemModel(QObject *parent = 0);
    198     ~UICustomFileSystemModel();
     197    explicit UIFileSystemModel(QObject *parent = 0);
     198    ~UIFileSystemModel();
    199199
    200200    QVariant       data(const QModelIndex &index, int role) const RT_OVERRIDE;
     
    206206    QModelIndex    index(int row, int column,
    207207                      const QModelIndex &parent = QModelIndex()) const RT_OVERRIDE;
    208     QModelIndex    index(const UICustomFileSystemItem* item);
     208    QModelIndex    index(const UIFileSystemItem* item);
    209209    QModelIndex    parent(const QModelIndex &index) const RT_OVERRIDE;
    210210    int            rowCount(const QModelIndex &parent = QModelIndex()) const RT_OVERRIDE;
     
    218218    void           setShowHumanReadableSizes(bool fShowHumanReadableSizes);
    219219    bool           showHumanReadableSizes() const;
    220     void           deleteItem(UICustomFileSystemItem* pItem);
    221     UICustomFileSystemItem* rootItem();
    222     const UICustomFileSystemItem* rootItem() const;
     220    void           deleteItem(UIFileSystemItem* pItem);
     221    UIFileSystemItem* rootItem();
     222    const UIFileSystemItem* rootItem() const;
    223223
    224224    void setIsWindowsFileSystem(bool fIsWindowsFileSystem);
     
    233233private:
    234234
    235     UICustomFileSystemItem    *m_pRootItem;
    236     void setupModelData(const QStringList &lines, UICustomFileSystemItem *parent);
     235    UIFileSystemItem    *m_pRootItem;
     236    void setupModelData(const QStringList &lines, UIFileSystemItem *parent);
    237237    bool m_fShowHumanReadableSizes;
    238238    bool m_fIsWindowFileSystemModel;
     
    240240
    241241
    242 #endif /* !FEQT_INCLUDED_SRC_globals_UICustomFileSystemModel_h */
     242#endif /* !FEQT_INCLUDED_SRC_globals_UIFileSystemModel_h */
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerGuestTable.cpp

    r102418 r102485  
    3838#include "UIConverter.h"
    3939#include "UICommon.h"
    40 #include "UICustomFileSystemModel.h"
     40#include "UIFileSystemModel.h"
    4141#include "UIErrorString.h"
    4242#include "UIFileManager.h"
     
    515515
    516516bool UIFileManagerGuestTable::readDirectory(const QString& strPath,
    517                                      UICustomFileSystemItem *parent, bool isStartDir /*= false*/)
     517                                     UIFileSystemItem *parent, bool isStartDir /*= false*/)
    518518{
    519519    if (!parent)
     
    549549        }
    550550
    551         QMap<QString, UICustomFileSystemItem*> fileObjects;
     551        QMap<QString, UIFileSystemItem*> fileObjects;
    552552
    553553        while (directory.isOk())
     
    562562                    QDateTime changeTime = QDateTime::fromMSecsSinceEpoch(fsInfo.GetChangeTime()/RT_NS_1MS);
    563563                    KFsObjType fsObjectType = fileType(fsInfo);
    564                     UICustomFileSystemItem *item = new UICustomFileSystemItem(fsInfo.GetName(), parent, fsObjectType);
     564                    UIFileSystemItem *item = new UIFileSystemItem(fsInfo.GetName(), parent, fsObjectType);
    565565                    if (!item)
    566566                        continue;
    567                     item->setData(static_cast<qulonglong>(fsInfo.GetObjectSize()), UICustomFileSystemModelData_Size);
    568                     item->setData(changeTime, UICustomFileSystemModelData_ChangeTime);
    569                     item->setData(fsInfo.GetUserName(), UICustomFileSystemModelData_Owner);
    570                     item->setData(permissionString(fsInfo), UICustomFileSystemModelData_Permissions);
    571                     printf(" %s === %s\n", qPrintable(fsInfo.GetName()), qPrintable(fsInfo.GetFileAttributes()));
     567                    item->setData(static_cast<qulonglong>(fsInfo.GetObjectSize()), UIFileSystemModelData_Size);
     568                    item->setData(changeTime, UIFileSystemModelData_ChangeTime);
     569                    item->setData(fsInfo.GetUserName(), UIFileSystemModelData_Owner);
     570                    item->setData(permissionString(fsInfo), UIFileSystemModelData_Permissions);
    572571                    item->setIsOpened(false);
    573572                    item->setIsHidden(isFileObjectHidden(fsInfo));
     
    606605}
    607606
    608 void UIFileManagerGuestTable::deleteByItem(UICustomFileSystemItem *item)
     607void UIFileManagerGuestTable::deleteByItem(UIFileSystemItem *item)
    609608{
    610609    if (!item)
     
    633632    if (!rootItem() || rootItem()->childCount() <= 0)
    634633        return;
    635     UICustomFileSystemItem *startDirItem = rootItem()->child(0);
     634    UIFileSystemItem *startDirItem = rootItem()->child(0);
    636635    if (!startDirItem)
    637636        return;
     
    651650}
    652651
    653 bool UIFileManagerGuestTable::renameItem(UICustomFileSystemItem *item, const QString &strOldPath)
     652bool UIFileManagerGuestTable::renameItem(UIFileSystemItem *item, const QString &strOldPath)
    654653{
    655654    if (!item || item->isUpDirectory())
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerGuestTable.h

    r102418 r102485  
    5353class CGuestSessionStateChangedEvent;
    5454class UIActionPool;
    55 class UICustomFileSystemItem;
     55class UIFileSystemItem;
    5656class UIGuestSessionWidget;
    5757
     
    8181
    8282    void            retranslateUi() override final;
    83     virtual bool    readDirectory(const QString& strPath, UICustomFileSystemItem *parent, bool isStartDir = false) override final;
    84     virtual void    deleteByItem(UICustomFileSystemItem *item) override final;
     83    virtual bool    readDirectory(const QString& strPath, UIFileSystemItem *parent, bool isStartDir = false) override final;
     84    virtual void    deleteByItem(UIFileSystemItem *item) override final;
    8585    virtual void    goToHomeDirectory() override final;
    86     virtual bool    renameItem(UICustomFileSystemItem *item, const QString &strOldPath) override final;
     86    virtual bool    renameItem(UIFileSystemItem *item, const QString &strOldPath) override final;
    8787    virtual bool    createDirectory(const QString &path, const QString &directoryName) override final;
    8888    virtual QString fsObjectPropertyString() override final;
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerHostTable.cpp

    r102481 r102485  
    3737#include "UIFileManager.h"
    3838#include "UIFileTableNavigationWidget.h"
    39 #include "UICustomFileSystemModel.h"
     39#include "UIFileSystemModel.h"
    4040#include "UIFileManagerHostTable.h"
    4141#include "UIPathOperations.h"
     
    112112        const QFileInfo &entryInfo = entryList.at(i);
    113113        if (entryInfo.baseName().isEmpty() || entryInfo.baseName() == "." ||
    114             entryInfo.baseName() == UICustomFileSystemModel::strUpDirectoryString)
     114            entryInfo.baseName() == UIFileSystemModel::strUpDirectoryString)
    115115            continue;
    116116        statistics.m_totalSize += entryInfo.size();
     
    157157}
    158158
    159 /* static */ bool UIFileManagerHostTable::scanDirectory(const QString& strPath, UICustomFileSystemItem *parent,
    160                                                         QMap<QString, UICustomFileSystemItem*> &fileObjects)
     159/* static */ bool UIFileManagerHostTable::scanDirectory(const QString& strPath, UIFileSystemItem *parent,
     160                                                        QMap<QString, UIFileSystemItem*> &fileObjects)
    161161{
    162162
     
    173173    {
    174174        const QFileInfo &fileInfo = entries.at(i);
    175         UICustomFileSystemItem *item = new UICustomFileSystemItem(fileInfo.fileName(), parent, fileType(fileInfo));
     175        UIFileSystemItem *item = new UIFileSystemItem(fileInfo.fileName(), parent, fileType(fileInfo));
    176176        if (!item)
    177177            continue;
    178178
    179         item->setData(fileInfo.size(),         UICustomFileSystemModelData_Size);
    180         item->setData(fileInfo.lastModified(), UICustomFileSystemModelData_ChangeTime);
    181         item->setData(fileInfo.owner(),        UICustomFileSystemModelData_Owner);
    182         item->setData(permissionString(fileInfo.permissions()),  UICustomFileSystemModelData_Permissions);
     179        item->setData(fileInfo.size(),         UIFileSystemModelData_Size);
     180        item->setData(fileInfo.lastModified(), UIFileSystemModelData_ChangeTime);
     181        item->setData(fileInfo.owner(),        UIFileSystemModelData_Owner);
     182        item->setData(permissionString(fileInfo.permissions()),  UIFileSystemModelData_Permissions);
    183183
    184184        /* if the item is a symlink set the target path and
     
    282282}
    283283
    284 bool UIFileManagerHostTable::readDirectory(const QString& strPath, UICustomFileSystemItem *parent, bool isStartDir /*= false*/)
     284bool UIFileManagerHostTable::readDirectory(const QString& strPath, UIFileSystemItem *parent, bool isStartDir /*= false*/)
    285285{
    286286    if (!parent)
    287287        return false;
    288288
    289     QMap<QString, UICustomFileSystemItem*> fileObjects;
     289    QMap<QString, UIFileSystemItem*> fileObjects;
    290290    if (!scanDirectory(strPath, parent, fileObjects))
    291291        return false;
     
    294294}
    295295
    296 void UIFileManagerHostTable::deleteByItem(UICustomFileSystemItem *item)
     296void UIFileManagerHostTable::deleteByItem(UIFileSystemItem *item)
    297297{
    298298    if (item->isUpDirectory())
     
    320320    if (!rootItem() || rootItem()->childCount() <= 0)
    321321        return;
    322     UICustomFileSystemItem *startDirItem = rootItem()->child(0);
     322    UIFileSystemItem *startDirItem = rootItem()->child(0);
    323323    if (!startDirItem)
    324324        return;
     
    328328}
    329329
    330 bool UIFileManagerHostTable::renameItem(UICustomFileSystemItem *item, const QString &strOldPath)
     330bool UIFileManagerHostTable::renameItem(UIFileSystemItem *item, const QString &strOldPath)
    331331{
    332332    if (!item || item->isUpDirectory())
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerHostTable.h

    r102418 r102485  
    4040/* Forward declarations: */
    4141class UIActionPool;
    42 class UICustomFileSystemItem;
     42class UIFileSystemItem;
    4343
    4444/** This class scans the host file system by using the Qt API
    45     and connects to the UICustomFileSystemModel*/
     45    and connects to the UIFileSystemModel*/
    4646class UIFileManagerHostTable : public UIFileManagerTable
    4747{
     
    6161    /** Scans the directory with the path @strPath and inserts items to the
    6262     *  tree under the @p parent. */
    63     static bool scanDirectory(const QString& strPath, UICustomFileSystemItem *parent,
    64                               QMap<QString, UICustomFileSystemItem*> &fileObjects);
     63    static bool scanDirectory(const QString& strPath, UIFileSystemItem *parent,
     64                              QMap<QString, UIFileSystemItem*> &fileObjects);
    6565    void            retranslateUi() override final;
    66     virtual bool    readDirectory(const QString& strPath, UICustomFileSystemItem *parent, bool isStartDir = false) override final;
    67     virtual void    deleteByItem(UICustomFileSystemItem *item) override final;
     66    virtual bool    readDirectory(const QString& strPath, UIFileSystemItem *parent, bool isStartDir = false) override final;
     67    virtual void    deleteByItem(UIFileSystemItem *item) override final;
    6868    virtual void    goToHomeDirectory() override final;
    69     virtual bool    renameItem(UICustomFileSystemItem *item, const QString &strOldPath) override final;
     69    virtual bool    renameItem(UIFileSystemItem *item, const QString &strOldPath) override final;
    7070    virtual bool    createDirectory(const QString &path, const QString &directoryName) override final;
    7171    virtual QString fsObjectPropertyString() override final;
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerTable.cpp

    r102446 r102485  
    4343#include "UIActionPool.h"
    4444#include "UICommon.h"
    45 #include "UICustomFileSystemModel.h"
     45#include "UIFileSystemModel.h"
    4646#include "UIErrorString.h"
    4747#include "UIFileManager.h"
     
    458458    }
    459459
    460     m_pModel = new UICustomFileSystemModel(this);
     460    m_pModel = new UIFileSystemModel(this);
    461461    if (!m_pModel)
    462462        return;
    463463
    464     connect(m_pModel, &UICustomFileSystemModel::sigItemRenamed,
     464    connect(m_pModel, &UIFileSystemModel::sigItemRenamed,
    465465            this, &UIFileManagerTable::sltHandleItemRenameAttempt);
    466466
    467     m_pProxyModel = new UICustomFileSystemProxyModel(this);
     467    m_pProxyModel = new UIFileSystemProxyModel(this);
    468468    if (!m_pProxyModel)
    469469        return;
     
    497497        connect(m_pView, &UIGuestControlFileView::customContextMenuRequested,
    498498                this, &UIFileManagerTable::sltCreateFileViewContextMenu);
    499         m_pView->hideColumn(UICustomFileSystemModelData_LocalPath);
    500         m_pView->hideColumn(UICustomFileSystemModelData_ISOFilePath);
    501         m_pView->hideColumn(UICustomFileSystemModelData_RemovedFromVISO);
    502         m_pView->hideColumn(UICustomFileSystemModelData_DescendantRemovedFromVISO);
     499        m_pView->hideColumn(UIFileSystemModelData_LocalPath);
     500        m_pView->hideColumn(UIFileSystemModelData_ISOFilePath);
     501        m_pView->hideColumn(UIFileSystemModelData_RemovedFromVISO);
     502        m_pView->hideColumn(UIFileSystemModelData_DescendantRemovedFromVISO);
    503503
    504504        m_sessionWidgets << m_pView;
     
    536536        m_pView->selectionModel()->reset();
    537537
    538     UICustomFileSystemItem *item = static_cast<UICustomFileSystemItem*>(index.internalPointer());
     538    UIFileSystemItem *item = static_cast<UIFileSystemItem*>(index.internalPointer());
    539539    if (item)
    540540    {
     
    556556    /* On Unix-like systems startItem represents the root directory. On Windows it is like "my computer" under which
    557557     * drives are listed: */
    558     UICustomFileSystemItem* startItem = new UICustomFileSystemItem(startPath, rootItem(), KFsObjType_Directory);
     558    UIFileSystemItem* startItem = new UIFileSystemItem(startPath, rootItem(), KFsObjType_Directory);
    559559
    560560    startItem->setIsOpened(false);
     
    566566}
    567567
    568 void UIFileManagerTable::populateStartDirectory(UICustomFileSystemItem *startItem)
     568void UIFileManagerTable::populateStartDirectory(UIFileSystemItem *startItem)
    569569{
    570570    determineDriveLetters();
     
    578578        for (int i = 0; i < m_driveLetterList.size(); ++i)
    579579        {
    580             UICustomFileSystemItem* driveItem = new UICustomFileSystemItem(UIPathOperations::removeTrailingDelimiters(m_driveLetterList[i]),
     580            UIFileSystemItem* driveItem = new UIFileSystemItem(UIPathOperations::removeTrailingDelimiters(m_driveLetterList[i]),
    581581                                                                           startItem, KFsObjType_Directory);
    582582            driveItem->setIsOpened(false);
     
    587587}
    588588
    589 void UIFileManagerTable::checkDotDot(QMap<QString,UICustomFileSystemItem*> &map,
    590                                      UICustomFileSystemItem *parent, bool isStartDir)
     589void UIFileManagerTable::checkDotDot(QMap<QString,UIFileSystemItem*> &map,
     590                                     UIFileSystemItem *parent, bool isStartDir)
    591591{
    592592    if (!parent)
    593593        return;
    594594    /* Make sure we have an item representing up directory, and make sure it is not there for the start dir: */
    595     if (!map.contains(UICustomFileSystemModel::strUpDirectoryString)  && !isStartDir)
    596     {
    597         UICustomFileSystemItem *item = new UICustomFileSystemItem(UICustomFileSystemModel::strUpDirectoryString,
     595    if (!map.contains(UIFileSystemModel::strUpDirectoryString)  && !isStartDir)
     596    {
     597        UIFileSystemItem *item = new UIFileSystemItem(UIFileSystemModel::strUpDirectoryString,
    598598                                                                  parent, KFsObjType_Directory);
    599599        item->setIsOpened(false);
    600         map.insert(UICustomFileSystemModel::strUpDirectoryString, item);
    601     }
    602     else if (map.contains(UICustomFileSystemModel::strUpDirectoryString)  && isStartDir)
    603     {
    604         map.remove(UICustomFileSystemModel::strUpDirectoryString);
     600        map.insert(UIFileSystemModel::strUpDirectoryString, item);
     601    }
     602    else if (map.contains(UIFileSystemModel::strUpDirectoryString)  && isStartDir)
     603    {
     604        map.remove(UIFileSystemModel::strUpDirectoryString);
    605605    }
    606606}
     
    671671        return;
    672672
    673     UICustomFileSystemItem *item = static_cast<UICustomFileSystemItem*>(index.internalPointer());
     673    UIFileSystemItem *item = static_cast<UIFileSystemItem*>(index.internalPointer());
    674674    if (!item)
    675675        return;
     
    698698void UIFileManagerTable::goIntoDirectory(const QStringList &pathTrail)
    699699{
    700     UICustomFileSystemItem *parent = getStartDirectoryItem();
     700    UIFileSystemItem *parent = getStartDirectoryItem();
    701701
    702702    for(int i = 0; i < pathTrail.size(); ++i)
     
    709709                return;
    710710        /* search the current path item among the parent's children: */
    711         UICustomFileSystemItem *item = parent->child(pathTrail.at(i));
     711        UIFileSystemItem *item = parent->child(pathTrail.at(i));
    712712
    713713        if (!item)
     
    725725}
    726726
    727 void UIFileManagerTable::goIntoDirectory(UICustomFileSystemItem *item)
     727void UIFileManagerTable::goIntoDirectory(UIFileSystemItem *item)
    728728{
    729729    if (!item || !m_pModel)
     
    732732}
    733733
    734 UICustomFileSystemItem* UIFileManagerTable::indexData(const QModelIndex &index) const
     734UIFileSystemItem* UIFileManagerTable::indexData(const QModelIndex &index) const
    735735{
    736736    if (!index.isValid())
    737737        return 0;
    738     return static_cast<UICustomFileSystemItem*>(index.internalPointer());
     738    return static_cast<UIFileSystemItem*>(index.internalPointer());
    739739}
    740740
     
    745745    QModelIndex currentIndex = currentRootIndex();
    746746
    747     UICustomFileSystemItem *treeItem = indexData(currentIndex);
     747    UIFileSystemItem *treeItem = indexData(currentIndex);
    748748    if (!treeItem)
    749749        return;
     
    806806    QModelIndex modelIndex =
    807807        m_pProxyModel ? m_pProxyModel->mapToSource(selectedItemIndices.at(0)) : selectedItemIndices.at(0);
    808     UICustomFileSystemItem *item = indexData(modelIndex);
     808    UIFileSystemItem *item = indexData(modelIndex);
    809809    if (!item || item->isUpDirectory())
    810810        return;
     
    819819    if (!currentIndex.isValid())
    820820        return;
    821     UICustomFileSystemItem *parentFolderItem = static_cast<UICustomFileSystemItem*>(currentIndex.internalPointer());
     821    UIFileSystemItem *parentFolderItem = static_cast<UIFileSystemItem*>(currentIndex.internalPointer());
    822822    if (!parentFolderItem)
    823823        return;
    824     QString strBase(UICustomFileSystemModel::tr("NewDirectory"));
     824    QString strBase(UIFileSystemModel::tr("NewDirectory"));
    825825    QString newDirectoryName(strBase);
    826826    QStringList nameList = currentDirectoryListing();
     
    838838
    839839    /* Now we try to edit the newly created item thereby enabling the user to rename the new item: */
    840     QList<UICustomFileSystemItem*> content = parentFolderItem->children();
    841     UICustomFileSystemItem* newItem = 0;
     840    QList<UIFileSystemItem*> content = parentFolderItem->children();
     841    UIFileSystemItem* newItem = 0;
    842842    /* Search the new item: */
    843     foreach (UICustomFileSystemItem* childItem, content)
     843    foreach (UIFileSystemItem* childItem, content)
    844844    {
    845845
     
    909909}
    910910
    911 void UIFileManagerTable::sltHandleItemRenameAttempt(UICustomFileSystemItem *pItem, const QString &strOldPath,
     911void UIFileManagerTable::sltHandleItemRenameAttempt(UIFileSystemItem *pItem, const QString &strOldPath,
    912912                                                    const QString &strOldName, const QString &strNewName)
    913913{
     
    919919    {
    920920        /* Restore the previous name. relist the view: */
    921         pItem->setData(strOldName, static_cast<int>(UICustomFileSystemModelData_Name));
     921        pItem->setData(strOldName, static_cast<int>(UIFileSystemModelData_Name));
    922922        relist();
    923923        emit sigLogOutput(QString(pItem->path()).append(" could not be renamed"), QString(), FileManagerLogType_Error);
     
    961961            continue;
    962962
    963         UICustomFileSystemItem *item = static_cast<UICustomFileSystemItem*>(index.internalPointer());
     963        UIFileSystemItem *item = static_cast<UIFileSystemItem*>(index.internalPointer());
    964964        if (item && item->isUpDirectory())
    965965        {
     
    10041004void UIFileManagerTable::deleteByIndex(const QModelIndex &itemIndex)
    10051005{
    1006     UICustomFileSystemItem *treeItem = indexData(itemIndex);
     1006    UIFileSystemItem *treeItem = indexData(itemIndex);
    10071007    if (!treeItem)
    10081008        return;
     
    10121012void UIFileManagerTable::retranslateUi()
    10131013{
    1014     UICustomFileSystemItem *pRootItem = rootItem();
     1014    UIFileSystemItem *pRootItem = rootItem();
    10151015    if (pRootItem)
    10161016    {
    1017         pRootItem->setData(UIFileManager::tr("Name"), UICustomFileSystemModelData_Name);
    1018         pRootItem->setData(UIFileManager::tr("Size"), UICustomFileSystemModelData_Size);
    1019         pRootItem->setData(UIFileManager::tr("Change Time"), UICustomFileSystemModelData_ChangeTime);
    1020         pRootItem->setData(UIFileManager::tr("Owner"), UICustomFileSystemModelData_Owner);
    1021         pRootItem->setData(UIFileManager::tr("Permissions"), UICustomFileSystemModelData_Permissions);
     1017        pRootItem->setData(UIFileManager::tr("Name"), UIFileSystemModelData_Name);
     1018        pRootItem->setData(UIFileManager::tr("Size"), UIFileSystemModelData_Size);
     1019        pRootItem->setData(UIFileManager::tr("Change Time"), UIFileSystemModelData_ChangeTime);
     1020        pRootItem->setData(UIFileManager::tr("Owner"), UIFileSystemModelData_Owner);
     1021        pRootItem->setData(UIFileManager::tr("Permissions"), UIFileSystemModelData_Permissions);
    10221022    }
    10231023}
     
    10871087}
    10881088
    1089 UICustomFileSystemItem *UIFileManagerTable::getStartDirectoryItem()
    1090 {
    1091     UICustomFileSystemItem* pRootItem = rootItem();
     1089UIFileSystemItem *UIFileManagerTable::getStartDirectoryItem()
     1090{
     1091    UIFileSystemItem* pRootItem = rootItem();
    10921092    if (!pRootItem)
    10931093        return 0;
     
    11041104    if (!currentRoot.isValid())
    11051105        return QString();
    1106     UICustomFileSystemItem *item = static_cast<UICustomFileSystemItem*>(currentRoot.internalPointer());
     1106    UIFileSystemItem *item = static_cast<UIFileSystemItem*>(currentRoot.internalPointer());
    11071107    if (!item)
    11081108        return QString();
     
    11251125        QModelIndex index =
    11261126            m_pProxyModel ? m_pProxyModel->mapToSource(selectedItemIndices.at(i)) : selectedItemIndices.at(i);
    1127         UICustomFileSystemItem *item = static_cast<UICustomFileSystemItem*>(index.internalPointer());
     1127        UIFileSystemItem *item = static_cast<UIFileSystemItem*>(index.internalPointer());
    11281128        if (!item)
    11291129            continue;
     
    11511151}
    11521152
    1153 UICustomFileSystemItem* UIFileManagerTable::rootItem()
     1153UIFileSystemItem* UIFileManagerTable::rootItem()
    11541154{
    11551155    if (!m_pModel)
     
    12611261
    12621262    int rowCount = m_pProxyModel->rowCount(m_pView->rootIndex());
    1263     UICustomFileSystemItem *pFoundItem = 0;
     1263    UIFileSystemItem *pFoundItem = 0;
    12641264    QModelIndex index;
    12651265    for (int i = 0; i < rowCount && !pFoundItem; ++i)
     
    12681268        if (!index.isValid())
    12691269            continue;
    1270         pFoundItem = static_cast<UICustomFileSystemItem*>(m_pProxyModel->mapToSource(index).internalPointer());
     1270        pFoundItem = static_cast<UIFileSystemItem*>(m_pProxyModel->mapToSource(index).internalPointer());
    12711271        if (!pFoundItem)
    12721272            continue;
     
    13451345QStringList UIFileManagerTable::currentDirectoryListing() const
    13461346{
    1347     UICustomFileSystemItem *pItem = static_cast<UICustomFileSystemItem*>(currentRootIndex().internalPointer());
     1347    UIFileSystemItem *pItem = static_cast<UIFileSystemItem*>(currentRootIndex().internalPointer());
    13481348    if (!pItem)
    13491349        return QStringList();
    13501350    QStringList list;
    1351     foreach (const UICustomFileSystemItem *pChild, pItem->children())
     1351    foreach (const UIFileSystemItem *pChild, pItem->children())
    13521352    {
    13531353        if (pChild)
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerTable.h

    r102446 r102485  
    5959class QVBoxLayout;
    6060class UIActionPool;
    61 class UICustomFileSystemItem;
    62 class UICustomFileSystemModel;
    63 class UICustomFileSystemProxyModel;
     61class UIFileSystemItem;
     62class UIFileSystemModel;
     63class UIFileSystemProxyModel;
    6464class UIFileTableNavigationWidget;
    6565class UIGuestControlFileView;
     
    137137/** This class serves a base class for file table. Currently a guest version
    138138 *  and a host version are derived from this base. Each of these children
    139  *  populates the UICustomFileSystemModel by scanning the file system
     139 *  populates the UIFileSystemModel by scanning the file system
    140140 *  differently. The file structure kept in this class as a tree. */
    141141class UIFileManagerTable : public QIWithRetranslateUI<QWidget>
     
    210210    void changeLocation(const QModelIndex &index);
    211211    void initializeFileTree();
    212     void checkDotDot(QMap<QString,UICustomFileSystemItem*> &map, UICustomFileSystemItem *parent, bool isStartDir);
    213 
    214     virtual bool     readDirectory(const QString& strPath, UICustomFileSystemItem *parent, bool isStartDir = false) = 0;
    215     virtual void     deleteByItem(UICustomFileSystemItem *item) = 0;
     212    void checkDotDot(QMap<QString,UIFileSystemItem*> &map, UIFileSystemItem *parent, bool isStartDir);
     213
     214    virtual bool     readDirectory(const QString& strPath, UIFileSystemItem *parent, bool isStartDir = false) = 0;
     215    virtual void     deleteByItem(UIFileSystemItem *item) = 0;
    216216    virtual void     goToHomeDirectory() = 0;
    217     virtual bool     renameItem(UICustomFileSystemItem *item, const QString &strOldPath) = 0;
     217    virtual bool     renameItem(UIFileSystemItem *item, const QString &strOldPath) = 0;
    218218    virtual bool     createDirectory(const QString &path, const QString &directoryName) = 0;
    219219    virtual QString  fsObjectPropertyString() = 0;
     
    243243    void             goIntoDirectory(const QStringList &pathTrail);
    244244    /** Goes into directory pointed by the @p item */
    245     void             goIntoDirectory(UICustomFileSystemItem *item);
    246     UICustomFileSystemItem* indexData(const QModelIndex &index) const;
     245    void             goIntoDirectory(UIFileSystemItem *item);
     246    UIFileSystemItem* indexData(const QModelIndex &index) const;
    247247    bool             eventFilter(QObject *pObject, QEvent *pEvent) RT_OVERRIDE;
    248248    CGuestFsObjInfo  guestFsObjectInfo(const QString& path, CGuestSession &comGuestSession) const;
    249249    void             setSelectionDependentActionsEnabled(bool fIsEnabled);
    250     UICustomFileSystemItem*   rootItem();
     250    UIFileSystemItem*   rootItem();
    251251    void             setPathSeparator(const QChar &separator);
    252252    QHBoxLayout*     toolBarLayout();
     
    281281     *  if the file system rename fails we restore the old name of the item. See the comment of
    282282     *  sltRename() for more details. Note that when this slot is called item->path() has also changed. Thus strOldPath. */
    283     void sltHandleItemRenameAttempt(UICustomFileSystemItem *pItem, const QString &strOldPath,
     283    void sltHandleItemRenameAttempt(UIFileSystemItem *pItem, const QString &strOldPath,
    284284                                    const QString &strOldName, const QString &strNewName);
    285285    void sltHandleNavigationWidgetPathChange(const QString& strPath);
     
    292292    /** @p itemIndex is assumed to be 'model' index not 'proxy model' index */
    293293    void             deleteByIndex(const QModelIndex &itemIndex);
    294     /** Returns the UICustomFileSystemItem for path / which is a direct (and single) child of m_pRootItem */
    295     UICustomFileSystemItem *getStartDirectoryItem();
     294    /** Returns the UIFileSystemItem for path / which is a direct (and single) child of m_pRootItem */
     295    UIFileSystemItem *getStartDirectoryItem();
    296296    void            deSelectUpDirectoryItem();
    297297    void            setSelectionForAll(QItemSelectionModel::SelectionFlags flags);
     
    299299    /** The start directory requires a special attention since on file systems with drive letters
    300300     *  drive letter are direct children of the start directory. On other systems start directory is '/' */
    301     void            populateStartDirectory(UICustomFileSystemItem *startItem);
     301    void            populateStartDirectory(UIFileSystemItem *startItem);
    302302    /** Root index of the m_pModel */
    303303    QModelIndex     currentRootIndex() const;
     
    313313    void            markUnmarkSearchLineEdit(bool fMark);
    314314    QStringList     currentDirectoryListing() const;
    315     UICustomFileSystemModel       *m_pModel;
    316     UIGuestControlFileView        *m_pView;
    317     UICustomFileSystemProxyModel  *m_pProxyModel;
     315    UIFileSystemModel       *m_pModel;
     316    UIGuestControlFileView  *m_pView;
     317    UIFileSystemProxyModel  *m_pProxyModel;
    318318
    319319    QILineEdit      *m_pSearchLineEdit;
     
    323323    QHBoxLayout     *m_pToolBarLayout;
    324324    QVector<QWidget*> m_sessionWidgets;
    325     friend class     UICustomFileSystemModel;
     325    friend class     UIFileSystemModel;
    326326};
    327327
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/viso/UIVisoContentBrowser.cpp

    r102454 r102485  
    4040#include "QIToolBar.h"
    4141#include "UIActionPool.h"
    42 #include "UICustomFileSystemModel.h"
     42#include "UIFileSystemModel.h"
    4343#include "UIPathOperations.h"
    4444#include "UIVisoContentBrowser.h"
     
    263263    if (rootItem() && rootItem()->childCount() > 0)
    264264    {
    265         UICustomFileSystemItem *pStartItem = startItem();
     265        UIFileSystemItem *pStartItem = startItem();
    266266        if (pStartItem)
    267267        {
     
    279279
    280280void UIVisoContentBrowser::importISOContentToViso(const QString &strISOFilePath,
    281                                                   UICustomFileSystemItem *pParentItem /* = 0 */,
     281                                                  UIFileSystemItem *pParentItem /* = 0 */,
    282282                                                  const QString &strDirPath /* = QString() */)
    283283{
     
    294294    if (!strDirPath.isEmpty())
    295295    {
    296         UICustomFileSystemItem* pAddedItem = new UICustomFileSystemItem(UICustomFileSystemModel::strUpDirectoryString,
     296        UIFileSystemItem* pAddedItem = new UIFileSystemItem(UIFileSystemModel::strUpDirectoryString,
    297297                                                                        pParentItem,
    298298                                                                        KFsObjType_Directory);
    299         pAddedItem->setData(strISOFilePath, UICustomFileSystemModelData_ISOFilePath);
     299        pAddedItem->setData(strISOFilePath, UIFileSystemModelData_ISOFilePath);
    300300    }
    301301    QList<ISOFileObject> objectList = openAndReadISODir(strISOFilePath, strDirPath);
     
    314314            continue;
    315315
    316         UICustomFileSystemItem* pAddedItem = new UICustomFileSystemItem(fileInfo.fileName(), pParentItem,
     316        UIFileSystemItem* pAddedItem = new UIFileSystemItem(fileInfo.fileName(), pParentItem,
    317317                                                                        objectList[i].enmObjectType);
    318318
    319319        QString path = UIPathOperations::mergePaths(pParentItem->path(), fileInfo.fileName());
    320         pAddedItem->setData(path, UICustomFileSystemModelData_LocalPath);
    321         pAddedItem->setData(strISOFilePath, UICustomFileSystemModelData_ISOFilePath);
     320        pAddedItem->setData(path, UIFileSystemModelData_LocalPath);
     321        pAddedItem->setData(strISOFilePath, UIFileSystemModelData_ISOFilePath);
    322322        pAddedItem->setIsOpened(false);
    323323
     
    331331void UIVisoContentBrowser::removeISOContentFromViso()
    332332{
    333     UICustomFileSystemItem* pParentItem = startItem();
     333    UIFileSystemItem* pParentItem = startItem();
    334334    AssertReturnVoid(pParentItem);
    335335    AssertReturnVoid(m_pModel);
    336336
    337     QList<UICustomFileSystemItem*> itemsToDelete;
     337    QList<UIFileSystemItem*> itemsToDelete;
    338338    /* Delete all children of startItem that were imported from an ISO: */
    339339    for (int i = 0; i < pParentItem->childCount(); ++i)
    340340    {
    341         UICustomFileSystemItem* pItem = pParentItem->child(i);
    342         if (!pItem || pItem->data(UICustomFileSystemModelData_ISOFilePath).toString().isEmpty())
     341        UIFileSystemItem* pItem = pParentItem->child(i);
     342        if (!pItem || pItem->data(UIFileSystemModelData_ISOFilePath).toString().isEmpty())
    343343            continue;
    344344        itemsToDelete << pItem;
    345345    }
    346346
    347     foreach (UICustomFileSystemItem *pItem, itemsToDelete)
     347    foreach (UIFileSystemItem *pItem, itemsToDelete)
    348348            m_pModel->deleteItem(pItem);
    349349    if (m_pTableProxyModel)
     
    364364         return;
    365365
    366     UICustomFileSystemItem *pParentItem = static_cast<UICustomFileSystemItem*>(parentIndex.internalPointer());
     366    UIFileSystemItem *pParentItem = static_cast<UIFileSystemItem*>(parentIndex.internalPointer());
    367367    if (!pParentItem)
    368368        return;
     
    376376            continue;
    377377
    378         UICustomFileSystemItem* pAddedItem = new UICustomFileSystemItem(fileInfo.fileName(), pParentItem,
     378        UIFileSystemItem* pAddedItem = new UIFileSystemItem(fileInfo.fileName(), pParentItem,
    379379                                                                        fileType(fileInfo));
    380         pAddedItem->setData(strPath, UICustomFileSystemModelData_LocalPath);
     380        pAddedItem->setData(strPath, UIFileSystemModelData_LocalPath);
    381381
    382382        pAddedItem->setIsOpened(false);
     
    386386            pAddedItem->setIsSymLinkToADirectory(QFileInfo(fileInfo.symLinkTarget()).isDir());
    387387        }
    388         createVisoEntry(pAddedItem->path(), pAddedItem->data(UICustomFileSystemModelData_LocalPath).toString(), false);
     388        createVisoEntry(pAddedItem->path(), pAddedItem->data(UIFileSystemModelData_LocalPath).toString(), false);
    389389    }
    390390    if (m_pTableProxyModel)
     
    422422void UIVisoContentBrowser::retranslateUi()
    423423{
    424     UICustomFileSystemItem *pRootItem = rootItem();
     424    UIFileSystemItem *pRootItem = rootItem();
    425425    if (pRootItem)
    426426    {
    427         pRootItem->setData(QApplication::translate("UIVisoCreatorWidget", "Name"), UICustomFileSystemModelData_Name);
    428         pRootItem->setData(QApplication::translate("UIVisoCreatorWidget", "Size"), UICustomFileSystemModelData_Size);
    429         pRootItem->setData(QApplication::translate("UIVisoCreatorWidget", "Change Time"), UICustomFileSystemModelData_ChangeTime);
    430         pRootItem->setData(QApplication::translate("UIVisoCreatorWidget", "Owner"), UICustomFileSystemModelData_Owner);
    431         pRootItem->setData(QApplication::translate("UIVisoCreatorWidget", "Permissions"), UICustomFileSystemModelData_Permissions);
    432         pRootItem->setData(QApplication::translate("UIVisoCreatorWidget", "Local Path"), UICustomFileSystemModelData_LocalPath);
    433         pRootItem->setData(QApplication::translate("UIVisoCreatorWidget", "Has Removed Child"), UICustomFileSystemModelData_DescendantRemovedFromVISO);
     427        pRootItem->setData(QApplication::translate("UIVisoCreatorWidget", "Name"), UIFileSystemModelData_Name);
     428        pRootItem->setData(QApplication::translate("UIVisoCreatorWidget", "Size"), UIFileSystemModelData_Size);
     429        pRootItem->setData(QApplication::translate("UIVisoCreatorWidget", "Change Time"), UIFileSystemModelData_ChangeTime);
     430        pRootItem->setData(QApplication::translate("UIVisoCreatorWidget", "Owner"), UIFileSystemModelData_Owner);
     431        pRootItem->setData(QApplication::translate("UIVisoCreatorWidget", "Permissions"), UIFileSystemModelData_Permissions);
     432        pRootItem->setData(QApplication::translate("UIVisoCreatorWidget", "Local Path"), UIFileSystemModelData_LocalPath);
     433        pRootItem->setData(QApplication::translate("UIVisoCreatorWidget", "Has Removed Child"), UIFileSystemModelData_DescendantRemovedFromVISO);
    434434    }
    435435    if (m_pSubMenu)
     
    443443    if (!index.isValid() || !m_pTableProxyModel)
    444444        return;
    445     UICustomFileSystemItem *pClickedItem =
    446         static_cast<UICustomFileSystemItem*>(m_pTableProxyModel->mapToSource(index).internalPointer());
     445    UIFileSystemItem *pClickedItem =
     446        static_cast<UIFileSystemItem*>(m_pTableProxyModel->mapToSource(index).internalPointer());
    447447    if (!pClickedItem)
    448448        return;
     
    452452    if (pClickedItem->isRemovedFromViso())
    453453        return;
    454     QString strISOPath = pClickedItem->data(UICustomFileSystemModelData_ISOFilePath).toString();
     454    QString strISOPath = pClickedItem->data(UIFileSystemModelData_ISOFilePath).toString();
    455455    if (pClickedItem->isUpDirectory())
    456456        goUp();
    457457    else if (!strISOPath.isEmpty())
    458458    {
    459         importISOContentToViso(strISOPath, pClickedItem, pClickedItem->data(UICustomFileSystemModelData_LocalPath).toString());
     459        importISOContentToViso(strISOPath, pClickedItem, pClickedItem->data(UIFileSystemModelData_LocalPath).toString());
    460460        setTableRootIndex(index);
    461461    }
     
    482482         return;
    483483
    484     UICustomFileSystemItem *pParentItem = static_cast<UICustomFileSystemItem*>(parentIndex.internalPointer());
     484    UIFileSystemItem *pParentItem = static_cast<UIFileSystemItem*>(parentIndex.internalPointer());
    485485    if (!pParentItem)
    486486        return;
    487487
    488488    /*  Check to see if we already have a directory named strNewDirectoryName: */
    489     const QList<UICustomFileSystemItem*> children = pParentItem->children();
    490     foreach (const UICustomFileSystemItem *item, children)
     489    const QList<UIFileSystemItem*> children = pParentItem->children();
     490    foreach (const UIFileSystemItem *item, children)
    491491    {
    492492        if (item->fileObjectName() == strNewDirectoryName)
     
    494494    }
    495495
    496     UICustomFileSystemItem* pAddedItem = new UICustomFileSystemItem(strNewDirectoryName, pParentItem,
     496    UIFileSystemItem* pAddedItem = new UIFileSystemItem(strNewDirectoryName, pParentItem,
    497497                                                                    KFsObjType_Directory);
    498498
     
    514514}
    515515
    516 void UIVisoContentBrowser::removeItems(const QList<UICustomFileSystemItem*> itemList)
     516void UIVisoContentBrowser::removeItems(const QList<UIFileSystemItem*> itemList)
    517517{
    518518    AssertReturnVoid(m_pModel);
    519519    AssertReturnVoid(m_pTableProxyModel);
    520     foreach(UICustomFileSystemItem *pItem, itemList)
     520    foreach(UIFileSystemItem *pItem, itemList)
    521521    {
    522522        if (!pItem || pItem->isUpDirectory())
     
    530530        bool bFoundInMap = m_entryMap.remove(strVisoPath) > 0;
    531531        if (!bFoundInMap)
    532             createVisoEntry(pItem->path(), pItem->data(UICustomFileSystemModelData_LocalPath).toString(), true /* bool bRemove */);
     532            createVisoEntry(pItem->path(), pItem->data(UIFileSystemModelData_LocalPath).toString(), true /* bool bRemove */);
    533533
    534534        markRemovedUnremovedItemParents(pItem, true);
     
    539539}
    540540
    541 void UIVisoContentBrowser::restoreItems(const QList<UICustomFileSystemItem*> itemList)
    542 {
    543     foreach(UICustomFileSystemItem *pItem, itemList)
     541void UIVisoContentBrowser::restoreItems(const QList<UIFileSystemItem*> itemList)
     542{
     543    foreach(UIFileSystemItem *pItem, itemList)
    544544    {
    545545        if (!pItem || pItem->isUpDirectory())
     
    553553        bool bFoundInMap = m_entryMap.remove(strVisoPath) > 0;
    554554        if (!bFoundInMap)
    555             createVisoEntry(pItem->path(), pItem->data(UICustomFileSystemModelData_LocalPath).toString(), false /* bool bRemove */);
     555            createVisoEntry(pItem->path(), pItem->data(UIFileSystemModelData_LocalPath).toString(), false /* bool bRemove */);
    556556
    557557        markRemovedUnremovedItemParents(pItem, false);
     
    561561}
    562562
    563 void UIVisoContentBrowser::markRemovedUnremovedItemParents(UICustomFileSystemItem *pItem, bool fRemoved)
     563void UIVisoContentBrowser::markRemovedUnremovedItemParents(UIFileSystemItem *pItem, bool fRemoved)
    564564{
    565565    pItem->setRemovedFromViso(fRemoved);
    566     UICustomFileSystemItem *pRoot = rootItem();
    567     UICustomFileSystemItem *pParent = pItem->parentItem();
     566    UIFileSystemItem *pRoot = rootItem();
     567    UIFileSystemItem *pParent = pItem->parentItem();
    568568
    569569    while (pParent && pParent != pRoot)
    570570    {
    571571        pParent->setToolTip(QApplication::translate("UIVisoCreatorWidget", "Child/children removed"));
    572         pParent->setData(true, UICustomFileSystemModelData_DescendantRemovedFromVISO);
     572        pParent->setData(true, UIFileSystemModelData_DescendantRemovedFromVISO);
    573573        pParent = pParent->parentItem();
    574574    }
     
    579579    UIVisoBrowserBase::prepareObjects();
    580580
    581     m_pModel = new UICustomFileSystemModel(this);
    582     m_pTableProxyModel = new UICustomFileSystemProxyModel(this);
     581    m_pModel = new UIFileSystemModel(this);
     582    m_pTableProxyModel = new UIFileSystemProxyModel(this);
    583583    if (m_pTableProxyModel)
    584584    {
     
    616616    m_pTableView->setModel(m_pTableProxyModel);
    617617    setTableRootIndex();
    618     m_pTableView->hideColumn(UICustomFileSystemModelData_Owner);
    619     m_pTableView->hideColumn(UICustomFileSystemModelData_Permissions);
    620     m_pTableView->hideColumn(UICustomFileSystemModelData_Size);
    621     m_pTableView->hideColumn(UICustomFileSystemModelData_ChangeTime);
    622     m_pTableView->hideColumn(UICustomFileSystemModelData_ISOFilePath);
    623     m_pTableView->hideColumn(UICustomFileSystemModelData_RemovedFromVISO);
     618    m_pTableView->hideColumn(UIFileSystemModelData_Owner);
     619    m_pTableView->hideColumn(UIFileSystemModelData_Permissions);
     620    m_pTableView->hideColumn(UIFileSystemModelData_Size);
     621    m_pTableView->hideColumn(UIFileSystemModelData_ChangeTime);
     622    m_pTableView->hideColumn(UIFileSystemModelData_ISOFilePath);
     623    m_pTableView->hideColumn(UIFileSystemModelData_RemovedFromVISO);
    624624
    625625    m_pTableView->setSortingEnabled(true);
     
    729729                this, &UIVisoContentBrowser::sltTableSelectionChanged);
    730730    if (m_pModel)
    731         connect(m_pModel, &UICustomFileSystemModel::sigItemRenamed,
     731        connect(m_pModel, &UIFileSystemModel::sigItemRenamed,
    732732                this, &UIVisoContentBrowser::sltItemRenameAttempt);
    733733
     
    756756}
    757757
    758 UICustomFileSystemItem* UIVisoContentBrowser::rootItem()
     758UIFileSystemItem* UIVisoContentBrowser::rootItem()
    759759{
    760760    if (!m_pModel)
     
    763763}
    764764
    765 UICustomFileSystemItem* UIVisoContentBrowser::startItem()
    766 {
    767     UICustomFileSystemItem* pRoot = rootItem();
     765UIFileSystemItem* UIVisoContentBrowser::startItem()
     766{
     767    UIFileSystemItem* pRoot = rootItem();
    768768
    769769    if (!pRoot || pRoot->childCount() <= 0)
     
    781781    const QString startPath = QString("/");
    782782
    783     UICustomFileSystemItem *pStartItem = new UICustomFileSystemItem(startPath, rootItem(), KFsObjType_Directory);
     783    UIFileSystemItem *pStartItem = new UIFileSystemItem(startPath, rootItem(), KFsObjType_Directory);
    784784
    785785    pStartItem->setIsOpened(false);
     
    806806    if (strPath == currentPath())
    807807        return;
    808     UICustomFileSystemItem *pItem = searchItemByPath(strPath);
     808    UIFileSystemItem *pItem = searchItemByPath(strPath);
    809809
    810810    if (pItem && pItem->isDirectory() && !pItem->isRemovedFromViso())
     
    816816}
    817817
    818 UICustomFileSystemItem* UIVisoContentBrowser::searchItemByPath(const QString &strPath)
    819 {
    820     UICustomFileSystemItem *pItem = startItem();
     818UIFileSystemItem* UIVisoContentBrowser::searchItemByPath(const QString &strPath)
     819{
     820    UIFileSystemItem *pItem = startItem();
    821821    QStringList path = UIPathOperations::pathTrail(strPath);
    822822
     
    909909            continue;
    910910
    911         UICustomFileSystemItem *pParent = startItem();
     911        UIFileSystemItem *pParent = startItem();
    912912        /* Make sure all the parents from start item until the immediate parent are created: */
    913913        for (int i = 0; i < pathList.size(); ++i)
     
    916916            strPath.append(pathList[i]);
    917917
    918             UICustomFileSystemItem *pItem = searchItemByPath(strPath);
     918            UIFileSystemItem *pItem = searchItemByPath(strPath);
    919919            KFsObjType enmObjectType;
    920920            /* All objects, except possibly the last one, are directories:*/
     
    925925            if (!pItem)
    926926            {
    927                 pItem = new UICustomFileSystemItem(pathList[i], pParent, enmObjectType);
     927                pItem = new UIFileSystemItem(pathList[i], pParent, enmObjectType);
    928928                if (!pItem)
    929929                    continue;
    930930
    931931                if (i == pathList.size() - 1)
    932                     pItem->setData(strLocalPath, UICustomFileSystemModelData_LocalPath);
     932                    pItem->setData(strLocalPath, UIFileSystemModelData_LocalPath);
    933933                /* Pre-scan and populate the directory since we may need its content while processing removed items: */
    934934                if (enmObjectType == KFsObjType_Directory)
     
    936936            }
    937937            if (i == pathList.size() - 1)
    938                 createVisoEntry(pItem->path(), pItem->data(UICustomFileSystemModelData_LocalPath).toString(), false);
     938                createVisoEntry(pItem->path(), pItem->data(UIFileSystemModelData_LocalPath).toString(), false);
    939939            pParent = pItem;
    940940        }
     
    948948void UIVisoContentBrowser::processRemovedEntries(const QStringList &removedEntries)
    949949{
    950     QList<UICustomFileSystemItem*> itemList;
     950    QList<UIFileSystemItem*> itemList;
    951951    foreach (const QString &strPath, removedEntries)
    952952    {
    953953        QFileInfo fileInfo(strPath);
    954         UICustomFileSystemItem *pItem = searchItemByPath(strPath);
     954        UIFileSystemItem *pItem = searchItemByPath(strPath);
    955955        if (pItem)
    956956            itemList << pItem;
     
    971971}
    972972
    973 void UIVisoContentBrowser::scanHostDirectory(UICustomFileSystemItem *directoryItem, bool fRecursive)
     973void UIVisoContentBrowser::scanHostDirectory(UIFileSystemItem *directoryItem, bool fRecursive)
    974974{
    975975    if (!directoryItem)
     
    978978       should be empty: */
    979979    if ((directoryItem->type() != KFsObjType_Directory && !directoryItem->isSymLinkToADirectory()) ||
    980         directoryItem->data(UICustomFileSystemModelData_LocalPath).toString().isEmpty())
    981         return;
    982     QDir directory(directoryItem->data(UICustomFileSystemModelData_LocalPath).toString());
     980        directoryItem->data(UIFileSystemModelData_LocalPath).toString().isEmpty())
     981        return;
     982    QDir directory(directoryItem->data(UIFileSystemModelData_LocalPath).toString());
    983983    if (directory.exists() && !directoryItem->isOpened())
    984984    {
     
    991991                continue;
    992992            KFsObjType enmType = fileType(fileInfo);
    993             UICustomFileSystemItem *newItem = new UICustomFileSystemItem(fileInfo.fileName(),
     993            UIFileSystemItem *newItem = new UIFileSystemItem(fileInfo.fileName(),
    994994                                                                         directoryItem,
    995995                                                                         enmType);
    996             newItem->setData(fileInfo.filePath(), UICustomFileSystemModelData_LocalPath);
     996            newItem->setData(fileInfo.filePath(), UIFileSystemModelData_LocalPath);
    997997            if (fileInfo.isSymLink())
    998998            {
     
    10301030    const QString strName(QDir::toNativeSeparators("/"));
    10311031
    1032     rootItem()->child(0)->setData(strName, UICustomFileSystemModelData_Name);
     1032    rootItem()->child(0)->setData(strName, UIFileSystemModelData_Name);
    10331033    /* If the table root index is the start item then we have to update the location selector text here: */
    10341034    // if (m_pTableProxyModel->mapToSource(m_pTableView->rootIndex()).internalPointer() == rootItem()->child(0))
     
    10371037}
    10381038
    1039 void UIVisoContentBrowser::renameFileObject(UICustomFileSystemItem *pItem)
     1039void UIVisoContentBrowser::renameFileObject(UIFileSystemItem *pItem)
    10401040{
    10411041    m_pTableView->edit(m_pTableProxyModel->mapFromSource(m_pModel->index(pItem)));
     
    10441044void UIVisoContentBrowser::sltItemRenameAction()
    10451045{
    1046     QList<UICustomFileSystemItem*> selectedItems = tableSelectedItems();
     1046    QList<UIFileSystemItem*> selectedItems = tableSelectedItems();
    10471047    if (selectedItems.empty())
    10481048        return;
     
    10501050}
    10511051
    1052 void UIVisoContentBrowser::sltItemRenameAttempt(UICustomFileSystemItem *pItem, const QString &strOldPath,
     1052void UIVisoContentBrowser::sltItemRenameAttempt(UIFileSystemItem *pItem, const QString &strOldPath,
    10531053                                                const QString &strOldName, const QString &strNewName)
    10541054{
    10551055    if (!pItem || !pItem->parentItem())
    10561056        return;
    1057     QList<UICustomFileSystemItem*> children = pItem->parentItem()->children();
     1057    QList<UIFileSystemItem*> children = pItem->parentItem()->children();
    10581058    bool bDuplicate = false;
    1059     foreach (const UICustomFileSystemItem *item, children)
     1059    foreach (const UIFileSystemItem *item, children)
    10601060    {
    10611061        if (item->fileObjectName() == strNewName && item != pItem)
     
    10681068    {
    10691069        /* Restore the previous name in case the @strNewName is a duplicate: */
    1070         pItem->setData(strOldName, static_cast<int>(UICustomFileSystemModelData_Name));
     1070        pItem->setData(strOldName, static_cast<int>(UIFileSystemModelData_Name));
    10711071    }
    10721072    else
     
    10761076           VISO file for the old path since in some cases, when remaned item is not top level, it still
    10771077           appears in ISO. So we remove it explicitly: */
    1078         m_entryMap.insert(strNewPath, pItem->data(UICustomFileSystemModelData_LocalPath).toString());
     1078        m_entryMap.insert(strNewPath, pItem->data(UIFileSystemModelData_LocalPath).toString());
    10791079        m_entryMap.remove(strOldPath);
    1080         if (!pItem->data(UICustomFileSystemModelData_LocalPath).toString().isEmpty())
     1080        if (!pItem->data(UIFileSystemModelData_LocalPath).toString().isEmpty())
    10811081            m_entryMap.insert(strOldPath, cRemoveText);
    10821082    }
     
    11301130}
    11311131
    1132 QList<UICustomFileSystemItem*> UIVisoContentBrowser::tableSelectedItems()
    1133 {
    1134     QList<UICustomFileSystemItem*> selectedItems;
     1132QList<UIFileSystemItem*> UIVisoContentBrowser::tableSelectedItems()
     1133{
     1134    QList<UIFileSystemItem*> selectedItems;
    11351135    if (!m_pTableProxyModel)
    11361136        return selectedItems;
     
    11411141    foreach (QModelIndex index, list)
    11421142    {
    1143         UICustomFileSystemItem *pItem =
    1144             static_cast<UICustomFileSystemItem*>(m_pTableProxyModel->mapToSource(index).internalPointer());
     1143        UIFileSystemItem *pItem =
     1144            static_cast<UIFileSystemItem*>(m_pTableProxyModel->mapToSource(index).internalPointer());
    11451145        if (pItem)
    11461146            selectedItems << pItem;
     
    11541154        return QString();
    11551155    QModelIndex index = m_pTableProxyModel->mapToSource(m_pTableView->rootIndex());
    1156     UICustomFileSystemItem *pItem = static_cast<UICustomFileSystemItem*>((index).internalPointer());
     1156    UIFileSystemItem *pItem = static_cast<UIFileSystemItem*>((index).internalPointer());
    11571157    if (!pItem)
    11581158        return QString();
     
    11651165        return false;
    11661166    QModelIndex index = m_pTableProxyModel->mapToSource(m_pTableView->rootIndex());
    1167     UICustomFileSystemItem *pItem = static_cast<UICustomFileSystemItem*>((index).internalPointer());
     1167    UIFileSystemItem *pItem = static_cast<UIFileSystemItem*>((index).internalPointer());
    11681168    if (!index.isValid() || !pItem)
    11691169        return false;
     
    11911191}
    11921192
    1193 const UICustomFileSystemItem* UIVisoContentBrowser::currentDirectoryItem() const
     1193const UIFileSystemItem* UIVisoContentBrowser::currentDirectoryItem() const
    11941194{
    11951195    if (!m_pTableView || !m_pTableView->rootIndex().isValid())
     
    11971197    QModelIndex currentRoot = m_pTableProxyModel->mapToSource(m_pTableView->rootIndex());
    11981198
    1199     return static_cast<UICustomFileSystemItem*>(currentRoot.internalPointer());
     1199    return static_cast<UIFileSystemItem*>(currentRoot.internalPointer());
    12001200}
    12011201
    12021202QStringList UIVisoContentBrowser::currentDirectoryListing() const
    12031203{
    1204     const UICustomFileSystemItem *pCurrentDirectoryItem = currentDirectoryItem();
     1204    const UIFileSystemItem *pCurrentDirectoryItem = currentDirectoryItem();
    12051205    if (!pCurrentDirectoryItem)
    12061206        return QStringList();
    12071207    QStringList nameList;
    1208     foreach (const UICustomFileSystemItem *pChild, pCurrentDirectoryItem->children())
     1208    foreach (const UIFileSystemItem *pChild, pCurrentDirectoryItem->children())
    12091209    {
    12101210        if (pChild)
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/viso/UIVisoContentBrowser.h

    r100629 r102485  
    4343/* Forward declarations: */
    4444class QFileInfo;
    45 class UICustomFileSystemItem;
    46 class UICustomFileSystemModel;
    47 class UICustomFileSystemProxyModel;
     45class UIFileSystemItem;
     46class UIFileSystemModel;
     47class UIFileSystemProxyModel;
    4848class UIVisoContentTableView;
    4949
     
    6464    /* Imports pathList (relative to ISO file's root) to VISO content. */
    6565    void importISOContentToViso(const QString &strISOFilePath,
    66                                 UICustomFileSystemItem *pParentItem = 0,
     66                                UIFileSystemItem *pParentItem = 0,
    6767                                const QString &strDirPath = QString());
    6868    void removeISOContentFromViso();
     
    8787    /** Handles the signal we get from the model during setData call. Restores the old name of the file object
    8888     *  to @p strOldName if need be (if rename fails for some reason). */
    89     void sltItemRenameAttempt(UICustomFileSystemItem *pItem, const QString &strOldPath,
     89    void sltItemRenameAttempt(UIFileSystemItem *pItem, const QString &strOldPath,
    9090                              const QString &strOldName, const QString &strNewName);
    9191    void sltRemoveItems();
     
    115115    void                    prepareToolBar();
    116116    void                    initializeModel();
    117     UICustomFileSystemItem *rootItem();
     117    UIFileSystemItem *rootItem();
    118118    /* Child of root. */
    119     UICustomFileSystemItem *startItem();
     119    UIFileSystemItem *startItem();
    120120
    121121    QModelIndex             convertIndexToTableIndex(const QModelIndex &index);
    122122    /** Lists the content of the host file system directory by using Qt file system API. */
    123     void                    scanHostDirectory(UICustomFileSystemItem *directory, bool fRecursive);
     123    void                    scanHostDirectory(UIFileSystemItem *directory, bool fRecursive);
    124124    KFsObjType              fileType(const QFileInfo &fsInfo);
    125125    /** Renames the starts item's name as VISO name changes. */
    126126    void                    updateStartItemName();
    127     void                    renameFileObject(UICustomFileSystemItem *pItem);
    128     void                    removeItems(const QList<UICustomFileSystemItem*> itemList);
    129     void                    restoreItems(const QList<UICustomFileSystemItem*> itemList);
     127    void                    renameFileObject(UIFileSystemItem *pItem);
     128    void                    removeItems(const QList<UIFileSystemItem*> itemList);
     129    void                    restoreItems(const QList<UIFileSystemItem*> itemList);
    130130    /** Creates and entry for pItem consisting of a map item (key is viso path and value is host file system path)
    131131     *  if @p bRemove is true then the value is the string ":remove:" which effectively removes the file object
     
    133133    void                    createVisoEntry(const QString &strPath, const QString &strLocalPath, bool bRemove = false);
    134134    QString                 currentPath() const;
    135     UICustomFileSystemItem* searchItemByPath(const QString &strPath);
     135    UIFileSystemItem* searchItemByPath(const QString &strPath);
    136136    void                    goToStart();
    137137    /** Returns a list of items which are currecntly selected
    138138     *  in the table view. */
    139     QList<UICustomFileSystemItem*> tableSelectedItems();
     139    QList<UIFileSystemItem*> tableSelectedItems();
    140140    /* Names of the file objects of the current directory. */
    141141    QStringList                    currentDirectoryListing() const;
     
    145145    /* Processes a list of VISO paths that are loaded from a file and indicate file object to be removed from VISO content. */
    146146    void                           processRemovedEntries(const QStringList &removedEntries);
    147     const UICustomFileSystemItem*  currentDirectoryItem() const;
    148     void                           markRemovedUnremovedItemParents(UICustomFileSystemItem *pItem, bool fRemoved);
     147    const UIFileSystemItem*  currentDirectoryItem() const;
     148    void                           markRemovedUnremovedItemParents(UIFileSystemItem *pItem, bool fRemoved);
    149149    void                           enableDisableSelectionDependentActions();
    150150    UIVisoContentTableView        *m_pTableView;
    151     UICustomFileSystemModel       *m_pModel;
    152     UICustomFileSystemProxyModel  *m_pTableProxyModel;
     151    UIFileSystemModel             *m_pModel;
     152    UIFileSystemProxyModel        *m_pTableProxyModel;
    153153
    154154    QString                       m_strImportedISOPath;
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