mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-02-18 05:44:14 -05:00
fixed sorting of transfer by priority
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4617 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
b4d4f3171c
commit
21feaf46da
@ -141,6 +141,32 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class PriorityItem : public SortByNameItem
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
PriorityItem(QHeaderView *header) : SortByNameItem(header) {}
|
||||||
|
|
||||||
|
virtual bool operator<(const QStandardItem &other) const
|
||||||
|
{
|
||||||
|
const int role = model() ? model()->sortRole() : Qt::DisplayRole;
|
||||||
|
|
||||||
|
QString l = data(role).value<QString>();
|
||||||
|
QString r = other.data(role).value<QString>();
|
||||||
|
|
||||||
|
bool bl,br ;
|
||||||
|
int nl = l.toInt(&bl) ;
|
||||||
|
int nr = r.toInt(&br) ;
|
||||||
|
|
||||||
|
if(bl && br)
|
||||||
|
return nl < nr ;
|
||||||
|
|
||||||
|
if(bl ^ br)
|
||||||
|
return br ;
|
||||||
|
|
||||||
|
return SortByNameItem::operator<(other);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/** Constructor */
|
/** Constructor */
|
||||||
TransfersDialog::TransfersDialog(QWidget *parent)
|
TransfersDialog::TransfersDialog(QWidget *parent)
|
||||||
: RsAutoUpdatePage(1000,parent)
|
: RsAutoUpdatePage(1000,parent)
|
||||||
@ -580,6 +606,7 @@ int TransfersDialog::addItem(const QString&, const QString& name, const QString&
|
|||||||
|
|
||||||
// change progress column to own class for sorting
|
// change progress column to own class for sorting
|
||||||
DLListModel->setItem(row, PROGRESS, new ProgressItem (NULL));
|
DLListModel->setItem(row, PROGRESS, new ProgressItem (NULL));
|
||||||
|
DLListModel->setItem(row, PRIORITY, new PriorityItem (NULL));
|
||||||
}
|
}
|
||||||
|
|
||||||
DLListModel->setData(DLListModel->index(row, NAME), QVariant(name));
|
DLListModel->setData(DLListModel->index(row, NAME), QVariant(name));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user