Changeset 76309 in vbox for trunk/src/VBox
- Timestamp:
- Dec 20, 2018 8:59:24 AM (6 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/guestctrl
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UICustomFileSystemModel.cpp
r76303 r76309 53 53 UIFileTableItem::~UIFileTableItem() 54 54 { 55 qDeleteAll(m_childItems); 56 m_childItems.clear(); 55 reset(); 57 56 } 58 57 … … 63 62 m_childItems.append(item); 64 63 m_childMap.insert(item->name(), item); 64 } 65 66 void UIFileTableItem::reset() 67 { 68 qDeleteAll(m_childItems); 69 m_childItems.clear(); 70 m_childMap.clear(); 71 m_bIsOpened = false; 65 72 } 66 73 … … 280 287 , m_fShowHumanReadableSizes(false) 281 288 { 282 } 283 284 UIFileTableItem* UICustomFileSystemModel::rootItem() const 285 { 286 if (!m_pParent) 287 return 0; 288 return m_pParent->m_pRootItem; 289 initializeTree(); 290 } 291 292 UIFileTableItem* UICustomFileSystemModel::rootItem() 293 { 294 return m_pRootItem; 295 } 296 297 const UIFileTableItem* UICustomFileSystemModel::rootItem() const 298 { 299 return m_pRootItem; 289 300 } 290 301 291 302 UICustomFileSystemModel::~UICustomFileSystemModel() 292 {} 303 { 304 delete m_pRootItem; 305 } 293 306 294 307 int UICustomFileSystemModel::columnCount(const QModelIndex &parent) const … … 422 435 } 423 436 424 QModelIndex UICustomFileSystemModel::index(int row, int column, const QModelIndex &parent) 425 const 437 QModelIndex UICustomFileSystemModel::index(int row, int column, const QModelIndex &parent) const 426 438 { 427 439 if (!hasIndex(row, column, parent)) 428 440 return QModelIndex(); 429 441 430 UIFileTableItem *parentItem; 431 432 if (!parent.isValid()) 433 parentItem = rootItem(); 434 else 442 const UIFileTableItem* parentItem = rootItem(); 443 444 if (parent.isValid()) 435 445 parentItem = static_cast<UIFileTableItem*>(parent.internalPointer()); 446 436 447 if (!parentItem) 437 448 return QModelIndex(); … … 463 474 if (parent.column() > 0) 464 475 return 0; 465 UIFileTableItem *parentItem = 0; 466 if (!parent.isValid()) 467 parentItem = rootItem(); 468 else 476 const UIFileTableItem *parentItem = rootItem(); 477 if (parent.isValid()) 469 478 parentItem = static_cast<UIFileTableItem*>(parent.internalPointer()); 470 479 if (!parentItem) … … 496 505 } 497 506 507 void UICustomFileSystemModel::reset() 508 { 509 beginResetModel(); 510 m_pRootItem->reset(); 511 endResetModel(); 512 } 513 498 514 void UICustomFileSystemModel::setShowHumanReadableSizes(bool fShowHumanReadableSizes) 499 515 { … … 505 521 return m_fShowHumanReadableSizes; 506 522 } 523 524 void UICustomFileSystemModel::initializeTree() 525 { 526 QVector<QVariant> headData; 527 headData.resize(UICustomFileSystemModelColumn_Max); 528 m_pRootItem = new UIFileTableItem(headData, 0, KFsObjType_Directory); 529 } -
trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UICustomFileSystemModel.h
r76303 r76309 53 53 54 54 void appendChild(UIFileTableItem *child); 55 55 void reset(); 56 56 UIFileTableItem *child(int row) const; 57 57 /** Searches for the child by path and returns it if found. */ … … 141 141 /** UICustomFileSystemModel serves as the model for a file structure. 142 142 * it supports a tree level hierarchy which can be displayed with 143 * QTableView and/or QTreeView. Note the file structure data is not 144 * kept by the model but rather by the containing widget which also servers 145 * as the interface to functionality that this model provides.*/ 143 * QTableView and/or QTreeView. .*/ 146 144 class UICustomFileSystemModel : public QAbstractItemModel 147 145 { … … 170 168 void beginReset(); 171 169 void endReset(); 170 void reset(); 171 172 172 void setShowHumanReadableSizes(bool fShowHumanReadableSizes); 173 173 bool showHumanReadableSizes() const; 174 UIFileTableItem* rootItem(); 175 const UIFileTableItem* rootItem() const; 174 176 175 177 static const char* strUpDirectoryString; 176 178 177 179 private: 178 179 UIFileTableItem * rootItem() const;180 void initializeTree(); 181 UIFileTableItem *m_pRootItem; 180 182 void setupModelData(const QStringList &lines, UIFileTableItem *parent); 181 183 UIFileManagerTable *m_pParent; 182 UIFileTableItem *m_pRootItem;183 184 bool m_fShowHumanReadableSizes; 184 185 -
trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerGuestTable.cpp
r76301 r76309 286 286 if (m_comGuestSession.isNull()) 287 287 return; 288 if (! m_pRootItem || m_pRootItem->childCount() <= 0)289 return; 290 UIFileTableItem *startDirItem = m_pRootItem->child(0);288 if (!rootItem() || rootItem()->childCount() <= 0) 289 return; 290 UIFileTableItem *startDirItem = rootItem()->child(0); 291 291 if (!startDirItem) 292 292 return; -
trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerHostTable.cpp
r76300 r76309 294 294 void UIFileManagerHostTable::goToHomeDirectory() 295 295 { 296 if (! m_pRootItem || m_pRootItem->childCount() <= 0)297 return; 298 UIFileTableItem *startDirItem = m_pRootItem->child(0);296 if (!rootItem() || rootItem()->childCount() <= 0) 297 return; 298 UIFileTableItem *startDirItem = rootItem()->child(0); 299 299 if (!startDirItem) 300 300 return; -
trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerTable.cpp
r76301 r76309 511 511 :QIWithRetranslateUI<QWidget>(pParent) 512 512 , m_eFileOperationType(FileOperationType_None) 513 , m_pRootItem(0)514 513 , m_pLocationLabel(0) 515 514 , m_pPropertiesDialog(0) … … 528 527 UIFileManagerTable::~UIFileManagerTable() 529 528 { 530 delete m_pRootItem;531 529 } 532 530 … … 534 532 { 535 533 if (m_pModel) 536 m_pModel->beginReset(); 537 delete m_pRootItem; 538 m_pRootItem = 0; 539 if (m_pModel) 540 m_pModel->endReset(); 534 m_pModel->reset(); 535 541 536 if (m_pLocationComboBox) 542 537 { … … 680 675 void UIFileManagerTable::initializeFileTree() 681 676 { 682 if (m_pRootItem) 683 reset(); 684 685 /* Root item: */ 677 if (m_pModel) 678 m_pModel->reset(); 679 if (!rootItem()) 680 return; 681 686 682 const QString startPath("/"); 687 QVector<QVariant> headData;688 headData.resize(UICustomFileSystemModelColumn_Max);689 m_pRootItem = new UIFileTableItem(headData, 0, KFsObjType_Directory);690 683 UIFileTableItem* startItem = new UIFileTableItem(createTreeItemData(startPath, 4096, QDateTime(), 691 684 "" /* owner */, "" /* permissions */), 692 m_pRootItem, KFsObjType_Directory);685 rootItem(), KFsObjType_Directory); 693 686 startItem->setPath(startPath); 694 m_pRootItem->appendChild(startItem);687 rootItem()->appendChild(startItem); 695 688 startItem->setIsOpened(false); 696 689 populateStartDirectory(startItem); … … 1102 1095 void UIFileManagerTable::retranslateUi() 1103 1096 { 1104 if (m_pRootItem) 1105 { 1106 m_pRootItem->setData(UIFileManager::tr("Name"), UICustomFileSystemModelColumn_Name); 1107 m_pRootItem->setData(UIFileManager::tr("Size"), UICustomFileSystemModelColumn_Size); 1108 m_pRootItem->setData(UIFileManager::tr("Change Time"), UICustomFileSystemModelColumn_ChangeTime); 1109 m_pRootItem->setData(UIFileManager::tr("Owner"), UICustomFileSystemModelColumn_Owner); 1110 m_pRootItem->setData(UIFileManager::tr("Permissions"), UICustomFileSystemModelColumn_Permissions); 1097 UIFileTableItem *pRootItem = rootItem(); 1098 if (pRootItem) 1099 { 1100 pRootItem->setData(UIFileManager::tr("Name"), UICustomFileSystemModelColumn_Name); 1101 pRootItem->setData(UIFileManager::tr("Size"), UICustomFileSystemModelColumn_Size); 1102 pRootItem->setData(UIFileManager::tr("Change Time"), UICustomFileSystemModelColumn_ChangeTime); 1103 pRootItem->setData(UIFileManager::tr("Owner"), UICustomFileSystemModelColumn_Owner); 1104 pRootItem->setData(UIFileManager::tr("Permissions"), UICustomFileSystemModelColumn_Permissions); 1111 1105 } 1112 1106 if (m_pWarningLabel) … … 1175 1169 UIFileTableItem *UIFileManagerTable::getStartDirectoryItem() 1176 1170 { 1177 if (!m_pRootItem) 1171 UIFileTableItem* pRootItem = rootItem(); 1172 if (!pRootItem) 1178 1173 return 0; 1179 if ( m_pRootItem->childCount() <= 0)1174 if (pRootItem->childCount() <= 0) 1180 1175 return 0; 1181 return m_pRootItem->child(0);1176 return pRootItem->child(0); 1182 1177 } 1183 1178 … … 1250 1245 } 1251 1246 1252 1253 1247 QVector<QVariant> UIFileManagerTable::createTreeItemData(const QString &strName, ULONG64 size, const QDateTime &changeTime, 1254 1248 const QString &strOwner, const QString &strPermissions) … … 1262 1256 data[UICustomFileSystemModelColumn_Permissions] = strPermissions; 1263 1257 return data; 1258 } 1259 1260 UIFileTableItem* UIFileManagerTable::rootItem() 1261 { 1262 if (!m_pModel) 1263 return 0; 1264 return m_pModel->rootItem(); 1264 1265 } 1265 1266 -
trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerTable.h
r76301 r76309 256 256 QVector<QVariant> createTreeItemData(const QString &strName, ULONG64 size, const QDateTime &changeTime, 257 257 const QString &strOwner, const QString &strPermissions); 258 259 UIFileTableItem *m_pRootItem; 258 UIFileTableItem* rootItem(); 259 260 260 261 QILabel *m_pLocationLabel; 261 262 UIPropertiesDialog *m_pPropertiesDialog;
Note:
See TracChangeset
for help on using the changeset viewer.