Ticket #3988: filters.diff

File filters.diff, 4.8 KB (added by herman@…, 17 years ago)
  • 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;
  • 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    MSqlQuery query(MSqlQuery::InitCon());
     1077
     1078    MSqlQuery subquery(MSqlQuery::InitCon());
     1079    subquery.prepare("SELECT smartplaylistid, name FROM music_smartplaylists "
     1080                     "WHERE categoryid = :CATEGORYID ORDER BY name;");
     1081
     1082    int a_counter = 1;
     1083    if (query.exec("SELECT categoryid, name FROM music_smartplaylist_categories ORDER BY name;"))
     1084    {
     1085        if (query.isActive() && query.numRowsAffected() > 0)
     1086        {
     1087            while (query.next())
     1088            {
     1089                sub_node = tree_to_write_to->addNode(QString::fromUtf8(query.value(1).toString()), a_counter++);
     1090
     1091                subquery.bindValue(":CATEGORYID", query.value(0));
     1092                if (subquery.exec())
     1093                {
     1094                    if (subquery.isActive() && subquery.numRowsAffected() > 0)
     1095                    {
     1096                        while (subquery.next())
     1097                        {
     1098                            Playlist *pl_playlist = new Playlist(all_available_music);
     1099
     1100                            pl_playlist->fillSonglistFromSmartPlaylist(query.value(1).toString(),
     1101                                            subquery.value(1).toString(), false, PL_FILTERONLY, 0);
     1102
     1103                            GenericTree *subsub_node =
     1104                                sub_node->addNode(QString::fromUtf8(subquery.value(1).toString()), 2);
     1105
     1106                            all_available_music->writeTree(subsub_node, true);
     1107
     1108                            delete pl_playlist;
     1109                        }
     1110                    }
     1111                }
     1112
     1113            }
     1114        }
     1115    }   
     1116
     1117    sub_node = tree_to_write_to->addNode(QObject::tr("All My Playlists"), a_counter);
    10751118    sub_node->setAttribute(0, 1);
    10761119    sub_node->setAttribute(1, 1);
    10771120    sub_node->setAttribute(2, 1);
     
    10851128
    10861129    active_playlist->writeTree(subsub_node, 0);
    10871130
    1088     int a_counter = 0; 
     1131    a_counter = 0; 
    10891132   
    10901133    //
    10911134    //  Write the CD playlist (if there's anything in it)
  • 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);