Ticket #3988: filters.2.diff

File filters.2.diff, 5.0 KB (added by herman@…, 17 years ago)

Diff relative to mythplugins; fixed selection of default node

  • mythmusic/mythmusic/metadata.cpp

     
    977977    delete builder;
    978978}
    979979
    980 void AllMusic::writeTree(GenericTree *tree_to_write_to)
     980void AllMusic::writeTree(GenericTree *tree_to_write_to, bool skiproot)
    981981{
    982     m_root_node->writeTree(tree_to_write_to, 0);
     982    m_root_node->writeTree(tree_to_write_to, 0, !skiproot);
    983983}
    984984
    985985bool AllMusic::putYourselfOnTheListView(TreeCheckItem *where)
     
    12651265   
    12661266}
    12671267
    1268 void MusicNode::writeTree(GenericTree *tree_to_write_to, int a_counter)
     1268void MusicNode::writeTree(GenericTree *tree_to_write_to, int a_counter, bool addself)
    12691269{
    12701270   
    1271     GenericTree *sub_node = tree_to_write_to->addNode(my_title);
    1272     sub_node->setAttribute(0, 0);
    1273     sub_node->setAttribute(1, a_counter);
    1274     sub_node->setAttribute(2, rand());
    1275     sub_node->setAttribute(3, rand());
     1271    GenericTree *sub_node;
     1272
     1273    if(addself)
     1274    {
     1275        sub_node = tree_to_write_to->addNode(my_title);
     1276        sub_node->setAttribute(0, 0);
     1277        sub_node->setAttribute(1, a_counter);
     1278        sub_node->setAttribute(2, rand());
     1279        sub_node->setAttribute(3, rand());
     1280    }
     1281    else
     1282        sub_node = tree_to_write_to;
    12761283   
    12771284    QPtrListIterator<Metadata>  anit(my_tracks);
    12781285    Metadata *a_track;
  • mythmusic/mythmusic/playlist.cpp

     
    10691069
    10701070GenericTree* PlaylistsContainer::writeTree(GenericTree *tree_to_write_to)
    10711071{
     1072    GenericTree *sub_node;
     1073
    10721074    all_available_music->writeTree(tree_to_write_to);
    10731075
    1074     GenericTree *sub_node = tree_to_write_to->addNode(QObject::tr("All My Playlists"), 1);
     1076    sub_node = tree_to_write_to->addNode(QObject::tr("All My Playlists"), 1);
    10751077    sub_node->setAttribute(0, 1);
    10761078    sub_node->setAttribute(1, 1);
    10771079    sub_node->setAttribute(2, 1);
     
    11261128
    11271129    GenericTree* active_playlist_node = subsub_node->findLeaf();
    11281130    if(!active_playlist_node) active_playlist_node = subsub_node;
     1131
     1132    MSqlQuery query(MSqlQuery::InitCon());
     1133
     1134    MSqlQuery subquery(MSqlQuery::InitCon());
     1135    subquery.prepare("SELECT smartplaylistid, name FROM music_smartplaylists "
     1136                     "WHERE categoryid = :CATEGORYID ORDER BY name;");
     1137
     1138    a_counter = 2;
     1139    if (query.exec("SELECT categoryid, name FROM music_smartplaylist_categories ORDER BY name;"))
     1140    {
     1141        if (query.isActive() && query.numRowsAffected() > 0)
     1142        {
     1143            while (query.next())
     1144            {
     1145                sub_node = tree_to_write_to->addNode(QString::fromUtf8(query.value(1).toString()), a_counter++);
     1146
     1147                subquery.bindValue(":CATEGORYID", query.value(0));
     1148                if (subquery.exec())
     1149                {
     1150                    if (subquery.isActive() && subquery.numRowsAffected() > 0)
     1151                    {
     1152                        while (subquery.next())
     1153                        {
     1154                            Playlist *pl_playlist = new Playlist(all_available_music);
     1155
     1156                            pl_playlist->fillSonglistFromSmartPlaylist(query.value(1).toString(),
     1157                                            subquery.value(1).toString(), false, PL_FILTERONLY, 0);
     1158
     1159                            GenericTree *subsub_node =
     1160                                sub_node->addNode(QString::fromUtf8(subquery.value(1).toString()), 2);
     1161
     1162                            all_available_music->writeTree(subsub_node, true);
     1163
     1164                            delete pl_playlist;
     1165                        }
     1166                    }
     1167                }
     1168
     1169            }
     1170        }
     1171    }   
     1172
    11291173    return active_playlist_node;
    11301174}
    11311175
  • mythmusic/mythmusic/metadata.h

     
    269269    QString     getTitle(){return my_title;}
    270270    void        printYourself(int indent_amount);   // debugging
    271271    void        putYourselfOnTheListView(TreeCheckItem *parent, bool show_node);
    272     void        writeTree(GenericTree *tree_to_write_to, int a_counter);
     272    void        writeTree(GenericTree *tree_to_write_to, int a_counter, bool addself = true);
    273273    void        sort();
    274274    void        setPlayCountMin(int tmp_min) { m_playcountMin = tmp_min; }
    275275    void        setPlayCountMax(int tmp_max) { m_playcountMax = tmp_max; }
     
    348348    void        printTree();    // debugging
    349349    void        sortTree();
    350350    inline void clearTree() { m_root_node-> clear(); }
    351     void        writeTree(GenericTree *tree_to_write_to);
     351    void        writeTree(GenericTree *tree_to_write_to, bool skiproot = false);
    352352    void        setSorting(QString a_paths);
    353353    bool        putYourselfOnTheListView(TreeCheckItem *where);
    354354    void        putCDOnTheListView(CDCheckItem *where);