VirtualBox

Changeset 75480 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
Nov 15, 2018 12:26:08 PM (6 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:6699. Misc. improvements in guest control file manager

Location:
trunk/src/VBox/Frontends/VirtualBox/src/guestctrl
Files:
12 edited

Legend:

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

    r75425 r75480  
    113113    : bListDirectoriesOnTop(true)
    114114    , bAskDeleteConfirmation(false)
     115    , bShowHumanReadableSizes(true)
    115116{
    116117}
     
    255256    }
    256257
    257     // m_pFileOperationsList = new UIFileOperationsList;
    258     // if (m_pFileOperationsList)
    259     // {
    260     //     m_pTabWidget->addTab(m_pFileOperationsList, "File Operatiions");
    261     //     m_pFileOperationsList->header()->hide();
    262     // }
    263258    pTopLayout->addLayout(pFileTableContainerLayout);
    264259    m_pSessionPanel = new UIGuestControlFileManagerSessionPanel(this /* manager dialog */, 0 /*parent */);
     
    277272        m_pSettingsPanel->hide();
    278273        m_panelActionMap.insert(m_pSettingsPanel, m_pActionPool->action(UIActionIndex_M_GuestControlFileManager_T_Settings));
    279         connect(m_pSettingsPanel, &UIGuestControlFileManagerSettingsPanel::sigListDirectoriesFirstChanged,
     274        connect(m_pSettingsPanel, &UIGuestControlFileManagerSettingsPanel::sigSettingsChanged,
    280275                this, &UIGuestControlFileManager::sltListDirectoriesBeforeChanged);
    281276        pTopLayout->addWidget(m_pSettingsPanel);
    282277    }
     278
     279    m_pVerticalSplitter->addWidget(pTopWidget);
    283280
    284281    m_pOperationsPanel =
     
    288285        m_pOperationsPanel->hide();
    289286        m_panelActionMap.insert(m_pOperationsPanel, m_pActionPool->action(UIActionIndex_M_GuestControlFileManager_T_FileOperations));
    290         pTopLayout->addWidget(m_pOperationsPanel);
    291     }
    292 
    293     m_pVerticalSplitter->addWidget(pTopWidget);
     287    }
    294288
    295289    m_pLogPanel = new UIGuestControlFileManagerLogPanel(this /* manager dialog */, 0 /*parent */);
     
    299293        m_panelActionMap.insert(m_pLogPanel, m_pActionPool->action(UIActionIndex_M_GuestControlFileManager_T_Log));
    300294    }
     295
    301296    m_pVerticalSplitter->addWidget(pTopWidget);
     297    m_pVerticalSplitter->addWidget(m_pOperationsPanel);
    302298    m_pVerticalSplitter->addWidget(m_pLogPanel);
    303299    m_pVerticalSplitter->setCollapsible(m_pVerticalSplitter->indexOf(pTopWidget), false);
     300    m_pVerticalSplitter->setCollapsible(m_pVerticalSplitter->indexOf(m_pOperationsPanel), false);
    304301    m_pVerticalSplitter->setCollapsible(m_pVerticalSplitter->indexOf(m_pLogPanel), false);
    305302    m_pVerticalSplitter->setStretchFactor(0, 3);
    306303    m_pVerticalSplitter->setStretchFactor(1, 1);
     304    m_pVerticalSplitter->setStretchFactor(2, 1);
    307305}
    308306
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIGuestControlFileManager.h

    r75425 r75480  
    6969    bool bListDirectoriesOnTop;
    7070    bool bAskDeleteConfirmation;
     71    bool bShowHumanReadableSizes;
    7172
    7273private:
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIGuestControlFileManagerOperationsPanel.cpp

    r75425 r75480  
    169169    if (m_pTableWidget)
    170170    {
    171         m_pTableWidget->setColumnCount(1);
     171        m_pTableWidget->setColumnCount(TableColumn_Max);
     172        QStringList headers;
     173        headers << "Progress" << "Information";
     174        m_pTableWidget->setHorizontalHeaderLabels(headers);
    172175        mainLayout()->addWidget(m_pTableWidget);
    173176    }
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIGuestControlFileManagerOperationsPanel.h

    r75425 r75480  
    5858private:
    5959
     60    enum TableColumn
     61    {
     62        TableColumn_Progress,
     63        TableColumn_Info,
     64        TableColumn_Max
     65    };
     66
    6067    /** @name Member variables.
    6168      * @{ */
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIGuestControlFileManagerSettingsPanel.cpp

    r75425 r75480  
    4242    , m_pListDirectoriesOnTopCheckBox(0)
    4343    , m_pDeleteConfirmationCheckBox(0)
     44    , m_pHumanReabableSizesCheckBox(0)
    4445    , m_pFileManagerSettings(pFileManagerSettings)
    4546{
     
    6061    if (m_pListDirectoriesOnTopCheckBox)
    6162    {
    62         m_pListDirectoriesOnTopCheckBox->setChecked(true);
    6363        mainLayout()->addWidget(m_pListDirectoriesOnTopCheckBox, 0, Qt::AlignLeft);
    6464    }
     
    6767    if (m_pDeleteConfirmationCheckBox)
    6868    {
    69         m_pDeleteConfirmationCheckBox->setChecked(false);
    7069        mainLayout()->addWidget(m_pDeleteConfirmationCheckBox, 0, Qt::AlignLeft);
    7170    }
    7271
    73 
     72    m_pHumanReabableSizesCheckBox = new QCheckBox;
     73    if (m_pHumanReabableSizesCheckBox)
     74    {
     75        mainLayout()->addWidget(m_pHumanReabableSizesCheckBox, 0, Qt::AlignLeft);
     76    }
     77    /* Set initial checkbox status wrt. settings: */
     78    if (m_pFileManagerSettings)
     79    {
     80        if (m_pListDirectoriesOnTopCheckBox)
     81            m_pListDirectoriesOnTopCheckBox->setChecked(m_pFileManagerSettings->bListDirectoriesOnTop);
     82        if (m_pDeleteConfirmationCheckBox)
     83            m_pDeleteConfirmationCheckBox->setChecked(m_pFileManagerSettings->bAskDeleteConfirmation);
     84        if (m_pHumanReabableSizesCheckBox)
     85            m_pHumanReabableSizesCheckBox->setChecked(m_pFileManagerSettings->bShowHumanReadableSizes);
     86    }
    7487    retranslateUi();
    7588    mainLayout()->addStretch(2);
    7689}
    7790
    78 void UIGuestControlFileManagerSettingsPanel::sltListDirectoryCheckBoxToogled(bool fChecked)
     91void UIGuestControlFileManagerSettingsPanel::sltListDirectoryCheckBoxToogled(bool bChecked)
    7992{
    8093    if (!m_pFileManagerSettings)
    8194        return;
    82     m_pFileManagerSettings->bListDirectoriesOnTop = fChecked;
    83     emit sigListDirectoriesFirstChanged();
     95    m_pFileManagerSettings->bListDirectoriesOnTop = bChecked;
     96    emit sigSettingsChanged();
     97}
     98
     99void UIGuestControlFileManagerSettingsPanel::sltDeleteConfirmationCheckBoxToogled(bool bChecked)
     100{
     101    if (!m_pFileManagerSettings)
     102        return;
     103    m_pFileManagerSettings->bAskDeleteConfirmation = bChecked;
     104    emit sigSettingsChanged();
     105}
     106
     107void UIGuestControlFileManagerSettingsPanel::sltHumanReabableSizesCheckBoxToogled(bool bChecked)
     108{
     109    if (!m_pFileManagerSettings)
     110        return;
     111    m_pFileManagerSettings->bShowHumanReadableSizes = bChecked;
     112    emit sigSettingsChanged();
    84113}
    85114
     
    89118        connect(m_pListDirectoriesOnTopCheckBox, &QCheckBox::toggled,
    90119                this, &UIGuestControlFileManagerSettingsPanel::sltListDirectoryCheckBoxToogled);
     120    if (m_pDeleteConfirmationCheckBox)
     121        connect(m_pDeleteConfirmationCheckBox, &QCheckBox::toggled,
     122                this, &UIGuestControlFileManagerSettingsPanel::sltDeleteConfirmationCheckBoxToogled);
     123    if (m_pHumanReabableSizesCheckBox)
     124        connect(m_pHumanReabableSizesCheckBox, &QCheckBox::toggled,
     125                this, &UIGuestControlFileManagerSettingsPanel::sltHumanReabableSizesCheckBoxToogled);
    91126}
    92127
     
    94129{
    95130    UIGuestControlFileManagerPanel::retranslateUi();
     131    if (m_pListDirectoriesOnTopCheckBox)
     132    {
     133        m_pListDirectoriesOnTopCheckBox->setText(UIGuestControlFileManager::tr("List directories on top"));
     134        m_pListDirectoriesOnTopCheckBox->setToolTip(UIGuestControlFileManager::tr("List directories before files"));
     135    }
    96136
    97     m_pListDirectoriesOnTopCheckBox->setText(UIGuestControlFileManager::tr("List directories on top"));
    98     m_pListDirectoriesOnTopCheckBox->setToolTip(UIGuestControlFileManager::tr("List directories before files"));
     137    if (m_pDeleteConfirmationCheckBox)
     138    {
     139        m_pDeleteConfirmationCheckBox->setText(UIGuestControlFileManager::tr("Ask before delete"));
     140        m_pDeleteConfirmationCheckBox->setToolTip(UIGuestControlFileManager::tr("List directories before files"));
     141    }
    99142
    100     m_pDeleteConfirmationCheckBox->setText(UIGuestControlFileManager::tr("Ask before delete"));
    101     m_pDeleteConfirmationCheckBox->setToolTip(UIGuestControlFileManager::tr("List directories before files"));
     143    if (m_pHumanReabableSizesCheckBox)
     144    {
     145        m_pHumanReabableSizesCheckBox->setText(UIGuestControlFileManager::tr("Human readable sizes"));
     146        m_pHumanReabableSizesCheckBox->setToolTip(UIGuestControlFileManager::tr("List directories before files"));
     147    }
    102148}
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIGuestControlFileManagerSettingsPanel.h

    r75425 r75480  
    4242signals:
    4343
    44     void sigListDirectoriesFirstChanged();
     44    void sigSettingsChanged();
    4545
    4646protected:
     
    5454private slots:
    5555
    56     void sltListDirectoryCheckBoxToogled(bool fChecked);
     56    void sltListDirectoryCheckBoxToogled(bool bChecked);
     57    void sltDeleteConfirmationCheckBoxToogled(bool bChecked);
     58    void sltHumanReabableSizesCheckBoxToogled(bool bChecked);
    5759
    5860private:
     
    6062    QCheckBox                         *m_pListDirectoriesOnTopCheckBox;
    6163    QCheckBox                         *m_pDeleteConfirmationCheckBox;
     64    QCheckBox                         *m_pHumanReabableSizesCheckBox;
     65
    6266    UIGuestControlFileManagerSettings *m_pFileManagerSettings;
    6367};
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIGuestControlFileModel.cpp

    r75425 r75480  
    131131    {
    132132        /* dont show anything but the name for up directories: */
    133         if (item->isUpDirectory() && index.column() != 0)
     133        if (item->isUpDirectory() && index.column() != UIGuestControlFileModelColumn_Name)
    134134            return QVariant();
    135135        /* Format date/time column: */
     
    140140                return dateTime.toString("dd.MM.yyyy hh:mm:ss");
    141141        }
     142        /* Decide whether to show human-readable file object sizes: */
     143        if (index.column() == UIGuestControlFileModelColumn_Size)
     144        {
     145            UIGuestControlFileManagerSettings* pSettings =
     146                UIGuestControlFileManagerSettings::instance();
     147            if (pSettings && pSettings->bShowHumanReadableSizes)
     148            {
     149                qulonglong size = item->data(index.column()).toULongLong();
     150                return UIGuestControlFileTable::humanReadableSize(size);
     151            }
     152            else
     153                return item->data(index.column());
     154        }
    142155        return item->data(index.column());
    143156    }
    144 
     157    /* Show the up directory array: */
    145158    if (role == Qt::DecorationRole && index.column() == 0)
    146159    {
     
    274287    endResetModel();
    275288}
    276 
    277 bool UIGuestControlFileModel::insertRows(int position, int rows, const QModelIndex &parent)
    278 {
    279     UIFileTableItem *parentItem = static_cast<UIFileTableItem*>(parent.internalPointer());
    280 
    281     if (!parentItem)
    282         return false;
    283     beginInsertRows(parent, position, position + rows -1);
    284 
    285     QList<QVariant> data;
    286     data << "New Item" << 0 << QDateTime::currentDateTime();
    287     UIFileTableItem *newItem = new UIFileTableItem(data, parentItem, FileObjectType_Directory);
    288     parentItem->appendChild(newItem);
    289     endInsertRows();
    290 
    291     return true;
    292 }
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIGuestControlFileModel.h

    r75425 r75480  
    2929class UIFileTableItem;
    3030class UIGuestControlFileTable;
     31
     32enum UIGuestControlFileModelColumn
     33{
     34    UIGuestControlFileModelColumn_Name = 0,
     35    UIGuestControlFileModelColumn_Size,
     36    UIGuestControlFileModelColumn_ChangeTime,
     37    UIGuestControlFileModelColumn_Owner,
     38    UIGuestControlFileModelColumn_Permissions,
     39    UIGuestControlFileModelColumn_Max
     40};
    3141
    3242/** A QSortFilterProxyModel extension used in file tables. Modifies some
     
    7787    void           beginReset();
    7888    void           endReset();
    79     bool           insertRows(int position, int rows, const QModelIndex &parent);
    8089    static const char* strUpDirectoryString;
    8190
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIGuestControlFileTable.cpp

    r75425 r75480  
    432432*********************************************************************************************************************************/
    433433
    434 UIFileTableItem::UIFileTableItem(const QList<QVariant> &data,
     434UIFileTableItem::UIFileTableItem(const QVector<QVariant> &data,
    435435                                 UIFileTableItem *parent, FileObjectType type)
    436436    : m_itemData(data)
     
    756756    /* Root item: */
    757757    const QString startPath("/");
    758     QList<QVariant> headData;
    759     headData << "Name" << "Size" << "Change Time" << "Owner" << "Permissions";
     758    QVector<QVariant> headData;
     759    headData.resize(UIGuestControlFileModelColumn_Max);
     760    headData[UIGuestControlFileModelColumn_Name] = "Name";
     761    headData[UIGuestControlFileModelColumn_Size] = "Size";
     762    headData[UIGuestControlFileModelColumn_ChangeTime] = "Change Time";
     763    headData[UIGuestControlFileModelColumn_Owner] = "Owner";
     764    headData[UIGuestControlFileModelColumn_Permissions] = "Permissions";
    760765    m_pRootItem = new UIFileTableItem(headData, 0, FileObjectType_Directory);
    761     QList<QVariant> startDirData;
    762     startDirData << startPath << 4096 << QDateTime() << "" << "";
    763     UIFileTableItem* startItem = new UIFileTableItem(startDirData, m_pRootItem, FileObjectType_Directory);
    764 
     766    UIFileTableItem* startItem = new UIFileTableItem(createTreeItemData(startPath, 4096, QDateTime(),
     767                                                                        "" /* owner */, "" /* permissions */),
     768                                                     m_pRootItem, FileObjectType_Directory);
    765769    startItem->setPath(startPath);
    766770    m_pRootItem->appendChild(startItem);
     
    785789        for (int i = 0; i < m_driveLetterList.size(); ++i)
    786790        {
    787             QList<QVariant> data;
    788 
    789             data << m_driveLetterList[i] << 4096 << QDateTime() << "";
    790             UIFileTableItem* driveItem = new UIFileTableItem(data, startItem, FileObjectType_Directory);
     791            UIFileTableItem* driveItem = new UIFileTableItem(createTreeItemData(m_driveLetterList[i], 4096,
     792                                                                                QDateTime(), QString(), QString()),
     793                                                             startItem, FileObjectType_Directory);
    791794            driveItem->setPath(m_driveLetterList[i]);
    792795            startItem->appendChild(driveItem);
     
    808811        if (!map.contains(UIGuestControlFileModel::strUpDirectoryString)  && !isStartDir)
    809812        {
    810             QList<QVariant> data;
    811             data << UIGuestControlFileModel::strUpDirectoryString << 4096 << "";
    812             UIFileTableItem *item = new UIFileTableItem(data, parent, FileObjectType_Directory);
     813            QVector<QVariant> data;
     814            UIFileTableItem *item = new UIFileTableItem(createTreeItemData(UIGuestControlFileModel::strUpDirectoryString, 4096,
     815                                                                           QDateTime(), QString(), QString())
     816                                                        , parent, FileObjectType_Directory);
    813817            item->setIsOpened(false);
    814818            map.insert(UIGuestControlFileModel::strUpDirectoryString, item);
     
    12991303}
    13001304
     1305
     1306QVector<QVariant> UIGuestControlFileTable::createTreeItemData(const QString &strName, ULONG64 size, const QDateTime &changeTime,
     1307                                                            const QString &strOwner, const QString &strPermissions)
     1308{
     1309    QVector<QVariant> data;
     1310    data.resize(UIGuestControlFileModelColumn_Max);
     1311    data[UIGuestControlFileModelColumn_Name]        = strName;
     1312    data[UIGuestControlFileModelColumn_Size]        = (qulonglong)size;
     1313    data[UIGuestControlFileModelColumn_ChangeTime]  = changeTime;
     1314    data[UIGuestControlFileModelColumn_Owner]       = strOwner;
     1315    data[UIGuestControlFileModelColumn_Permissions] = strPermissions;
     1316    return data;
     1317}
     1318
    13011319QString UIGuestControlFileTable::fileTypeString(FileObjectType type)
    13021320{
     
    13951413    m_pSearchLineEdit->blockSignals(false);
    13961414}
     1415
    13971416#include "UIGuestControlFileTable.moc"
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIGuestControlFileTable.h

    r75425 r75480  
    168168     *  the name of the file object which is the file name including extension or name of the
    169169     *  directory */
    170     explicit UIFileTableItem(const QList<QVariant> &data,
     170    explicit UIFileTableItem(const QVector<QVariant> &data,
    171171                             UIFileTableItem *parentItem, FileObjectType type);
    172172    ~UIFileTableItem();
     
    220220    QMap<QString, UIFileTableItem*> m_childMap;
    221221    /** It is required that m_itemData[0] is name (QString) of the file object */
    222     QList<QVariant>  m_itemData;
     222    QVector<QVariant>  m_itemData;
    223223    UIFileTableItem *m_parentItem;
    224224    bool             m_bIsOpened;
     
    263263    static QString humanReadableSize(ULONG64 size);
    264264
     265public slots:
     266
     267    void sltReceiveDirectoryStatistics(UIDirectoryStatistics statictics);
     268    void sltCreateNewDirectory();
     269    /* index is passed by the item view and represents the double clicked object's 'proxy' model index */
     270    void sltItemDoubleClicked(const QModelIndex &index);
     271    void sltItemClicked(const QModelIndex &index);
     272    void sltGoUp();
     273    void sltGoHome();
     274    void sltRefresh();
     275    void sltDelete();
     276    void sltRename();
     277    void sltCopy();
     278    void sltCut();
     279    void sltPaste();
     280    void sltShowProperties();
     281    void sltSelectAll();
     282    void sltInvertSelection();
    265283
    266284protected:
     
    296314    CGuestFsObjInfo  guestFsObjectInfo(const QString& path, CGuestSession &comGuestSession) const;
    297315    void             setSelectionDependentActionsEnabled(bool fIsEnabled);
     316    /** Creates a QList out of the parameters wrt. UIGuestControlFileModelColumn enum */
     317    QVector<QVariant>  createTreeItemData(const QString &strName, ULONG64 size, const QDateTime &changeTime,
     318                                        const QString &strOwner, const QString &strPermissions);
    298319
    299320    UIFileTableItem         *m_pRootItem;
     
    308329    /** The set of actions which need some selection to work on. Like cut, copy etc. */
    309330    QSet<QAction*> m_selectionDependentActions;
    310 
    311 public slots:
    312 
    313     void sltReceiveDirectoryStatistics(UIDirectoryStatistics statictics);
    314     void sltCreateNewDirectory();
    315     /* index is passed by the item view and represents the double clicked object's 'proxy' model index */
    316     void sltItemDoubleClicked(const QModelIndex &index);
    317     void sltItemClicked(const QModelIndex &index);
    318     void sltGoUp();
    319     void sltGoHome();
    320     void sltRefresh();
    321     void sltDelete();
    322     void sltRename();
    323     void sltCopy();
    324     void sltCut();
    325     void sltPaste();
    326     void sltShowProperties();
    327     void sltSelectAll();
    328     void sltInvertSelection();
    329331
    330332private slots:
     
    353355    /* Searches the content of m_pSearchLineEdit within the current items' names and selects the item if found. */
    354356    void            performSelectionSearch(const QString &strSearchText);
    355     /* Clears the m_pSearchLineEdit and hides it. */
     357    /** Clears the m_pSearchLineEdit and hides it. */
    356358    void            disableSelectionSearch();
    357 
    358359    UIGuestControlFileModel      *m_pModel;
    359360    UIGuestControlFileView       *m_pView;
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIGuestFileTable.cpp

    r75425 r75480  
    197197        while (fsInfo.isOk())
    198198        {
    199             QList<QVariant> data;
     199            QVector<QVariant> data;
    200200            QDateTime changeTime = QDateTime::fromMSecsSinceEpoch(fsInfo.GetChangeTime()/1000000);
    201201
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIHostFileTable.cpp

    r75425 r75480  
    221221
    222222        const QFileInfo &fileInfo = entries.at(i);
    223         QList<QVariant> data;
    224         data << fileInfo.fileName() << fileInfo.size()
    225              << fileInfo.lastModified() << fileInfo.owner() <<
    226             permissionString(fileInfo.permissions());
    227         UIFileTableItem *item = new UIFileTableItem(data, parent, fileType(fileInfo));
     223        UIFileTableItem *item = new UIFileTableItem(createTreeItemData(fileInfo.fileName(), fileInfo.size(),
     224                                                                       fileInfo.lastModified(), fileInfo.owner(),
     225                                                                       permissionString(fileInfo.permissions())),
     226                                                    parent, fileType(fileInfo));
    228227        if (!item)
    229228            continue;
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