Changeset 76750 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Jan 9, 2019 9:48:49 PM (6 years ago)
- 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 109 109 } 110 110 111 void UICustomFileSystemItem::removeChildren() 112 { 113 reset(); 114 } 115 111 116 int UICustomFileSystemItem::columnCount() const 112 117 { -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UICustomFileSystemModel.h
r76707 r76750 61 61 /** Removes the item from the list of children and !!DELETES!! the item. */ 62 62 void removeChild(UICustomFileSystemItem *pItem); 63 void removeChildren(); 63 64 int columnCount() const; 64 65 QVariant data(int column) const; -
trunk/src/VBox/Frontends/VirtualBox/src/medium/viso/UIVisoContentBrowser.cpp
r76730 r76750 189 189 m_pNewDirectoryAction->setToolTip(QApplication::translate("UIVisoCreator", "Create a new directory under the current location")); 190 190 if (m_pResetAction) 191 m_pResetAction->setToolTip(QApplication::translate("UIVisoCreator", "Re move the whole content"));191 m_pResetAction->setToolTip(QApplication::translate("UIVisoCreator", "Reset ISO content.")); 192 192 if (m_pRenameAction) 193 193 m_pRenameAction->setToolTip(QApplication::translate("UIVisoCreator", "Rename the selected object")); … … 246 246 247 247 /* 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(); 249 249 foreach (const UICustomFileSystemItem *item, children) 250 250 { … … 266 266 void UIVisoContentBrowser::sltHandleRemoveItems() 267 267 { 268 QVector<UICustomFileSystemItem*> selectedItems = tableSelectedItems(); 269 foreach(UICustomFileSystemItem *pItem, selectedItems) 268 removeItems(tableSelectedItems()); 269 } 270 271 void UIVisoContentBrowser::removeItems(const QList<UICustomFileSystemItem*> itemList) 272 { 273 foreach(UICustomFileSystemItem *pItem, itemList) 270 274 { 271 275 if (!pItem) 272 276 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(); ) 275 279 { 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)) 277 284 { 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; 285 287 } 288 else 289 ++iterator; 286 290 } 287 /* Else mark it as "removed" in the viso file entry list: */ 288 else 289 { 291 if (!bFoundInMap) 290 292 createAnIsoEntry(pItem, true /* bool bRemove */); 291 } 292 } 293 294 foreach(UICustomFileSystemItem *pItem, selectedItems) 293 } 294 295 foreach(UICustomFileSystemItem *pItem, itemList) 295 296 { 296 297 if (!pItem) … … 360 361 m_pRemoveAction->setIcon(UIIconPool::iconSetFull(":/file_manager_delete_24px.png", ":/file_manager_delete_16px.png", 361 362 ":/file_manager_delete_disabled_24px.png", ":/file_manager_delete_disabled_16px.png")); 362 m_pRemoveAction->setEnabled( true);363 m_pRemoveAction->setEnabled(false); 363 364 } 364 365 … … 372 373 } 373 374 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 382 375 m_pRenameAction = new QAction(this); 383 376 if (m_pRenameAction) … … 386 379 m_pRenameAction->setIcon(UIIconPool::iconSet(":/file_manager_rename_16px.png", ":/file_manager_rename_disabled_16px.png")); 387 380 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); 388 391 } 389 392 … … 403 406 connect(m_pRemoveAction, &QAction::triggered, 404 407 this, &UIVisoContentBrowser::sltHandleRemoveItems); 408 if (m_pResetAction) 409 connect(m_pResetAction, &QAction::triggered, 410 this, &UIVisoContentBrowser::sltHandleResetAction); 411 405 412 if (m_pTableView->selectionModel()) 406 413 connect(m_pTableView->selectionModel(), &QItemSelectionModel::selectionChanged, … … 430 437 startItem->setIsOpened(false); 431 438 } 432 433 439 434 440 void UIVisoContentBrowser::setTableRootIndex(QModelIndex index /* = QModelIndex */) … … 637 643 pItem->setData(UIPathOperations::mergePaths(pItem->parentItem()->path(), pItem->name()), UICustomFileSystemModelColumn_Path); 638 644 639 640 641 645 if (m_pTableProxyModel) 642 646 m_pTableProxyModel->invalidate(); … … 652 656 } 653 657 658 void 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 654 670 void UIVisoContentBrowser::reset() 655 671 { … … 657 673 } 658 674 659 Q Vector<UICustomFileSystemItem*> UIVisoContentBrowser::tableSelectedItems()660 { 661 Q Vector<UICustomFileSystemItem*> selectedItems;675 QList<UICustomFileSystemItem*> UIVisoContentBrowser::tableSelectedItems() 676 { 677 QList<UICustomFileSystemItem*> selectedItems; 662 678 if (!m_pTableProxyModel) 663 679 return selectedItems; … … 665 681 if (!selectionModel || selectionModel->selectedIndexes().isEmpty()) 666 682 return selectedItems; 667 QModelIndexList list = selectionModel->selected Indexes();683 QModelIndexList list = selectionModel->selectedRows(); 668 684 foreach (QModelIndex index, list) 669 685 { -
trunk/src/VBox/Frontends/VirtualBox/src/medium/viso/UIVisoContentBrowser.h
r76730 r76750 78 78 void sltHandleRemoveItems(); 79 79 void sltHandleTableSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected); 80 void sltHandleResetAction(); 80 81 81 82 private: … … 91 92 void updateStartItemName(); 92 93 void renameFileObject(UICustomFileSystemItem *pItem); 94 void removeItems(const QList<UICustomFileSystemItem*> itemList); 93 95 /** Creates and entry for pItem consisting of a map item (key is iso path and value is host file system path) 94 96 * if @p bRemove is true then the value is the string ":remove:" which effectively removes the file object … … 98 100 /** Returns a list of items which are currecntly selected 99 101 * in the table view. */ 100 QVector<UICustomFileSystemItem*> tableSelectedItems(); 102 QList<UICustomFileSystemItem*> tableSelectedItems(); 103 101 104 UICustomFileSystemModel *m_pModel; 102 105 UICustomFileSystemProxyModel *m_pTableProxyModel; -
trunk/src/VBox/Frontends/VirtualBox/src/medium/viso/UIVisoHostBrowser.cpp
r76730 r76750 101 101 m_pTitleLabel->setText(QApplication::translate("UIVisoCreator", "Host file system")); 102 102 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")); 104 104 } 105 105 … … 193 193 if (bShow) 194 194 { 195 m_pTableModel->setFilter(QDir::AllDirs | QDir::NoDotAndDotDot | QDir::Hidden);196 195 m_pTreeModel->setFilter(QDir::AllDirs | QDir::NoDotAndDotDot | QDir::Hidden); 196 m_pTableModel->setFilter(QDir::AllEntries | QDir::NoDot | QDir::Hidden | QDir::System); 197 197 } 198 198 else 199 199 { 200 m_pTableModel->setFilter(QDir::AllDirs | QDir::NoDotAndDotDot);201 200 m_pTreeModel->setFilter(QDir::AllDirs | QDir::NoDotAndDotDot); 201 m_pTableModel->setFilter(QDir::AllEntries | QDir::NoDot); 202 202 } 203 203 } … … 214 214 for (int i = 0; i < selectedIndices.size(); ++i) 215 215 { 216 pathList << m_pTableModel->filePath(selectedIndices[i]); 216 QString strPath = m_pTableModel->filePath(selectedIndices[i]); 217 if (strPath.contains("..")) 218 continue; 219 pathList << strPath; 217 220 } 218 221 emit sigAddObjectsToViso(pathList); -
trunk/src/VBox/Frontends/VirtualBox/src/medium/viso/UIVisoHostBrowser.h
r76730 r76750 55 55 virtual void setTableRootIndex(QModelIndex index = QModelIndex()) /* override */; 56 56 virtual void setTreeCurrentIndex(QModelIndex index = QModelIndex()) /* override */; 57 58 57 virtual void treeSelectionChanged(const QModelIndex &selectedTreeIndex) /* override */; 59 58
Note:
See TracChangeset
for help on using the changeset viewer.