VirtualBox

Changeset 75610 in vbox for trunk/src


Ignore:
Timestamp:
Nov 20, 2018 11:14:35 AM (6 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:6699. Some infrastructure for move-to-guest and move-to-host operations"

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  
    284284    {
    285285        m_pOperationsPanel->hide();
     286        connect(m_pOperationsPanel, &UIGuestControlFileManagerOperationsPanel::sigFileOperationComplete,
     287                this, &UIGuestControlFileManager::sltFileOperationComplete);
    286288        m_panelActionMap.insert(m_pOperationsPanel, m_pActionPool->action(UIActionIndex_M_GuestControlFileManager_T_FileOperations));
    287289    }
     
    465467void UIGuestControlFileManager::sltCopyGuestToHost()
    466468{
    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);
    472470}
    473471
    474472void UIGuestControlFileManager::sltCopyHostToGuest()
    475473{
    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
     477void UIGuestControlFileManager::sltMoveGuestToHost()
     478{
     479    copyMoveToHost(true);
     480}
     481
     482void UIGuestControlFileManager::sltMoveHostToGuest()
     483{
     484    copyMoveToGuest(true);
    481485}
    482486
     
    514518    if (m_pOperationsPanel)
    515519        m_pOperationsPanel->addNewProgress(comProgress);
     520}
     521
     522void 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
     537void 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
     546void 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();
    516553}
    517554
     
    683720            iterator.value()->setChecked(false);
    684721    }
    685     m_visiblePanelsList.removeOne(panel);
     722    m_visiblePanelsList.removeAll(panel);
    686723    manageEscapeShortCut();
    687724}
     
    697734            iterator.value()->setChecked(true);
    698735    }
    699     m_visiblePanelsList.push_back(panel);
     736    if (!m_visiblePanelsList.contains(panel))
     737        m_visiblePanelsList.push_back(panel);
    700738    manageEscapeShortCut();
    701739}
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIGuestControlFileManager.h

    r75480 r75610  
    110110    void sltCopyGuestToHost();
    111111    void sltCopyHostToGuest();
     112    void sltMoveGuestToHost();
     113    void sltMoveHostToGuest();
    112114    void sltPanelActionToggled(bool fChecked);
    113115    void sltListDirectoriesBeforeChanged();
    114116    void sltReceieveNewFileOperation(const CProgress &comProgress);
     117    void sltFileOperationComplete(QUuid progressId);
    115118
    116119private:
     
    149152        - assigned it to the most recently "unhidden" panel */
    150153    void manageEscapeShortCut();
    151 
     154    void copyMoveToGuest(bool fIsMove);
     155    void copyMoveToHost(bool fIsMove);
    152156    template<typename T>
    153157    QStringList               getFsObjInfoStringList(const T &fsObjectInfo) const;
    154158    void                      appendLog(const QString &strLog, FileManagerLogType eLogType);
     159
    155160    CGuest                    m_comGuest;
    156161    CGuestSession             m_comGuestSession;
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIGuestControlFileManagerOperationsPanel.cpp

    r75518 r75610  
    5555    ~UIFileOperationProgressWidget();
    5656
     57signals:
     58
     59    void sigProgressTaskComplete(QUuid progressId);
     60
    5761protected:
    5862
     
    121125    if (m_pCancelButton)
    122126    {
    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; } ");
    125131        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;}");
    127132        m_pCancelButton->setFixedSize(sh);
     133
    128134        connect(m_pCancelButton, &QIToolButton::clicked, this, &UIFileOperationProgressWidget::sltCancelProgress);
    129         if (!m_comProgress.GetCancelable())
     135        if (!m_comProgress.isNull() && !m_comProgress.GetCancelable())
    130136            m_pCancelButton->setEnabled(false);
    131         m_pMainLayout->addWidget(m_pCancelButton, 0, Qt::AlignLeft | Qt::AlignTop);
     137        m_pMainLayout->addWidget(m_pCancelButton);
    132138    }
    133139
     
    147153void UIFileOperationProgressWidget::prepareEventHandler()
    148154{
     155    if (m_comProgress.isNull())
     156        return;
    149157    m_pEventHandler = new UIProgressEventHandler(this, m_comProgress);
    150158    connect(m_pEventHandler, &UIProgressEventHandler::sigProgressPercentageChange,
     
    172180    if (m_pCancelButton)
    173181        m_pCancelButton->setEnabled(false);
     182    emit sigProgressTaskComplete(m_comProgress.GetId());
    174183}
    175184
     
    191200    : UIGuestControlFileManagerPanel(pManagerWidget, pParent)
    192201    , m_pTableWidget(0)
    193     , m_pOperationsWidget(0)
    194202{
    195203    prepare();
     
    202210
    203211    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
    205217    m_pTableWidget->resizeColumnsToContents();
    206218}
     
    231243void UIGuestControlFileManagerOperationsPanel::prepareConnections()
    232244{
     245
    233246}
    234247
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIGuestControlFileManagerOperationsPanel.h

    r75480 r75610  
    1919#define ___UIGuestControlFileManagerOperationsPanel_h___
    2020
     21/* Qt includes: */
     22# include <QUuid>
     23
    2124/* GUI includes: */
    2225#include "UIGuestControlDefs.h"
     
    3538{
    3639    Q_OBJECT;
     40
     41signals:
     42
     43    void sigFileOperationComplete(QUuid progressId);
    3744
    3845public:
     
    6875      * @{ */
    6976        QTableWidget *m_pTableWidget;
    70         UIFileOperationProgressWidget *m_pOperationsWidget;
    7177    /** @} */
    7278
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIGuestControlFileTable.cpp

    r75480 r75610  
    13601360}
    13611361
     1362void UIGuestControlFileTable::continueWithMove(const QUuid &progressId)
     1363{
     1364    QStringList sourcePathList = m_deleteAfterCopyCache.value(progressId);
     1365    deleteByPath(m_deleteAfterCopyCache.value(progressId, QStringList()));
     1366}
     1367
    13621368void UIGuestControlFileTable::sltReceiveDirectoryStatistics(UIDirectoryStatistics statistics)
    13631369{
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIGuestControlFileTable.h

    r75480 r75610  
    262262    static const unsigned    m_iKiloByte;
    263263    static QString humanReadableSize(ULONG64 size);
     264    /** Deletes the file objects whose stored in the m_pDeleteAfterCopyCache */
     265    void continueWithMove(const QUuid &progressId);
    264266
    265267public slots:
     
    293295    virtual void     readDirectory(const QString& strPath, UIFileTableItem *parent, bool isStartDir = false) = 0;
    294296    virtual void     deleteByItem(UIFileTableItem *item) = 0;
     297    virtual void     deleteByPath(const QStringList &pathList) = 0;
    295298    virtual void     goToHomeDirectory() = 0;
    296299    virtual bool     renameItem(UIFileTableItem *item, QString newBaseName) = 0;
     
    329332    /** The set of actions which need some selection to work on. Like cut, copy etc. */
    330333    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;
    331337
    332338private slots:
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIGuestFileTable.cpp

    r75517 r75610  
    2323# include <QDateTime>
    2424# include <QFileInfo>
     25# include <QUuid>
    2526
    2627/* GUI includes: */
     
    228229        insertItemsToTree(directories, parent, true, isStartDir);
    229230        insertItemsToTree(files, parent, false, isStartDir);
    230         //updateCurrentLocationEdit(strPath);
    231231    }
    232232    directory.Close();
     
    251251        emit sigLogOutput(QString(item->path()).append(" could not be deleted"), FileManagerLogType_Error);
    252252        emit sigLogOutput(UIErrorString::formatErrorInfo(m_comGuestSession), FileManagerLogType_Error);
     253    }
     254}
     255
     256void 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
    253272    }
    254273}
     
    310329}
    311330
    312 void UIGuestFileTable::copyHostToGuest(const QStringList &hostSourcePathList)
     331void UIGuestFileTable::copyHostToGuest(const QStringList &hostSourcePathList, bool fDeleteAfterSuccessfulCopy /* = false */)
    313332{
    314333    QVector<QString> sourcePaths = hostSourcePathList.toVector();
     
    334353    }
    335354    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
     361void UIGuestFileTable::copyGuestToHost(const QString& hostDestinationPath, bool fDeleteAfterSuccessfulCopy /* = false */)
    340362{
    341363    QVector<QString> sourcePaths = selectedItemPathList().toVector();
     
    361383    }
    362384    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();
    364389}
    365390
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIGuestFileTable.h

    r75425 r75610  
    1818#ifndef ___UIGuestTable_h___
    1919#define ___UIGuestTable_h___
     20
     21/* Qt includes: */
     22# include <QUuid>
    2023
    2124/* COM includes: */
     
    3942    UIGuestFileTable(UIActionPool *pActionPool, QWidget *pParent = 0);
    4043    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);
    4346
    4447signals:
    4548
    4649    void sigNewFileOperation(const CProgress &comProgress);
     50    void sigCacheHostFileObjectsForDeletion(const QUuid &moveProgessId, const QStringList &hostPathList);
    4751
    4852protected:
     
    5155    virtual void    readDirectory(const QString& strPath, UIFileTableItem *parent, bool isStartDir = false) /* override */;
    5256    virtual void    deleteByItem(UIFileTableItem *item) /* override */;
     57    virtual void    deleteByPath(const QStringList &pathList) /* override */;
    5358    virtual void    goToHomeDirectory() /* override */;
    5459    virtual bool    renameItem(UIFileTableItem *item, QString newBaseName);
     
    6772    void prepareActionConnections();
    6873
    69     mutable CGuestSession m_comGuestSession;
    70 
     74    mutable CGuestSession     m_comGuestSession;
    7175};
    7276
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIHostFileTable.cpp

    r75480 r75610  
    132132    prepareActionConnections();
    133133    retranslateUi();
     134}
     135
     136void UIHostFileTable::setDeleteAfterCopyCache(const QUuid &progressId, const QStringList &sourceObjectsList)
     137{
     138    m_deleteAfterCopyCache[progressId] = sourceObjectsList;
    134139}
    135140
     
    257262    if (!item->isDirectory())
    258263    {
    259         QDir itemToDelete;//(item->path());
     264        QDir itemToDelete;
    260265        itemToDelete.remove(item->path());
    261266    }
     
    271276     if (!deleteSuccess)
    272277         emit sigLogOutput(QString(item->path()).append(" could not be deleted"), FileManagerLogType_Error);
     278}
     279
     280void 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    }
    273299}
    274300
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIHostFileTable.h

    r75425 r75610  
    3434
    3535    UIHostFileTable(UIActionPool *pActionPool, QWidget *pParent = 0);
     36    void setDeleteAfterCopyCache(const QUuid &progressId, const QStringList &sourceObjectsList);
    3637
    3738protected:
     
    4142    virtual void    readDirectory(const QString& strPath, UIFileTableItem *parent, bool isStartDir = false) /* override */;
    4243    virtual void    deleteByItem(UIFileTableItem *item) /* override */;
     44    virtual void    deleteByPath(const QStringList &pathList) /* override */;
    4345    virtual void    goToHomeDirectory() /* override */;
    4446    virtual bool    renameItem(UIFileTableItem *item, QString newBaseName);
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