VirtualBox

Changeset 71325 in vbox


Ignore:
Timestamp:
Mar 14, 2018 2:21:14 PM (7 years ago)
Author:
vboxsync
Message:

FE/Qt bugref:6699 Working on copy to/from guest and go to guest home directory functionalities

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

Legend:

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

    r71310 r71325  
    190190    if (m_pCloseButton)
    191191        m_pCloseButton->setText(UIVMInformationDialog::tr("Close Session"));
    192 
    193192}
    194193
     
    361360                m_pToolBar->addWidget(bottomSpacerWidget);
    362361
    363 
    364362                containerLayout->addWidget(m_pToolBar);
    365363            }
     
    486484        return;
    487485    QString hostDestinationPath = m_pHostFileTable->currentDirectoryPath();
    488     printf("current host path %s\n", hostDestinationPath.toStdString().c_str());
    489486    m_pGuestFileTable->copyGuestToHost(hostDestinationPath);
     487    m_pHostFileTable->refresh();
    490488}
    491489
     
    495493        return;
    496494    QStringList hostSourcePathList = m_pHostFileTable->selectedItemPathList();
    497     for(int i = 0; i < hostSourcePathList.size(); ++i)
    498         printf("%s\n", hostSourcePathList[i].toStdString().c_str());
    499495    m_pGuestFileTable->copyHostToGuest(hostSourcePathList);
     496    m_pGuestFileTable->refresh();
    500497}
    501498
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/guestctrl/UIGuestControlFileTable.cpp

    r71298 r71325  
    5656    static QString removeTrailingDelimiters(const QString &path);
    5757    static QString addStartDelimiter(const QString &path);
    58     static QString removeAllDelimiters(const QString &path);
    59 
    60     //    static QString removeTrailingDelimiters(const QString &path);
     58
    6159    static QString sanitize(const QString &path);
    6260    /** Merge prefix and suffix by making sure they have a single '/' in between */
     
    356354    , m_pModel(0)
    357355    , m_pLocationLabel(0)
    358     , m_pGoHome(0)
    359356    , m_pMainLayout(0)
    360357    , m_pCurrentLocationEdit(0)
    361358    , m_pToolBar(0)
    362359    , m_pGoUp(0)
     360    , m_pGoHome(0)
    363361    , m_pRefresh(0)
    364362    , m_pDelete(0)
     
    511509        m_pCopy->setIcon(UIIconPool::iconSet(QString(":/fd_copy_22px.png")));
    512510        m_pToolBar->addAction(m_pCopy);
    513         m_pCopy->setEnabled(false);
     511        //m_pCopy->setEnabled(false);
    514512    }
    515513
     
    655653}
    656654
    657 void UIGuestControlFileTable::goIntoDirectory(const QVector<QString> &pathTrail)
     655void UIGuestControlFileTable::goIntoDirectory(const QList<QString> &pathTrail)
    658656{
    659657    UIFileTableItem *parent = getStartDirectoryItem();
     
    766764        sltRefresh();
    767765    }
    768 
    769 }
    770 
     766}
    771767
    772768void UIGuestControlFileTable::deleteByIndex(const QModelIndex &itemIndex)
     
    928924}
    929925
     926CGuestFsObjInfo UIGuestControlFileTable::guestFsObjectInfo(const QString& path, CGuestSession &comGuestSession) const
     927{
     928    if (comGuestSession.isNull())
     929        return CGuestFsObjInfo();
     930    CGuestFsObjInfo comFsObjInfo = comGuestSession.FsObjQueryInfo(path, true /*aFollowSymlinks*/);
     931    if (!comFsObjInfo.isOk())
     932        return CGuestFsObjInfo();
     933    return comFsObjInfo;
     934}
     935
    930936
    931937/*********************************************************************************************************************************
     
    936942    :UIGuestControlFileTable(pParent)
    937943{
    938     configureObjects();
    939944    retranslateUi();
    940945}
     
    10291034void UIGuestFileTable::goToHomeDirectory()
    10301035{
    1031     /** @todo not implemented in guest control yet: */
     1036    if (m_comGuestSession.isNull())
     1037        return;
     1038    if (!m_pRootItem || m_pRootItem->childCount() <= 0)
     1039        return;
     1040    UIFileTableItem *startDirItem = m_pRootItem->child(0);
     1041    if (!startDirItem)
     1042        return;
     1043
     1044    QString userHome = UIPathOperations::sanitize(m_comGuestSession.GetUserHome());
     1045    QList<QString> pathTrail = userHome.split(UIPathOperations::delimiter);
     1046
     1047    goIntoDirectory(pathTrail);
    10321048}
    10331049
     
    10471063}
    10481064
    1049 void UIGuestFileTable::configureObjects()
    1050 {
    1051     if (m_pGoHome)
    1052         m_pGoHome->setEnabled(false);
    1053 }
    1054 
    10551065bool UIGuestFileTable::createDirectory(const QString &path, const QString &directoryName)
    10561066{
     
    10901100
    10911101    /* Currently API expects a path including a file name for file copy*/
    1092     KFsObjType objectType = fsObjectType(guestSourcePath);
     1102    CGuestFsObjInfo fileInfo = guestFsObjectInfo(guestSourcePath, m_comGuestSession);
     1103    KFsObjType objectType = fileInfo.GetType();
    10931104    if (objectType == KFsObjType_File)
    10941105    {
    1095         // QString destinatioFilePath =  mergePaths(hostDestinationPath, const QString &Path, const QString &baseName);
    1096 
    1097     }
    1098 
    1099     QVector<KDirectoryCopyFlag> aFlags(KDirectoryCopyFlag_CopyIntoExisting);
    1100     /** @todo listen to CProgress object to monitor copy operation: */
    1101     /*CProgress comProgress = */m_comGuestSession.DirectoryCopyFromGuest(guestSourcePath, hostDestinationPath, aFlags);
     1106        QVector<KFileCopyFlag> flags(KFileCopyFlag_FollowLinks);
     1107        /* API expects a full file path as destionation: */
     1108        QString destinatioFilePath =  UIPathOperations::mergePaths(hostDestinationPath, UIPathOperations::getObjectName(guestSourcePath));
     1109        /** @todo listen to CProgress object to monitor copy operation: */
     1110        /*CProgress comProgress =*/ m_comGuestSession.FileCopyFromGuest(guestSourcePath, destinatioFilePath, flags);
     1111
     1112    }
     1113    else if (objectType == KFsObjType_Directory)
     1114    {
     1115        QVector<KDirectoryCopyFlag> aFlags(KDirectoryCopyFlag_CopyIntoExisting);
     1116        /** @todo listen to CProgress object to monitor copy operation: */
     1117        /*CProgress comProgress = */ m_comGuestSession.DirectoryCopyFromGuest(guestSourcePath, hostDestinationPath, aFlags);
     1118    }
    11021119    if (!m_comGuestSession.isOk())
    11031120        return false;
     
    11091126    if (m_comGuestSession.isNull())
    11101127        return false;
    1111     QVector<KDirectoryCopyFlag> aFlags(KDirectoryCopyFlag_CopyIntoExisting);
    1112     /** @todo listen to CProgress object to monitor copy operation: */
    1113     /*CProgress comProgress = */m_comGuestSession.DirectoryCopyToGuest(hostSourcePath, guestDestinationPath, aFlags);
     1128    QFileInfo hostFileInfo(hostSourcePath);
     1129    if (!hostFileInfo.exists())
     1130        return false;
     1131
     1132    /* Currently API expects a path including a file name for file copy*/
     1133    if (hostFileInfo.isFile() || hostFileInfo.isSymLink())
     1134    {
     1135    }
     1136    else if(hostFileInfo.isDir())
     1137    {
     1138    }
     1139    // {
     1140    //     QVector<KFileCopyFlag> flags(KFileCopyFlag_FollowLinks);
     1141    //     /* API expects a full file path as destionation: */
     1142    //     QString destinatioFilePath =  UIPathOperations::mergePaths(guestDestinationPath,
     1143    //                                                                UIPathOperations::getObjectName(hostSourcePath));
     1144    //     /** @todo listen to CProgress object to monitor copy operation: */
     1145    //     /*CProgress comProgress =*/ m_comGuestSession.FileCopyToGuest(hostSourcePath, destinatioFilePath, flags);
     1146
     1147    // }
     1148    // else if (objectType == KFsObjType_Directory)
     1149    // {
     1150    //     QVector<KDirectoryCopyFlag> aFlags(KDirectoryCopyFlag_CopyIntoExisting);
     1151    //     /** @todo listen to CProgress object to monitor copy operation: */
     1152    //     /*CProgress comProgress = */ m_comGuestSession.DirectoryCopyToGuest(hostSourcePath, guestDestinationPath, aFlags);
     1153    // }
     1154    // if (!m_comGuestSession.isOk())
     1155    //     return false;
    11141156    return true;
    1115 }
    1116 
    1117 KFsObjType UIGuestFileTable::fsObjectType(const QString& path)
    1118 {
    1119     if (m_comGuestSession.isNull())
    1120         return KFsObjType_Unknown;
    1121     CGuestFsObjInfo comFsObjInfo = m_comGuestSession.FsObjQueryInfo(path, false /*aFollowSymlinks*/);
    1122     if (!comFsObjInfo.isOk() || m_comGuestSession.isOk())
    1123         return KFsObjType_Unknown;
    1124     return comFsObjInfo.GetType();
    11251157}
    11261158
     
    12121244    // UIFileTableItem *rootDirectoryItem
    12131245    QDir homeDirectory(QDir::homePath());
    1214     QVector<QString> pathTrail;//(QDir::rootPath());
     1246    QList<QString> pathTrail;//(QDir::rootPath());
    12151247    do{
    12161248
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/guestctrl/UIGuestControlFileTable.h

    r71298 r71325  
    110110    /** Returns the paths of the selected items (if any) as a list */
    111111    QStringList selectedItemPathList();
     112    virtual void refresh();
    112113
    113114protected:
     
    120121                           bool isDirectoryMap, bool isStartDir);
    121122    virtual void readDirectory(const QString& strPath, UIFileTableItem *parent, bool isStartDir = false) = 0;
    122     virtual void refresh();
    123123    virtual void deleteByItem(UIFileTableItem *item) = 0;
    124124    virtual void goToHomeDirectory() = 0;
     
    127127    void             goIntoDirectory(const QModelIndex &itemIndex);
    128128    /** Follow the path trail, open directories as we go and descend */
    129     void             goIntoDirectory(const QVector<QString> &pathTrail);
     129    void             goIntoDirectory(const QList<QString> &pathTrail);
    130130    /** Go into directory pointed by the @p item */
    131131    void             goIntoDirectory(UIFileTableItem *item);
    132132    UIFileTableItem* indexData(const QModelIndex &index) const;
    133133    void keyPressEvent(QKeyEvent * pEvent);
    134 
     134    CGuestFsObjInfo guestFsObjectInfo(const QString& path, CGuestSession &comGuestSession) const;
    135135
    136136
     
    143143    UIGuestControlFileModel *m_pModel;
    144144    QILabel                 *m_pLocationLabel;
    145     QAction                  *m_pGoHome;
    146145
    147146protected slots:
     
    168167    UIToolBar       *m_pToolBar;
    169168    QAction         *m_pGoUp;
    170 
     169    QAction         *m_pGoHome;
    171170    QAction         *m_pRefresh;
    172171    QAction         *m_pDelete;
    173172    QAction         *m_pRename;
    174173    QAction         *m_pCreateNewDirectory;
     174
    175175
    176176    QAction         *m_pCopy;
     
    205205private:
    206206
    207     KFsObjType fsObjectType(const QString& path);
    208207    bool copyGuestToHost(const QString &guestSourcePath, const QString& hostDestinationPath);
    209208    bool copyHostToGuest(const QString& hostSourcePath, const QString &guestDestinationPath);
    210209
    211     void configureObjects();
    212     CGuestSession m_comGuestSession;
     210    mutable CGuestSession m_comGuestSession;
    213211
    214212};
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