VirtualBox

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


Ignore:
Timestamp:
Jan 9, 2019 9:48:49 PM (6 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9080: Additional improvements and fixes

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

Legend:

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

    r76707 r76750  
    109109}
    110110
     111void UICustomFileSystemItem::removeChildren()
     112{
     113    reset();
     114}
     115
    111116int UICustomFileSystemItem::columnCount() const
    112117{
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UICustomFileSystemModel.h

    r76707 r76750  
    6161    /** Removes the item from the list of children and !!DELETES!! the item. */
    6262    void removeChild(UICustomFileSystemItem *pItem);
     63    void removeChildren();
    6364    int columnCount() const;
    6465    QVariant data(int column) const;
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/viso/UIVisoContentBrowser.cpp

    r76730 r76750  
    189189        m_pNewDirectoryAction->setToolTip(QApplication::translate("UIVisoCreator", "Create a new directory under the current location"));
    190190    if (m_pResetAction)
    191         m_pResetAction->setToolTip(QApplication::translate("UIVisoCreator", "Remove the whole content"));
     191        m_pResetAction->setToolTip(QApplication::translate("UIVisoCreator", "Reset ISO content."));
    192192    if (m_pRenameAction)
    193193        m_pRenameAction->setToolTip(QApplication::translate("UIVisoCreator", "Rename the selected object"));
     
    246246
    247247    /*  Check to see if we already have a directory named strNewDirectoryName: */
    248     QList<const UICustomFileSystemItem*> children = pParentItem->children();
     248    const QList<const UICustomFileSystemItem*> children = pParentItem->children();
    249249    foreach (const UICustomFileSystemItem *item, children)
    250250    {
     
    266266void UIVisoContentBrowser::sltHandleRemoveItems()
    267267{
    268     QVector<UICustomFileSystemItem*> selectedItems = tableSelectedItems();
    269     foreach(UICustomFileSystemItem *pItem, selectedItems)
     268    removeItems(tableSelectedItems());
     269}
     270
     271void UIVisoContentBrowser::removeItems(const QList<UICustomFileSystemItem*> itemList)
     272{
     273    foreach(UICustomFileSystemItem *pItem, itemList)
    270274    {
    271275        if (!pItem)
    272276            continue;
    273         /* If the item is a directory the remove the item from iso entry list: */
    274         if (pItem->type() == KFsObjType_Directory)
     277        bool bFoundInMap = false;
     278        for (QMap<QString, QString>::iterator iterator = m_entryMap.begin(); iterator != m_entryMap.end(); )
    275279        {
    276             for (QMap<QString, QString>::iterator iterator = m_entryMap.begin(); iterator != m_entryMap.end(); )
     280            QString strIsoPath = pItem->data(UICustomFileSystemModelColumn_Path).toString();
     281            if (strIsoPath.isEmpty())
     282                continue;
     283            if (iterator.key().startsWith(strIsoPath))
    277284            {
    278                 QString strIsoPath = pItem->data(UICustomFileSystemModelColumn_Path).toString();
    279                 if (strIsoPath.isEmpty())
    280                     continue;
    281                 if (iterator.key().startsWith(strIsoPath, Qt::CaseInsensitive))
    282                     iterator = m_entryMap.erase(iterator);
    283                 else
    284                     ++iterator;
     285                iterator = m_entryMap.erase(iterator);
     286                bFoundInMap = true;
    285287            }
     288            else
     289                ++iterator;
    286290        }
    287         /* Else mark it as "removed" in the viso file entry list: */
    288         else
    289         {
     291        if (!bFoundInMap)
    290292            createAnIsoEntry(pItem, true /* bool bRemove */);
    291         }
    292     }
    293 
    294     foreach(UICustomFileSystemItem *pItem, selectedItems)
     293    }
     294
     295    foreach(UICustomFileSystemItem *pItem, itemList)
    295296    {
    296297        if (!pItem)
     
    360361        m_pRemoveAction->setIcon(UIIconPool::iconSetFull(":/file_manager_delete_24px.png", ":/file_manager_delete_16px.png",
    361362                                                     ":/file_manager_delete_disabled_24px.png", ":/file_manager_delete_disabled_16px.png"));
    362         m_pRemoveAction->setEnabled(true);
     363        m_pRemoveAction->setEnabled(false);
    363364    }
    364365
     
    372373    }
    373374
    374     m_pResetAction = new QAction(this);
    375     if (m_pResetAction)
    376     {
    377         m_pVerticalToolBar->addAction(m_pResetAction);
    378         m_pResetAction->setIcon(UIIconPool::iconSet(":/file_manager_delete_16px.png", ":/file_manager_delete_disabled_16px.png"));
    379         m_pResetAction->setEnabled(true);
    380     }
    381 
    382375    m_pRenameAction = new QAction(this);
    383376    if (m_pRenameAction)
     
    386379        m_pRenameAction->setIcon(UIIconPool::iconSet(":/file_manager_rename_16px.png", ":/file_manager_rename_disabled_16px.png"));
    387380        m_pRenameAction->setEnabled(false);
     381    }
     382
     383    m_pVerticalToolBar->addSeparator();
     384
     385    m_pResetAction = new QAction(this);
     386    if (m_pResetAction)
     387    {
     388        m_pVerticalToolBar->addAction(m_pResetAction);
     389        m_pResetAction->setIcon(UIIconPool::iconSet(":/cd_remove_16px.png", ":/cd_remove_disabled_16px.png"));
     390        m_pResetAction->setEnabled(true);
    388391    }
    389392
     
    403406        connect(m_pRemoveAction, &QAction::triggered,
    404407                this, &UIVisoContentBrowser::sltHandleRemoveItems);
     408    if (m_pResetAction)
     409        connect(m_pResetAction, &QAction::triggered,
     410                this, &UIVisoContentBrowser::sltHandleResetAction);
     411
    405412    if (m_pTableView->selectionModel())
    406413        connect(m_pTableView->selectionModel(), &QItemSelectionModel::selectionChanged,
     
    430437    startItem->setIsOpened(false);
    431438}
    432 
    433439
    434440void UIVisoContentBrowser::setTableRootIndex(QModelIndex index /* = QModelIndex */)
     
    637643    pItem->setData(UIPathOperations::mergePaths(pItem->parentItem()->path(), pItem->name()), UICustomFileSystemModelColumn_Path);
    638644
    639 
    640 
    641645    if (m_pTableProxyModel)
    642646        m_pTableProxyModel->invalidate();
     
    652656}
    653657
     658void UIVisoContentBrowser::sltHandleResetAction()
     659{
     660    if (!rootItem() || !rootItem()->child(0))
     661        return;
     662    rootItem()->child(0)->removeChildren();
     663    m_entryMap.clear();
     664    if (m_pTableProxyModel)
     665        m_pTableProxyModel->invalidate();
     666    if (m_pTreeProxyModel)
     667        m_pTreeProxyModel->invalidate();
     668}
     669
    654670void UIVisoContentBrowser::reset()
    655671{
     
    657673}
    658674
    659 QVector<UICustomFileSystemItem*> UIVisoContentBrowser::tableSelectedItems()
    660 {
    661     QVector<UICustomFileSystemItem*> selectedItems;
     675QList<UICustomFileSystemItem*> UIVisoContentBrowser::tableSelectedItems()
     676{
     677    QList<UICustomFileSystemItem*> selectedItems;
    662678    if (!m_pTableProxyModel)
    663679        return selectedItems;
     
    665681    if (!selectionModel || selectionModel->selectedIndexes().isEmpty())
    666682        return selectedItems;
    667     QModelIndexList list = selectionModel->selectedIndexes();
     683    QModelIndexList list = selectionModel->selectedRows();
    668684    foreach (QModelIndex index, list)
    669685    {
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/viso/UIVisoContentBrowser.h

    r76730 r76750  
    7878    void sltHandleRemoveItems();
    7979    void sltHandleTableSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
     80    void sltHandleResetAction();
    8081
    8182private:
     
    9192    void                    updateStartItemName();
    9293    void                    renameFileObject(UICustomFileSystemItem *pItem);
     94    void                    removeItems(const QList<UICustomFileSystemItem*> itemList);
    9395    /** Creates and entry for pItem consisting of a map item (key is iso path and value is host file system path)
    9496     *  if @p bRemove is true then the value is the string ":remove:" which effectively removes the file object
     
    98100    /** Returns a list of items which are currecntly selected
    99101     *  in the table view. */
    100     QVector<UICustomFileSystemItem*> tableSelectedItems();
     102    QList<UICustomFileSystemItem*> tableSelectedItems();
     103
    101104    UICustomFileSystemModel      *m_pModel;
    102105    UICustomFileSystemProxyModel *m_pTableProxyModel;
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/viso/UIVisoHostBrowser.cpp

    r76730 r76750  
    101101        m_pTitleLabel->setText(QApplication::translate("UIVisoCreator", "Host file system"));
    102102    if (m_pAddAction)
    103         m_pAddAction->setToolTip(QApplication::translate("UIVisoCreator", "Add selected file objects to VISO"));
     103        m_pAddAction->setToolTip(QApplication::translate("UIVisoCreator", "Add selected file objects to ISO"));
    104104}
    105105
     
    193193    if (bShow)
    194194    {
    195         m_pTableModel->setFilter(QDir::AllDirs | QDir::NoDotAndDotDot | QDir::Hidden);
    196195        m_pTreeModel->setFilter(QDir::AllDirs | QDir::NoDotAndDotDot | QDir::Hidden);
     196        m_pTableModel->setFilter(QDir::AllEntries | QDir::NoDot | QDir::Hidden | QDir::System);
    197197    }
    198198    else
    199199    {
    200         m_pTableModel->setFilter(QDir::AllDirs | QDir::NoDotAndDotDot);
    201200        m_pTreeModel->setFilter(QDir::AllDirs | QDir::NoDotAndDotDot);
     201        m_pTableModel->setFilter(QDir::AllEntries | QDir::NoDot);
    202202    }
    203203}
     
    214214    for (int i = 0; i < selectedIndices.size(); ++i)
    215215    {
    216         pathList << m_pTableModel->filePath(selectedIndices[i]);
     216        QString strPath = m_pTableModel->filePath(selectedIndices[i]);
     217        if (strPath.contains(".."))
     218            continue;
     219        pathList << strPath;
    217220    }
    218221    emit sigAddObjectsToViso(pathList);
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/viso/UIVisoHostBrowser.h

    r76730 r76750  
    5555    virtual void setTableRootIndex(QModelIndex index = QModelIndex()) /* override */;
    5656    virtual void setTreeCurrentIndex(QModelIndex index = QModelIndex()) /* override */;
    57 
    5857    virtual void treeSelectionChanged(const QModelIndex &selectedTreeIndex) /* override */;
    5958
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