sorting bugfix for #140

This commit is contained in:
doitux
2012-12-19 15:06:13 +01:00
parent 9f164bf004
commit 51ad6c5580
3 changed files with 43 additions and 20 deletions
@@ -155,9 +155,9 @@ gameLobbyDialogImpl::gameLobbyDialogImpl(startWindowImpl *parent, ConfigFile *c)
treeView_GameList->setColumnWidth(0,190); treeView_GameList->setColumnWidth(0,190);
treeView_GameList->setColumnWidth(1,55); treeView_GameList->setColumnWidth(1,55);
treeView_GameList->setColumnWidth(2,65); treeView_GameList->setColumnWidth(2,65);
treeView_GameList->setColumnWidth(3,30); treeView_GameList->setColumnWidth(3,25);
treeView_GameList->setColumnWidth(4,30); treeView_GameList->setColumnWidth(4,25);
treeView_GameList->setColumnWidth(5,20); treeView_GameList->setColumnWidth(5,30);
treeView_GameList->setStyleSheet("QTreeView {background-color: white; background-image: url(\""+myAppDataPath +"gfx/gui/misc/background_gamelist.png\"); background-attachment: fixed; background-position: top center ; background-repeat: no-repeat;}"); treeView_GameList->setStyleSheet("QTreeView {background-color: white; background-image: url(\""+myAppDataPath +"gfx/gui/misc/background_gamelist.png\"); background-attachment: fixed; background-position: top center ; background-repeat: no-repeat;}");
#endif #endif
@@ -448,10 +448,12 @@ void gameLobbyDialogImpl::refresh(int actionID)
treeView_GameList->setColumnWidth(4,30); treeView_GameList->setColumnWidth(4,30);
#else #else
treeView_GameList->setColumnWidth(0,190); treeView_GameList->setColumnWidth(0,190);
treeView_GameList->setColumnWidth(1,65); treeView_GameList->setColumnWidth(1,55);
treeView_GameList->setColumnWidth(2,65); treeView_GameList->setColumnWidth(2,65);
treeView_GameList->setColumnWidth(3,40); treeView_GameList->setColumnWidth(3,25);
treeView_GameList->setColumnWidth(4,40); treeView_GameList->setColumnWidth(4,25);
treeView_GameList->setColumnWidth(5,30);
#endif #endif
QStringList headerList2; QStringList headerList2;
@@ -639,9 +641,13 @@ void gameLobbyDialogImpl::updateGameItem(QList <QStandardItem*> itemList, unsign
} }
itemList.at(5)->setData(QString::number(info.data.playerActionTimeoutSec)+"s/"+QString::number(info.data.delayBetweenHandsSec)+"s", Qt::DisplayRole); itemList.at(5)->setData(QString::number(info.data.playerActionTimeoutSec)+"s/"+QString::number(info.data.delayBetweenHandsSec)+"s", Qt::DisplayRole);
itemList.at(5)->setData(QString::number(info.data.playerActionTimeoutSec), 16); QString actionTimeOutString = QString::number(info.data.playerActionTimeoutSec);
if(info.data.playerActionTimeoutSec < 10) {
actionTimeOutString = "0"+actionTimeOutString;
}
itemList.at(5)->setData(actionTimeOutString, 16);
// treeView_GameList->sortByColumn(myConfig->readConfigInt("DlgGameLobbyGameListSortingSection"), (Qt::SortOrder)myConfig->readConfigInt("DlgGameLobbyGameListSortingOrder") ); treeView_GameList->sortByColumn(myConfig->readConfigInt("DlgGameLobbyGameListSortingSection"), (Qt::SortOrder)myConfig->readConfigInt("DlgGameLobbyGameListSortingOrder") );
refreshGameStats(); refreshGameStats();
} }
@@ -859,9 +865,9 @@ void gameLobbyDialogImpl::clearDialog()
treeView_GameList->setColumnWidth(0,190); treeView_GameList->setColumnWidth(0,190);
treeView_GameList->setColumnWidth(1,55); treeView_GameList->setColumnWidth(1,55);
treeView_GameList->setColumnWidth(2,65); treeView_GameList->setColumnWidth(2,65);
treeView_GameList->setColumnWidth(3,30); treeView_GameList->setColumnWidth(3,25);
treeView_GameList->setColumnWidth(4,30); treeView_GameList->setColumnWidth(4,25);
treeView_GameList->setColumnWidth(5,20); treeView_GameList->setColumnWidth(5,30);
#endif #endif
pushButton_CreateGame->clearFocus(); pushButton_CreateGame->clearFocus();
@@ -41,3 +41,19 @@ bool MyGameListSortFilterProxyModel::filterAcceptsRow(int sourceRow, const QMode
&& sourceModel()->data(index5, 16).toString().contains(column5RegExp)) || sourceModel()->data(index0, 16) == "MeInThisGame"); && sourceModel()->data(index5, 16).toString().contains(column5RegExp)) || sourceModel()->data(index0, 16) == "MeInThisGame");
} }
bool MyGameListSortFilterProxyModel::lessThan(const QModelIndex &left, const QModelIndex &right) const
{
switch(sortColumn()) {
case 5: {
return sourceModel()->data(left, 16).toString() < sourceModel()->data(right, 16).toString();
}
break;
default: {
return QSortFilterProxyModel::lessThan(left, right);
}
break;
}
return false;
}
@@ -44,6 +44,7 @@ public:
protected: protected:
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const; bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const;
bool lessThan(const QModelIndex &left, const QModelIndex &right) const;
private: private:
QRegExp column1RegExp; QRegExp column1RegExp;