Imported InfoWindow.cpp 1.14 from the OT repository: the "Disks" info window no
longer calculates the size by iterating over all files - it now just adds up the disk capacities. This fixes the userland part of bug #210 - the kernel part has already been fixed earlier. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16599 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -133,7 +133,8 @@ OpenParentAndSelectOriginal(const entry_ref *ref)
|
||||
|
||||
|
||||
static BWindow *
|
||||
OpenToolTipWindow(BRect rect, const char *name, const char *string, BMessenger target, BFont &font, BMessage *message)
|
||||
OpenToolTipWindow(BRect rect, const char *name, const char *string,
|
||||
BMessenger target, BFont &font, BMessage *message)
|
||||
{
|
||||
BWindow *window = new BWindow(rect, name, B_BORDERED_WINDOW_LOOK,
|
||||
B_FLOATING_ALL_WINDOW_FEEL,
|
||||
@@ -157,17 +158,17 @@ OpenToolTipWindow(BRect rect, const char *name, const char *string, BMessenger t
|
||||
|
||||
|
||||
BInfoWindow::BInfoWindow(Model *model, int32 group_index, LockingList<BWindow> *list)
|
||||
: BWindow(BInfoWindow::InfoWindowRect(false),
|
||||
"InfoWindow", B_TITLED_WINDOW,
|
||||
B_NOT_RESIZABLE | B_NOT_ZOOMABLE, B_CURRENT_WORKSPACE),
|
||||
fModel(model),
|
||||
fStopCalc(false),
|
||||
fIndex(group_index),
|
||||
fCalcThreadID(-1),
|
||||
fWindowList(list),
|
||||
fPermissionsView(NULL),
|
||||
fFilePanel(NULL),
|
||||
fFilePanelOpen(false)
|
||||
: BWindow(BInfoWindow::InfoWindowRect(false),
|
||||
"InfoWindow", B_TITLED_WINDOW,
|
||||
B_NOT_RESIZABLE | B_NOT_ZOOMABLE, B_CURRENT_WORKSPACE),
|
||||
fModel(model),
|
||||
fStopCalc(false),
|
||||
fIndex(group_index),
|
||||
fCalcThreadID(-1),
|
||||
fWindowList(list),
|
||||
fPermissionsView(NULL),
|
||||
fFilePanel(NULL),
|
||||
fFilePanelOpen(false)
|
||||
{
|
||||
SetPulseRate(1000000); // we use pulse to check freebytes on volume
|
||||
|
||||
@@ -261,7 +262,7 @@ BInfoWindow::Show()
|
||||
ResizeTo(windRect.Width(), windRect.Height());
|
||||
|
||||
// volume case is handled by view
|
||||
if (!TargetModel()->IsVolume()) {
|
||||
if (!TargetModel()->IsVolume() && !TargetModel()->IsRoot()) {
|
||||
if (TargetModel()->IsDirectory()) {
|
||||
// if this is a folder then spawn thread to calculate size
|
||||
SetSizeStr("calculating" B_UTF8_ELLIPSIS);
|
||||
@@ -586,7 +587,6 @@ BInfoWindow::CalcSize(void *castToWindow)
|
||||
return B_ERROR;
|
||||
|
||||
window->SetSizeStr("Error calculating folder size.");
|
||||
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
@@ -692,20 +692,20 @@ BInfoWindow::OpenFilePanel(const entry_ref *ref)
|
||||
|
||||
|
||||
AttributeView::AttributeView(BRect rect, Model *model)
|
||||
: BView(rect, "attr_view", B_FOLLOW_ALL_SIDES, B_WILL_DRAW | B_PULSE_NEEDED),
|
||||
fDivider(0),
|
||||
fPreferredAppMenu(NULL),
|
||||
fModel(model),
|
||||
fIconModel(model),
|
||||
fMouseDown(false),
|
||||
fDragging(false),
|
||||
fDoubleClick(false),
|
||||
fTrackingState(no_track),
|
||||
fIsDropTarget(false),
|
||||
fTitleEditView(NULL),
|
||||
fPathWindow(NULL),
|
||||
fLinkWindow(NULL),
|
||||
fDescWindow(NULL)
|
||||
: BView(rect, "attr_view", B_FOLLOW_ALL_SIDES, B_WILL_DRAW | B_PULSE_NEEDED),
|
||||
fDivider(0),
|
||||
fPreferredAppMenu(NULL),
|
||||
fModel(model),
|
||||
fIconModel(model),
|
||||
fMouseDown(false),
|
||||
fDragging(false),
|
||||
fDoubleClick(false),
|
||||
fTrackingState(no_track),
|
||||
fIsDropTarget(false),
|
||||
fTitleEditView(NULL),
|
||||
fPathWindow(NULL),
|
||||
fLinkWindow(NULL),
|
||||
fDescWindow(NULL)
|
||||
{
|
||||
// Set view color to standard background grey
|
||||
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||
@@ -1102,7 +1102,7 @@ AttributeView::MouseDown(BPoint point)
|
||||
} else if (fTitleEditView) {
|
||||
FinishEditingTitle(true);
|
||||
} else if (fSizeRect.Contains(point)) {
|
||||
if (fModel->IsDirectory() && !fModel->IsVolume()) {
|
||||
if (fModel->IsDirectory() && !fModel->IsVolume() && !fModel->IsRoot()) {
|
||||
InvertRect(fSizeRect);
|
||||
fTrackingState = size_track;
|
||||
} else
|
||||
@@ -1356,7 +1356,6 @@ AttributeView::OpenLinkTarget()
|
||||
BInfoWindow *window = dynamic_cast<BInfoWindow *>(Window());
|
||||
if (window)
|
||||
window->OpenFilePanel(fModel->EntryRef());
|
||||
|
||||
} else {
|
||||
entry_ref ref;
|
||||
entry.GetRef(&ref);
|
||||
@@ -1409,14 +1408,28 @@ AttributeView::MouseUp(BPoint point)
|
||||
void
|
||||
AttributeView::CheckAndSetSize()
|
||||
{
|
||||
if (fModel->IsVolume()) {
|
||||
BVolume volume(fModel->NodeRef()->device);
|
||||
off_t freeBytes = volume.FreeBytes();
|
||||
if (fModel->IsVolume() || fModel->IsRoot()) {
|
||||
off_t freeBytes = 0;
|
||||
off_t capacity = 0;
|
||||
|
||||
if (fModel->IsVolume()) {
|
||||
BVolume volume(fModel->NodeRef()->device);
|
||||
freeBytes = volume.FreeBytes();
|
||||
capacity = volume.Capacity();
|
||||
} else {
|
||||
// iterate over all volumes
|
||||
BVolumeRoster volumeRoster;
|
||||
BVolume volume;
|
||||
while (volumeRoster.GetNextVolume(&volume) == B_OK) {
|
||||
freeBytes += volume.FreeBytes();
|
||||
capacity += volume.Capacity();
|
||||
}
|
||||
}
|
||||
|
||||
if (fFreeBytes == freeBytes)
|
||||
return;
|
||||
|
||||
fFreeBytes = freeBytes;
|
||||
off_t capacity = volume.Capacity();
|
||||
char buffer[500];
|
||||
if (capacity >= kGBSize)
|
||||
sprintf(buffer, "%.1f G", (float)capacity / kGBSize);
|
||||
@@ -1478,7 +1491,6 @@ AttributeView::MessageReceived(BMessage *message)
|
||||
|
||||
fModel->SetPreferredAppSignature(newSignature);
|
||||
nodeInfo.SetPreferredApp(newSignature);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1557,7 +1569,7 @@ AttributeView::Draw(BRect)
|
||||
|
||||
// Capacity/size
|
||||
SetHighColor(kAttrTitleColor);
|
||||
if (fModel->IsVolume()) {
|
||||
if (fModel->IsVolume() || fModel->IsRoot()) {
|
||||
MovePenTo(BPoint(fDivider - (StringWidth("Capacity:")), lineBase));
|
||||
DrawString("Capacity:");
|
||||
} else {
|
||||
@@ -1909,13 +1921,15 @@ AttributeView::BuildContextMenu(BMenu *parent)
|
||||
parent->AddItem(new BMenuItem("Empty Trash", new BMessage(kEmptyTrash)));
|
||||
|
||||
BMenuItem *sizeItem = NULL;
|
||||
if (model.IsDirectory() && !model.IsVolume())
|
||||
if (model.IsDirectory() && !model.IsVolume() && !model.IsRoot()) {
|
||||
parent->AddItem(sizeItem = new BMenuItem("Recalculate Folder Size",
|
||||
new BMessage(kRecalculateSize)));
|
||||
}
|
||||
|
||||
if (model.IsSymLink())
|
||||
if (model.IsSymLink()) {
|
||||
parent->AddItem(sizeItem = new BMenuItem("Set new link target",
|
||||
new BMessage(kSetLinkTarget)));
|
||||
}
|
||||
|
||||
parent->AddItem(new BSeparatorItem());
|
||||
parent->AddItem(new BMenuItem("Permissions", new BMessage(kPermissionsSelected), 'P'));
|
||||
@@ -1997,10 +2011,10 @@ AttributeView::SetSizeStr(const char *sizeStr)
|
||||
|
||||
|
||||
TrackingView::TrackingView(BRect frame, const char *str, const BFont *font, BMessage *message)
|
||||
: BControl(frame, "trackingView", str, message, B_FOLLOW_ALL, B_WILL_DRAW),
|
||||
fMouseDown(false),
|
||||
fMouseInView(false),
|
||||
fFont(*font)
|
||||
: BControl(frame, "trackingView", str, message, B_FOLLOW_ALL, B_WILL_DRAW),
|
||||
fMouseDown(false),
|
||||
fMouseInView(false),
|
||||
fFont(*font)
|
||||
{
|
||||
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||
SetEventMask(B_POINTER_EVENTS, 0);
|
||||
@@ -2035,7 +2049,9 @@ void
|
||||
TrackingView::MouseUp(BPoint)
|
||||
{
|
||||
if (Message() != NULL) {
|
||||
if (fMouseInView) Invoke();
|
||||
if (fMouseInView)
|
||||
Invoke();
|
||||
|
||||
fMouseDown = false;
|
||||
Window()->Close();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user