Re: List Orders
Neil Stevens <[email protected]>
| Newsgroups | gmane.comp.kde.look |
|---|---|
| Message-ID | <[email protected]> |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Sunday May 05, 2002 06:13, Dirk Groeneveld wrote:
> Hi!
>
> PHP can do that, IIRC. Maybe that code could be reused...
KListViews can do it, too. Just do something like this:
QString MyListViewItem::key(int column, bool ascending)
{
t = text(col);
// pad numbers for some user-friendly sorting
QRegExp re("[^\\d](\\d+)");
int location = t.length();
do
{
location = t.findRev(re, location - t.length() - 1);
if(location != -1)
{
QString numberPart = *re.capturedTexts().at(1);
t.replace(location + 1, numberPart.length(), numberPart.rightJustify(500,
'0'));
}
} while(location != -1);
// if it starts with a number pad the number with zeros
QRegExp re2("^(\\d*)(.*)");
if(-1 != re2.search(t))
{
QString numberPart = *re2.capturedTexts().at(1);
t = *re2.capturedTexts().at(2);
if(!numberPart.isEmpty()) t.prepend(numberPart.rightJustify(500, '0'));
}
return t;
}
- --
Neil Stevens - [email protected]
"I always cheer up immensely if an attack is particularly wounding
because I think, well, if they attack one personally, it means they
have not a single political argument left." - Margaret Thatcher
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org
iD8DBQE82Afdf7mnligQOmERAno0AJ47UiuIilAnpVKVAhYX6KfPQtXBiACgmoWT
X30yeBDpbkau9oRG6AbnHKU=
=ZEe7
-----END PGP SIGNATURE-----