fixed sorting problem in new model due to missing call to sortRole()

This commit is contained in:
csoler 2018-11-30 17:24:43 +01:00
parent dce660357a
commit f56e932fb7
No known key found for this signature in database
GPG Key ID: 7BCA522266C0804C
3 changed files with 19 additions and 3 deletions

View File

@ -63,6 +63,7 @@ class GxsIdDetails : public QObject
Q_OBJECT
public:
static const int ICON_TYPE_NONE = 0x0000 ;
static const int ICON_TYPE_AVATAR = 0x0001 ;
static const int ICON_TYPE_PGP = 0x0002 ;
static const int ICON_TYPE_RECOGN = 0x0004 ;

View File

@ -310,6 +310,7 @@ QVariant RsGxsForumModel::data(const QModelIndex &index, int role) const
case ThreadPinnedRole: return pinnedRole (fmpe,index.column()) ;
case MissingRole: return missingRole (fmpe,index.column()) ;
case StatusRole: return statusRole (fmpe,index.column()) ;
case SortRole: return sortRole (fmpe,index.column()) ;
default:
return QVariant();
}
@ -424,10 +425,22 @@ QVariant RsGxsForumModel::authorRole(const ForumModelPostEntry& fmpe,int column)
QVariant RsGxsForumModel::sortRole(const ForumModelPostEntry& fmpe,int column) const
{
if(column == COLUMN_THREAD_DATA)
return QVariant(QString::number(fmpe.mPublishTs)); // we should probably have leading zeroes here
switch(column)
{
case COLUMN_THREAD_DATE: return QVariant(QString::number(fmpe.mPublishTs)); // we should probably have leading zeroes here
case COLUMN_THREAD_READ: return QVariant((bool)IS_MSG_UNREAD(fmpe.mMsgStatus));
case COLUMN_THREAD_DISTRIBUTION: return decorationRole(fmpe,column);
case COLUMN_THREAD_AUTHOR:
{
QString str,comment ;
QList<QIcon> icons;
GxsIdDetails::MakeIdDesc(fmpe.mAuthorId, false, str, icons, comment,GxsIdDetails::ICON_TYPE_NONE);
return QVariant();
return QVariant(str);
}
default:
return displayRole(fmpe,column);
}
}
QVariant RsGxsForumModel::displayRole(const ForumModelPostEntry& fmpe,int col) const

View File

@ -372,6 +372,7 @@ GxsForumThreadWidget::GxsForumThreadWidget(const RsGxsGroupId &forumId, QWidget
mThreadModel = new RsGxsForumModel(this);
mThreadProxyModel = new ForumPostSortFilterProxyModel(ui->threadTreeWidget->header(),this);
mThreadProxyModel->setSourceModel(mThreadModel);
mThreadProxyModel->setSortRole(RsGxsForumModel::SortRole);
ui->threadTreeWidget->setModel(mThreadProxyModel);
ui->threadTreeWidget->setSortingEnabled(true);
@ -381,6 +382,7 @@ GxsForumThreadWidget::GxsForumThreadWidget(const RsGxsGroupId &forumId, QWidget
ui->threadTreeWidget->setItemDelegateForColumn(RsGxsForumModel::COLUMN_THREAD_AUTHOR,new AuthorItemDelegate()) ;
ui->threadTreeWidget->setItemDelegateForColumn(RsGxsForumModel::COLUMN_THREAD_READ,new ReadStatusItemDelegate()) ;
ui->threadTreeWidget->header()->setSortIndicatorShown(true);
connect(ui->threadTreeWidget->header(),SIGNAL(sortIndicatorChanged(int,Qt::SortOrder)),this,SLOT(sortColumn(int,Qt::SortOrder)));
connect(ui->versions_CB, SIGNAL(currentIndexChanged(int)), this, SLOT(changedVersion()));