fixed update of posts list in new ForumModel

This commit is contained in:
csoler 2018-11-22 09:47:58 +01:00
parent e01de33e1a
commit b28a76e35b
No known key found for this signature in database
GPG key ID: 7BCA522266C0804C
2 changed files with 21 additions and 15 deletions

View file

@ -202,7 +202,8 @@ GxsForumThreadWidget::GxsForumThreadWidget(const RsGxsGroupId &forumId, QWidget
mThreadCompareRole = new RSTreeWidgetItemCompareRole; mThreadCompareRole = new RSTreeWidgetItemCompareRole;
mThreadCompareRole->setRole(COLUMN_THREAD_DATE, ROLE_THREAD_SORT); mThreadCompareRole->setRole(COLUMN_THREAD_DATE, ROLE_THREAD_SORT);
ui->threadTreeWidget->setModel(new RsGxsForumModel(this)); mThreadModel = new RsGxsForumModel(this);
ui->threadTreeWidget->setModel(mThreadModel);
ui->threadTreeWidget->setItemDelegateForColumn(COLUMN_THREAD_DISTRIBUTION,new DistributionItemDelegate()) ; ui->threadTreeWidget->setItemDelegateForColumn(COLUMN_THREAD_DISTRIBUTION,new DistributionItemDelegate()) ;
connect(ui->versions_CB, SIGNAL(currentIndexChanged(int)), this, SLOT(changedVersion())); connect(ui->versions_CB, SIGNAL(currentIndexChanged(int)), this, SLOT(changedVersion()));
@ -395,7 +396,8 @@ void GxsForumThreadWidget::groupIdChanged()
emit groupChanged(this); emit groupChanged(this);
fillComplete(); mThreadModel->setForum(groupId());
//fillComplete();
} }
QString GxsForumThreadWidget::groupName(bool withUnreadCount) QString GxsForumThreadWidget::groupName(bool withUnreadCount)
@ -474,7 +476,7 @@ void GxsForumThreadWidget::updateDisplay(bool complete)
if (complete) { if (complete) {
/* Fill complete */ /* Fill complete */
requestGroupData(); requestGroupData();
insertThreads(); //insertThreads();
insertMessage(); insertMessage();
mIgnoredMsgId.clear(); mIgnoredMsgId.clear();
@ -492,7 +494,7 @@ void GxsForumThreadWidget::updateDisplay(bool complete)
if (grpIds.find(groupId())!=grpIds.end()){ if (grpIds.find(groupId())!=grpIds.end()){
updateGroup = true; updateGroup = true;
/* Update threads */ /* Update threads */
insertThreads(); //insertThreads();
} else { } else {
std::map<RsGxsGroupId, std::set<RsGxsMessageId> > msgIds; std::map<RsGxsGroupId, std::set<RsGxsMessageId> > msgIds;
getAllMsgIds(msgIds); getAllMsgIds(msgIds);
@ -504,7 +506,7 @@ void GxsForumThreadWidget::updateDisplay(bool complete)
if (msgIds.find(groupId()) != msgIds.end()) { if (msgIds.find(groupId()) != msgIds.end()) {
/* Update threads */ /* Update threads */
insertThreads(); //insertThreads();
} }
} }
@ -1427,7 +1429,7 @@ QTreeWidgetItem *GxsForumThreadWidget::convertMsgToThreadWidget(const RsGxsForum
return item; return item;
} }
#ifdef TO_REMOVE
void GxsForumThreadWidget::insertThreads() void GxsForumThreadWidget::insertThreads()
{ {
#ifdef DEBUG_FORUMS #ifdef DEBUG_FORUMS
@ -1502,9 +1504,9 @@ void GxsForumThreadWidget::insertThreads()
ui->threadTreeWidget->setRootIsDecorated(!mFillThread->mFlatView); ui->threadTreeWidget->setRootIsDecorated(!mFillThread->mFlatView);
// connect thread // connect thread
connect(mFillThread, SIGNAL(finished()), this, SLOT(fillThreadFinished()), Qt::BlockingQueuedConnection); // connect(mFillThread, SIGNAL(finished()), this, SLOT(fillThreadFinished()), Qt::BlockingQueuedConnection);
connect(mFillThread, SIGNAL(status(QString)), this, SLOT(fillThreadStatus(QString))); // connect(mFillThread, SIGNAL(status(QString)), this, SLOT(fillThreadStatus(QString)));
connect(mFillThread, SIGNAL(progress(int,int)), this, SLOT(fillThreadProgress(int,int))); // connect(mFillThread, SIGNAL(progress(int,int)), this, SLOT(fillThreadProgress(int,int)));
#ifdef DEBUG_FORUMS #ifdef DEBUG_FORUMS
std::cerr << "ForumsDialog::insertThreads() Start fill thread" << std::endl; std::cerr << "ForumsDialog::insertThreads() Start fill thread" << std::endl;
@ -1535,7 +1537,6 @@ static void copyItem(QTreeWidgetItem *item, const QTreeWidgetItem *newItem)
void GxsForumThreadWidget::fillThreads(QList<QTreeWidgetItem *> &threadList, bool expandNewMessages, QList<QTreeWidgetItem*> &itemToExpand) void GxsForumThreadWidget::fillThreads(QList<QTreeWidgetItem *> &threadList, bool expandNewMessages, QList<QTreeWidgetItem*> &itemToExpand)
{ {
#ifdef TODO
#ifdef DEBUG_FORUMS #ifdef DEBUG_FORUMS
std::cerr << "GxsForumThreadWidget::fillThreads()" << std::endl; std::cerr << "GxsForumThreadWidget::fillThreads()" << std::endl;
#endif #endif
@ -1607,9 +1608,10 @@ void GxsForumThreadWidget::fillThreads(QList<QTreeWidgetItem *> &threadList, boo
#ifdef DEBUG_FORUMS #ifdef DEBUG_FORUMS
std::cerr << "GxsForumThreadWidget::fillThreads() done" << std::endl; std::cerr << "GxsForumThreadWidget::fillThreads() done" << std::endl;
#endif #endif
#endif
} }
#endif
#ifdef TO_REMOVE
void GxsForumThreadWidget::fillChildren(QTreeWidgetItem *parentItem, QTreeWidgetItem *newParentItem, bool expandNewMessages, QList<QTreeWidgetItem*> &itemToExpand) void GxsForumThreadWidget::fillChildren(QTreeWidgetItem *parentItem, QTreeWidgetItem *newParentItem, bool expandNewMessages, QList<QTreeWidgetItem*> &itemToExpand)
{ {
int index = 0; int index = 0;
@ -1673,6 +1675,7 @@ void GxsForumThreadWidget::fillChildren(QTreeWidgetItem *parentItem, QTreeWidget
} }
} }
} }
#endif
void GxsForumThreadWidget::insertMessage() void GxsForumThreadWidget::insertMessage()
{ {
@ -2487,7 +2490,7 @@ void GxsForumThreadWidget::filterColumnChanged(int column)
if (column == COLUMN_THREAD_CONTENT) { if (column == COLUMN_THREAD_CONTENT) {
// need content ... refill // need content ... refill
insertThreads(); //insertThreads();
} else { } else {
filterItems(ui->filterLineEdit->text()); filterItems(ui->filterLineEdit->text());
} }

View file

@ -32,6 +32,7 @@ class RSTreeWidgetItemCompareRole;
class RsGxsForumMsg; class RsGxsForumMsg;
class GxsForumsFillThread; class GxsForumsFillThread;
class RsGxsForumGroup; class RsGxsForumGroup;
class RsGxsForumModel;
namespace Ui { namespace Ui {
class GxsForumThreadWidget; class GxsForumThreadWidget;
@ -149,11 +150,11 @@ private slots:
private: private:
void insertMessageData(const RsGxsForumMsg &msg); void insertMessageData(const RsGxsForumMsg &msg);
void insertThreads();
void insertMessage(); void insertMessage();
void fillThreads(QList<QTreeWidgetItem *> &threadList, bool expandNewMessages, QList<QTreeWidgetItem*> &itemToExpand); //void insertThreads();
void fillChildren(QTreeWidgetItem *parentItem, QTreeWidgetItem *newParentItem, bool expandNewMessages, QList<QTreeWidgetItem*> &itemToExpand); //void fillThreads(QList<QTreeWidgetItem *> &threadList, bool expandNewMessages, QList<QTreeWidgetItem*> &itemToExpand);
//void fillChildren(QTreeWidgetItem *parentItem, QTreeWidgetItem *newParentItem, bool expandNewMessages, QList<QTreeWidgetItem*> &itemToExpand);
int getSelectedMsgCount(QList<QTreeWidgetItem*> *pRows, QList<QTreeWidgetItem*> *pRowsRead, QList<QTreeWidgetItem*> *pRowsUnread); int getSelectedMsgCount(QList<QTreeWidgetItem*> *pRows, QList<QTreeWidgetItem*> *pRowsRead, QList<QTreeWidgetItem*> *pRowsUnread);
void setMsgReadStatus(QList<QTreeWidgetItem*> &rows, bool read); void setMsgReadStatus(QList<QTreeWidgetItem*> &rows, bool read);
@ -225,6 +226,8 @@ private:
QMap<RsGxsMessageId,QVector<QPair<time_t,RsGxsMessageId> > > mPostVersions ; // holds older versions of posts QMap<RsGxsMessageId,QVector<QPair<time_t,RsGxsMessageId> > > mPostVersions ; // holds older versions of posts
RsGxsForumModel *mThreadModel;
Ui::GxsForumThreadWidget *ui; Ui::GxsForumThreadWidget *ui;
}; };