Changeset 76429 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Dec 23, 2018 9:25:44 PM (6 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/globals/UICustomFileSystemModel.cpp
r76344 r76429 50 50 if (parent) 51 51 parent->appendChild(this); 52 53 52 } 54 53 -
trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerGuestTable.cpp
r76345 r76429 196 196 { 197 197 CFsObjInfo fsInfo = directory.Read(); 198 QMap<QString, UICustomFileSystemItem*> directories; 199 QMap<QString, UICustomFileSystemItem*> files; 198 QMap<QString, UICustomFileSystemItem*> fileObjects; 200 199 201 200 while (fsInfo.isOk()) 202 201 { 203 QVector<QVariant> data; 204 QDateTime changeTime = QDateTime::fromMSecsSinceEpoch(fsInfo.GetChangeTime()/RT_NS_1MS); 205 206 data << fsInfo.GetName() << static_cast<qulonglong>(fsInfo.GetObjectSize()) 207 << changeTime << fsInfo.GetUserName() << permissionString(fsInfo); 208 209 KFsObjType fsObjectType = fileType(fsInfo); 210 UICustomFileSystemItem *item = new UICustomFileSystemItem(data, parent, fsObjectType); 211 212 if (!item) 213 continue; 214 item->setPath(UIPathOperations::mergePaths(strPath, fsInfo.GetName())); 215 if (fsObjectType == KFsObjType_Directory) 202 if (fsInfo.GetName() != "." && fsInfo.GetName() != "..") 216 203 { 217 directories.insert(fsInfo.GetName(), item); 218 item->setIsOpened(false); 219 } 220 else if(fsObjectType == KFsObjType_File) 221 { 222 files.insert(fsInfo.GetName(), item); 223 item->setIsOpened(false); 224 } 225 else if(fsObjectType == KFsObjType_Symlink) 226 { 227 files.insert(fsInfo.GetName(), item); 204 QVector<QVariant> data; 205 QDateTime changeTime = QDateTime::fromMSecsSinceEpoch(fsInfo.GetChangeTime()/RT_NS_1MS); 206 207 data << fsInfo.GetName() << static_cast<qulonglong>(fsInfo.GetObjectSize()) 208 << changeTime << fsInfo.GetUserName() << permissionString(fsInfo); 209 210 KFsObjType fsObjectType = fileType(fsInfo); 211 UICustomFileSystemItem *item = new UICustomFileSystemItem(data, parent, fsObjectType); 212 213 if (!item) 214 continue; 215 item->setPath(UIPathOperations::mergePaths(strPath, fsInfo.GetName())); 216 fileObjects.insert(fsInfo.GetName(), item); 228 217 item->setIsOpened(false); 229 218 /* @todo. We will need to wait a fully implemented SymlinkRead function … … 234 223 // qPrintable(m_comGuestSession.SymlinkRead(path, aFlags))); 235 224 } 236 237 225 fsInfo = directory.Read(); 238 226 } 239 insertItemsToTree(directories, parent, true, isStartDir); 240 insertItemsToTree(files, parent, false, isStartDir); 227 checkDotDot(fileObjects, parent, isStartDir); 241 228 } 242 229 directory.Close(); -
trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerHostTable.cpp
r76333 r76429 134 134 prepareActionConnections(); 135 135 retranslateUi(); 136 } 137 138 /* static */ void UIFileManagerHostTable::scanDirectory(const QString& strPath, UICustomFileSystemItem *parent, 139 QMap<QString, UICustomFileSystemItem*> &fileObjects) 140 { 141 142 QDir directory(strPath); 143 /* For some reason when this filter is applied, folder content QDir::entryInfoList() 144 returns an empty list: */ 145 /*directory.setFilter(QDir::NoDotAndDotDot);*/ 146 parent->setIsOpened(true); 147 if (!directory.exists()) 148 return; 149 QFileInfoList entries = directory.entryInfoList(); 150 151 152 for (int i = 0; i < entries.size(); ++i) 153 { 154 155 156 const QFileInfo &fileInfo = entries.at(i); 157 QVector<QVariant> itemData = UICustomFileSystemItem::createTreeItemData(fileInfo.fileName(), fileInfo.size(), 158 fileInfo.lastModified(), fileInfo.owner(), 159 permissionString(fileInfo.permissions())); 160 if (fileInfo.fileName() == ".") 161 continue; 162 if (fileInfo.fileName() == "..") 163 continue; 164 165 UICustomFileSystemItem *item = new UICustomFileSystemItem(itemData, parent, fileType(fileInfo)); 166 if (!item) 167 continue; 168 item->setPath(fileInfo.absoluteFilePath()); 169 /* if the item is a symlink set the target path and 170 check the target if it is a directory: */ 171 if (fileInfo.isSymLink()) /** @todo No symlinks here on windows, while fsObjectPropertyString() does see them. RTDirReadEx works wrt symlinks, btw. */ 172 { 173 item->setTargetPath(fileInfo.symLinkTarget()); 174 item->setIsSymLinkToADirectory(QFileInfo(fileInfo.symLinkTarget()).isDir()); 175 } 176 fileObjects.insert(fileInfo.fileName(), item); 177 item->setIsOpened(false); 178 } 179 136 180 } 137 181 … … 207 251 return; 208 252 209 QDir directory(strPath); 210 //directory.setFilter(QDir::NoDotAndDotDot); 211 parent->setIsOpened(true); 212 if (!directory.exists()) 213 return; 214 QFileInfoList entries = directory.entryInfoList(); 215 QMap<QString, UICustomFileSystemItem*> directories; 216 QMap<QString, UICustomFileSystemItem*> files; 217 218 for (int i = 0; i < entries.size(); ++i) 219 { 220 221 const QFileInfo &fileInfo = entries.at(i); 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 if (!item) 227 continue; 228 item->setPath(fileInfo.absoluteFilePath()); 229 /* if the item is a symlink set the target path and 230 check the target if it is a directory: */ 231 if (fileInfo.isSymLink()) /** @todo No symlinks here on windows, while fsObjectPropertyString() does see them. RTDirReadEx works wrt symlinks, btw. */ 232 { 233 item->setTargetPath(fileInfo.symLinkTarget()); 234 item->setIsSymLinkToADirectory(QFileInfo(fileInfo.symLinkTarget()).isDir()); 235 } 236 if (fileInfo.isDir()) 237 { 238 directories.insert(fileInfo.fileName(), item); 239 item->setIsOpened(false); 240 } 241 else 242 { 243 files.insert(fileInfo.fileName(), item); 244 item->setIsOpened(false); 245 } 246 } 247 insertItemsToTree(directories, parent, true, isStartDir); 248 insertItemsToTree(files, parent, false, isStartDir); 249 //updateCurrentLocationEdit(strPath); 253 QMap<QString, UICustomFileSystemItem*> fileObjects; 254 scanDirectory(strPath, parent, fileObjects); 255 checkDotDot(fileObjects, parent, isStartDir); 250 256 } 251 257 … … 331 337 } 332 338 333 KFsObjType UIFileManagerHostTable::fileType(const QFileInfo &fsInfo)339 /* static */ KFsObjType UIFileManagerHostTable::fileType(const QFileInfo &fsInfo) 334 340 { 335 341 if (!fsInfo.exists()) … … 454 460 } 455 461 456 QString UIFileManagerHostTable::permissionString(QFileDevice::Permissions permissions)462 /* static */QString UIFileManagerHostTable::permissionString(QFileDevice::Permissions permissions) 457 463 { 458 464 QString strPermissions; -
trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerHostTable.h
r76333 r76429 35 35 36 36 UIFileManagerHostTable(UIActionPool *pActionPool, QWidget *pParent = 0); 37 /** Scans the directory with the path @strPath and inserts items to the 38 * tree under the @p parent. */ 39 static void scanDirectory(const QString& strPath, UICustomFileSystemItem *parent, 40 QMap<QString, UICustomFileSystemItem*> &fileObjects); 37 41 38 42 protected: 39 43 40 KFsObjType fileType(const QFileInfo &fsInfo);44 static KFsObjType fileType(const QFileInfo &fsInfo); 41 45 void retranslateUi() /* override */; 42 46 virtual void readDirectory(const QString& strPath, UICustomFileSystemItem *parent, bool isStartDir = false) /* override */; … … 60 64 private: 61 65 62 QString permissionString(QFileDevice::Permissions permissions);66 static QString permissionString(QFileDevice::Permissions permissions); 63 67 void prepareActionConnections(); 64 68 -
trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerTable.cpp
r76333 r76429 588 588 } 589 589 590 void UIFileManagerTable:: insertItemsToTree(QMap<QString,UICustomFileSystemItem*> &map,591 UICustomFileSystemItem *parent, bool isDirectoryMap, bool isStartDir)590 void UIFileManagerTable::checkDotDot(QMap<QString,UICustomFileSystemItem*> &map, 591 UICustomFileSystemItem *parent, bool isStartDir) 592 592 { 593 593 if (!parent) 594 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 if (isDirectoryMap) 597 { 598 if (!map.contains(UICustomFileSystemModel::strUpDirectoryString) && !isStartDir) 599 { 600 QVector<QVariant> data = UICustomFileSystemItem::createTreeItemData(UICustomFileSystemModel::strUpDirectoryString, 601 4096, QDateTime(), QString(), QString()); 602 603 UICustomFileSystemItem *item = new UICustomFileSystemItem(data, parent, KFsObjType_Directory); 604 item->setIsOpened(false); 605 map.insert(UICustomFileSystemModel::strUpDirectoryString, item); 606 } 607 else if (map.contains(UICustomFileSystemModel::strUpDirectoryString) && isStartDir) 608 { 609 map.remove(UICustomFileSystemModel::strUpDirectoryString); 610 } 611 } 612 for (QMap<QString,UICustomFileSystemItem*>::const_iterator iterator = map.begin(); 613 iterator != map.end(); ++iterator) 614 { 615 if (iterator.key() == "." || iterator.key().isEmpty()) 616 continue; 617 parent->appendChild(iterator.value()); 596 if (!map.contains(UICustomFileSystemModel::strUpDirectoryString) && !isStartDir) 597 { 598 QVector<QVariant> data = UICustomFileSystemItem::createTreeItemData(UICustomFileSystemModel::strUpDirectoryString, 599 4096, QDateTime(), QString(), QString()); 600 601 UICustomFileSystemItem *item = new UICustomFileSystemItem(data, parent, KFsObjType_Directory); 602 item->setIsOpened(false); 603 map.insert(UICustomFileSystemModel::strUpDirectoryString, item); 604 } 605 else if (map.contains(UICustomFileSystemModel::strUpDirectoryString) && isStartDir) 606 { 607 map.remove(UICustomFileSystemModel::strUpDirectoryString); 618 608 } 619 609 } -
trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerTable.h
r76333 r76429 193 193 void changeLocation(const QModelIndex &index); 194 194 void initializeFileTree(); 195 void insertItemsToTree(QMap<QString,UICustomFileSystemItem*> &map, UICustomFileSystemItem *parent,196 bool isDirectoryMap, bool isStartDir); 195 void checkDotDot(QMap<QString,UICustomFileSystemItem*> &map, UICustomFileSystemItem *parent, bool isStartDir); 196 197 197 virtual void readDirectory(const QString& strPath, UICustomFileSystemItem *parent, bool isStartDir = false) = 0; 198 198 virtual void deleteByItem(UICustomFileSystemItem *item) = 0;
Note:
See TracChangeset
for help on using the changeset viewer.