User list sorting fix
This commit is contained in:
parent
235d591778
commit
a5d73a9a60
2 changed files with 23 additions and 2 deletions
|
@ -3,7 +3,6 @@
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <QTreeWidget>
|
|
||||||
#include <QTextEdit>
|
#include <QTextEdit>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
|
@ -237,6 +236,20 @@ void ServerMessageLog::processServerMessageEvent(Event_ServerMessage *event)
|
||||||
textEdit->append(event->getMessage());
|
textEdit->append(event->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UserListTWI::UserListTWI()
|
||||||
|
: QTreeWidgetItem(Type)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool UserListTWI::operator<(const QTreeWidgetItem &other) const
|
||||||
|
{
|
||||||
|
// Equal user level => sort by name
|
||||||
|
if (data(0, Qt::UserRole) == other.data(0, Qt::UserRole))
|
||||||
|
return data(2, Qt::UserRole).toString().toLower() < other.data(2, Qt::UserRole).toString().toLower();
|
||||||
|
// Else sort by user level
|
||||||
|
return data(0, Qt::UserRole).toInt() > other.data(0, Qt::UserRole).toInt();
|
||||||
|
}
|
||||||
|
|
||||||
UserList::UserList(AbstractClient *_client, QWidget *parent)
|
UserList::UserList(AbstractClient *_client, QWidget *parent)
|
||||||
: QGroupBox(parent)
|
: QGroupBox(parent)
|
||||||
{
|
{
|
||||||
|
@ -279,10 +292,11 @@ void UserList::processUserInfo(ServerInfo_User *user)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!item) {
|
if (!item) {
|
||||||
item = new QTreeWidgetItem;
|
item = new UserListTWI;
|
||||||
userTree->addTopLevelItem(item);
|
userTree->addTopLevelItem(item);
|
||||||
retranslateUi();
|
retranslateUi();
|
||||||
}
|
}
|
||||||
|
item->setData(0, Qt::UserRole, user->getUserLevel());
|
||||||
item->setIcon(0, QIcon(UserLevelPixmapGenerator::generatePixmap(12, user->getUserLevel())));
|
item->setIcon(0, QIcon(UserLevelPixmapGenerator::generatePixmap(12, user->getUserLevel())));
|
||||||
item->setIcon(1, QIcon(CountryPixmapGenerator::generatePixmap(12, user->getCountry())));
|
item->setIcon(1, QIcon(CountryPixmapGenerator::generatePixmap(12, user->getCountry())));
|
||||||
item->setData(2, Qt::UserRole, user->getName());
|
item->setData(2, Qt::UserRole, user->getName());
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#define TAB_SERVER_H
|
#define TAB_SERVER_H
|
||||||
|
|
||||||
#include <QGroupBox>
|
#include <QGroupBox>
|
||||||
|
#include <QTreeWidget>
|
||||||
#include "tab.h"
|
#include "tab.h"
|
||||||
#include "protocol_datastructures.h"
|
#include "protocol_datastructures.h"
|
||||||
|
|
||||||
|
@ -76,6 +77,12 @@ public:
|
||||||
void retranslateUi();
|
void retranslateUi();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class UserListTWI : public QTreeWidgetItem {
|
||||||
|
public:
|
||||||
|
UserListTWI();
|
||||||
|
bool operator<(const QTreeWidgetItem &other) const;
|
||||||
|
};
|
||||||
|
|
||||||
class UserList : public QGroupBox {
|
class UserList : public QGroupBox {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
private:
|
private:
|
||||||
|
|
Loading…
Reference in a new issue