implements: Change the behaviour of the "Display idle players" sorting
menu #112
This commit is contained in:
@@ -32,7 +32,7 @@ using namespace std;
|
||||
|
||||
|
||||
gameLobbyDialogImpl::gameLobbyDialogImpl(startWindowImpl *parent, ConfigFile *c)
|
||||
: QDialog(parent), myW(NULL), myStartWindow(parent), myConfig(c), currentGameName(""), myPlayerId(0), isGameAdministrator(false), inGame(false), guestMode(false), blinkingButtonAnimationState(true), myChat(NULL), keyUpCounter(0), infoMsgToShowId(0), currentInvitationGameId(0), inviteDialogIsCurrentlyShown(false), autoStartTimerCounter(0)
|
||||
: QDialog(parent), myW(NULL), myStartWindow(parent), myConfig(c), currentGameName(""), myPlayerId(0), isGameAdministrator(false), inGame(false), guestMode(false), blinkingButtonAnimationState(true), myChat(NULL), keyUpCounter(0), infoMsgToShowId(0), currentInvitationGameId(0), inviteDialogIsCurrentlyShown(false), autoStartTimerCounter(0), lastNickListFilterState(0)
|
||||
{
|
||||
|
||||
#ifdef __APPLE__
|
||||
@@ -1495,12 +1495,22 @@ void gameLobbyDialogImpl::changeGameListFilter(int index)
|
||||
|
||||
void gameLobbyDialogImpl::changeNickListFilter(int state)
|
||||
{
|
||||
if(lastNickListFilterState == 0) {
|
||||
myNickListSortFilterProxyModel->setLastFilterStateCountry(false);
|
||||
myNickListSortFilterProxyModel->setLastFilterStateAlpha(true);
|
||||
}
|
||||
else if(lastNickListFilterState == 1) {
|
||||
myNickListSortFilterProxyModel->setLastFilterStateCountry(true);
|
||||
myNickListSortFilterProxyModel->setLastFilterStateAlpha(false);
|
||||
}
|
||||
|
||||
myNickListSortFilterProxyModel->setFilterState(state);
|
||||
myNickListModel->sort(0, Qt::DescendingOrder);
|
||||
|
||||
myNickListSortFilterProxyModel->setFilterRegExp(QString());
|
||||
myNickListSortFilterProxyModel->setFilterKeyColumn(0);
|
||||
|
||||
lastNickListFilterState = state;
|
||||
writeDialogSettings(2);
|
||||
}
|
||||
|
||||
|
||||
@@ -198,6 +198,7 @@ private:
|
||||
|
||||
QLabel *autoStartTimerOverlay;
|
||||
int autoStartTimerCounter;
|
||||
int lastNickListFilterState;
|
||||
|
||||
protected:
|
||||
bool eventFilter(QObject *obj, QEvent *event);
|
||||
|
||||
@@ -63,7 +63,14 @@ bool MyNickListSortFilterProxyModel::lessThan(const QModelIndex &left, const QMo
|
||||
}
|
||||
break;
|
||||
case 2: {
|
||||
return QSortFilterProxyModel::lessThan(left, right);
|
||||
if(lastFilterStateCountry) {
|
||||
QString leftCountryAndName(sourceModel()->data(left, 33).toString().toUpper()+sourceModel()->data(left, Qt::DisplayRole).toString().toLower());
|
||||
QString rightCountryAndName(sourceModel()->data(right, 33).toString().toUpper()+sourceModel()->data(right, Qt::DisplayRole).toString().toLower());
|
||||
return leftCountryAndName < rightCountryAndName;
|
||||
}
|
||||
else if(lastFilterStateAlpha) {
|
||||
return QSortFilterProxyModel::lessThan(left, right);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -28,6 +28,8 @@ public:
|
||||
MyNickListSortFilterProxyModel(QObject *parent = 0);
|
||||
|
||||
void setFilterState(int state);
|
||||
void setLastFilterStateCountry( bool country ) { lastFilterStateCountry = country;}
|
||||
void setLastFilterStateAlpha( bool alpha ) { lastFilterStateAlpha = alpha;}
|
||||
|
||||
protected:
|
||||
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const;
|
||||
@@ -36,7 +38,8 @@ protected:
|
||||
private:
|
||||
|
||||
int filterState;
|
||||
|
||||
bool lastFilterStateCountry;
|
||||
bool lastFilterStateAlpha;
|
||||
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user