patch from Phenom to fix uninitialized values

This commit is contained in:
csoler 2021-02-10 19:59:52 +01:00
parent faadd24ef3
commit f0500c3fd1
3 changed files with 26 additions and 9 deletions

View File

@ -351,31 +351,45 @@ void PostedListWidgetWithModel::handlePostsTreeSizeChange(QSize size)
mPostedPostsModel->triggerRedraw();
}
void PostedListWidgetWithModel::updateShowLabel()
{
if (mPostedPostsModel->rowCount() > 0)
whileBlocking(ui->showLabel)->setText(QString::number(mPostedPostsModel->displayedStartPostIndex()+1)
+" - "+QString::number(mPostedPostsModel->displayedStartPostIndex()+mPostedPostsModel->rowCount()));
else
whileBlocking(ui->showLabel)->setText(tr("Empty"));
ui->nextButton->setEnabled(mPostedPostsModel->displayedStartPostIndex() + POSTS_CHUNK_SIZE < mPostedPostsModel->filteredPostsCount());
ui->prevButton->setEnabled(mPostedPostsModel->displayedStartPostIndex() > 0);
}
void PostedListWidgetWithModel::filterItems(QString text)
{
QStringList lst = text.split(" ",QString::SkipEmptyParts) ;
uint32_t count;
mPostedPostsModel->setFilter(lst,count) ;
ui->showLabel->setText(QString::number(mPostedPostsModel->displayedStartPostIndex()+1)+" - "+QString::number(std::min(mPostedPostsModel->filteredPostsCount(),mPostedPostsModel->displayedStartPostIndex()+POSTS_CHUNK_SIZE+1)));
updateShowLabel();
}
void PostedListWidgetWithModel::nextPosts()
{
ui->postsTree->selectionModel()->clear();
if(mPostedPostsModel->displayedStartPostIndex() + POSTS_CHUNK_SIZE < mPostedPostsModel->filteredPostsCount())
{
mPostedPostsModel->setPostsInterval(POSTS_CHUNK_SIZE+mPostedPostsModel->displayedStartPostIndex(),POSTS_CHUNK_SIZE);
ui->showLabel->setText(QString::number(mPostedPostsModel->displayedStartPostIndex()+1)+" - "+QString::number(std::min(mPostedPostsModel->filteredPostsCount(),mPostedPostsModel->displayedStartPostIndex()+POSTS_CHUNK_SIZE+1)));
updateShowLabel();
}
}
void PostedListWidgetWithModel::prevPosts()
{
if((int)mPostedPostsModel->displayedStartPostIndex() - POSTS_CHUNK_SIZE >= 0)
ui->postsTree->selectionModel()->clear();
if((int)mPostedPostsModel->displayedStartPostIndex() > 0)
{
mPostedPostsModel->setPostsInterval(mPostedPostsModel->displayedStartPostIndex()-POSTS_CHUNK_SIZE,POSTS_CHUNK_SIZE);
ui->showLabel->setText(QString::number(mPostedPostsModel->displayedStartPostIndex()+1)+" - "+QString::number(std::min(mPostedPostsModel->filteredPostsCount(),mPostedPostsModel->displayedStartPostIndex()+POSTS_CHUNK_SIZE+1)));
mPostedPostsModel->setPostsInterval((int)mPostedPostsModel->displayedStartPostIndex()-POSTS_CHUNK_SIZE,POSTS_CHUNK_SIZE);
updateShowLabel();
}
}
@ -651,7 +665,7 @@ void PostedListWidgetWithModel::postPostLoad()
else
std::cerr << "No pre-selected channel post." << std::endl;
whileBlocking(ui->showLabel)->setText(QString::number(mPostedPostsModel->displayedStartPostIndex()+1)+" - "+QString::number(std::min(mPostedPostsModel->filteredPostsCount(),mPostedPostsModel->displayedStartPostIndex()+POSTS_CHUNK_SIZE+1)));
updateShowLabel();
}
void PostedListWidgetWithModel::forceRedraw()

View File

@ -150,6 +150,7 @@ private slots:
void nextPosts();
void prevPosts();
void filterItems(QString s);
void updateShowLabel();
public slots:
void handlePostsTreeSizeChange(QSize size);

View File

@ -194,7 +194,7 @@ void RsPostedPostsModel::setFilter(const QStringList& strings, uint32_t& count)
count = mFilteredPosts.size();
mDisplayedStartIndex = 0;
mDisplayedNbPosts = std::min(count,mDisplayedNbPosts) ;
mDisplayedNbPosts = std::min(count,mDefaultDisplayedNbPosts) ;
std::cerr << "After filtering: " << count << " posts remain." << std::endl;
@ -494,6 +494,8 @@ void RsPostedPostsModel::setPostsInterval(int start,int nb_posts)
{
if(start >= (int)mFilteredPosts.size())
return;
if(start < 0)
start = 0;
preMods();
@ -542,7 +544,7 @@ void RsPostedPostsModel::setPosts(const RsPostedGroup& group, std::vector<RsPost
uint32_t tmpval;
setFilter(QStringList(),tmpval);
mDisplayedNbPosts = std::min((uint32_t)mFilteredPosts.size(),mDisplayedNbPosts);
mDisplayedNbPosts = std::min((uint32_t)mFilteredPosts.size(),mDefaultDisplayedNbPosts);
mDisplayedStartIndex = 0;
if (rowCount()>0)