* Now listens to disk device notifications, and rescans its device list when

something comes in -- this could be greatly improved, though.
* Cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29583 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2009-03-18 08:56:49 +00:00
parent 3f78b216ad
commit a7ea0713b4
6 changed files with 121 additions and 116 deletions
+22 -19
View File
@@ -1,10 +1,11 @@
/* /*
* Copyright 2007-2008 Haiku Inc. All rights reserved. * Copyright 2007-2009 Haiku Inc. All rights reserved.
* Distributed under the terms of the MIT license. * Distributed under the terms of the MIT license.
* *
* Authors: * Authors:
* Stephan Aßmus <[email protected]> * Stephan Aßmus <[email protected]>
*/ */
#include "DiskView.h" #include "DiskView.h"
#include "MainWindow.h" #include "MainWindow.h"
@@ -28,14 +29,14 @@ class PartitionView : public BView {
public: public:
PartitionView(const char* name, float weight, off_t offset, PartitionView(const char* name, float weight, off_t offset,
int32 level, partition_id id) int32 level, partition_id id)
: BView(name, B_WILL_DRAW | B_SUPPORTS_LAYOUT | B_FULL_UPDATE_ON_RESIZE) : BView(name, B_WILL_DRAW | B_SUPPORTS_LAYOUT | B_FULL_UPDATE_ON_RESIZE),
, fID(id) fID(id),
, fWeight(weight) fWeight(weight),
, fOffset(offset) fOffset(offset),
, fLevel(level) fLevel(level),
, fSelected(false) fSelected(false),
, fMouseOver(false) fMouseOver(false),
, fGroupLayout(new BGroupLayout(B_HORIZONTAL, kLayoutInset)) fGroupLayout(new BGroupLayout(B_HORIZONTAL, kLayoutInset))
{ {
SetLayout(fGroupLayout); SetLayout(fGroupLayout);
@@ -184,10 +185,11 @@ private:
class DiskView::PartitionLayout : public BDiskDeviceVisitor { class DiskView::PartitionLayout : public BDiskDeviceVisitor {
public: public:
PartitionLayout(BView* view, SpaceIDMap& spaceIDMap) PartitionLayout(BView* view, SpaceIDMap& spaceIDMap)
: fView(view) :
, fViewMap() fView(view),
, fSelectedPartition(-1) fViewMap(),
, fSpaceIDMap(spaceIDMap) fSelectedPartition(-1),
fSpaceIDMap(spaceIDMap)
{ {
} }
@@ -273,7 +275,7 @@ public:
// TODO: remove again once Disk Device API is fixed // TODO: remove again once Disk Device API is fixed
if (!is_valid_partitionable_space(size)) if (!is_valid_partitionable_space(size))
continue; continue;
// //
double scale = (double)size / parentSize; double scale = (double)size / parentSize;
partition_id id partition_id id
= fSpaceIDMap.SpaceIDFor(partition->ID(), offset); = fSpaceIDMap.SpaceIDFor(partition->ID(), offset);
@@ -319,11 +321,11 @@ public:
DiskView::DiskView(const BRect& frame, uint32 resizeMode, DiskView::DiskView(const BRect& frame, uint32 resizeMode,
SpaceIDMap& spaceIDMap) SpaceIDMap& spaceIDMap)
: Inherited(frame, "diskview", resizeMode, : Inherited(frame, "diskview", resizeMode,
B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE) B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE),
, fDiskCount(0) fDiskCount(0),
, fDisk(NULL) fDisk(NULL),
, fSpaceIDMap(spaceIDMap) fSpaceIDMap(spaceIDMap),
, fPartitionLayout(new PartitionLayout(this, fSpaceIDMap)) fPartitionLayout(new PartitionLayout(this, fSpaceIDMap))
{ {
BGroupLayout* layout = new BGroupLayout(B_HORIZONTAL, kLayoutInset); BGroupLayout* layout = new BGroupLayout(B_HORIZONTAL, kLayoutInset);
SetLayout(layout); SetLayout(layout);
@@ -415,6 +417,7 @@ DiskView::SetDiskCount(int32 count)
fDiskCount = count; fDiskCount = count;
} }
void void
DiskView::SetDisk(BDiskDevice* disk, partition_id selectedPartition) DiskView::SetDisk(BDiskDevice* disk, partition_id selectedPartition)
{ {
+15 -16
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2007 Haiku Inc. All rights reserved. * Copyright 2002-2009 Haiku Inc. All rights reserved.
* Distributed under the terms of the MIT license. * Distributed under the terms of the MIT license.
* *
* Authors: * Authors:
@@ -7,6 +7,7 @@
* Ithamar R. Adema <[email protected]> * Ithamar R. Adema <[email protected]>
* Stephan Aßmus <[email protected]> * Stephan Aßmus <[email protected]>
*/ */
#include "DriveSetup.h" #include "DriveSetup.h"
#include "MainWindow.h" #include "MainWindow.h"
@@ -18,22 +19,10 @@
#include <Path.h> #include <Path.h>
int
main(int, char**)
{
DriveSetup app;
app.Run();
return 0;
}
// #pragma mark -
DriveSetup::DriveSetup() DriveSetup::DriveSetup()
: BApplication("application/x-vnd.Haiku-DriveSetup") : BApplication("application/x-vnd.Haiku-DriveSetup"),
, fWindow(NULL) fWindow(NULL),
, fSettings(0UL) fSettings(0UL)
{ {
} }
@@ -152,3 +141,13 @@ DriveSetup::_GetSettingsFile(BFile& file, bool forWriting) const
} }
// #pragma mark -
int
main(int, char**)
{
DriveSetup app;
app.Run();
return 0;
}
+10 -16
View File
@@ -1,10 +1,11 @@
/* /*
* Copyright 2008 Haiku Inc. All rights reserved. * Copyright 2008-2009 Haiku Inc. All rights reserved.
* Distributed under the terms of the MIT license. * Distributed under the terms of the MIT license.
* *
* Authors: * Authors:
* Stephan Aßmus <[email protected]> * Stephan Aßmus <[email protected]>
*/ */
#include "InitParamsPanel.h" #include "InitParamsPanel.h"
#include <stdio.h> #include <stdio.h>
@@ -27,7 +28,7 @@ class InitParamsPanel::EscapeFilter : public BMessageFilter {
public: public:
EscapeFilter(InitParamsPanel* target) EscapeFilter(InitParamsPanel* target)
: BMessageFilter(B_ANY_DELIVERY, B_ANY_SOURCE), : BMessageFilter(B_ANY_DELIVERY, B_ANY_SOURCE),
fPanel(target) fPanel(target)
{ {
} }
virtual ~EscapeFilter() virtual ~EscapeFilter()
@@ -68,15 +69,14 @@ enum {
}; };
InitParamsPanel::InitParamsPanel(BWindow* window) InitParamsPanel::InitParamsPanel(BWindow* window)
: BWindow(BRect(300.0, 200.0, 600.0, 300.0), 0, B_MODAL_WINDOW_LOOK, : BWindow(BRect(300.0, 200.0, 600.0, 300.0), 0, B_MODAL_WINDOW_LOOK,
B_MODAL_SUBSET_WINDOW_FEEL, B_MODAL_SUBSET_WINDOW_FEEL,
B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS) B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS),
, fEscapeFilter(new EscapeFilter(this)) fEscapeFilter(new EscapeFilter(this)),
, fExitSemaphore(create_sem(0, "InitParamsPanel exit")) fExitSemaphore(create_sem(0, "InitParamsPanel exit")),
, fWindow(window) fWindow(window),
, fReturnValue(GO_CANCELED) fReturnValue(GO_CANCELED)
{ {
AddCommonFilter(fEscapeFilter); AddCommonFilter(fEscapeFilter);
@@ -211,7 +211,7 @@ InitParamsPanel::Go(BString& name, BString& parameters)
B_CAN_INTERRUPT | B_RELATIVE_TIMEOUT, 50000); B_CAN_INTERRUPT | B_RELATIVE_TIMEOUT, 50000);
if (err != B_TIMED_OUT && err != B_INTERRUPTED) if (err != B_TIMED_OUT && err != B_INTERRUPTED)
break; break;
fWindow->UpdateIfNeeded(); fWindow->UpdateIfNeeded();
} }
if (!Lock()) if (!Lock())
@@ -226,7 +226,7 @@ InitParamsPanel::Go(BString& name, BString& parameters)
if (!message || message->FindString("size", &size) < B_OK) if (!message || message->FindString("size", &size) < B_OK)
size = "2048"; size = "2048";
// TODO: use libroot driver settings API // TODO: use libroot driver settings API
parameters << "block_size " << size << ";\n"; parameters << "block_size " << size << ";\n";
} }
} }
@@ -245,9 +245,3 @@ InitParamsPanel::Cancel()
fReturnValue = GO_CANCELED; fReturnValue = GO_CANCELED;
release_sem(fExitSemaphore); release_sem(fExitSemaphore);
} }
+46 -38
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2008 Haiku Inc. All rights reserved. * Copyright 2002-2009 Haiku Inc. All rights reserved.
* Distributed under the terms of the MIT license. * Distributed under the terms of the MIT license.
* *
* Authors: * Authors:
@@ -7,6 +7,7 @@
* Ithamar R. Adema <[email protected]> * Ithamar R. Adema <[email protected]>
* Stephan Aßmus <[email protected]> * Stephan Aßmus <[email protected]>
*/ */
#include "MainWindow.h" #include "MainWindow.h"
#include "DiskView.h" #include "DiskView.h"
#include "InitParamsPanel.h" #include "InitParamsPanel.h"
@@ -37,9 +38,10 @@ class ListPopulatorVisitor : public BDiskDeviceVisitor {
public: public:
ListPopulatorVisitor(PartitionListView* list, int32& diskCount, ListPopulatorVisitor(PartitionListView* list, int32& diskCount,
SpaceIDMap& spaceIDMap) SpaceIDMap& spaceIDMap)
: fPartitionList(list) :
, fDiskCount(diskCount) fPartitionList(list),
, fSpaceIDMap(spaceIDMap) fDiskCount(diskCount),
fSpaceIDMap(spaceIDMap)
{ {
fDiskCount = 0; fDiskCount = 0;
fSpaceIDMap.Clear(); fSpaceIDMap.Clear();
@@ -88,7 +90,7 @@ private:
// TODO: remove again once Disk Device API is fixed // TODO: remove again once Disk Device API is fixed
if (!is_valid_partitionable_space(size)) if (!is_valid_partitionable_space(size))
continue; continue;
// //
partition_id id = fSpaceIDMap.SpaceIDFor(parentID, offset); partition_id id = fSpaceIDMap.SpaceIDFor(parentID, offset);
fPartitionList->AddSpace(parentID, id, offset, size); fPartitionList->AddSpace(parentID, id, offset, size);
} }
@@ -145,10 +147,10 @@ enum {
MainWindow::MainWindow(BRect frame) MainWindow::MainWindow(BRect frame)
: BWindow(frame, "DriveSetup", B_DOCUMENT_WINDOW, : BWindow(frame, "DriveSetup", B_DOCUMENT_WINDOW,
B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE) B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE),
, fCurrentDisk(NULL) fCurrentDisk(NULL),
, fCurrentPartitionID(-1) fCurrentPartitionID(-1),
, fSpaceIDMap() fSpaceIDMap()
{ {
BMenuBar* menuBar = new BMenuBar(Bounds(), "root menu"); BMenuBar* menuBar = new BMenuBar(Bounds(), "root menu");
@@ -161,7 +163,7 @@ MainWindow::MainWindow(BRect frame)
fDeleteMI = new BMenuItem("Delete (not implemented)", fDeleteMI = new BMenuItem("Delete (not implemented)",
new BMessage(MSG_DELETE)); new BMessage(MSG_DELETE));
fDeleteMI->SetEnabled(false); fDeleteMI->SetEnabled(false);
fMountMI = new BMenuItem("Mount", new BMessage(MSG_MOUNT), 'M'); fMountMI = new BMenuItem("Mount", new BMessage(MSG_MOUNT), 'M');
fUnmountMI = new BMenuItem("Unmount", new BMessage(MSG_UNMOUNT), 'U'); fUnmountMI = new BMenuItem("Unmount", new BMessage(MSG_UNMOUNT), 'U');
@@ -170,38 +172,37 @@ fDeleteMI->SetEnabled(false);
// Disk menu // Disk menu
fDiskMenu = new BMenu("Disk"); fDiskMenu = new BMenu("Disk");
fDiskMenu->AddItem(fFormatMI); fDiskMenu->AddItem(fFormatMI);
fDiskMenu->AddItem(fEjectMI); fDiskMenu->AddItem(fEjectMI);
fDiskMenu->AddItem(fSurfaceTestMI); fDiskMenu->AddItem(fSurfaceTestMI);
fDiskMenu->AddSeparatorItem(); fDiskMenu->AddSeparatorItem();
fDiskMenu->AddItem(fRescanMI); fDiskMenu->AddItem(fRescanMI);
menuBar->AddItem(fDiskMenu); menuBar->AddItem(fDiskMenu);
// Parition menu // Parition menu
fPartitionMenu = new BMenu("Partition"); fPartitionMenu = new BMenu("Partition");
fCreateMenu = new BMenu("Create (not implemented)"); fCreateMenu = new BMenu("Create (not implemented)");
fPartitionMenu->AddItem(fCreateMenu); fPartitionMenu->AddItem(fCreateMenu);
fInitMenu = new BMenu("Initialize"); fInitMenu = new BMenu("Initialize");
fPartitionMenu->AddItem(fInitMenu); fPartitionMenu->AddItem(fInitMenu);
fPartitionMenu->AddItem(fDeleteMI); fPartitionMenu->AddItem(fDeleteMI);
fPartitionMenu->AddSeparatorItem(); fPartitionMenu->AddSeparatorItem();
fPartitionMenu->AddItem(fMountMI); fPartitionMenu->AddItem(fMountMI);
fPartitionMenu->AddItem(fUnmountMI); fPartitionMenu->AddItem(fUnmountMI);
fPartitionMenu->AddSeparatorItem(); fPartitionMenu->AddSeparatorItem();
fPartitionMenu->AddItem(fMountAllMI); fPartitionMenu->AddItem(fMountAllMI);
menuBar->AddItem(fPartitionMenu); menuBar->AddItem(fPartitionMenu);
AddChild(menuBar); AddChild(menuBar);
// add DiskView // add DiskView
BRect r(Bounds()); BRect r(Bounds());
r.top = menuBar->Frame().bottom + 1; r.top = menuBar->Frame().bottom + 1;
@@ -221,6 +222,8 @@ fDeleteMI->SetEnabled(false);
fListView->SetSelectionMessage(new BMessage(MSG_PARTITION_ROW_SELECTED)); fListView->SetSelectionMessage(new BMessage(MSG_PARTITION_ROW_SELECTED));
fListView->SetTarget(this); fListView->SetTarget(this);
BDiskDeviceRoster().StartWatching(this);
// populate the Initialiaze menu with the available file systems // populate the Initialiaze menu with the available file systems
_ScanFileSystems(); _ScanFileSystems();
@@ -231,6 +234,7 @@ fDeleteMI->SetEnabled(false);
MainWindow::~MainWindow() MainWindow::~MainWindow()
{ {
BDiskDeviceRoster().StopWatching(this);
delete fCurrentDisk; delete fCurrentDisk;
} }
@@ -281,6 +285,9 @@ MainWindow::MessageReceived(BMessage* message)
case MSG_SURFACE_TEST: case MSG_SURFACE_TEST:
printf("MSG_SURFACE_TEST\n"); printf("MSG_SURFACE_TEST\n");
break; break;
// TODO: this could probably be done better!
case B_DEVICE_UPDATE:
case MSG_RESCAN: case MSG_RESCAN:
_ScanDrives(); _ScanDrives();
break; break;
@@ -309,7 +316,7 @@ MainWindow::MessageReceived(BMessage* message)
} }
bool bool
MainWindow::QuitRequested() MainWindow::QuitRequested()
{ {
// TODO: ask about any unsaved changes // TODO: ask about any unsaved changes
@@ -327,7 +334,7 @@ MainWindow::StoreSettings(BMessage* archive) const
{ {
if (archive->ReplaceRect("window frame", Frame()) < B_OK) if (archive->ReplaceRect("window frame", Frame()) < B_OK)
archive->AddRect("window frame", Frame()); archive->AddRect("window frame", Frame());
BMessage columnSettings; BMessage columnSettings;
fListView->SaveState(&columnSettings); fListView->SaveState(&columnSettings);
if (archive->ReplaceMessage("column settings", &columnSettings) < B_OK) if (archive->ReplaceMessage("column settings", &columnSettings) < B_OK)
@@ -425,7 +432,7 @@ MainWindow::_AdaptToSelectedPartition()
= dynamic_cast<PartitionListRow*>(_topLevelRow); = dynamic_cast<PartitionListRow*>(_topLevelRow);
PartitionListRow* selectedRow PartitionListRow* selectedRow
= dynamic_cast<PartitionListRow*>(_selectedRow); = dynamic_cast<PartitionListRow*>(_selectedRow);
if (topLevelRow) if (topLevelRow)
diskID = topLevelRow->ID(); diskID = topLevelRow->ID();
if (selectedRow) { if (selectedRow) {
@@ -482,10 +489,10 @@ MainWindow::_EnabledDisableMenuItems(BDiskDevice* disk,
fPartitionMenu->SetEnabled(false); fPartitionMenu->SetEnabled(false);
} else { } else {
// fFormatMI->SetEnabled(true); // fFormatMI->SetEnabled(true);
fFormatMI->SetEnabled(false); fFormatMI->SetEnabled(false);
fEjectMI->SetEnabled(disk->IsRemovableMedia()); fEjectMI->SetEnabled(disk->IsRemovableMedia());
// fSurfaceTestMI->SetEnabled(true); // fSurfaceTestMI->SetEnabled(true);
fSurfaceTestMI->SetEnabled(false); fSurfaceTestMI->SetEnabled(false);
// Create menu and items // Create menu and items
fPartitionMenu->SetEnabled(true); fPartitionMenu->SetEnabled(true);
@@ -524,16 +531,16 @@ fSurfaceTestMI->SetEnabled(false);
if (partition) { if (partition) {
fInitMenu->SetEnabled(!partition->IsMounted()); fInitMenu->SetEnabled(!partition->IsMounted());
// fDeleteMI->SetEnabled(!partition->IsMounted()); // fDeleteMI->SetEnabled(!partition->IsMounted());
fDeleteMI->SetEnabled(false); fDeleteMI->SetEnabled(false);
fMountMI->SetEnabled(!partition->IsMounted()); fMountMI->SetEnabled(!partition->IsMounted());
bool unMountable = false; bool unMountable = false;
if (partition->IsMounted()) { if (partition->IsMounted()) {
// see if this partition is the boot volume // see if this partition is the boot volume
BVolume volume; BVolume volume;
BVolume bootVolume; BVolume bootVolume;
if (BVolumeRoster().GetBootVolume(&bootVolume) == B_OK if (BVolumeRoster().GetBootVolume(&bootVolume) == B_OK
&& partition->GetVolume(&volume) == B_OK) { && partition->GetVolume(&volume) == B_OK) {
unMountable = volume != bootVolume; unMountable = volume != bootVolume;
} else } else
unMountable = true; unMountable = true;
@@ -555,7 +562,7 @@ MainWindow::_DisplayPartitionError(BString _message,
const BPartition* partition, status_t error) const const BPartition* partition, status_t error) const
{ {
char message[1024]; char message[1024];
if (partition && _message.FindFirst("%s") >= 0) { if (partition && _message.FindFirst("%s") >= 0) {
BString name; BString name;
name << " \"" << partition->ContentName() << "\""; name << " \"" << partition->ContentName() << "\"";
@@ -659,8 +666,9 @@ MainWindow::_MountAll()
class ModificationPreparer { class ModificationPreparer {
public: public:
ModificationPreparer(BDiskDevice* disk) ModificationPreparer(BDiskDevice* disk)
: fDisk(disk) :
, fModificationStatus(fDisk->PrepareModifications()) fDisk(disk),
fModificationStatus(fDisk->PrepareModifications())
{ {
} }
~ModificationPreparer() ~ModificationPreparer()
+22 -22
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2006-2008 Haiku Inc. All rights reserved. * Copyright 2006-2009 Haiku Inc. All rights reserved.
* Distributed under the terms of the MIT license. * Distributed under the terms of the MIT license.
* *
* Authors: * Authors:
@@ -18,8 +18,8 @@
BBitmapStringField::BBitmapStringField(BBitmap* bitmap, const char* string) BBitmapStringField::BBitmapStringField(BBitmap* bitmap, const char* string)
: Inherited(string) : Inherited(string),
, fBitmap(bitmap) fBitmap(bitmap)
{ {
} }
@@ -114,7 +114,7 @@ PartitionColumn::DrawField(BField* field, BRect rect, BView* parent)
} else if (stringField) { } else if (stringField) {
float width = rect.Width() - (2 * fTextMargin); float width = rect.Width() - (2 * fTextMargin);
if (width != stringField->Width()) { if (width != stringField->Width()) {
BString truncatedString(stringField->String()); BString truncatedString(stringField->String());
@@ -156,7 +156,7 @@ PartitionColumn::GetPreferredWidth(BField *_field, BView* parent) const
} }
bool bool
PartitionColumn::AcceptsField(const BField* field) const PartitionColumn::AcceptsField(const BField* field) const
{ {
return dynamic_cast<const BStringField*>(field) != NULL; return dynamic_cast<const BStringField*>(field) != NULL;
@@ -178,11 +178,11 @@ enum {
PartitionListRow::PartitionListRow(BPartition* partition) PartitionListRow::PartitionListRow(BPartition* partition)
: Inherited() : Inherited(),
, fPartitionID(partition->ID()) fPartitionID(partition->ID()),
, fParentID(partition->Parent() ? partition->Parent()->ID() : -1) fParentID(partition->Parent() ? partition->Parent()->ID() : -1),
, fOffset(partition->Offset()) fOffset(partition->Offset()),
, fSize(partition->Size()) fSize(partition->Size())
{ {
BPath path; BPath path;
partition->GetPath(&path); partition->GetPath(&path);
@@ -206,7 +206,7 @@ PartitionListRow::PartitionListRow(BPartition* partition)
SetField(new BStringField(kUnavailableString), kFilesystemColumn); SetField(new BStringField(kUnavailableString), kFilesystemColumn);
SetField(new BStringField(kUnavailableString), kVolumeNameColumn); SetField(new BStringField(kUnavailableString), kVolumeNameColumn);
} }
if (partition->IsMounted() && partition->GetMountPoint(&path) == B_OK) { if (partition->IsMounted() && partition->GetMountPoint(&path) == B_OK) {
SetField(new BStringField(path.Path()), kMountedAtColumn); SetField(new BStringField(path.Path()), kMountedAtColumn);
} else { } else {
@@ -221,18 +221,18 @@ PartitionListRow::PartitionListRow(BPartition* partition)
PartitionListRow::PartitionListRow(partition_id parentID, partition_id id, PartitionListRow::PartitionListRow(partition_id parentID, partition_id id,
off_t offset, off_t size) off_t offset, off_t size)
: Inherited() : Inherited(),
, fPartitionID(id) fPartitionID(id),
, fParentID(parentID) fParentID(parentID),
, fOffset(offset) fOffset(offset),
, fSize(size) fSize(size)
{ {
// TODO: design icon for spaces on partitions // TODO: design icon for spaces on partitions
SetField(new BBitmapStringField(NULL, "-"), kDeviceColumn); SetField(new BBitmapStringField(NULL, "-"), kDeviceColumn);
SetField(new BStringField("<empty>"), kFilesystemColumn); SetField(new BStringField("<empty>"), kFilesystemColumn);
SetField(new BStringField(kUnavailableString), kVolumeNameColumn); SetField(new BStringField(kUnavailableString), kVolumeNameColumn);
SetField(new BStringField(kUnavailableString), kMountedAtColumn); SetField(new BStringField(kUnavailableString), kMountedAtColumn);
char sizeString[1024]; char sizeString[1024];
@@ -282,11 +282,11 @@ PartitionListRow*
PartitionListView::AddPartition(BPartition* partition) PartitionListView::AddPartition(BPartition* partition)
{ {
PartitionListRow* partitionrow = FindRow(partition->ID()); PartitionListRow* partitionrow = FindRow(partition->ID());
// forget about it if this partition is already in the listview // forget about it if this partition is already in the listview
if (partitionrow != NULL) if (partitionrow != NULL)
return partitionrow; return partitionrow;
// create the row for this partition // create the row for this partition
partitionrow = new PartitionListRow(partition); partitionrow = new PartitionListRow(partition);
@@ -311,7 +311,7 @@ PartitionListView::AddPartition(BPartition* partition)
// make sure the row is initially expanded // make sure the row is initially expanded
ExpandOrCollapse(partitionrow, true); ExpandOrCollapse(partitionrow, true);
return partitionrow; return partitionrow;
} }
@@ -324,7 +324,7 @@ PartitionListView::AddSpace(partition_id parentID, partition_id id,
PartitionListRow* parent = FindRow(parentID); PartitionListRow* parent = FindRow(parentID);
if (!parent) if (!parent)
return NULL; return NULL;
// create the row for this partition // create the row for this partition
PartitionListRow* partitionrow = new PartitionListRow(parentID, PartitionListRow* partitionrow = new PartitionListRow(parentID,
id, offset, size); id, offset, size);
@@ -337,7 +337,7 @@ PartitionListView::AddSpace(partition_id parentID, partition_id id,
// make sure the row is initially expanded // make sure the row is initially expanded
ExpandOrCollapse(partitionrow, true); ExpandOrCollapse(partitionrow, true);
return partitionrow; return partitionrow;
} }
+6 -5
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2007 Haiku Inc. All rights reserved. * Copyright 2002-2009 Haiku Inc. All rights reserved.
* Distributed under the terms of the MIT license. * Distributed under the terms of the MIT license.
* *
* Authors: * Authors:
@@ -7,6 +7,7 @@
* Ithamar R. Adema <[email protected]> * Ithamar R. Adema <[email protected]>
* Stephan Aßmus <[email protected]> * Stephan Aßmus <[email protected]>
*/ */
#include "Support.h" #include "Support.h"
#include <Partition.h> #include <Partition.h>
@@ -78,11 +79,12 @@ is_valid_partitionable_space(size_t size)
} }
// #pragma mark -SpaceIDMap // #pragma mark - SpaceIDMap
SpaceIDMap::SpaceIDMap() SpaceIDMap::SpaceIDMap()
: HashMap<HashString, partition_id>() : HashMap<HashString, partition_id>(),
, fNextSpaceID(-2) fNextSpaceID(-2)
{ {
} }
@@ -107,4 +109,3 @@ SpaceIDMap::SpaceIDFor(partition_id parentID, off_t spaceOffset)
return newID; return newID;
} }