VirtualBox

Changeset 71645 in vbox for trunk/src


Ignore:
Timestamp:
Apr 4, 2018 9:41:07 AM (7 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:6699 Some modifications to UIGuestFileTable class

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

Legend:

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

    r71639 r71645  
    5050
    5151/** QWidget extension
    52   * providing GUI with guest session information and control tab in session-information window. */
     52 * providing GUI with guest session information and control tab in session-information window. */
    5353class UIGuestControlFileManager : public QIWithRetranslateUI<QWidget>
    5454{
     
    103103    CGuest              m_comGuest;
    104104    CGuestSession       m_comGuestSession;
    105 
    106105    QVBoxLayout        *m_pMainLayout;
    107106    QSplitter          *m_pVerticalSplitter;
     
    113112    QHBoxLayout        *m_pFileTableContainerLayout;
    114113    QITabWidget        *m_pTabWidget;
     114
    115115    UIFileOperationsList       *m_pFileOperationsList;
    116     UIGuestControlConsole    *m_pConsole;
    117     UIGuestControlInterface  *m_pControlInterface;
    118 
     116    UIGuestControlConsole      *m_pConsole;
     117    UIGuestControlInterface    *m_pControlInterface;
     118    /* m_pSessionCreateWidget is a QWidget extension enabling user to start/stop
     119     * a Guest Control session. */
    119120    UIGuestSessionCreateWidget *m_pSessionCreateWidget;
    120121    UIGuestFileTable           *m_pGuestFileTable;
     
    128129
    129130#endif /* !___UIGuestControlFileManager_h___ */
    130 
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/guestctrl/UIGuestControlFileTable.cpp

    r71639 r71645  
    143143    :QThread(parent)
    144144    , m_pathList(pathList)
    145     , m_bContinueRunning(true)
     145    , m_fOkToContinue(true)
    146146{
    147147}
     
    156156{
    157157    m_mutex.lock();
    158     m_bContinueRunning = false;
     158    m_fOkToContinue = false;
    159159    m_mutex.unlock();
     160}
     161
     162bool UIDirectoryDiskUsageComputer::isOkToContinue() const
     163{
     164    return m_fOkToContinue;
    160165}
    161166
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/guestctrl/UIGuestControlFileTable.h

    r71639 r71645  
    5858};
    5959
     60/** A simple struck to store some statictics for a directory. Mainly used by  UIDirectoryDiskUsageComputer instances. */
    6061class UIDirectoryStatistics
    6162{
     
    7273
    7374/** Examines the paths in @p strStartPath and collects some staticstics from them recursively (in case directories)
    74     Runs on a worker thread to avoid GUI freezes. UIGuestFileTable and UIHostFileTable uses specialized children
    75     of this class since the call made on file objects are different */
     75 *  Runs on a worker thread to avoid GUI freezes. UIGuestFileTable and UIHostFileTable uses specialized children
     76 *  of this class since the calls made on file objects are different. */
    7677class UIDirectoryDiskUsageComputer : public QThread
    7778{
     
    8586
    8687    UIDirectoryDiskUsageComputer(QObject *parent, QStringList strStartPath);
     88    /** Sets the m_fOkToContinue to false. This results an early termination
     89      * of the  directoryStatisticsRecursive member function. */
    8790    void stopRecursion();
    8891
    8992protected:
    9093
    91     /** Read the directory with the path @p path recursively and collect #of objects and
    92         total size */
     94    /** Read the directory with the path @p path recursively and collect #of objects and  total size */
    9395    virtual void directoryStatisticsRecursive(const QString &path, UIDirectoryStatistics &statistics) = 0;
    94     void                  run();
     96    virtual void           run() /* override */;
     97    /** Returns the m_fOkToContinue flag */
     98    bool                  isOkToContinue() const;
     99    /** Stores a list of paths whose statistics are accumulated, can be file, directory etc: */
    95100    QStringList           m_pathList;
    96101    UIDirectoryStatistics m_resultStatistics;
    97     bool                  m_bContinueRunning;
    98102    QMutex                m_mutex;
     103
     104private:
     105
     106    bool     m_fOkToContinue;
    99107};
    100108
     
    148156
    149157    /** @p data contains values to be shown in table view's colums. data[0] is assumed to be
    150         the name of the file object which is the file name including extension or name of the
    151         directory */
     158     *  the name of the file object which is the file name including extension or name of the
     159     *  directory */
    152160    explicit UIFileTableItem(const QList<QVariant> &data,
    153161                             UIFileTableItem *parentItem, FileObjectType type);
     
    214222
    215223/** This class serves a base class for file table. Currently a guest version
    216     and a host version are derived from this base. Each of these children
    217     populates the UIGuestControlFileModel by scanning the file system
    218     differently. The file structre kept in this class as a tree. */
     224 *  and a host version are derived from this base. Each of these children
     225 *  populates the UIGuestControlFileModel by scanning the file system
     226 *  differently. The file structre kept in this class as a tree. */
    219227class UIGuestControlFileTable : public QIWithRetranslateUI<QWidget>
    220228{
     
    250258    void insertItemsToTree(QMap<QString,UIFileTableItem*> &map, UIFileTableItem *parent,
    251259                           bool isDirectoryMap, bool isStartDir);
    252     virtual void readDirectory(const QString& strPath, UIFileTableItem *parent, bool isStartDir = false) = 0;
    253     virtual void deleteByItem(UIFileTableItem *item) = 0;
    254     virtual void goToHomeDirectory() = 0;
    255     virtual bool renameItem(UIFileTableItem *item, QString newBaseName) = 0;
    256     virtual bool createDirectory(const QString &path, const QString &directoryName) = 0;
    257     virtual QString fsObjectPropertyString() = 0;
    258     virtual void  showProperties() = 0;
    259     static QString fileTypeString(FileObjectType type);
     260    virtual void     readDirectory(const QString& strPath, UIFileTableItem *parent, bool isStartDir = false) = 0;
     261    virtual void     deleteByItem(UIFileTableItem *item) = 0;
     262    virtual void     goToHomeDirectory() = 0;
     263    virtual bool     renameItem(UIFileTableItem *item, QString newBaseName) = 0;
     264    virtual bool     createDirectory(const QString &path, const QString &directoryName) = 0;
     265    virtual QString  fsObjectPropertyString() = 0;
     266    virtual void     showProperties() = 0;
     267    static QString   fileTypeString(FileObjectType type);
    260268    void             goIntoDirectory(const QModelIndex &itemIndex);
    261     /** Follow the path trail, open directories as we go and descend */
     269    /** Follows the path trail, opens directories as it descends */
    262270    void             goIntoDirectory(const QList<QString> &pathTrail);
    263     /** Go into directory pointed by the @p item */
     271    /** Goes into directory pointed by the @p item */
    264272    void             goIntoDirectory(UIFileTableItem *item);
    265273    UIFileTableItem* indexData(const QModelIndex &index) const;
    266     void keyPressEvent(QKeyEvent * pEvent);
    267     CGuestFsObjInfo guestFsObjectInfo(const QString& path, CGuestSession &comGuestSession) const;
     274    void             keyPressEvent(QKeyEvent * pEvent);
     275    CGuestFsObjInfo  guestFsObjectInfo(const QString& path, CGuestSession &comGuestSession) const;
    268276
    269277    UIFileTableItem         *m_pRootItem;
    270 
    271278    UIGuestControlFileView  *m_pView;
    272279    UIGuestControlFileModel *m_pModel;
     
    302309    void             prepareActions();
    303310    void             deleteByIndex(const QModelIndex &itemIndex);
    304     /** Return the UIFileTableItem for path / which is a direct (and single) child of m_pRootItem */
     311    /** Returns the UIFileTableItem for path / which is a direct (and single) child of m_pRootItem */
    305312    UIFileTableItem *getStartDirectoryItem();
    306313    /** Shows a modal dialog with a line edit for user to enter a new directory name and return the entered string*/
     
    321328    QVector<QAction*> m_selectionDependentActions;
    322329    /** The absolue path list of the file objects which user has chosen to cut/copy. this
    323         list will be cleaned after a paste operation or overwritten by a subsequent cut/copy */
     330      * list will be cleaned after a paste operation or overwritten by a subsequent cut/copy */
    324331    QStringList       m_copyCutBuffer;
    325332    friend class UIGuestControlFileModel;
     
    327334
    328335#endif /* !___UIGuestControlFileTable_h___ */
    329 
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/guestctrl/UIGuestFileTable.cpp

    r71639 r71645  
    5454protected:
    5555
     56    virtual void run() /* override */;
    5657    virtual void directoryStatisticsRecursive(const QString &path, UIDirectoryStatistics &statistics) /* override */;
    5758
     
    7273}
    7374
     75void UIGuestDirectoryDiskUsageComputer::run()
     76{
     77    /* Initialize COM: */
     78    COMBase::InitializeCOM(false);
     79    UIDirectoryDiskUsageComputer::run();
     80    /* Cleanup COM: */
     81    COMBase::CleanupCOM();
     82}
     83
    7484void UIGuestDirectoryDiskUsageComputer::directoryStatisticsRecursive(const QString &path, UIDirectoryStatistics &statistics)
    7585{
    7686    if (m_comGuestSession.isNull())
    7787        return;
    78     if (!m_bContinueRunning)
    79         return;
     88    /* Prevent modification of the continue flag while reading: */
     89    m_mutex.lock();
     90    /* Check if m_fOkToContinue is set to false. if so just end recursion: */
     91    if (!isOkToContinue())
     92    {
     93        m_mutex.unlock();
     94        return;
     95    }
     96    m_mutex.unlock();
     97
    8098    CGuestFsObjInfo fileInfo = m_comGuestSession.FsObjQueryInfo(path, true);
    8199
     
    461479
    462480    /** @todo I have decided to look into this afterwards when API is more mature, for
    463         currently this stuff runs into an assert in Main: */
     481        currently this stuff runs into an assert in Main. this may be because that I will have to init deinit
     482        COM. see UIThreadWorker: */
    464483    /* if the selection include a directory or it is a multiple selection the create a worker thread
    465484       to compute total size of the selection (recusively) */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/guestctrl/UIGuestFileTable.h

    r71639 r71645  
    2626#include "UIGuestControlFileTable.h"
    2727
    28 /** This class scans the guest file system by using the VBox API
    29     and populates the UIGuestControlFileModel*/
     28/** This class scans the guest file system by using the VBox Guest Control API
     29 *  and populates the UIGuestControlFileModel*/
    3030class UIGuestFileTable : public UIGuestControlFileTable
    3131{
     
    6363
    6464#endif /* !___UIGuestControlFileTable_h___ */
    65 
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/guestctrl/UIHostFileTable.cpp

    r71639 r71645  
    6262void UIHostDirectoryDiskUsageComputer::directoryStatisticsRecursive(const QString &path, UIDirectoryStatistics &statistics)
    6363{
    64 
    65     if (!m_bContinueRunning)
    66         return;
     64    /* Prevent modification of the continue flag while reading: */
     65    m_mutex.lock();
     66    /* Check if m_fOkToContinue is set to false. if so just end recursion: */
     67    if (!isOkToContinue())
     68    {
     69        m_mutex.unlock();
     70        return;
     71    }
     72    m_mutex.unlock();
     73
    6774    QFileInfo fileInfo(path);
    6875    if (!fileInfo.exists())
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