mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
fixed sorting problem in new model due to missing call to sortRole()
This commit is contained in:
parent
dce660357a
commit
f56e932fb7
@ -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 ;
|
||||
|
@ -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
|
||||
|
@ -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()));
|
||||
|
Loading…
Reference in New Issue
Block a user