libsaria: Create a list of all tracks in a library
This list will eventually be used to fill in a gtk listview, but for now I gather all the information in one place.
This commit is contained in:
parent
170e700746
commit
6dfe4de57b
|
@ -1,10 +1,14 @@
|
|||
#ifndef LIBSARIA_LIBRARY_H
|
||||
#define LIBSARIA_LIBRARY_H
|
||||
|
||||
#include <libsaria/track.h>
|
||||
|
||||
#include <list>
|
||||
#include <string>
|
||||
using namespace std;
|
||||
|
||||
void libsaria_add_library(string);
|
||||
void libsaria_refresh_library();
|
||||
void libsaria_library_list(list<Track> &);
|
||||
|
||||
#endif /* LIBSARIA_LIBRARY_H */
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
#ifndef LIBSARIA_TRACK_H
|
||||
#define LIBSARIA_TRACK_H
|
||||
|
||||
#include <libsaria/tags.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
class Track
|
||||
{
|
||||
private:
|
||||
ino_t inode;
|
||||
TrackTag *tags;
|
||||
|
||||
public:
|
||||
Track(ino_t, TrackTag *);
|
||||
~Track();
|
||||
};
|
||||
|
||||
#endif /* LIBSARIA_TRACK_H */
|
|
@ -1,6 +1,10 @@
|
|||
|
||||
#include "library/library.h"
|
||||
#include <libsaria/callback.h>
|
||||
#include <libsaria/track.h>
|
||||
|
||||
#include <list>
|
||||
using namespace std;
|
||||
|
||||
static Library library;
|
||||
|
||||
|
@ -14,3 +18,8 @@ void libsaria_refresh_library()
|
|||
{
|
||||
trigger_callback(LIBRARY_REFRESH);
|
||||
}
|
||||
|
||||
void libsaria_library_list(list<Track> &track_list)
|
||||
{
|
||||
library.list_all(track_list);
|
||||
}
|
||||
|
|
|
@ -8,3 +8,10 @@ Library::Library()
|
|||
Library::~Library()
|
||||
{
|
||||
}
|
||||
|
||||
void Library::list_all(list<Track> &track_list)
|
||||
{
|
||||
map<string, LibraryPath>::iterator it;
|
||||
for (it = path_map.begin(); it != path_map.end(); it++)
|
||||
it->second.list_all(track_list);
|
||||
}
|
||||
|
|
|
@ -3,8 +3,10 @@
|
|||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <list>
|
||||
using namespace std;
|
||||
|
||||
#include <libsaria/track.h>
|
||||
#include "path.h"
|
||||
|
||||
class Library
|
||||
|
@ -18,6 +20,7 @@ class Library
|
|||
|
||||
void add_path(string);
|
||||
void update_path(string);
|
||||
void list_all(list<Track> &);
|
||||
};
|
||||
|
||||
#endif /* LIBSARIA_LIBRARY_SOURCE_H */
|
||||
|
|
|
@ -14,3 +14,11 @@ unsigned int LibraryPath::size()
|
|||
{
|
||||
return file_map.size();
|
||||
}
|
||||
|
||||
void LibraryPath::list_all(list<Track> &track_list)
|
||||
{
|
||||
map<ino_t, TrackTag>::iterator it;
|
||||
for (it = file_map.begin(); it != file_map.end(); it++) {
|
||||
track_list.push_back(Track(it->first, &it->second));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,12 +2,14 @@
|
|||
#define LIBSARIA_LIBRARY_PATH_H
|
||||
|
||||
#include <string>
|
||||
#include <list>
|
||||
#include <map>
|
||||
using namespace std;
|
||||
|
||||
#include <libsaria/path.h>
|
||||
#include <libsaria/idle.h>
|
||||
#include <libsaria/tags.h>
|
||||
#include <libsaria/track.h>
|
||||
|
||||
class LibraryPath
|
||||
{
|
||||
|
@ -22,6 +24,7 @@ class LibraryPath
|
|||
void update();
|
||||
void insert_track(ino_t, TrackTag &);
|
||||
unsigned int size();
|
||||
void list_all(list<Track> &track_list);
|
||||
};
|
||||
|
||||
class ScanTask : public IdleTask
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
|
||||
#include <libsaria/track.h>
|
||||
#include <libsaria/tags.h>
|
||||
|
||||
Track::Track(ino_t ino, TrackTag *tag)
|
||||
{
|
||||
inode = ino;
|
||||
tags = tag;
|
||||
}
|
||||
|
||||
Track::~Track()
|
||||
{
|
||||
}
|
Loading…
Reference in New Issue