auto clear of search field and fixed bug causing some lines not to update

This commit is contained in:
csoler 2020-08-29 14:46:35 +02:00
parent 11ecd6fbd1
commit 3ba9a1eb5d
3 changed files with 13 additions and 4 deletions

View File

@ -69,7 +69,7 @@ void RsGxsChannelPostsModel::setMode(TreeMode mode)
if(mode == TREE_MODE_LIST) if(mode == TREE_MODE_LIST)
setNumColumns(2); setNumColumns(2);
emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(rowCount()-1,mColumns-1,(void*)NULL)); triggerViewUpdate();
} }
void RsGxsChannelPostsModel::handleEvent_main_thread(std::shared_ptr<const RsEvent> event) void RsGxsChannelPostsModel::handleEvent_main_thread(std::shared_ptr<const RsEvent> event)
@ -116,7 +116,7 @@ void RsGxsChannelPostsModel::handleEvent_main_thread(std::shared_ptr<const RsEve
{ {
mPosts[j] = posts[i]; mPosts[j] = posts[i];
emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(rowCount()-1,mColumns-1,(void*)NULL)); triggerViewUpdate();
} }
} }
},this); },this);
@ -146,6 +146,10 @@ void RsGxsChannelPostsModel::postMods()
{ {
endResetModel(); endResetModel();
triggerViewUpdate();
}
void RsGxsChannelPostsModel::triggerViewUpdate()
{
emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(rowCount()-1,mColumns-1,(void*)NULL)); emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(rowCount()-1,mColumns-1,(void*)NULL));
} }

View File

@ -111,6 +111,8 @@ public:
void updateChannel(const RsGxsGroupId& channel_group_id); void updateChannel(const RsGxsGroupId& channel_group_id);
const RsGxsGroupId& currentGroupId() const; const RsGxsGroupId& currentGroupId() const;
void triggerViewUpdate();
void setNumColumns(int n); void setNumColumns(int n);
void setMode(TreeMode mode); void setMode(TreeMode mode);
TreeMode getMode() const { return mTreeMode; } TreeMode getMode() const { return mTreeMode; }

View File

@ -508,7 +508,9 @@ void GxsChannelPostsWidgetWithModel::switchView()
selectItem(msg_id); selectItem(msg_id);
ui->postsTree->setFocus(); ui->postsTree->setFocus();
ui->postsTree->dataChanged(QModelIndex(),QModelIndex()); // forces update of the whole tree mChannelPostsModel->triggerViewUpdate(); // This is already called by setMode(), but the model cannot know how many
// columns is actually has until we call handlePostsTreeSizeChange(), so
// we have to call it again here.
} }
void GxsChannelPostsWidgetWithModel::copyMessageLink() void GxsChannelPostsWidgetWithModel::copyMessageLink()
@ -581,7 +583,7 @@ void GxsChannelPostsWidgetWithModel::handlePostsTreeSizeChange(QSize s,bool forc
int n_columns = std::max(1,(int)floor(s.width() / (mChannelPostsDelegate->cellSize(0,font(),ui->postsTree->width())))); int n_columns = std::max(1,(int)floor(s.width() / (mChannelPostsDelegate->cellSize(0,font(),ui->postsTree->width()))));
std::cerr << "nb columns: " << n_columns << " current count=" << mChannelPostsModel->columnCount() << std::endl; std::cerr << "nb columns: " << n_columns << " current count=" << mChannelPostsModel->columnCount() << std::endl;
if(n_columns != mChannelPostsModel->columnCount()) if(force || (n_columns != mChannelPostsModel->columnCount()))
mChannelPostsModel->setNumColumns(n_columns); mChannelPostsModel->setNumColumns(n_columns);
} }
@ -714,6 +716,7 @@ void GxsChannelPostsWidgetWithModel::updateGroupData()
{ {
mGroup = group; mGroup = group;
mChannelPostsModel->updateChannel(groupId()); mChannelPostsModel->updateChannel(groupId());
ui->filterLineEdit->clear();
insertChannelDetails(mGroup); insertChannelDetails(mGroup);