VirtualBox

Changeset 71276 in vbox for trunk


Ignore:
Timestamp:
Mar 8, 2018 3:28:52 PM (7 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:6699 Implementing some helper functions for copying file system objects from/to guest

Location:
trunk/src/VBox/Frontends/VirtualBox/src/runtime/guestctrl
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/guestctrl/UIGuestControlFileManager.cpp

    r71274 r71276  
    346346                {
    347347                    m_pCopyGuestToHost->setIcon(UIIconPool::iconSet(QString(":/arrow_right_10px_x2.png")));
    348                     m_pCopyGuestToHost->setEnabled(false);
     348                    connect(m_pCopyGuestToHost, &QAction::triggered, this, &UIGuestControlFileManager::sltCopyGuestToHost);
    349349                }
    350350
     
    353353                {
    354354                    m_pCopyHostToGuest->setIcon(UIIconPool::iconSet(QString(":/arrow_left_10px_x2.png")));
    355                     m_pCopyHostToGuest->setEnabled(false);
     355                    connect(m_pCopyHostToGuest, &QAction::triggered, this, &UIGuestControlFileManager::sltCopyHostToGuest);
    356356                }
     357
    357358                m_pToolBar->addWidget(topSpacerWidget);
    358359                m_pToolBar->addAction(m_pCopyGuestToHost);
     
    480481}
    481482
     483void UIGuestControlFileManager::sltCopyGuestToHost()
     484{
     485    if (!m_pGuestFileTable || !m_pHostFileTable)
     486        return;
     487    QString hostDestinationPath = m_pHostFileTable->currentPath();
     488    printf("current host path %s\n", hostDestinationPath.toStdString().c_str());
     489    m_pGuestFileTable->copyGuestToHost(hostDestinationPath);
     490}
     491
     492void UIGuestControlFileManager::sltCopyHostToGuest()
     493{
     494    if (!m_pGuestFileTable || !m_pHostFileTable)
     495        return;
     496    QStringList hostSourcePathList = m_pHostFileTable->selectedItemPathList();
     497    for(int i = 0; i < hostSourcePathList.size(); ++i)
     498        printf("%s\n", hostSourcePathList[i].toStdString().c_str());
     499    m_pGuestFileTable->copyHostToGuest(hostSourcePathList);
     500}
     501
    482502void UIGuestControlFileManager::initFileTable()
    483503{
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/guestctrl/UIGuestControlFileManager.h

    r71234 r71276  
    6565    void sltGuestSessionStateChanged(const CGuestSessionStateChangedEvent &cEvent);
    6666    void sltReceieveLogOutput(QString strOutput);
     67    void sltCopyGuestToHost();
     68    void sltCopyHostToGuest();
    6769
    6870private:
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/guestctrl/UIGuestControlFileTable.cpp

    r71274 r71276  
    821821}
    822822
     823QString UIGuestControlFileTable::currentPath() const
     824{
     825    if (!m_pView)
     826        return QString();
     827    QModelIndex currentRoot = m_pView->rootIndex();
     828    if (!currentRoot.isValid())
     829        return QString();
     830    UIFileTableItem *item = static_cast<UIFileTableItem*>(currentRoot.internalPointer());
     831    if (!item)
     832        return QString();
     833    return item->path();
     834}
     835
     836QStringList UIGuestControlFileTable::selectedItemPathList()
     837{
     838    QItemSelectionModel *selectionModel =  m_pView->selectionModel();
     839    if (!selectionModel)
     840        return QStringList();
     841
     842    QStringList pathList;
     843    QModelIndexList selectedItemIndices = selectionModel->selectedRows();
     844    for(int i = 0; i < selectedItemIndices.size(); ++i)
     845    {
     846        UIFileTableItem *item = static_cast<UIFileTableItem*>(selectedItemIndices.at(i).internalPointer());
     847        if (!item)
     848            continue;
     849        pathList.push_back(item->path());
     850    }
     851    return pathList;
     852}
    823853
    824854/*********************************************************************************************************************************
     
    964994}
    965995
     996void UIGuestFileTable::copyGuestToHost(const QString& hostDestinationPath)
     997{
     998}
     999
     1000void UIGuestFileTable::copyHostToGuest(const QStringList &hostSourcePathList)
     1001{
     1002}
    9661003
    9671004/*********************************************************************************************************************************
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/guestctrl/UIGuestControlFileTable.h

    r71271 r71276  
    111111    void reset();
    112112    void emitLogOutput(const QString& strOutput);
     113    /** Returns the path of the rootIndex */
     114    QString     currentPath() const;
     115    /** Returns the paths of the selected items (if any) as a list */
     116    QStringList selectedItemPathList();
    113117
    114118protected:
     
    147151    QILabel                 *m_pLocationLabel;
    148152    QAction                  *m_pGoHome;
     153
    149154protected slots:
    150155
     
    193198    UIGuestFileTable(QWidget *pParent = 0);
    194199    void initGuestFileTable(const CGuestSession &session);
     200    void copyGuestToHost(const QString& hostDestinationPath);
     201    void copyHostToGuest(const QStringList &hostSourcePathList);
    195202
    196203protected:
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette