VirtualBox

Ignore:
Timestamp:
Jul 18, 2023 12:35:45 PM (19 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
158460
Message:

FE/Qt: bugref:9080. Make sure selection dependent actions are enabled/disabled during reset operation.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/medium/viso
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/viso/UIVisoBrowserBase.h

    r100478 r100629  
    6262    ~UIVisoBrowserBase();
    6363    virtual void showHideHiddenObjects(bool bShow) = 0;
    64     virtual bool tableViewHasSelection() const = 0;
    6564
    6665public slots:
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/viso/UIVisoContentBrowser.cpp

    r100605 r100629  
    179179    void sigNewItemsDropped(QStringList pathList);
    180180
     181
    181182public:
    182183
     
    185186    void dropEvent(QDropEvent *event);
    186187    void dragMoveEvent(QDragMoveEvent *event);
     188    bool hasSelection() const;
    187189};
    188190
     
    199201{
    200202    event->acceptProposedAction();
     203}
     204
     205bool UIVisoContentTableView::hasSelection() const
     206{
     207    if (!selectionModel())
     208        return false;
     209    return selectionModel()->hasSelection();
    201210}
    202211
     
    643652    AssertReturnVoid(m_pGoBackward);
    644653
    645     m_pRemoveAction->setEnabled(tableViewHasSelection());
    646     m_pRestoreAction->setEnabled(tableViewHasSelection());
    647     m_pRenameAction->setEnabled(tableViewHasSelection());
     654    m_pRemoveAction->setEnabled(m_pTableView->hasSelection());
     655    m_pRestoreAction->setEnabled(m_pTableView->hasSelection());
     656    m_pRenameAction->setEnabled(m_pTableView->hasSelection());
    648657
    649658    m_pToolBar->addAction(m_pGoBackward);
     
    787796    if (m_pGoUp)
    788797        m_pGoUp->setEnabled(!onStartItem());
     798    m_pTableView->clearSelection();
     799    enableDisableSelectionDependentActions();
    789800}
    790801
     
    820831{
    821832    Q_UNUSED(bShow);
    822 }
    823 
    824 bool UIVisoContentBrowser::tableViewHasSelection() const
    825 {
    826     if (!m_pTableView)
    827         return false;
    828     QItemSelectionModel *pSelectionModel = m_pTableView->selectionModel();
    829     if (!pSelectionModel)
    830         return false;
    831     return pSelectionModel->hasSelection();
    832833}
    833834
     
    10791080    emit sigTableSelectionChanged(selected.isEmpty());
    10801081
    1081     if (m_pRemoveAction)
    1082         m_pRemoveAction->setEnabled(!selected.isEmpty());
    1083     if (m_pRestoreAction)
    1084         m_pRestoreAction->setEnabled(!selected.isEmpty());
    1085     if (m_pRenameAction)
    1086         m_pRenameAction->setEnabled(!selected.isEmpty());
     1082    enableDisableSelectionDependentActions();
    10871083}
    10881084
     
    10911087    if (!rootItem() || !rootItem()->child(0))
    10921088        return;
     1089    goToStart();
    10931090    rootItem()->child(0)->removeChildren();
    10941091    m_entryMap.clear();
     
    11741171    /* Go up if we are not already in root: */
    11751172    if (!onStartItem())
    1176     {
    11771173        setTableRootIndex(currentRoot.parent());
    1178     }
     1174}
     1175
     1176void UIVisoContentBrowser::goToStart()
     1177{
     1178    while(!onStartItem())
     1179        goUp();
    11791180}
    11801181
     
    12021203}
    12031204
     1205void UIVisoContentBrowser::enableDisableSelectionDependentActions()
     1206{
     1207    AssertReturnVoid(m_pTableView);
     1208
     1209    bool fSelection = m_pTableView->hasSelection();
     1210    if (m_pRemoveAction)
     1211        m_pRemoveAction->setEnabled(fSelection);
     1212    if (m_pRestoreAction)
     1213        m_pRestoreAction->setEnabled(fSelection);
     1214    if (m_pRenameAction)
     1215        m_pRenameAction->setEnabled(fSelection);
     1216}
     1217
    12041218#include "UIVisoContentBrowser.moc"
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/viso/UIVisoContentBrowser.h

    r100601 r100629  
    7373    QStringList entryList();
    7474    virtual void showHideHiddenObjects(bool bShow)  override final;
    75     virtual bool tableViewHasSelection() const final override;
     75
    7676    void parseVisoFileContent(const QString &strFileName);
    7777    void prepareMainMenu(QMenu *pMenu);
     
    134134    QString                 currentPath() const;
    135135    UICustomFileSystemItem* searchItemByPath(const QString &strPath);
    136 
     136    void                    goToStart();
    137137    /** Returns a list of items which are currecntly selected
    138138     *  in the table view. */
     
    147147    const UICustomFileSystemItem*  currentDirectoryItem() const;
    148148    void                           markRemovedUnremovedItemParents(UICustomFileSystemItem *pItem, bool fRemoved);
     149    void                           enableDisableSelectionDependentActions();
    149150    UIVisoContentTableView        *m_pTableView;
    150151    UICustomFileSystemModel       *m_pModel;
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/viso/UIVisoHostBrowser.h

    r100559 r100629  
    5858    QString      currentPath() const;
    5959    void         setCurrentPath(const QString &strPath);
    60     virtual bool tableViewHasSelection() const final override;
     60    bool tableViewHasSelection() const;
    6161    /* The list of path of the selected file objects. */
    6262    QStringList selectedPathList() const;
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