Move LibraryDirectoryModel out of LibraryModel.
There are several instances of the LibraryModel class used in the system. Each of these creates a LibraryDirectoryModel instance, but only the instance held by the main library is every used. Move this out of the LibraryModel class and into the Library class.
This commit is contained in:
parent
18a08e87c2
commit
bc99ff80a9
@ -287,7 +287,7 @@ LibraryBackend* Application::library_backend() const {
|
||||
}
|
||||
|
||||
LibraryDirectoryModel* Application::directory_model() const {
|
||||
return library()->model()->directory_model();
|
||||
return library()->directory_model();
|
||||
}
|
||||
|
||||
LibraryModel* Application::library_model() const { return library()->model(); }
|
||||
|
@ -17,14 +17,15 @@
|
||||
|
||||
#include "library.h"
|
||||
|
||||
#include "librarymodel.h"
|
||||
#include "librarybackend.h"
|
||||
#include "core/application.h"
|
||||
#include "core/database.h"
|
||||
#include "core/player.h"
|
||||
#include "core/tagreaderclient.h"
|
||||
#include "core/taskmanager.h"
|
||||
#include "core/thread.h"
|
||||
#include "librarybackend.h"
|
||||
#include "librarydirectorymodel.h"
|
||||
#include "librarymodel.h"
|
||||
#include "smartplaylists/generator.h"
|
||||
#include "smartplaylists/querygenerator.h"
|
||||
#include "smartplaylists/search.h"
|
||||
@ -56,6 +57,7 @@ Library::Library(Application* app, QObject* parent)
|
||||
using smart_playlists::SearchTerm;
|
||||
|
||||
model_ = new LibraryModel(backend_, app_, this);
|
||||
dir_model_ = new LibraryDirectoryModel(backend_.get(), this);
|
||||
model_->set_show_smart_playlists(true);
|
||||
model_->set_default_smart_playlists(
|
||||
LibraryModel::DefaultGenerators()
|
||||
|
@ -30,6 +30,7 @@ class Application;
|
||||
class Database;
|
||||
class LibraryBackend;
|
||||
class LibraryModel;
|
||||
class LibraryDirectoryModel;
|
||||
class LibraryWatcher;
|
||||
class TaskManager;
|
||||
class Thread;
|
||||
@ -50,6 +51,7 @@ class Library : public QObject {
|
||||
|
||||
LibraryBackend* backend() const { return backend_.get(); }
|
||||
LibraryModel* model() const { return model_; }
|
||||
LibraryDirectoryModel* directory_model() const { return dir_model_; }
|
||||
|
||||
QString full_rescan_reason(int schema_version) const {
|
||||
return full_rescan_revisions_.value(schema_version, QString());
|
||||
@ -80,6 +82,7 @@ class Library : public QObject {
|
||||
Application* app_;
|
||||
std::shared_ptr<LibraryBackend> backend_;
|
||||
LibraryModel* model_;
|
||||
LibraryDirectoryModel* dir_model_;
|
||||
|
||||
LibraryWatcher* watcher_;
|
||||
Thread* watcher_thread_;
|
||||
|
@ -33,7 +33,6 @@
|
||||
|
||||
#include "librarybackend.h"
|
||||
#include "libraryitem.h"
|
||||
#include "librarydirectorymodel.h"
|
||||
#include "libraryview.h"
|
||||
#include "sqlrow.h"
|
||||
#include "core/application.h"
|
||||
@ -79,7 +78,6 @@ LibraryModel::LibraryModel(std::shared_ptr<LibraryBackend> backend,
|
||||
: SimpleTreeModel<LibraryItem>(new LibraryItem(this), parent),
|
||||
backend_(backend),
|
||||
app_(app),
|
||||
dir_model_(new LibraryDirectoryModel(backend.get(), this)),
|
||||
show_smart_playlists_(false),
|
||||
show_various_artists_(true),
|
||||
total_song_count_(0),
|
||||
|
@ -38,7 +38,6 @@
|
||||
|
||||
class Application;
|
||||
class AlbumCoverLoader;
|
||||
class LibraryDirectoryModel;
|
||||
class LibraryBackend;
|
||||
namespace smart_playlists {
|
||||
class Search;
|
||||
@ -120,7 +119,6 @@ class LibraryModel : public SimpleTreeModel<LibraryItem> {
|
||||
};
|
||||
|
||||
LibraryBackend* backend() const { return backend_.get(); }
|
||||
LibraryDirectoryModel* directory_model() const { return dir_model_; }
|
||||
|
||||
typedef QList<smart_playlists::GeneratorPtr> GeneratorList;
|
||||
typedef QList<GeneratorList> DefaultGenerators;
|
||||
@ -263,7 +261,6 @@ signals:
|
||||
private:
|
||||
std::shared_ptr<LibraryBackend> backend_;
|
||||
Application* app_;
|
||||
LibraryDirectoryModel* dir_model_;
|
||||
bool show_smart_playlists_;
|
||||
DefaultGenerators default_smart_playlists_;
|
||||
bool show_various_artists_;
|
||||
|
Loading…
x
Reference in New Issue
Block a user