VirtualBox

Changeset 100348 in vbox


Ignore:
Timestamp:
Jul 3, 2023 2:03:27 PM (17 months ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9080. Adding an action for removing imported ISO content.

Location:
trunk/src/VBox/Frontends/VirtualBox/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIActionPool.cpp

    r100323 r100348  
    26462646        setStatusTip(QApplication::translate("UIActionPool", "Import ISO into the VISO content."));
    26472647        setToolTip(QApplication::translate("UIActionPool", "Import Selected ISO(s) into the VISO content.")
     2648                   + (shortcut().isEmpty() ? QString() : QString(" (%1)").arg(shortcut().toString())));
     2649    }
     2650};
     2651
     2652
     2653class UIActionMenuVISOCreatorRemoveISO : public UIActionSimple
     2654{
     2655    Q_OBJECT;
     2656
     2657public:
     2658    /** Constructs action passing @a pParent to the base-class. */
     2659    UIActionMenuVISOCreatorRemoveISO(UIActionPool *pParent)
     2660        : UIActionSimple(pParent,
     2661                         ":/cd_remove_16px.png", ":/cd_remove_32px.png", ":/cd_remove_disabled_16px.png", ":/cd_remove_disabled_32px.png")
     2662    {
     2663        setShortcutContext(Qt::WidgetWithChildrenShortcut);
     2664    }
     2665
     2666protected:
     2667
     2668    /** Returns shortcut extra-data ID. */
     2669    virtual QString shortcutExtraDataID() const RT_OVERRIDE
     2670    {
     2671        return QString("ISORemove");
     2672    }
     2673
     2674    /** Handles translation event. */
     2675    virtual void retranslateUi() RT_OVERRIDE
     2676    {
     2677        setName(QApplication::translate("UIActionPool", "ISORemove"));
     2678        setShortcutScope(QApplication::translate("UIActionPool", "VISO Creator"));
     2679        setStatusTip(QApplication::translate("UIActionPool", "Remove ISO into the VISO content."));
     2680        setToolTip(QApplication::translate("UIActionPool", "Remove Selected ISO(s) into the VISO content.")
    26482681                   + (shortcut().isEmpty() ? QString() : QString(" (%1)").arg(shortcut().toString())));
    26492682    }
     
    34653498    m_pool[UIActionIndex_M_VISOCreator_Open] = new UIActionMenuVISOCreatorOpen(this);
    34663499    m_pool[UIActionIndex_M_VISOCreator_ImportISO] = new UIActionMenuVISOCreatorImportISO(this);
     3500    m_pool[UIActionIndex_M_VISOCreator_RemoveISO] = new UIActionMenuVISOCreatorRemoveISO(this);
    34673501
    34683502    m_pool[UIActionIndex_M_VISOCreator_VisoContent_GoHome] = new UIActionMenuVISOCreatorGoHome(this);
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIActionPool.h

    r100323 r100348  
    163163    UIActionIndex_M_VISOCreator_Open,
    164164    UIActionIndex_M_VISOCreator_ImportISO,
     165    UIActionIndex_M_VISOCreator_RemoveISO,
    165166    UIActionIndex_M_VISOCreator_VisoContent_GoHome,
    166167    UIActionIndex_M_VISOCreator_VisoContent_GoUp,
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/viso/UIVisoContentBrowser.cpp

    r100345 r100348  
    267267                                                  const QString &strDirPath /* = QString() */)
    268268{
     269    /* We can import only a ISO file into VISO:*/
     270    if (!importedISOPath().isEmpty())
     271        return;
    269272    if (!pParentItem)
    270         pParentItem = rootItem()->children()[0];
     273    {
     274        pParentItem = startItem();
     275        setTableRootIndex(m_pModel->index(pParentItem));
     276    }
    271277    if (!m_pTableView || !pParentItem)
    272278        return;
     
    312318    if (m_pTableProxyModel)
    313319        m_pTableProxyModel->invalidate();
    314 }
    315 
     320    emit sigISOContentImportedOrRemoved(true /* imported*/);
     321}
     322
     323void UIVisoContentBrowser::removeISOContentFromViso()
     324{
     325    UICustomFileSystemItem* pParentItem = startItem();
     326    AssertReturnVoid(pParentItem);
     327    AssertReturnVoid(m_pModel);
     328
     329    QList<UICustomFileSystemItem*> itemsToDelete;
     330    /* Delete all children of startItem that were imported from an ISO: */
     331    for (int i = 0; i < pParentItem->childCount(); ++i)
     332    {
     333        UICustomFileSystemItem* pItem = pParentItem->child(i);
     334        if (!pItem || pItem->data(UICustomFileSystemModelData_ISOFilePath).toString().isEmpty())
     335            continue;
     336        itemsToDelete << pItem;
     337    }
     338
     339    foreach (UICustomFileSystemItem *pItem, itemsToDelete)
     340            m_pModel->deleteItem(pItem);
     341    if (m_pTableProxyModel)
     342        m_pTableProxyModel->invalidate();
     343
     344    setImportedISOPath();
     345    emit sigISOContentImportedOrRemoved(false /* imported*/);
     346}
    316347
    317348void UIVisoContentBrowser::addObjectsToViso(const QStringList &pathList)
     
    545576        m_pTableView->hideColumn(UICustomFileSystemModelData_Size);
    546577        m_pTableView->hideColumn(UICustomFileSystemModelData_ChangeTime);
     578        m_pTableView->hideColumn(UICustomFileSystemModelData_ISOFilePath);
    547579
    548580        m_pTableView->setSortingEnabled(true);
     
    606638}
    607639
    608 void UIVisoContentBrowser::setImportedISOPath(const QString &strPath)
     640void UIVisoContentBrowser::setImportedISOPath(const QString &strPath /* = QString() */)
    609641{
    610642    if (m_strImportedISOPath == strPath)
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/viso/UIVisoContentBrowser.h

    r100333 r100348  
    5656
    5757    void sigTableSelectionChanged(bool fIsSelectionEmpty);
     58    void sigISOContentImportedOrRemoved(bool fImportedr);
    5859
    5960public:
     
    6566                                UICustomFileSystemItem *pParentItem = 0,
    6667                                const QString &strDirPath = QString());
     68    void removeISOContentFromViso();
    6769    /** Adds file objests from the host file system. @p pathList consists of list of paths to there objects. */
    6870    void addObjectsToViso(const QStringList &pathList);
     
    7779
    7880    const QString &importedISOPath() const;
    79     void setImportedISOPath(const QString &strPath);
     81    void setImportedISOPath(const QString &strPath = QString());
    8082
    8183public slots:
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/viso/UIVisoCreator.cpp

    r100345 r100348  
    261261    , m_pOpenAction(0)
    262262    , m_pImportISOAction(0)
     263    , m_pRemoveISOAction(0)
    263264    , m_pMainLayout(0)
    264265    , m_pHostBrowser(0)
     
    414415void UIVisoCreatorWidget::sltISOImportAction()
    415416{
    416     if (!m_pHostBrowser)
     417    if (!m_pHostBrowser || !m_pVISOContentBrowser)
    417418        return;
    418419    QStringList selectedObjectPaths = m_pHostBrowser->selectedPathList();
     
    420421        return;
    421422    m_pVISOContentBrowser->importISOContentToViso(selectedObjectPaths[0]);
     423}
     424
     425void UIVisoCreatorWidget::sltISORemoveAction()
     426{
     427    if (!m_pVISOContentBrowser)
     428        return;
     429    m_pVISOContentBrowser->removeISOContentFromViso();
     430}
     431
     432void UIVisoCreatorWidget::sltISOContentImportedOrRemoved(bool fImported)
     433{
     434    if (m_pImportISOAction)
     435        m_pImportISOAction->setEnabled(!fImported);
     436    if (m_pRemoveISOAction)
     437        m_pRemoveISOAction->setEnabled(fImported);
    422438}
    423439
     
    510526        connect(m_pVISOContentBrowser, &UIVisoContentBrowser::sigTableSelectionChanged,
    511527                this, &UIVisoCreatorWidget::sltContentBrowserTableSelectionChanged);
     528        connect(m_pVISOContentBrowser, &UIVisoContentBrowser::sigISOContentImportedOrRemoved,
     529                this, &UIVisoCreatorWidget::sltISOContentImportedOrRemoved);
    512530    }
    513531
     
    530548        connect(m_pImportISOAction, &QAction::triggered,
    531549                this, &UIVisoCreatorWidget::sltISOImportAction);
     550    if (m_pRemoveISOAction)
     551        connect(m_pRemoveISOAction, &QAction::triggered,
     552                this, &UIVisoCreatorWidget::sltISORemoveAction);
    532553}
    533554
     
    546567    if (m_pImportISOAction)
    547568        m_pImportISOAction->setEnabled(false);
     569
     570    m_pRemoveISOAction = m_pActionPool->action(UIActionIndex_M_VISOCreator_RemoveISO);
     571    if (m_pRemoveISOAction)
     572        m_pRemoveISOAction->setEnabled(false);
    548573}
    549574
     
    566591        if (m_pImportISOAction)
    567592            m_pMainMenu->addAction(m_pImportISOAction);
     593        if (m_pRemoveISOAction)
     594            m_pMainMenu->addAction(m_pRemoveISOAction);
    568595    }
    569596    if (m_pVISOContentBrowser)
     
    587614        if (m_pImportISOAction)
    588615            m_pVerticalToolBar->addAction(m_pImportISOAction);
     616        if (m_pRemoveISOAction)
     617            m_pVerticalToolBar->addAction(m_pRemoveISOAction);
    589618
    590619        m_pVerticalToolBar->addWidget(bottomSpacerWidget);
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/viso/UIVisoCreator.h

    r100333 r100348  
    119119    void sltOpenAction();
    120120    void sltISOImportAction();
     121    void sltISORemoveAction();
     122    void sltISOContentImportedOrRemoved(bool fImported);
    121123
    122124private:
     
    143145        QAction              *m_pOpenAction;
    144146        QAction              *m_pImportISOAction;
     147        QAction              *m_pRemoveISOAction;
    145148    /** @} */
    146149
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