Big cleanup, rewrote Shelf.h.

Fixed bug in BShelf::ReplicantAt() - it is supposed to test if any of
the variables passed in is NULL before writing to them.
Got rid of the _PR3_COMPATIBLE_ stuff - we definitely don't need that :)
Refactored the code a bit - moved the identical parts of the three
DeleteReplicant() variants into a separate method _DeleteReplicant(),
moved _rep_data_ code out of the class definition, replaced names like
"fView2" and "aBool" with something more meaningful.
Prefixed private methods with '_'.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13471 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2005-07-06 00:43:52 +00:00
parent 4da171eff7
commit 508d8a847f
2 changed files with 356 additions and 398 deletions

View File

@ -1,145 +1,115 @@
/******************************************************************************* /*
/ * Copyright 2001-2005, Haiku Inc.
/ File: Shelf.h * Distributed under the terms of the MIT License.
/ */
/ Description: BShelf stores replicant views that are dropped onto it
/
/ Copyright 1996-98, Be Incorporated, All Rights Reserved
/
*******************************************************************************/
#ifndef _SHELF_H #ifndef _SHELF_H
#define _SHELF_H #define _SHELF_H
#include <BeBuild.h>
#include <Handler.h> #include <Handler.h>
#include <List.h> #include <List.h>
class BDataIO; class BDataIO;
class BView; class BView;
class BEntry; class BEntry;
extern "C" void _ReservedShelf1__6BShelfFv(BShelf *const, int32, struct entry_ref;
const BMessage*, const BView*);
/*----------------------------------------------------------------*/ class _rep_data_;
/*----- BShelf class ---------------------------------------------*/
class BShelf : public BHandler { class BShelf : public BHandler {
public: public:
BShelf(BView *view, BShelf(BView* view, bool allowDrags = true, const char* shelfType = NULL);
bool allow_drags = true, BShelf(const entry_ref* ref, BView* view, bool allowDrags = true,
const char *shelf_type = NULL); const char* shelfType = NULL);
BShelf(const entry_ref *ref, BShelf(BDataIO* stream, BView* view, bool allowDrags = true,
BView *view, const char* shelfType = NULL);
bool allow_drags = true, BShelf(BMessage *data);
const char *shelf_type = NULL); virtual ~BShelf();
BShelf(BDataIO *stream,
BView *view,
bool allow_drags = true,
const char *shelf_type = NULL);
BShelf(BMessage *data);
virtual ~BShelf();
virtual status_t Archive(BMessage *data, bool deep = true) const; virtual status_t Archive(BMessage* data, bool deep = true) const;
static BArchivable *Instantiate(BMessage *data); static BArchivable* Instantiate(BMessage* archive);
virtual void MessageReceived(BMessage *msg); virtual void MessageReceived(BMessage *msg);
status_t Save(); status_t Save();
virtual void SetDirty(bool state); virtual void SetDirty(bool state);
bool IsDirty() const; bool IsDirty() const;
virtual BHandler *ResolveSpecifier(BMessage *msg, virtual BHandler* ResolveSpecifier(BMessage *msg,
int32 index, int32 index, BMessage *specifier,
BMessage *specifier, int32 form, const char *property);
int32 form, virtual status_t GetSupportedSuites(BMessage* data);
const char *property);
virtual status_t GetSupportedSuites(BMessage *data);
virtual status_t Perform(perform_code d, void *arg); virtual status_t Perform(perform_code d, void *arg);
bool AllowsDragging() const; bool AllowsDragging() const;
void SetAllowsDragging(bool state); void SetAllowsDragging(bool state);
bool AllowsZombies() const; bool AllowsZombies() const;
void SetAllowsZombies(bool state); void SetAllowsZombies(bool state);
bool DisplaysZombies() const; bool DisplaysZombies() const;
void SetDisplaysZombies(bool state); void SetDisplaysZombies(bool state);
bool IsTypeEnforced() const; bool IsTypeEnforced() const;
void SetTypeEnforced(bool state); void SetTypeEnforced(bool state);
status_t SetSaveLocation(BDataIO *data_io); status_t SetSaveLocation(BDataIO *data_io);
status_t SetSaveLocation(const entry_ref *ref); status_t SetSaveLocation(const entry_ref *ref);
BDataIO *SaveLocation(entry_ref *ref) const; BDataIO* SaveLocation(entry_ref *ref) const;
status_t AddReplicant(BMessage *data, BPoint location); status_t AddReplicant(BMessage *data, BPoint location);
status_t DeleteReplicant(BView *replicant); status_t DeleteReplicant(BView *replicant);
status_t DeleteReplicant(BMessage *data); status_t DeleteReplicant(BMessage *data);
status_t DeleteReplicant(int32 index); status_t DeleteReplicant(int32 index);
int32 CountReplicants() const; int32 CountReplicants() const;
BMessage *ReplicantAt(int32 index, BMessage* ReplicantAt(int32 index,
BView **view = NULL, BView **view = NULL,
uint32 *uid = NULL, uint32 *uid = NULL,
status_t *perr = NULL) const; status_t *perr = NULL) const;
int32 IndexOf(const BView *replicant_view) const; int32 IndexOf(const BView *replicantView) const;
int32 IndexOf(const BMessage *archive) const; int32 IndexOf(const BMessage *archive) const;
int32 IndexOf(uint32 id) const; int32 IndexOf(uint32 id) const;
protected: protected:
virtual bool CanAcceptReplicantMessage(BMessage*) const; virtual bool CanAcceptReplicantMessage(BMessage*) const;
virtual bool CanAcceptReplicantView(BRect, BView*, BMessage*) const; virtual bool CanAcceptReplicantView(BRect, BView*, BMessage*) const;
virtual BPoint AdjustReplicantBy(BRect, BMessage*) const; virtual BPoint AdjustReplicantBy(BRect, BMessage*) const;
virtual void ReplicantDeleted(int32 index, virtual void ReplicantDeleted(int32 index, const BMessage *archive,
const BMessage *archive, const BView *replicant);
const BView *replicant);
/*----- Private or reserved -----------------------------------------*/ private:
private: friend class _TContainerViewFilter_;
friend class _TContainerViewFilter_;
friend void _ReservedShelf1__6BShelfFv(BShelf *const, int32,
const BMessage*, const BView*);
virtual void _ReservedShelf2();
virtual void _ReservedShelf3();
virtual void _ReservedShelf4();
virtual void _ReservedShelf5();
#if !_PR3_COMPATIBLE_ virtual void _ReservedShelf2();
virtual void _ReservedShelf6(); virtual void _ReservedShelf3();
virtual void _ReservedShelf7(); virtual void _ReservedShelf4();
virtual void _ReservedShelf8(); virtual void _ReservedShelf5();
#endif virtual void _ReservedShelf6();
BShelf(const BShelf&); virtual void _ReservedShelf7();
BShelf &operator=(const BShelf &); virtual void _ReservedShelf8();
status_t _Archive(BMessage *data) const; BShelf(const BShelf& other);
void InitData(BEntry *entry, BShelf& operator=(const BShelf& other);
BDataIO *stream,
BView *view,
bool allow_drags);
status_t RealAddReplicant(BMessage *data,
BPoint *loc,
uint32 uid);
status_t GetProperty(BMessage *msg, BMessage *reply);
BView *fContainerView; status_t _Archive(BMessage* data) const;
BDataIO *fStream; void _InitData(BEntry* entry, BDataIO* stream,
BEntry *fEntry; BView* view, bool allowDrags);
BList fReplicants; status_t _DeleteReplicant(_rep_data_* replicant);
_TContainerViewFilter_ *fFilter; status_t _RealAddReplicant(BMessage* data,
uint32 fGenCount; BPoint* location, uint32 uniqueID);
bool fAllowDragging; status_t _GetProperty(BMessage* message, BMessage* reply);
bool fDirty;
bool fDisplayZombies;
bool fAllowZombies;
bool fTypeEnforced;
uint32 _reserved[3]; /* was 5 */ private:
#if !_PR3_COMPATIBLE_ BView* fContainerView;
uint32 _more_reserved[5]; BDataIO* fStream;
#endif BEntry* fEntry;
BList fReplicants;
_TContainerViewFilter_* fFilter;
uint32 fGenCount;
bool fAllowDragging;
bool fDirty;
bool fDisplayZombies;
bool fAllowZombies;
bool fTypeEnforced;
uint32 _reserved[8];
}; };
/*-------------------------------------------------------------*/ #endif /* _SHELF_H */
/*-------------------------------------------------------------*/
#endif /* _SHELF_H */

