Changeset 102485 in vbox
- Timestamp:
- Dec 5, 2023 5:37:02 PM (12 months ago)
- 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 820 820 src/globals/UIAnimationFramework.h \ 821 821 src/globals/UICommon.h \ 822 src/globals/UI CustomFileSystemModel.h \822 src/globals/UIFileSystemModel.h \ 823 823 src/globals/UIDesktopWidgetWatchdog.h \ 824 824 src/globals/UIMainEventListener.h \ … … 1389 1389 src/globals/UICommon.cpp \ 1390 1390 src/globals/UICursor.cpp \ 1391 src/globals/UI CustomFileSystemModel.cpp \1391 src/globals/UIFileSystemModel.cpp \ 1392 1392 src/globals/UIDefs.cpp \ 1393 1393 src/globals/UIDesktopWidgetWatchdog.cpp \ -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIFileSystemModel.h
r102484 r102485 1 1 /* $Id$ */ 2 2 /** @file 3 * VBox Qt GUI - UI CustomFileSystemModel class declaration.3 * VBox Qt GUI - UIFileSystemModel class declaration. 4 4 */ 5 5 … … 26 26 */ 27 27 28 #ifndef FEQT_INCLUDED_SRC_globals_UI CustomFileSystemModel_h29 #define FEQT_INCLUDED_SRC_globals_UI CustomFileSystemModel_h28 #ifndef FEQT_INCLUDED_SRC_globals_UIFileSystemModel_h 29 #define FEQT_INCLUDED_SRC_globals_UIFileSystemModel_h 30 30 #ifndef RT_WITHOUT_PRAGMA_ONCE 31 31 # pragma once … … 42 42 43 43 class QMimeData; 44 class UI CustomFileSystemModel;45 46 enum UI CustomFileSystemModelData47 { 48 UI CustomFileSystemModelData_Name = 0,49 UI CustomFileSystemModelData_Size,50 UI CustomFileSystemModelData_ChangeTime,51 UI CustomFileSystemModelData_Owner,52 UI CustomFileSystemModelData_Permissions,53 UI CustomFileSystemModelData_LocalPath,54 UI CustomFileSystemModelData_ISOFilePath, /* in case of import-iso this contains full path of the container iso file. */55 UI CustomFileSystemModelData_RemovedFromVISO,56 UI CustomFileSystemModelData_DescendantRemovedFromVISO,57 UI CustomFileSystemModelData_Max58 }; 59 60 /** A UI CustomFileSystemItem instance is a tree node representing a file object (file, directory, etc). The tree contructed61 by these instances is the data source for the UI CustomFileSystemModel. */62 class SHARED_LIBRARY_STUFF UI CustomFileSystemItem44 class UIFileSystemModel; 45 46 enum 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. */ 62 class SHARED_LIBRARY_STUFF UIFileSystemItem 63 63 { 64 64 … … 66 66 67 67 /** @p strName contains file object name which is assumed to be unique among a parent object's children. */ 68 UI CustomFileSystemItem(const QString &strFileObjectName, UICustomFileSystemItem *parentItem, KFsObjType type);69 virtual ~UI CustomFileSystemItem();68 UIFileSystemItem(const QString &strFileObjectName, UIFileSystemItem *parentItem, KFsObjType type); 69 virtual ~UIFileSystemItem(); 70 70 71 71 void reset(); 72 virtual UI CustomFileSystemItem *child(int row) const;72 virtual UIFileSystemItem *child(int row) const; 73 73 /** Searches for the child by file object name and returns it if found. */ 74 UI CustomFileSystemItem *child(const QString &strFileObjectName) const;74 UIFileSystemItem *child(const QString &strFileObjectName) const; 75 75 int childCount() const; 76 QList<UI CustomFileSystemItem*> children() const;76 QList<UIFileSystemItem*> children() const; 77 77 /** Removes the item from the list of children and !!DELETES!! the item. */ 78 void removeChild(UI CustomFileSystemItem *pItem);78 void removeChild(UIFileSystemItem *pItem); 79 79 void removeChildren(); 80 80 int columnCount() const; 81 81 QVariant data(int column) const; 82 82 void setData(const QVariant &data, int index); 83 void setData(const QVariant &data, UI CustomFileSystemModelData enmColumn);83 void setData(const QVariant &data, UIFileSystemModelData enmColumn); 84 84 int row() const; 85 UI CustomFileSystemItem *parentItem();86 UI CustomFileSystemItem *parentItem() const;85 UIFileSystemItem *parentItem(); 86 UIFileSystemItem *parentItem() const; 87 87 88 88 bool isDirectory() const; … … 128 128 private: 129 129 130 void appendChild(UI CustomFileSystemItem *child);131 void setParentModel(UI CustomFileSystemModel *pModel);132 UI CustomFileSystemModel *parentModel();133 134 QList<UI CustomFileSystemItem*> m_childItems;135 QMap<UI CustomFileSystemModelData, QVariant> m_itemData;136 UI CustomFileSystemItem *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; 137 137 bool m_bIsOpened; 138 138 /** If this is a symlink m_targetPath keeps the absolute path of the target */ … … 147 147 QString m_strToolTip; 148 148 /** Pointer to the parent model. */ 149 UI CustomFileSystemModel *m_pParentModel;150 friend UI CustomFileSystemModel;149 UIFileSystemModel *m_pParentModel; 150 friend UIFileSystemModel; 151 151 }; 152 152 153 153 /** A QSortFilterProxyModel extension used in file tables. Modifies some 154 154 * of the base class behavior like lessThan(..) */ 155 class SHARED_LIBRARY_STUFF UI CustomFileSystemProxyModel : public QSortFilterProxyModel155 class SHARED_LIBRARY_STUFF UIFileSystemProxyModel : public QSortFilterProxyModel 156 156 { 157 157 … … 160 160 public: 161 161 162 UI CustomFileSystemProxyModel(QObject *parent = 0);162 UIFileSystemProxyModel(QObject *parent = 0); 163 163 164 164 void setListDirectoriesOnTop(bool fListDirectoriesOnTop); … … 180 180 }; 181 181 182 /** UI CustomFileSystemModel serves as the model for a file structure.182 /** UIFileSystemModel serves as the model for a file structure. 183 183 * it supports a tree level hierarchy which can be displayed with 184 184 * QTableView and/or QTreeView.*/ 185 class SHARED_LIBRARY_STUFF UI CustomFileSystemModel : public QAbstractItemModel185 class SHARED_LIBRARY_STUFF UIFileSystemModel : public QAbstractItemModel 186 186 { 187 187 … … 190 190 signals: 191 191 192 void sigItemRenamed(UI CustomFileSystemItem *pItem, const QString &strOldPath,192 void sigItemRenamed(UIFileSystemItem *pItem, const QString &strOldPath, 193 193 const QString &strOldName, const QString &strNewName); 194 194 195 195 public: 196 196 197 explicit UI CustomFileSystemModel(QObject *parent = 0);198 ~UI CustomFileSystemModel();197 explicit UIFileSystemModel(QObject *parent = 0); 198 ~UIFileSystemModel(); 199 199 200 200 QVariant data(const QModelIndex &index, int role) const RT_OVERRIDE; … … 206 206 QModelIndex index(int row, int column, 207 207 const QModelIndex &parent = QModelIndex()) const RT_OVERRIDE; 208 QModelIndex index(const UI CustomFileSystemItem* item);208 QModelIndex index(const UIFileSystemItem* item); 209 209 QModelIndex parent(const QModelIndex &index) const RT_OVERRIDE; 210 210 int rowCount(const QModelIndex &parent = QModelIndex()) const RT_OVERRIDE; … … 218 218 void setShowHumanReadableSizes(bool fShowHumanReadableSizes); 219 219 bool showHumanReadableSizes() const; 220 void deleteItem(UI CustomFileSystemItem* pItem);221 UI CustomFileSystemItem* rootItem();222 const UI CustomFileSystemItem* rootItem() const;220 void deleteItem(UIFileSystemItem* pItem); 221 UIFileSystemItem* rootItem(); 222 const UIFileSystemItem* rootItem() const; 223 223 224 224 void setIsWindowsFileSystem(bool fIsWindowsFileSystem); … … 233 233 private: 234 234 235 UI CustomFileSystemItem *m_pRootItem;236 void setupModelData(const QStringList &lines, UI CustomFileSystemItem *parent);235 UIFileSystemItem *m_pRootItem; 236 void setupModelData(const QStringList &lines, UIFileSystemItem *parent); 237 237 bool m_fShowHumanReadableSizes; 238 238 bool m_fIsWindowFileSystemModel; … … 240 240 241 241 242 #endif /* !FEQT_INCLUDED_SRC_globals_UI CustomFileSystemModel_h */242 #endif /* !FEQT_INCLUDED_SRC_globals_UIFileSystemModel_h */ -
trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerGuestTable.cpp
r102418 r102485 38 38 #include "UIConverter.h" 39 39 #include "UICommon.h" 40 #include "UI CustomFileSystemModel.h"40 #include "UIFileSystemModel.h" 41 41 #include "UIErrorString.h" 42 42 #include "UIFileManager.h" … … 515 515 516 516 bool UIFileManagerGuestTable::readDirectory(const QString& strPath, 517 UI CustomFileSystemItem *parent, bool isStartDir /*= false*/)517 UIFileSystemItem *parent, bool isStartDir /*= false*/) 518 518 { 519 519 if (!parent) … … 549 549 } 550 550 551 QMap<QString, UI CustomFileSystemItem*> fileObjects;551 QMap<QString, UIFileSystemItem*> fileObjects; 552 552 553 553 while (directory.isOk()) … … 562 562 QDateTime changeTime = QDateTime::fromMSecsSinceEpoch(fsInfo.GetChangeTime()/RT_NS_1MS); 563 563 KFsObjType fsObjectType = fileType(fsInfo); 564 UI CustomFileSystemItem *item = new UICustomFileSystemItem(fsInfo.GetName(), parent, fsObjectType);564 UIFileSystemItem *item = new UIFileSystemItem(fsInfo.GetName(), parent, fsObjectType); 565 565 if (!item) 566 566 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); 572 571 item->setIsOpened(false); 573 572 item->setIsHidden(isFileObjectHidden(fsInfo)); … … 606 605 } 607 606 608 void UIFileManagerGuestTable::deleteByItem(UI CustomFileSystemItem *item)607 void UIFileManagerGuestTable::deleteByItem(UIFileSystemItem *item) 609 608 { 610 609 if (!item) … … 633 632 if (!rootItem() || rootItem()->childCount() <= 0) 634 633 return; 635 UI CustomFileSystemItem *startDirItem = rootItem()->child(0);634 UIFileSystemItem *startDirItem = rootItem()->child(0); 636 635 if (!startDirItem) 637 636 return; … … 651 650 } 652 651 653 bool UIFileManagerGuestTable::renameItem(UI CustomFileSystemItem *item, const QString &strOldPath)652 bool UIFileManagerGuestTable::renameItem(UIFileSystemItem *item, const QString &strOldPath) 654 653 { 655 654 if (!item || item->isUpDirectory()) -
trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerGuestTable.h
r102418 r102485 53 53 class CGuestSessionStateChangedEvent; 54 54 class UIActionPool; 55 class UI CustomFileSystemItem;55 class UIFileSystemItem; 56 56 class UIGuestSessionWidget; 57 57 … … 81 81 82 82 void retranslateUi() override final; 83 virtual bool readDirectory(const QString& strPath, UI CustomFileSystemItem *parent, bool isStartDir = false) override final;84 virtual void deleteByItem(UI CustomFileSystemItem *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; 85 85 virtual void goToHomeDirectory() override final; 86 virtual bool renameItem(UI CustomFileSystemItem *item, const QString &strOldPath) override final;86 virtual bool renameItem(UIFileSystemItem *item, const QString &strOldPath) override final; 87 87 virtual bool createDirectory(const QString &path, const QString &directoryName) override final; 88 88 virtual QString fsObjectPropertyString() override final; -
trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerHostTable.cpp
r102481 r102485 37 37 #include "UIFileManager.h" 38 38 #include "UIFileTableNavigationWidget.h" 39 #include "UI CustomFileSystemModel.h"39 #include "UIFileSystemModel.h" 40 40 #include "UIFileManagerHostTable.h" 41 41 #include "UIPathOperations.h" … … 112 112 const QFileInfo &entryInfo = entryList.at(i); 113 113 if (entryInfo.baseName().isEmpty() || entryInfo.baseName() == "." || 114 entryInfo.baseName() == UI CustomFileSystemModel::strUpDirectoryString)114 entryInfo.baseName() == UIFileSystemModel::strUpDirectoryString) 115 115 continue; 116 116 statistics.m_totalSize += entryInfo.size(); … … 157 157 } 158 158 159 /* static */ bool UIFileManagerHostTable::scanDirectory(const QString& strPath, UI CustomFileSystemItem *parent,160 QMap<QString, UI CustomFileSystemItem*> &fileObjects)159 /* static */ bool UIFileManagerHostTable::scanDirectory(const QString& strPath, UIFileSystemItem *parent, 160 QMap<QString, UIFileSystemItem*> &fileObjects) 161 161 { 162 162 … … 173 173 { 174 174 const QFileInfo &fileInfo = entries.at(i); 175 UI CustomFileSystemItem *item = new UICustomFileSystemItem(fileInfo.fileName(), parent, fileType(fileInfo));175 UIFileSystemItem *item = new UIFileSystemItem(fileInfo.fileName(), parent, fileType(fileInfo)); 176 176 if (!item) 177 177 continue; 178 178 179 item->setData(fileInfo.size(), UI CustomFileSystemModelData_Size);180 item->setData(fileInfo.lastModified(), UI CustomFileSystemModelData_ChangeTime);181 item->setData(fileInfo.owner(), UI CustomFileSystemModelData_Owner);182 item->setData(permissionString(fileInfo.permissions()), UI CustomFileSystemModelData_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); 183 183 184 184 /* if the item is a symlink set the target path and … … 282 282 } 283 283 284 bool UIFileManagerHostTable::readDirectory(const QString& strPath, UI CustomFileSystemItem *parent, bool isStartDir /*= false*/)284 bool UIFileManagerHostTable::readDirectory(const QString& strPath, UIFileSystemItem *parent, bool isStartDir /*= false*/) 285 285 { 286 286 if (!parent) 287 287 return false; 288 288 289 QMap<QString, UI CustomFileSystemItem*> fileObjects;289 QMap<QString, UIFileSystemItem*> fileObjects; 290 290 if (!scanDirectory(strPath, parent, fileObjects)) 291 291 return false; … … 294 294 } 295 295 296 void UIFileManagerHostTable::deleteByItem(UI CustomFileSystemItem *item)296 void UIFileManagerHostTable::deleteByItem(UIFileSystemItem *item) 297 297 { 298 298 if (item->isUpDirectory()) … … 320 320 if (!rootItem() || rootItem()->childCount() <= 0) 321 321 return; 322 UI CustomFileSystemItem *startDirItem = rootItem()->child(0);322 UIFileSystemItem *startDirItem = rootItem()->child(0); 323 323 if (!startDirItem) 324 324 return; … … 328 328 } 329 329 330 bool UIFileManagerHostTable::renameItem(UI CustomFileSystemItem *item, const QString &strOldPath)330 bool UIFileManagerHostTable::renameItem(UIFileSystemItem *item, const QString &strOldPath) 331 331 { 332 332 if (!item || item->isUpDirectory()) -
trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerHostTable.h
r102418 r102485 40 40 /* Forward declarations: */ 41 41 class UIActionPool; 42 class UI CustomFileSystemItem;42 class UIFileSystemItem; 43 43 44 44 /** This class scans the host file system by using the Qt API 45 and connects to the UI CustomFileSystemModel*/45 and connects to the UIFileSystemModel*/ 46 46 class UIFileManagerHostTable : public UIFileManagerTable 47 47 { … … 61 61 /** Scans the directory with the path @strPath and inserts items to the 62 62 * tree under the @p parent. */ 63 static bool scanDirectory(const QString& strPath, UI CustomFileSystemItem *parent,64 QMap<QString, UI CustomFileSystemItem*> &fileObjects);63 static bool scanDirectory(const QString& strPath, UIFileSystemItem *parent, 64 QMap<QString, UIFileSystemItem*> &fileObjects); 65 65 void retranslateUi() override final; 66 virtual bool readDirectory(const QString& strPath, UI CustomFileSystemItem *parent, bool isStartDir = false) override final;67 virtual void deleteByItem(UI CustomFileSystemItem *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; 68 68 virtual void goToHomeDirectory() override final; 69 virtual bool renameItem(UI CustomFileSystemItem *item, const QString &strOldPath) override final;69 virtual bool renameItem(UIFileSystemItem *item, const QString &strOldPath) override final; 70 70 virtual bool createDirectory(const QString &path, const QString &directoryName) override final; 71 71 virtual QString fsObjectPropertyString() override final; -
trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerTable.cpp
r102446 r102485 43 43 #include "UIActionPool.h" 44 44 #include "UICommon.h" 45 #include "UI CustomFileSystemModel.h"45 #include "UIFileSystemModel.h" 46 46 #include "UIErrorString.h" 47 47 #include "UIFileManager.h" … … 458 458 } 459 459 460 m_pModel = new UI CustomFileSystemModel(this);460 m_pModel = new UIFileSystemModel(this); 461 461 if (!m_pModel) 462 462 return; 463 463 464 connect(m_pModel, &UI CustomFileSystemModel::sigItemRenamed,464 connect(m_pModel, &UIFileSystemModel::sigItemRenamed, 465 465 this, &UIFileManagerTable::sltHandleItemRenameAttempt); 466 466 467 m_pProxyModel = new UI CustomFileSystemProxyModel(this);467 m_pProxyModel = new UIFileSystemProxyModel(this); 468 468 if (!m_pProxyModel) 469 469 return; … … 497 497 connect(m_pView, &UIGuestControlFileView::customContextMenuRequested, 498 498 this, &UIFileManagerTable::sltCreateFileViewContextMenu); 499 m_pView->hideColumn(UI CustomFileSystemModelData_LocalPath);500 m_pView->hideColumn(UI CustomFileSystemModelData_ISOFilePath);501 m_pView->hideColumn(UI CustomFileSystemModelData_RemovedFromVISO);502 m_pView->hideColumn(UI CustomFileSystemModelData_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); 503 503 504 504 m_sessionWidgets << m_pView; … … 536 536 m_pView->selectionModel()->reset(); 537 537 538 UI CustomFileSystemItem *item = static_cast<UICustomFileSystemItem*>(index.internalPointer());538 UIFileSystemItem *item = static_cast<UIFileSystemItem*>(index.internalPointer()); 539 539 if (item) 540 540 { … … 556 556 /* On Unix-like systems startItem represents the root directory. On Windows it is like "my computer" under which 557 557 * drives are listed: */ 558 UI CustomFileSystemItem* startItem = new UICustomFileSystemItem(startPath, rootItem(), KFsObjType_Directory);558 UIFileSystemItem* startItem = new UIFileSystemItem(startPath, rootItem(), KFsObjType_Directory); 559 559 560 560 startItem->setIsOpened(false); … … 566 566 } 567 567 568 void UIFileManagerTable::populateStartDirectory(UI CustomFileSystemItem *startItem)568 void UIFileManagerTable::populateStartDirectory(UIFileSystemItem *startItem) 569 569 { 570 570 determineDriveLetters(); … … 578 578 for (int i = 0; i < m_driveLetterList.size(); ++i) 579 579 { 580 UI CustomFileSystemItem* driveItem = new UICustomFileSystemItem(UIPathOperations::removeTrailingDelimiters(m_driveLetterList[i]),580 UIFileSystemItem* driveItem = new UIFileSystemItem(UIPathOperations::removeTrailingDelimiters(m_driveLetterList[i]), 581 581 startItem, KFsObjType_Directory); 582 582 driveItem->setIsOpened(false); … … 587 587 } 588 588 589 void UIFileManagerTable::checkDotDot(QMap<QString,UI CustomFileSystemItem*> &map,590 UI CustomFileSystemItem *parent, bool isStartDir)589 void UIFileManagerTable::checkDotDot(QMap<QString,UIFileSystemItem*> &map, 590 UIFileSystemItem *parent, bool isStartDir) 591 591 { 592 592 if (!parent) 593 593 return; 594 594 /* Make sure we have an item representing up directory, and make sure it is not there for the start dir: */ 595 if (!map.contains(UI CustomFileSystemModel::strUpDirectoryString) && !isStartDir)596 { 597 UI CustomFileSystemItem *item = new UICustomFileSystemItem(UICustomFileSystemModel::strUpDirectoryString,595 if (!map.contains(UIFileSystemModel::strUpDirectoryString) && !isStartDir) 596 { 597 UIFileSystemItem *item = new UIFileSystemItem(UIFileSystemModel::strUpDirectoryString, 598 598 parent, KFsObjType_Directory); 599 599 item->setIsOpened(false); 600 map.insert(UI CustomFileSystemModel::strUpDirectoryString, item);601 } 602 else if (map.contains(UI CustomFileSystemModel::strUpDirectoryString) && isStartDir)603 { 604 map.remove(UI CustomFileSystemModel::strUpDirectoryString);600 map.insert(UIFileSystemModel::strUpDirectoryString, item); 601 } 602 else if (map.contains(UIFileSystemModel::strUpDirectoryString) && isStartDir) 603 { 604 map.remove(UIFileSystemModel::strUpDirectoryString); 605 605 } 606 606 } … … 671 671 return; 672 672 673 UI CustomFileSystemItem *item = static_cast<UICustomFileSystemItem*>(index.internalPointer());673 UIFileSystemItem *item = static_cast<UIFileSystemItem*>(index.internalPointer()); 674 674 if (!item) 675 675 return; … … 698 698 void UIFileManagerTable::goIntoDirectory(const QStringList &pathTrail) 699 699 { 700 UI CustomFileSystemItem *parent = getStartDirectoryItem();700 UIFileSystemItem *parent = getStartDirectoryItem(); 701 701 702 702 for(int i = 0; i < pathTrail.size(); ++i) … … 709 709 return; 710 710 /* search the current path item among the parent's children: */ 711 UI CustomFileSystemItem *item = parent->child(pathTrail.at(i));711 UIFileSystemItem *item = parent->child(pathTrail.at(i)); 712 712 713 713 if (!item) … … 725 725 } 726 726 727 void UIFileManagerTable::goIntoDirectory(UI CustomFileSystemItem *item)727 void UIFileManagerTable::goIntoDirectory(UIFileSystemItem *item) 728 728 { 729 729 if (!item || !m_pModel) … … 732 732 } 733 733 734 UI CustomFileSystemItem* UIFileManagerTable::indexData(const QModelIndex &index) const734 UIFileSystemItem* UIFileManagerTable::indexData(const QModelIndex &index) const 735 735 { 736 736 if (!index.isValid()) 737 737 return 0; 738 return static_cast<UI CustomFileSystemItem*>(index.internalPointer());738 return static_cast<UIFileSystemItem*>(index.internalPointer()); 739 739 } 740 740 … … 745 745 QModelIndex currentIndex = currentRootIndex(); 746 746 747 UI CustomFileSystemItem *treeItem = indexData(currentIndex);747 UIFileSystemItem *treeItem = indexData(currentIndex); 748 748 if (!treeItem) 749 749 return; … … 806 806 QModelIndex modelIndex = 807 807 m_pProxyModel ? m_pProxyModel->mapToSource(selectedItemIndices.at(0)) : selectedItemIndices.at(0); 808 UI CustomFileSystemItem *item = indexData(modelIndex);808 UIFileSystemItem *item = indexData(modelIndex); 809 809 if (!item || item->isUpDirectory()) 810 810 return; … … 819 819 if (!currentIndex.isValid()) 820 820 return; 821 UI CustomFileSystemItem *parentFolderItem = static_cast<UICustomFileSystemItem*>(currentIndex.internalPointer());821 UIFileSystemItem *parentFolderItem = static_cast<UIFileSystemItem*>(currentIndex.internalPointer()); 822 822 if (!parentFolderItem) 823 823 return; 824 QString strBase(UI CustomFileSystemModel::tr("NewDirectory"));824 QString strBase(UIFileSystemModel::tr("NewDirectory")); 825 825 QString newDirectoryName(strBase); 826 826 QStringList nameList = currentDirectoryListing(); … … 838 838 839 839 /* Now we try to edit the newly created item thereby enabling the user to rename the new item: */ 840 QList<UI CustomFileSystemItem*> content = parentFolderItem->children();841 UI CustomFileSystemItem* newItem = 0;840 QList<UIFileSystemItem*> content = parentFolderItem->children(); 841 UIFileSystemItem* newItem = 0; 842 842 /* Search the new item: */ 843 foreach (UI CustomFileSystemItem* childItem, content)843 foreach (UIFileSystemItem* childItem, content) 844 844 { 845 845 … … 909 909 } 910 910 911 void UIFileManagerTable::sltHandleItemRenameAttempt(UI CustomFileSystemItem *pItem, const QString &strOldPath,911 void UIFileManagerTable::sltHandleItemRenameAttempt(UIFileSystemItem *pItem, const QString &strOldPath, 912 912 const QString &strOldName, const QString &strNewName) 913 913 { … … 919 919 { 920 920 /* Restore the previous name. relist the view: */ 921 pItem->setData(strOldName, static_cast<int>(UI CustomFileSystemModelData_Name));921 pItem->setData(strOldName, static_cast<int>(UIFileSystemModelData_Name)); 922 922 relist(); 923 923 emit sigLogOutput(QString(pItem->path()).append(" could not be renamed"), QString(), FileManagerLogType_Error); … … 961 961 continue; 962 962 963 UI CustomFileSystemItem *item = static_cast<UICustomFileSystemItem*>(index.internalPointer());963 UIFileSystemItem *item = static_cast<UIFileSystemItem*>(index.internalPointer()); 964 964 if (item && item->isUpDirectory()) 965 965 { … … 1004 1004 void UIFileManagerTable::deleteByIndex(const QModelIndex &itemIndex) 1005 1005 { 1006 UI CustomFileSystemItem *treeItem = indexData(itemIndex);1006 UIFileSystemItem *treeItem = indexData(itemIndex); 1007 1007 if (!treeItem) 1008 1008 return; … … 1012 1012 void UIFileManagerTable::retranslateUi() 1013 1013 { 1014 UI CustomFileSystemItem *pRootItem = rootItem();1014 UIFileSystemItem *pRootItem = rootItem(); 1015 1015 if (pRootItem) 1016 1016 { 1017 pRootItem->setData(UIFileManager::tr("Name"), UI CustomFileSystemModelData_Name);1018 pRootItem->setData(UIFileManager::tr("Size"), UI CustomFileSystemModelData_Size);1019 pRootItem->setData(UIFileManager::tr("Change Time"), UI CustomFileSystemModelData_ChangeTime);1020 pRootItem->setData(UIFileManager::tr("Owner"), UI CustomFileSystemModelData_Owner);1021 pRootItem->setData(UIFileManager::tr("Permissions"), UI CustomFileSystemModelData_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); 1022 1022 } 1023 1023 } … … 1087 1087 } 1088 1088 1089 UI CustomFileSystemItem *UIFileManagerTable::getStartDirectoryItem()1090 { 1091 UI CustomFileSystemItem* pRootItem = rootItem();1089 UIFileSystemItem *UIFileManagerTable::getStartDirectoryItem() 1090 { 1091 UIFileSystemItem* pRootItem = rootItem(); 1092 1092 if (!pRootItem) 1093 1093 return 0; … … 1104 1104 if (!currentRoot.isValid()) 1105 1105 return QString(); 1106 UI CustomFileSystemItem *item = static_cast<UICustomFileSystemItem*>(currentRoot.internalPointer());1106 UIFileSystemItem *item = static_cast<UIFileSystemItem*>(currentRoot.internalPointer()); 1107 1107 if (!item) 1108 1108 return QString(); … … 1125 1125 QModelIndex index = 1126 1126 m_pProxyModel ? m_pProxyModel->mapToSource(selectedItemIndices.at(i)) : selectedItemIndices.at(i); 1127 UI CustomFileSystemItem *item = static_cast<UICustomFileSystemItem*>(index.internalPointer());1127 UIFileSystemItem *item = static_cast<UIFileSystemItem*>(index.internalPointer()); 1128 1128 if (!item) 1129 1129 continue; … … 1151 1151 } 1152 1152 1153 UI CustomFileSystemItem* UIFileManagerTable::rootItem()1153 UIFileSystemItem* UIFileManagerTable::rootItem() 1154 1154 { 1155 1155 if (!m_pModel) … … 1261 1261 1262 1262 int rowCount = m_pProxyModel->rowCount(m_pView->rootIndex()); 1263 UI CustomFileSystemItem *pFoundItem = 0;1263 UIFileSystemItem *pFoundItem = 0; 1264 1264 QModelIndex index; 1265 1265 for (int i = 0; i < rowCount && !pFoundItem; ++i) … … 1268 1268 if (!index.isValid()) 1269 1269 continue; 1270 pFoundItem = static_cast<UI CustomFileSystemItem*>(m_pProxyModel->mapToSource(index).internalPointer());1270 pFoundItem = static_cast<UIFileSystemItem*>(m_pProxyModel->mapToSource(index).internalPointer()); 1271 1271 if (!pFoundItem) 1272 1272 continue; … … 1345 1345 QStringList UIFileManagerTable::currentDirectoryListing() const 1346 1346 { 1347 UI CustomFileSystemItem *pItem = static_cast<UICustomFileSystemItem*>(currentRootIndex().internalPointer());1347 UIFileSystemItem *pItem = static_cast<UIFileSystemItem*>(currentRootIndex().internalPointer()); 1348 1348 if (!pItem) 1349 1349 return QStringList(); 1350 1350 QStringList list; 1351 foreach (const UI CustomFileSystemItem *pChild, pItem->children())1351 foreach (const UIFileSystemItem *pChild, pItem->children()) 1352 1352 { 1353 1353 if (pChild) -
trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerTable.h
r102446 r102485 59 59 class QVBoxLayout; 60 60 class UIActionPool; 61 class UI CustomFileSystemItem;62 class UI CustomFileSystemModel;63 class UI CustomFileSystemProxyModel;61 class UIFileSystemItem; 62 class UIFileSystemModel; 63 class UIFileSystemProxyModel; 64 64 class UIFileTableNavigationWidget; 65 65 class UIGuestControlFileView; … … 137 137 /** This class serves a base class for file table. Currently a guest version 138 138 * and a host version are derived from this base. Each of these children 139 * populates the UI CustomFileSystemModel by scanning the file system139 * populates the UIFileSystemModel by scanning the file system 140 140 * differently. The file structure kept in this class as a tree. */ 141 141 class UIFileManagerTable : public QIWithRetranslateUI<QWidget> … … 210 210 void changeLocation(const QModelIndex &index); 211 211 void initializeFileTree(); 212 void checkDotDot(QMap<QString,UI CustomFileSystemItem*> &map, UICustomFileSystemItem *parent, bool isStartDir);213 214 virtual bool readDirectory(const QString& strPath, UI CustomFileSystemItem *parent, bool isStartDir = false) = 0;215 virtual void deleteByItem(UI CustomFileSystemItem *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; 216 216 virtual void goToHomeDirectory() = 0; 217 virtual bool renameItem(UI CustomFileSystemItem *item, const QString &strOldPath) = 0;217 virtual bool renameItem(UIFileSystemItem *item, const QString &strOldPath) = 0; 218 218 virtual bool createDirectory(const QString &path, const QString &directoryName) = 0; 219 219 virtual QString fsObjectPropertyString() = 0; … … 243 243 void goIntoDirectory(const QStringList &pathTrail); 244 244 /** Goes into directory pointed by the @p item */ 245 void goIntoDirectory(UI CustomFileSystemItem *item);246 UI CustomFileSystemItem* indexData(const QModelIndex &index) const;245 void goIntoDirectory(UIFileSystemItem *item); 246 UIFileSystemItem* indexData(const QModelIndex &index) const; 247 247 bool eventFilter(QObject *pObject, QEvent *pEvent) RT_OVERRIDE; 248 248 CGuestFsObjInfo guestFsObjectInfo(const QString& path, CGuestSession &comGuestSession) const; 249 249 void setSelectionDependentActionsEnabled(bool fIsEnabled); 250 UI CustomFileSystemItem* rootItem();250 UIFileSystemItem* rootItem(); 251 251 void setPathSeparator(const QChar &separator); 252 252 QHBoxLayout* toolBarLayout(); … … 281 281 * if the file system rename fails we restore the old name of the item. See the comment of 282 282 * sltRename() for more details. Note that when this slot is called item->path() has also changed. Thus strOldPath. */ 283 void sltHandleItemRenameAttempt(UI CustomFileSystemItem *pItem, const QString &strOldPath,283 void sltHandleItemRenameAttempt(UIFileSystemItem *pItem, const QString &strOldPath, 284 284 const QString &strOldName, const QString &strNewName); 285 285 void sltHandleNavigationWidgetPathChange(const QString& strPath); … … 292 292 /** @p itemIndex is assumed to be 'model' index not 'proxy model' index */ 293 293 void deleteByIndex(const QModelIndex &itemIndex); 294 /** Returns the UI CustomFileSystemItem for path / which is a direct (and single) child of m_pRootItem */295 UI CustomFileSystemItem *getStartDirectoryItem();294 /** Returns the UIFileSystemItem for path / which is a direct (and single) child of m_pRootItem */ 295 UIFileSystemItem *getStartDirectoryItem(); 296 296 void deSelectUpDirectoryItem(); 297 297 void setSelectionForAll(QItemSelectionModel::SelectionFlags flags); … … 299 299 /** The start directory requires a special attention since on file systems with drive letters 300 300 * drive letter are direct children of the start directory. On other systems start directory is '/' */ 301 void populateStartDirectory(UI CustomFileSystemItem *startItem);301 void populateStartDirectory(UIFileSystemItem *startItem); 302 302 /** Root index of the m_pModel */ 303 303 QModelIndex currentRootIndex() const; … … 313 313 void markUnmarkSearchLineEdit(bool fMark); 314 314 QStringList currentDirectoryListing() const; 315 UI CustomFileSystemModel *m_pModel;316 UIGuestControlFileView 317 UI CustomFileSystemProxyModel *m_pProxyModel;315 UIFileSystemModel *m_pModel; 316 UIGuestControlFileView *m_pView; 317 UIFileSystemProxyModel *m_pProxyModel; 318 318 319 319 QILineEdit *m_pSearchLineEdit; … … 323 323 QHBoxLayout *m_pToolBarLayout; 324 324 QVector<QWidget*> m_sessionWidgets; 325 friend class UI CustomFileSystemModel;325 friend class UIFileSystemModel; 326 326 }; 327 327 -
trunk/src/VBox/Frontends/VirtualBox/src/medium/viso/UIVisoContentBrowser.cpp
r102454 r102485 40 40 #include "QIToolBar.h" 41 41 #include "UIActionPool.h" 42 #include "UI CustomFileSystemModel.h"42 #include "UIFileSystemModel.h" 43 43 #include "UIPathOperations.h" 44 44 #include "UIVisoContentBrowser.h" … … 263 263 if (rootItem() && rootItem()->childCount() > 0) 264 264 { 265 UI CustomFileSystemItem *pStartItem = startItem();265 UIFileSystemItem *pStartItem = startItem(); 266 266 if (pStartItem) 267 267 { … … 279 279 280 280 void UIVisoContentBrowser::importISOContentToViso(const QString &strISOFilePath, 281 UI CustomFileSystemItem *pParentItem /* = 0 */,281 UIFileSystemItem *pParentItem /* = 0 */, 282 282 const QString &strDirPath /* = QString() */) 283 283 { … … 294 294 if (!strDirPath.isEmpty()) 295 295 { 296 UI CustomFileSystemItem* pAddedItem = new UICustomFileSystemItem(UICustomFileSystemModel::strUpDirectoryString,296 UIFileSystemItem* pAddedItem = new UIFileSystemItem(UIFileSystemModel::strUpDirectoryString, 297 297 pParentItem, 298 298 KFsObjType_Directory); 299 pAddedItem->setData(strISOFilePath, UI CustomFileSystemModelData_ISOFilePath);299 pAddedItem->setData(strISOFilePath, UIFileSystemModelData_ISOFilePath); 300 300 } 301 301 QList<ISOFileObject> objectList = openAndReadISODir(strISOFilePath, strDirPath); … … 314 314 continue; 315 315 316 UI CustomFileSystemItem* pAddedItem = new UICustomFileSystemItem(fileInfo.fileName(), pParentItem,316 UIFileSystemItem* pAddedItem = new UIFileSystemItem(fileInfo.fileName(), pParentItem, 317 317 objectList[i].enmObjectType); 318 318 319 319 QString path = UIPathOperations::mergePaths(pParentItem->path(), fileInfo.fileName()); 320 pAddedItem->setData(path, UI CustomFileSystemModelData_LocalPath);321 pAddedItem->setData(strISOFilePath, UI CustomFileSystemModelData_ISOFilePath);320 pAddedItem->setData(path, UIFileSystemModelData_LocalPath); 321 pAddedItem->setData(strISOFilePath, UIFileSystemModelData_ISOFilePath); 322 322 pAddedItem->setIsOpened(false); 323 323 … … 331 331 void UIVisoContentBrowser::removeISOContentFromViso() 332 332 { 333 UI CustomFileSystemItem* pParentItem = startItem();333 UIFileSystemItem* pParentItem = startItem(); 334 334 AssertReturnVoid(pParentItem); 335 335 AssertReturnVoid(m_pModel); 336 336 337 QList<UI CustomFileSystemItem*> itemsToDelete;337 QList<UIFileSystemItem*> itemsToDelete; 338 338 /* Delete all children of startItem that were imported from an ISO: */ 339 339 for (int i = 0; i < pParentItem->childCount(); ++i) 340 340 { 341 UI CustomFileSystemItem* pItem = pParentItem->child(i);342 if (!pItem || pItem->data(UI CustomFileSystemModelData_ISOFilePath).toString().isEmpty())341 UIFileSystemItem* pItem = pParentItem->child(i); 342 if (!pItem || pItem->data(UIFileSystemModelData_ISOFilePath).toString().isEmpty()) 343 343 continue; 344 344 itemsToDelete << pItem; 345 345 } 346 346 347 foreach (UI CustomFileSystemItem *pItem, itemsToDelete)347 foreach (UIFileSystemItem *pItem, itemsToDelete) 348 348 m_pModel->deleteItem(pItem); 349 349 if (m_pTableProxyModel) … … 364 364 return; 365 365 366 UI CustomFileSystemItem *pParentItem = static_cast<UICustomFileSystemItem*>(parentIndex.internalPointer());366 UIFileSystemItem *pParentItem = static_cast<UIFileSystemItem*>(parentIndex.internalPointer()); 367 367 if (!pParentItem) 368 368 return; … … 376 376 continue; 377 377 378 UI CustomFileSystemItem* pAddedItem = new UICustomFileSystemItem(fileInfo.fileName(), pParentItem,378 UIFileSystemItem* pAddedItem = new UIFileSystemItem(fileInfo.fileName(), pParentItem, 379 379 fileType(fileInfo)); 380 pAddedItem->setData(strPath, UI CustomFileSystemModelData_LocalPath);380 pAddedItem->setData(strPath, UIFileSystemModelData_LocalPath); 381 381 382 382 pAddedItem->setIsOpened(false); … … 386 386 pAddedItem->setIsSymLinkToADirectory(QFileInfo(fileInfo.symLinkTarget()).isDir()); 387 387 } 388 createVisoEntry(pAddedItem->path(), pAddedItem->data(UI CustomFileSystemModelData_LocalPath).toString(), false);388 createVisoEntry(pAddedItem->path(), pAddedItem->data(UIFileSystemModelData_LocalPath).toString(), false); 389 389 } 390 390 if (m_pTableProxyModel) … … 422 422 void UIVisoContentBrowser::retranslateUi() 423 423 { 424 UI CustomFileSystemItem *pRootItem = rootItem();424 UIFileSystemItem *pRootItem = rootItem(); 425 425 if (pRootItem) 426 426 { 427 pRootItem->setData(QApplication::translate("UIVisoCreatorWidget", "Name"), UI CustomFileSystemModelData_Name);428 pRootItem->setData(QApplication::translate("UIVisoCreatorWidget", "Size"), UI CustomFileSystemModelData_Size);429 pRootItem->setData(QApplication::translate("UIVisoCreatorWidget", "Change Time"), UI CustomFileSystemModelData_ChangeTime);430 pRootItem->setData(QApplication::translate("UIVisoCreatorWidget", "Owner"), UI CustomFileSystemModelData_Owner);431 pRootItem->setData(QApplication::translate("UIVisoCreatorWidget", "Permissions"), UI CustomFileSystemModelData_Permissions);432 pRootItem->setData(QApplication::translate("UIVisoCreatorWidget", "Local Path"), UI CustomFileSystemModelData_LocalPath);433 pRootItem->setData(QApplication::translate("UIVisoCreatorWidget", "Has Removed Child"), UI CustomFileSystemModelData_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); 434 434 } 435 435 if (m_pSubMenu) … … 443 443 if (!index.isValid() || !m_pTableProxyModel) 444 444 return; 445 UI CustomFileSystemItem *pClickedItem =446 static_cast<UI CustomFileSystemItem*>(m_pTableProxyModel->mapToSource(index).internalPointer());445 UIFileSystemItem *pClickedItem = 446 static_cast<UIFileSystemItem*>(m_pTableProxyModel->mapToSource(index).internalPointer()); 447 447 if (!pClickedItem) 448 448 return; … … 452 452 if (pClickedItem->isRemovedFromViso()) 453 453 return; 454 QString strISOPath = pClickedItem->data(UI CustomFileSystemModelData_ISOFilePath).toString();454 QString strISOPath = pClickedItem->data(UIFileSystemModelData_ISOFilePath).toString(); 455 455 if (pClickedItem->isUpDirectory()) 456 456 goUp(); 457 457 else if (!strISOPath.isEmpty()) 458 458 { 459 importISOContentToViso(strISOPath, pClickedItem, pClickedItem->data(UI CustomFileSystemModelData_LocalPath).toString());459 importISOContentToViso(strISOPath, pClickedItem, pClickedItem->data(UIFileSystemModelData_LocalPath).toString()); 460 460 setTableRootIndex(index); 461 461 } … … 482 482 return; 483 483 484 UI CustomFileSystemItem *pParentItem = static_cast<UICustomFileSystemItem*>(parentIndex.internalPointer());484 UIFileSystemItem *pParentItem = static_cast<UIFileSystemItem*>(parentIndex.internalPointer()); 485 485 if (!pParentItem) 486 486 return; 487 487 488 488 /* Check to see if we already have a directory named strNewDirectoryName: */ 489 const QList<UI CustomFileSystemItem*> children = pParentItem->children();490 foreach (const UI CustomFileSystemItem *item, children)489 const QList<UIFileSystemItem*> children = pParentItem->children(); 490 foreach (const UIFileSystemItem *item, children) 491 491 { 492 492 if (item->fileObjectName() == strNewDirectoryName) … … 494 494 } 495 495 496 UI CustomFileSystemItem* pAddedItem = new UICustomFileSystemItem(strNewDirectoryName, pParentItem,496 UIFileSystemItem* pAddedItem = new UIFileSystemItem(strNewDirectoryName, pParentItem, 497 497 KFsObjType_Directory); 498 498 … … 514 514 } 515 515 516 void UIVisoContentBrowser::removeItems(const QList<UI CustomFileSystemItem*> itemList)516 void UIVisoContentBrowser::removeItems(const QList<UIFileSystemItem*> itemList) 517 517 { 518 518 AssertReturnVoid(m_pModel); 519 519 AssertReturnVoid(m_pTableProxyModel); 520 foreach(UI CustomFileSystemItem *pItem, itemList)520 foreach(UIFileSystemItem *pItem, itemList) 521 521 { 522 522 if (!pItem || pItem->isUpDirectory()) … … 530 530 bool bFoundInMap = m_entryMap.remove(strVisoPath) > 0; 531 531 if (!bFoundInMap) 532 createVisoEntry(pItem->path(), pItem->data(UI CustomFileSystemModelData_LocalPath).toString(), true /* bool bRemove */);532 createVisoEntry(pItem->path(), pItem->data(UIFileSystemModelData_LocalPath).toString(), true /* bool bRemove */); 533 533 534 534 markRemovedUnremovedItemParents(pItem, true); … … 539 539 } 540 540 541 void UIVisoContentBrowser::restoreItems(const QList<UI CustomFileSystemItem*> itemList)542 { 543 foreach(UI CustomFileSystemItem *pItem, itemList)541 void UIVisoContentBrowser::restoreItems(const QList<UIFileSystemItem*> itemList) 542 { 543 foreach(UIFileSystemItem *pItem, itemList) 544 544 { 545 545 if (!pItem || pItem->isUpDirectory()) … … 553 553 bool bFoundInMap = m_entryMap.remove(strVisoPath) > 0; 554 554 if (!bFoundInMap) 555 createVisoEntry(pItem->path(), pItem->data(UI CustomFileSystemModelData_LocalPath).toString(), false /* bool bRemove */);555 createVisoEntry(pItem->path(), pItem->data(UIFileSystemModelData_LocalPath).toString(), false /* bool bRemove */); 556 556 557 557 markRemovedUnremovedItemParents(pItem, false); … … 561 561 } 562 562 563 void UIVisoContentBrowser::markRemovedUnremovedItemParents(UI CustomFileSystemItem *pItem, bool fRemoved)563 void UIVisoContentBrowser::markRemovedUnremovedItemParents(UIFileSystemItem *pItem, bool fRemoved) 564 564 { 565 565 pItem->setRemovedFromViso(fRemoved); 566 UI CustomFileSystemItem *pRoot = rootItem();567 UI CustomFileSystemItem *pParent = pItem->parentItem();566 UIFileSystemItem *pRoot = rootItem(); 567 UIFileSystemItem *pParent = pItem->parentItem(); 568 568 569 569 while (pParent && pParent != pRoot) 570 570 { 571 571 pParent->setToolTip(QApplication::translate("UIVisoCreatorWidget", "Child/children removed")); 572 pParent->setData(true, UI CustomFileSystemModelData_DescendantRemovedFromVISO);572 pParent->setData(true, UIFileSystemModelData_DescendantRemovedFromVISO); 573 573 pParent = pParent->parentItem(); 574 574 } … … 579 579 UIVisoBrowserBase::prepareObjects(); 580 580 581 m_pModel = new UI CustomFileSystemModel(this);582 m_pTableProxyModel = new UI CustomFileSystemProxyModel(this);581 m_pModel = new UIFileSystemModel(this); 582 m_pTableProxyModel = new UIFileSystemProxyModel(this); 583 583 if (m_pTableProxyModel) 584 584 { … … 616 616 m_pTableView->setModel(m_pTableProxyModel); 617 617 setTableRootIndex(); 618 m_pTableView->hideColumn(UI CustomFileSystemModelData_Owner);619 m_pTableView->hideColumn(UI CustomFileSystemModelData_Permissions);620 m_pTableView->hideColumn(UI CustomFileSystemModelData_Size);621 m_pTableView->hideColumn(UI CustomFileSystemModelData_ChangeTime);622 m_pTableView->hideColumn(UI CustomFileSystemModelData_ISOFilePath);623 m_pTableView->hideColumn(UI CustomFileSystemModelData_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); 624 624 625 625 m_pTableView->setSortingEnabled(true); … … 729 729 this, &UIVisoContentBrowser::sltTableSelectionChanged); 730 730 if (m_pModel) 731 connect(m_pModel, &UI CustomFileSystemModel::sigItemRenamed,731 connect(m_pModel, &UIFileSystemModel::sigItemRenamed, 732 732 this, &UIVisoContentBrowser::sltItemRenameAttempt); 733 733 … … 756 756 } 757 757 758 UI CustomFileSystemItem* UIVisoContentBrowser::rootItem()758 UIFileSystemItem* UIVisoContentBrowser::rootItem() 759 759 { 760 760 if (!m_pModel) … … 763 763 } 764 764 765 UI CustomFileSystemItem* UIVisoContentBrowser::startItem()766 { 767 UI CustomFileSystemItem* pRoot = rootItem();765 UIFileSystemItem* UIVisoContentBrowser::startItem() 766 { 767 UIFileSystemItem* pRoot = rootItem(); 768 768 769 769 if (!pRoot || pRoot->childCount() <= 0) … … 781 781 const QString startPath = QString("/"); 782 782 783 UI CustomFileSystemItem *pStartItem = new UICustomFileSystemItem(startPath, rootItem(), KFsObjType_Directory);783 UIFileSystemItem *pStartItem = new UIFileSystemItem(startPath, rootItem(), KFsObjType_Directory); 784 784 785 785 pStartItem->setIsOpened(false); … … 806 806 if (strPath == currentPath()) 807 807 return; 808 UI CustomFileSystemItem *pItem = searchItemByPath(strPath);808 UIFileSystemItem *pItem = searchItemByPath(strPath); 809 809 810 810 if (pItem && pItem->isDirectory() && !pItem->isRemovedFromViso()) … … 816 816 } 817 817 818 UI CustomFileSystemItem* UIVisoContentBrowser::searchItemByPath(const QString &strPath)819 { 820 UI CustomFileSystemItem *pItem = startItem();818 UIFileSystemItem* UIVisoContentBrowser::searchItemByPath(const QString &strPath) 819 { 820 UIFileSystemItem *pItem = startItem(); 821 821 QStringList path = UIPathOperations::pathTrail(strPath); 822 822 … … 909 909 continue; 910 910 911 UI CustomFileSystemItem *pParent = startItem();911 UIFileSystemItem *pParent = startItem(); 912 912 /* Make sure all the parents from start item until the immediate parent are created: */ 913 913 for (int i = 0; i < pathList.size(); ++i) … … 916 916 strPath.append(pathList[i]); 917 917 918 UI CustomFileSystemItem *pItem = searchItemByPath(strPath);918 UIFileSystemItem *pItem = searchItemByPath(strPath); 919 919 KFsObjType enmObjectType; 920 920 /* All objects, except possibly the last one, are directories:*/ … … 925 925 if (!pItem) 926 926 { 927 pItem = new UI CustomFileSystemItem(pathList[i], pParent, enmObjectType);927 pItem = new UIFileSystemItem(pathList[i], pParent, enmObjectType); 928 928 if (!pItem) 929 929 continue; 930 930 931 931 if (i == pathList.size() - 1) 932 pItem->setData(strLocalPath, UI CustomFileSystemModelData_LocalPath);932 pItem->setData(strLocalPath, UIFileSystemModelData_LocalPath); 933 933 /* Pre-scan and populate the directory since we may need its content while processing removed items: */ 934 934 if (enmObjectType == KFsObjType_Directory) … … 936 936 } 937 937 if (i == pathList.size() - 1) 938 createVisoEntry(pItem->path(), pItem->data(UI CustomFileSystemModelData_LocalPath).toString(), false);938 createVisoEntry(pItem->path(), pItem->data(UIFileSystemModelData_LocalPath).toString(), false); 939 939 pParent = pItem; 940 940 } … … 948 948 void UIVisoContentBrowser::processRemovedEntries(const QStringList &removedEntries) 949 949 { 950 QList<UI CustomFileSystemItem*> itemList;950 QList<UIFileSystemItem*> itemList; 951 951 foreach (const QString &strPath, removedEntries) 952 952 { 953 953 QFileInfo fileInfo(strPath); 954 UI CustomFileSystemItem *pItem = searchItemByPath(strPath);954 UIFileSystemItem *pItem = searchItemByPath(strPath); 955 955 if (pItem) 956 956 itemList << pItem; … … 971 971 } 972 972 973 void UIVisoContentBrowser::scanHostDirectory(UI CustomFileSystemItem *directoryItem, bool fRecursive)973 void UIVisoContentBrowser::scanHostDirectory(UIFileSystemItem *directoryItem, bool fRecursive) 974 974 { 975 975 if (!directoryItem) … … 978 978 should be empty: */ 979 979 if ((directoryItem->type() != KFsObjType_Directory && !directoryItem->isSymLinkToADirectory()) || 980 directoryItem->data(UI CustomFileSystemModelData_LocalPath).toString().isEmpty())981 return; 982 QDir directory(directoryItem->data(UI CustomFileSystemModelData_LocalPath).toString());980 directoryItem->data(UIFileSystemModelData_LocalPath).toString().isEmpty()) 981 return; 982 QDir directory(directoryItem->data(UIFileSystemModelData_LocalPath).toString()); 983 983 if (directory.exists() && !directoryItem->isOpened()) 984 984 { … … 991 991 continue; 992 992 KFsObjType enmType = fileType(fileInfo); 993 UI CustomFileSystemItem *newItem = new UICustomFileSystemItem(fileInfo.fileName(),993 UIFileSystemItem *newItem = new UIFileSystemItem(fileInfo.fileName(), 994 994 directoryItem, 995 995 enmType); 996 newItem->setData(fileInfo.filePath(), UI CustomFileSystemModelData_LocalPath);996 newItem->setData(fileInfo.filePath(), UIFileSystemModelData_LocalPath); 997 997 if (fileInfo.isSymLink()) 998 998 { … … 1030 1030 const QString strName(QDir::toNativeSeparators("/")); 1031 1031 1032 rootItem()->child(0)->setData(strName, UI CustomFileSystemModelData_Name);1032 rootItem()->child(0)->setData(strName, UIFileSystemModelData_Name); 1033 1033 /* If the table root index is the start item then we have to update the location selector text here: */ 1034 1034 // if (m_pTableProxyModel->mapToSource(m_pTableView->rootIndex()).internalPointer() == rootItem()->child(0)) … … 1037 1037 } 1038 1038 1039 void UIVisoContentBrowser::renameFileObject(UI CustomFileSystemItem *pItem)1039 void UIVisoContentBrowser::renameFileObject(UIFileSystemItem *pItem) 1040 1040 { 1041 1041 m_pTableView->edit(m_pTableProxyModel->mapFromSource(m_pModel->index(pItem))); … … 1044 1044 void UIVisoContentBrowser::sltItemRenameAction() 1045 1045 { 1046 QList<UI CustomFileSystemItem*> selectedItems = tableSelectedItems();1046 QList<UIFileSystemItem*> selectedItems = tableSelectedItems(); 1047 1047 if (selectedItems.empty()) 1048 1048 return; … … 1050 1050 } 1051 1051 1052 void UIVisoContentBrowser::sltItemRenameAttempt(UI CustomFileSystemItem *pItem, const QString &strOldPath,1052 void UIVisoContentBrowser::sltItemRenameAttempt(UIFileSystemItem *pItem, const QString &strOldPath, 1053 1053 const QString &strOldName, const QString &strNewName) 1054 1054 { 1055 1055 if (!pItem || !pItem->parentItem()) 1056 1056 return; 1057 QList<UI CustomFileSystemItem*> children = pItem->parentItem()->children();1057 QList<UIFileSystemItem*> children = pItem->parentItem()->children(); 1058 1058 bool bDuplicate = false; 1059 foreach (const UI CustomFileSystemItem *item, children)1059 foreach (const UIFileSystemItem *item, children) 1060 1060 { 1061 1061 if (item->fileObjectName() == strNewName && item != pItem) … … 1068 1068 { 1069 1069 /* Restore the previous name in case the @strNewName is a duplicate: */ 1070 pItem->setData(strOldName, static_cast<int>(UI CustomFileSystemModelData_Name));1070 pItem->setData(strOldName, static_cast<int>(UIFileSystemModelData_Name)); 1071 1071 } 1072 1072 else … … 1076 1076 VISO file for the old path since in some cases, when remaned item is not top level, it still 1077 1077 appears in ISO. So we remove it explicitly: */ 1078 m_entryMap.insert(strNewPath, pItem->data(UI CustomFileSystemModelData_LocalPath).toString());1078 m_entryMap.insert(strNewPath, pItem->data(UIFileSystemModelData_LocalPath).toString()); 1079 1079 m_entryMap.remove(strOldPath); 1080 if (!pItem->data(UI CustomFileSystemModelData_LocalPath).toString().isEmpty())1080 if (!pItem->data(UIFileSystemModelData_LocalPath).toString().isEmpty()) 1081 1081 m_entryMap.insert(strOldPath, cRemoveText); 1082 1082 } … … 1130 1130 } 1131 1131 1132 QList<UI CustomFileSystemItem*> UIVisoContentBrowser::tableSelectedItems()1133 { 1134 QList<UI CustomFileSystemItem*> selectedItems;1132 QList<UIFileSystemItem*> UIVisoContentBrowser::tableSelectedItems() 1133 { 1134 QList<UIFileSystemItem*> selectedItems; 1135 1135 if (!m_pTableProxyModel) 1136 1136 return selectedItems; … … 1141 1141 foreach (QModelIndex index, list) 1142 1142 { 1143 UI CustomFileSystemItem *pItem =1144 static_cast<UI CustomFileSystemItem*>(m_pTableProxyModel->mapToSource(index).internalPointer());1143 UIFileSystemItem *pItem = 1144 static_cast<UIFileSystemItem*>(m_pTableProxyModel->mapToSource(index).internalPointer()); 1145 1145 if (pItem) 1146 1146 selectedItems << pItem; … … 1154 1154 return QString(); 1155 1155 QModelIndex index = m_pTableProxyModel->mapToSource(m_pTableView->rootIndex()); 1156 UI CustomFileSystemItem *pItem = static_cast<UICustomFileSystemItem*>((index).internalPointer());1156 UIFileSystemItem *pItem = static_cast<UIFileSystemItem*>((index).internalPointer()); 1157 1157 if (!pItem) 1158 1158 return QString(); … … 1165 1165 return false; 1166 1166 QModelIndex index = m_pTableProxyModel->mapToSource(m_pTableView->rootIndex()); 1167 UI CustomFileSystemItem *pItem = static_cast<UICustomFileSystemItem*>((index).internalPointer());1167 UIFileSystemItem *pItem = static_cast<UIFileSystemItem*>((index).internalPointer()); 1168 1168 if (!index.isValid() || !pItem) 1169 1169 return false; … … 1191 1191 } 1192 1192 1193 const UI CustomFileSystemItem* UIVisoContentBrowser::currentDirectoryItem() const1193 const UIFileSystemItem* UIVisoContentBrowser::currentDirectoryItem() const 1194 1194 { 1195 1195 if (!m_pTableView || !m_pTableView->rootIndex().isValid()) … … 1197 1197 QModelIndex currentRoot = m_pTableProxyModel->mapToSource(m_pTableView->rootIndex()); 1198 1198 1199 return static_cast<UI CustomFileSystemItem*>(currentRoot.internalPointer());1199 return static_cast<UIFileSystemItem*>(currentRoot.internalPointer()); 1200 1200 } 1201 1201 1202 1202 QStringList UIVisoContentBrowser::currentDirectoryListing() const 1203 1203 { 1204 const UI CustomFileSystemItem *pCurrentDirectoryItem = currentDirectoryItem();1204 const UIFileSystemItem *pCurrentDirectoryItem = currentDirectoryItem(); 1205 1205 if (!pCurrentDirectoryItem) 1206 1206 return QStringList(); 1207 1207 QStringList nameList; 1208 foreach (const UI CustomFileSystemItem *pChild, pCurrentDirectoryItem->children())1208 foreach (const UIFileSystemItem *pChild, pCurrentDirectoryItem->children()) 1209 1209 { 1210 1210 if (pChild) -
trunk/src/VBox/Frontends/VirtualBox/src/medium/viso/UIVisoContentBrowser.h
r100629 r102485 43 43 /* Forward declarations: */ 44 44 class QFileInfo; 45 class UI CustomFileSystemItem;46 class UI CustomFileSystemModel;47 class UI CustomFileSystemProxyModel;45 class UIFileSystemItem; 46 class UIFileSystemModel; 47 class UIFileSystemProxyModel; 48 48 class UIVisoContentTableView; 49 49 … … 64 64 /* Imports pathList (relative to ISO file's root) to VISO content. */ 65 65 void importISOContentToViso(const QString &strISOFilePath, 66 UI CustomFileSystemItem *pParentItem = 0,66 UIFileSystemItem *pParentItem = 0, 67 67 const QString &strDirPath = QString()); 68 68 void removeISOContentFromViso(); … … 87 87 /** Handles the signal we get from the model during setData call. Restores the old name of the file object 88 88 * to @p strOldName if need be (if rename fails for some reason). */ 89 void sltItemRenameAttempt(UI CustomFileSystemItem *pItem, const QString &strOldPath,89 void sltItemRenameAttempt(UIFileSystemItem *pItem, const QString &strOldPath, 90 90 const QString &strOldName, const QString &strNewName); 91 91 void sltRemoveItems(); … … 115 115 void prepareToolBar(); 116 116 void initializeModel(); 117 UI CustomFileSystemItem *rootItem();117 UIFileSystemItem *rootItem(); 118 118 /* Child of root. */ 119 UI CustomFileSystemItem *startItem();119 UIFileSystemItem *startItem(); 120 120 121 121 QModelIndex convertIndexToTableIndex(const QModelIndex &index); 122 122 /** Lists the content of the host file system directory by using Qt file system API. */ 123 void scanHostDirectory(UI CustomFileSystemItem *directory, bool fRecursive);123 void scanHostDirectory(UIFileSystemItem *directory, bool fRecursive); 124 124 KFsObjType fileType(const QFileInfo &fsInfo); 125 125 /** Renames the starts item's name as VISO name changes. */ 126 126 void updateStartItemName(); 127 void renameFileObject(UI CustomFileSystemItem *pItem);128 void removeItems(const QList<UI CustomFileSystemItem*> itemList);129 void restoreItems(const QList<UI CustomFileSystemItem*> itemList);127 void renameFileObject(UIFileSystemItem *pItem); 128 void removeItems(const QList<UIFileSystemItem*> itemList); 129 void restoreItems(const QList<UIFileSystemItem*> itemList); 130 130 /** Creates and entry for pItem consisting of a map item (key is viso path and value is host file system path) 131 131 * if @p bRemove is true then the value is the string ":remove:" which effectively removes the file object … … 133 133 void createVisoEntry(const QString &strPath, const QString &strLocalPath, bool bRemove = false); 134 134 QString currentPath() const; 135 UI CustomFileSystemItem* searchItemByPath(const QString &strPath);135 UIFileSystemItem* searchItemByPath(const QString &strPath); 136 136 void goToStart(); 137 137 /** Returns a list of items which are currecntly selected 138 138 * in the table view. */ 139 QList<UI CustomFileSystemItem*> tableSelectedItems();139 QList<UIFileSystemItem*> tableSelectedItems(); 140 140 /* Names of the file objects of the current directory. */ 141 141 QStringList currentDirectoryListing() const; … … 145 145 /* Processes a list of VISO paths that are loaded from a file and indicate file object to be removed from VISO content. */ 146 146 void processRemovedEntries(const QStringList &removedEntries); 147 const UI CustomFileSystemItem* currentDirectoryItem() const;148 void markRemovedUnremovedItemParents(UI CustomFileSystemItem *pItem, bool fRemoved);147 const UIFileSystemItem* currentDirectoryItem() const; 148 void markRemovedUnremovedItemParents(UIFileSystemItem *pItem, bool fRemoved); 149 149 void enableDisableSelectionDependentActions(); 150 150 UIVisoContentTableView *m_pTableView; 151 UI CustomFileSystemModel*m_pModel;152 UI CustomFileSystemProxyModel*m_pTableProxyModel;151 UIFileSystemModel *m_pModel; 152 UIFileSystemProxyModel *m_pTableProxyModel; 153 153 154 154 QString m_strImportedISOPath;
Note:
See TracChangeset
for help on using the changeset viewer.