Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Widgets - General questions or Mixed problems » ColumnList question (sort column)
ColumnList question (sort column) [message #2898] Sat, 29 April 2006 11:32 Go to next message
forlano is currently offline  forlano
Messages: 1185
Registered: March 2006
Location: Italy
Senior Contributor
Hello,

I have put my data in a columnlist widget and I would like to see them sorted alphabetically (it does not matter if during the insertion or at the end). The syntax to do it is:

Sort(const ValueOrder& order)

but I was unable fo find an example that shows how to set this argument.

Thank you,
Luigi
Re: ColumnList question (sort column) [message #2909 is a reply to message #2898] Sat, 29 April 2006 19:52 Go to previous messageGo to next message
fudadmin is currently offline  fudadmin
Messages: 1321
Registered: November 2005
Location: Kaunas, Lithuania
Ultimate Contributor
Administrator
I don't know how much useful for your case but you can try to study ide/Custom.cpp:
class CustomOrder : public ArrayCtrl::Order {
public:
	virtual bool operator()(const Vector<Value>& row1, const Vector<Value>& row2) const {
		for(int i = 0; i < 3; i++)
			if(String(row1[i]) != String(row2[i]))
				return String(row1[i]) < String(row2[i]);
		return false;
	}
};

and related stuff...
Re: ColumnList question (sort column) [message #2912 is a reply to message #2909] Sat, 29 April 2006 21:41 Go to previous messageGo to next message
forlano is currently offline  forlano
Messages: 1185
Registered: March 2006
Location: Italy
Senior Contributor
fudadmin wrote on Sat, 29 April 2006 19:52

I don't know how much useful for your case but you can try to study ide/Custom.cpp:
class CustomOrder : public ArrayCtrl::Order {
public:
	virtual bool operator()(const Vector<Value>& row1, const Vector<Value>& row2) const {
		for(int i = 0; i < 3; i++)
			if(String(row1[i]) != String(row2[i]))
				return String(row1[i]) < String(row2[i]);
		return false;
	}
};

and related stuff...


Shocked Oh my God ...
I guess I'll continue to live with an unsorted columnlist Smile
Re: ColumnList question (sort column) [message #2913 is a reply to message #2898] Sat, 29 April 2006 22:58 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
forlano wrote on Sat, 29 April 2006 05:32

Hello,

I have put my data in a columnlist widget and I would like to see them sorted alphabetically (it does not matter if during the insertion or at the end). The syntax to do it is:

Sort(const ValueOrder& order)

but I was unable fo find an example that shows how to set this argument.

Thank you,
Luigi



[/code]
struct ValueOrder {
virtual bool operator()(const Value& a, const Value& b) const = 0;
};

struct StdValueOrder : ValueOrder {
int language;

virtual bool operator()(const Value& a, const Value& b) const;

StdValueOrder(int l = -1);
virtual ~StdValueOrder();
};

struct FnValueOrder : ValueOrder {
int (*fn)(const Value& a, const Value& b);

virtual bool operator()(const Value& a, const Value& b) const;

FnValueOrder(int (*fn)(const Value& a, const Value& b));
virtual ~FnValueOrder();
};
[/code]

Use "StdValueOrder()" in place of ValueOrder if you expect the "normal" ordering and content of columnlist consists of "Std" values (number, String, Date, Time).

list.Sort(StdValueOrder());


If you need something special, you can either create comparison function and use FnValueOrder, or you can derive ValueOrder and provide new operator().

Mirek
Re: ColumnList question (sort column) [message #2916 is a reply to message #2913] Sat, 29 April 2006 23:20 Go to previous message
forlano is currently offline  forlano
Messages: 1185
Registered: March 2006
Location: Italy
Senior Contributor
luzr wrote on Sat, 29 April 2006 22:58


list.Sort(StdValueOrder());



This was enough to let it to work. The other lines were too complicated to understand for the moment... I've not yet learned the chapter about the operator in the Eckel's book Smile.
Thanks,
Luigi

[Updated on: Sat, 29 April 2006 23:20]

Report message to a moderator

Previous Topic: How to set window shape by means of a bitmap?
Next Topic: Borderless always-on-top non-modal window
Goto Forum:
  


Current Time: Thu May 02 01:04:12 CEST 2024

Total time taken to generate the page: 0.95812 seconds