- Timestamp:
- Apr 4, 2018 9:41:07 AM (7 years ago)
- 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 50 50 51 51 /** 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. */ 53 53 class UIGuestControlFileManager : public QIWithRetranslateUI<QWidget> 54 54 { … … 103 103 CGuest m_comGuest; 104 104 CGuestSession m_comGuestSession; 105 106 105 QVBoxLayout *m_pMainLayout; 107 106 QSplitter *m_pVerticalSplitter; … … 113 112 QHBoxLayout *m_pFileTableContainerLayout; 114 113 QITabWidget *m_pTabWidget; 114 115 115 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. */ 119 120 UIGuestSessionCreateWidget *m_pSessionCreateWidget; 120 121 UIGuestFileTable *m_pGuestFileTable; … … 128 129 129 130 #endif /* !___UIGuestControlFileManager_h___ */ 130 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/guestctrl/UIGuestControlFileTable.cpp
r71639 r71645 143 143 :QThread(parent) 144 144 , m_pathList(pathList) 145 , m_ bContinueRunning(true)145 , m_fOkToContinue(true) 146 146 { 147 147 } … … 156 156 { 157 157 m_mutex.lock(); 158 m_ bContinueRunning= false;158 m_fOkToContinue = false; 159 159 m_mutex.unlock(); 160 } 161 162 bool UIDirectoryDiskUsageComputer::isOkToContinue() const 163 { 164 return m_fOkToContinue; 160 165 } 161 166 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/guestctrl/UIGuestControlFileTable.h
r71639 r71645 58 58 }; 59 59 60 /** A simple struck to store some statictics for a directory. Mainly used by UIDirectoryDiskUsageComputer instances. */ 60 61 class UIDirectoryStatistics 61 62 { … … 72 73 73 74 /** Examines the paths in @p strStartPath and collects some staticstics from them recursively (in case directories) 74 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. */ 76 77 class UIDirectoryDiskUsageComputer : public QThread 77 78 { … … 85 86 86 87 UIDirectoryDiskUsageComputer(QObject *parent, QStringList strStartPath); 88 /** Sets the m_fOkToContinue to false. This results an early termination 89 * of the directoryStatisticsRecursive member function. */ 87 90 void stopRecursion(); 88 91 89 92 protected: 90 93 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 */ 93 95 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: */ 95 100 QStringList m_pathList; 96 101 UIDirectoryStatistics m_resultStatistics; 97 bool m_bContinueRunning;98 102 QMutex m_mutex; 103 104 private: 105 106 bool m_fOkToContinue; 99 107 }; 100 108 … … 148 156 149 157 /** @p data contains values to be shown in table view's colums. data[0] is assumed to be 150 151 158 * the name of the file object which is the file name including extension or name of the 159 * directory */ 152 160 explicit UIFileTableItem(const QList<QVariant> &data, 153 161 UIFileTableItem *parentItem, FileObjectType type); … … 214 222 215 223 /** This class serves a base class for file table. Currently a guest version 216 217 218 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. */ 219 227 class UIGuestControlFileTable : public QIWithRetranslateUI<QWidget> 220 228 { … … 250 258 void insertItemsToTree(QMap<QString,UIFileTableItem*> &map, UIFileTableItem *parent, 251 259 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); 260 268 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 */ 262 270 void goIntoDirectory(const QList<QString> &pathTrail); 263 /** Go into directory pointed by the @p item */271 /** Goes into directory pointed by the @p item */ 264 272 void goIntoDirectory(UIFileTableItem *item); 265 273 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; 268 276 269 277 UIFileTableItem *m_pRootItem; 270 271 278 UIGuestControlFileView *m_pView; 272 279 UIGuestControlFileModel *m_pModel; … … 302 309 void prepareActions(); 303 310 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 */ 305 312 UIFileTableItem *getStartDirectoryItem(); 306 313 /** Shows a modal dialog with a line edit for user to enter a new directory name and return the entered string*/ … … 321 328 QVector<QAction*> m_selectionDependentActions; 322 329 /** The absolue path list of the file objects which user has chosen to cut/copy. this 323 330 * list will be cleaned after a paste operation or overwritten by a subsequent cut/copy */ 324 331 QStringList m_copyCutBuffer; 325 332 friend class UIGuestControlFileModel; … … 327 334 328 335 #endif /* !___UIGuestControlFileTable_h___ */ 329 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/guestctrl/UIGuestFileTable.cpp
r71639 r71645 54 54 protected: 55 55 56 virtual void run() /* override */; 56 57 virtual void directoryStatisticsRecursive(const QString &path, UIDirectoryStatistics &statistics) /* override */; 57 58 … … 72 73 } 73 74 75 void UIGuestDirectoryDiskUsageComputer::run() 76 { 77 /* Initialize COM: */ 78 COMBase::InitializeCOM(false); 79 UIDirectoryDiskUsageComputer::run(); 80 /* Cleanup COM: */ 81 COMBase::CleanupCOM(); 82 } 83 74 84 void UIGuestDirectoryDiskUsageComputer::directoryStatisticsRecursive(const QString &path, UIDirectoryStatistics &statistics) 75 85 { 76 86 if (m_comGuestSession.isNull()) 77 87 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 80 98 CGuestFsObjInfo fileInfo = m_comGuestSession.FsObjQueryInfo(path, true); 81 99 … … 461 479 462 480 /** @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: */ 464 483 /* if the selection include a directory or it is a multiple selection the create a worker thread 465 484 to compute total size of the selection (recusively) */ -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/guestctrl/UIGuestFileTable.h
r71639 r71645 26 26 #include "UIGuestControlFileTable.h" 27 27 28 /** This class scans the guest file system by using the VBox API29 28 /** This class scans the guest file system by using the VBox Guest Control API 29 * and populates the UIGuestControlFileModel*/ 30 30 class UIGuestFileTable : public UIGuestControlFileTable 31 31 { … … 63 63 64 64 #endif /* !___UIGuestControlFileTable_h___ */ 65 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/guestctrl/UIHostFileTable.cpp
r71639 r71645 62 62 void UIHostDirectoryDiskUsageComputer::directoryStatisticsRecursive(const QString &path, UIDirectoryStatistics &statistics) 63 63 { 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 67 74 QFileInfo fileInfo(path); 68 75 if (!fileInfo.exists())
Note:
See TracChangeset
for help on using the changeset viewer.