Seeing as no one on beshare or irc feel like talking to me. (did I do something?)
I guess I’ll try my luck here. How do I use the SortItemsUnder method of BOutlineListView?
This is what I have:
method is decleared as:
int MimeListView::sortitemscompare(BListItem *itemA, BListItem *itemB)
then I call it with:
SortItemsUnder(item, true, sortitemscompare);
item is a BListItem*, true is a bool and soritemscompare is my method.
When I compile I get:
Error : /boot/home/develop/Prefs (personal)/filetypes/MimeListView.cpp: In method void MimeListView::ScanExpanded(class BListItem *)': no matching function for call to
MimeListView::SortItemsUnder (BListItem *&, bool, {unknown type})'
MimeListView.cpp line 259 SortItemsUnder(item, true, sortitemscompare);
Warning : candidates are: BOutlineListView::SortItemsUnder(BListItem , bool, int ()(const BListItem *, const BListItem ))
OutlineListView.h line 97 const BListItem));
Help please
inseculous wrote:
method is decleared as:
int MimeListView::sortitemscompare(BListItem *itemA, BListItem *itemB)
As it’s written here:
inseculous wrote:
Warning : candidates are: BOutlineListView::SortItemsUnder(BListItem *, bool, int (*)(const BListItem *, const BListItem *))
The above function need to be declared as “int MimeListView::sortitemscompare(const BListItem *, const BListItem *)”.
With “const” BListItems.
Moreover, since it’s a class function, it needs to be declared static.
thank you very much. Is there a good tutorial online somewhere that might help me understand what is happening here?
ok, i’m sure this is going to make me look rather idiotic but I have to ask. How do you do the BList sortitems callback? It’s declared with const void * and I tried the same as above to no avail.
What I’m trying to do is find a fast way to sort items under a branch of a BOutlineListView and the SortItemsUnder makes the scrollbar jump around abit and takes forever. So I’m trying to add the items to a blist, sort it and then put them in the tree. I’m hoping that this will speed things up abit.
inseculous wrote:ok, i'm sure this is going to make me look rather idiotic but I have to ask. How do you do the BList sortitems callback? It's declared with const void * and I tried the same as above to no avail.
Here’s what the bebook says:
“The arguments passed to the comparison function are declared to be void*; however, they should be regarded as pointers to the items in the listââ¬âin other words, as pointers to pointers.”
Could be that you’r treating them as pointers to objects ?
I made the same mistake the first time I tried.