Rewrite collection model and search

Fixes #392
This commit is contained in:
Jonas Kvinge
2021-06-27 22:54:08 +02:00
parent ea1e4541c0
commit e477449cd4
52 changed files with 2321 additions and 2637 deletions

View File

@@ -40,7 +40,6 @@
#include <QJsonDocument>
#include <QJsonObject>
#include <QSettings>
#include <QSortFilterProxyModel>
#include "core/logging.h"
#include "core/shared_ptr.h"
@@ -52,6 +51,7 @@
#include "utilities/randutils.h"
#include "collection/collectionbackend.h"
#include "collection/collectionmodel.h"
#include "collection/collectionfilter.h"
#include "subsonicservice.h"
#include "subsonicurlhandler.h"
#include "subsonicrequest.h"
@@ -68,7 +68,6 @@ const char *SubsonicService::kApiVersion = "1.11.0";
namespace {
constexpr char kSongsTable[] = "subsonic_songs";
constexpr char kSongsFtsTable[] = "subsonic_songs_fts";
constexpr int kMaxRedirects = 3;
} // namespace
@@ -78,7 +77,6 @@ SubsonicService::SubsonicService(Application *app, QObject *parent)
url_handler_(new SubsonicUrlHandler(app, this)),
collection_backend_(nullptr),
collection_model_(nullptr),
collection_sort_model_(new QSortFilterProxyModel(this)),
http2_(false),
verify_certificate_(false),
download_album_covers_(true),
@@ -87,21 +85,10 @@ SubsonicService::SubsonicService(Application *app, QObject *parent)
app->player()->RegisterUrlHandler(url_handler_);
// Backend
collection_backend_ = make_shared<CollectionBackend>();
collection_backend_->moveToThread(app_->database()->thread());
collection_backend_->Init(app_->database(), app->task_manager(), Song::Source::Subsonic, QLatin1String(kSongsTable), QLatin1String(kSongsFtsTable));
// Model
collection_backend_->Init(app_->database(), app->task_manager(), Song::Source::Subsonic, QLatin1String(kSongsTable));
collection_model_ = new CollectionModel(collection_backend_, app_, this);
collection_sort_model_->setSourceModel(collection_model_);
collection_sort_model_->setSortRole(CollectionModel::Role_SortText);
collection_sort_model_->setDynamicSortFilter(true);
collection_sort_model_->setSortLocaleAware(true);
collection_sort_model_->sort(0);
SubsonicService::ReloadSettings();

View File

@@ -42,7 +42,6 @@
#include "internet/internetservice.h"
#include "settings/subsonicsettingspage.h"
class QSortFilterProxyModel;
class QNetworkReply;
class Application;
@@ -51,6 +50,7 @@ class SubsonicRequest;
class SubsonicScrobbleRequest;
class CollectionBackend;
class CollectionModel;
class CollectionFilter;
class SubsonicService : public InternetService {
Q_OBJECT
@@ -78,11 +78,11 @@ class SubsonicService : public InternetService {
SharedPtr<CollectionBackend> collection_backend() const { return collection_backend_; }
CollectionModel *collection_model() const { return collection_model_; }
QSortFilterProxyModel *collection_sort_model() const { return collection_sort_model_; }
CollectionFilter *collection_filter_model() const { return collection_model_->filter(); }
SharedPtr<CollectionBackend> songs_collection_backend() override { return collection_backend_; }
CollectionModel *songs_collection_model() override { return collection_model_; }
QSortFilterProxyModel *songs_collection_sort_model() override { return collection_sort_model_; }
CollectionFilter *songs_collection_filter_model() override { return collection_model_->filter(); }
void CheckConfiguration();
void Scrobble(const QString &song_id, const bool submission, const QDateTime &time);
@@ -109,7 +109,6 @@ class SubsonicService : public InternetService {
SharedPtr<CollectionBackend> collection_backend_;
CollectionModel *collection_model_;
QSortFilterProxyModel *collection_sort_model_;
SharedPtr<SubsonicRequest> songs_request_;
SharedPtr<SubsonicScrobbleRequest> scrobble_request_;