Dietrich Streifert schrieb:
Well I try hard with the "qooxdoo" style. Where did I fail? I thought I
used spaces and not tabs. Where did you miss the semicolon?
Please enlight me master ;-)
for (something) {
};
The last semicolon is needed to compress the script through our script
(if your remove line breaks).
Insert a space after each semicolon in a for loop, no spaces in parenthesis
It should be:
for (var i=0; i<l; i++)
and not:
for ( var i=0;i<l;i++ )
We really need a style guide sometimes.
Sebastian
Sebastian Werner schrieb:
Dietrich Streifert schrieb:
OK. Here is the slightly optimezed diff against current CVS renderer
and the adapted example:
Even if this is not optimal I think the working interface should be
added and the optimiziations should be added to the TODO List. I
don't think that sorting a small to medium size QxList ( up to 100
items) does make a big difference if it is uses an optimized sorting.
Ok thanks.
Please try to make your code more qooxdoo style - also for patches.
Semicolons must be exist after closing brackets sometimes, too. And
please try to make indents and spacing like the rest of the file and
don't try to adopt your own style there. This would be really helpful
for any future patches. Thanks.
I have finally committed it to CVS.
Sebastian
Best Regards...
Sebastian Werner schrieb:
Dietrich Streifert schrieb:
Here It is and SOLVED:
Please have a look at the List_4.html example attached to the mail.
The trick is to NOT sort the children array. A new array is built
upon the sort criteria (eg. the label or the value of the item)
which holds a reference to the child item.
Just my 2 cents:
It was a really bad idea to sort the array which is accessed through
a getter. As javascript always references to this array, also if you
modify it, you will override many qooxdoo internals (and probably
broke them) this way.
Then this new array is sorted and after that the items are re-added
in the new order by callint the addAtEnd method of the QxList.
addAtEnd is IMHO a bit complex. Normally you does not need to re-add
them (ok, qooxdoo does not really will re-add them, as it compares
the old and new parent before), but there is currently unfortunately
no other way to solve this. I hope the overhead is not to big.
addAtEnd is a bit to complex because it always need the current
length. Normally you will use a loop to refill the children to the
parent. Possible you can alternativly does something like this:
for (var i=0, a=sortedChildren, l=a.length; i<l; i++) {
myParent.addAt(a[i], i);
};
This should be a small time faster. If we need something like this
sorting more often we should thought about a more optimized way to
refresh such widgets.
Sebastian
I created three new methods for QxList:
1) internal _sortItemsCompare method for sorting comparison
2) sortItemsByString() which sorts asc/desc by the getLabel() value
3) sortItemsByValue() which sorts asc/desc by the getValue() value
Should I put the new methods into QxList and create a patch for
QxList?
------------------------------------------------------------------------
QxList Item Sorting demo
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through
log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
Qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
------------------------------------------------------------------------
QxList Item Sorting demo
------------------------------------------------------------------------
--- source/script/widgets/QxList.js.orig 2005-11-28
11:31:22.197065000 +0100
+++ source/script/widgets/QxList.js 2005-11-28 11:44:39.388143000
+0100
@@ -303,3 +303,51 @@
proto.findValueExact = function(vText, vStartIndex) {
return this._findItem(vText, vStartIndex || 0, "ValueExact");
};
+
+/*
+
-------------------------------------------------------------------------------
+ SORT SUPPORT
+
-------------------------------------------------------------------------------
+*/
+
+proto._sortItemsCompare = function(a,b) {
+ var ret = a.key < b.key ? -1 : ( a.key == b.key ? 0 : 1 );
+ return ret;
+};
+
+proto.sortItemsByString = function(reverse) {
+ var sortitems = [];
+ var items = this.getChildren();
+
+ for(var i=0;i<items.length;i++) {
+ sortitems[i] = { key:items[i].getLabel(), item:items[i] };
+ } +
+ sortitems.sort(this._sortItemsCompare);
+ if ( reverse ) {
+ sortitems.reverse();
+ }
+
+ for(var i=0;i<sortitems.length;i++) {
+ this.addAt(sortitems[i].item,i);
+ }
+};
+
+proto.sortItemsByValue = function(reverse) {
+ var sortitems = [];
+ var items = this.getChildren();
+
+ for(var i=0;i<items.length;i++) {
+ sortitems[i] = { key:items[i].getValue(), item:items[i] };
+ } +
+ sortitems.sort(this._sortItemsCompare);
+ if ( reverse ) {
+ sortitems.reverse();
+ }
+
+ for(var i=0;i<sortitems.length;i++) {
+ this.addAt(sortitems[i].item,i);
+ }
+};
+
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log
files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
Qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
Qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel