Library: Make _enabled private
I added in accessor functions to get and set this value. Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
01e514736e
commit
754d45efd0
|
@ -144,7 +144,7 @@ void library :: init()
|
||||||
library_q.load();
|
library_q.load();
|
||||||
|
|
||||||
for (it = db->begin(); it != db->end(); it = db->next(it)) {
|
for (it = db->begin(); it != db->end(); it = db->next(it)) {
|
||||||
if ((*it)->library->enabled)
|
if ((*it)->library->enabled())
|
||||||
library_q.add(*it);
|
library_q.add(*it);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -197,10 +197,10 @@ void library :: set_enabled(Library *library, bool enabled)
|
||||||
Database<Track>::iterator it;
|
Database<Track>::iterator it;
|
||||||
Database<Track> *db = &(tagdb :: get_track_db());
|
Database<Track> *db = &(tagdb :: get_track_db());
|
||||||
|
|
||||||
if (!library || (library->enabled == enabled))
|
if (!library || (library->enabled() == enabled))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
library->enabled = enabled;
|
library->set_enabled(enabled);
|
||||||
tagdb :: commit_library();
|
tagdb :: commit_library();
|
||||||
|
|
||||||
for (it = db->begin(); it != db->end(); it = db->next(it)) {
|
for (it = db->begin(); it != db->end(); it = db->next(it)) {
|
||||||
|
|
|
@ -5,12 +5,12 @@
|
||||||
#include <core/tags/library.h>
|
#include <core/tags/library.h>
|
||||||
|
|
||||||
Library :: Library()
|
Library :: Library()
|
||||||
: count(0), enabled(false)
|
: _enabled(false), count(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Library :: Library(const std::string &s)
|
Library :: Library(const std::string &s)
|
||||||
: _path(s), count(0), enabled(true)
|
: _path(s), _enabled(true), count(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,11 +21,21 @@ const std::string Library :: primary_key() const
|
||||||
|
|
||||||
void Library :: read(File &f)
|
void Library :: read(File &f)
|
||||||
{
|
{
|
||||||
f >> enabled;
|
f >> _enabled;
|
||||||
_path = f.getline();
|
_path = f.getline();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Library :: write(File &f)
|
void Library :: write(File &f)
|
||||||
{
|
{
|
||||||
f << enabled << " " << _path;
|
f << _enabled << " " << _path;
|
||||||
|
}
|
||||||
|
|
||||||
|
const bool Library :: enabled()
|
||||||
|
{
|
||||||
|
return _enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Library :: set_enabled(bool enabled)
|
||||||
|
{
|
||||||
|
_enabled = enabled;
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,13 +12,12 @@
|
||||||
*/
|
*/
|
||||||
class Library : public DatabaseEntry {
|
class Library : public DatabaseEntry {
|
||||||
private:
|
private:
|
||||||
std::string _path; /**< Path to the root directory of this library. */
|
std::string _path; /**< Path to the root directory of this library. */
|
||||||
|
bool _enabled; /**< Is this library path enabled? */
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/** Number of tracks in this library */
|
/** Number of tracks in this library */
|
||||||
unsigned int count;
|
unsigned int count;
|
||||||
/** True if the library is enabled, false otherwise */
|
|
||||||
bool enabled;
|
|
||||||
|
|
||||||
/** Library constructor */
|
/** Library constructor */
|
||||||
Library();
|
Library();
|
||||||
|
@ -46,6 +45,21 @@ public:
|
||||||
* @param file The file to write to.
|
* @param file The file to write to.
|
||||||
*/
|
*/
|
||||||
void write(File &);
|
void write(File &);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called to check if this library path is currently enabled.
|
||||||
|
*
|
||||||
|
* @return Library::_enabled.
|
||||||
|
*/
|
||||||
|
const bool enabled();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called to set if this library path is enabled.
|
||||||
|
*
|
||||||
|
* @param enabled True if this path should be enabled, false otherwise.
|
||||||
|
*/
|
||||||
|
void set_enabled(bool);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* OCARINA_CORE_TAGS_LIBRARY_H */
|
#endif /* OCARINA_CORE_TAGS_LIBRARY_H */
|
||||||
|
|
|
@ -44,7 +44,7 @@ static void list_path(Library *lib)
|
||||||
row = *(c_list->append());
|
row = *(c_list->append());
|
||||||
|
|
||||||
row[c_cols.c_id] = lib->index();
|
row[c_cols.c_id] = lib->index();
|
||||||
row[c_cols.c_enabled] = lib->enabled;
|
row[c_cols.c_enabled] = lib->enabled();
|
||||||
row[c_cols.c_size] = lib->count;
|
row[c_cols.c_size] = lib->count;
|
||||||
row[c_cols.c_path] = lib->primary_key();
|
row[c_cols.c_path] = lib->primary_key();
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ static void test_library_tag()
|
||||||
|
|
||||||
test_equal(library.primary_key(), (std::string)"/home/Zelda/Music");
|
test_equal(library.primary_key(), (std::string)"/home/Zelda/Music");
|
||||||
test_equal(library.count, (unsigned)0);
|
test_equal(library.count, (unsigned)0);
|
||||||
test_equal(library.enabled, true);
|
test_equal(library.enabled(), true);
|
||||||
|
|
||||||
library.count = 42; /* not saved to disk */
|
library.count = 42; /* not saved to disk */
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ static void test_library_tag()
|
||||||
library = Library();
|
library = Library();
|
||||||
test_equal(library.primary_key(), (std::string)"");
|
test_equal(library.primary_key(), (std::string)"");
|
||||||
test_equal(library.count, (unsigned)0);
|
test_equal(library.count, (unsigned)0);
|
||||||
test_equal(library.enabled, false);
|
test_equal(library.enabled(), false);
|
||||||
|
|
||||||
f.open(OPEN_READ);
|
f.open(OPEN_READ);
|
||||||
library.read(f);
|
library.read(f);
|
||||||
|
@ -31,7 +31,7 @@ static void test_library_tag()
|
||||||
|
|
||||||
test_equal(library.primary_key(), (std::string)"/home/Zelda/Music");
|
test_equal(library.primary_key(), (std::string)"/home/Zelda/Music");
|
||||||
test_equal(library.count, (unsigned)0);
|
test_equal(library.count, (unsigned)0);
|
||||||
test_equal(library.enabled, true);
|
test_equal(library.enabled(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
|
|
|
@ -44,9 +44,9 @@ void test_colmgr()
|
||||||
test_equal(colmgr :: get_path(path), Glib::ustring("/tmp/ocarina/"));
|
test_equal(colmgr :: get_path(path), Glib::ustring("/tmp/ocarina/"));
|
||||||
|
|
||||||
library = tagdb :: lookup_library(1);
|
library = tagdb :: lookup_library(1);
|
||||||
test_equal(library->enabled, true);
|
test_equal(library->enabled(), true);
|
||||||
colmgr :: toggle_path_enabled(path);
|
colmgr :: toggle_path_enabled(path);
|
||||||
test_equal(library->enabled, false);
|
test_equal(library->enabled(), false);
|
||||||
|
|
||||||
colmgr :: update_path(path);
|
colmgr :: update_path(path);
|
||||||
test_equal(idle :: run_task(), true);
|
test_equal(idle :: run_task(), true);
|
||||||
|
@ -62,15 +62,15 @@ void test_colmgr()
|
||||||
path = Gtk::TreePath(row);
|
path = Gtk::TreePath(row);
|
||||||
library = tagdb :: lookup_library(0);
|
library = tagdb :: lookup_library(0);
|
||||||
|
|
||||||
test_equal(library->enabled, true);
|
test_equal(library->enabled(), true);
|
||||||
test_equal(library :: get_queue()->size(), (unsigned)20);
|
test_equal(library :: get_queue()->size(), (unsigned)20);
|
||||||
|
|
||||||
colmgr :: toggle_path_enabled(path);
|
colmgr :: toggle_path_enabled(path);
|
||||||
test_equal(library->enabled, false);
|
test_equal(library->enabled(), false);
|
||||||
test_equal(library :: get_queue()->size(), (unsigned)0);
|
test_equal(library :: get_queue()->size(), (unsigned)0);
|
||||||
|
|
||||||
colmgr :: toggle_path_enabled(path);
|
colmgr :: toggle_path_enabled(path);
|
||||||
test_equal(library->enabled, true);
|
test_equal(library->enabled(), true);
|
||||||
test_equal(library :: get_queue()->size(), (unsigned)20);
|
test_equal(library :: get_queue()->size(), (unsigned)20);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue