void CDirstatDoc::SetWorkingItemAncestor(CItem *item) { if (m_workingItem != NULL) SetWorkingItem(CItem::FindCommonAncestor(m_workingItem, item)); else SetWorkingItem(item); }
void CDirstatDoc::OnViewShowunknown() { CArray<CItem *, CItem *> drives; GetDriveItems(drives); if (m_showUnknown) { for (int i=0; i < drives.GetSize(); i++) { CItem *unknown= drives[i]->FindUnknownItem(); ASSERT(unknown != NULL); if (GetSelection() == unknown) SetSelection(unknown->GetParent()); if (GetZoomItem() == unknown) m_zoomItem= unknown->GetParent(); drives[i]->RemoveUnknownItem(); } m_showUnknown= false; } else { for (int i=0; i < drives.GetSize(); i++) drives[i]->CreateUnknownItem(); m_showUnknown= true; } if (drives.GetSize() > 0) SetWorkingItem(GetRootItem()); UpdateAllViews(NULL); }
void CDirstatDoc::OnViewShowfreespace() { CArray<CItem *, CItem *> drives; GetDriveItems(drives); if (m_showFreeSpace) { for (int i=0; i < drives.GetSize(); i++) { CItem *free= drives[i]->FindFreeSpaceItem(); ASSERT(free != NULL); if (GetSelection() == free) SetSelection(free->GetParent()); if (GetZoomItem() == free) m_zoomItem= free->GetParent(); drives[i]->RemoveFreeSpaceItem(); } m_showFreeSpace= false; } else { for (int i=0; i < drives.GetSize(); i++) drives[i]->CreateFreeSpaceItem(); m_showFreeSpace= true; } if (drives.GetSize() > 0) SetWorkingItem(GetRootItem()); UpdateAllViews(NULL); }
void CDirstatDoc::DeleteContents() { delete m_rootItem; m_rootItem= NULL; SetWorkingItem(NULL); m_zoomItem= NULL; m_selectedItem= NULL; GetApp()->ReReadMountPoints(); }
void CDirstatDoc::RefreshRecyclers() { CArray<CItem *, CItem *> drives; GetDriveItems(drives); for (int i=0; i < drives.GetSize(); i++) { drives[i]->RefreshRecycler(); } SetWorkingItem(GetRootItem()); }
void CDirstatDoc::OnCleanupDelete() { CItem *item= GetSelection(); if (item == NULL || item->GetType() != IT_DIRECTORY && item->GetType() != IT_FILE || item->IsRootItem()) return; if (DeletePhysicalItem(item, false)) { SetWorkingItem(GetRootItem()); UpdateAllViews(NULL); } }
void CDirstatDoc::OnCleanupDelete() { // FIXME: Multi-select CItem *item = GetSelection(0); if(NULL == item || item->GetType() != IT_DIRECTORY && item->GetType() != IT_FILE || item->IsRootItem()) { return; } if(DeletePhysicalItem(item, false)) { SetWorkingItem(GetRootItem()); UpdateAllViews(NULL); } }
// This method does some work for ticks ms. // return: true if done or suspended. // bool CDirstatDoc::Work(DWORD ticks) { if(NULL == m_rootItem) { return true; } if(GetMainFrame()->IsProgressSuspended()) { return true; } if(!m_rootItem->IsDone()) { m_rootItem->DoSomeWork(ticks); if(m_rootItem->IsDone()) { m_extensionDataValid = false; GetMainFrame()->SetProgressPos100(); GetMainFrame()->RestoreTypeView(); GetMainFrame()->RestoreGraphView(); UpdateAllViews(NULL); } else { ASSERT(m_workingItem != NULL); if(m_workingItem != NULL) // to be honest, "defensive programming" is stupid, but c'est la vie: it's safer. { GetMainFrame()->SetProgressPos(m_workingItem->GetProgressPos()); } UpdateAllViews(NULL, HINT_SOMEWORKDONE); } } if(m_rootItem->IsDone()) { SetWorkingItem(NULL); return true; } else { return false; } }
// Starts a refresh of an item. // If the physical item has been deleted, // updates selection, zoom and working item accordingly. // void CDirstatDoc::RefreshItem(CItem *item) { ASSERT(item != NULL); CWaitCursor wc; ClearReselectChildStack(); if(item->IsAncestorOf(GetZoomItem())) { SetZoomItem(item); } // FIXME: Multi-select if(item->IsAncestorOf(GetSelection(0))) { SetSelection(item); UpdateAllViews(NULL, HINT_SELECTIONCHANGED); } SetWorkingItemAncestor(item); CItem *parent = item->GetParent(); if(!item->StartRefresh()) { if(GetZoomItem() == item) { SetZoomItem(parent); } // FIXME: Multi-select if(GetSelection(0) == item) { SetSelection(parent); UpdateAllViews(NULL, HINT_SELECTIONCHANGED); } if(m_workingItem == item) { SetWorkingItem(parent); } } UpdateAllViews(NULL); }
BOOL CDirstatDoc::OnOpenDocument(LPCTSTR lpszPathName) { CDocument::OnNewDocument(); // --> DeleteContents() CString spec= lpszPathName; CString folder; CStringArray drives; DecodeSelection(spec, folder, drives); CStringArray rootFolders; if (drives.GetSize() > 0) { m_showMyComputer= (drives.GetSize() > 1); for (int i=0; i < drives.GetSize(); i++) rootFolders.Add(drives[i]); } else { ASSERT(!folder.IsEmpty()); m_showMyComputer= false; rootFolders.Add(folder); } CArray<CItem *, CItem *> driveItems; if (m_showMyComputer) { m_rootItem= new CItem((ITEMTYPE)(IT_MYCOMPUTER|ITF_ROOTITEM), LoadString(IDS_MYCOMPUTER)); for (int i=0; i < rootFolders.GetSize(); i++) { CItem *drive= new CItem(IT_DRIVE, rootFolders[i]); driveItems.Add(drive); m_rootItem->AddChild(drive); } } else { ITEMTYPE type= IsDrive(rootFolders[0]) ? IT_DRIVE : IT_DIRECTORY; m_rootItem= new CItem((ITEMTYPE)(type|ITF_ROOTITEM), rootFolders[0], false); if (m_rootItem->GetType() == IT_DRIVE) driveItems.Add(m_rootItem); m_rootItem->UpdateLastChange(); } m_zoomItem= m_rootItem; for (int i=0; i < driveItems.GetSize(); i++) { if (OptionShowFreeSpace()) driveItems[i]->CreateFreeSpaceItem(); if (OptionShowUnknown()) driveItems[i]->CreateUnknownItem(); } SetWorkingItem(m_rootItem); GetMainFrame()->MinimizeGraphView(); GetMainFrame()->MinimizeTypeView(); UpdateAllViews(NULL, HINT_NEWROOT); return true; }