Esempio n. 1
0
bool PlaylistsProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
{
    if (!filterEnabled) {
        return true;
    }
    if (!isChildOfRoot(sourceParent)) {
        return true;
    }

    const QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent);
    PlaylistsModel::Item *item = static_cast<PlaylistsModel::Item *>(index.internalPointer());

    if (item->isPlaylist()) {
        PlaylistsModel::PlaylistItem *pl = static_cast<PlaylistsModel::PlaylistItem *>(item);

        if (matchesFilter(QStringList() << pl->name)) {
            return true;
        }

        for (PlaylistsModel::SongItem *s: pl->songs) {
            if (matchesFilter(*s)) {
                return true;
            }
        }
    } else {
        PlaylistsModel::SongItem *s = static_cast<PlaylistsModel::SongItem *>(item);
        return matchesFilter(*s);
    }

    return false;
}
Esempio n. 2
0
bool PlayQueueProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
{
    if (!filterEnabled) {
        return true;
    }

    if (-1!=sourceParent.row()) {
        return false;
    }

    const QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent);
    return index.isValid() && matchesFilter(*static_cast<Song *>(index.internalPointer()));
}
Esempio n. 3
0
bool DynamicProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
{
    if (!filterEnabled) {
        return true;
    }
    if (!isChildOfRoot(sourceParent)) {
        return true;
    }
    if (matchesFilter(QStringList() << sourceModel()->data(sourceModel()->index(sourceRow, 0, sourceParent), Qt::DisplayRole).toString())) {
        return true;
    }

    Dynamic::Entry item = Dynamic::self()->entry(sourceRow);
    foreach (const Dynamic::Rule & r, item.rules) {
        Dynamic::Rule::ConstIterator it=r.constBegin();
        Dynamic::Rule::ConstIterator end=r.constEnd();
        for (; it!=end; ++it) {
            if (matchesFilter(QStringList() << it.value())) {
                return true;
            }
        }
    }
    return false;
}
Esempio n. 4
0
bool DirViewProxyModel::filterAcceptsDirViewItem(const DirViewItem * const item, QStringList strings) const
{
    strings << item->data();
    if (matchesFilter(strings)) {
        return true;
    }

    for (int i = 0; i < item->childCount(); i++) {
        if (filterAcceptsDirViewItem(item->child(i), strings)) {
            return true;
        }
    }

    return false;
}
Esempio n. 5
0
bool DirViewProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
{
    if (!filterEnabled) {
        return true;
    }
    if (!isChildOfRoot(sourceParent)) {
        return true;
    }

    const QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent);
    DirViewItem *item = static_cast<DirViewItem *>(index.internalPointer());
    QModelIndex idx=index.parent();
    QStringList strings;

    // Traverse back up tree, so we get parent strings...
    while (idx.isValid()) {
        DirViewItem *i = static_cast<DirViewItem *>(idx.internalPointer());
        if (DirViewItem::Type_Dir!=i->type()) {
            break;
        }
        strings << i->data();
        idx=idx.parent();
    }

    if (DirViewItem::Type_Dir==item->type()) {
        // Check *all* children...
        if (filterAcceptsDirViewItem(item, strings)) {
            return true;
        }
    } else {
        strings << item->data();
        return matchesFilter(strings);
    }

    return false;
}
bool MusicLibraryProxyModel::filterAcceptsSong(const MusicLibraryItem *item) const
{
    return matchesFilter(static_cast<const MusicLibraryItemSong *>(item)->song());
}
Esempio n. 7
0
bool PodcastService::Proxy::filterAcceptsEpisode(const Episode *item) const
{
    return matchesFilter(QStringList() << item->name << item->parent->name);
}