- Timestamp:
- Nov 20, 2018 11:14:35 AM (6 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/guestctrl
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIGuestControlFileManager.cpp
r75480 r75610 284 284 { 285 285 m_pOperationsPanel->hide(); 286 connect(m_pOperationsPanel, &UIGuestControlFileManagerOperationsPanel::sigFileOperationComplete, 287 this, &UIGuestControlFileManager::sltFileOperationComplete); 286 288 m_panelActionMap.insert(m_pOperationsPanel, m_pActionPool->action(UIActionIndex_M_GuestControlFileManager_T_FileOperations)); 287 289 } … … 465 467 void UIGuestControlFileManager::sltCopyGuestToHost() 466 468 { 467 if (!m_pGuestFileTable || !m_pHostFileTable) 468 return; 469 QString hostDestinationPath = m_pHostFileTable->currentDirectoryPath(); 470 m_pGuestFileTable->copyGuestToHost(hostDestinationPath); 471 m_pHostFileTable->refresh(); 469 copyMoveToHost(false); 472 470 } 473 471 474 472 void UIGuestControlFileManager::sltCopyHostToGuest() 475 473 { 476 if (!m_pGuestFileTable || !m_pHostFileTable) 477 return; 478 QStringList hostSourcePathList = m_pHostFileTable->selectedItemPathList(); 479 m_pGuestFileTable->copyHostToGuest(hostSourcePathList); 480 m_pGuestFileTable->refresh(); 474 copyMoveToGuest(false); 475 } 476 477 void UIGuestControlFileManager::sltMoveGuestToHost() 478 { 479 copyMoveToHost(true); 480 } 481 482 void UIGuestControlFileManager::sltMoveHostToGuest() 483 { 484 copyMoveToGuest(true); 481 485 } 482 486 … … 514 518 if (m_pOperationsPanel) 515 519 m_pOperationsPanel->addNewProgress(comProgress); 520 } 521 522 void UIGuestControlFileManager::sltFileOperationComplete(QUuid progressId) 523 { 524 if (m_pGuestFileTable) 525 { 526 m_pGuestFileTable->refresh(); 527 /* The following call deletes file objects whose paths have been cached for later deletion: */ 528 m_pGuestFileTable->continueWithMove(progressId); 529 } 530 531 if (m_pHostFileTable) 532 { 533 m_pHostFileTable->refresh(); 534 } 535 } 536 537 void UIGuestControlFileManager::copyMoveToHost(bool fIsMove) 538 { 539 if (!m_pGuestFileTable || !m_pHostFileTable) 540 return; 541 QString hostDestinationPath = m_pHostFileTable->currentDirectoryPath(); 542 m_pGuestFileTable->copyGuestToHost(hostDestinationPath, fIsMove); 543 m_pHostFileTable->refresh(); 544 } 545 546 void UIGuestControlFileManager::copyMoveToGuest(bool fIsMove) 547 { 548 if (!m_pGuestFileTable || !m_pHostFileTable) 549 return; 550 QStringList hostSourcePathList = m_pHostFileTable->selectedItemPathList(); 551 m_pGuestFileTable->copyHostToGuest(hostSourcePathList, fIsMove); 552 m_pGuestFileTable->refresh(); 516 553 } 517 554 … … 683 720 iterator.value()->setChecked(false); 684 721 } 685 m_visiblePanelsList.remove One(panel);722 m_visiblePanelsList.removeAll(panel); 686 723 manageEscapeShortCut(); 687 724 } … … 697 734 iterator.value()->setChecked(true); 698 735 } 699 m_visiblePanelsList.push_back(panel); 736 if (!m_visiblePanelsList.contains(panel)) 737 m_visiblePanelsList.push_back(panel); 700 738 manageEscapeShortCut(); 701 739 } -
trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIGuestControlFileManager.h
r75480 r75610 110 110 void sltCopyGuestToHost(); 111 111 void sltCopyHostToGuest(); 112 void sltMoveGuestToHost(); 113 void sltMoveHostToGuest(); 112 114 void sltPanelActionToggled(bool fChecked); 113 115 void sltListDirectoriesBeforeChanged(); 114 116 void sltReceieveNewFileOperation(const CProgress &comProgress); 117 void sltFileOperationComplete(QUuid progressId); 115 118 116 119 private: … … 149 152 - assigned it to the most recently "unhidden" panel */ 150 153 void manageEscapeShortCut(); 151 154 void copyMoveToGuest(bool fIsMove); 155 void copyMoveToHost(bool fIsMove); 152 156 template<typename T> 153 157 QStringList getFsObjInfoStringList(const T &fsObjectInfo) const; 154 158 void appendLog(const QString &strLog, FileManagerLogType eLogType); 159 155 160 CGuest m_comGuest; 156 161 CGuestSession m_comGuestSession; -
trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIGuestControlFileManagerOperationsPanel.cpp
r75518 r75610 55 55 ~UIFileOperationProgressWidget(); 56 56 57 signals: 58 59 void sigProgressTaskComplete(QUuid progressId); 60 57 61 protected: 58 62 … … 121 125 if (m_pCancelButton) 122 126 { 123 m_pCancelButton->setIcon(UIIconPool::iconSet(":/close_16px.png")); 124 127 //m_pCancelButton->setIcon(UIIconPool::iconSet(":/close_16px.png")); 128 m_pCancelButton->setIcon(QApplication::style()->standardIcon(QStyle::SP_DockWidgetCloseButton)); 129 //m_pCancelButton->setStyleSheet("QToolButton { border: 0px none black; margin: 0px 0px 0px 0px; } QToolButton::menu-indicator {image: none;}"); 130 m_pCancelButton->setStyleSheet("QToolButton { border: 0px none black; margin: 0px 0px 0px 0px; } "); 125 131 const QSize sh = m_pCancelButton->sizeHint(); 126 m_pCancelButton->setStyleSheet("QToolButton { border: 0px none black; margin: 0px 0px 0px 0px; } QToolButton::menu-indicator {image: none;}");127 132 m_pCancelButton->setFixedSize(sh); 133 128 134 connect(m_pCancelButton, &QIToolButton::clicked, this, &UIFileOperationProgressWidget::sltCancelProgress); 129 if (!m_comProgress. GetCancelable())135 if (!m_comProgress.isNull() && !m_comProgress.GetCancelable()) 130 136 m_pCancelButton->setEnabled(false); 131 m_pMainLayout->addWidget(m_pCancelButton , 0, Qt::AlignLeft | Qt::AlignTop);137 m_pMainLayout->addWidget(m_pCancelButton); 132 138 } 133 139 … … 147 153 void UIFileOperationProgressWidget::prepareEventHandler() 148 154 { 155 if (m_comProgress.isNull()) 156 return; 149 157 m_pEventHandler = new UIProgressEventHandler(this, m_comProgress); 150 158 connect(m_pEventHandler, &UIProgressEventHandler::sigProgressPercentageChange, … … 172 180 if (m_pCancelButton) 173 181 m_pCancelButton->setEnabled(false); 182 emit sigProgressTaskComplete(m_comProgress.GetId()); 174 183 } 175 184 … … 191 200 : UIGuestControlFileManagerPanel(pManagerWidget, pParent) 192 201 , m_pTableWidget(0) 193 , m_pOperationsWidget(0)194 202 { 195 203 prepare(); … … 202 210 203 211 m_pTableWidget->setRowCount(m_pTableWidget->rowCount() + 1); 204 m_pTableWidget->setCellWidget(m_pTableWidget->rowCount() - 1, 0, new UIFileOperationProgressWidget(comProgress)); 212 UIFileOperationProgressWidget *pOperationsWidget = new UIFileOperationProgressWidget(comProgress); 213 m_pTableWidget->setCellWidget(m_pTableWidget->rowCount() - 1, 0, pOperationsWidget); 214 connect(pOperationsWidget, &UIFileOperationProgressWidget::sigProgressTaskComplete, 215 this, &UIGuestControlFileManagerOperationsPanel::sigFileOperationComplete); 216 205 217 m_pTableWidget->resizeColumnsToContents(); 206 218 } … … 231 243 void UIGuestControlFileManagerOperationsPanel::prepareConnections() 232 244 { 245 233 246 } 234 247 -
trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIGuestControlFileManagerOperationsPanel.h
r75480 r75610 19 19 #define ___UIGuestControlFileManagerOperationsPanel_h___ 20 20 21 /* Qt includes: */ 22 # include <QUuid> 23 21 24 /* GUI includes: */ 22 25 #include "UIGuestControlDefs.h" … … 35 38 { 36 39 Q_OBJECT; 40 41 signals: 42 43 void sigFileOperationComplete(QUuid progressId); 37 44 38 45 public: … … 68 75 * @{ */ 69 76 QTableWidget *m_pTableWidget; 70 UIFileOperationProgressWidget *m_pOperationsWidget;71 77 /** @} */ 72 78 -
trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIGuestControlFileTable.cpp
r75480 r75610 1360 1360 } 1361 1361 1362 void UIGuestControlFileTable::continueWithMove(const QUuid &progressId) 1363 { 1364 QStringList sourcePathList = m_deleteAfterCopyCache.value(progressId); 1365 deleteByPath(m_deleteAfterCopyCache.value(progressId, QStringList())); 1366 } 1367 1362 1368 void UIGuestControlFileTable::sltReceiveDirectoryStatistics(UIDirectoryStatistics statistics) 1363 1369 { -
trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIGuestControlFileTable.h
r75480 r75610 262 262 static const unsigned m_iKiloByte; 263 263 static QString humanReadableSize(ULONG64 size); 264 /** Deletes the file objects whose stored in the m_pDeleteAfterCopyCache */ 265 void continueWithMove(const QUuid &progressId); 264 266 265 267 public slots: … … 293 295 virtual void readDirectory(const QString& strPath, UIFileTableItem *parent, bool isStartDir = false) = 0; 294 296 virtual void deleteByItem(UIFileTableItem *item) = 0; 297 virtual void deleteByPath(const QStringList &pathList) = 0; 295 298 virtual void goToHomeDirectory() = 0; 296 299 virtual bool renameItem(UIFileTableItem *item, QString newBaseName) = 0; … … 329 332 /** The set of actions which need some selection to work on. Like cut, copy etc. */ 330 333 QSet<QAction*> m_selectionDependentActions; 334 /** Paths of the source file objects are stored in this map to delete those 335 * after the copy progress completed notification is receieved */ 336 QMap<QUuid, QStringList> m_deleteAfterCopyCache; 331 337 332 338 private slots: -
trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIGuestFileTable.cpp
r75517 r75610 23 23 # include <QDateTime> 24 24 # include <QFileInfo> 25 # include <QUuid> 25 26 26 27 /* GUI includes: */ … … 228 229 insertItemsToTree(directories, parent, true, isStartDir); 229 230 insertItemsToTree(files, parent, false, isStartDir); 230 //updateCurrentLocationEdit(strPath);231 231 } 232 232 directory.Close(); … … 251 251 emit sigLogOutput(QString(item->path()).append(" could not be deleted"), FileManagerLogType_Error); 252 252 emit sigLogOutput(UIErrorString::formatErrorInfo(m_comGuestSession), FileManagerLogType_Error); 253 } 254 } 255 256 void UIGuestFileTable::deleteByPath(const QStringList &pathList) 257 { 258 foreach (const QString &strPath, pathList) 259 { 260 CGuestFsObjInfo fileInfo = m_comGuestSession.FsObjQueryInfo(strPath, true); 261 FileObjectType eType = fileType(fileInfo); 262 if (eType == FileObjectType_File || eType == FileObjectType_SymLink) 263 { 264 m_comGuestSession.FsObjRemove(strPath); 265 } 266 else if (eType == FileObjectType_Directory) 267 { 268 QVector<KDirectoryRemoveRecFlag> flags(KDirectoryRemoveRecFlag_ContentAndDir); 269 m_comGuestSession.DirectoryRemoveRecursive(strPath, flags); 270 } 271 253 272 } 254 273 } … … 310 329 } 311 330 312 void UIGuestFileTable::copyHostToGuest(const QStringList &hostSourcePathList )331 void UIGuestFileTable::copyHostToGuest(const QStringList &hostSourcePathList, bool fDeleteAfterSuccessfulCopy /* = false */) 313 332 { 314 333 QVector<QString> sourcePaths = hostSourcePathList.toVector(); … … 334 353 } 335 354 emit sigNewFileOperation(progress); 336 refresh(); 337 } 338 339 void UIGuestFileTable::copyGuestToHost(const QString& hostDestinationPath) 355 /* Cache the progress id and host source file objects' path in case of move operation. we will delete 356 * these when/if we receieve progress completed notification: */ 357 if (fDeleteAfterSuccessfulCopy) 358 emit sigCacheHostFileObjectsForDeletion(progress.GetId(), sourcePaths.toList()); 359 } 360 361 void UIGuestFileTable::copyGuestToHost(const QString& hostDestinationPath, bool fDeleteAfterSuccessfulCopy /* = false */) 340 362 { 341 363 QVector<QString> sourcePaths = selectedItemPathList().toVector(); … … 361 383 } 362 384 emit sigNewFileOperation(progress); 363 refresh(); 385 /* Cache the progress id and source file objects' path in case of move operation. we will delete 386 * these when/if we receieve progress completed notification: */ 387 if (fDeleteAfterSuccessfulCopy) 388 m_deleteAfterCopyCache[progress.GetId()] = sourcePaths.toList(); 364 389 } 365 390 -
trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIGuestFileTable.h
r75425 r75610 18 18 #ifndef ___UIGuestTable_h___ 19 19 #define ___UIGuestTable_h___ 20 21 /* Qt includes: */ 22 # include <QUuid> 20 23 21 24 /* COM includes: */ … … 39 42 UIGuestFileTable(UIActionPool *pActionPool, QWidget *pParent = 0); 40 43 void initGuestFileTable(const CGuestSession &session); 41 void copyGuestToHost(const QString& hostDestinationPath );42 void copyHostToGuest(const QStringList &hostSourcePathList );44 void copyGuestToHost(const QString& hostDestinationPath, bool fDeleteAfterSuccessfulCopy = false); 45 void copyHostToGuest(const QStringList &hostSourcePathList, bool fDeleteAfterSuccessfulCopy = false); 43 46 44 47 signals: 45 48 46 49 void sigNewFileOperation(const CProgress &comProgress); 50 void sigCacheHostFileObjectsForDeletion(const QUuid &moveProgessId, const QStringList &hostPathList); 47 51 48 52 protected: … … 51 55 virtual void readDirectory(const QString& strPath, UIFileTableItem *parent, bool isStartDir = false) /* override */; 52 56 virtual void deleteByItem(UIFileTableItem *item) /* override */; 57 virtual void deleteByPath(const QStringList &pathList) /* override */; 53 58 virtual void goToHomeDirectory() /* override */; 54 59 virtual bool renameItem(UIFileTableItem *item, QString newBaseName); … … 67 72 void prepareActionConnections(); 68 73 69 mutable CGuestSession m_comGuestSession; 70 74 mutable CGuestSession m_comGuestSession; 71 75 }; 72 76 -
trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIHostFileTable.cpp
r75480 r75610 132 132 prepareActionConnections(); 133 133 retranslateUi(); 134 } 135 136 void UIHostFileTable::setDeleteAfterCopyCache(const QUuid &progressId, const QStringList &sourceObjectsList) 137 { 138 m_deleteAfterCopyCache[progressId] = sourceObjectsList; 134 139 } 135 140 … … 257 262 if (!item->isDirectory()) 258 263 { 259 QDir itemToDelete; //(item->path());264 QDir itemToDelete; 260 265 itemToDelete.remove(item->path()); 261 266 } … … 271 276 if (!deleteSuccess) 272 277 emit sigLogOutput(QString(item->path()).append(" could not be deleted"), FileManagerLogType_Error); 278 } 279 280 void UIHostFileTable::deleteByPath(const QStringList &pathList) 281 { 282 foreach (const QString &strPath, pathList) 283 { 284 bool deleteSuccess = true; 285 FileObjectType eType = fileType(QFileInfo(strPath)); 286 if (eType == FileObjectType_File || eType == FileObjectType_SymLink) 287 { 288 deleteSuccess = QDir().remove(strPath); 289 } 290 else if (eType == FileObjectType_Directory) 291 { 292 QDir itemToDelete(strPath); 293 itemToDelete.setFilter(QDir::NoDotAndDotDot); 294 deleteSuccess = itemToDelete.removeRecursively(); 295 } 296 if (!deleteSuccess) 297 emit sigLogOutput(QString(strPath).append(" could not be deleted"), FileManagerLogType_Error); 298 } 273 299 } 274 300 -
trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIHostFileTable.h
r75425 r75610 34 34 35 35 UIHostFileTable(UIActionPool *pActionPool, QWidget *pParent = 0); 36 void setDeleteAfterCopyCache(const QUuid &progressId, const QStringList &sourceObjectsList); 36 37 37 38 protected: … … 41 42 virtual void readDirectory(const QString& strPath, UIFileTableItem *parent, bool isStartDir = false) /* override */; 42 43 virtual void deleteByItem(UIFileTableItem *item) /* override */; 44 virtual void deleteByPath(const QStringList &pathList) /* override */; 43 45 virtual void goToHomeDirectory() /* override */; 44 46 virtual bool renameItem(UIFileTableItem *item, QString newBaseName);
Note:
See TracChangeset
for help on using the changeset viewer.