Author: tgoettlicher Date: Fri May 4 15:34:35 2012 New Revision: 68088 URL: http://svn.opensuse.org/viewcvs/yast?rev=68088&view=rev Log: finetuned-sort function Modified: trunk/qt/src/QY2ListView.cc Modified: trunk/qt/src/QY2ListView.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/qt/src/QY2ListView.cc?rev=68088&r1=68087&r2=68088&view=diff ============================================================================== --- trunk/qt/src/QY2ListView.cc (original) +++ trunk/qt/src/QY2ListView.cc Fri May 4 15:34:35 2012 @@ -439,10 +439,23 @@ // numeric sorting if columns are numbers int column = treeWidget()->sortColumn(); - QRegExp re("\\d*"); - if ( re.exactMatch(text(column)) && re.exactMatch(otherListViewItem.text(column)) ) - return text(column).toInt() < otherListViewItem.text(column).toInt(); + QString text1=text(column).trimmed(); + QString text2=otherListViewItem.text(column).trimmed(); + text1=text1.left(text1.indexOf(QChar(' '))); + text2=text2.left(text2.indexOf(QChar(' '))); + + bool ok1, ok2; // conversion to int successful + bool retval = text1.toInt(&ok1) < text2.toInt(&ok2); + + if (ok1 && ok2 ) + return retval; // int < int + else if (ok1 && !ok2) + return true; // int < string + else if (!ok1 && ok2) + return false; // string > int + + // and finally non-numeric sorting is done by the base class return QTreeWidgetItem::operator<(otherListViewItem); } -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org