diff --git a/core/library.cpp b/core/library.cpp index 6d1f75dc..4b9a7745 100644 --- a/core/library.cpp +++ b/core/library.cpp @@ -144,7 +144,7 @@ void library :: init() library_q.load(); for (it = db->begin(); it != db->end(); it = db->next(it)) { - if ((*it)->library->enabled) + if ((*it)->library->enabled()) library_q.add(*it); } } @@ -197,10 +197,10 @@ void library :: set_enabled(Library *library, bool enabled) Database::iterator it; Database *db = &(tagdb :: get_track_db()); - if (!library || (library->enabled == enabled)) + if (!library || (library->enabled() == enabled)) return; - library->enabled = enabled; + library->set_enabled(enabled); tagdb :: commit_library(); for (it = db->begin(); it != db->end(); it = db->next(it)) { diff --git a/core/tags/library.cpp b/core/tags/library.cpp index 4b06aaf9..add7392e 100644 --- a/core/tags/library.cpp +++ b/core/tags/library.cpp @@ -5,12 +5,12 @@ #include Library :: Library() - : count(0), enabled(false) + : _enabled(false), count(0) { } 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) { - f >> enabled; + f >> _enabled; _path = f.getline(); } 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; } diff --git a/include/core/tags/library.h b/include/core/tags/library.h index c8952963..39d6af65 100644 --- a/include/core/tags/library.h +++ b/include/core/tags/library.h @@ -12,13 +12,12 @@ */ class Library : public DatabaseEntry { 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: /** Number of tracks in this library */ unsigned int count; - /** True if the library is enabled, false otherwise */ - bool enabled; /** Library constructor */ Library(); @@ -46,6 +45,21 @@ public: * @param file The file to write to. */ 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 */ diff --git a/lib/colmgr.cpp b/lib/colmgr.cpp index 7c281c2c..c3318a3f 100644 --- a/lib/colmgr.cpp +++ b/lib/colmgr.cpp @@ -44,7 +44,7 @@ static void list_path(Library *lib) row = *(c_list->append()); 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_path] = lib->primary_key(); } diff --git a/tests/core/tags/library.cpp b/tests/core/tags/library.cpp index b1cb695f..8f2d44c5 100644 --- a/tests/core/tags/library.cpp +++ b/tests/core/tags/library.cpp @@ -12,7 +12,7 @@ static void test_library_tag() test_equal(library.primary_key(), (std::string)"/home/Zelda/Music"); test_equal(library.count, (unsigned)0); - test_equal(library.enabled, true); + test_equal(library.enabled(), true); library.count = 42; /* not saved to disk */ @@ -23,7 +23,7 @@ static void test_library_tag() library = Library(); test_equal(library.primary_key(), (std::string)""); test_equal(library.count, (unsigned)0); - test_equal(library.enabled, false); + test_equal(library.enabled(), false); f.open(OPEN_READ); 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.count, (unsigned)0); - test_equal(library.enabled, true); + test_equal(library.enabled(), true); } int main(int argc, char **argv) diff --git a/tests/lib/colmgr.cpp b/tests/lib/colmgr.cpp index c206486b..c4b6f205 100644 --- a/tests/lib/colmgr.cpp +++ b/tests/lib/colmgr.cpp @@ -44,9 +44,9 @@ void test_colmgr() test_equal(colmgr :: get_path(path), Glib::ustring("/tmp/ocarina/")); library = tagdb :: lookup_library(1); - test_equal(library->enabled, true); + test_equal(library->enabled(), true); colmgr :: toggle_path_enabled(path); - test_equal(library->enabled, false); + test_equal(library->enabled(), false); colmgr :: update_path(path); test_equal(idle :: run_task(), true); @@ -62,15 +62,15 @@ void test_colmgr() path = Gtk::TreePath(row); library = tagdb :: lookup_library(0); - test_equal(library->enabled, true); + test_equal(library->enabled(), true); test_equal(library :: get_queue()->size(), (unsigned)20); colmgr :: toggle_path_enabled(path); - test_equal(library->enabled, false); + test_equal(library->enabled(), false); test_equal(library :: get_queue()->size(), (unsigned)0); colmgr :: toggle_path_enabled(path); - test_equal(library->enabled, true); + test_equal(library->enabled(), true); test_equal(library :: get_queue()->size(), (unsigned)20); }