Put the code to Extract a replicant into its own function.
BShelf::_AddReplicant() is finally getting acceptable. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23182 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -101,6 +101,8 @@ class BShelf : public BHandler {
|
|||||||
status_t _DeleteReplicant(BPrivate::replicant_data* replicant);
|
status_t _DeleteReplicant(BPrivate::replicant_data* replicant);
|
||||||
status_t _AddReplicant(BMessage* data,
|
status_t _AddReplicant(BMessage* data,
|
||||||
BPoint* location, uint32 uniqueID);
|
BPoint* location, uint32 uniqueID);
|
||||||
|
BView *_GetReplicant(BMessage *data, BView *view, const BPoint &point,
|
||||||
|
BDragger *&dragger, BDragger::relation &relation);
|
||||||
_BZombieReplicantView_ *_CreateZombie(BMessage *data, BDragger *&dragger);
|
_BZombieReplicantView_ *_CreateZombie(BMessage *data, BDragger *&dragger);
|
||||||
|
|
||||||
status_t _GetProperty(BMessage* message, BMessage* reply);
|
status_t _GetProperty(BMessage* message, BMessage* reply);
|
||||||
|
|||||||
@@ -1143,11 +1143,6 @@ BShelf::_AddReplicant(BMessage *data, BPoint *location, uint32 uniqueID)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BDragger* dragger = NULL;
|
|
||||||
BView* replicant = NULL;
|
|
||||||
BDragger::relation relation = BDragger::TARGET_UNKNOWN;
|
|
||||||
_BZombieReplicantView_* zombie = NULL;
|
|
||||||
|
|
||||||
// Instantiate the object, if this fails we have a zombie
|
// Instantiate the object, if this fails we have a zombie
|
||||||
image_id image;
|
image_id image;
|
||||||
BArchivable *archivable = _InstantiateObject(data, &image);
|
BArchivable *archivable = _InstantiateObject(data, &image);
|
||||||
@@ -1157,15 +1152,46 @@ BShelf::_AddReplicant(BMessage *data, BPoint *location, uint32 uniqueID)
|
|||||||
return send_reply(data, B_ERROR, uniqueID);
|
return send_reply(data, B_ERROR, uniqueID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BDragger* dragger = NULL;
|
||||||
|
BView* replicant = NULL;
|
||||||
|
BDragger::relation relation = BDragger::TARGET_UNKNOWN;
|
||||||
|
_BZombieReplicantView_* zombie = NULL;
|
||||||
if (view != NULL) {
|
if (view != NULL) {
|
||||||
BPoint point;
|
const BPoint point = location ? *location : view->Frame().LeftTop();
|
||||||
if (location)
|
replicant = _GetReplicant(data, view, point, dragger, relation);
|
||||||
point = *location;
|
if (replicant == NULL)
|
||||||
else
|
send_reply(data, B_ERROR, uniqueID);
|
||||||
point = view->Frame().LeftTop();
|
|
||||||
|
|
||||||
|
} else if (fDisplayZombies && fAllowZombies)
|
||||||
|
zombie = _CreateZombie(data, dragger);
|
||||||
|
|
||||||
|
else if (!fAllowZombies) {
|
||||||
|
// There was no view, and we're not allowed to have any zombies
|
||||||
|
// in the house
|
||||||
|
return send_reply(data, B_ERROR, uniqueID);
|
||||||
|
}
|
||||||
|
|
||||||
|
data->RemoveName("_drop_point_");
|
||||||
|
data->RemoveName("_drop_offset_");
|
||||||
|
|
||||||
|
replicant_data *item = new replicant_data(data, replicant, dragger,
|
||||||
|
relation, uniqueID, image);
|
||||||
|
|
||||||
|
item->error = B_OK;
|
||||||
|
item->zombie_view = zombie;
|
||||||
|
|
||||||
|
fReplicants.AddItem(item);
|
||||||
|
|
||||||
|
return send_reply(data, B_OK, uniqueID);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BView *
|
||||||
|
BShelf::_GetReplicant(BMessage *data, BView *view, const BPoint &point,
|
||||||
|
BDragger *&dragger, BDragger::relation &relation)
|
||||||
|
{
|
||||||
// TODO: test me -- there seems to be lots of bugs parked here!
|
// TODO: test me -- there seems to be lots of bugs parked here!
|
||||||
|
BView *replicant = NULL;
|
||||||
_GetReplicantData(data, view, replicant, dragger, relation);
|
_GetReplicantData(data, view, replicant, dragger, relation);
|
||||||
|
|
||||||
if (dragger != NULL)
|
if (dragger != NULL)
|
||||||
@@ -1194,7 +1220,7 @@ BShelf::_AddReplicant(BMessage *data, BPoint *location, uint32 uniqueID)
|
|||||||
delete dragger;
|
delete dragger;
|
||||||
}
|
}
|
||||||
|
|
||||||
return send_reply(data, B_ERROR, uniqueID);
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
BPoint adjust = AdjustReplicantBy(frame, data);
|
BPoint adjust = AdjustReplicantBy(frame, data);
|
||||||
@@ -1209,27 +1235,8 @@ BShelf::_AddReplicant(BMessage *data, BPoint *location, uint32 uniqueID)
|
|||||||
fContainerView->AddChild(dragger);
|
fContainerView->AddChild(dragger);
|
||||||
|
|
||||||
replicant->AddFilter(new ReplicantViewFilter(this, replicant));
|
replicant->AddFilter(new ReplicantViewFilter(this, replicant));
|
||||||
} else if (fDisplayZombies && fAllowZombies)
|
|
||||||
zombie = _CreateZombie(data, dragger);
|
|
||||||
|
|
||||||
else if (!fAllowZombies) {
|
return replicant;
|
||||||
// There was no view, and we're not allowed to have any zombies
|
|
||||||
// in the house
|
|
||||||
return send_reply(data, B_ERROR, uniqueID);
|
|
||||||
}
|
|
||||||
|
|
||||||
data->RemoveName("_drop_point_");
|
|
||||||
data->RemoveName("_drop_offset_");
|
|
||||||
|
|
||||||
replicant_data *item = new replicant_data(data, replicant, dragger,
|
|
||||||
relation, uniqueID, image);
|
|
||||||
|
|
||||||
item->error = B_OK;
|
|
||||||
item->zombie_view = zombie;
|
|
||||||
|
|
||||||
fReplicants.AddItem(item);
|
|
||||||
|
|
||||||
return send_reply(data, B_OK, uniqueID);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user