* Added layout-friendly constructor.
* Reordered functions to match the order in the header (and vice versa). * Removed unused private functions. * Updated the header to follow our coding style. * Cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31088 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2006, 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.
|
||||||
*/
|
*/
|
||||||
#ifndef _OUTLINE_LIST_VIEW_H
|
#ifndef _OUTLINE_LIST_VIEW_H
|
||||||
@@ -12,129 +12,131 @@ class BListItem;
|
|||||||
|
|
||||||
|
|
||||||
class BOutlineListView : public BListView {
|
class BOutlineListView : public BListView {
|
||||||
public:
|
public:
|
||||||
BOutlineListView(BRect frame, const char* name,
|
BOutlineListView(BRect frame, const char* name,
|
||||||
list_view_type type = B_SINGLE_SELECTION_LIST,
|
list_view_type type = B_SINGLE_SELECTION_LIST,
|
||||||
uint32 resizeMode = B_FOLLOW_LEFT | B_FOLLOW_TOP,
|
uint32 resizeMode
|
||||||
|
= B_FOLLOW_LEFT | B_FOLLOW_TOP,
|
||||||
|
uint32 flags = B_WILL_DRAW | B_FRAME_EVENTS
|
||||||
|
| B_NAVIGABLE);
|
||||||
|
BOutlineListView(const char* name,
|
||||||
|
list_view_type type = B_SINGLE_SELECTION_LIST,
|
||||||
uint32 flags = B_WILL_DRAW | B_FRAME_EVENTS
|
uint32 flags = B_WILL_DRAW | B_FRAME_EVENTS
|
||||||
| B_NAVIGABLE);
|
| B_NAVIGABLE);
|
||||||
BOutlineListView(BMessage* archive);
|
BOutlineListView(BMessage* archive);
|
||||||
virtual ~BOutlineListView();
|
virtual ~BOutlineListView();
|
||||||
|
|
||||||
static BArchivable* Instantiate(BMessage* archive);
|
static BArchivable* Instantiate(BMessage* archive);
|
||||||
virtual status_t Archive(BMessage* archive, bool deep = true) const;
|
virtual status_t Archive(BMessage* archive, bool deep = true) const;
|
||||||
|
|
||||||
virtual void MouseDown(BPoint where);
|
virtual void MouseDown(BPoint where);
|
||||||
virtual void KeyDown(const char* bytes, int32 numBytes);
|
virtual void KeyDown(const char* bytes, int32 numBytes);
|
||||||
virtual void FrameMoved(BPoint newPosition);
|
virtual void FrameMoved(BPoint newPosition);
|
||||||
virtual void FrameResized(float newWidth, float newHeight);
|
virtual void FrameResized(float newWidth, float newHeight);
|
||||||
virtual void MouseUp(BPoint where);
|
virtual void MouseUp(BPoint where);
|
||||||
|
|
||||||
virtual bool AddUnder(BListItem* item, BListItem* underItem);
|
virtual bool AddUnder(BListItem* item, BListItem* underItem);
|
||||||
|
|
||||||
virtual bool AddItem(BListItem* item);
|
virtual bool AddItem(BListItem* item);
|
||||||
virtual bool AddItem(BListItem* item, int32 fullListIndex);
|
virtual bool AddItem(BListItem* item, int32 fullListIndex);
|
||||||
virtual bool AddList(BList* newItems);
|
virtual bool AddList(BList* newItems);
|
||||||
virtual bool AddList(BList* newItems, int32 fullListIndex);
|
virtual bool AddList(BList* newItems, int32 fullListIndex);
|
||||||
|
|
||||||
virtual bool RemoveItem(BListItem* item);
|
virtual bool RemoveItem(BListItem* item);
|
||||||
virtual BListItem* RemoveItem(int32 fullListIndex);
|
virtual BListItem* RemoveItem(int32 fullListIndex);
|
||||||
virtual bool RemoveItems(int32 fullListIndex, int32 count);
|
virtual bool RemoveItems(int32 fullListIndex, int32 count);
|
||||||
|
|
||||||
BListItem* FullListItemAt(int32 fullListIndex) const;
|
BListItem* FullListItemAt(int32 fullListIndex) const;
|
||||||
int32 FullListIndexOf(BPoint point) const;
|
int32 FullListIndexOf(BPoint point) const;
|
||||||
int32 FullListIndexOf(BListItem* item) const;
|
int32 FullListIndexOf(BListItem* item) const;
|
||||||
BListItem* FullListFirstItem() const;
|
BListItem* FullListFirstItem() const;
|
||||||
BListItem* FullListLastItem() const;
|
BListItem* FullListLastItem() const;
|
||||||
bool FullListHasItem(BListItem* item) const;
|
bool FullListHasItem(BListItem* item) const;
|
||||||
int32 FullListCountItems() const;
|
int32 FullListCountItems() const;
|
||||||
int32 FullListCurrentSelection(int32 index = 0) const;
|
int32 FullListCurrentSelection(int32 index = 0) const;
|
||||||
|
|
||||||
virtual void MakeEmpty();
|
virtual void MakeEmpty();
|
||||||
bool FullListIsEmpty() const;
|
bool FullListIsEmpty() const;
|
||||||
void FullListDoForEach(bool (*func)(BListItem* item));
|
void FullListDoForEach(bool (*func)(BListItem* item));
|
||||||
void FullListDoForEach(bool (*func)(BListItem* item, void *), void*);
|
void FullListDoForEach(
|
||||||
|
bool (*func)(BListItem* item, void*), void*);
|
||||||
|
|
||||||
BListItem* Superitem(const BListItem* item);
|
BListItem* Superitem(const BListItem* item);
|
||||||
|
|
||||||
void Expand(BListItem* item);
|
void Expand(BListItem* item);
|
||||||
void Collapse(BListItem* item);
|
void Collapse(BListItem* item);
|
||||||
|
|
||||||
bool IsExpanded(int32 fullListIndex);
|
bool IsExpanded(int32 fullListIndex);
|
||||||
|
|
||||||
virtual BHandler* ResolveSpecifier(BMessage* message, int32 index,
|
virtual BHandler* ResolveSpecifier(BMessage* message, int32 index,
|
||||||
BMessage* specifier, int32 what, const char* property);
|
BMessage* specifier, int32 what,
|
||||||
virtual status_t GetSupportedSuites(BMessage* data);
|
const char* property);
|
||||||
virtual status_t Perform(perform_code d, void* arg);
|
virtual status_t GetSupportedSuites(BMessage* data);
|
||||||
|
virtual status_t Perform(perform_code d, void* arg);
|
||||||
|
|
||||||
virtual void ResizeToPreferred();
|
virtual void ResizeToPreferred();
|
||||||
virtual void GetPreferredSize(float* _width, float* _height);
|
virtual void GetPreferredSize(float* _width, float* _height);
|
||||||
virtual void MakeFocus(bool focus = true);
|
virtual void MakeFocus(bool focus = true);
|
||||||
virtual void AllAttached();
|
virtual void AllAttached();
|
||||||
virtual void AllDetached();
|
virtual void AllDetached();
|
||||||
virtual void DetachedFromWindow();
|
virtual void DetachedFromWindow();
|
||||||
|
|
||||||
void FullListSortItems(int (*compareFunc)(const BListItem* first,
|
void FullListSortItems(int (*compareFunc)(
|
||||||
const BListItem* second));
|
const BListItem* first,
|
||||||
void SortItemsUnder(BListItem* underItem, bool oneLevelOnly,
|
const BListItem* second));
|
||||||
int (*compareFunc)(const BListItem* first,
|
void SortItemsUnder(BListItem* underItem,
|
||||||
const BListItem* second));
|
bool oneLevelOnly, int (*compareFunc)(
|
||||||
int32 CountItemsUnder(BListItem* under, bool oneLevelOnly) const;
|
const BListItem* first,
|
||||||
BListItem* EachItemUnder(BListItem* underItem, bool oneLevelOnly,
|
const BListItem* second));
|
||||||
BListItem* (*eachFunc)(BListItem* item, void* arg),
|
int32 CountItemsUnder(BListItem* under,
|
||||||
void* arg);
|
bool oneLevelOnly) const;
|
||||||
BListItem* ItemUnderAt(BListItem* underItem, bool oneLevelOnly,
|
BListItem* EachItemUnder(BListItem* underItem,
|
||||||
|
bool oneLevelOnly, BListItem* (*eachFunc)(
|
||||||
|
BListItem* item, void* arg), void* arg);
|
||||||
|
BListItem* ItemUnderAt(BListItem* underItem, bool oneLevelOnly,
|
||||||
int32 index) const;
|
int32 index) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual bool DoMiscellaneous(MiscCode code, MiscData* data);
|
virtual bool DoMiscellaneous(MiscCode code, MiscData* data);
|
||||||
virtual void MessageReceived(BMessage *message);
|
virtual void MessageReceived(BMessage* message);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual void _ReservedOutlineListView1();
|
virtual void _ReservedOutlineListView1();
|
||||||
virtual void _ReservedOutlineListView2();
|
virtual void _ReservedOutlineListView2();
|
||||||
virtual void _ReservedOutlineListView3();
|
virtual void _ReservedOutlineListView3();
|
||||||
virtual void _ReservedOutlineListView4();
|
virtual void _ReservedOutlineListView4();
|
||||||
|
|
||||||
typedef BListView _inherited;
|
protected:
|
||||||
|
virtual void ExpandOrCollapse(BListItem* underItem, bool expand);
|
||||||
|
virtual BRect LatchRect(BRect itemRect, int32 level) const;
|
||||||
|
virtual void DrawLatch(BRect itemRect, int32 level,
|
||||||
|
bool collapsed, bool highlighted,
|
||||||
|
bool misTracked);
|
||||||
|
virtual void DrawItem(BListItem* item, BRect itemRect,
|
||||||
|
bool complete = false);
|
||||||
|
|
||||||
int32 FullListIndex(int32 index) const;
|
private:
|
||||||
int32 ListViewIndex(int32 index) const;
|
int32 _FullListIndex(int32 index) const;
|
||||||
|
|
||||||
protected:
|
void _PopulateTree(BList* tree, BList& target,
|
||||||
virtual void ExpandOrCollapse(BListItem* underItem, bool expand);
|
|
||||||
virtual BRect LatchRect(BRect itemRect, int32 level) const;
|
|
||||||
virtual void DrawLatch(BRect itemRect, int32 level, bool collapsed,
|
|
||||||
bool highlighted, bool misTracked);
|
|
||||||
virtual void DrawItem(BListItem* item, BRect itemRect, bool complete = false);
|
|
||||||
|
|
||||||
private:
|
|
||||||
void _PopulateTree(BList* tree, BList& target,
|
|
||||||
int32& firstIndex, bool onlyVisible);
|
int32& firstIndex, bool onlyVisible);
|
||||||
void _SortTree(BList* tree, bool oneLevelOnly,
|
void _SortTree(BList* tree, bool oneLevelOnly,
|
||||||
int (*compareFunc)(const BListItem* a, const BListItem* b));
|
int (*compareFunc)(const BListItem* a,
|
||||||
void _DestructTree(BList* tree);
|
const BListItem* b));
|
||||||
BList* _BuildTree(BListItem* underItem, int32& index);
|
void _DestructTree(BList* tree);
|
||||||
|
BList* _BuildTree(BListItem* underItem, int32& index);
|
||||||
|
|
||||||
BListItem* _RemoveItem(BListItem* item, int32 fullListIndex);
|
void _CullInvisibleItems(BList &list);
|
||||||
bool _SwapItems(int32 first, int32 second);
|
bool _SwapItems(int32 first, int32 second);
|
||||||
void _CullInvisibleItems(BList &list);
|
BListItem* _RemoveItem(BListItem* item, int32 fullListIndex);
|
||||||
BListItem* RemoveOne(int32 fullListIndex);
|
|
||||||
|
|
||||||
static void TrackInLatchItem(void *);
|
BListItem* _SuperitemForIndex(int32 fullListIndex, int32 level,
|
||||||
static void TrackOutLatchItem(void *);
|
|
||||||
|
|
||||||
bool OutlineSwapItems(int32 a, int32 b);
|
|
||||||
bool OutlineMoveItem(int32 from, int32 to);
|
|
||||||
bool OutlineReplaceItem(int32 index, BListItem* item);
|
|
||||||
void CommonMoveItems(int32 from, int32 count, int32 to);
|
|
||||||
BListItem* _SuperitemForIndex(int32 fullListIndex, int32 level,
|
|
||||||
int32* _superIndex = NULL);
|
int32* _superIndex = NULL);
|
||||||
int32 _FindPreviousVisibleIndex(int32 fullListIndex);
|
int32 _FindPreviousVisibleIndex(int32 fullListIndex);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BList fFullList;
|
BList fFullList;
|
||||||
uint32 _reserved[2];
|
uint32 _reserved[2];
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _OUTLINE_LIST_VIEW_H
|
#endif // _OUTLINE_LIST_VIEW_H
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2001-2008, Haiku Inc.
|
* Copyright 2001-2009, Haiku Inc.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -12,34 +12,69 @@
|
|||||||
//! BOutlineListView represents a "nestable" list view.
|
//! BOutlineListView represents a "nestable" list view.
|
||||||
|
|
||||||
#include <OutlineListView.h>
|
#include <OutlineListView.h>
|
||||||
#include <Window.h>
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <Window.h>
|
||||||
|
|
||||||
#include <binary_compatibility/Interface.h>
|
#include <binary_compatibility/Interface.h>
|
||||||
|
|
||||||
|
|
||||||
const float kLatchHeight = 8.0f;
|
typedef int (*compare_func)(const BListItem* a, const BListItem* b);
|
||||||
const float kLatchWidth = 4.0f;
|
|
||||||
|
|
||||||
struct ListItemComparator {
|
struct ListItemComparator {
|
||||||
ListItemComparator(int (*compareFunc)(const BListItem *, const BListItem *))
|
ListItemComparator(compare_func compareFunc)
|
||||||
: fCompareFunc(compareFunc)
|
:
|
||||||
|
fCompareFunc(compareFunc)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator()(const BListItem *a, const BListItem *b) const
|
bool operator()(const BListItem* a, const BListItem* b) const
|
||||||
{
|
{
|
||||||
return fCompareFunc(a, b) < 0;
|
return fCompareFunc(a, b) < 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int (*fCompareFunc)(const BListItem *, const BListItem *);
|
compare_func fCompareFunc;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
const float kLatchHeight = 8.0f;
|
||||||
|
const float kLatchWidth = 4.0f;
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
_GetSubItems(BList& sourceList, BList& destList, BListItem* parent, int32 start)
|
||||||
|
{
|
||||||
|
for (int32 i = start; i < sourceList.CountItems(); i++) {
|
||||||
|
BListItem* item = (BListItem*)sourceList.ItemAt(i);
|
||||||
|
if (item->OutlineLevel() <= parent->OutlineLevel())
|
||||||
|
break;
|
||||||
|
destList.AddItem(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
_DoSwap(BList& list, int32 firstIndex, int32 secondIndex, BList* firstItems,
|
||||||
|
BList* secondItems)
|
||||||
|
{
|
||||||
|
BListItem* item = (BListItem*)list.ItemAt(firstIndex);
|
||||||
|
list.SwapItems(firstIndex, secondIndex);
|
||||||
|
list.RemoveItems(secondIndex + 1, secondItems->CountItems());
|
||||||
|
list.RemoveItems(firstIndex + 1, firstItems->CountItems());
|
||||||
|
list.AddList(secondItems, firstIndex + 1);
|
||||||
|
int32 newIndex = list.IndexOf(item);
|
||||||
|
if (newIndex + 1 < list.CountItems())
|
||||||
|
list.AddList(firstItems, newIndex + 1);
|
||||||
|
else
|
||||||
|
list.AddList(firstItems);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark -
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
@@ -50,17 +85,24 @@ BOutlineListView::BOutlineListView(BRect frame, const char* name,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BOutlineListView::BOutlineListView(const char* name, list_view_type type,
|
||||||
|
uint32 flags)
|
||||||
|
: BListView(name, type, flags)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
BOutlineListView::BOutlineListView(BMessage* archive)
|
BOutlineListView::BOutlineListView(BMessage* archive)
|
||||||
: BListView(archive)
|
: BListView(archive)
|
||||||
{
|
{
|
||||||
int32 i = 0;
|
int32 i = 0;
|
||||||
BMessage subData;
|
BMessage subData;
|
||||||
while (archive->FindMessage("_l_full_items", i++, &subData) == B_OK) {
|
while (archive->FindMessage("_l_full_items", i++, &subData) == B_OK) {
|
||||||
BArchivable *object = instantiate_object(&subData);
|
BArchivable* object = instantiate_object(&subData);
|
||||||
if (!object)
|
if (!object)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
BListItem *item = dynamic_cast<BListItem*>(object);
|
BListItem* item = dynamic_cast<BListItem*>(object);
|
||||||
if (item)
|
if (item)
|
||||||
AddItem(item);
|
AddItem(item);
|
||||||
}
|
}
|
||||||
@@ -73,7 +115,7 @@ BOutlineListView::~BOutlineListView()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BArchivable *
|
BArchivable*
|
||||||
BOutlineListView::Instantiate(BMessage* archive)
|
BOutlineListView::Instantiate(BMessage* archive)
|
||||||
{
|
{
|
||||||
if (validate_instantiation(archive, "BOutlineListView"))
|
if (validate_instantiation(archive, "BOutlineListView"))
|
||||||
@@ -97,7 +139,7 @@ BOutlineListView::Archive(BMessage* archive, bool deep) const
|
|||||||
status = archive->AddInt32("_lv_type", fListType);
|
status = archive->AddInt32("_lv_type", fListType);
|
||||||
if (status == B_OK && deep) {
|
if (status == B_OK && deep) {
|
||||||
int32 i = 0;
|
int32 i = 0;
|
||||||
BListItem *item = NULL;
|
BListItem* item = NULL;
|
||||||
while ((item = static_cast<BListItem*>(fFullList.ItemAt(i++)))) {
|
while ((item = static_cast<BListItem*>(fFullList.ItemAt(i++)))) {
|
||||||
BMessage subData;
|
BMessage subData;
|
||||||
status = item->Archive(&subData, true);
|
status = item->Archive(&subData, true);
|
||||||
@@ -127,7 +169,7 @@ BOutlineListView::MouseDown(BPoint point)
|
|||||||
int32 index = IndexOf(point);
|
int32 index = IndexOf(point);
|
||||||
|
|
||||||
if (index != -1) {
|
if (index != -1) {
|
||||||
BListItem *item = ItemAt(index);
|
BListItem* item = ItemAt(index);
|
||||||
|
|
||||||
if (item->fHasSubitems
|
if (item->fHasSubitems
|
||||||
&& LatchRect(ItemFrame(index), item->fLevel).Contains(point)) {
|
&& LatchRect(ItemFrame(index), item->fLevel).Contains(point)) {
|
||||||
@@ -149,7 +191,7 @@ BOutlineListView::KeyDown(const char* bytes, int32 numBytes)
|
|||||||
switch (bytes[0]) {
|
switch (bytes[0]) {
|
||||||
case B_RIGHT_ARROW:
|
case B_RIGHT_ARROW:
|
||||||
{
|
{
|
||||||
BListItem *item = ItemAt(currentSel);
|
BListItem* item = ItemAt(currentSel);
|
||||||
if (item && item->fHasSubitems) {
|
if (item && item->fHasSubitems) {
|
||||||
if (!IsExpanded(currentSel))
|
if (!IsExpanded(currentSel))
|
||||||
Expand(item);
|
Expand(item);
|
||||||
@@ -161,7 +203,7 @@ BOutlineListView::KeyDown(const char* bytes, int32 numBytes)
|
|||||||
|
|
||||||
case B_LEFT_ARROW:
|
case B_LEFT_ARROW:
|
||||||
{
|
{
|
||||||
BListItem *item = ItemAt(currentSel);
|
BListItem* item = ItemAt(currentSel);
|
||||||
if (item) {
|
if (item) {
|
||||||
if (item->fHasSubitems)
|
if (item->fHasSubitems)
|
||||||
Collapse(item);
|
Collapse(item);
|
||||||
@@ -248,7 +290,7 @@ BOutlineListView::AddItem(BListItem* item, int32 fullListIndex)
|
|||||||
// other list, too
|
// other list, too
|
||||||
|
|
||||||
if (item->fLevel > 0) {
|
if (item->fLevel > 0) {
|
||||||
BListItem *super = _SuperitemForIndex(fullListIndex, item->fLevel);
|
BListItem* super = _SuperitemForIndex(fullListIndex, item->fLevel);
|
||||||
if (super == NULL)
|
if (super == NULL)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@@ -290,7 +332,7 @@ BOutlineListView::AddList(BList* newItems, int32 fullListIndex)
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
for (int32 i = 0; i < newItems->CountItems(); i++)
|
for (int32 i = 0; i < newItems->CountItems(); i++)
|
||||||
AddItem((BListItem *)newItems->ItemAt(i), fullListIndex + i);
|
AddItem((BListItem*)newItems->ItemAt(i), fullListIndex + i);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -327,7 +369,7 @@ BOutlineListView::RemoveItems(int32 fullIndex, int32 count)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BListItem *
|
BListItem*
|
||||||
BOutlineListView::FullListItemAt(int32 fullListIndex) const
|
BOutlineListView::FullListItemAt(int32 fullListIndex) const
|
||||||
{
|
{
|
||||||
return (BListItem*)fFullList.ItemAt(fullListIndex);
|
return (BListItem*)fFullList.ItemAt(fullListIndex);
|
||||||
@@ -340,7 +382,7 @@ BOutlineListView::FullListIndexOf(BPoint point) const
|
|||||||
int32 index = BListView::IndexOf(point);
|
int32 index = BListView::IndexOf(point);
|
||||||
|
|
||||||
if (index > 0)
|
if (index > 0)
|
||||||
index = FullListIndex(index);
|
index = _FullListIndex(index);
|
||||||
|
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
@@ -353,14 +395,14 @@ BOutlineListView::FullListIndexOf(BListItem* item) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BListItem *
|
BListItem*
|
||||||
BOutlineListView::FullListFirstItem() const
|
BOutlineListView::FullListFirstItem() const
|
||||||
{
|
{
|
||||||
return (BListItem*)fFullList.FirstItem();
|
return (BListItem*)fFullList.FirstItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BListItem *
|
BListItem*
|
||||||
BOutlineListView::FullListLastItem() const
|
BOutlineListView::FullListLastItem() const
|
||||||
{
|
{
|
||||||
return (BListItem*)fFullList.LastItem();
|
return (BListItem*)fFullList.LastItem();
|
||||||
@@ -368,7 +410,7 @@ BOutlineListView::FullListLastItem() const
|
|||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
BOutlineListView::FullListHasItem(BListItem *item) const
|
BOutlineListView::FullListHasItem(BListItem* item) const
|
||||||
{
|
{
|
||||||
return fFullList.HasItem(item);
|
return fFullList.HasItem(item);
|
||||||
}
|
}
|
||||||
@@ -386,7 +428,7 @@ BOutlineListView::FullListCurrentSelection(int32 index) const
|
|||||||
{
|
{
|
||||||
int32 i = BListView::CurrentSelection(index);
|
int32 i = BListView::CurrentSelection(index);
|
||||||
|
|
||||||
BListItem *item = BListView::ItemAt(i);
|
BListItem* item = BListView::ItemAt(i);
|
||||||
if (item)
|
if (item)
|
||||||
return fFullList.IndexOf(item);
|
return fFullList.IndexOf(item);
|
||||||
|
|
||||||
@@ -424,7 +466,7 @@ BOutlineListView::FullListDoForEach(bool (*func)(BListItem* item, void* arg),
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BListItem *
|
BListItem*
|
||||||
BOutlineListView::Superitem(const BListItem* item)
|
BOutlineListView::Superitem(const BListItem* item)
|
||||||
{
|
{
|
||||||
int32 index = FullListIndexOf((BListItem*)item);
|
int32 index = FullListIndexOf((BListItem*)item);
|
||||||
@@ -546,7 +588,7 @@ BOutlineListView::Collapse(BListItem* item)
|
|||||||
bool
|
bool
|
||||||
BOutlineListView::IsExpanded(int32 fullListIndex)
|
BOutlineListView::IsExpanded(int32 fullListIndex)
|
||||||
{
|
{
|
||||||
BListItem *item = FullListItemAt(fullListIndex);
|
BListItem* item = FullListItemAt(fullListIndex);
|
||||||
if (!item)
|
if (!item)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -554,7 +596,7 @@ BOutlineListView::IsExpanded(int32 fullListIndex)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BHandler *
|
BHandler*
|
||||||
BOutlineListView::ResolveSpecifier(BMessage* msg, int32 index,
|
BOutlineListView::ResolveSpecifier(BMessage* msg, int32 index,
|
||||||
BMessage* specifier, int32 what, const char* property)
|
BMessage* specifier, int32 what, const char* property)
|
||||||
{
|
{
|
||||||
@@ -597,8 +639,8 @@ BOutlineListView::Perform(perform_code code, void* _data)
|
|||||||
{
|
{
|
||||||
perform_data_get_height_for_width* data
|
perform_data_get_height_for_width* data
|
||||||
= (perform_data_get_height_for_width*)_data;
|
= (perform_data_get_height_for_width*)_data;
|
||||||
BOutlineListView::GetHeightForWidth(data->width, &data->min, &data->max,
|
BOutlineListView::GetHeightForWidth(data->width, &data->min,
|
||||||
&data->preferred);
|
&data->max, &data->preferred);
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
case PERFORM_CODE_SET_LAYOUT:
|
case PERFORM_CODE_SET_LAYOUT:
|
||||||
@@ -692,7 +734,8 @@ BOutlineListView::SortItemsUnder(BListItem* underItem, bool oneLevelOnly,
|
|||||||
// Populate to the full list
|
// Populate to the full list
|
||||||
_PopulateTree(tree, fFullList, firstIndex, false);
|
_PopulateTree(tree, fFullList, firstIndex, false);
|
||||||
|
|
||||||
if (underItem == NULL || (underItem->IsItemVisible() && underItem->IsExpanded())) {
|
if (underItem == NULL
|
||||||
|
|| (underItem->IsItemVisible() && underItem->IsExpanded())) {
|
||||||
// Populate to BListView's list
|
// Populate to BListView's list
|
||||||
firstIndex = fList.IndexOf(underItem) + 1;
|
firstIndex = fList.IndexOf(underItem) + 1;
|
||||||
lastIndex = firstIndex;
|
lastIndex = firstIndex;
|
||||||
@@ -715,91 +758,9 @@ BOutlineListView::SortItemsUnder(BListItem* underItem, bool oneLevelOnly,
|
|||||||
_DestructTree(tree);
|
_DestructTree(tree);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
BOutlineListView::_PopulateTree(BList* tree, BList& target,
|
|
||||||
int32& firstIndex, bool onlyVisible)
|
|
||||||
{
|
|
||||||
BListItem** items = (BListItem**)target.Items();
|
|
||||||
int32 count = tree->CountItems();
|
|
||||||
|
|
||||||
for (int32 index = 0; index < count; index++) {
|
|
||||||
BListItem* item = (BListItem*)tree->ItemAtFast(index);
|
|
||||||
|
|
||||||
items[firstIndex++] = item;
|
|
||||||
|
|
||||||
if (item->HasSubitems() && (!onlyVisible || item->IsExpanded()))
|
|
||||||
_PopulateTree(item->fTemporaryList, target, firstIndex, onlyVisible);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
BOutlineListView::_SortTree(BList* tree, bool oneLevelOnly,
|
|
||||||
int (*compareFunc)(const BListItem* a, const BListItem* b))
|
|
||||||
{
|
|
||||||
BListItem **items = (BListItem **)tree->Items();
|
|
||||||
std::sort(items, items + tree->CountItems(), ListItemComparator(compareFunc));
|
|
||||||
|
|
||||||
if (oneLevelOnly)
|
|
||||||
return;
|
|
||||||
|
|
||||||
for (int32 index = tree->CountItems(); index-- > 0;) {
|
|
||||||
BListItem* item = (BListItem*)tree->ItemAt(index);
|
|
||||||
|
|
||||||
if (item->HasSubitems())
|
|
||||||
_SortTree(item->fTemporaryList, false, compareFunc);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
BOutlineListView::_DestructTree(BList* tree)
|
|
||||||
{
|
|
||||||
for (int32 index = tree->CountItems(); index-- > 0;) {
|
|
||||||
BListItem* item = (BListItem*)tree->ItemAt(index);
|
|
||||||
|
|
||||||
if (item->HasSubitems())
|
|
||||||
_DestructTree(item->fTemporaryList);
|
|
||||||
}
|
|
||||||
|
|
||||||
delete tree;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
BList*
|
|
||||||
BOutlineListView::_BuildTree(BListItem* underItem, int32& fullIndex)
|
|
||||||
{
|
|
||||||
int32 fullCount = FullListCountItems();
|
|
||||||
uint32 level = underItem != NULL ? underItem->OutlineLevel() + 1 : 0;
|
|
||||||
BList* list = new BList;
|
|
||||||
if (underItem != NULL)
|
|
||||||
underItem->fTemporaryList = list;
|
|
||||||
|
|
||||||
while (fullIndex < fullCount) {
|
|
||||||
BListItem *item = FullListItemAt(fullIndex);
|
|
||||||
|
|
||||||
// If we jump out of the subtree, break out
|
|
||||||
if (item->fLevel < level)
|
|
||||||
break;
|
|
||||||
|
|
||||||
// If the level matches, put them into the list
|
|
||||||
// (we handle the case of a missing sublevel gracefully)
|
|
||||||
list->AddItem(item);
|
|
||||||
fullIndex++;
|
|
||||||
|
|
||||||
if (item->HasSubitems()) {
|
|
||||||
// we're going deeper
|
|
||||||
_BuildTree(item, fullIndex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int32
|
int32
|
||||||
BOutlineListView::CountItemsUnder(BListItem* underItem,
|
BOutlineListView::CountItemsUnder(BListItem* underItem, bool oneLevelOnly) const
|
||||||
bool oneLevelOnly) const
|
|
||||||
{
|
{
|
||||||
int32 i = FullListIndexOf(underItem);
|
int32 i = FullListIndexOf(underItem);
|
||||||
if (i == -1)
|
if (i == -1)
|
||||||
@@ -810,7 +771,7 @@ BOutlineListView::CountItemsUnder(BListItem* underItem,
|
|||||||
uint32 baseLevel = underItem->OutlineLevel();
|
uint32 baseLevel = underItem->OutlineLevel();
|
||||||
|
|
||||||
for (; i < FullListCountItems(); i++) {
|
for (; i < FullListCountItems(); i++) {
|
||||||
BListItem *item = FullListItemAt(i);
|
BListItem* item = FullListItemAt(i);
|
||||||
|
|
||||||
// If we jump out of the subtree, return count
|
// If we jump out of the subtree, return count
|
||||||
if (item->fLevel <= baseLevel)
|
if (item->fLevel <= baseLevel)
|
||||||
@@ -825,16 +786,16 @@ BOutlineListView::CountItemsUnder(BListItem* underItem,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BListItem *
|
BListItem*
|
||||||
BOutlineListView::EachItemUnder(BListItem *underItem, bool oneLevelOnly,
|
BOutlineListView::EachItemUnder(BListItem* underItem, bool oneLevelOnly,
|
||||||
BListItem *(*eachFunc)(BListItem* item, void* arg), void* arg)
|
BListItem* (*eachFunc)(BListItem* item, void* arg), void* arg)
|
||||||
{
|
{
|
||||||
int32 i = IndexOf(underItem);
|
int32 i = IndexOf(underItem);
|
||||||
if (i == -1)
|
if (i == -1)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
while (i < FullListCountItems()) {
|
while (i < FullListCountItems()) {
|
||||||
BListItem *item = FullListItemAt(i);
|
BListItem* item = FullListItemAt(i);
|
||||||
|
|
||||||
// If we jump out of the subtree, return NULL
|
// If we jump out of the subtree, return NULL
|
||||||
if (item->fLevel < underItem->OutlineLevel())
|
if (item->fLevel < underItem->OutlineLevel())
|
||||||
@@ -854,7 +815,7 @@ BOutlineListView::EachItemUnder(BListItem *underItem, bool oneLevelOnly,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BListItem *
|
BListItem*
|
||||||
BOutlineListView::ItemUnderAt(BListItem* underItem,
|
BOutlineListView::ItemUnderAt(BListItem* underItem,
|
||||||
bool oneLevelOnly, int32 index) const
|
bool oneLevelOnly, int32 index) const
|
||||||
{
|
{
|
||||||
@@ -863,7 +824,7 @@ BOutlineListView::ItemUnderAt(BListItem* underItem,
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
while (i < FullListCountItems()) {
|
while (i < FullListCountItems()) {
|
||||||
BListItem *item = FullListItemAt(i);
|
BListItem* item = FullListItemAt(i);
|
||||||
|
|
||||||
// If we jump out of the subtree, return NULL
|
// If we jump out of the subtree, return NULL
|
||||||
if (item->fLevel < underItem->OutlineLevel())
|
if (item->fLevel < underItem->OutlineLevel())
|
||||||
@@ -883,88 +844,6 @@ BOutlineListView::ItemUnderAt(BListItem* underItem,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _GetSubItems(BList &sourceList, BList &destList,
|
|
||||||
BListItem *parent, int32 start)
|
|
||||||
{
|
|
||||||
for (int32 i = start; i < sourceList.CountItems(); i++) {
|
|
||||||
BListItem *item = (BListItem *)sourceList.ItemAt(i);
|
|
||||||
if (item->OutlineLevel() <= parent->OutlineLevel())
|
|
||||||
break;
|
|
||||||
destList.AddItem(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
_DoSwap(BList &list, int32 firstIndex, int32 secondIndex, BList *firstItems,
|
|
||||||
BList *secondItems)
|
|
||||||
{
|
|
||||||
BListItem *item = (BListItem *)list.ItemAt(firstIndex);
|
|
||||||
list.SwapItems(firstIndex, secondIndex);
|
|
||||||
list.RemoveItems(secondIndex + 1, secondItems->CountItems());
|
|
||||||
list.RemoveItems(firstIndex + 1, firstItems->CountItems());
|
|
||||||
list.AddList(secondItems, firstIndex + 1);
|
|
||||||
int32 newIndex = list.IndexOf(item);
|
|
||||||
if (newIndex + 1 < list.CountItems())
|
|
||||||
list.AddList(firstItems, newIndex + 1);
|
|
||||||
else
|
|
||||||
list.AddList(firstItems);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
BOutlineListView::_CullInvisibleItems(BList &list)
|
|
||||||
{
|
|
||||||
int32 index = 0;
|
|
||||||
while (index < list.CountItems()) {
|
|
||||||
if (reinterpret_cast<BListItem *>(list.ItemAt(index))->IsItemVisible())
|
|
||||||
++index;
|
|
||||||
else
|
|
||||||
list.RemoveItem(index);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
|
||||||
BOutlineListView::_SwapItems(int32 first, int32 second)
|
|
||||||
{
|
|
||||||
// same item, do nothing
|
|
||||||
if (first == second)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
// fail, first item out of bounds
|
|
||||||
if ((first < 0) || (first >= CountItems()))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
// fail, second item out of bounds
|
|
||||||
if ((second < 0) || (second >= CountItems()))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
int32 firstIndex = min_c(first, second);
|
|
||||||
int32 secondIndex = max_c(first, second);
|
|
||||||
BListItem *firstItem = ItemAt(firstIndex);
|
|
||||||
BListItem *secondItem = ItemAt(secondIndex);
|
|
||||||
BList firstSubItems, secondSubItems;
|
|
||||||
|
|
||||||
if (Superitem(firstItem) != Superitem(secondItem))
|
|
||||||
return false;
|
|
||||||
if (!firstItem->IsItemVisible() || !secondItem->IsItemVisible())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
int32 fullFirstIndex = FullListIndex(firstIndex);
|
|
||||||
int32 fullSecondIndex = FullListIndex(secondIndex);
|
|
||||||
_GetSubItems(fFullList, firstSubItems, firstItem, fullFirstIndex + 1);
|
|
||||||
_GetSubItems(fFullList, secondSubItems, secondItem, fullSecondIndex + 1);
|
|
||||||
_DoSwap(fFullList, fullFirstIndex, fullSecondIndex, &firstSubItems,
|
|
||||||
&secondSubItems);
|
|
||||||
|
|
||||||
_CullInvisibleItems(firstSubItems);
|
|
||||||
_CullInvisibleItems(secondSubItems);
|
|
||||||
_DoSwap(fList, firstIndex, secondIndex, &firstSubItems,
|
|
||||||
&secondSubItems);
|
|
||||||
|
|
||||||
_RecalcItemTops(firstIndex);
|
|
||||||
_RescanSelection(firstIndex, secondIndex + secondSubItems.CountItems());
|
|
||||||
Invalidate(Bounds());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
BOutlineListView::DoMiscellaneous(MiscCode code, MiscData* data)
|
BOutlineListView::DoMiscellaneous(MiscCode code, MiscData* data)
|
||||||
@@ -989,32 +868,8 @@ void BOutlineListView::_ReservedOutlineListView3() {}
|
|||||||
void BOutlineListView::_ReservedOutlineListView4() {}
|
void BOutlineListView::_ReservedOutlineListView4() {}
|
||||||
|
|
||||||
|
|
||||||
int32
|
|
||||||
BOutlineListView::FullListIndex(int32 index) const
|
|
||||||
{
|
|
||||||
BListItem *item = ItemAt(index);
|
|
||||||
|
|
||||||
if (item == NULL)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
return FullListIndexOf(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int32
|
|
||||||
BOutlineListView::ListViewIndex(int32 index) const
|
|
||||||
{
|
|
||||||
BListItem *item = ItemAt(index);
|
|
||||||
|
|
||||||
if (item == NULL)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
return BListView::IndexOf(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BOutlineListView::ExpandOrCollapse(BListItem *underItem, bool expand)
|
BOutlineListView::ExpandOrCollapse(BListItem* underItem, bool expand)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1081,20 +936,171 @@ BOutlineListView::DrawItem(BListItem* item, BRect itemRect, bool complete)
|
|||||||
if (item->fHasSubitems)
|
if (item->fHasSubitems)
|
||||||
DrawLatch(itemRect, item->fLevel, !item->IsExpanded(), false, false);
|
DrawLatch(itemRect, item->fLevel, !item->IsExpanded(), false, false);
|
||||||
|
|
||||||
itemRect.left += (item->fLevel) * 10.0f + 15.0f;
|
itemRect.left += item->fLevel * 10.0f + 15.0f;
|
||||||
item->DrawItem(this, itemRect, complete);
|
item->DrawItem(this, itemRect, complete);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
int32
|
||||||
\brief Removes a single item from the list and all of its children.
|
BOutlineListView::_FullListIndex(int32 index) const
|
||||||
|
{
|
||||||
|
BListItem* item = ItemAt(index);
|
||||||
|
|
||||||
|
if (item == NULL)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
return FullListIndexOf(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BOutlineListView::_PopulateTree(BList* tree, BList& target,
|
||||||
|
int32& firstIndex, bool onlyVisible)
|
||||||
|
{
|
||||||
|
BListItem** items = (BListItem**)target.Items();
|
||||||
|
int32 count = tree->CountItems();
|
||||||
|
|
||||||
|
for (int32 index = 0; index < count; index++) {
|
||||||
|
BListItem* item = (BListItem*)tree->ItemAtFast(index);
|
||||||
|
|
||||||
|
items[firstIndex++] = item;
|
||||||
|
|
||||||
|
if (item->HasSubitems() && (!onlyVisible || item->IsExpanded()))
|
||||||
|
_PopulateTree(item->fTemporaryList, target, firstIndex, onlyVisible);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BOutlineListView::_SortTree(BList* tree, bool oneLevelOnly,
|
||||||
|
int (*compareFunc)(const BListItem* a, const BListItem* b))
|
||||||
|
{
|
||||||
|
BListItem** items = (BListItem**)tree->Items();
|
||||||
|
std::sort(items, items + tree->CountItems(), ListItemComparator(compareFunc));
|
||||||
|
|
||||||
|
if (oneLevelOnly)
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (int32 index = tree->CountItems(); index-- > 0;) {
|
||||||
|
BListItem* item = (BListItem*)tree->ItemAt(index);
|
||||||
|
|
||||||
|
if (item->HasSubitems())
|
||||||
|
_SortTree(item->fTemporaryList, false, compareFunc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BOutlineListView::_DestructTree(BList* tree)
|
||||||
|
{
|
||||||
|
for (int32 index = tree->CountItems(); index-- > 0;) {
|
||||||
|
BListItem* item = (BListItem*)tree->ItemAt(index);
|
||||||
|
|
||||||
|
if (item->HasSubitems())
|
||||||
|
_DestructTree(item->fTemporaryList);
|
||||||
|
}
|
||||||
|
|
||||||
|
delete tree;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BList*
|
||||||
|
BOutlineListView::_BuildTree(BListItem* underItem, int32& fullIndex)
|
||||||
|
{
|
||||||
|
int32 fullCount = FullListCountItems();
|
||||||
|
uint32 level = underItem != NULL ? underItem->OutlineLevel() + 1 : 0;
|
||||||
|
BList* list = new BList;
|
||||||
|
if (underItem != NULL)
|
||||||
|
underItem->fTemporaryList = list;
|
||||||
|
|
||||||
|
while (fullIndex < fullCount) {
|
||||||
|
BListItem* item = FullListItemAt(fullIndex);
|
||||||
|
|
||||||
|
// If we jump out of the subtree, break out
|
||||||
|
if (item->fLevel < level)
|
||||||
|
break;
|
||||||
|
|
||||||
|
// If the level matches, put them into the list
|
||||||
|
// (we handle the case of a missing sublevel gracefully)
|
||||||
|
list->AddItem(item);
|
||||||
|
fullIndex++;
|
||||||
|
|
||||||
|
if (item->HasSubitems()) {
|
||||||
|
// we're going deeper
|
||||||
|
_BuildTree(item, fullIndex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BOutlineListView::_CullInvisibleItems(BList& list)
|
||||||
|
{
|
||||||
|
int32 index = 0;
|
||||||
|
while (index < list.CountItems()) {
|
||||||
|
if (reinterpret_cast<BListItem*>(list.ItemAt(index))->IsItemVisible())
|
||||||
|
++index;
|
||||||
|
else
|
||||||
|
list.RemoveItem(index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
BOutlineListView::_SwapItems(int32 first, int32 second)
|
||||||
|
{
|
||||||
|
// same item, do nothing
|
||||||
|
if (first == second)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
// fail, first item out of bounds
|
||||||
|
if ((first < 0) || (first >= CountItems()))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// fail, second item out of bounds
|
||||||
|
if ((second < 0) || (second >= CountItems()))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
int32 firstIndex = min_c(first, second);
|
||||||
|
int32 secondIndex = max_c(first, second);
|
||||||
|
BListItem* firstItem = ItemAt(firstIndex);
|
||||||
|
BListItem* secondItem = ItemAt(secondIndex);
|
||||||
|
BList firstSubItems, secondSubItems;
|
||||||
|
|
||||||
|
if (Superitem(firstItem) != Superitem(secondItem))
|
||||||
|
return false;
|
||||||
|
if (!firstItem->IsItemVisible() || !secondItem->IsItemVisible())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
int32 fullFirstIndex = _FullListIndex(firstIndex);
|
||||||
|
int32 fullSecondIndex = _FullListIndex(secondIndex);
|
||||||
|
_GetSubItems(fFullList, firstSubItems, firstItem, fullFirstIndex + 1);
|
||||||
|
_GetSubItems(fFullList, secondSubItems, secondItem, fullSecondIndex + 1);
|
||||||
|
_DoSwap(fFullList, fullFirstIndex, fullSecondIndex, &firstSubItems,
|
||||||
|
&secondSubItems);
|
||||||
|
|
||||||
|
_CullInvisibleItems(firstSubItems);
|
||||||
|
_CullInvisibleItems(secondSubItems);
|
||||||
|
_DoSwap(fList, firstIndex, secondIndex, &firstSubItems,
|
||||||
|
&secondSubItems);
|
||||||
|
|
||||||
|
_RecalcItemTops(firstIndex);
|
||||||
|
_RescanSelection(firstIndex, secondIndex + secondSubItems.CountItems());
|
||||||
|
Invalidate(Bounds());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*! \brief Removes a single item from the list and all of its children.
|
||||||
|
|
||||||
Unlike the BeOS version, this one will actually delete the children, too,
|
Unlike the BeOS version, this one will actually delete the children, too,
|
||||||
as there should be no reference left to them. This may cause problems for
|
as there should be no reference left to them. This may cause problems for
|
||||||
applications that actually take the misbehaviour of the Be classes into
|
applications that actually take the misbehaviour of the Be classes into
|
||||||
account.
|
account.
|
||||||
*/
|
*/
|
||||||
BListItem *
|
BListItem*
|
||||||
BOutlineListView::_RemoveItem(BListItem* item, int32 fullIndex)
|
BOutlineListView::_RemoveItem(BListItem* item, int32 fullIndex)
|
||||||
{
|
{
|
||||||
if (item == NULL || fullIndex < 0 || fullIndex >= FullListCountItems())
|
if (item == NULL || fullIndex < 0 || fullIndex >= FullListCountItems())
|
||||||
@@ -1107,7 +1113,7 @@ BOutlineListView::_RemoveItem(BListItem* item, int32 fullIndex)
|
|||||||
if (item->IsItemVisible()) {
|
if (item->IsItemVisible()) {
|
||||||
// remove children, too
|
// remove children, too
|
||||||
while (fullIndex + 1 < CountItems()) {
|
while (fullIndex + 1 < CountItems()) {
|
||||||
BListItem *subItem = ItemAt(fullIndex + 1);
|
BListItem* subItem = ItemAt(fullIndex + 1);
|
||||||
|
|
||||||
if (subItem->OutlineLevel() <= level)
|
if (subItem->OutlineLevel() <= level)
|
||||||
break;
|
break;
|
||||||
@@ -1133,61 +1139,14 @@ BOutlineListView::_RemoveItem(BListItem* item, int32 fullIndex)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BListItem *
|
/*! Returns the super item before the item specified by \a fullListIndex
|
||||||
BOutlineListView::RemoveOne(int32 fullListIndex)
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
BOutlineListView::TrackInLatchItem(void *)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
BOutlineListView::TrackOutLatchItem(void *)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool
|
|
||||||
BOutlineListView::OutlineSwapItems(int32 a, int32 b)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool
|
|
||||||
BOutlineListView::OutlineMoveItem(int32 from, int32 to)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool
|
|
||||||
BOutlineListView::OutlineReplaceItem(int32 index, BListItem *item)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
BOutlineListView::CommonMoveItems(int32 from, int32 count, int32 to)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*!
|
|
||||||
Returns the super item before the item specified by \a fullListIndex
|
|
||||||
and \a level.
|
and \a level.
|
||||||
*/
|
*/
|
||||||
BListItem *
|
BListItem*
|
||||||
BOutlineListView::_SuperitemForIndex(int32 fullListIndex, int32 level,
|
BOutlineListView::_SuperitemForIndex(int32 fullListIndex, int32 level,
|
||||||
int32* _superIndex)
|
int32* _superIndex)
|
||||||
{
|
{
|
||||||
BListItem *item;
|
BListItem* item;
|
||||||
fullListIndex--;
|
fullListIndex--;
|
||||||
|
|
||||||
while (fullListIndex >= 0) {
|
while (fullListIndex >= 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user