Changeset 71832 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Apr 12, 2018 6:56:48 AM (7 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/runtime/guestctrl
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/runtime/guestctrl/UIGuestControlFileModel.cpp
r71639 r71832 116 116 if (item->isUpDirectory()) 117 117 return QIcon(":/arrow_up_10px_x2.png"); 118 else if(item->isDriveItem()) 119 return QIcon(":/hd_32px.png"); 118 120 else 119 121 return QIcon(":/sf_32px.png"); … … 256 258 return true; 257 259 } 258 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/guestctrl/UIGuestControlFileTable.cpp
r71794 r71832 171 171 172 172 const QChar UIPathOperations::delimiter = QChar('/'); 173 const QChar UIPathOperations::dosDelimiter = QChar('\\'); 173 174 174 175 /* static */ QString UIPathOperations::removeMultipleDelimiters(const QString &path) … … 193 194 } 194 195 195 /* static */ QString UIPathOperations::addTrailingDelimiters 196 (const QString &path) 196 /* static */ QString UIPathOperations::addTrailingDelimiters(const QString &path) 197 197 { 198 198 if (path.isNull() || path.isEmpty()) … … 209 209 return QString(path); 210 210 QString newPath(path); 211 212 if (doesPathStartWithDriveLetter(newPath)) 213 { 214 if (newPath.at(newPath.length() - 1) != delimiter) 215 newPath += delimiter; 216 return newPath; 217 } 211 218 if (newPath.at(0) != delimiter) 212 219 newPath.insert(0, delimiter); … … 216 223 /* static */ QString UIPathOperations::sanitize(const QString &path) 217 224 { 218 return addStartDelimiter(removeTrailingDelimiters(removeMultipleDelimiters(path))); 225 //return addStartDelimiter(removeTrailingDelimiters(removeMultipleDelimiters(path))); 226 QString newPath = addStartDelimiter(removeTrailingDelimiters(removeMultipleDelimiters(path))).replace(dosDelimiter, delimiter); 227 return newPath; 219 228 } 220 229 … … 270 279 { 271 280 QStringList pathList = path.split(UIPathOperations::delimiter, QString::SkipEmptyParts); 281 if (!pathList.isEmpty() && doesPathStartWithDriveLetter(pathList[0])) 282 { 283 pathList[0] = addTrailingDelimiters(pathList[0]); 284 } 272 285 return pathList; 286 } 287 288 /* static */ bool UIPathOperations::doesPathStartWithDriveLetter(const QString &path) 289 { 290 if (path.length() < 2) 291 return false; 292 /* search for ':' with the path: */ 293 if (!path[0].isLetter()) 294 return false; 295 if (path[1] != ':') 296 return false; 297 return true; 273 298 } 274 299 … … 545 570 , m_isTargetADirectory(false) 546 571 , m_type(type) 572 , m_isDriveItem(false) 547 573 { 548 574 } … … 693 719 { 694 720 m_isTargetADirectory = flag; 721 } 722 723 void UIFileTableItem::setIsDriveItem(bool flag) 724 { 725 m_isDriveItem = flag; 726 } 727 728 bool UIFileTableItem::isDriveItem() const 729 { 730 return m_isDriveItem; 695 731 } 696 732 … … 972 1008 if (m_pRootItem) 973 1009 reset(); 974 1010 determineDriveLetters(); 1011 /* Root item: */ 975 1012 const QString startPath("/"); 976 1013 QList<QVariant> headData; … … 983 1020 startItem->setPath(startPath); 984 1021 m_pRootItem->appendChild(startItem); 985 986 1022 startItem->setIsOpened(false); 987 /* Read the root directory and get the list: */ 988 readDirectory(startPath, startItem, true); 1023 if (m_driveLetterList.isEmpty()) 1024 { 1025 /* Read the root directory and get the list: */ 1026 readDirectory(startPath, startItem, true); 1027 } 1028 else 1029 { 1030 for (int i = 0; i < m_driveLetterList.size(); ++i) 1031 { 1032 QList<QVariant> data; 1033 1034 data << m_driveLetterList[i] << 4096 << QDateTime() << ""; 1035 UIFileTableItem* driveItem = new UIFileTableItem(data, startItem, FileObjectType_Directory); 1036 driveItem->setPath(m_driveLetterList[i]); 1037 startItem->appendChild(driveItem); 1038 driveItem->setIsOpened(false); 1039 driveItem->setIsDriveItem(true); 1040 startItem->setIsOpened(true); 1041 } 1042 } 989 1043 m_pView->setRootIndex(m_pModel->rootIndex()); 990 1044 m_pModel->signalUpdate(); … … 995 1049 UIFileTableItem *parent, bool isDirectoryMap, bool isStartDir) 996 1050 { 1051 if (parent) 1052 997 1053 /* Make sure we have a ".." item within directories, and make sure it is not there for the start dir: */ 998 1054 if (isDirectoryMap) … … 1244 1300 if (comboLocation == currentDirectoryPath()) 1245 1301 return; 1246 1247 QStringList pathList = comboLocation.split(UIPathOperations::delimiter, QString::SkipEmptyParts); 1248 goIntoDirectory(pathList); 1302 goIntoDirectory(UIPathOperations::pathTrail(comboLocation)); 1249 1303 } 1250 1304 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/guestctrl/UIGuestControlFileTable.h
r71792 r71832 147 147 static QString constructNewItemPath(const QString &previousPath, const QString &newBaseName); 148 148 /** Split the path and return it as a QStringList, top most being the 0th element. No delimiters */ 149 QStringList pathTrail(const QString &path);149 static QStringList pathTrail(const QString &path); 150 150 static const QChar delimiter; 151 static const QChar dosDelimiter; 152 153 /** Try to guess if the path starts with DOS style drive letters */ 154 static bool doesPathStartWithDriveLetter(const QString &path); 155 151 156 }; 152 157 … … 203 208 QString name() const; 204 209 210 void setIsDriveItem(bool flag); 211 bool isDriveItem() const; 212 205 213 private: 206 214 207 215 QList<UIFileTableItem*> m_childItems; 208 /** Used to find children by path*/216 /** Used to find children by name */ 209 217 QMap<QString, UIFileTableItem*> m_childMap; 210 218 /** It is required that m_itemData[0] is name (QString) of the file object */ … … 219 227 bool m_isTargetADirectory; 220 228 FileObjectType m_type; 221 229 /** True if only this item represents a DOS style drive letter item */ 230 bool m_isDriveItem; 222 231 }; 223 232 … … 267 276 virtual QString fsObjectPropertyString() = 0; 268 277 virtual void showProperties() = 0; 278 /** For non-windows system does nothing and for windows systems populates m_driveLetterList with 279 * drive letters */ 280 virtual void determineDriveLetters() = 0; 269 281 static QString fileTypeString(FileObjectType type); 270 282 void goIntoDirectory(const QModelIndex &itemIndex); … … 285 297 QAction *m_pPaste; 286 298 UIPropertiesDialog *m_pPropertiesDialog; 299 /** Stores the drive letters the file system has (for windows system). For non-windows 300 * systems this is empty and for windows system it should at least contain C:/ */ 301 QStringList m_driveLetterList; 287 302 288 303 protected slots: … … 336 351 QVector<QAction*> m_selectionDependentActions; 337 352 /** The absolue path list of the file objects which user has chosen to cut/copy. this 338 *list will be cleaned after a paste operation or overwritten by a subsequent cut/copy */353 * list will be cleaned after a paste operation or overwritten by a subsequent cut/copy */ 339 354 QStringList m_copyCutBuffer; 340 355 friend class UIGuestControlFileModel; -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/guestctrl/UIGuestFileTable.cpp
r71693 r71832 178 178 flag.push_back(KDirectoryOpenFlag_None); 179 179 180 directory = m_comGuestSession.DirectoryOpen( strPath, /*aFilter*/ "", flag);180 directory = m_comGuestSession.DirectoryOpen(UIPathOperations::sanitize(strPath), /*aFilter*/ "", flag); 181 181 if (!m_comGuestSession.isOk()) 182 182 { … … 204 204 continue; 205 205 item->setPath(UIPathOperations::mergePaths(strPath, fsInfo.GetName())); 206 207 206 if (fsObjectType == FileObjectType_Directory) 208 207 { … … 269 268 } 270 269 QStringList pathList = userHome.split(UIPathOperations::delimiter, QString::SkipEmptyParts); 271 goIntoDirectory( pathList);270 goIntoDirectory(UIPathOperations::pathTrail(userHome)); 272 271 } 273 272 … … 555 554 } 556 555 556 void UIGuestFileTable::determineDriveLetters() 557 { 558 if (m_comGuestSession.isNull()) 559 return; 560 KPathStyle pathStyle = m_comGuestSession.GetPathStyle(); 561 if (pathStyle != KPathStyle_DOS) 562 return; 563 564 /** @todo Currently API lacks a way to query windows drive letters. 565 * so we enumarate them by using CGuestSession::DirectoryExists() */ 566 for (int i = 'A'; i <= 'Z'; ++i) 567 { 568 QString path((char)i); 569 path += ":/"; 570 bool exists = m_comGuestSession.DirectoryExists(path, false /* aFollowSymlinks */); 571 if (exists) 572 m_driveLetterList.push_back(path); 573 } 574 } 575 557 576 #include "UIGuestFileTable.moc" 558 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/guestctrl/UIGuestFileTable.h
r71654 r71832 49 49 virtual QString fsObjectPropertyString() /* override */; 50 50 virtual void showProperties() /* override */; 51 virtual void determineDriveLetters() /* override */; 51 52 52 53 private: … … 63 64 64 65 #endif /* !___UIGuestControlFileTable_h___ */ 65 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/guestctrl/UIHostFileTable.cpp
r71693 r71832 227 227 228 228 QString userHome = UIPathOperations::sanitize(QDir::homePath()); 229 QStringList pathList = userHome.split(UIPathOperations::delimiter, QString::SkipEmptyParts); 230 goIntoDirectory(pathList); 229 goIntoDirectory(UIPathOperations::pathTrail(userHome)); 231 230 } 232 231 … … 382 381 } 383 382 383 void UIHostFileTable::determineDriveLetters() 384 { 385 } 386 384 387 #include "UIHostFileTable.moc" 385 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/guestctrl/UIHostFileTable.h
r71639 r71832 43 43 virtual QString fsObjectPropertyString() /* override */; 44 44 virtual void showProperties() /* override */; 45 virtual void determineDriveLetters() /* override */; 45 46 46 47 private: … … 50 51 51 52 #endif /* !___UIGuestControlFileTable_h___ */ 52
Note:
See TracChangeset
for help on using the changeset viewer.