View File

@ -1,32 +1,15 @@
//------------------------------------------------------------------------------ /*
// Copyright (c) 2001-2004, Haiku * Copyright 2001-2005, Haiku.
// * Distributed under the terms of the MIT License.
// Permission is hereby granted, free of charge, to any person obtaining a *
// copy of this software and associated documentation files (the "Software"), * Authors:
// to deal in the Software without restriction, including without limitation * Marc Flerackers (mflerackers@androme.be)
// the rights to use, copy, modify, merge, publish, distribute, sublicense, * Axel Dörfler, axeld@pinc-software.de
// and/or sell copies of the Software, and to permit persons to whom the */
// Software is furnished to do so, subject to the following conditions:
// /** BShelf stores replicant views that are dropped onto it */
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// File Name: Shelf.cpp
// Author: Marc Flerackers (mflerackers@androme.be)
// Description: BShelf stores replicant views that are dropped onto it
//------------------------------------------------------------------------------
// Standard Includes -----------------------------------------------------------
// System Includes -------------------------------------------------------------
#include <Beep.h> #include <Beep.h>
#include <Dragger.h> #include <Dragger.h>
#include <Entry.h> #include <Entry.h>
@ -44,113 +27,26 @@
#include <stdio.h> #include <stdio.h>
extern "C" void _ReservedShelf1__6BShelfFv(BShelf *const, int32,
const BMessage*, const BView*);
class _rep_data_ { class _rep_data_ {
private:
friend class BShelf;
_rep_data_(BMessage *message, BView *view, BDragger *dragger, _rep_data_(BMessage *message, BView *view, BDragger *dragger,
BDragger::relation relation, unsigned long id, image_id image) BDragger::relation relation, unsigned long id, image_id image);
: _rep_data_();
fMessage(message),
fView(view),
fDragger(NULL),
fRelation(relation),
fId(id),
fImage(image),
fError(B_OK),
fView2(NULL)
{
}
_rep_data_() static _rep_data_* find(BList const *list, BMessage const *msg);
: static _rep_data_* find(BList const *list, BView const *view, bool allowZombie);
fMessage(NULL), static _rep_data_* find(BList const *list, unsigned long id);
fView(NULL),
fDragger(NULL),
fRelation(BDragger::TARGET_UNKNOWN),
fId(0),
fError(B_ERROR),
fView2(NULL)
{
}
static _rep_data_ *find(BList const *list, BMessage const *msg) static int32 index_of(BList const *list, BMessage const *msg);
{ static int32 index_of(BList const *list, BView const *view, bool allowZombie);
int32 i = 0; static int32 index_of(BList const *list, unsigned long id);
_rep_data_ *item;
while ((item = (_rep_data_*)list->ItemAt(i++)) != NULL) {
if (item->fMessage == msg)
return item;
}
return NULL;
}
static _rep_data_ *find(BList const *list, BView const *view, bool aBool)
{
int32 i = 0;
_rep_data_ *item;
while ((item = (_rep_data_*)list->ItemAt(i++)) != NULL) {
if (item->fView == view)
return item;
if (aBool && item->fView2 == view)
return item;
}
return NULL;
}
static _rep_data_ *find(BList const *list, unsigned long id)
{
int32 i = 0;
_rep_data_ *item;
while ((item = (_rep_data_*)list->ItemAt(i++)) != NULL) {
if (item->fId == id)
return item;
}
return NULL;
}
static int32 index_of(BList const *list, BMessage const *msg)
{
int32 i = 0;
_rep_data_ *item;
while ((item = (_rep_data_*)list->ItemAt(i++)) != NULL) {
if (item->fMessage == msg)
return i;
}
return -1;
}
static int32 index_of(BList const *list, BView const *view, bool aBool)
{
int32 i = 0;
_rep_data_ *item;
while ((item = (_rep_data_*)list->ItemAt(i++)) != NULL) {
if (item->fView == view)
return i;
if (aBool && item->fView2 == view)
return i;
}
return -1;
}
static int32 index_of(BList const *list, unsigned long id)
{
int32 i = 0;
_rep_data_ *item;
while ((item = (_rep_data_*)list->ItemAt(i++)) != NULL) {
if (item->fId == id)
return i;
}
return -1;
}
friend class BShelf;
BMessage *fMessage; BMessage *fMessage;
BView *fView; BView *fView;
@ -159,23 +55,154 @@ friend class BShelf;
unsigned long fId; unsigned long fId;
image_id fImage; image_id fImage;
status_t fError; status_t fError;
BView *fView2; BView *fZombieView;
}; };
class _TContainerViewFilter_ : public BMessageFilter { class _TContainerViewFilter_ : public BMessageFilter {
public: public:
_TContainerViewFilter_(BShelf *shelf, BView *view); _TContainerViewFilter_(BShelf *shelf, BView *view);
virtual ~_TContainerViewFilter_(); virtual ~_TContainerViewFilter_();
filter_result Filter(BMessage *msg, BHandler **handler); filter_result Filter(BMessage *msg, BHandler **handler);
filter_result ObjectDropFilter(BMessage *msg, BHandler **handler); filter_result ObjectDropFilter(BMessage *msg, BHandler **handler);
protected:
BShelf *fShelf; BShelf *fShelf;
BView *fView; BView *fView;
}; };
// #pragma mark -
_rep_data_::_rep_data_(BMessage *message, BView *view, BDragger *dragger,
BDragger::relation relation, unsigned long id, image_id image)
:
fMessage(message),
fView(view),
fDragger(NULL),
fRelation(relation),
fId(id),
fImage(image),
fError(B_OK),
fZombieView(NULL)
{
}
_rep_data_::_rep_data_()
:
fMessage(NULL),
fView(NULL),
fDragger(NULL),
fRelation(BDragger::TARGET_UNKNOWN),
fId(0),
fError(B_ERROR),
fZombieView(NULL)
{
}
//static
_rep_data_ *
_rep_data_::find(BList const *list, BMessage const *msg)
{
int32 i = 0;
_rep_data_ *item;
while ((item = (_rep_data_*)list->ItemAt(i++)) != NULL) {
if (item->fMessage == msg)
return item;
}
return NULL;
}
//static
_rep_data_ *
_rep_data_::find(BList const *list, BView const *view, bool allowZombie)
{
int32 i = 0;
_rep_data_ *item;
while ((item = (_rep_data_*)list->ItemAt(i++)) != NULL) {
if (item->fView == view)
return item;
if (allowZombie && item->fZombieView == view)
return item;
}
return NULL;
}
//static
_rep_data_ *
_rep_data_::find(BList const *list, unsigned long id)
{
int32 i = 0;
_rep_data_ *item;
while ((item = (_rep_data_*)list->ItemAt(i++)) != NULL) {
if (item->fId == id)
return item;
}
return NULL;
}
//static
int32
_rep_data_::index_of(BList const *list, BMessage const *msg)
{
int32 i = 0;
_rep_data_ *item;
while ((item = (_rep_data_*)list->ItemAt(i++)) != NULL) {
if (item->fMessage == msg)
return i;
}
return -1;
}
//static
int32
_rep_data_::index_of(BList const *list, BView const *view, bool allowZombie)
{
int32 i = 0;
_rep_data_ *item;
while ((item = (_rep_data_*)list->ItemAt(i++)) != NULL) {
if (item->fView == view)
return i;
if (allowZombie && item->fZombieView == view)
return i;
}
return -1;
}
//static
int32
_rep_data_::index_of(BList const *list, unsigned long id)
{
int32 i = 0;
_rep_data_ *item;
while ((item = (_rep_data_*)list->ItemAt(i++)) != NULL) {
if (item->fId == id)
return i;
}
return -1;
}
// #pragma mark -
_TContainerViewFilter_::_TContainerViewFilter_(BShelf *shelf, BView *view) _TContainerViewFilter_::_TContainerViewFilter_(BShelf *shelf, BView *view)
: BMessageFilter(B_ANY_DELIVERY, B_ANY_SOURCE) : BMessageFilter(B_ANY_DELIVERY, B_ANY_SOURCE)
{ {
@ -261,7 +288,7 @@ _TContainerViewFilter_::ObjectDropFilter(BMessage *msg, BHandler **_handler)
} }
} else { } else {
if (fShelf->RealAddReplicant(msg, &point, 0) == B_OK) if (fShelf->_RealAddReplicant(msg, &point, 0) == B_OK)
Looper()->DetachCurrentMessage(); Looper()->DetachCurrentMessage();
} }
@ -269,54 +296,61 @@ _TContainerViewFilter_::ObjectDropFilter(BMessage *msg, BHandler **_handler)
} }
class _TReplicantViewFilter_ : public BMessageFilter { // #pragma mark -
public:
_TReplicantViewFilter_(BShelf *shelf, BView *view)
: BMessageFilter(B_ANY_DELIVERY, B_ANY_SOURCE)
{
fShelf = shelf;
fView = view;
}
virtual ~_TReplicantViewFilter_()
{
}
filter_result Filter(BMessage *, BHandler **)
{
return B_DISPATCH_MESSAGE;
}
class _TReplicantViewFilter_ : public BMessageFilter {
public:
_TReplicantViewFilter_(BShelf *shelf, BView *view)
: BMessageFilter(B_ANY_DELIVERY, B_ANY_SOURCE)
{
fShelf = shelf;
fView = view;
}
virtual ~_TReplicantViewFilter_()
{
}
filter_result Filter(BMessage *, BHandler **)
{
return B_DISPATCH_MESSAGE;
}
protected:
BShelf *fShelf; BShelf *fShelf;
BView *fView; BView *fView;
}; };
// **** BShelf **** // #pragma mark -
BShelf::BShelf(BView *view, bool allow_drags, const char *shelf_type) BShelf::BShelf(BView *view, bool allow_drags, const char *shelf_type)
: BHandler(shelf_type) : BHandler(shelf_type)
{ {
InitData(NULL, NULL, view, allow_drags); _InitData(NULL, NULL, view, allow_drags);
} }
BShelf::BShelf(const entry_ref *ref, BView *view, bool allow_drags, BShelf::BShelf(const entry_ref *ref, BView *view, bool allow_drags,
const char *shelf_type) const char *shelf_type)
: BHandler(shelf_type) : BHandler(shelf_type)
{ {
InitData(new BEntry(ref), NULL, view, allow_drags); _InitData(new BEntry(ref), NULL, view, allow_drags);
} }
BShelf::BShelf(BDataIO *stream, BView *view, bool allow_drags, BShelf::BShelf(BDataIO *stream, BView *view, bool allow_drags,
const char *shelf_type) const char *shelf_type)
: BHandler(shelf_type) : BHandler(shelf_type)
{ {
InitData(NULL, stream, view, allow_drags); _InitData(NULL, stream, view, allow_drags);
} }
BShelf::BShelf(BMessage *data) BShelf::BShelf(BMessage *data)
: BHandler(data) : BHandler(data)
{ {
// TODO: Implement ? // TODO: Implement ?
} }
@ -493,26 +527,25 @@ BShelf::SaveLocation(entry_ref *ref) const
if (fStream && ref) { if (fStream && ref) {
*ref = entry; *ref = entry;
return fStream; return fStream;
}
} else if (fEntry) { if (fEntry) {
fEntry->GetRef(&entry); fEntry->GetRef(&entry);
if (ref) if (ref)
*ref = entry; *ref = entry;
return NULL; return NULL;
} else {
*ref = entry;
return NULL;
} }
*ref = entry;
return NULL;
} }
status_t status_t
BShelf::AddReplicant(BMessage *data, BPoint location) BShelf::AddReplicant(BMessage *data, BPoint location)
{ {
return RealAddReplicant(data, &location, 0); return _RealAddReplicant(data, &location, 0);
} }
@ -522,33 +555,10 @@ BShelf::DeleteReplicant(BView *replicant)
int32 index = _rep_data_::index_of(&fReplicants, replicant, true); int32 index = _rep_data_::index_of(&fReplicants, replicant, true);
_rep_data_ *item = (_rep_data_*)fReplicants.ItemAt(index); _rep_data_ *item = (_rep_data_*)fReplicants.ItemAt(index);
if (item == NULL)
return B_BAD_VALUE;
if (!item) return _DeleteReplicant(item);
return B_ERROR;
bool aBool;
item->fMessage->FindBool("", &aBool);
BView *view = item->fView;
if (!view)
view = item->fView2;
if (view)
view->RemoveSelf();
if (item->fDragger)
item->fDragger->RemoveSelf();
fReplicants.RemoveItem(item);
if (aBool && item->fImage >= 0)
unload_add_on(item->fImage);
delete item;
return B_OK;
} }
@ -558,33 +568,10 @@ BShelf::DeleteReplicant(BMessage *data)
int32 index = _rep_data_::index_of(&fReplicants, data); int32 index = _rep_data_::index_of(&fReplicants, data);
_rep_data_ *item = (_rep_data_*)fReplicants.ItemAt(index); _rep_data_ *item = (_rep_data_*)fReplicants.ItemAt(index);
if (!item) if (!item)
return B_ERROR; return B_BAD_VALUE;
bool aBool; return _DeleteReplicant(item);
item->fMessage->FindBool("", &aBool);
BView *view = item->fView;
if (!view)
view = item->fView2;
if (view)
view->RemoveSelf();
if (item->fDragger)
item->fDragger->RemoveSelf();
fReplicants.RemoveItem(item);
if (aBool && item->fImage >= 0)
unload_add_on(item->fImage);
delete item;
return B_OK;
} }
@ -592,35 +579,10 @@ status_t
BShelf::DeleteReplicant(int32 index) BShelf::DeleteReplicant(int32 index)
{ {
_rep_data_ *item = (_rep_data_*)fReplicants.ItemAt(index); _rep_data_ *item = (_rep_data_*)fReplicants.ItemAt(index);
if (!item) if (!item)
return B_ERROR; return B_BAD_INDEX;
bool aBool; return _DeleteReplicant(item);
item->fMessage->FindBool("", &aBool);
BView *view = item->fView;
if (!view)
view = item->fView2;
if (view)
view->RemoveSelf();
if (item->fDragger)
item->fDragger->RemoveSelf();
ReplicantDeleted(index, item->fMessage, item->fView);
fReplicants.RemoveItem(item);
if (aBool && item->fImage >= 0)
unload_add_on(item->fImage);
delete item;
return B_OK;
} }
@ -632,27 +594,30 @@ BShelf::CountReplicants() const
BMessage * BMessage *
BShelf::ReplicantAt(int32 index, BView **view, uint32 *uid, BShelf::ReplicantAt(int32 index, BView **_view, uint32 *_uniqueID,
status_t *perr) const status_t *_error) const
{ {
status_t err = B_ERROR;
BMessage *message = NULL;
_rep_data_ *item = (_rep_data_*)fReplicants.ItemAt(index); _rep_data_ *item = (_rep_data_*)fReplicants.ItemAt(index);
if (item == NULL) {
// no replicant found
if (_view)
*_view = NULL;
if (_uniqueID)
*_uniqueID = ~0UL;
if (_error)
*_error = B_BAD_INDEX;
if (item) { return NULL;
message = item->fMessage;
*view = item->fView;
*uid = item->fId;
*perr = item->fError;
} else {
*view = NULL;
*uid = 0;
*perr = err;
} }
return message; if (_view)
*_view = item->fView;
if (_uniqueID)
*_uniqueID = item->fId;
if (_error)
*_error = item->fError;
return item->fMessage;
} }
@ -714,11 +679,9 @@ void BShelf::_ReservedShelf2() {}
void BShelf::_ReservedShelf3() {} void BShelf::_ReservedShelf3() {}
void BShelf::_ReservedShelf4() {} void BShelf::_ReservedShelf4() {}
void BShelf::_ReservedShelf5() {} void BShelf::_ReservedShelf5() {}
#if !_PR3_COMPATIBLE_
void BShelf::_ReservedShelf6() {} void BShelf::_ReservedShelf6() {}
void BShelf::_ReservedShelf7() {} void BShelf::_ReservedShelf7() {}
void BShelf::_ReservedShelf8() {} void BShelf::_ReservedShelf8() {}
#endif
BShelf::BShelf(const BShelf&) BShelf::BShelf(const BShelf&)
@ -751,15 +714,15 @@ BShelf::_Archive(BMessage *data) const
void void
BShelf::InitData(BEntry *entry, BDataIO *stream, BView *view, BShelf::_InitData(BEntry *entry, BDataIO *stream, BView *view,
bool allow_drags) bool allowDrags)
{ {
fContainerView = view; fContainerView = view;
fStream = NULL; fStream = NULL;
fEntry = entry; fEntry = entry;
fFilter = NULL; fFilter = NULL;
fGenCount = 1; fGenCount = 1;
fAllowDragging = allow_drags; fAllowDragging = allowDrags;
fDirty = true; fDirty = true;
fDisplayZombies = false; fDisplayZombies = false;
fAllowZombies = true; fAllowZombies = true;
@ -779,20 +742,18 @@ BShelf::InitData(BEntry *entry, BDataIO *stream, BView *view,
BMessage archive; BMessage archive;
if (archive.Unflatten(fStream) == B_OK) { if (archive.Unflatten(fStream) == B_OK) {
bool aBool; bool allowZombies;
if (archive.FindBool("_zom_dsp", &allowZombies) != B_OK)
allowZombies = false;
if (!archive.FindBool("_zom_dsp", &aBool)) SetDisplaysZombies(allowZombies);
aBool = false;
SetDisplaysZombies(aBool); if (archive.FindBool("_zom_alw", &allowZombies) != B_OK)
allowZombies = true;
if (!archive.FindBool("_zom_alw", &aBool)) SetAllowsZombies(allowZombies);
aBool = true;
SetAllowsZombies(aBool);
int32 genCount; int32 genCount;
if (!archive.FindInt32("_sg_cnt", &genCount)) if (!archive.FindInt32("_sg_cnt", &genCount))
genCount = 1; genCount = 1;
@ -803,7 +764,34 @@ BShelf::InitData(BEntry *entry, BDataIO *stream, BView *view,
status_t status_t
BShelf::RealAddReplicant(BMessage *data, BPoint *loc, uint32 uid) BShelf::_DeleteReplicant(_rep_data_* item)
{
bool loadedImage;
item->fMessage->FindBool("", &loadedImage);
BView *view = item->fView;
if (view == NULL)
view = item->fZombieView;
if (view)
view->RemoveSelf();
if (item->fDragger)
item->fDragger->RemoveSelf();
fReplicants.RemoveItem(item);
if (loadedImage && item->fImage >= 0)
unload_add_on(item->fImage);
delete item;
return B_OK;
}
status_t
BShelf::_RealAddReplicant(BMessage *data, BPoint *loc, uint32 uid)
{ {
BView *replicant = NULL; BView *replicant = NULL;
BDragger *dragger = NULL; BDragger *dragger = NULL;
@ -947,7 +935,7 @@ BShelf::RealAddReplicant(BMessage *data, BPoint *loc, uint32 uid)
image); image);
item->fError = B_OK; item->fError = B_OK;
item->fView2 = zombie; item->fZombieView = zombie;
if (zombie) if (zombie)
zombie->SetArchive(data); zombie->SetArchive(data);
@ -967,7 +955,7 @@ BShelf::RealAddReplicant(BMessage *data, BPoint *loc, uint32 uid)
status_t status_t
BShelf::GetProperty(BMessage *msg, BMessage *reply) BShelf::_GetProperty(BMessage *msg, BMessage *reply)
{ {
//TODO: Implement //TODO: Implement
return B_ERROR; return B_ERROR;