Changeset 76333 in vbox for trunk/src/VBox
- Timestamp:
- Dec 21, 2018 12:56:44 PM (6 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/globals/UICustomFileSystemModel.cpp
r76332 r76333 36 36 37 37 /********************************************************************************************************************************* 38 * UI FileTableItem implementation.*38 * UICustomFileSystemItem implementation. * 39 39 *********************************************************************************************************************************/ 40 40 41 UI FileTableItem::UIFileTableItem(const QVector<QVariant> &data,42 UI FileTableItem *parent, KFsObjType type)41 UICustomFileSystemItem::UICustomFileSystemItem(const QVector<QVariant> &data, 42 UICustomFileSystemItem *parent, KFsObjType type) 43 43 : m_itemData(data) 44 44 , m_parentItem(parent) … … 50 50 } 51 51 52 UI FileTableItem::~UIFileTableItem()52 UICustomFileSystemItem::~UICustomFileSystemItem() 53 53 { 54 54 reset(); 55 55 } 56 56 57 void UI FileTableItem::appendChild(UIFileTableItem *item)57 void UICustomFileSystemItem::appendChild(UICustomFileSystemItem *item) 58 58 { 59 59 if (!item) … … 63 63 } 64 64 65 void UI FileTableItem::reset()65 void UICustomFileSystemItem::reset() 66 66 { 67 67 qDeleteAll(m_childItems); … … 71 71 } 72 72 73 UI FileTableItem *UIFileTableItem::child(int row) const73 UICustomFileSystemItem *UICustomFileSystemItem::child(int row) const 74 74 { 75 75 return m_childItems.value(row); 76 76 } 77 77 78 UI FileTableItem *UIFileTableItem::child(const QString &path) const78 UICustomFileSystemItem *UICustomFileSystemItem::child(const QString &path) const 79 79 { 80 80 if (!m_childMap.contains(path)) … … 83 83 } 84 84 85 int UI FileTableItem::childCount() const85 int UICustomFileSystemItem::childCount() const 86 86 { 87 87 return m_childItems.count(); 88 88 } 89 89 90 int UI FileTableItem::columnCount() const90 int UICustomFileSystemItem::columnCount() const 91 91 { 92 92 return m_itemData.count(); 93 93 } 94 94 95 QVariant UI FileTableItem::data(int column) const95 QVariant UICustomFileSystemItem::data(int column) const 96 96 { 97 97 return m_itemData.value(column); 98 98 } 99 99 100 QString UI FileTableItem::name() const100 QString UICustomFileSystemItem::name() const 101 101 { 102 102 if (m_itemData.isEmpty() || !m_itemData[0].canConvert(QMetaType::QString)) … … 105 105 } 106 106 107 void UI FileTableItem::setData(const QVariant &data, int index)107 void UICustomFileSystemItem::setData(const QVariant &data, int index) 108 108 { 109 109 if (index >= m_itemData.length()) … … 112 112 } 113 113 114 UI FileTableItem *UIFileTableItem::parentItem()114 UICustomFileSystemItem *UICustomFileSystemItem::parentItem() 115 115 { 116 116 return m_parentItem; 117 117 } 118 118 119 int UI FileTableItem::row() const119 int UICustomFileSystemItem::row() const 120 120 { 121 121 if (m_parentItem) 122 return m_parentItem->m_childItems.indexOf(const_cast<UI FileTableItem*>(this));122 return m_parentItem->m_childItems.indexOf(const_cast<UICustomFileSystemItem*>(this)); 123 123 return 0; 124 124 } 125 125 126 bool UI FileTableItem::isDirectory() const126 bool UICustomFileSystemItem::isDirectory() const 127 127 { 128 128 return m_type == KFsObjType_Directory; 129 129 } 130 130 131 bool UI FileTableItem::isSymLink() const131 bool UICustomFileSystemItem::isSymLink() const 132 132 { 133 133 return m_type == KFsObjType_Symlink; 134 134 } 135 135 136 bool UI FileTableItem::isFile() const136 bool UICustomFileSystemItem::isFile() const 137 137 { 138 138 return m_type == KFsObjType_File; 139 139 } 140 140 141 void UI FileTableItem::clearChildren()141 void UICustomFileSystemItem::clearChildren() 142 142 { 143 143 qDeleteAll(m_childItems); … … 146 146 } 147 147 148 bool UI FileTableItem::isOpened() const148 bool UICustomFileSystemItem::isOpened() const 149 149 { 150 150 return m_bIsOpened; 151 151 } 152 152 153 void UI FileTableItem::setIsOpened(bool flag)153 void UICustomFileSystemItem::setIsOpened(bool flag) 154 154 { 155 155 m_bIsOpened = flag; 156 156 } 157 157 158 const QString &UI FileTableItem::path() const158 const QString &UICustomFileSystemItem::path() const 159 159 { 160 160 return m_strPath; 161 161 } 162 162 163 void UI FileTableItem::setPath(const QString &path)163 void UICustomFileSystemItem::setPath(const QString &path) 164 164 { 165 165 if (path.isNull() || path.isEmpty()) … … 169 169 } 170 170 171 bool UI FileTableItem::isUpDirectory() const171 bool UICustomFileSystemItem::isUpDirectory() const 172 172 { 173 173 if (!isDirectory()) … … 178 178 } 179 179 180 KFsObjType UI FileTableItem::type() const180 KFsObjType UICustomFileSystemItem::type() const 181 181 { 182 182 return m_type; 183 183 } 184 184 185 const QString &UI FileTableItem::targetPath() const185 const QString &UICustomFileSystemItem::targetPath() const 186 186 { 187 187 return m_strTargetPath; 188 188 } 189 189 190 void UI FileTableItem::setTargetPath(const QString &path)190 void UICustomFileSystemItem::setTargetPath(const QString &path) 191 191 { 192 192 m_strTargetPath = path; 193 193 } 194 194 195 bool UI FileTableItem::isSymLinkToADirectory() const195 bool UICustomFileSystemItem::isSymLinkToADirectory() const 196 196 { 197 197 return m_isTargetADirectory; 198 198 } 199 199 200 void UI FileTableItem::setIsSymLinkToADirectory(bool flag)200 void UICustomFileSystemItem::setIsSymLinkToADirectory(bool flag) 201 201 { 202 202 m_isTargetADirectory = flag; 203 203 } 204 204 205 bool UI FileTableItem::isSymLinkToAFile() const205 bool UICustomFileSystemItem::isSymLinkToAFile() const 206 206 { 207 207 return isSymLink() && !m_isTargetADirectory; 208 208 } 209 209 210 void UI FileTableItem::setIsDriveItem(bool flag)210 void UICustomFileSystemItem::setIsDriveItem(bool flag) 211 211 { 212 212 m_isDriveItem = flag; 213 213 } 214 214 215 bool UI FileTableItem::isDriveItem() const215 bool UICustomFileSystemItem::isDriveItem() const 216 216 { 217 217 return m_isDriveItem; 218 218 } 219 219 220 UICustomFileSystemProxyModel::UICustomFileSystemProxyModel(QObject *parent /* = 0 */) 221 :QSortFilterProxyModel(parent) 222 , m_fListDirectoriesOnTop(false) 223 { 224 } 225 226 void UICustomFileSystemProxyModel::setListDirectoriesOnTop(bool fListDirectoriesOnTop) 227 { 228 m_fListDirectoriesOnTop = fListDirectoriesOnTop; 220 /* static */QVector<QVariant> UICustomFileSystemItem::createTreeItemData(const QString &strName, unsigned long long size, 221 const QDateTime &changeTime, 222 const QString &strOwner, const QString &strPermissions) 223 { 224 QVector<QVariant> data; 225 data.resize(UICustomFileSystemModelColumn_Max); 226 data[UICustomFileSystemModelColumn_Name] = strName; 227 data[UICustomFileSystemModelColumn_Size] = (qulonglong)size; 228 data[UICustomFileSystemModelColumn_ChangeTime] = changeTime; 229 data[UICustomFileSystemModelColumn_Owner] = strOwner; 230 data[UICustomFileSystemModelColumn_Permissions] = strPermissions; 231 return data; 229 232 } 230 233 … … 241 244 bool UICustomFileSystemProxyModel::lessThan(const QModelIndex &left, const QModelIndex &right) const 242 245 { 243 UI FileTableItem *pLeftItem = static_cast<UIFileTableItem*>(left.internalPointer());244 UI FileTableItem *pRightItem = static_cast<UIFileTableItem*>(right.internalPointer());246 UICustomFileSystemItem *pLeftItem = static_cast<UICustomFileSystemItem*>(left.internalPointer()); 247 UICustomFileSystemItem *pRightItem = static_cast<UICustomFileSystemItem*>(right.internalPointer()); 245 248 246 249 if (pLeftItem && pRightItem) … … 281 284 } 282 285 286 UICustomFileSystemProxyModel::UICustomFileSystemProxyModel(QObject *parent /* = 0 */) 287 :QSortFilterProxyModel(parent) 288 , m_fListDirectoriesOnTop(false) 289 { 290 } 291 292 void UICustomFileSystemProxyModel::setListDirectoriesOnTop(bool fListDirectoriesOnTop) 293 { 294 m_fListDirectoriesOnTop = fListDirectoriesOnTop; 295 } 296 297 298 /********************************************************************************************************************************* 299 * UICustomFileSystemModel implementation. * 300 *********************************************************************************************************************************/ 301 283 302 UICustomFileSystemModel::UICustomFileSystemModel(QObject *parent) 284 303 : QAbstractItemModel(parent) … … 288 307 } 289 308 290 UI FileTableItem* UICustomFileSystemModel::rootItem()309 UICustomFileSystemItem* UICustomFileSystemModel::rootItem() 291 310 { 292 311 return m_pRootItem; 293 312 } 294 313 295 const UI FileTableItem* UICustomFileSystemModel::rootItem() const314 const UICustomFileSystemItem* UICustomFileSystemModel::rootItem() const 296 315 { 297 316 return m_pRootItem; … … 306 325 { 307 326 if (parent.isValid()) 308 return static_cast<UI FileTableItem*>(parent.internalPointer())->columnCount();327 return static_cast<UICustomFileSystemItem*>(parent.internalPointer())->columnCount(); 309 328 else 310 329 { … … 322 341 if (index.column() == 0 && value.canConvert(QMetaType::QString)) 323 342 { 324 UI FileTableItem *pItem = static_cast<UIFileTableItem*>(index.internalPointer());343 UICustomFileSystemItem *pItem = static_cast<UICustomFileSystemItem*>(index.internalPointer()); 325 344 if (!pItem) 326 345 return false; … … 339 358 if (!index.isValid()) 340 359 return QVariant(); 341 UI FileTableItem *item = static_cast<UIFileTableItem*>(index.internalPointer());360 UICustomFileSystemItem *item = static_cast<UICustomFileSystemItem*>(index.internalPointer()); 342 361 if (!item) 343 362 return QVariant(); … … 398 417 if (!index.isValid()) 399 418 return 0; 400 UI FileTableItem *item = static_cast<UIFileTableItem*>(index.internalPointer());419 UICustomFileSystemItem *item = static_cast<UICustomFileSystemItem*>(index.internalPointer()); 401 420 if (!item) 402 421 return QAbstractItemModel::flags(index); … … 420 439 } 421 440 422 QModelIndex UICustomFileSystemModel::index(UI FileTableItem* item)441 QModelIndex UICustomFileSystemModel::index(UICustomFileSystemItem* item) 423 442 { 424 443 if (!item) … … 432 451 return QModelIndex(); 433 452 434 const UI FileTableItem* parentItem = rootItem();453 const UICustomFileSystemItem* parentItem = rootItem(); 435 454 436 455 if (parent.isValid()) 437 parentItem = static_cast<UI FileTableItem*>(parent.internalPointer());456 parentItem = static_cast<UICustomFileSystemItem*>(parent.internalPointer()); 438 457 439 458 if (!parentItem) 440 459 return QModelIndex(); 441 460 442 UI FileTableItem *childItem = parentItem->child(row);461 UICustomFileSystemItem *childItem = parentItem->child(row); 443 462 if (childItem) 444 463 return createIndex(row, column, childItem); … … 453 472 return QModelIndex(); 454 473 455 UI FileTableItem *childItem = static_cast<UIFileTableItem*>(index.internalPointer());456 UI FileTableItem *parentItem = childItem->parentItem();474 UICustomFileSystemItem *childItem = static_cast<UICustomFileSystemItem*>(index.internalPointer()); 475 UICustomFileSystemItem *parentItem = childItem->parentItem(); 457 476 458 477 if (parentItem == rootItem()) … … 466 485 if (parent.column() > 0) 467 486 return 0; 468 const UI FileTableItem *parentItem = rootItem();487 const UICustomFileSystemItem *parentItem = rootItem(); 469 488 if (parent.isValid()) 470 parentItem = static_cast<UI FileTableItem*>(parent.internalPointer());489 parentItem = static_cast<UICustomFileSystemItem*>(parent.internalPointer()); 471 490 if (!parentItem) 472 491 return 0; … … 518 537 QVector<QVariant> headData; 519 538 headData.resize(UICustomFileSystemModelColumn_Max); 520 m_pRootItem = new UI FileTableItem(headData, 0, KFsObjType_Directory);521 } 539 m_pRootItem = new UICustomFileSystemItem(headData, 0, KFsObjType_Directory); 540 } -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UICustomFileSystemModel.h
r76332 r76333 36 36 }; 37 37 38 /** A UI FileTableItem instance is a tree node representing a file object (file, directory, etc). The tree contructed38 /** A UICustomFileSystemItem instance is a tree node representing a file object (file, directory, etc). The tree contructed 39 39 by these instances is the data source for the UICustomFileSystemModel. */ 40 class UI FileTableItem40 class UICustomFileSystemItem 41 41 { 42 42 public: … … 45 45 * the name of the file object which is the file name including extension or name of the 46 46 * directory */ 47 explicit UI FileTableItem(const QVector<QVariant> &data,48 UI FileTableItem *parentItem, KFsObjType type);49 ~UI FileTableItem();47 explicit UICustomFileSystemItem(const QVector<QVariant> &data, 48 UICustomFileSystemItem *parentItem, KFsObjType type); 49 ~UICustomFileSystemItem(); 50 50 51 void appendChild(UI FileTableItem *child);51 void appendChild(UICustomFileSystemItem *child); 52 52 void reset(); 53 UI FileTableItem *child(int row) const;53 UICustomFileSystemItem *child(int row) const; 54 54 /** Searches for the child by path and returns it if found. */ 55 UI FileTableItem *child(const QString &path) const;55 UICustomFileSystemItem *child(const QString &path) const; 56 56 int childCount() const; 57 57 int columnCount() const; … … 59 59 void setData(const QVariant &data, int index); 60 60 int row() const; 61 UI FileTableItem *parentItem();61 UICustomFileSystemItem *parentItem(); 62 62 63 63 bool isDirectory() const; … … 93 93 bool isDriveItem() const; 94 94 95 static QVector<QVariant> createTreeItemData(const QString &strName, unsigned long long size, const QDateTime &changeTime, 96 const QString &strOwner, const QString &strPermissions); 97 95 98 private: 96 99 97 QList<UI FileTableItem*> m_childItems;100 QList<UICustomFileSystemItem*> m_childItems; 98 101 /** Used to find children by name */ 99 QMap<QString, UI FileTableItem*> m_childMap;102 QMap<QString, UICustomFileSystemItem*> m_childMap; 100 103 /** It is required that m_itemData[0] is name (QString) of the file object */ 101 104 QVector<QVariant> m_itemData; 102 UI FileTableItem *m_parentItem;105 UICustomFileSystemItem *m_parentItem; 103 106 bool m_bIsOpened; 104 107 /** Full absolute path of the item. Without the trailing '/' */ … … 145 148 signals: 146 149 147 void sigItemRenamed(UI FileTableItem *pItem, QString strOldName, QString strNewName);150 void sigItemRenamed(UICustomFileSystemItem *pItem, QString strOldName, QString strNewName); 148 151 149 152 public: … … 160 163 QModelIndex index(int row, int column, 161 164 const QModelIndex &parent = QModelIndex()) const /* override */; 162 QModelIndex index(UI FileTableItem* item);165 QModelIndex index(UICustomFileSystemItem* item); 163 166 QModelIndex parent(const QModelIndex &index) const /* override */; 164 167 int rowCount(const QModelIndex &parent = QModelIndex()) const /* override */; … … 172 175 void setShowHumanReadableSizes(bool fShowHumanReadableSizes); 173 176 bool showHumanReadableSizes() const; 174 UI FileTableItem* rootItem();175 const UI FileTableItem* rootItem() const;177 UICustomFileSystemItem* rootItem(); 178 const UICustomFileSystemItem* rootItem() const; 176 179 177 180 static const char* strUpDirectoryString; … … 179 182 private: 180 183 void initializeTree(); 181 UI FileTableItem *m_pRootItem;182 void setupModelData(const QStringList &lines, UI FileTableItem *parent);184 UICustomFileSystemItem *m_pRootItem; 185 void setupModelData(const QStringList &lines, UICustomFileSystemItem *parent); 183 186 bool m_fShowHumanReadableSizes; 184 187 }; -
trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerGuestTable.cpp
r76329 r76333 175 175 176 176 void UIFileManagerGuestTable::readDirectory(const QString& strPath, 177 UI FileTableItem *parent, bool isStartDir /*= false*/)177 UICustomFileSystemItem *parent, bool isStartDir /*= false*/) 178 178 179 179 { … … 196 196 { 197 197 CFsObjInfo fsInfo = directory.Read(); 198 QMap<QString, UI FileTableItem*> directories;199 QMap<QString, UI FileTableItem*> files;198 QMap<QString, UICustomFileSystemItem*> directories; 199 QMap<QString, UICustomFileSystemItem*> files; 200 200 201 201 while (fsInfo.isOk()) … … 208 208 209 209 KFsObjType fsObjectType = fileType(fsInfo); 210 UI FileTableItem *item = new UIFileTableItem(data, parent, fsObjectType);210 UICustomFileSystemItem *item = new UICustomFileSystemItem(data, parent, fsObjectType); 211 211 212 212 if (!item) … … 243 243 } 244 244 245 void UIFileManagerGuestTable::deleteByItem(UI FileTableItem *item)245 void UIFileManagerGuestTable::deleteByItem(UICustomFileSystemItem *item) 246 246 { 247 247 if (!item) … … 289 289 if (!rootItem() || rootItem()->childCount() <= 0) 290 290 return; 291 UI FileTableItem *startDirItem = rootItem()->child(0);291 UICustomFileSystemItem *startDirItem = rootItem()->child(0); 292 292 if (!startDirItem) 293 293 return; … … 303 303 } 304 304 305 bool UIFileManagerGuestTable::renameItem(UI FileTableItem *item, QString newBaseName)305 bool UIFileManagerGuestTable::renameItem(UICustomFileSystemItem *item, QString newBaseName) 306 306 { 307 307 -
trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerGuestTable.h
r76300 r76333 31 31 /* Forward declarations: */ 32 32 class UIActionPool; 33 class UICustomFileSystemItem; 33 34 34 35 /** This class scans the guest file system by using the VBox Guest Control API … … 53 54 54 55 void retranslateUi() /* override */; 55 virtual void readDirectory(const QString& strPath, UI FileTableItem *parent, bool isStartDir = false) /* override */;56 virtual void deleteByItem(UI FileTableItem *item) /* override */;56 virtual void readDirectory(const QString& strPath, UICustomFileSystemItem *parent, bool isStartDir = false) /* override */; 57 virtual void deleteByItem(UICustomFileSystemItem *item) /* override */; 57 58 virtual void deleteByPath(const QStringList &pathList) /* override */; 58 59 virtual void goToHomeDirectory() /* override */; 59 virtual bool renameItem(UI FileTableItem *item, QString newBaseName);60 virtual bool renameItem(UICustomFileSystemItem *item, QString newBaseName); 60 61 virtual bool createDirectory(const QString &path, const QString &directoryName); 61 62 virtual QString fsObjectPropertyString() /* override */; -
trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerHostTable.cpp
r76329 r76333 202 202 } 203 203 204 void UIFileManagerHostTable::readDirectory(const QString& strPath, UI FileTableItem *parent, bool isStartDir /*= false*/)204 void UIFileManagerHostTable::readDirectory(const QString& strPath, UICustomFileSystemItem *parent, bool isStartDir /*= false*/) 205 205 { 206 206 if (!parent) … … 213 213 return; 214 214 QFileInfoList entries = directory.entryInfoList(); 215 QMap<QString, UI FileTableItem*> directories;216 QMap<QString, UI FileTableItem*> files;215 QMap<QString, UICustomFileSystemItem*> directories; 216 QMap<QString, UICustomFileSystemItem*> files; 217 217 218 218 for (int i = 0; i < entries.size(); ++i) … … 220 220 221 221 const QFileInfo &fileInfo = entries.at(i); 222 UIFileTableItem *item = new UIFileTableItem(createTreeItemData(fileInfo.fileName(), fileInfo.size(),223 fileInfo.lastModified(), fileInfo.owner(),224 permissionString(fileInfo.permissions())),225 222 QVector<QVariant> itemData = UICustomFileSystemItem::createTreeItemData(fileInfo.fileName(), fileInfo.size(), 223 fileInfo.lastModified(), fileInfo.owner(), 224 permissionString(fileInfo.permissions())); 225 UICustomFileSystemItem *item = new UICustomFileSystemItem(itemData, parent, fileType(fileInfo)); 226 226 if (!item) 227 227 continue; … … 250 250 } 251 251 252 void UIFileManagerHostTable::deleteByItem(UI FileTableItem *item)252 void UIFileManagerHostTable::deleteByItem(UICustomFileSystemItem *item) 253 253 { 254 254 if (item->isUpDirectory()) … … 297 297 if (!rootItem() || rootItem()->childCount() <= 0) 298 298 return; 299 UI FileTableItem *startDirItem = rootItem()->child(0);299 UICustomFileSystemItem *startDirItem = rootItem()->child(0); 300 300 if (!startDirItem) 301 301 return; … … 305 305 } 306 306 307 bool UIFileManagerHostTable::renameItem(UI FileTableItem *item, QString newBaseName)307 bool UIFileManagerHostTable::renameItem(UICustomFileSystemItem *item, QString newBaseName) 308 308 { 309 309 if (!item || item->isUpDirectory() || newBaseName.isEmpty()) -
trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerHostTable.h
r76300 r76333 24 24 /* Forward declarations: */ 25 25 class UIActionPool; 26 class UICustomFileSystemItem; 26 27 27 28 /** This class scans the host file system by using the Qt API … … 39 40 KFsObjType fileType(const QFileInfo &fsInfo); 40 41 void retranslateUi() /* override */; 41 virtual void readDirectory(const QString& strPath, UI FileTableItem *parent, bool isStartDir = false) /* override */;42 virtual void deleteByItem(UI FileTableItem *item) /* override */;42 virtual void readDirectory(const QString& strPath, UICustomFileSystemItem *parent, bool isStartDir = false) /* override */; 43 virtual void deleteByItem(UICustomFileSystemItem *item) /* override */; 43 44 virtual void deleteByPath(const QStringList &pathList) /* override */; 44 45 virtual void goToHomeDirectory() /* override */; 45 virtual bool renameItem(UI FileTableItem *item, QString newBaseName);46 virtual bool renameItem(UICustomFileSystemItem *item, QString newBaseName); 46 47 virtual bool createDirectory(const QString &path, const QString &directoryName); 47 48 virtual QString fsObjectPropertyString() /* override */; -
trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerTable.cpp
r76329 r76333 534 534 m_pView->clearSelection(); 535 535 536 UI FileTableItem *item = static_cast<UIFileTableItem*>(index.internalPointer());536 UICustomFileSystemItem *item = static_cast<UICustomFileSystemItem*>(index.internalPointer()); 537 537 if (item) 538 538 { … … 551 551 552 552 const QString startPath("/"); 553 UIFileTableItem* startItem = new UIFileTableItem(createTreeItemData(startPath, 4096, QDateTime(),554 "" /* owner */, "" /* permissions */),555 553 QVector<QVariant> itemData = UICustomFileSystemItem::createTreeItemData(startPath, 4096, QDateTime(), 554 "" /* owner */, "" /* permissions */); 555 UICustomFileSystemItem* startItem = new UICustomFileSystemItem(itemData, rootItem(), KFsObjType_Directory); 556 556 startItem->setPath(startPath); 557 557 rootItem()->appendChild(startItem); … … 564 564 } 565 565 566 void UIFileManagerTable::populateStartDirectory(UI FileTableItem *startItem)566 void UIFileManagerTable::populateStartDirectory(UICustomFileSystemItem *startItem) 567 567 { 568 568 determineDriveLetters(); … … 576 576 for (int i = 0; i < m_driveLetterList.size(); ++i) 577 577 { 578 UIFileTableItem* driveItem = new UIFileTableItem(createTreeItemData(m_driveLetterList[i], 4096,579 QDateTime(), QString(), QString()),580 578 QVector<QVariant> itemData = UICustomFileSystemItem::createTreeItemData(m_driveLetterList[i], 4096, 579 QDateTime(), QString(), QString()); 580 UICustomFileSystemItem* driveItem = new UICustomFileSystemItem(itemData, startItem, KFsObjType_Directory); 581 581 driveItem->setPath(m_driveLetterList[i]); 582 582 startItem->appendChild(driveItem); … … 588 588 } 589 589 590 void UIFileManagerTable::insertItemsToTree(QMap<QString,UI FileTableItem*> &map,591 UI FileTableItem *parent, bool isDirectoryMap, bool isStartDir)592 { 593 if ( parent)594 590 void UIFileManagerTable::insertItemsToTree(QMap<QString,UICustomFileSystemItem*> &map, 591 UICustomFileSystemItem *parent, bool isDirectoryMap, bool isStartDir) 592 { 593 if (!parent) 594 return; 595 595 /* Make sure we have an item representing up directory, and make sure it is not there for the start dir: */ 596 596 if (isDirectoryMap) … … 598 598 if (!map.contains(UICustomFileSystemModel::strUpDirectoryString) && !isStartDir) 599 599 { 600 QVector<QVariant> data ;601 UIFileTableItem *item = new UIFileTableItem(createTreeItemData(UICustomFileSystemModel::strUpDirectoryString, 4096,602 QDateTime(), QString(), QString()) 603 600 QVector<QVariant> data = UICustomFileSystemItem::createTreeItemData(UICustomFileSystemModel::strUpDirectoryString, 601 4096, QDateTime(), QString(), QString()); 602 603 UICustomFileSystemItem *item = new UICustomFileSystemItem(data, parent, KFsObjType_Directory); 604 604 item->setIsOpened(false); 605 605 map.insert(UICustomFileSystemModel::strUpDirectoryString, item); … … 610 610 } 611 611 } 612 for (QMap<QString,UI FileTableItem*>::const_iterator iterator = map.begin();612 for (QMap<QString,UICustomFileSystemItem*>::const_iterator iterator = map.begin(); 613 613 iterator != map.end(); ++iterator) 614 614 { … … 672 672 return; 673 673 674 UI FileTableItem *item = static_cast<UIFileTableItem*>(index.internalPointer());674 UICustomFileSystemItem *item = static_cast<UICustomFileSystemItem*>(index.internalPointer()); 675 675 if (!item) 676 676 return; … … 695 695 void UIFileManagerTable::goIntoDirectory(const QStringList &pathTrail) 696 696 { 697 UI FileTableItem *parent = getStartDirectoryItem();697 UICustomFileSystemItem *parent = getStartDirectoryItem(); 698 698 699 699 for(int i = 0; i < pathTrail.size(); ++i) … … 705 705 readDirectory(parent->path(), parent, parent == getStartDirectoryItem()); 706 706 /* search the current path item among the parent's children: */ 707 UI FileTableItem *item = parent->child(pathTrail.at(i));707 UICustomFileSystemItem *item = parent->child(pathTrail.at(i)); 708 708 if (!item) 709 709 return; … … 717 717 } 718 718 719 void UIFileManagerTable::goIntoDirectory(UI FileTableItem *item)719 void UIFileManagerTable::goIntoDirectory(UICustomFileSystemItem *item) 720 720 { 721 721 if (!item || !m_pModel) … … 724 724 } 725 725 726 UI FileTableItem* UIFileManagerTable::indexData(const QModelIndex &index) const726 UICustomFileSystemItem* UIFileManagerTable::indexData(const QModelIndex &index) const 727 727 { 728 728 if (!index.isValid()) 729 729 return 0; 730 return static_cast<UI FileTableItem*>(index.internalPointer());730 return static_cast<UICustomFileSystemItem*>(index.internalPointer()); 731 731 } 732 732 … … 737 737 QModelIndex currentIndex = currentRootIndex(); 738 738 739 UI FileTableItem *treeItem = indexData(currentIndex);739 UICustomFileSystemItem *treeItem = indexData(currentIndex); 740 740 if (!treeItem) 741 741 return; … … 798 798 QModelIndex modelIndex = 799 799 m_pProxyModel ? m_pProxyModel->mapToSource(selectedItemIndices.at(0)) : selectedItemIndices.at(0); 800 UI FileTableItem *item = indexData(modelIndex);800 UICustomFileSystemItem *item = indexData(modelIndex); 801 801 if (!item || item->isUpDirectory()) 802 802 return; … … 811 811 if (!currentIndex.isValid()) 812 812 return; 813 UI FileTableItem *item = static_cast<UIFileTableItem*>(currentIndex.internalPointer());813 UICustomFileSystemItem *item = static_cast<UICustomFileSystemItem*>(currentIndex.internalPointer()); 814 814 if (!item) 815 815 return; … … 888 888 } 889 889 890 void UIFileManagerTable::sltHandleItemRenameAttempt(UI FileTableItem *pItem, QString strOldName, QString strNewName)890 void UIFileManagerTable::sltHandleItemRenameAttempt(UICustomFileSystemItem *pItem, QString strOldName, QString strNewName) 891 891 { 892 892 if (!pItem) … … 929 929 continue; 930 930 931 UI FileTableItem *item = static_cast<UIFileTableItem*>(index.internalPointer());931 UICustomFileSystemItem *item = static_cast<UICustomFileSystemItem*>(index.internalPointer()); 932 932 if (item && item->isUpDirectory()) 933 933 { … … 972 972 void UIFileManagerTable::deleteByIndex(const QModelIndex &itemIndex) 973 973 { 974 UI FileTableItem *treeItem = indexData(itemIndex);974 UICustomFileSystemItem *treeItem = indexData(itemIndex); 975 975 if (!treeItem) 976 976 return; … … 980 980 void UIFileManagerTable::retranslateUi() 981 981 { 982 UI FileTableItem *pRootItem = rootItem();982 UICustomFileSystemItem *pRootItem = rootItem(); 983 983 if (pRootItem) 984 984 { … … 1052 1052 } 1053 1053 1054 UI FileTableItem *UIFileManagerTable::getStartDirectoryItem()1055 { 1056 UI FileTableItem* pRootItem = rootItem();1054 UICustomFileSystemItem *UIFileManagerTable::getStartDirectoryItem() 1055 { 1056 UICustomFileSystemItem* pRootItem = rootItem(); 1057 1057 if (!pRootItem) 1058 1058 return 0; … … 1083 1083 if (!currentRoot.isValid()) 1084 1084 return QString(); 1085 UI FileTableItem *item = static_cast<UIFileTableItem*>(currentRoot.internalPointer());1085 UICustomFileSystemItem *item = static_cast<UICustomFileSystemItem*>(currentRoot.internalPointer()); 1086 1086 if (!item) 1087 1087 return QString(); … … 1104 1104 QModelIndex index = 1105 1105 m_pProxyModel ? m_pProxyModel->mapToSource(selectedItemIndices.at(i)) : selectedItemIndices.at(i); 1106 UI FileTableItem *item = static_cast<UIFileTableItem*>(index.internalPointer());1106 UICustomFileSystemItem *item = static_cast<UICustomFileSystemItem*>(index.internalPointer()); 1107 1107 if (!item) 1108 1108 continue; … … 1130 1130 } 1131 1131 1132 QVector<QVariant> UIFileManagerTable::createTreeItemData(const QString &strName, ULONG64 size, const QDateTime &changeTime, 1133 const QString &strOwner, const QString &strPermissions) 1134 { 1135 QVector<QVariant> data; 1136 data.resize(UICustomFileSystemModelColumn_Max); 1137 data[UICustomFileSystemModelColumn_Name] = strName; 1138 data[UICustomFileSystemModelColumn_Size] = (qulonglong)size; 1139 data[UICustomFileSystemModelColumn_ChangeTime] = changeTime; 1140 data[UICustomFileSystemModelColumn_Owner] = strOwner; 1141 data[UICustomFileSystemModelColumn_Permissions] = strPermissions; 1142 return data; 1143 } 1144 1145 UIFileTableItem* UIFileManagerTable::rootItem() 1132 UICustomFileSystemItem* UIFileManagerTable::rootItem() 1146 1133 { 1147 1134 if (!m_pModel) … … 1224 1211 1225 1212 int rowCount = m_pProxyModel->rowCount(m_pView->rootIndex()); 1226 UI FileTableItem *pFoundItem = 0;1213 UICustomFileSystemItem *pFoundItem = 0; 1227 1214 QModelIndex index; 1228 1215 for (int i = 0; i < rowCount && !pFoundItem; ++i) … … 1231 1218 if (!index.isValid()) 1232 1219 continue; 1233 pFoundItem = static_cast<UI FileTableItem*>(m_pProxyModel->mapToSource(index).internalPointer());1220 pFoundItem = static_cast<UICustomFileSystemItem*>(m_pProxyModel->mapToSource(index).internalPointer()); 1234 1221 if (!pFoundItem) 1235 1222 continue; -
trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerTable.h
r76329 r76333 46 46 class QVBoxLayout; 47 47 class UIActionPool; 48 class UI FileTableItem;48 class UICustomFileSystemItem; 49 49 class UICustomFileSystemModel; 50 50 class UICustomFileSystemProxyModel; … … 193 193 void changeLocation(const QModelIndex &index); 194 194 void initializeFileTree(); 195 void insertItemsToTree(QMap<QString,UI FileTableItem*> &map, UIFileTableItem *parent,195 void insertItemsToTree(QMap<QString,UICustomFileSystemItem*> &map, UICustomFileSystemItem *parent, 196 196 bool isDirectoryMap, bool isStartDir); 197 virtual void readDirectory(const QString& strPath, UI FileTableItem *parent, bool isStartDir = false) = 0;198 virtual void deleteByItem(UI FileTableItem *item) = 0;197 virtual void readDirectory(const QString& strPath, UICustomFileSystemItem *parent, bool isStartDir = false) = 0; 198 virtual void deleteByItem(UICustomFileSystemItem *item) = 0; 199 199 virtual void deleteByPath(const QStringList &pathList) = 0; 200 200 virtual void goToHomeDirectory() = 0; 201 virtual bool renameItem(UI FileTableItem *item, QString newBaseName) = 0;201 virtual bool renameItem(UICustomFileSystemItem *item, QString newBaseName) = 0; 202 202 virtual bool createDirectory(const QString &path, const QString &directoryName) = 0; 203 203 virtual QString fsObjectPropertyString() = 0; … … 225 225 void goIntoDirectory(const QStringList &pathTrail); 226 226 /** Goes into directory pointed by the @p item */ 227 void goIntoDirectory(UI FileTableItem *item);228 UI FileTableItem* indexData(const QModelIndex &index) const;227 void goIntoDirectory(UICustomFileSystemItem *item); 228 UICustomFileSystemItem* indexData(const QModelIndex &index) const; 229 229 bool eventFilter(QObject *pObject, QEvent *pEvent) /* override */; 230 230 CGuestFsObjInfo guestFsObjectInfo(const QString& path, CGuestSession &comGuestSession) const; 231 231 void setSelectionDependentActionsEnabled(bool fIsEnabled); 232 /** Creates a QList out of the parameters wrt. UICustomFileSystemModelColumn enum */ 233 QVector<QVariant> createTreeItemData(const QString &strName, ULONG64 size, const QDateTime &changeTime, 234 const QString &strOwner, const QString &strPermissions); 235 UIFileTableItem* rootItem(); 236 232 UICustomFileSystemItem* rootItem(); 237 233 238 234 QILabel *m_pLocationLabel; … … 260 256 * if the file system rename fails we restore the old name of the item. See the comment of 261 257 * sltRename() for more details. */ 262 void sltHandleItemRenameAttempt(UI FileTableItem *pItem, QString strOldName, QString strNewName);258 void sltHandleItemRenameAttempt(UICustomFileSystemItem *pItem, QString strOldName, QString strNewName); 263 259 264 260 private: … … 268 264 /** @p itemIndex is assumed to be 'model' index not 'proxy model' index */ 269 265 void deleteByIndex(const QModelIndex &itemIndex); 270 /** Returns the UI FileTableItem for path / which is a direct (and single) child of m_pRootItem */271 UI FileTableItem *getStartDirectoryItem();266 /** Returns the UICustomFileSystemItem for path / which is a direct (and single) child of m_pRootItem */ 267 UICustomFileSystemItem *getStartDirectoryItem(); 272 268 /** Shows a modal dialog with a line edit for user to enter a new directory name and return the entered string*/ 273 269 QString getNewDirectoryName(); … … 277 273 /** The start directory requires a special attention since on file systems with drive letters 278 274 * drive letter are direct children of the start directory. On other systems start directory is '/' */ 279 void populateStartDirectory(UI FileTableItem *startItem);275 void populateStartDirectory(UICustomFileSystemItem *startItem); 280 276 /** Root index of the m_pModel */ 281 277 QModelIndex currentRootIndex() const;
Note:
See TracChangeset
for help on using the changeset viewer.