Ticket #84: filter.diff

File filter.diff, 8.7 KB (added by herman@…, 19 years ago)
  • mythmusic/playbackbox.cpp

     
    5151    curSmartPlaylistCategory = "";
    5252    curSmartPlaylistName = "";
    5353   
     54    menufilters = gContext->GetNumSetting("MusicMenuFilters", 0);
     55
    5456    // Set our pointers the playlists and the metadata containers
    5557
    5658    all_playlists = the_playlists;
     
    316318        else if (action == "MUTE")
    317319            toggleMute();
    318320        else if (action == "MENU")
     321        {
     322            menufilters = false;
    319323            showMenu();
     324        }
     325        else if (action == "FILTER")
     326        {
     327            menufilters = true;
     328            showMenu();
     329        }
    320330        else if (action == "INFO")
    321331            showEditMetadataDialog();
    322332        else
     
    554564   
    555565    visual_mode_timer->stop();
    556566
    557     all_playlists->getActive()->removeAllTracks();
     567    if (!menufilters)
     568        all_playlists->getActive()->removeAllTracks();
    558569    all_playlists->getActive()->fillSonglistFromQuery(whereClause);
    559     all_playlists->getActive()->fillSongsFromSonglist();
    560     all_playlists->getActive()->postLoad();
     570    all_playlists->getActive()->fillSongsFromSonglist(menufilters);
     571    if (!menufilters)
     572        all_playlists->getActive()->postLoad();
    561573
    562574    if (visual_mode_delay > 0)
    563575        visual_mode_timer->start(visual_mode_delay * 1000);
    564576
    565     constructPlaylistTree();
    566    
    567     stop();
    568     wipeTrackInfo();
    569    
    570     // move to first track in list
    571     branches_to_current_node.clear();
    572     branches_to_current_node.append(0); //  Root node
    573     branches_to_current_node.append(1); //  We're on a playlist (not "My Music")
    574     branches_to_current_node.append(0); //  Active play Queue
    575     music_tree_list->moveToNodesFirstChild(branches_to_current_node);
     577    if (!menufilters)
     578    {
     579        constructPlaylistTree();
     580       
     581        stop();
     582        wipeTrackInfo();
     583       
     584        // move to first track in list
     585        branches_to_current_node.clear();
     586        branches_to_current_node.append(0); //  Root node
     587        branches_to_current_node.append(1); //  We're on a playlist (not "My Music")
     588        branches_to_current_node.append(0); //  Active play Queue
     589        music_tree_list->moveToNodesFirstChild(branches_to_current_node);
     590    }
    576591    music_tree_list->refresh();
    577592}
    578593
     
    584599
    585600    all_playlists->getActive()->removeAllTracks();
    586601    all_playlists->getActive()->fillSonglistFromSmartPlaylist(category, name);
    587     all_playlists->getActive()->fillSongsFromSonglist();
     602    all_playlists->getActive()->fillSongsFromSonglist(menufilters);
    588603    all_playlists->getActive()->postLoad();
    589604
    590605    if (visual_mode_delay > 0)
  • mythmusic/playlist.h

     
    7575
    7676    void describeYourself(void); //  debugging
    7777
    78     void fillSongsFromSonglist();
     78    void fillSongsFromSonglist(bool filter);
    7979    void fillSonglistFromSongs();
    8080    void fillSonglistFromQuery(QString whereClause);
    8181    void fillSonglistFromSmartPlaylist(QString category, QString name);
  • mythmusic/metadata.cpp

     
    892892    Metadata *inserter;
    893893    while ( (inserter = an_iterator.current()) != 0 )
    894894    {
    895         intoTree(inserter);
     895        if (inserter->isVisible())
     896            intoTree(inserter);
    896897        ++an_iterator;
    897898    }
    898899}
     
    12031204    }
    12041205}
    12051206
     1207void AllMusic::setAllVisible(bool visible)
     1208{
     1209    QPtrListIterator<Metadata> an_iterator( all_music );
     1210    Metadata *md;
     1211    while ( (md = an_iterator.current()) != 0 )
     1212    {
     1213        md->setVisible(visible);
     1214        ++an_iterator;
     1215    }
     1216}
     1217
    12061218MusicNode::MusicNode(QString a_title, QStringList tree_levels, uint depth)
    12071219{
    12081220    my_title = a_title;
  • mythmusic/playlist.cpp

     
    319319    cd_playlist.clear();
    320320
    321321    active_playlist->loadPlaylist("default_playlist_storage", my_host);
    322     active_playlist->fillSongsFromSonglist();
     322    active_playlist->fillSongsFromSonglist(false);
    323323   
    324324    backup_playlist->loadPlaylist("backup_playlist_storage", my_host);
    325     backup_playlist->fillSongsFromSonglist();
     325    backup_playlist->fillSongsFromSonglist(false);
    326326
    327327    all_other_playlists->clear();
    328328
     
    342342            Playlist *temp_playlist = new Playlist(all_available_music);   //  No, we don't destruct this ...
    343343            temp_playlist->setParent(this);
    344344            temp_playlist->loadPlaylistByID(query.value(0).toInt(), my_host);
    345             temp_playlist->fillSongsFromSonglist();
     345            temp_playlist->fillSongsFromSonglist(false);
    346346            all_other_playlists->append(temp_playlist); //  ... cause it's sitting on this PtrList
    347347        }
    348348    }
     
    520520        name = "and they should **REALLY** never see this";
    521521}
    522522
    523 void Playlist::fillSongsFromSonglist()
     523void Playlist::fillSongsFromSonglist(bool filter)
    524524{
    525525    int an_int;
     526
     527    if (filter)
     528        all_available_music->setAllVisible(false);
     529
    526530    QStringList list = QStringList::split(",", raw_songlist);
    527531    QStringList::iterator it = list.begin();
    528532    for (; it != list.end(); it++)
     
    530534        an_int = QString(*it).toInt();
    531535        if (an_int != 0)
    532536        {
    533             Track *a_track = new Track(an_int, all_available_music);
    534             a_track->setParent(this);
    535             songs.append(a_track);
     537            if (filter)
     538            {
     539                Metadata *md = all_available_music->getMetadata(an_int);
     540                if(md)
     541                    md->setVisible(true);
     542            }
     543            else
     544            {
     545                Track *a_track = new Track(an_int, all_available_music);
     546                a_track->setParent(this);
     547                songs.append(a_track);
     548            }
    536549        }
    537550        else
    538551        {
     
    541554            cerr << "            If this happens on repeated invocations of mythmusic, then something is really wrong" << endl;
    542555        }
    543556    }
     557
     558    if (filter)
     559    {
     560        all_available_music->buildTree();
     561        all_available_music->sortTree();
     562    }
    544563}
    545564
    546565void Playlist::fillSonglistFromSongs()
  • mythmusic/metadata.h

     
    3838                lastplay = llastplay;
    3939                compilation = lcompilation;
    4040                changed = false;
     41                show = true;
    4142            }
    4243
    4344    Metadata(const Metadata &other)
     
    5859                lastplay = other.lastplay;
    5960                playcount = other.playcount;
    6061                compilation = other.compilation;
     62                show = other.show;
    6163                changed = false;
    6264            }
    6365
     
    110112    int PlayCount() { return playcount; }
    111113    void incPlayCount();
    112114
     115    bool isVisible() { return show; }
     116    void setVisible(bool visible) { show = visible; }
     117
    113118    // track is part of a compilation album
    114119    bool Compilation() { return compilation; }
    115120    void setCompilation(bool state) { compilation = state; formattedartist = formattedtitle = ""; }
     
    153158    QString filename;
    154159    bool    changed;
    155160
     161    bool    show;
     162
    156163    static QString m_startdir;
    157164
    158165    // Various formatting strings
     
    264271    bool        cleanOutThreads();
    265272    int         getCDTrackCount(){return cd_data.count();}
    266273    void        resetListings(){last_listed = -1;}
     274    void        setAllVisible(bool visible);
    267275   
    268276  private:
    269277 
  • mythmusic/main.cpp

     
    393393    REG_KEY("Music", "THMBUP", "Increase rating", "9");
    394394    REG_KEY("Music", "THMBDOWN", "Decrease rating", "7");
    395395    REG_KEY("Music", "REFRESH", "Refresh music tree", "8");
     396    REG_KEY("Music", "FILTER", "Filter All My Music", "F");
    396397
    397398    REG_MEDIA_HANDLER("MythMusic Media Handler", "", "", handleMedia, MEDIATYPE_AUDIO | MEDIATYPE_MIXED);
    398399}
  • mythmusic/playbackbox.h

     
    129129    bool isplaying;
    130130    bool lcd_volume_visible;
    131131
     132    bool menufilters;
     133
    132134    MainVisual *mainvisual;
    133135
    134136    QString visual_mode;