mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-02-08 19:08:46 -05:00
improved the logic to make the channel layout update faster
This commit is contained in:
parent
9d956f6126
commit
3e35ce4ddd
@ -63,7 +63,7 @@ void RsGxsChannelPostsModel::setMode(TreeMode mode)
|
|||||||
if(mode == TREE_MODE_LIST)
|
if(mode == TREE_MODE_LIST)
|
||||||
setNumColumns(2);
|
setNumColumns(2);
|
||||||
|
|
||||||
triggerViewUpdate();
|
triggerViewUpdate(true,true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RsGxsChannelPostsModel::computeCommentCounts( std::vector<RsGxsChannelPost>& posts, std::vector<RsGxsComment>& comments)
|
void RsGxsChannelPostsModel::computeCommentCounts( std::vector<RsGxsChannelPost>& posts, std::vector<RsGxsComment>& comments)
|
||||||
@ -118,12 +118,15 @@ void RsGxsChannelPostsModel::preMods()
|
|||||||
}
|
}
|
||||||
void RsGxsChannelPostsModel::postMods()
|
void RsGxsChannelPostsModel::postMods()
|
||||||
{
|
{
|
||||||
triggerViewUpdate();
|
|
||||||
emit layoutChanged();
|
emit layoutChanged();
|
||||||
}
|
}
|
||||||
void RsGxsChannelPostsModel::triggerViewUpdate()
|
void RsGxsChannelPostsModel::triggerViewUpdate(bool data_changed, bool layout_changed)
|
||||||
{
|
{
|
||||||
|
if(data_changed)
|
||||||
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));
|
||||||
|
|
||||||
|
if(layout_changed)
|
||||||
|
emit layoutChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RsGxsChannelPostsModel::getFilesList(std::list<ChannelPostFileInfo>& files)
|
void RsGxsChannelPostsModel::getFilesList(std::list<ChannelPostFileInfo>& files)
|
||||||
@ -316,17 +319,8 @@ bool RsGxsChannelPostsModel::setNumColumns(int n)
|
|||||||
|
|
||||||
preMods();
|
preMods();
|
||||||
|
|
||||||
beginResetModel();
|
|
||||||
endResetModel();
|
|
||||||
|
|
||||||
mColumns = n;
|
mColumns = n;
|
||||||
|
|
||||||
if (rowCount()>0)
|
|
||||||
{
|
|
||||||
beginInsertRows(QModelIndex(),0,rowCount()-1);
|
|
||||||
endInsertRows();
|
|
||||||
}
|
|
||||||
|
|
||||||
postMods();
|
postMods();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -548,7 +542,7 @@ void RsGxsChannelPostsModel::updateSinglePost(const RsGxsChannelPost& post,std::
|
|||||||
uint32_t count;
|
uint32_t count;
|
||||||
updateFilter(count);
|
updateFilter(count);
|
||||||
|
|
||||||
triggerViewUpdate();
|
triggerViewUpdate(true,false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RsGxsChannelPostsModel::setPosts(const RsGxsChannelGroup& group, std::vector<RsGxsChannelPost>& posts)
|
void RsGxsChannelPostsModel::setPosts(const RsGxsChannelGroup& group, std::vector<RsGxsChannelPost>& posts)
|
||||||
|
@ -115,7 +115,7 @@ 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 triggerViewUpdate(bool data_changed,bool layout_changed);
|
||||||
|
|
||||||
// sets the number of columns. Returns 0 if nothing changes.
|
// sets the number of columns. Returns 0 if nothing changes.
|
||||||
bool setNumColumns(int n);
|
bool setNumColumns(int n);
|
||||||
|
@ -540,7 +540,11 @@ void GxsChannelPostsWidgetWithModel::updateZoomFactor(int what_to_do)
|
|||||||
int n_columns = std::max(1,(int)floor(s.width() / (mChannelPostsDelegate->cellSize(0,font(),s.width()))));
|
int n_columns = std::max(1,(int)floor(s.width() / (mChannelPostsDelegate->cellSize(0,font(),s.width()))));
|
||||||
|
|
||||||
mChannelPostsModel->setNumColumns(n_columns); // forces the update
|
mChannelPostsModel->setNumColumns(n_columns); // forces the update
|
||||||
mChannelPostsModel->triggerViewUpdate();
|
|
||||||
|
if(what_to_do)
|
||||||
|
mChannelPostsModel->triggerViewUpdate(true,false);
|
||||||
|
else
|
||||||
|
mChannelPostsModel->triggerViewUpdate(false,true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GxsChannelPostsWidgetWithModel::sortColumnPostFiles(int col,Qt::SortOrder so)
|
void GxsChannelPostsWidgetWithModel::sortColumnPostFiles(int col,Qt::SortOrder so)
|
||||||
@ -646,7 +650,7 @@ void GxsChannelPostsWidgetWithModel::switchView()
|
|||||||
selectItem(msg_id);
|
selectItem(msg_id);
|
||||||
ui->postsTree->setFocus();
|
ui->postsTree->setFocus();
|
||||||
|
|
||||||
mChannelPostsModel->triggerViewUpdate(); // This is already called by setMode(), but the model cannot know how many
|
mChannelPostsModel->triggerViewUpdate(false,true); // This is already called by setMode(), but the model cannot know how many
|
||||||
// columns is actually has until we call handlePostsTreeSizeChange(), so
|
// columns is actually has until we call handlePostsTreeSizeChange(), so
|
||||||
// we have to call it again here.
|
// we have to call it again here.
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user