ensure pinned posts always stay grouped together

This commit is contained in:
csoler 2018-09-01 18:40:28 +02:00
parent 5c2f714ada
commit e7d721b3de
No known key found for this signature in database
GPG Key ID: 7BCA522266C0804C

View File

@ -88,6 +88,7 @@
#define COLUMN_THREAD_CONTENT 6
#define COLUMN_THREAD_COUNT 7
#define COLUMN_THREAD_MSGID 8
#define COLUMN_THREAD_NB_COLUMNS 9
#define COLUMN_THREAD_DATA 0 // column for storing the userdata like parentid
@ -1272,7 +1273,7 @@ QTreeWidgetItem *GxsForumThreadWidget::convertMsgToThreadWidget(const RsGxsForum
QString itemText = DateTime::formatDateTime(qtime);
// This is an attempt to put pinned posts on the top. We should rather use a QSortFilterProxyModel here.
QString itemSort = is_pinned?QString::number(0):QString::number(msg.mMeta.mPublishTs);//Don't need to format it as for sort.
QString itemSort = QString::number(msg.mMeta.mPublishTs);//Don't need to format it as for sort.
if (useChildTS)
{
@ -1297,6 +1298,10 @@ QTreeWidgetItem *GxsForumThreadWidget::convertMsgToThreadWidget(const RsGxsForum
item->setText(COLUMN_THREAD_DATE, itemText);
item->setData(COLUMN_THREAD_DATE, ROLE_THREAD_SORT, itemSort);
if(is_pinned) // make sure all pinned poses are grouped together
for(int i=0;i<COLUMN_THREAD_NB_COLUMNS;++i)
item->setData(i,ROLE_THREAD_SORT, QString("_"));
// Set later with GxsIdRSTreeWidgetItem::setId
item->setData(COLUMN_THREAD_DATA, ROLE_THREAD_AUTHOR, QString::fromStdString(msg.mMeta.mAuthorId.toStdString()));