VirtualBox

Changeset 71201 in vbox for trunk


Ignore:
Timestamp:
Mar 5, 2018 1:20:48 PM (7 years ago)
Author:
vboxsync
Message:

FE/Qt bugref:6699 Implement 'refresh' 'go up' actions in file table

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

Legend:

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

    r71195 r71201  
    7777
    7878    void retranslateUi();
     79    void keyPressEvent(QKeyEvent * pEvent);
    7980
    8081private slots:
     
    190191        m_pCloseButton->setText(UIVMInformationDialog::tr("Close Session"));
    191192
     193}
     194
     195void UIGuestSessionCreateWidget::keyPressEvent(QKeyEvent * pEvent)
     196{
     197    /* Emit sigCreateSession upon enter press: */
     198    if (pEvent->key() == Qt::Key_Enter || pEvent->key() == Qt::Key_Return)
     199    {
     200        if ((m_pUserNameEdit && m_pUserNameEdit->hasFocus()) ||
     201            (m_pPasswordEdit && m_pPasswordEdit->hasFocus()))
     202            sigCreateSession(m_pUserNameEdit->text(), m_pPasswordEdit->text());
     203    }
     204    QWidget::keyPressEvent(pEvent);
    192205}
    193206
     
    458471    if (m_pSessionCreateWidget)
    459472        m_pSessionCreateWidget->switchSessionCloseMode();
    460     if(m_pGuestFileTable)
     473    if (m_pGuestFileTable)
    461474        m_pGuestFileTable->setEnabled(true);
    462     if(m_pToolBar)
     475    if (m_pToolBar)
    463476        m_pToolBar->setEnabled(true);
    464477}
     
    468481    if (m_pSessionCreateWidget)
    469482        m_pSessionCreateWidget->switchSessionCreateMode();
    470     if(m_pGuestFileTable)
     483    if (m_pGuestFileTable)
    471484        m_pGuestFileTable->setEnabled(false);
    472     if(m_pToolBar)
     485    if (m_pToolBar)
    473486        m_pToolBar->setEnabled(false);
    474487
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/guestctrl/UIGuestControlFileTable.cpp

    r71191 r71201  
    8181    /** True if this is directory and name is ".." */
    8282    bool isUpDirectory() const;
     83    void clearChildren();
    8384
    8485private:
     
    104105{
    105106    qDeleteAll(m_childItems);
     107    m_childItems.clear();
    106108}
    107109
     
    147149{
    148150    return m_bIsDirectory;
     151}
     152
     153void UIFileTableItem::clearChildren()
     154{
     155    qDeleteAll(m_childItems);
     156    m_childItems.clear();
    149157}
    150158
     
    452460
    453461    m_pGoUp = new QAction(this);
    454     m_pGoUp->setIcon(UIIconPool::iconSet(QString(":/arrow_up_10px_x2.png")));
    455     m_pToolBar->addAction(m_pGoUp);
    456 
     462    if (m_pGoUp)
     463    {
     464        connect(m_pGoUp, &QAction::triggered, this, &UIGuestControlFileTable::sltGoUp);
     465        m_pGoUp->setIcon(UIIconPool::iconSet(QString(":/arrow_up_10px_x2.png")));
     466        m_pToolBar->addAction(m_pGoUp);
     467    }
    457468
    458469    m_pRefresh = new QAction(this);
    459     m_pRefresh->setIcon(UIIconPool::iconSet(QString(":/refresh_22px.png")));
    460     m_pToolBar->addAction(m_pRefresh);
     470    if (m_pRefresh)
     471    {
     472        connect(m_pRefresh, &QAction::triggered, this, &UIGuestControlFileTable::sltRefresh);
     473        m_pRefresh->setIcon(UIIconPool::iconSet(QString(":/refresh_22px.png")));
     474        m_pToolBar->addAction(m_pRefresh);
     475    }
     476
    461477
    462478    m_pDelete = new QAction(this);
     
    582598    changeLocation(index);
    583599}
     600
     601void UIGuestControlFileTable::sltGoUp()
     602{
     603    if (!m_pView || !m_pModel)
     604        return;
     605    QModelIndex currentRoot = m_pView->rootIndex();
     606    if (!currentRoot.isValid())
     607        return;
     608    if (currentRoot != m_pModel->rootIndex())
     609        m_pView->setRootIndex(currentRoot.parent());
     610}
     611
     612void UIGuestControlFileTable::sltRefresh()
     613{
     614    if (!m_pView || !m_pModel)
     615        return;
     616    QModelIndex currentIndex = m_pView->rootIndex();
     617    if (!currentIndex.isValid())
     618        return;
     619    UIFileTableItem *treeItem =
     620        static_cast<UIFileTableItem*>(currentIndex.internalPointer());
     621    if (!treeItem)
     622        return;
     623    m_pModel->beginReset();
     624    /* For now we clear the whole subtree (that isrecursively) which is an overkill: */
     625    treeItem->clearChildren();
     626    readDirectory(treeItem->path(), treeItem, false);
     627    m_pModel->endReset();
     628    m_pView->setRootIndex(currentIndex);
     629}
     630
    584631
    585632void UIGuestControlFileTable::retranslateUi()
     
    714761}
    715762
     763void UIGuestFileTable::refresh()
     764{
     765}
     766
    716767
    717768/*********************************************************************************************************************************
     
    774825}
    775826
     827void UIHostFileTable::refresh()
     828{
     829}
     830
    776831#include "UIGuestControlFileTable.moc"
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/guestctrl/UIGuestControlFileTable.h

    r71191 r71201  
    100100                           bool isDirectoryMap, bool isStartDir);
    101101    virtual void readDirectory(const QString& strPath, UIFileTableItem *parent, bool isStartDir = false) = 0;
    102 
     102    virtual void refresh() = 0;
    103103    UIFileTableItem         *m_pRootItem;
    104104
     
    114114
    115115    void sltItemDoubleClicked(const QModelIndex &index);
     116    void sltGoUp();
     117    void sltRefresh();
    116118
    117119private:
     
    148150    void retranslateUi() /* override */;
    149151    virtual void readDirectory(const QString& strPath, UIFileTableItem *parent, bool isStartDir = false) /* override */;
     152    virtual void refresh() /* override */;
    150153
    151154private:
     
    168171    void retranslateUi() /* override */;
    169172    virtual void readDirectory(const QString& strPath, UIFileTableItem *parent, bool isStartDir = false) /* override */;
     173    virtual void refresh() /* override */;
    170174
    171175};
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