Changeset 71208 in vbox
- Timestamp:
- Mar 5, 2018 5:39:39 PM (7 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/guestctrl
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/guestctrl/UIGuestControlFileManager.cpp
r71201 r71208 424 424 { 425 425 m_pLogOutput->appendPlainText("Guest session is not valid"); 426 postSessionClosed(); 426 427 return; 427 428 } … … 439 440 void UIGuestControlFileManager::sltGuestSessionStateChanged(const CGuestSessionStateChangedEvent &cEvent) 440 441 { 441 if (cEvent.isOk() && m_comGuestSession.isOk()) // && m_comGuestProcess.GetStatus() == KProcessStatus_Error)442 if (cEvent.isOk() && m_comGuestSession.isOk()) 442 443 { 443 444 CVirtualBoxErrorInfo cErrorInfo = cEvent.GetError(); 444 if (cErrorInfo.isOk()) // && cErrorInfo.GetResultCode() != S_OK)445 if (cErrorInfo.isOk()) 445 446 { 446 447 m_pLogOutput->appendPlainText(cErrorInfo.GetText()); … … 520 521 connect(m_pQtSessionListener->getWrapped(), &UIMainEventListener::sigGuestSessionStatedChanged, 521 522 this, &UIGuestControlFileManager::sltGuestSessionStateChanged); 522 // /* Wait session to start: */ 523 // const ULONG waitTimeout = 2000; 524 // KGuestSessionWaitResult waitResult = guestSession.WaitFor(KGuestSessionWaitForFlag_Start, waitTimeout); 525 // if (waitResult != KGuestSessionWaitResult_Start) 526 // return false; 527 528 // outSession = guestSession; 523 /* Wait session to start. For some reason we cannot get GuestSessionStatusChanged event 524 consistently. So we wait: */ 525 m_pLogOutput->appendPlainText("Waiting the session to start"); 526 const ULONG waitTimeout = 2000; 527 KGuestSessionWaitResult waitResult = m_comGuestSession.WaitFor(KGuestSessionWaitForFlag_Start, waitTimeout); 528 if (waitResult != KGuestSessionWaitResult_Start) 529 { 530 m_pLogOutput->appendPlainText("The session did not start"); 531 sltCloseSession(); 532 return false; 533 } 529 534 530 535 return true; -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/guestctrl/UIGuestControlFileTable.cpp
r71201 r71208 38 38 # include "CFsObjInfo.h" 39 39 # include "CGuestDirectory.h" 40 # include "CProgress.h" 40 41 41 42 #endif /* !VBOX_WITH_PRECOMPILED_HEADERS */ … … 477 478 478 479 m_pDelete = new QAction(this); 479 m_pDelete->setIcon(UIIconPool::iconSet(QString(":/vm_delete_32px.png"))); 480 m_pToolBar->addAction(m_pDelete); 480 if (m_pDelete) 481 { 482 connect(m_pDelete, &QAction::triggered, this, &UIGuestControlFileTable::sltDelete); 483 m_pDelete->setIcon(UIIconPool::iconSet(QString(":/vm_delete_32px.png"))); 484 m_pToolBar->addAction(m_pDelete); 485 } 481 486 482 487 m_pNewFolder = new QAction(this); … … 612 617 void UIGuestControlFileTable::sltRefresh() 613 618 { 619 refresh(); 620 } 621 622 void UIGuestControlFileTable::refresh() 623 { 614 624 if (!m_pView || !m_pModel) 615 625 return; … … 621 631 if (!treeItem) 622 632 return; 633 bool isRootDir = (m_pModel->rootIndex() == currentIndex); 623 634 m_pModel->beginReset(); 624 635 /* For now we clear the whole subtree (that isrecursively) which is an overkill: */ 625 636 treeItem->clearChildren(); 626 readDirectory(treeItem->path(), treeItem, false);637 readDirectory(treeItem->path(), treeItem, isRootDir); 627 638 m_pModel->endReset(); 628 639 m_pView->setRootIndex(currentIndex); 629 640 } 630 641 642 void UIGuestControlFileTable::sltDelete() 643 { 644 if (!m_pView || !m_pModel) 645 return; 646 QItemSelectionModel *selectionModel = m_pView->selectionModel(); 647 if (!selectionModel) 648 return; 649 650 QModelIndexList selectedItemIndices = selectionModel->selectedIndexes(); 651 for(int i = 0; i < selectedItemIndices.size(); ++i) 652 { 653 deleteByIndex(selectedItemIndices.at(i)); 654 } 655 refresh(); 656 } 657 658 void UIGuestControlFileTable::deleteByIndex(const QModelIndex &itemIndex) 659 { 660 if (!itemIndex.isValid()) 661 return; 662 UIFileTableItem *treeItem = static_cast<UIFileTableItem*>(itemIndex.internalPointer()); 663 if (!treeItem) 664 return; 665 deleteByItem(treeItem); 666 } 631 667 632 668 void UIGuestControlFileTable::retranslateUi() … … 641 677 { 642 678 m_pDelete->setText(UIVMInformationDialog::tr("Delete")); 643 m_pDelete->setToolTip(UIVMInformationDialog::tr("Delete the selected item "));644 m_pDelete->setStatusTip(UIVMInformationDialog::tr("Delete the selected item "));679 m_pDelete->setToolTip(UIVMInformationDialog::tr("Delete the selected item(s)")); 680 m_pDelete->setStatusTip(UIVMInformationDialog::tr("Delete the selected item(s)")); 645 681 } 646 682 … … 663 699 { 664 700 m_pCopy->setText(UIVMInformationDialog::tr("Copy the selected item")); 665 m_pCopy->setToolTip(UIVMInformationDialog::tr("Copy the selected item "));666 m_pCopy->setStatusTip(UIVMInformationDialog::tr("Copy the selected item "));701 m_pCopy->setToolTip(UIVMInformationDialog::tr("Copy the selected item(s)")); 702 m_pCopy->setStatusTip(UIVMInformationDialog::tr("Copy the selected item(s)")); 667 703 668 704 } … … 670 706 if (m_pCut) 671 707 { 672 m_pCut->setText(UIVMInformationDialog::tr("Cut the selected item "));673 m_pCut->setToolTip(UIVMInformationDialog::tr("Cut the selected item "));674 m_pCut->setStatusTip(UIVMInformationDialog::tr("Cut the selected item "));708 m_pCut->setText(UIVMInformationDialog::tr("Cut the selected item(s)")); 709 m_pCut->setToolTip(UIVMInformationDialog::tr("Cut the selected item(s)")); 710 m_pCut->setStatusTip(UIVMInformationDialog::tr("Cut the selected item(s)")); 675 711 676 712 } … … 678 714 if ( m_pPaste) 679 715 { 680 m_pPaste->setText(UIVMInformationDialog::tr("Paste the copied item "));681 m_pPaste->setToolTip(UIVMInformationDialog::tr("Paste the copied item "));682 m_pPaste->setStatusTip(UIVMInformationDialog::tr("Paste the copied item "));716 m_pPaste->setText(UIVMInformationDialog::tr("Paste the copied item(s)")); 717 m_pPaste->setToolTip(UIVMInformationDialog::tr("Paste the copied item(s)")); 718 m_pPaste->setStatusTip(UIVMInformationDialog::tr("Paste the copied item(s)")); 683 719 } 684 720 … … 761 797 } 762 798 763 void UIGuestFileTable::refresh() 764 { 765 } 766 799 void UIGuestFileTable::deleteByItem(UIFileTableItem *item) 800 { 801 if (!item) 802 return; 803 if (!m_comGuestSession.isOk()) 804 return; 805 if (item->isUpDirectory()) 806 return; 807 QVector<KDirectoryRemoveRecFlag> flags(KDirectoryRemoveRecFlag_ContentAndDir); 808 809 if (item->isDirectory()) 810 { 811 m_comGuestSession.DirectoryRemoveRecursive(item->path(), flags); 812 } 813 else 814 { 815 m_comGuestSession.FsObjRemove(item->path()); 816 } 817 } 767 818 768 819 /********************************************************************************************************************************* … … 825 876 } 826 877 827 void UIHostFileTable::refresh() 828 { 878 void UIHostFileTable::deleteByItem(UIFileTableItem */*item */) 879 { 880 829 881 } 830 882 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/guestctrl/UIGuestControlFileTable.h
r71201 r71208 100 100 bool isDirectoryMap, bool isStartDir); 101 101 virtual void readDirectory(const QString& strPath, UIFileTableItem *parent, bool isStartDir = false) = 0; 102 virtual void refresh() = 0; 102 virtual void refresh(); 103 virtual void deleteByItem(UIFileTableItem *item) = 0; 103 104 UIFileTableItem *m_pRootItem; 104 105 … … 116 117 void sltGoUp(); 117 118 void sltRefresh(); 119 void sltDelete(); 118 120 119 121 private: … … 121 123 void prepareObjects(); 122 124 void prepareActions(); 125 void deleteByIndex(const QModelIndex &itemIndex); 123 126 QGridLayout *m_pMainLayout; 124 127 QILineEdit *m_pCurrentLocationEdit; … … 150 153 void retranslateUi() /* override */; 151 154 virtual void readDirectory(const QString& strPath, UIFileTableItem *parent, bool isStartDir = false) /* override */; 152 virtual void refresh() /* override */;155 virtual void deleteByItem(UIFileTableItem *item) /* override */; 153 156 154 157 private: … … 171 174 void retranslateUi() /* override */; 172 175 virtual void readDirectory(const QString& strPath, UIFileTableItem *parent, bool isStartDir = false) /* override */; 173 virtual void refresh() /* override */; 174 176 virtual void deleteByItem(UIFileTableItem *item) /* override */; 175 177 }; 176 178
Note:
See TracChangeset
for help on using the changeset viewer.