Index: metadata.cpp
===================================================================
--- metadata.cpp	(revision 14488)
+++ metadata.cpp	(working copy)
@@ -977,9 +977,9 @@
     delete builder;
 }
 
-void AllMusic::writeTree(GenericTree *tree_to_write_to)
+void AllMusic::writeTree(GenericTree *tree_to_write_to, bool skiproot)
 {
-    m_root_node->writeTree(tree_to_write_to, 0);
+    m_root_node->writeTree(tree_to_write_to, 0, !skiproot);
 }
 
 bool AllMusic::putYourselfOnTheListView(TreeCheckItem *where)
@@ -1265,14 +1265,21 @@
     
 }
 
-void MusicNode::writeTree(GenericTree *tree_to_write_to, int a_counter)
+void MusicNode::writeTree(GenericTree *tree_to_write_to, int a_counter, bool addself)
 {
     
-    GenericTree *sub_node = tree_to_write_to->addNode(my_title);
-    sub_node->setAttribute(0, 0);
-    sub_node->setAttribute(1, a_counter);
-    sub_node->setAttribute(2, rand());
-    sub_node->setAttribute(3, rand());
+    GenericTree *sub_node;
+
+    if(addself)
+    {
+        sub_node = tree_to_write_to->addNode(my_title);
+        sub_node->setAttribute(0, 0);
+        sub_node->setAttribute(1, a_counter);
+        sub_node->setAttribute(2, rand());
+        sub_node->setAttribute(3, rand());
+    }
+    else
+        sub_node = tree_to_write_to;
     
     QPtrListIterator<Metadata>  anit(my_tracks);
     Metadata *a_track;
Index: playlist.cpp
===================================================================
--- playlist.cpp	(revision 14488)
+++ playlist.cpp	(working copy)
@@ -1069,9 +1069,52 @@
 
 GenericTree* PlaylistsContainer::writeTree(GenericTree *tree_to_write_to)
 {
+    GenericTree *sub_node;
+
     all_available_music->writeTree(tree_to_write_to);
 
-    GenericTree *sub_node = tree_to_write_to->addNode(QObject::tr("All My Playlists"), 1);
+    MSqlQuery query(MSqlQuery::InitCon());
+
+    MSqlQuery subquery(MSqlQuery::InitCon());
+    subquery.prepare("SELECT smartplaylistid, name FROM music_smartplaylists "
+                     "WHERE categoryid = :CATEGORYID ORDER BY name;");
+
+    int a_counter = 1;
+    if (query.exec("SELECT categoryid, name FROM music_smartplaylist_categories ORDER BY name;"))
+    {
+        if (query.isActive() && query.numRowsAffected() > 0)
+        {
+            while (query.next())
+            {
+                sub_node = tree_to_write_to->addNode(QString::fromUtf8(query.value(1).toString()), a_counter++);
+
+                subquery.bindValue(":CATEGORYID", query.value(0));
+                if (subquery.exec())
+                {
+                    if (subquery.isActive() && subquery.numRowsAffected() > 0)
+                    {
+                        while (subquery.next())
+                        {
+                            Playlist *pl_playlist = new Playlist(all_available_music);
+
+                            pl_playlist->fillSonglistFromSmartPlaylist(query.value(1).toString(),
+                                            subquery.value(1).toString(), false, PL_FILTERONLY, 0);
+
+                            GenericTree *subsub_node = 
+                                sub_node->addNode(QString::fromUtf8(subquery.value(1).toString()), 2);
+
+                            all_available_music->writeTree(subsub_node, true);
+
+                            delete pl_playlist;
+                        }
+                    }
+                }
+
+            }
+        }
+    }    
+
+    sub_node = tree_to_write_to->addNode(QObject::tr("All My Playlists"), a_counter);
     sub_node->setAttribute(0, 1);
     sub_node->setAttribute(1, 1);
     sub_node->setAttribute(2, 1);
@@ -1085,7 +1128,7 @@
 
     active_playlist->writeTree(subsub_node, 0);
 
-    int a_counter = 0;  
+    a_counter = 0;  
     
     //
     //  Write the CD playlist (if there's anything in it)
Index: metadata.h
===================================================================
--- metadata.h	(revision 14488)
+++ metadata.h	(working copy)
@@ -269,7 +269,7 @@
     QString     getTitle(){return my_title;}
     void        printYourself(int indent_amount);   // debugging
     void        putYourselfOnTheListView(TreeCheckItem *parent, bool show_node);
-    void        writeTree(GenericTree *tree_to_write_to, int a_counter);
+    void        writeTree(GenericTree *tree_to_write_to, int a_counter, bool addself = true);
     void        sort();
     void        setPlayCountMin(int tmp_min) { m_playcountMin = tmp_min; }
     void        setPlayCountMax(int tmp_max) { m_playcountMax = tmp_max; }
@@ -348,7 +348,7 @@
     void        printTree();    // debugging
     void        sortTree();
     inline void clearTree() { m_root_node-> clear(); }
-    void        writeTree(GenericTree *tree_to_write_to);
+    void        writeTree(GenericTree *tree_to_write_to, bool skiproot = false);
     void        setSorting(QString a_paths);
     bool        putYourselfOnTheListView(TreeCheckItem *where);
     void        putCDOnTheListView(CDCheckItem *where);
