Faster filter
This commit is contained in:
@@ -64,6 +64,10 @@ bool AlbumsProxyModel::filterAcceptsSong(AlbumsModel::Item *item) const
|
||||
|
||||
bool AlbumsProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
|
||||
{
|
||||
if (filterGenre.isEmpty() && filterRegExp().isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent);
|
||||
AlbumsModel::Item *item = static_cast<AlbumsModel::Item *>(index.internalPointer());
|
||||
|
||||
|
||||
@@ -72,14 +72,16 @@ bool DirViewProxyModel::filterAcceptsDirViewItem(const DirViewItem * const item,
|
||||
|
||||
bool DirViewProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
|
||||
{
|
||||
if (filterRegExp().isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent);
|
||||
DirViewItem *item = static_cast<DirViewItem *>(index.internalPointer());
|
||||
|
||||
return filterAcceptsDirViewItem(item, true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool DirViewProxyModel::lessThan(const QModelIndex &left, const QModelIndex &right) const
|
||||
{
|
||||
const DirViewItem * const leftItem = static_cast<DirViewItem *>(left.internalPointer());
|
||||
|
||||
@@ -136,6 +136,10 @@ bool MusicLibraryProxyModel::filterAcceptsSong(const MusicLibraryItem * const it
|
||||
|
||||
bool MusicLibraryProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
|
||||
{
|
||||
if (_filterGenre.isEmpty() && filterRegExp().isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent);
|
||||
const MusicLibraryItem * const item = static_cast<MusicLibraryItem *>(index.internalPointer());
|
||||
|
||||
|
||||
@@ -37,6 +37,10 @@ PlaylistsProxyModel::PlaylistsProxyModel(QObject *parent) : QSortFilterProxyMode
|
||||
|
||||
bool PlaylistsProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
|
||||
{
|
||||
if (filterRegExp().isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent);
|
||||
PlaylistsModel::Item *item = static_cast<PlaylistsModel::Item *>(index.internalPointer());
|
||||
|
||||
|
||||
@@ -38,6 +38,10 @@ PlayQueueProxyModel::PlayQueueProxyModel(QObject *parent) : QSortFilterProxyMode
|
||||
|
||||
bool PlayQueueProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
|
||||
{
|
||||
if (filterRegExp().isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
int columnCount = sourceModel()->columnCount(sourceParent);
|
||||
|
||||
for (int i = 0; i < columnCount; i++) {
|
||||
@@ -62,11 +66,8 @@ QMimeData *PlayQueueProxyModel::mimeData(const QModelIndexList &indexes) const
|
||||
}
|
||||
|
||||
/* map proxy to real indexes and redirect to sourceModel */
|
||||
bool PlayQueueProxyModel::dropMimeData(const QMimeData *data,
|
||||
Qt::DropAction action, int row, int column, const QModelIndex & parent)
|
||||
bool PlayQueueProxyModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent)
|
||||
{
|
||||
const QModelIndex index = this->index(row, column, parent);
|
||||
const QModelIndex sourceIndex = mapToSource(index);
|
||||
|
||||
const QModelIndex sourceIndex = mapToSource(index(row, column, parent));
|
||||
return sourceModel()->dropMimeData(data, action, sourceIndex.row(), sourceIndex.column(), sourceIndex.parent());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user