Fix search in grouped queue

This commit is contained in:
craig
2012-02-27 19:57:33 +00:00
committed by craig
parent ef35eb49db
commit d80b2181f0
2 changed files with 21 additions and 7 deletions

View File

@@ -168,7 +168,6 @@ int PlayQueueModel::columnCount(const QModelIndex &) const
QVariant PlayQueueModel::data(const QModelIndex &index, int role) const
{
if (!index.isValid() || index.row() >= songs.size()) {
return QVariant();
}

View File

@@ -27,6 +27,7 @@
#include <QtCore/QByteArray>
#include "playqueueproxymodel.h"
#include "playqueuemodel.h"
#include "song.h"
PlayQueueProxyModel::PlayQueueProxyModel(QObject *parent)
: QSortFilterProxyModel(parent)
@@ -44,14 +45,28 @@ bool PlayQueueProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &sou
return true;
}
int columnCount = sourceModel()->columnCount(sourceParent);
Q_UNUSED(sourceParent)
PlayQueueModel *m=static_cast<PlayQueueModel *>(sourceModel());
Song s=m->getSongByRow(sourceRow);
QRegExp re=filterRegExp();
for (int i = 0; i < columnCount; i++) {
QModelIndex index = sourceModel()->index(sourceRow, i, sourceParent);
if (sourceModel()->data(index).toString().contains(filterRegExp())) {
return true;
}
/*if (m->isGrouped()) {
return QString(!s.albumartist.isEmpty() && s.albumartist != s.artist
? s.title + " - " + s.artist
: s.title).contains(re);
} else*/ {
return s.album.contains(re) || s.artist.contains(re) || s.genre.contains(re) ||
(s.title.isEmpty() ? s.file.contains(re) : s.title.contains(re));
}
// int columnCount = sourceModel()->columnCount(sourceParent);
//
// for (int i = 0; i < columnCount; i++) {
// QModelIndex index = sourceModel()->index(sourceRow, i, sourceParent);
// if (sourceModel()->data(index).toString().contains(filterRegExp())) {
// return true;
// }
// }
return false;
}