From 59b375477182e2dcc8d3db4ac01e7798b707f060 Mon Sep 17 00:00:00 2001
From: csoler
Afterwards you can unsubscribe from the context menu of the forum list at left.
")); ui->threadTreeWidget->enableColumnCustomize(true); + ui->threadTreeWidget->sortItems(COLUMN_THREAD_DATE, Qt::DescendingOrder); } void GxsForumThreadWidget::blank() @@ -639,7 +638,7 @@ void GxsForumThreadWidget::threadListCustomPopupMenu(QPoint /*point*/) } } - if(IS_GROUP_ADMIN(mSubscribeFlags)) + if(IS_GROUP_ADMIN(mSubscribeFlags) && (*selectedItems.begin())->parent() == NULL) contextMnu.addAction(pinUpPostAct); } @@ -1324,10 +1323,11 @@ QTreeWidgetItem *GxsForumThreadWidget::convertMsgToThreadWidget(const RsGxsForum } item->setText(COLUMN_THREAD_DATE, itemText); - item->setData(COLUMN_THREAD_DATE, ROLE_THREAD_SORT, itemSort); if(is_pinned) item->setData(COLUMN_THREAD_DATE,ROLE_THREAD_SORT, QVariant(0)); // this is used by the sorting model to put all posts on top + else + item->setData(COLUMN_THREAD_DATE,ROLE_THREAD_SORT, itemSort); // Set later with GxsIdRSTreeWidgetItem::setId item->setData(COLUMN_THREAD_DATA, ROLE_THREAD_AUTHOR, QString::fromStdString(msg.mMeta.mAuthorId.toStdString())); @@ -2171,6 +2171,14 @@ void GxsForumThreadWidget::togglePinUpPost() QTreeWidgetItem *item = ui->threadTreeWidget->currentItem(); + // normally this method is only called on top level items. We still check it just in case... + + if(item->parent() != NULL) + { + std::cerr << "(EE) togglePinUpPost() called on non top level post. This is inconsistent." << std::endl; + return ; + } + QString thread_title = (item != NULL)?item->text(COLUMN_THREAD_TITLE):QString() ; std::cerr << "Toggling Pin-up state of post " << mThreadId.toStdString() << ": \"" << thread_title.toStdString() << "\"" << std::endl; @@ -2183,6 +2191,7 @@ void GxsForumThreadWidget::togglePinUpPost() uint32_t token; rsGxsForums->updateGroup(token,mForumGroup); + ui->threadTreeWidget->takeTopLevelItem(ui->threadTreeWidget->indexOfTopLevelItem(item)); // forces the re-creation of all posts widgets. A bit extreme. We should rather only delete item above updateDisplay(true) ; }