sorting bugfix for #140
This commit is contained in:
@@ -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();
|
||||||
|
|||||||
@@ -20,24 +20,40 @@
|
|||||||
#include <QtCore>
|
#include <QtCore>
|
||||||
|
|
||||||
MyGameListSortFilterProxyModel::MyGameListSortFilterProxyModel(QObject *parent)
|
MyGameListSortFilterProxyModel::MyGameListSortFilterProxyModel(QObject *parent)
|
||||||
: QSortFilterProxyModel(parent)
|
: QSortFilterProxyModel(parent)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MyGameListSortFilterProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
|
bool MyGameListSortFilterProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
|
||||||
{
|
{
|
||||||
|
|
||||||
QModelIndex index0 = sourceModel()->index(sourceRow, 0, sourceParent);
|
QModelIndex index0 = sourceModel()->index(sourceRow, 0, sourceParent);
|
||||||
QModelIndex index1 = sourceModel()->index(sourceRow, 1, sourceParent);
|
QModelIndex index1 = sourceModel()->index(sourceRow, 1, sourceParent);
|
||||||
QModelIndex index2 = sourceModel()->index(sourceRow, 2, sourceParent);
|
QModelIndex index2 = sourceModel()->index(sourceRow, 2, sourceParent);
|
||||||
QModelIndex index3 = sourceModel()->index(sourceRow, 3, sourceParent);
|
QModelIndex index3 = sourceModel()->index(sourceRow, 3, sourceParent);
|
||||||
QModelIndex index4 = sourceModel()->index(sourceRow, 4, sourceParent);
|
QModelIndex index4 = sourceModel()->index(sourceRow, 4, sourceParent);
|
||||||
QModelIndex index5 = sourceModel()->index(sourceRow, 5, sourceParent);
|
QModelIndex index5 = sourceModel()->index(sourceRow, 5, sourceParent);
|
||||||
|
|
||||||
return ((sourceModel()->data(index1, 16).toString().contains(column1RegExp)
|
return ((sourceModel()->data(index1, 16).toString().contains(column1RegExp)
|
||||||
&& sourceModel()->data(index2, 16).toString().contains(column2RegExp)
|
&& sourceModel()->data(index2, 16).toString().contains(column2RegExp)
|
||||||
&& sourceModel()->data(index3, 16).toString().contains(column3RegExp)
|
&& sourceModel()->data(index3, 16).toString().contains(column3RegExp)
|
||||||
&& sourceModel()->data(index4, 16).toString().contains(column4RegExp)
|
&& sourceModel()->data(index4, 16).toString().contains(column4RegExp)
|
||||||
&& 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;
|
||||||
|
|||||||
Reference in New Issue
Block a user