* 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:
parent
3da4d36c6a
commit
7c74b12b2a
@ -1,17 +1,11 @@
|
||||
/*******************************************************************************
|
||||
/
|
||||
/ File: ListItem.h
|
||||
/
|
||||
/ Description: BListView represents a one-dimensional list view.
|
||||
/
|
||||
/ Copyright 1996-98, Be Incorporated, All Rights Reserved
|
||||
/
|
||||
*******************************************************************************/
|
||||
|
||||
/*
|
||||
* Copyright 2006, Haiku, Inc. All Rights Reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _LIST_ITEM_H
|
||||
#define _LIST_ITEM_H
|
||||
|
||||
#include <BeBuild.h>
|
||||
|
||||
#include <Archivable.h>
|
||||
#include <Rect.h>
|
||||
|
||||
@ -20,15 +14,14 @@ class BMessage;
|
||||
class BOutlineListView;
|
||||
class BView;
|
||||
|
||||
/*----------------------------------------------------------------*/
|
||||
/*----- BListItem class ------------------------------------------*/
|
||||
|
||||
class BListItem : public BArchivable {
|
||||
public:
|
||||
public:
|
||||
BListItem(uint32 outlineLevel = 0, bool expanded = true);
|
||||
BListItem(BMessage *data);
|
||||
virtual ~BListItem();
|
||||
virtual status_t Archive(BMessage *data, bool deep = true) const;
|
||||
BListItem(BMessage* archive);
|
||||
virtual ~BListItem();
|
||||
|
||||
virtual status_t Archive(BMessage* archive, bool deep = true) const;
|
||||
|
||||
float Height() const;
|
||||
float Width() const;
|
||||
@ -36,39 +29,38 @@ virtual status_t Archive(BMessage *data, bool deep = true) const;
|
||||
void Select();
|
||||
void Deselect();
|
||||
|
||||
virtual void SetEnabled(bool on);
|
||||
virtual void SetEnabled(bool enabled);
|
||||
bool IsEnabled() const;
|
||||
|
||||
void SetHeight(float height);
|
||||
void SetWidth(float width);
|
||||
virtual void DrawItem(BView *owner,
|
||||
BRect bounds,
|
||||
virtual void DrawItem(BView* owner, BRect frame,
|
||||
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;
|
||||
void SetExpanded(bool expanded);
|
||||
uint32 OutlineLevel() const;
|
||||
|
||||
/*----- Private or reserved -----------------------------------------*/
|
||||
private:
|
||||
friend class BOutlineListView;
|
||||
private:
|
||||
friend class BOutlineListView;
|
||||
|
||||
bool HasSubitems() const;
|
||||
|
||||
virtual void _ReservedListItem1();
|
||||
virtual void _ReservedListItem2();
|
||||
virtual void _ReservedListItem1();
|
||||
virtual void _ReservedListItem2();
|
||||
|
||||
BListItem(const BListItem &);
|
||||
BListItem &operator=(const BListItem &);
|
||||
BListItem(const BListItem& item);
|
||||
BListItem& operator=(const BListItem& item);
|
||||
|
||||
/* calls used by BOutlineListView*/
|
||||
bool IsItemVisible() const;
|
||||
void SetItemVisible(bool);
|
||||
void SetItemVisible(bool visible);
|
||||
|
||||
uint32 _reserved[2];
|
||||
private:
|
||||
uint32 _reserved[1];
|
||||
BList* fTemporaryList;
|
||||
float fWidth;
|
||||
float fHeight;
|
||||
uint32 fLevel;
|
||||
@ -79,9 +71,7 @@ virtual void _ReservedListItem2();
|
||||
bool fVisible : 1;
|
||||
};
|
||||
|
||||
#include <StringItem.h>
|
||||
// to maintain source compatibility
|
||||
|
||||
/*-------------------------------------------------------------*/
|
||||
|
||||
#include <StringItem.h> /* to maintain compatibility */
|
||||
|
||||
#endif /* _LIST_ITEM_H */
|
||||
#endif // _LIST_ITEM_H
|
||||
|
@ -1,156 +1,137 @@
|
||||
/*******************************************************************************
|
||||
/
|
||||
/ File: OutlineListView.h
|
||||
/
|
||||
/ Description: BOutlineListView represents a "nestable" list view.
|
||||
/
|
||||
/ Copyright 1997-98, Be Incorporated, All Rights Reserved
|
||||
/
|
||||
*******************************************************************************/
|
||||
|
||||
/*
|
||||
* Copyright 2006, Haiku, Inc. All Rights Reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _OUTLINE_LIST_VIEW_H
|
||||
#define _OUTLINE_LIST_VIEW_H
|
||||
|
||||
#include <BeBuild.h>
|
||||
|
||||
#include <ListView.h>
|
||||
|
||||
class BListItem;
|
||||
|
||||
/*----------------------------------------------------------------*/
|
||||
/*----- BOutlineListView class -----------------------------------*/
|
||||
|
||||
class BOutlineListView : public BListView {
|
||||
public:
|
||||
BOutlineListView(BRect frame,
|
||||
const char * name,
|
||||
public:
|
||||
BOutlineListView(BRect frame, const char* name,
|
||||
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
|
||||
| B_NAVIGABLE);
|
||||
BOutlineListView(BMessage *data);
|
||||
virtual ~BOutlineListView();
|
||||
BOutlineListView(BMessage* archive);
|
||||
virtual ~BOutlineListView();
|
||||
|
||||
static BArchivable *Instantiate(BMessage *data);
|
||||
virtual status_t Archive(BMessage *data, bool deep = true) const;
|
||||
static BArchivable* Instantiate(BMessage* archive);
|
||||
virtual status_t Archive(BMessage* archive, bool deep = true) const;
|
||||
|
||||
virtual void MouseDown(BPoint where);
|
||||
virtual void KeyDown(const char *bytes, int32 numBytes);
|
||||
virtual void FrameMoved(BPoint new_position);
|
||||
virtual void FrameResized(float new_width, float new_height);
|
||||
virtual void MouseUp(BPoint where);
|
||||
virtual void MouseDown(BPoint where);
|
||||
virtual void KeyDown(const char* bytes, int32 numBytes);
|
||||
virtual void FrameMoved(BPoint newPosition);
|
||||
virtual void FrameResized(float newWidth, float newHeight);
|
||||
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, int32 fullListIndex);
|
||||
virtual bool AddList(BList *newItems);
|
||||
virtual bool AddList(BList *newItems, int32 fullListIndex);
|
||||
virtual bool AddItem(BListItem* item);
|
||||
virtual bool AddItem(BListItem* item, int32 fullListIndex);
|
||||
virtual bool AddList(BList* newItems);
|
||||
virtual bool AddList(BList* newItems, int32 fullListIndex);
|
||||
|
||||
virtual bool RemoveItem(BListItem *item);
|
||||
virtual BListItem *RemoveItem(int32 fullListIndex);
|
||||
virtual bool RemoveItems(int32 fullListIndex, int32 count);
|
||||
virtual bool RemoveItem(BListItem* item);
|
||||
virtual BListItem* RemoveItem(int32 fullListIndex);
|
||||
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(BListItem *item) const;
|
||||
BListItem *FullListFirstItem() const;
|
||||
BListItem *FullListLastItem() const;
|
||||
bool FullListHasItem(BListItem *item) const;
|
||||
int32 FullListIndexOf(BListItem* item) const;
|
||||
BListItem* FullListFirstItem() const;
|
||||
BListItem* FullListLastItem() const;
|
||||
bool FullListHasItem(BListItem* item) const;
|
||||
int32 FullListCountItems() const;
|
||||
int32 FullListCurrentSelection(int32 index = 0) const;
|
||||
virtual void MakeEmpty();
|
||||
|
||||
virtual void MakeEmpty();
|
||||
bool FullListIsEmpty() const;
|
||||
void FullListDoForEach(bool (*func)(BListItem *));
|
||||
void FullListDoForEach(bool (*func)(BListItem *, void *), void*);
|
||||
void FullListDoForEach(bool (*func)(BListItem* item));
|
||||
void FullListDoForEach(bool (*func)(BListItem* item, void *), void*);
|
||||
|
||||
BListItem *Superitem(const BListItem *item);
|
||||
BListItem* Superitem(const BListItem* item);
|
||||
|
||||
void Expand(BListItem *item);
|
||||
void Collapse(BListItem *item);
|
||||
void Expand(BListItem* item);
|
||||
void Collapse(BListItem* item);
|
||||
|
||||
bool IsExpanded(int32 fullListIndex);
|
||||
|
||||
virtual BHandler *ResolveSpecifier(BMessage *msg,
|
||||
int32 index,
|
||||
BMessage *specifier,
|
||||
int32 form,
|
||||
const char *property);
|
||||
virtual status_t GetSupportedSuites(BMessage *data);
|
||||
virtual status_t Perform(perform_code d, void *arg);
|
||||
virtual BHandler* ResolveSpecifier(BMessage* message, int32 index,
|
||||
BMessage* specifier, int32 what, const char* property);
|
||||
virtual status_t GetSupportedSuites(BMessage* data);
|
||||
virtual status_t Perform(perform_code d, void* arg);
|
||||
|
||||
virtual void ResizeToPreferred();
|
||||
virtual void GetPreferredSize(float *width, float *height);
|
||||
virtual void MakeFocus(bool state = true);
|
||||
virtual void AllAttached();
|
||||
virtual void AllDetached();
|
||||
virtual void DetachedFromWindow();
|
||||
virtual void ResizeToPreferred();
|
||||
virtual void GetPreferredSize(float* _width, float* _height);
|
||||
virtual void MakeFocus(bool focus = true);
|
||||
virtual void AllAttached();
|
||||
virtual void AllDetached();
|
||||
virtual void DetachedFromWindow();
|
||||
|
||||
|
||||
|
||||
void FullListSortItems(int (*compareFunc)(const BListItem *,
|
||||
const BListItem *));
|
||||
void SortItemsUnder(BListItem *underItem,
|
||||
bool oneLevelOnly,
|
||||
int (*compareFunc)(const BListItem *,
|
||||
const BListItem*));
|
||||
int32 CountItemsUnder(BListItem *under, bool oneLevelOnly) const;
|
||||
BListItem *EachItemUnder(BListItem *underItem,
|
||||
bool oneLevelOnly,
|
||||
BListItem *(*eachFunc)(BListItem *, void *),
|
||||
void *);
|
||||
BListItem *ItemUnderAt(BListItem *underItem,
|
||||
bool oneLevelOnly,
|
||||
void FullListSortItems(int (*compareFunc)(const BListItem* first,
|
||||
const BListItem* second));
|
||||
void SortItemsUnder(BListItem* underItem, bool oneLevelOnly,
|
||||
int (*compareFunc)(const BListItem* first,
|
||||
const BListItem* second));
|
||||
int32 CountItemsUnder(BListItem* under, bool oneLevelOnly) const;
|
||||
BListItem* EachItemUnder(BListItem* underItem, bool oneLevelOnly,
|
||||
BListItem* (*eachFunc)(BListItem* item, void* arg),
|
||||
void* arg);
|
||||
BListItem* ItemUnderAt(BListItem* underItem, bool oneLevelOnly,
|
||||
int32 index) const;
|
||||
|
||||
protected:
|
||||
protected:
|
||||
virtual bool DoMiscellaneous(MiscCode code, MiscData* data);
|
||||
virtual void MessageReceived(BMessage *message);
|
||||
|
||||
virtual bool DoMiscellaneous(MiscCode code, MiscData * data);
|
||||
virtual void MessageReceived(BMessage *);
|
||||
private:
|
||||
virtual void _ReservedOutlineListView1();
|
||||
virtual void _ReservedOutlineListView2();
|
||||
virtual void _ReservedOutlineListView3();
|
||||
virtual void _ReservedOutlineListView4();
|
||||
|
||||
/*----- Private or reserved -----------------------------------------*/
|
||||
private:
|
||||
virtual void _ReservedOutlineListView1();
|
||||
virtual void _ReservedOutlineListView2();
|
||||
virtual void _ReservedOutlineListView3();
|
||||
virtual void _ReservedOutlineListView4();
|
||||
|
||||
typedef BListView _inherited;
|
||||
typedef BListView _inherited;
|
||||
|
||||
int32 FullListIndex(int32 index) const;
|
||||
int32 ListViewIndex(int32 index) const;
|
||||
|
||||
#if !_PR3_COMPATIBLE_
|
||||
protected:
|
||||
#endif
|
||||
virtual void ExpandOrCollapse(BListItem *underItem, bool expand);
|
||||
|
||||
private:
|
||||
|
||||
virtual BRect LatchRect(BRect itemRect, int32 level) const;
|
||||
virtual void DrawLatch(BRect itemRect, int32 level, bool collapsed,
|
||||
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 *i, BRect cRect, bool complete = false);
|
||||
virtual void DrawItem(BListItem* item, BRect itemRect, bool complete = false);
|
||||
|
||||
BListItem *RemoveCommon(int32 fullListIndex);
|
||||
BListItem *RemoveOne(int32 fullListIndex);
|
||||
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);
|
||||
|
||||
static void TrackInLatchItem(void *);
|
||||
static void TrackOutLatchItem(void *);
|
||||
BListItem* RemoveCommon(int32 fullListIndex);
|
||||
BListItem* RemoveOne(int32 fullListIndex);
|
||||
|
||||
static void TrackInLatchItem(void *);
|
||||
static void TrackOutLatchItem(void *);
|
||||
|
||||
bool OutlineSwapItems(int32 a, int32 b);
|
||||
bool OutlineMoveItem(int32 from, int32 to);
|
||||
bool OutlineReplaceItem(int32 index, BListItem *item);
|
||||
bool OutlineReplaceItem(int32 index, BListItem* item);
|
||||
void CommonMoveItems(int32 from, int32 count, int32 to);
|
||||
BListItem *SuperitemForIndex(int32 fullListIndex, int32 level);
|
||||
BListItem* SuperitemForIndex(int32 fullListIndex, int32 level);
|
||||
int32 FindPreviousVisibleIndex(int32 fullListIndex);
|
||||
|
||||
BList fullList;
|
||||
private:
|
||||
BList fFullList;
|
||||
uint32 _reserved[2];
|
||||
};
|
||||
|
||||
/*----------------------------------------------------------------*/
|
||||
/*----------------------------------------------------------------*/
|
||||
|
||||
#endif /* _OUTLINE_LIST_VIEW_H */
|
||||
#endif // _OUTLINE_LIST_VIEW_H
|
||||
|
@ -1,58 +1,42 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// File: StringItem.h
|
||||
//
|
||||
// Description:
|
||||
//
|
||||
// Copyright 2001, Ulrich Wimboeck
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/*
|
||||
* Copyright 2006, Haiku, Inc. All Rights Reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _STRING_ITEM_H
|
||||
#define _STRING_ITEM_H
|
||||
|
||||
|
||||
#include <ListItem.h>
|
||||
|
||||
|
||||
#ifdef USE_OPENBEOS_NAMESPACE
|
||||
namespace OpenBeOS {
|
||||
#endif
|
||||
|
||||
|
||||
//----- BStringItem class ----------------------------------------
|
||||
|
||||
class BStringItem : public BListItem
|
||||
{
|
||||
public:
|
||||
BStringItem(const char *text, uint32 outlineLevel = 0, bool expanded = true);
|
||||
BStringItem(BMessage *data);
|
||||
class BStringItem : public BListItem {
|
||||
public:
|
||||
BStringItem(const char* text, uint32 outlineLevel = 0,
|
||||
bool expanded = true);
|
||||
BStringItem(BMessage* archive);
|
||||
virtual ~BStringItem();
|
||||
|
||||
static BArchivable *Instantiate(BMessage *data);
|
||||
virtual status_t Archive(BMessage *data, bool deep = true) const;
|
||||
static BArchivable* Instantiate(BMessage* archive);
|
||||
virtual status_t Archive(BMessage* archive, bool deep = true) const;
|
||||
|
||||
virtual void DrawItem(BView *owner, BRect frame, bool complete = false);
|
||||
virtual void SetText(const char *text);
|
||||
const char *Text() const;
|
||||
virtual void DrawItem(BView* owner, BRect frame, bool complete = false);
|
||||
virtual void SetText(const char* text);
|
||||
const char* Text() const;
|
||||
|
||||
virtual void Update(BView *owner, const BFont *font);
|
||||
virtual void Update(BView* owner, const BFont* font);
|
||||
|
||||
virtual status_t Perform(perform_code code, void *arg);
|
||||
virtual status_t Perform(perform_code code, void* arg);
|
||||
|
||||
private:
|
||||
private:
|
||||
virtual void _ReservedStringItem1();
|
||||
virtual void _ReservedStringItem2();
|
||||
|
||||
BStringItem(const BStringItem &);
|
||||
BStringItem& operator=(const BStringItem &);
|
||||
BStringItem(const BStringItem& item);
|
||||
BStringItem& operator=(const BStringItem& item);
|
||||
|
||||
char *fText;
|
||||
char* fText;
|
||||
float fBaselineOffset;
|
||||
uint32 _reserved[2];
|
||||
};
|
||||
|
||||
#ifdef USE_OPENBEOS_NAMESPACE
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _STRING_ITEM_H */
|
||||
#endif // _STRING_ITEM_H
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user