Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
jonaski committed Oct 31, 2024
1 parent dfcf715 commit a527575
Show file tree
Hide file tree
Showing 612 changed files with 8,694 additions and 4,865 deletions.
148 changes: 92 additions & 56 deletions CMakeLists.txt

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/analyzer/analyzerbase.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
#include <QString>
#include <QPainter>

#include "core/shared_ptr.h"
#include "includes/shared_ptr.h"
#include "analyzer/fht.h"
#include "engine/enginebase.h"

Expand Down
2 changes: 1 addition & 1 deletion src/analyzer/analyzercontainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@
#include "waverubberanalyzer.h"
#include "rainbowanalyzer.h"

#include "includes/shared_ptr.h"
#include "core/logging.h"
#include "core/shared_ptr.h"
#include "core/settings.h"
#include "engine/enginebase.h"

Expand Down
2 changes: 1 addition & 1 deletion src/analyzer/analyzercontainer.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#include <QAction>
#include <QActionGroup>

#include "core/shared_ptr.h"
#include "includes/shared_ptr.h"
#include "engine/enginebase.h"

class QTimer;
Expand Down
25 changes: 6 additions & 19 deletions src/collection/collectionbackend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,11 @@
#include <QSqlQuery>
#include <QSqlError>

#include "core/shared_ptr.h"
#include "includes/shared_ptr.h"
#include "core/logging.h"
#include "core/database.h"
#include "core/scopedtransaction.h"
#include "core/song.h"
#include "core/sqlrow.h"
#include "smartplaylists/smartplaylistsearch.h"

#include "collectiondirectory.h"
#include "collectionbackend.h"
Expand Down Expand Up @@ -1932,37 +1930,26 @@ void CollectionBackend::DeleteAll() {

}

