mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-25 12:38:48 +03:00
Make unfiltered messages hidden by default
This commit is contained in:
parent
0597041d8e
commit
d4336b56d6
1 changed files with 24 additions and 16 deletions
|
@ -39,6 +39,8 @@ void
|
||||||
TimelineFilter::startFiltering()
|
TimelineFilter::startFiltering()
|
||||||
{
|
{
|
||||||
incrementalSearchIndex = 0;
|
incrementalSearchIndex = 0;
|
||||||
|
invalidateFilter();
|
||||||
|
|
||||||
continueFiltering();
|
continueFiltering();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,9 +63,10 @@ bool
|
||||||
TimelineFilter::event(QEvent *ev)
|
TimelineFilter::event(QEvent *ev)
|
||||||
{
|
{
|
||||||
if (ev->type() == getFilterEventType()) {
|
if (ev->type() == getFilterEventType()) {
|
||||||
// process the next 30 events by claiming their "filterrole" data has changed.
|
if (incrementalSearchIndex < std::numeric_limits<int>::max()) {
|
||||||
int orgIndex = incrementalSearchIndex;
|
int orgIndex = incrementalSearchIndex;
|
||||||
incrementalSearchIndex += 30;
|
// process the next 100 events by claiming their "filterrole" data has changed.
|
||||||
|
incrementalSearchIndex += 100;
|
||||||
|
|
||||||
if (auto s = source(); s) {
|
if (auto s = source(); s) {
|
||||||
auto count = s->rowCount();
|
auto count = s->rowCount();
|
||||||
|
@ -74,8 +77,12 @@ TimelineFilter::event(QEvent *ev)
|
||||||
s->dataChanged(s->index(orgIndex),
|
s->dataChanged(s->index(orgIndex),
|
||||||
s->index(std::min(incrementalSearchIndex, count - 1)),
|
s->index(std::min(incrementalSearchIndex, count - 1)),
|
||||||
{FilterRole});
|
{FilterRole});
|
||||||
|
|
||||||
|
if (incrementalSearchIndex < count && incrementalSearchIndex > 0) {
|
||||||
continueFiltering();
|
continueFiltering();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return QSortFilterProxyModel::event(ev);
|
return QSortFilterProxyModel::event(ev);
|
||||||
|
@ -113,11 +120,11 @@ TimelineFilter::fetchAgain()
|
||||||
if (threadId.isEmpty() && contentFilter.isEmpty())
|
if (threadId.isEmpty() && contentFilter.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (auto s = source()) {
|
if (auto s = source(); s && incrementalSearchIndex == std::numeric_limits<int>::max()) {
|
||||||
if (rowCount() == cachedCount && s->canFetchMore(QModelIndex()))
|
if (this->rowCount() == cachedCount && s->canFetchMore(QModelIndex()))
|
||||||
s->fetchMore(QModelIndex());
|
s->fetchMore(QModelIndex());
|
||||||
else
|
else
|
||||||
cachedCount = rowCount();
|
cachedCount = this->rowCount();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -163,6 +170,7 @@ TimelineFilter::setSource(TimelineModel *s)
|
||||||
|
|
||||||
// reset the search index a second time just to be safe.
|
// reset the search index a second time just to be safe.
|
||||||
incrementalSearchIndex = 0;
|
incrementalSearchIndex = 0;
|
||||||
|
|
||||||
emit sourceChanged();
|
emit sourceChanged();
|
||||||
invalidateFilter();
|
invalidateFilter();
|
||||||
}
|
}
|
||||||
|
@ -197,7 +205,7 @@ TimelineFilter::filterAcceptsRow(int source_row, const QModelIndex &) const
|
||||||
{
|
{
|
||||||
// this chunk is still unfiltered.
|
// this chunk is still unfiltered.
|
||||||
if (source_row > incrementalSearchIndex)
|
if (source_row > incrementalSearchIndex)
|
||||||
return true;
|
return false;
|
||||||
|
|
||||||
if (threadId.isEmpty() && contentFilter.isEmpty())
|
if (threadId.isEmpty() && contentFilter.isEmpty())
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in a new issue