* Implemented BOutlineListView::FullListSortItems() and SortItemsUnder() - dunno
what Be's implementation did wrong but instead of taking almost 30 seconds to sort the MIME type database (roughly 1100 entries, and yes, that's why the original FileTypes is that slow when it has to show the internal types), this one needs only 4 ms for the same task (that's an amply 7500x speedup). * Implemented some more missing functions - it's by no means complete yet, though. * Rewrote OutlineListView.h, ListItem.h, and StringItem.h. * Fixed some minor bugs, but there are probably a lot more. * Major cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16349 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,17 +1,11 @@
|
|||||||
/*******************************************************************************
|
/*
|
||||||
/
|
* Copyright 2006, Haiku, Inc. All Rights Reserved.
|
||||||
/ File: ListItem.h
|
* Distributed under the terms of the MIT License.
|
||||||
/
|
*/
|
||||||
/ Description: BListView represents a one-dimensional list view.
|
|
||||||
/
|
|
||||||
/ Copyright 1996-98, Be Incorporated, All Rights Reserved
|
|
||||||
/
|
|
||||||
*******************************************************************************/
|
|
||||||
|
|
||||||
#ifndef _LIST_ITEM_H
|
#ifndef _LIST_ITEM_H
|
||||||
#define _LIST_ITEM_H
|
#define _LIST_ITEM_H
|
||||||
|
|
||||||
#include <BeBuild.h>
|
|
||||||
#include <Archivable.h>
|
#include <Archivable.h>
|
||||||
#include <Rect.h>
|
#include <Rect.h>
|
||||||
|
|
||||||
@@ -20,15 +14,14 @@ class BMessage;
|
|||||||
class BOutlineListView;
|
class BOutlineListView;
|
||||||
class BView;
|
class BView;
|
||||||
|
|
||||||
/*----------------------------------------------------------------*/
|
|
||||||
/*----- BListItem class ------------------------------------------*/
|
|
||||||
|
|
||||||
class BListItem : public BArchivable {
|
class BListItem : public BArchivable {
|
||||||
public:
|
public:
|
||||||
BListItem(uint32 outlineLevel = 0, bool expanded = true);
|
BListItem(uint32 outlineLevel = 0, bool expanded = true);
|
||||||
BListItem(BMessage *data);
|
BListItem(BMessage* archive);
|
||||||
virtual ~BListItem();
|
virtual ~BListItem();
|
||||||
virtual status_t Archive(BMessage *data, bool deep = true) const;
|
|
||||||
|
virtual status_t Archive(BMessage* archive, bool deep = true) const;
|
||||||
|
|
||||||
float Height() const;
|
float Height() const;
|
||||||
float Width() const;
|
float Width() const;
|
||||||
@@ -36,23 +29,21 @@ virtual status_t Archive(BMessage *data, bool deep = true) const;
|
|||||||
void Select();
|
void Select();
|
||||||
void Deselect();
|
void Deselect();
|
||||||
|
|
||||||
virtual void SetEnabled(bool on);
|
virtual void SetEnabled(bool enabled);
|
||||||
bool IsEnabled() const;
|
bool IsEnabled() const;
|
||||||
|
|
||||||
void SetHeight(float height);
|
void SetHeight(float height);
|
||||||
void SetWidth(float width);
|
void SetWidth(float width);
|
||||||
virtual void DrawItem(BView *owner,
|
virtual void DrawItem(BView* owner, BRect frame,
|
||||||
BRect bounds,
|
|
||||||
bool complete = false) = 0;
|
bool complete = false) = 0;
|
||||||
virtual void Update(BView* owner, const BFont* font);
|
virtual void Update(BView* owner, const BFont* font);
|
||||||
|
|
||||||
virtual status_t Perform(perform_code d, void *arg);
|
virtual status_t Perform(perform_code code, void* arg);
|
||||||
|
|
||||||
bool IsExpanded() const;
|
bool IsExpanded() const;
|
||||||
void SetExpanded(bool expanded);
|
void SetExpanded(bool expanded);
|
||||||
uint32 OutlineLevel() const;
|
uint32 OutlineLevel() const;
|
||||||
|
|
||||||
/*----- Private or reserved -----------------------------------------*/
|
|
||||||
private:
|
private:
|
||||||
friend class BOutlineListView;
|
friend class BOutlineListView;
|
||||||
|
|
||||||
@@ -61,14 +52,15 @@ friend class BOutlineListView;
|
|||||||
virtual void _ReservedListItem1();
|
virtual void _ReservedListItem1();
|
||||||
virtual void _ReservedListItem2();
|
virtual void _ReservedListItem2();
|
||||||
|
|
||||||
BListItem(const BListItem &);
|
BListItem(const BListItem& item);
|
||||||
BListItem &operator=(const BListItem &);
|
BListItem& operator=(const BListItem& item);
|
||||||
|
|
||||||
/* calls used by BOutlineListView*/
|
|
||||||
bool IsItemVisible() const;
|
bool IsItemVisible() const;
|
||||||
void SetItemVisible(bool);
|
void SetItemVisible(bool visible);
|
||||||
|
|
||||||
uint32 _reserved[2];
|
private:
|
||||||
|
uint32 _reserved[1];
|
||||||
|
BList* fTemporaryList;
|
||||||
float fWidth;
|
float fWidth;
|
||||||
float fHeight;
|
float fHeight;
|
||||||
uint32 fLevel;
|
uint32 fLevel;
|
||||||
@@ -79,9 +71,7 @@ virtual void _ReservedListItem2();
|
|||||||
bool fVisible : 1;
|
bool fVisible : 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#include <StringItem.h>
|
||||||
|
// to maintain source compatibility
|
||||||
|
|
||||||
/*-------------------------------------------------------------*/
|
#endif // _LIST_ITEM_H
|
||||||
|
|
||||||
#include <StringItem.h> /* to maintain compatibility */
|
|
||||||
|
|
||||||
#endif /* _LIST_ITEM_H */
|
|
||||||
|
|||||||
@@ -1,42 +1,33 @@
|
|||||||
/*******************************************************************************
|
/*
|
||||||
/
|
* Copyright 2006, Haiku, Inc. All Rights Reserved.
|
||||||
/ File: OutlineListView.h
|
* Distributed under the terms of the MIT License.
|
||||||
/
|
*/
|
||||||
/ Description: BOutlineListView represents a "nestable" list view.
|
|
||||||
/
|
|
||||||
/ Copyright 1997-98, Be Incorporated, All Rights Reserved
|
|
||||||
/
|
|
||||||
*******************************************************************************/
|
|
||||||
|
|
||||||
#ifndef _OUTLINE_LIST_VIEW_H
|
#ifndef _OUTLINE_LIST_VIEW_H
|
||||||
#define _OUTLINE_LIST_VIEW_H
|
#define _OUTLINE_LIST_VIEW_H
|
||||||
|
|
||||||
#include <BeBuild.h>
|
|
||||||
#include <ListView.h>
|
#include <ListView.h>
|
||||||
|
|
||||||
class BListItem;
|
class BListItem;
|
||||||
|
|
||||||
/*----------------------------------------------------------------*/
|
|
||||||
/*----- BOutlineListView class -----------------------------------*/
|
|
||||||
|
|
||||||
class BOutlineListView : public BListView {
|
class BOutlineListView : public BListView {
|
||||||
public:
|
public:
|
||||||
BOutlineListView(BRect frame,
|
BOutlineListView(BRect frame, const char* name,
|
||||||
const char * name,
|
|
||||||
list_view_type type = B_SINGLE_SELECTION_LIST,
|
list_view_type type = B_SINGLE_SELECTION_LIST,
|
||||||
uint32 resizeMask = B_FOLLOW_LEFT | B_FOLLOW_TOP,
|
uint32 resizeMode = B_FOLLOW_LEFT | B_FOLLOW_TOP,
|
||||||
uint32 flags = B_WILL_DRAW | B_FRAME_EVENTS
|
uint32 flags = B_WILL_DRAW | B_FRAME_EVENTS
|
||||||
| B_NAVIGABLE);
|
| B_NAVIGABLE);
|
||||||
BOutlineListView(BMessage *data);
|
BOutlineListView(BMessage* archive);
|
||||||
virtual ~BOutlineListView();
|
virtual ~BOutlineListView();
|
||||||
|
|
||||||
static BArchivable *Instantiate(BMessage *data);
|
static BArchivable* Instantiate(BMessage* archive);
|
||||||
virtual status_t Archive(BMessage *data, 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 new_position);
|
virtual void FrameMoved(BPoint newPosition);
|
||||||
virtual void FrameResized(float new_width, float new_height);
|
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);
|
||||||
@@ -50,8 +41,6 @@ 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);
|
||||||
|
|
||||||
|
|
||||||
/* The following calls operator on the full outlinelist */
|
|
||||||
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;
|
||||||
@@ -60,10 +49,11 @@ virtual bool RemoveItems(int32 fullListIndex, int32 count);
|
|||||||
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 *));
|
void FullListDoForEach(bool (*func)(BListItem* item));
|
||||||
void FullListDoForEach(bool (*func)(BListItem *, void *), void*);
|
void FullListDoForEach(bool (*func)(BListItem* item, void *), void*);
|
||||||
|
|
||||||
BListItem* Superitem(const BListItem* item);
|
BListItem* Superitem(const BListItem* item);
|
||||||
|
|
||||||
@@ -72,44 +62,34 @@ virtual void MakeEmpty();
|
|||||||
|
|
||||||
bool IsExpanded(int32 fullListIndex);
|
bool IsExpanded(int32 fullListIndex);
|
||||||
|
|
||||||
virtual BHandler *ResolveSpecifier(BMessage *msg,
|
virtual BHandler* ResolveSpecifier(BMessage* message, int32 index,
|
||||||
int32 index,
|
BMessage* specifier, int32 what, const char* property);
|
||||||
BMessage *specifier,
|
|
||||||
int32 form,
|
|
||||||
const char *property);
|
|
||||||
virtual status_t GetSupportedSuites(BMessage* data);
|
virtual status_t GetSupportedSuites(BMessage* data);
|
||||||
virtual status_t Perform(perform_code d, void* arg);
|
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 state = 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,
|
||||||
|
const BListItem* second));
|
||||||
void FullListSortItems(int (*compareFunc)(const BListItem *,
|
void SortItemsUnder(BListItem* underItem, bool oneLevelOnly,
|
||||||
const BListItem *));
|
int (*compareFunc)(const BListItem* first,
|
||||||
void SortItemsUnder(BListItem *underItem,
|
const BListItem* second));
|
||||||
bool oneLevelOnly,
|
|
||||||
int (*compareFunc)(const BListItem *,
|
|
||||||
const BListItem*));
|
|
||||||
int32 CountItemsUnder(BListItem* under, bool oneLevelOnly) const;
|
int32 CountItemsUnder(BListItem* under, bool oneLevelOnly) const;
|
||||||
BListItem *EachItemUnder(BListItem *underItem,
|
BListItem* EachItemUnder(BListItem* underItem, bool oneLevelOnly,
|
||||||
bool oneLevelOnly,
|
BListItem* (*eachFunc)(BListItem* item, void* arg),
|
||||||
BListItem *(*eachFunc)(BListItem *, void *),
|
void* arg);
|
||||||
void *);
|
BListItem* ItemUnderAt(BListItem* underItem, bool oneLevelOnly,
|
||||||
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 *);
|
virtual void MessageReceived(BMessage *message);
|
||||||
|
|
||||||
/*----- Private or reserved -----------------------------------------*/
|
|
||||||
private:
|
private:
|
||||||
virtual void _ReservedOutlineListView1();
|
virtual void _ReservedOutlineListView1();
|
||||||
virtual void _ReservedOutlineListView2();
|
virtual void _ReservedOutlineListView2();
|
||||||
@@ -121,17 +101,20 @@ typedef BListView _inherited;
|
|||||||
int32 FullListIndex(int32 index) const;
|
int32 FullListIndex(int32 index) const;
|
||||||
int32 ListViewIndex(int32 index) const;
|
int32 ListViewIndex(int32 index) const;
|
||||||
|
|
||||||
#if !_PR3_COMPATIBLE_
|
|
||||||
protected:
|
protected:
|
||||||
#endif
|
|
||||||
virtual void ExpandOrCollapse(BListItem* underItem, bool expand);
|
virtual void ExpandOrCollapse(BListItem* underItem, bool expand);
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
virtual BRect LatchRect(BRect itemRect, int32 level) const;
|
virtual BRect LatchRect(BRect itemRect, int32 level) const;
|
||||||
virtual void DrawLatch(BRect itemRect, int32 level, bool collapsed,
|
virtual void DrawLatch(BRect itemRect, int32 level, bool collapsed,
|
||||||
bool highlighted, bool misTracked);
|
bool highlighted, bool misTracked);
|
||||||
virtual void DrawItem(BListItem *i, BRect cRect, bool complete = false);
|
virtual void DrawItem(BListItem* item, BRect itemRect, bool complete = false);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void _PopulateTree(BList* tree, BList& target,
|
||||||
|
int32& firstIndex, bool onlyVisible);
|
||||||
|
void _SortTree(BList* tree, bool oneLevelOnly,
|
||||||
|
int (*compareFunc)(const BListItem* a, const BListItem* b));
|
||||||
|
void _DestructTree(BList* tree);
|
||||||
|
BList* _BuildTree(BListItem* underItem, int32& index);
|
||||||
|
|
||||||
BListItem* RemoveCommon(int32 fullListIndex);
|
BListItem* RemoveCommon(int32 fullListIndex);
|
||||||
BListItem* RemoveOne(int32 fullListIndex);
|
BListItem* RemoveOne(int32 fullListIndex);
|
||||||
@@ -146,11 +129,9 @@ static void TrackOutLatchItem(void *);
|
|||||||
BListItem* SuperitemForIndex(int32 fullListIndex, int32 level);
|
BListItem* SuperitemForIndex(int32 fullListIndex, int32 level);
|
||||||
int32 FindPreviousVisibleIndex(int32 fullListIndex);
|
int32 FindPreviousVisibleIndex(int32 fullListIndex);
|
||||||
|
|
||||||
BList fullList;
|
private:
|
||||||
|
BList fFullList;
|
||||||
uint32 _reserved[2];
|
uint32 _reserved[2];
|
||||||
};
|
};
|
||||||
|
|
||||||
/*----------------------------------------------------------------*/
|
#endif // _OUTLINE_LIST_VIEW_H
|
||||||
/*----------------------------------------------------------------*/
|
|
||||||
|
|
||||||
#endif /* _OUTLINE_LIST_VIEW_H */
|
|
||||||
|
|||||||
@@ -1,35 +1,23 @@
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
/*
|
||||||
//
|
* Copyright 2006, Haiku, Inc. All Rights Reserved.
|
||||||
// File: StringItem.h
|
* Distributed under the terms of the MIT License.
|
||||||
//
|
*/
|
||||||
// Description:
|
|
||||||
//
|
|
||||||
// Copyright 2001, Ulrich Wimboeck
|
|
||||||
//
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#ifndef _STRING_ITEM_H
|
#ifndef _STRING_ITEM_H
|
||||||
#define _STRING_ITEM_H
|
#define _STRING_ITEM_H
|
||||||
|
|
||||||
|
|
||||||
#include <ListItem.h>
|
#include <ListItem.h>
|
||||||
|
|
||||||
|
|
||||||
#ifdef USE_OPENBEOS_NAMESPACE
|
class BStringItem : public BListItem {
|
||||||
namespace OpenBeOS {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
//----- BStringItem class ----------------------------------------
|
|
||||||
|
|
||||||
class BStringItem : public BListItem
|
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
BStringItem(const char *text, uint32 outlineLevel = 0, bool expanded = true);
|
BStringItem(const char* text, uint32 outlineLevel = 0,
|
||||||
BStringItem(BMessage *data);
|
bool expanded = true);
|
||||||
|
BStringItem(BMessage* archive);
|
||||||
virtual ~BStringItem();
|
virtual ~BStringItem();
|
||||||
|
|
||||||
static BArchivable *Instantiate(BMessage *data);
|
static BArchivable* Instantiate(BMessage* archive);
|
||||||
virtual status_t Archive(BMessage *data, bool deep = true) const;
|
virtual status_t Archive(BMessage* archive, bool deep = true) const;
|
||||||
|
|
||||||
virtual void DrawItem(BView* owner, BRect frame, bool complete = false);
|
virtual void DrawItem(BView* owner, BRect frame, bool complete = false);
|
||||||
virtual void SetText(const char* text);
|
virtual void SetText(const char* text);
|
||||||
@@ -43,16 +31,12 @@ private:
|
|||||||
virtual void _ReservedStringItem1();
|
virtual void _ReservedStringItem1();
|
||||||
virtual void _ReservedStringItem2();
|
virtual void _ReservedStringItem2();
|
||||||
|
|
||||||
BStringItem(const BStringItem &);
|
BStringItem(const BStringItem& item);
|
||||||
BStringItem& operator=(const BStringItem &);
|
BStringItem& operator=(const BStringItem& item);
|
||||||
|
|
||||||
char* fText;
|
char* fText;
|
||||||
float fBaselineOffset;
|
float fBaselineOffset;
|
||||||
uint32 _reserved[2];
|
uint32 _reserved[2];
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef USE_OPENBEOS_NAMESPACE
|
#endif // _STRING_ITEM_H
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* _STRING_ITEM_H */
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user