summaryrefslogtreecommitdiff
path: root/playlist.c
diff options
context:
space:
mode:
authorGravatar Alexey Yakovenko <wakeroid@gmail.com>2010-02-15 22:48:20 +0100
committerGravatar Alexey Yakovenko <wakeroid@gmail.com>2010-02-18 18:39:18 +0100
commit707719656e6fc7c6e45f616f7e16cac424693013 (patch)
treed6fc4ea16139a193ff2f2bfd30563f3ba3ebb2db /playlist.c
parent8c48b540e031f2f7784f8317a0e87584505d16bd (diff)
playlist grouping WIP
Diffstat (limited to 'playlist.c')
-rw-r--r--playlist.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/playlist.c b/playlist.c
index 22e33a23..95530b00 100644
--- a/playlist.c
+++ b/playlist.c
@@ -2562,3 +2562,42 @@ pl_items_copy_junk (playItem_t *from, playItem_t *first, playItem_t *last) {
}
UNLOCK;
}
+
+void
+pl_group_by (const char *fmt) {
+ // remove all groupings
+ playItem_t *it;
+ it = playlist->head[PL_MAIN];
+ while (it) {
+ playItem_t *next = it->next[PL_MAIN];
+ if (it->is_group_title) {
+ pl_remove (it);
+ }
+ it = next;
+ }
+
+ // insert new
+ if (fmt) {
+ it = playlist->head[PL_MAIN];
+ char str[1024] = "--";
+ char curr[1024];
+ int idx = 0;
+ while (it) {
+ pl_format_title (it, -1, curr, sizeof (curr), -1, fmt);
+ if (strcmp (str, curr)) {
+ strcpy (str, curr);
+ playItem_t *grp = pl_item_alloc ();
+ grp->fname = strdup (str);
+ grp->is_group_title = 1;
+ it = pl_insert_item (it->prev[PL_MAIN], grp);
+ pl_item_unref (it);
+ }
+ it = it->next[PL_MAIN];
+ }
+ }
+}
+
+int
+pl_is_group_title (playItem_t *it) {
+ return it->is_group_title;
+}