lobby: add filter for idle players in the nicklist

This commit is contained in:
doitux
2010-08-30 08:31:42 +00:00
parent e0afbfdd15
commit 54761f80a2
2 changed files with 36 additions and 1 deletions
@@ -626,6 +626,16 @@ void gameLobbyDialogImpl::gameAddPlayer(unsigned gameId, unsigned playerId)
}
it++;
}
//mark player as active
int it1 = 0;
while (myNickListModel->item(it1)) {
if (myNickListModel->item(it1, 0)->data(Qt::UserRole) == playerId) {
myNickListModel->item(it1, 0)->setData("active", 34);
break;
}
++it1;
}
}
void gameLobbyDialogImpl::gameRemovePlayer(unsigned gameId, unsigned playerId)
@@ -653,6 +663,16 @@ void gameLobbyDialogImpl::gameRemovePlayer(unsigned gameId, unsigned playerId)
}
++it;
}
//mark player as idle again
int it1 = 0;
while (myNickListModel->item(it1)) {
if (myNickListModel->item(it1, 0)->data(Qt::UserRole) == playerId) {
myNickListModel->item(it1, 0)->setData("idle", 34);
break;
}
++it1;
}
}
void gameLobbyDialogImpl::updateStats(ServerStats /*stats*/)
@@ -878,6 +898,11 @@ void gameLobbyDialogImpl::updatePlayer(unsigned playerId, QString newPlayerName)
else {
myNickListModel->item(it1, 0)->setIcon(QIcon(QString(":/cflags/cflags/%1.png").arg(countryString)));
}
unsigned gameIdOfPlayer = mySession->getGameIdOfPlayer(playerId);
if(gameIdOfPlayer) { myNickListModel->item(it1, 0)->setData("active", 34); }
else { myNickListModel->item(it1, 0)->setData("idle", 34); }
break;
}
@@ -902,6 +927,7 @@ void gameLobbyDialogImpl::removePlayer(unsigned playerId, QString) {
}
checkPlayerQuantity();
}
void gameLobbyDialogImpl::playerLeftLobby(unsigned playerId)
@@ -934,6 +960,11 @@ void gameLobbyDialogImpl::playerJoinedLobby(unsigned playerId, QString /*playerN
item->setIcon(QIcon(QString(":/cflags/cflags/%1.png").arg(countryString)));
}
unsigned gameIdOfPlayer = mySession->getGameIdOfPlayer(playerId);
if(gameIdOfPlayer) { item->setData("active", 34); }
else { item->setData("idle", 34); }
myNickListModel->appendRow(item);
refreshPlayerStats();
@@ -1361,6 +1392,9 @@ void gameLobbyDialogImpl::changeNickListFilter(int state)
myNickListSortFilterProxyModel->setFilterState(state);
myNickListModel->sort(0, Qt::DescendingOrder);
myNickListSortFilterProxyModel->setFilterRegExp(QString());
myNickListSortFilterProxyModel->setFilterKeyColumn(0);
// switch(state) {
// case 0: {
//
@@ -21,7 +21,8 @@ bool MyNickListSortFilterProxyModel::filterAcceptsRow(int sourceRow, const QMode
}
break;
case 2: {
return QSortFilterProxyModel::filterAcceptsRow(sourceRow, sourceParent);
QModelIndex index0 = sourceModel()->index(sourceRow, 0, sourceParent);
return sourceModel()->data(index0, 34).toString().contains("idle") && QSortFilterProxyModel::filterAcceptsRow(sourceRow, sourceParent);
}
break;