- Timestamp:
- Mar 6, 2018 10:52:27 AM (7 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/guestctrl
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/guestctrl/UIGuestControlFileManager.cpp
r71208 r71234 323 323 m_pGuestFileTable->setEnabled(false); 324 324 if (m_pGuestFileTable) 325 { 326 connect(m_pGuestFileTable, &UIGuestFileTable::sigLogOutput, 327 this, &UIGuestControlFileManager::sltReceieveLogOutput); 325 328 containerLayout->addWidget(m_pGuestFileTable); 326 329 } 327 330 m_pToolBar = new UIToolBar; 328 331 if (m_pToolBar) … … 356 359 m_pHostFileTable = new UIHostFileTable; 357 360 if (m_pHostFileTable) 361 { 362 connect(m_pHostFileTable, &UIHostFileTable::sigLogOutput, 363 this, &UIGuestControlFileManager::sltReceieveLogOutput); 358 364 containerLayout->addWidget(m_pHostFileTable); 365 } 359 366 } 360 367 m_pVerticalSplitter->addWidget(fileTableContainer); … … 457 464 m_pLogOutput->appendPlainText("Session status has changed"); 458 465 } 466 } 467 468 void UIGuestControlFileManager::sltReceieveLogOutput(QString strOutput) 469 { 470 if (m_pLogOutput) 471 m_pLogOutput->appendPlainText(strOutput); 459 472 } 460 473 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/guestctrl/UIGuestControlFileManager.h
r71195 r71234 64 64 void sltCloseSession(); 65 65 void sltGuestSessionStateChanged(const CGuestSessionStateChangedEvent &cEvent); 66 void sltReceieveLogOutput(QString strOutput); 66 67 67 68 private: -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/guestctrl/UIGuestControlFileTable.cpp
r71209 r71234 80 80 void setPath(const QString &path); 81 81 82 const QString &name() const; 83 void setName(const QString &name); 84 82 85 /** True if this is directory and name is ".." */ 83 86 bool isUpDirectory() const; … … 91 94 bool m_bIsOpened; 92 95 QString m_strPath; 96 QString m_strName; 93 97 }; 94 98 … … 181 185 { 182 186 m_strPath = path; 187 } 188 189 const QString &UIFileTableItem::name() const 190 { 191 return m_strName; 192 } 193 194 void UIFileTableItem::setName(const QString &name) 195 { 196 m_strName = name; 183 197 } 184 198 … … 371 385 , m_pCurrentLocationEdit(0) 372 386 , m_pToolBar(0) 387 , m_pGoUp(0) 388 , m_pGoHome(0) 373 389 , m_pRefresh(0) 374 390 , m_pDelete(0) 391 , m_pRename(0) 375 392 , m_pNewFolder(0) 376 , m_pGoUp(0)377 393 , m_pCopy(0) 378 394 , m_pCut(0) … … 468 484 } 469 485 486 m_pGoHome = new QAction(this); 487 if (m_pGoHome) 488 { 489 connect(m_pGoHome, &QAction::triggered, this, &UIGuestControlFileTable::sltGoHome); 490 m_pGoHome->setIcon(UIIconPool::iconSet(QString(":/nw_24px.png"))); 491 m_pToolBar->addAction(m_pGoHome); 492 } 493 470 494 m_pRefresh = new QAction(this); 471 495 if (m_pRefresh) … … 476 500 } 477 501 502 m_pToolBar->addSeparator(); 478 503 479 504 m_pDelete = new QAction(this); … … 483 508 m_pDelete->setIcon(UIIconPool::iconSet(QString(":/vm_delete_32px.png"))); 484 509 m_pToolBar->addAction(m_pDelete); 510 } 511 512 m_pRename = new QAction(this); 513 if (m_pRename) 514 { 515 connect(m_pRename, &QAction::triggered, this, &UIGuestControlFileTable::sltRename); 516 m_pRename->setIcon(UIIconPool::iconSet(QString(":/name_16px_x2.png"))); 517 m_pToolBar->addAction(m_pRename); 485 518 } 486 519 … … 538 571 UIFileTableItem* startItem = new UIFileTableItem(startDirData, m_pRootItem); 539 572 startItem->setPath("/"); 573 startItem->setName("/"); 540 574 m_pRootItem->appendChild(startItem); 541 575 … … 583 617 if (!index.isValid() || !m_pModel || !m_pView) 584 618 return; 585 586 UIFileTableItem *item = static_cast<UIFileTableItem*>(index.internalPointer()); 619 goIntoDirectory(index); 620 } 621 622 void UIGuestControlFileTable::sltGoUp() 623 { 624 if (!m_pView || !m_pModel) 625 return; 626 QModelIndex currentRoot = m_pView->rootIndex(); 627 if (!currentRoot.isValid()) 628 return; 629 if (currentRoot != m_pModel->rootIndex()) 630 m_pView->setRootIndex(currentRoot.parent()); 631 } 632 633 void UIGuestControlFileTable::sltGoHome() 634 { 635 } 636 637 void UIGuestControlFileTable::sltRefresh() 638 { 639 refresh(); 640 } 641 642 void UIGuestControlFileTable::goIntoDirectory(const QModelIndex &itemIndex) 643 { 644 UIFileTableItem *item = static_cast<UIFileTableItem*>(itemIndex.internalPointer()); 587 645 if (!item) 588 646 return; … … 590 648 if (item->isUpDirectory()) 591 649 { 592 QModelIndex parentIndex = m_pModel->parent(m_pModel->parent(i ndex));650 QModelIndex parentIndex = m_pModel->parent(m_pModel->parent(itemIndex)); 593 651 if (parentIndex.isValid()) 594 652 changeLocation(parentIndex); … … 601 659 readDirectory(item->path(),item); 602 660 603 changeLocation(index); 604 } 605 606 void UIGuestControlFileTable::sltGoUp() 607 { 608 if (!m_pView || !m_pModel) 609 return; 610 QModelIndex currentRoot = m_pView->rootIndex(); 611 if (!currentRoot.isValid()) 612 return; 613 if (currentRoot != m_pModel->rootIndex()) 614 m_pView->setRootIndex(currentRoot.parent()); 615 } 616 617 void UIGuestControlFileTable::sltRefresh() 618 { 619 refresh(); 661 changeLocation(itemIndex); 620 662 } 621 663 … … 648 690 return; 649 691 650 QModelIndexList selectedItemIndices = selectionModel->selected Indexes();692 QModelIndexList selectedItemIndices = selectionModel->selectedRows(); 651 693 for(int i = 0; i < selectedItemIndices.size(); ++i) 652 694 { … … 654 696 } 655 697 refresh(); 698 } 699 700 void UIGuestControlFileTable::sltRename() 701 { 656 702 } 657 703 … … 668 714 void UIGuestControlFileTable::retranslateUi() 669 715 { 716 if (m_pGoUp) 717 { 718 m_pGoUp->setText(UIVMInformationDialog::tr("Move one level up")); 719 m_pGoUp->setToolTip(UIVMInformationDialog::tr("Move one level up")); 720 m_pGoUp->setStatusTip(UIVMInformationDialog::tr("Move one level up")); 721 } 722 723 if (m_pGoHome) 724 { 725 m_pGoHome->setText(UIVMInformationDialog::tr("Goto home folder")); 726 m_pGoHome->setToolTip(UIVMInformationDialog::tr("Goto home folder")); 727 m_pGoHome->setStatusTip(UIVMInformationDialog::tr("Goto home folder")); 728 } 729 730 if (m_pRename) 731 { 732 m_pRename->setText(UIVMInformationDialog::tr("Rename the selected item")); 733 m_pRename->setToolTip(UIVMInformationDialog::tr("Rename the selected item")); 734 m_pRename->setStatusTip(UIVMInformationDialog::tr("Rename the selected item")); 735 } 736 670 737 if (m_pRefresh) 671 738 { … … 688 755 689 756 } 690 if (m_pGoUp)691 {692 m_pGoUp->setText(UIVMInformationDialog::tr("Move one level up"));693 m_pGoUp->setToolTip(UIVMInformationDialog::tr("Move one level up"));694 m_pGoUp->setStatusTip(UIVMInformationDialog::tr("Move one level up"));695 696 }697 757 698 758 if (m_pCopy) … … 718 778 m_pPaste->setStatusTip(UIVMInformationDialog::tr("Paste the copied item(s)")); 719 779 } 720 780 } 781 782 783 void UIGuestControlFileTable::keyPressEvent(QKeyEvent * pEvent) 784 { 785 /* Browse into directory with enter: */ 786 if (pEvent->key() == Qt::Key_Enter || pEvent->key() == Qt::Key_Return) 787 { 788 if (m_pView && m_pModel) 789 { 790 /* Get the selected item. If there are 0 or more than 1 selection do nothing: */ 791 QItemSelectionModel *selectionModel = m_pView->selectionModel(); 792 if (selectionModel) 793 { 794 QModelIndexList selectedItemIndices = selectionModel->selectedRows(); 795 if (selectedItemIndices.size() == 1) 796 goIntoDirectory(selectedItemIndices.at(0)); 797 } 798 } 799 } 800 else if(pEvent->key() == Qt::Key_Delete) 801 { 802 sltDelete(); 803 } 804 QWidget::keyPressEvent(pEvent); 721 805 } 722 806 … … 813 897 else 814 898 { 899 /** @todo this is not working: */ 815 900 m_comGuestSession.FsObjRemove(item->path()); 816 901 } 817 902 } 903 818 904 819 905 /********************************************************************************************************************************* … … 841 927 842 928 QDir directory(strPath); 929 //directory.setFilter(QDir::NoDotAndDotDot); 843 930 parent->setIsOpened(true); 844 931 if (!directory.exists()) … … 848 935 QMap<QString, UIFileTableItem*> files; 849 936 850 851 937 for (int i = 0; i < entries.size(); ++i) 852 938 { 853 939 const QFileInfo &fileInfo = entries.at(i); 854 855 940 QList<QVariant> data; 856 941 data << fileInfo.baseName() << fileInfo.size(); … … 878 963 void UIHostFileTable::deleteByItem(UIFileTableItem *item) 879 964 { 880 Q_UNUSED(item); 965 if (!item->isDirectory()) 966 { 967 QDir itemToDelete;//(item->path()); 968 itemToDelete.remove(item->path()); 969 } 970 QDir itemToDelete(item->path()); 971 itemToDelete.setFilter(QDir::NoDotAndDotDot); 972 /* Try to delete item recursively (in case of directories). 973 note that this is no good way of deleting big directory 974 trees. We need a better error reporting and a kind of progress 975 indicator: */ 976 /** @todo replace this recursive delete by a better implementation: */ 977 bool deleteSuccess = itemToDelete.removeRecursively(); 978 979 if (!deleteSuccess) 980 emit sigLogOutput(QString(item->path()).append(" could not be deleted")); 881 981 } 882 982 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/guestctrl/UIGuestControlFileTable.h
r71208 r71234 43 43 /** UIGuestControlFileModel serves as the model for a file structure. 44 44 it supports a tree level hierarchy which can be displayed with 45 QTableView and/or QTreeView */ 45 QTableView and/or QTreeView. Note the file structure data is not 46 kept by the model but rather by the containing widget which also servers 47 as the interface to functionality this model provides.*/ 46 48 class UIGuestControlFileModel : public QAbstractItemModel 47 49 { … … 79 81 and a host version are derived from this base. Each of these children 80 82 populates the UIGuestControlFileModel by scanning the file system 81 differently. */ 83 differently. The file structre kept in this class as a tree and all 84 the interfacing is done thru this class.*/ 82 85 class UIGuestControlFileTable : public QIWithRetranslateUI<QWidget> 83 86 { 84 87 Q_OBJECT; 88 89 signals: 90 91 void sigLogOutput(QString); 85 92 86 93 public: … … 102 109 virtual void refresh(); 103 110 virtual void deleteByItem(UIFileTableItem *item) = 0; 111 void keyPressEvent(QKeyEvent * pEvent); 104 112 UIFileTableItem *m_pRootItem; 105 113 … … 116 124 void sltItemDoubleClicked(const QModelIndex &index); 117 125 void sltGoUp(); 126 void sltGoHome(); 118 127 void sltRefresh(); 119 128 void sltDelete(); 129 void sltRename(); 120 130 121 131 private: … … 124 134 void prepareActions(); 125 135 void deleteByIndex(const QModelIndex &itemIndex); 136 void goIntoDirectory(const QModelIndex &itemIndex); 126 137 QGridLayout *m_pMainLayout; 127 138 QILineEdit *m_pCurrentLocationEdit; 128 139 UIToolBar *m_pToolBar; 140 QAction *m_pGoUp; 141 QAction *m_pGoHome; 129 142 QAction *m_pRefresh; 130 143 QAction *m_pDelete; 144 QAction *m_pRename; 131 145 QAction *m_pNewFolder; 132 QAction *m_pGoUp; 146 133 147 QAction *m_pCopy; 134 148 QAction *m_pCut;
Note:
See TracChangeset
for help on using the changeset viewer.