fixed display 10-posts chunks

This commit is contained in:
csoler 2020-07-12 20:17:32 +02:00
parent 6e07ead572
commit b7a9962400
No known key found for this signature in database
GPG Key ID: 7BCA522266C0804C
4 changed files with 27 additions and 6 deletions

View File

@ -122,9 +122,12 @@ private slots:
void subscribeGroup(bool subscribe);
void setViewMode(int viewMode);
void settingsChanged();
void postChannelPostLoad();
void postPostLoad();
void postContextMenu(const QPoint&);
void copyMessageLink();
void next10Posts();
void prev10Posts();
void filterItems(QString s);
public slots:
void handlePostsTreeSizeChange(QSize size);

View File

@ -385,6 +385,13 @@ p, li { white-space: pre-wrap; }
</item>
</widget>
</item>
<item>
<widget class="LineEditClear" name="filter_LE">
<property name="placeholderText">
<string>Search</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
@ -542,6 +549,11 @@ p, li { white-space: pre-wrap; }
<extends>QTreeView</extends>
<header>gui/common/RSTreeView.h</header>
</customwidget>
<customwidget>
<class>LineEditClear</class>
<extends>QLineEdit</extends>
<header>gui/common/LineEditClear.h</header>
</customwidget>
<customwidget>
<class>GxsIdChooser</class>
<extends>QComboBox</extends>

View File

@ -137,7 +137,7 @@ void RsPostedPostsModel::postMods()
{
endResetModel();
emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(mFilteredPosts.size(),0,(void*)NULL));
emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(mDisplayedNbPosts,0,(void*)NULL));
}
void RsPostedPostsModel::setFilter(const QStringList& strings, uint32_t& count)
@ -171,8 +171,10 @@ void RsPostedPostsModel::setFilter(const QStringList& strings, uint32_t& count)
}
count = mFilteredPosts.size();
mDisplayedStartIndex = 0;
if(mDisplayedNbPosts > count)
mDisplayedNbPosts = count;
mDisplayedNbPosts = count ;
std::cerr << "After filtering: " << count << " posts remain." << std::endl;
@ -210,7 +212,7 @@ bool RsPostedPostsModel::getPostData(const QModelIndex& i,RsPostedPost& fmpe) co
quintptr ref = i.internalId();
uint32_t entry = 0;
if(!convertRefPointerToTabEntry(ref,entry) || entry >= mFilteredPosts.size())
if(!convertRefPointerToTabEntry(ref,entry))
return false ;
fmpe = mPosts[mFilteredPosts[entry]];
@ -290,7 +292,7 @@ quintptr RsPostedPostsModel::getChildRef(quintptr ref,int index) const
if(ref == quintptr(0))
{
quintptr new_ref;
convertTabEntryToRefPointer(index,new_ref);
convertTabEntryToRefPointer(index+mDisplayedStartIndex,new_ref);
return new_ref;
}
else
@ -717,7 +719,7 @@ QModelIndex RsPostedPostsModel::getIndexOfMessage(const RsGxsMessageId& mid) con
RsGxsMessageId postId = mid;
for(uint32_t i=0;i<mFilteredPosts.size();++i)
for(uint32_t i=mDisplayedStartIndex;i<mDisplayedStartIndex+mDisplayedNbPosts;++i)
{
// First look into msg versions, in case the msg is a version of an existing message

View File

@ -57,6 +57,8 @@
// Filter Str | | X | X (updated because FilteredList may change)
// Chunk chng | | X | X
//
// In the model, indexes internal refs are pointer casts of the index in the mFilteredPosts tab. Another possible choice
// was to use indexes in the tab of displayed indices, but this leads to a more complex impleemntation.
typedef uint32_t PostedPostsModelIndex;
@ -155,6 +157,8 @@ public:
// Helper functions
bool getPostData(const QModelIndex& i,RsPostedPost& fmpe) const ;
uint32_t postsCount() const { return mPosts.size() ; }
uint32_t displayedStartPostIndex() const { return mDisplayedStartIndex ; }
void clear() ;
// AbstractItemModel functions.