Ok I reimplemented that in this way. However, will this sort "names" as well in alphabetical even if I override the original < operator? Or should I code that in too?
#include "XTreeItem.h"
int iScore, iMyScore;
iScore = 0;
iMyScore = 0;
if(other.flags() == 0){
if(other.
text(0) == QString("FIRST"))iScore
= 100;
if(other.
text(0) == QString("SECOND"))iScore
= 90;
if(other.
text(0) == QString("THIRD"))iScore
= 80;
if(other.
text(0) == QString("FOURTH"))iScore
= 70;
if(other.
text(0) == QString("FIFTH"))iScore
= 60;
if(other.
text(0) == QString("SIXTH"))iScore
= 50;
}
if(flags() == 0){
if(text
(0) == QString("FIRST"))iMyScore
= 100;
if(text
(0) == QString("SECOND"))iMyScore
= 90;
if(text
(0) == QString("THIRD"))iMyScore
= 80;
if(text
(0) == QString("FOURTH"))iMyScore
= 70;
if(text
(0) == QString("FIFTH"))iMyScore
= 60;
if(text
(0) == QString("SIXTH"))iMyScore
= 50;
}
if(iMyScore < iScore){ return true; } else { return false; }
}
#include "XTreeItem.moc"
#include "XTreeItem.h"
bool QTreeWidgetItem::operator< ( const QTreeWidgetItem & other ) const {
int iScore, iMyScore;
iScore = 0;
iMyScore = 0;
if(other.flags() == 0){
if(other.text(0) == QString("FIRST"))iScore = 100;
if(other.text(0) == QString("SECOND"))iScore = 90;
if(other.text(0) == QString("THIRD"))iScore = 80;
if(other.text(0) == QString("FOURTH"))iScore = 70;
if(other.text(0) == QString("FIFTH"))iScore = 60;
if(other.text(0) == QString("SIXTH"))iScore = 50;
}
if(flags() == 0){
if(text(0) == QString("FIRST"))iMyScore = 100;
if(text(0) == QString("SECOND"))iMyScore = 90;
if(text(0) == QString("THIRD"))iMyScore = 80;
if(text(0) == QString("FOURTH"))iMyScore = 70;
if(text(0) == QString("FIFTH"))iMyScore = 60;
if(text(0) == QString("SIXTH"))iMyScore = 50;
}
if(iMyScore < iScore){ return true; } else { return false; }
}
#include "XTreeItem.moc"
To copy to clipboard, switch view to plain text mode
I know I shoulda used switches and/or functions better (more OO) but still is this basically what I should do to add weights?
Bookmarks