mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-25 07:29:33 -05:00
preserve sorting strategy when updating posts
This commit is contained in:
parent
0e4d438066
commit
a142694896
@ -260,6 +260,7 @@ PostedListWidgetWithModel::PostedListWidgetWithModel(const RsGxsGroupId& postedI
|
||||
|
||||
mPostedPostsDelegate->setDisplayMode(BoardPostDisplayWidget::DISPLAY_MODE_CARD_VIEW);
|
||||
switchDisplayMode(); // makes everything consistent and chooses classic view as default
|
||||
updateSorting(ui->sortStrategy_CB->currentIndex());
|
||||
|
||||
mEventHandlerId = 0;
|
||||
// Needs to be asynced because this function is called by another thread!
|
||||
@ -293,9 +294,9 @@ void PostedListWidgetWithModel::updateSorting(int s)
|
||||
switch(s)
|
||||
{
|
||||
default:
|
||||
case 0: mPostedPostsModel->setSortingStrategy(RsPostedPostsModel::SORT_HOT_SCORE); break;
|
||||
case 1: mPostedPostsModel->setSortingStrategy(RsPostedPostsModel::SORT_NEW_SCORE); break;
|
||||
case 2: mPostedPostsModel->setSortingStrategy(RsPostedPostsModel::SORT_TOP_SCORE); break;
|
||||
case 0: mPostedPostsModel->setSortingStrategy(RsPostedPostsModel::SORT_NEW_SCORE); break;
|
||||
case 1: mPostedPostsModel->setSortingStrategy(RsPostedPostsModel::SORT_TOP_SCORE); break;
|
||||
case 2: mPostedPostsModel->setSortingStrategy(RsPostedPostsModel::SORT_HOT_SCORE); break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -351,7 +351,7 @@ p, li { white-space: pre-wrap; }
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>1</number>
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
@ -359,15 +359,6 @@ p, li { white-space: pre-wrap; }
|
||||
<height>24</height>
|
||||
</size>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Hot</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../icons.qrc">
|
||||
<normaloff>:/icons/png/flame.png</normaloff>:/icons/png/flame.png</iconset>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>New</string>
|
||||
@ -386,6 +377,15 @@ p, li { white-space: pre-wrap; }
|
||||
<normaloff>:/icons/png/top.png</normaloff>:/icons/png/top.png</iconset>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Hot</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../icons.qrc">
|
||||
<normaloff>:/icons/png/flame.png</normaloff>:/icons/png/flame.png</iconset>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
|
@ -48,6 +48,8 @@ RsPostedPostsModel::RsPostedPostsModel(QObject *parent)
|
||||
initEmptyHierarchy();
|
||||
|
||||
mEventHandlerId = 0;
|
||||
mSortingStrategy = SORT_NEW_SCORE;
|
||||
|
||||
// Needs to be asynced because this function is called by another thread!
|
||||
|
||||
rsEvents->registerEventsHandler( [this](std::shared_ptr<const RsEvent> event)
|
||||
@ -473,6 +475,7 @@ void RsPostedPostsModel::setSortingStrategy(RsPostedPostsModel::SortingStrategy
|
||||
{
|
||||
preMods();
|
||||
|
||||
mSortingStrategy = s;
|
||||
std::sort(mPosts.begin(),mPosts.end(), PostSorter(s));
|
||||
|
||||
postMods();
|
||||
@ -517,7 +520,7 @@ void RsPostedPostsModel::setPosts(const RsPostedGroup& group, std::vector<RsPost
|
||||
|
||||
createPostsArray(posts);
|
||||
|
||||
std::sort(mPosts.begin(),mPosts.end(), PostSorter(SORT_NEW_SCORE));
|
||||
std::sort(mPosts.begin(),mPosts.end(), PostSorter(mSortingStrategy));
|
||||
|
||||
uint32_t tmpval;
|
||||
setFilter(QStringList(),tmpval);
|
||||
|
@ -245,7 +245,7 @@ private:
|
||||
std::vector<int> mFilteredPosts;
|
||||
uint32_t mDisplayedStartIndex;
|
||||
uint32_t mDisplayedNbPosts;
|
||||
|
||||
SortingStrategy mSortingStrategy;
|
||||
|
||||
RsEventsHandlerId_t mEventHandlerId ;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user