Changeset 71325 in vbox
- Timestamp:
- Mar 14, 2018 2:21:14 PM (7 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/runtime/guestctrl
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/runtime/guestctrl/UIGuestControlFileManager.cpp
r71310 r71325 190 190 if (m_pCloseButton) 191 191 m_pCloseButton->setText(UIVMInformationDialog::tr("Close Session")); 192 193 192 } 194 193 … … 361 360 m_pToolBar->addWidget(bottomSpacerWidget); 362 361 363 364 362 containerLayout->addWidget(m_pToolBar); 365 363 } … … 486 484 return; 487 485 QString hostDestinationPath = m_pHostFileTable->currentDirectoryPath(); 488 printf("current host path %s\n", hostDestinationPath.toStdString().c_str());489 486 m_pGuestFileTable->copyGuestToHost(hostDestinationPath); 487 m_pHostFileTable->refresh(); 490 488 } 491 489 … … 495 493 return; 496 494 QStringList hostSourcePathList = m_pHostFileTable->selectedItemPathList(); 497 for(int i = 0; i < hostSourcePathList.size(); ++i)498 printf("%s\n", hostSourcePathList[i].toStdString().c_str());499 495 m_pGuestFileTable->copyHostToGuest(hostSourcePathList); 496 m_pGuestFileTable->refresh(); 500 497 } 501 498 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/guestctrl/UIGuestControlFileTable.cpp
r71298 r71325 56 56 static QString removeTrailingDelimiters(const QString &path); 57 57 static QString addStartDelimiter(const QString &path); 58 static QString removeAllDelimiters(const QString &path); 59 60 // static QString removeTrailingDelimiters(const QString &path); 58 61 59 static QString sanitize(const QString &path); 62 60 /** Merge prefix and suffix by making sure they have a single '/' in between */ … … 356 354 , m_pModel(0) 357 355 , m_pLocationLabel(0) 358 , m_pGoHome(0)359 356 , m_pMainLayout(0) 360 357 , m_pCurrentLocationEdit(0) 361 358 , m_pToolBar(0) 362 359 , m_pGoUp(0) 360 , m_pGoHome(0) 363 361 , m_pRefresh(0) 364 362 , m_pDelete(0) … … 511 509 m_pCopy->setIcon(UIIconPool::iconSet(QString(":/fd_copy_22px.png"))); 512 510 m_pToolBar->addAction(m_pCopy); 513 m_pCopy->setEnabled(false);511 //m_pCopy->setEnabled(false); 514 512 } 515 513 … … 655 653 } 656 654 657 void UIGuestControlFileTable::goIntoDirectory(const Q Vector<QString> &pathTrail)655 void UIGuestControlFileTable::goIntoDirectory(const QList<QString> &pathTrail) 658 656 { 659 657 UIFileTableItem *parent = getStartDirectoryItem(); … … 766 764 sltRefresh(); 767 765 } 768 769 } 770 766 } 771 767 772 768 void UIGuestControlFileTable::deleteByIndex(const QModelIndex &itemIndex) … … 928 924 } 929 925 926 CGuestFsObjInfo UIGuestControlFileTable::guestFsObjectInfo(const QString& path, CGuestSession &comGuestSession) const 927 { 928 if (comGuestSession.isNull()) 929 return CGuestFsObjInfo(); 930 CGuestFsObjInfo comFsObjInfo = comGuestSession.FsObjQueryInfo(path, true /*aFollowSymlinks*/); 931 if (!comFsObjInfo.isOk()) 932 return CGuestFsObjInfo(); 933 return comFsObjInfo; 934 } 935 930 936 931 937 /********************************************************************************************************************************* … … 936 942 :UIGuestControlFileTable(pParent) 937 943 { 938 configureObjects();939 944 retranslateUi(); 940 945 } … … 1029 1034 void UIGuestFileTable::goToHomeDirectory() 1030 1035 { 1031 /** @todo not implemented in guest control yet: */ 1036 if (m_comGuestSession.isNull()) 1037 return; 1038 if (!m_pRootItem || m_pRootItem->childCount() <= 0) 1039 return; 1040 UIFileTableItem *startDirItem = m_pRootItem->child(0); 1041 if (!startDirItem) 1042 return; 1043 1044 QString userHome = UIPathOperations::sanitize(m_comGuestSession.GetUserHome()); 1045 QList<QString> pathTrail = userHome.split(UIPathOperations::delimiter); 1046 1047 goIntoDirectory(pathTrail); 1032 1048 } 1033 1049 … … 1047 1063 } 1048 1064 1049 void UIGuestFileTable::configureObjects()1050 {1051 if (m_pGoHome)1052 m_pGoHome->setEnabled(false);1053 }1054 1055 1065 bool UIGuestFileTable::createDirectory(const QString &path, const QString &directoryName) 1056 1066 { … … 1090 1100 1091 1101 /* Currently API expects a path including a file name for file copy*/ 1092 KFsObjType objectType = fsObjectType(guestSourcePath); 1102 CGuestFsObjInfo fileInfo = guestFsObjectInfo(guestSourcePath, m_comGuestSession); 1103 KFsObjType objectType = fileInfo.GetType(); 1093 1104 if (objectType == KFsObjType_File) 1094 1105 { 1095 // QString destinatioFilePath = mergePaths(hostDestinationPath, const QString &Path, const QString &baseName); 1096 1097 } 1098 1099 QVector<KDirectoryCopyFlag> aFlags(KDirectoryCopyFlag_CopyIntoExisting); 1100 /** @todo listen to CProgress object to monitor copy operation: */ 1101 /*CProgress comProgress = */m_comGuestSession.DirectoryCopyFromGuest(guestSourcePath, hostDestinationPath, aFlags); 1106 QVector<KFileCopyFlag> flags(KFileCopyFlag_FollowLinks); 1107 /* API expects a full file path as destionation: */ 1108 QString destinatioFilePath = UIPathOperations::mergePaths(hostDestinationPath, UIPathOperations::getObjectName(guestSourcePath)); 1109 /** @todo listen to CProgress object to monitor copy operation: */ 1110 /*CProgress comProgress =*/ m_comGuestSession.FileCopyFromGuest(guestSourcePath, destinatioFilePath, flags); 1111 1112 } 1113 else if (objectType == KFsObjType_Directory) 1114 { 1115 QVector<KDirectoryCopyFlag> aFlags(KDirectoryCopyFlag_CopyIntoExisting); 1116 /** @todo listen to CProgress object to monitor copy operation: */ 1117 /*CProgress comProgress = */ m_comGuestSession.DirectoryCopyFromGuest(guestSourcePath, hostDestinationPath, aFlags); 1118 } 1102 1119 if (!m_comGuestSession.isOk()) 1103 1120 return false; … … 1109 1126 if (m_comGuestSession.isNull()) 1110 1127 return false; 1111 QVector<KDirectoryCopyFlag> aFlags(KDirectoryCopyFlag_CopyIntoExisting); 1112 /** @todo listen to CProgress object to monitor copy operation: */ 1113 /*CProgress comProgress = */m_comGuestSession.DirectoryCopyToGuest(hostSourcePath, guestDestinationPath, aFlags); 1128 QFileInfo hostFileInfo(hostSourcePath); 1129 if (!hostFileInfo.exists()) 1130 return false; 1131 1132 /* Currently API expects a path including a file name for file copy*/ 1133 if (hostFileInfo.isFile() || hostFileInfo.isSymLink()) 1134 { 1135 } 1136 else if(hostFileInfo.isDir()) 1137 { 1138 } 1139 // { 1140 // QVector<KFileCopyFlag> flags(KFileCopyFlag_FollowLinks); 1141 // /* API expects a full file path as destionation: */ 1142 // QString destinatioFilePath = UIPathOperations::mergePaths(guestDestinationPath, 1143 // UIPathOperations::getObjectName(hostSourcePath)); 1144 // /** @todo listen to CProgress object to monitor copy operation: */ 1145 // /*CProgress comProgress =*/ m_comGuestSession.FileCopyToGuest(hostSourcePath, destinatioFilePath, flags); 1146 1147 // } 1148 // else if (objectType == KFsObjType_Directory) 1149 // { 1150 // QVector<KDirectoryCopyFlag> aFlags(KDirectoryCopyFlag_CopyIntoExisting); 1151 // /** @todo listen to CProgress object to monitor copy operation: */ 1152 // /*CProgress comProgress = */ m_comGuestSession.DirectoryCopyToGuest(hostSourcePath, guestDestinationPath, aFlags); 1153 // } 1154 // if (!m_comGuestSession.isOk()) 1155 // return false; 1114 1156 return true; 1115 }1116 1117 KFsObjType UIGuestFileTable::fsObjectType(const QString& path)1118 {1119 if (m_comGuestSession.isNull())1120 return KFsObjType_Unknown;1121 CGuestFsObjInfo comFsObjInfo = m_comGuestSession.FsObjQueryInfo(path, false /*aFollowSymlinks*/);1122 if (!comFsObjInfo.isOk() || m_comGuestSession.isOk())1123 return KFsObjType_Unknown;1124 return comFsObjInfo.GetType();1125 1157 } 1126 1158 … … 1212 1244 // UIFileTableItem *rootDirectoryItem 1213 1245 QDir homeDirectory(QDir::homePath()); 1214 Q Vector<QString> pathTrail;//(QDir::rootPath());1246 QList<QString> pathTrail;//(QDir::rootPath()); 1215 1247 do{ 1216 1248 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/guestctrl/UIGuestControlFileTable.h
r71298 r71325 110 110 /** Returns the paths of the selected items (if any) as a list */ 111 111 QStringList selectedItemPathList(); 112 virtual void refresh(); 112 113 113 114 protected: … … 120 121 bool isDirectoryMap, bool isStartDir); 121 122 virtual void readDirectory(const QString& strPath, UIFileTableItem *parent, bool isStartDir = false) = 0; 122 virtual void refresh();123 123 virtual void deleteByItem(UIFileTableItem *item) = 0; 124 124 virtual void goToHomeDirectory() = 0; … … 127 127 void goIntoDirectory(const QModelIndex &itemIndex); 128 128 /** Follow the path trail, open directories as we go and descend */ 129 void goIntoDirectory(const Q Vector<QString> &pathTrail);129 void goIntoDirectory(const QList<QString> &pathTrail); 130 130 /** Go into directory pointed by the @p item */ 131 131 void goIntoDirectory(UIFileTableItem *item); 132 132 UIFileTableItem* indexData(const QModelIndex &index) const; 133 133 void keyPressEvent(QKeyEvent * pEvent); 134 134 CGuestFsObjInfo guestFsObjectInfo(const QString& path, CGuestSession &comGuestSession) const; 135 135 136 136 … … 143 143 UIGuestControlFileModel *m_pModel; 144 144 QILabel *m_pLocationLabel; 145 QAction *m_pGoHome;146 145 147 146 protected slots: … … 168 167 UIToolBar *m_pToolBar; 169 168 QAction *m_pGoUp; 170 169 QAction *m_pGoHome; 171 170 QAction *m_pRefresh; 172 171 QAction *m_pDelete; 173 172 QAction *m_pRename; 174 173 QAction *m_pCreateNewDirectory; 174 175 175 176 176 QAction *m_pCopy; … … 205 205 private: 206 206 207 KFsObjType fsObjectType(const QString& path);208 207 bool copyGuestToHost(const QString &guestSourcePath, const QString& hostDestinationPath); 209 208 bool copyHostToGuest(const QString& hostSourcePath, const QString &guestDestinationPath); 210 209 211 void configureObjects(); 212 CGuestSession m_comGuestSession; 210 mutable CGuestSession m_comGuestSession; 213 211 214 212 };
Note:
See TracChangeset
for help on using the changeset viewer.