fixed display of current post in new Forum Model

This commit is contained in:
csoler 2018-11-22 22:52:27 +01:00
parent 20b8bca801
commit 543a7f280d
No known key found for this signature in database
GPG Key ID: 7BCA522266C0804C
3 changed files with 15 additions and 17 deletions

View File

@ -83,7 +83,7 @@ int RsGxsForumModel::rowCount(const QModelIndex& parent) const
}
int RsGxsForumModel::columnCount(const QModelIndex &parent) const
{
return COLUMN_THREAD_COUNT ;
return COLUMN_THREAD_NB_COLUMNS ;
}
bool RsGxsForumModel::hasChildren(const QModelIndex &parent) const
@ -139,7 +139,7 @@ bool RsGxsForumModel::convertRefPointerToTabEntry(void *ref,uint32_t& entry)
QModelIndex RsGxsForumModel::index(int row, int column, const QModelIndex & parent) const
{
// if(!hasIndex(row,column,parent))
if(row < 0 || column < 0 || column >= COLUMN_THREAD_COUNT)
if(row < 0 || column < 0 || column >= COLUMN_THREAD_NB_COLUMNS)
return QModelIndex();
void *ref = getChildRef(parent.internalPointer(),row);
@ -918,7 +918,7 @@ void RsGxsForumModel::debug_dump()
{
const ForumModelPostEntry& e(mPosts[i]);
std::cerr << " " << i << " : " << e.mAuthorId.toStdString() << " " << QString("%1").arg((uint32_t)e.mPostFlags,8,16,QChar('0')).toStdString();
std::cerr << " " << i << " : " << e.mMsgId << " (from " << e.mAuthorId.toStdString() << ") " << QString("%1").arg((uint32_t)e.mPostFlags,8,16,QChar('0')).toStdString();
for(uint32_t i=0;i<e.mChildren.size();++i)
std::cerr << " " << e.mChildren[i] ;

View File

@ -219,7 +219,7 @@ GxsForumThreadWidget::GxsForumThreadWidget(const RsGxsGroupId &forumId, QWidget
ui->newmessageButton->setText(tr("Reply"));
ui->newthreadButton->setText(tr("New thread"));
connect(ui->threadTreeWidget, SIGNAL(itemSelectionChanged()), this, SLOT(changedThread()));
connect(ui->threadTreeWidget, SIGNAL(clicked(QModelIndex)), this, SLOT(changedThread(QModelIndex)));
connect(ui->threadTreeWidget, SIGNAL(itemClicked(QTreeWidgetItem*,int)), this, SLOT(clickedThread(QTreeWidgetItem*,int)));
connect(ui->viewBox, SIGNAL(currentIndexChanged(int)), this, SLOT(changedViewBox()));
@ -776,21 +776,16 @@ void GxsForumThreadWidget::changedVersion()
insertMessage();
}
void GxsForumThreadWidget::changedThread()
void GxsForumThreadWidget::changedThread(QModelIndex index)
{
/* just grab the ids of the current item */
QModelIndexList selected_indexes = ui->threadTreeWidget->selectionModel()->selectedIndexes();
if(selected_indexes.size() != 1)
if(!index.isValid())
{
mThreadId.clear();
mOrigThreadId.clear();
return;
}
QModelIndex index = *selected_indexes.begin();
mThreadId = mOrigThreadId = RsGxsMessageId(index.sibling(index.row(),COLUMN_THREAD_MSGID).data(Qt::DisplayRole).toString().toStdString());
mThreadId = mOrigThreadId = RsGxsMessageId(mThreadModel->data(index.sibling(index.row(),COLUMN_THREAD_MSGID),Qt::DisplayRole).toString().toStdString());
std::cerr << "Switched to new thread ID " << mThreadId << std::endl;
@ -1785,7 +1780,6 @@ void GxsForumThreadWidget::insertMessage()
void GxsForumThreadWidget::insertMessageData(const RsGxsForumMsg &msg)
{
#ifdef TODO
/* As some time has elapsed since request - check that this is still the current msg.
* otherwise, another request will fill the data
*/
@ -1811,11 +1805,13 @@ void GxsForumThreadWidget::insertMessageData(const RsGxsForumMsg &msg)
mStateHelper->setActive(mTokenTypeMessageData, true);
QTreeWidgetItem *item = ui->threadTreeWidget->currentItem();
//mThreadId = mOrigThreadId = RsGxsMessageId(mThreadModel->data(index.sibling(index.row(),COLUMN_THREAD_MSGID),Qt::DisplayRole).toString().toStdString());
//QTreeWidgetItem *item = ui->threadTreeWidget->currentItem();
bool setToReadOnActive = Settings->getForumMsgSetToReadOnActivate();
uint32_t status = item->data(COLUMN_THREAD_DATA, ROLE_THREAD_STATUS).toUInt();
uint32_t status = msg.mMeta.mMsgStatus ;//item->data(COLUMN_THREAD_DATA, ROLE_THREAD_STATUS).toUInt();
#ifdef TODO
QList<QTreeWidgetItem*> row;
row.append(item);
@ -1833,6 +1829,7 @@ void GxsForumThreadWidget::insertMessageData(const RsGxsForumMsg &msg)
setMsgReadStatus(row, true);
}
}
#endif
ui->time_label->setText(DateTime::formatLongDateTime(msg.mMeta.mPublishTs));
ui->by_label->setId(msg.mMeta.mAuthorId);
@ -1860,7 +1857,6 @@ void GxsForumThreadWidget::insertMessageData(const RsGxsForumMsg &msg)
ui->postText->setHtml(extraTxt);
}
// ui->threadTitle->setText(QString::fromUtf8(msg.mMeta.mMsgName.c_str()));
#endif
}
void GxsForumThreadWidget::previousMessage()
@ -2604,6 +2600,8 @@ void GxsForumThreadWidget::updateMessageData(const RsGxsMessageId& msgId)
{
// 1 - get message data from p3GxsForums
std::cerr << "Retrieving post data for post " << msgId << std::endl;
std::set<RsGxsMessageId> msgs_to_request ;
std::vector<RsGxsForumMsg> msgs;

View File

@ -96,7 +96,7 @@ private slots:
void threadListCustomPopupMenu(QPoint point);
void contextMenuTextBrowser(QPoint point);
void changedThread();
void changedThread(QModelIndex index);
void changedVersion();
void clickedThread (QTreeWidgetItem *item, int column);