Skip to content

Commit

Permalink
Avoid unnecessary checks
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidLazarescu committed Feb 11, 2024
1 parent 9dfb022 commit 804bf2a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ bool LibraryProxyModel::filterAcceptsRow(int source_row,
{
auto index = sourceModel()->index(source_row, 0, source_parent);

if(!getIsFiltering())
return filterAcceptsFolder(index);

return filterAcceptsTags(index) && filterAcceptsAuthors(index) &&
filterAcceptsFormat(index) && filterAcceptsStatus(index) &&
filterAcceptsLanguage(index) && filterAcceptsFolder(index);
Expand All @@ -119,7 +122,7 @@ void LibraryProxyModel::setFilterRequest(QString authors, QString format,
invalidateFilter();
}

bool LibraryProxyModel::getIsFiltering()
bool LibraryProxyModel::getIsFiltering() const
{
return !m_filterRequest.authors.isEmpty() ||
!m_filterRequest.format.isEmpty() ||
Expand Down Expand Up @@ -383,8 +386,8 @@ void LibraryProxyModel::setFolderFilter(const QString& newFolder)

m_folder = newFolder;

invalidateFilter();
emit folderFilterChanged();
invalidateFilter();
}

} // namespace adapters::data_models
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class ADAPTERS_EXPORT LibraryProxyModel : public QSortFilterProxyModel
Q_INVOKABLE void setFilterRequest(QString authors, QString format,
QString language, bool onlyBooks,
bool onlyFiles, bool read, bool unread);
Q_INVOKABLE bool getIsFiltering();
Q_INVOKABLE bool getIsFiltering() const;
Q_INVOKABLE void addFilterTag(QString tag);
Q_INVOKABLE void removeFilterTag(QString tag);
Q_INVOKABLE void clearFilterTags();
Expand Down

0 comments on commit 804bf2a

Please sign in to comment.