void PanelView::ReadDisks(void) //////////////////////////////////////////////////////////////////////// { char drivename[256]; char drivepath[256]; // SetMousePointer(CR_HOURGLASS); MAINWINDOW->SetMousePointer(GenesisWindow::CR_HOURGLASS); CustomListItem *item; item = new CustomListItem("..",m_Path.String(),FT_DISKBACK, 0); item->AddIcon(m_ParentIcon); m_CustomListView->AddItem(item); item->SetHeight(15.0f); // Collect available volumes... BVolumeRoster *vr = new BVolumeRoster(); if (vr) { BVolume v; while (vr->GetNextVolume(&v)==B_NO_ERROR) { if (v.GetName(drivename)==B_NO_ERROR) { if (strlen(drivename)>0) { BDirectory dir; BEntry entry; BPath path; v.GetRootDirectory(&dir); dir.GetEntry(&entry); entry.GetPath(&path); sprintf(drivepath,"%s",path.Path()); item = new CustomListItem(drivename,drivepath,FT_DISKITEM,v.FreeBytes(),v.Capacity(),v.Device()); m_CustomListView->AddItem(item); if (m_Setting_ShowIcons) { if (!item->GetIcon(&v)) item->AddIcon(m_UnknownIcon); item->SetHeight(15.0f); } } } } delete vr; } m_CustomListView->DoSortList(); m_CustomListView->Select(0,false); // SetMousePointer(CR_DEFAULT); MAINWINDOW->SetMousePointer(GenesisWindow::CR_DEFAULT); }
void PanelView::RescanAttr(node_ref nref) //////////////////////////////////////////////////////////////////////// { if (m_PanelMode != PM_NORMAL) return; CustomListItem *item = m_CustomListView->FindItemByNodeRef(nref); if (item) { BString fullentryname(m_Path); fullentryname << "/" << item->m_FileName; item->GetIcon(fullentryname.String()); m_CustomListView->InvalidateItem(m_CustomListView->IndexOf(item)); m_CurrentTotalSize = m_CustomListView->GetCurrentTotalSize(); SelectionChanged(); } }
CustomListItem *PanelView::AddDirectoryEntry(BEntry *entry, bool sorted) //////////////////////////////////////////////////////////////////////// { CustomListItem *item; char name[B_FILE_NAME_LENGTH]; entry->GetName(name); if (entry->IsDirectory()) { item = new CustomListItem(name,m_Path.String(),FT_DIRECTORY, 0, this); if (sorted) m_CustomListView->AddSortedItem(item); else m_CustomListView->AddItem(item); if (m_Setting_ShowIcons) { if (!item->GetIcon(entry)) item->AddIcon(m_UnknownIcon); item->SetHeight(15.0f); } } else if (entry->IsSymLink()) { BEntry symlinkentry; entry_ref ref; struct stat statbuf; entry->GetRef(&ref); if (symlinkentry.SetTo(&ref, true)==B_OK) { if (symlinkentry.IsDirectory()) { item = new CustomListItem(name,m_Path.String(),FT_SYMLINKDIR, 0, this); if (sorted) m_CustomListView->AddSortedItem(item); else m_CustomListView->AddItem(item); if (m_Setting_ShowIcons) { if (!item->GetIcon(&symlinkentry)) item->AddIcon(m_UnknownIcon); item->SetHeight(15.0f); } } else { symlinkentry.GetStat(&statbuf); item = new CustomListItem(name,m_Path.String(),FT_SYMLINKFILE,statbuf.st_size, this); if (sorted) m_CustomListView->AddSortedItem(item); else m_CustomListView->AddItem(item); if (m_Setting_ShowIcons) { if (!item->GetIcon(&symlinkentry)) item->AddIcon(m_UnknownIcon); item->SetHeight(15.0f); } } } else { // Broken link... item = new CustomListItem(name, m_Path.String(), FT_SYMLINKBROKEN, 0 , this); if (sorted) m_CustomListView->AddSortedItem(item); else m_CustomListView->AddItem(item); if (m_Setting_ShowIcons) { if (!item->GetIcon(entry)) item->AddIcon(m_UnknownIcon); item->SetHeight(15.0f); } } } else { struct stat statbuf; entry->GetStat(&statbuf); item = new CustomListItem(name,m_Path.String(),FT_FILE,statbuf.st_size, this); if (sorted) m_CustomListView->AddSortedItem(item); else m_CustomListView->AddItem(item); if (m_Setting_ShowIcons) { if (!item->GetIcon(entry)) item->AddIcon(m_UnknownIcon); item->SetHeight(15.0f); } } return item; }