SongList CollectionBackend::SmartPlaylistsFindSongs(const SmartPlaylistSearch &search) {
SongList CollectionBackend::ExecuteQuery(const QString &sql) {

QMutexLocker l(db_->Mutex());
QSqlDatabase db(db_->Connect());

// Build the query
QString sql = search.ToSql(songs_table());

// Run the query
SongList ret;
SqlQuery query(db);
query.prepare(sql);
if (!query.Exec()) {
db_->ReportErrors(query);
return ret;
return SongList();
}

// Read the results
SongList songs;
while (query.next()) {
Song song;
song.InitFromQuery(query, true);
ret << song;
songs << song;
}
return ret;

}

SongList CollectionBackend::SmartPlaylistsGetAllSongs() {

// Get all the songs!
return SmartPlaylistsFindSongs(SmartPlaylistSearch(SmartPlaylistSearch::SearchType::All, SmartPlaylistSearch::TermList(), SmartPlaylistSearch::SortType::FieldAsc, SmartPlaylistSearchTerm::Field::Artist, -1));
return songs;

}

Expand Down
6 changes: 2 additions & 4 deletions src/collection/collectionbackend.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
#include <QUrl>
#include <QSqlDatabase>

#include "core/shared_ptr.h"
#include "includes/shared_ptr.h"
#include "core/song.h"
#include "collectionfilteroptions.h"
#include "collectionquery.h"
Expand All @@ -45,7 +45,6 @@
class QThread;
class TaskManager;
class Database;
class SmartPlaylistSearch;

class CollectionBackendInterface : public QObject {
Q_OBJECT
Expand Down Expand Up @@ -227,8 +226,7 @@ class CollectionBackend : public CollectionBackendInterface {

SongList GetSongsByFingerprint(const QString &fingerprint) override;

SongList SmartPlaylistsGetAllSongs();
SongList SmartPlaylistsFindSongs(const SmartPlaylistSearch &search);
SongList ExecuteQuery(const QString &sql);

void AddOrUpdateSongsAsync(const SongList &songs);
void UpdateSongsBySongIDAsync(const SongMap &new_songs);
Expand Down
2 changes: 1 addition & 1 deletion src/collection/collectiondirectorymodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#include <QVariant>
#include <QString>

#include "core/shared_ptr.h"
#include "includes/shared_ptr.h"
#include "core/filesystemmusicstorage.h"
#include "core/iconloader.h"
#include "core/musicstorage.h"
Expand Down
2 changes: 1 addition & 1 deletion src/collection/collectiondirectorymodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#include <QStringList>
#include <QIcon>

#include "core/shared_ptr.h"
#include "includes/shared_ptr.h"
#include "collectiondirectory.h"

class QModelIndex;
Expand Down
5 changes: 2 additions & 3 deletions src/collection/collectionfilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,9 @@
#include <QUrl>

#include "core/song.h"
#include "core/songmimedata.h"
#include "filterparser/filterparser.h"
#include "filterparser/filtertree.h"
#include "playlist/songmimedata.h"
#include "playlist/playlistmanager.h"
#include "collectionbackend.h"
#include "collectionfilter.h"
#include "collectionmodel.h"
Expand Down Expand Up @@ -95,7 +94,7 @@ QMimeData *CollectionFilter::mimeData(const QModelIndexList &indexes) const {
}

data->setUrls(urls);
data->name_for_new_playlist_ = PlaylistManager::GetNameForNewPlaylist(data->songs);
data->name_for_new_playlist_ = Song::GetNameForNewPlaylist(data->songs);

return data;

Expand Down
10 changes: 5 additions & 5 deletions src/collection/collectionfilterwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@
#include "groupbydialog.h"
#include "ui_collectionfilterwidget.h"
#include "widgets/searchfield.h"
#include "settings/collectionsettingspage.h"
#include "settings/appearancesettingspage.h"
#include "constants/collectionsettings.h"
#include "constants/appearancesettings.h"

using namespace Qt::Literals::StringLiterals;

Expand Down Expand Up @@ -204,8 +204,8 @@ void CollectionFilterWidget::setFilter(CollectionFilter *filter) {
void CollectionFilterWidget::ReloadSettings() {

Settings s;
s.beginGroup(AppearanceSettingsPage::kSettingsGroup);
int iconsize = s.value(AppearanceSettingsPage::kIconSizeConfigureButtons, 20).toInt();
s.beginGroup(AppearanceSettings::kSettingsGroup);
int iconsize = s.value(AppearanceSettings::kIconSizeConfigureButtons, 20).toInt();
s.endGroup();
ui_->options->setIconSize(QSize(iconsize, iconsize));
ui_->search_field->setIconSize(iconsize);
Expand Down Expand Up @@ -345,7 +345,7 @@ void CollectionFilterWidget::SaveGroupBy() {
qLog(Debug) << "Saving current grouping to" << name;

Settings s;
if (settings_group_.isEmpty() || settings_group_ == QLatin1String(CollectionSettingsPage::kSettingsGroup)) {
if (settings_group_.isEmpty() || settings_group_ == QLatin1String(CollectionSettings::kSettingsGroup)) {
s.beginGroup(SavedGroupingManager::kSavedGroupingsSettingsGroup);
}
else {
Expand Down
32 changes: 32 additions & 0 deletions src/collection/collectionitem.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Strawberry Music Player
* Copyright 2018-2024, Jonas Kvinge <[email protected]>
*
* Strawberry is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Strawberry is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
*
*/

#include "collectionitem.h"

CollectionItem::CollectionItem(SimpleTreeModel<CollectionItem> *_model)
: SimpleTreeItem<CollectionItem>(_model),
type(Type::Root),
container_level(-1),
compilation_artist_node_(nullptr) {}

CollectionItem::CollectionItem(const Type _type, CollectionItem *_parent)
: SimpleTreeItem<CollectionItem>(_parent),
type(_type),
container_level(-1),
compilation_artist_node_(nullptr) {}
19 changes: 3 additions & 16 deletions src/collection/collectionitem.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
/*
* Strawberry Music Player
* This file was part of Clementine.
* Copyright 2010, David Sansome <[email protected]>
* Copyright 2018-2021, Jonas Kvinge <[email protected]>
* Copyright 2018-2024, Jonas Kvinge <[email protected]>
*
* Strawberry is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand All @@ -22,8 +20,6 @@
#ifndef COLLECTIONITEM_H
#define COLLECTIONITEM_H

#include "config.h"

#include "core/simpletreeitem.h"
#include "core/song.h"

Expand All @@ -37,17 +33,8 @@ class CollectionItem : public SimpleTreeItem<CollectionItem> {
LoadingIndicator,
};

explicit CollectionItem(SimpleTreeModel<CollectionItem> *_model)
: SimpleTreeItem<CollectionItem>(_model),
type(Type::Root),
container_level(-1),
compilation_artist_node_(nullptr) {}

explicit CollectionItem(const Type _type, CollectionItem *_parent = nullptr)
: SimpleTreeItem<CollectionItem>(_parent),
type(_type),
container_level(-1),
compilation_artist_node_(nullptr) {}
explicit CollectionItem(SimpleTreeModel<CollectionItem> *_model);
explicit CollectionItem(const Type _type, CollectionItem *_parent = nullptr);

Type type;
int container_level;
Expand Down
Loading

0 comments on commit a527575

Please sign in to comment.