Add cpp files for classes with only header files

This commit is contained in:
Jonas Kvinge 2024-08-12 00:48:16 +02:00
parent 1ebcd61a75
commit f624b7a331
19 changed files with 317 additions and 47 deletions

View File

@ -41,6 +41,8 @@ set(SOURCES
core/translations.cpp
core/systemtrayicon.cpp
core/localredirectserver.cpp
core/mimedata.cpp
core/potranslator.cpp
utilities/strutils.cpp
utilities/envutils.cpp
utilities/colorutils.cpp
@ -110,8 +112,10 @@ set(SOURCES
playlist/playlistfilter.cpp
playlist/playlistheader.cpp
playlist/playlistitem.cpp
playlist/playlistitemmimedata.cpp
playlist/playlistlistcontainer.cpp
playlist/playlistlistmodel.cpp
playlist/playlistlistsortfiltermodel.cpp
playlist/playlistlistview.cpp
playlist/playlistmanager.cpp
playlist/playlistsaveoptionsdialog.cpp
@ -120,6 +124,7 @@ set(SOURCES
playlist/playlistundocommands.cpp
playlist/playlistview.cpp
playlist/playlistproxystyle.cpp
playlist/songmimedata.cpp
playlist/songloaderinserter.cpp
playlist/songplaylistitem.cpp
playlist/dynamicplaylistcontrols.cpp
@ -140,6 +145,7 @@ set(SOURCES
smartplaylists/playlistgenerator.cpp
smartplaylists/playlistgeneratorinserter.cpp
smartplaylists/playlistgeneratormimedata.cpp
smartplaylists/playlistquerygenerator.cpp
smartplaylists/smartplaylistquerywizardplugin.cpp
smartplaylists/smartplaylistsearch.cpp
@ -270,6 +276,7 @@ set(SOURCES
streaming/streamingcollectionview.cpp
streaming/streamingcollectionviewcontainer.cpp
streaming/streamingsearchview.cpp
streaming/streamsongmimedata.cpp
radios/radioservices.cpp
radios/radiobackend.cpp
@ -281,6 +288,7 @@ set(SOURCES
radios/radiochannel.cpp
radios/somafmservice.cpp
radios/radioparadiseservice.cpp
radios/radiomimedata.cpp
scrobbler/audioscrobbler.cpp
scrobbler/scrobblersettings.cpp
@ -764,6 +772,7 @@ optional_source(HAVE_LIBPULSE SOURCES engine/pulsedevicefinder.cpp)
optional_source(HAVE_GSTREAMER
SOURCES
transcoder/transcoder.cpp
transcoder/transcoderoptionsinterface.cpp
transcoder/transcodedialog.cpp
transcoder/transcoderoptionsdialog.cpp
transcoder/transcoderoptionsflac.cpp

44
src/core/mimedata.cpp Normal file
View File

@ -0,0 +1,44 @@
/*
* Strawberry Music Player
* This file was part of Clementine.
* Copyright 2010, David Sansome <me@davidsansome.com>
* Copyright 2018-2024, Jonas Kvinge <jonas@jkvinge.net>
*
* 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 "config.h"
#include <QString>
#include "mimedata.h"
MimeData::MimeData(const bool clear, const bool play_now, const bool enqueue, const bool enqueue_next_now, const bool open_in_new_playlist, QObject *parent)
: override_user_settings_(false),
clear_first_(clear),
play_now_(play_now),
enqueue_now_(enqueue),
enqueue_next_now_(enqueue_next_now),
open_in_new_playlist_(open_in_new_playlist),
name_for_new_playlist_(QString()),
from_doubleclick_(false) {
Q_UNUSED(parent);
}
QString MimeData::get_name_for_new_playlist() const {
return name_for_new_playlist_.isEmpty() ? tr("Playlist") : name_for_new_playlist_;
}

View File

@ -2,6 +2,7 @@
* Strawberry Music Player
* This file was part of Clementine.
* Copyright 2010, David Sansome <me@davidsansome.com>
* Copyright 2018-2024, Jonas Kvinge <jonas@jkvinge.net>
*
* Strawberry is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -21,9 +22,6 @@
#ifndef MIMEDATA_H
#define MIMEDATA_H
#include "config.h"
#include <QObject>
#include <QMimeData>
#include <QString>
@ -31,15 +29,7 @@ class MimeData : public QMimeData {
Q_OBJECT
public:
explicit MimeData(const bool clear = false, const bool play_now = false, const bool enqueue = false, const bool enqueue_next_now = false, const bool open_in_new_playlist = false, QObject* = nullptr)
: override_user_settings_(false),
clear_first_(clear),
play_now_(play_now),
enqueue_now_(enqueue),
enqueue_next_now_(enqueue_next_now),
open_in_new_playlist_(open_in_new_playlist),
name_for_new_playlist_(QString()),
from_doubleclick_(false) {}
explicit MimeData(const bool clear = false, const bool play_now = false, const bool enqueue = false, const bool enqueue_next_now = false, const bool open_in_new_playlist = false, QObject *parent = nullptr);
// If this is set then MainWindow will not touch any of the other flags.
bool override_user_settings_;
@ -69,9 +59,7 @@ class MimeData : public QMimeData {
// Returns a pretty name for a playlist containing songs described by this MimeData object.
// By pretty name we mean the value of 'name_for_new_playlist_' or generic "Playlist" string if the 'name_for_new_playlist_' attribute is empty.
QString get_name_for_new_playlist() {
return name_for_new_playlist_.isEmpty() ? tr("Playlist") : name_for_new_playlist_;
}
QString get_name_for_new_playlist() const;
};
#endif // MIMEDATA_H

34
src/core/potranslator.cpp Normal file
View File

@ -0,0 +1,34 @@
/*
* Strawberry Music Player
* This file was part of Clementine.
* Copyright 2010, David Sansome <me@davidsansome.com>
* Copyright 2018-2024, Jonas Kvinge <jonas@jkvinge.net>
*
* 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 <QString>
#include "potranslator.h"
PoTranslator::PoTranslator(QObject *parent) : QTranslator(parent) {}
QString PoTranslator::translate(const char *context, const char *source_text, const char *disambiguation, const int n) const {
QString ret = QTranslator::translate(context, source_text, disambiguation, n);
if (!ret.isEmpty()) return ret;
return QTranslator::translate(nullptr, source_text, disambiguation, n);
}

View File

@ -2,6 +2,7 @@
* Strawberry Music Player
* This file was part of Clementine.
* Copyright 2010, David Sansome <me@davidsansome.com>
* Copyright 2018-2024, Jonas Kvinge <jonas@jkvinge.net>
*
* Strawberry is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -22,6 +23,7 @@
#define POTRANSLATOR_H
#include <QTranslator>
#include <QString>
// We convert from .po files to .qm files, which loses context information.
// This translator tries loading strings with an empty context if it can't find any others.
@ -30,12 +32,8 @@ class PoTranslator : public QTranslator {
Q_OBJECT
public:
PoTranslator(QObject *parent = nullptr) : QTranslator(parent) {}
QString translate(const char *context, const char *source_text, const char *disambiguation = nullptr, int n = -1) const override {
QString ret = QTranslator::translate(context, source_text, disambiguation, n);
if (!ret.isEmpty()) return ret;
return QTranslator::translate(nullptr, source_text, disambiguation, n);
}
explicit PoTranslator(QObject *parent = nullptr);
QString translate(const char *context, const char *source_text, const char *disambiguation = nullptr, int n = -1) const override;
};
#endif // POTRANSLATOR_H

View File

@ -0,0 +1,37 @@
/*
* Strawberry Music Player
* This file was part of Clementine.
* Copyright 2010, David Sansome <me@davidsansome.com>
* Copyright 2018-2024, Jonas Kvinge <jonas@jkvinge.net>
*
* 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 "playlistitemmimedata.h"
#include "playlistitem.h"
PlaylistItemMimeData::PlaylistItemMimeData(const PlaylistItemPtr &item, QObject *parent)
: items_(PlaylistItemPtrList() << item) {
Q_UNUSED(parent);
}
PlaylistItemMimeData::PlaylistItemMimeData(const PlaylistItemPtrList &items, QObject *parent)
: items_(items) {
Q_UNUSED(parent);
}

View File

@ -2,6 +2,7 @@
* Strawberry Music Player
* This file was part of Clementine.
* Copyright 2010, David Sansome <me@davidsansome.com>
* Copyright 2018-2024, Jonas Kvinge <jonas@jkvinge.net>
*
* Strawberry is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -32,8 +33,8 @@ class PlaylistItemMimeData : public MimeData {
Q_OBJECT
public:
explicit PlaylistItemMimeData(const PlaylistItemPtr &item, QObject* = nullptr) : MimeData(), items_(PlaylistItemPtrList() << item) {}
explicit PlaylistItemMimeData(const PlaylistItemPtrList &items, QObject* = nullptr) : MimeData(), items_(items) {}
explicit PlaylistItemMimeData(const PlaylistItemPtr &item, QObject *parent = nullptr);
explicit PlaylistItemMimeData(const PlaylistItemPtrList &items, QObject *parent = nullptr);
PlaylistItemPtrList items_;
};

View File

@ -0,0 +1,36 @@
/*
* Strawberry Music Player
* This file was part of Clementine.
* Copyright 2010, David Sansome <me@davidsansome.com>
* Copyright 2018-2024, Jonas Kvinge <jonas@jkvinge.net>
*
* 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 "playlistlistsortfiltermodel.h"
PlaylistListSortFilterModel::PlaylistListSortFilterModel(QObject *parent)
: QSortFilterProxyModel(parent) {}
bool PlaylistListSortFilterModel::lessThan(const QModelIndex &left, const QModelIndex &right) const {
// Compare the display text first.
const int ret = left.data().toString().localeAwareCompare(right.data().toString());
if (ret < 0) return true;
if (ret > 0) return false;
// Now use the source model row order to ensure we always get a deterministic sorting even when two items are named the same.
return left.row() < right.row();
}

View File

@ -2,7 +2,7 @@
* Strawberry Music Player
* This file was part of Clementine.
* Copyright 2010, David Sansome <me@davidsansome.com>
* Copyright 2018-2021, Jonas Kvinge <jonas@jkvinge.net>
* Copyright 2018-2024, Jonas Kvinge <jonas@jkvinge.net>
*
* Strawberry is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -28,18 +28,9 @@ class PlaylistListSortFilterModel : public QSortFilterProxyModel {
Q_OBJECT
public:
explicit PlaylistListSortFilterModel(QObject *parent)
: QSortFilterProxyModel(parent) {}
explicit PlaylistListSortFilterModel(QObject *parent);
bool lessThan(const QModelIndex &left, const QModelIndex &right) const override {
// Compare the display text first.
const int ret = left.data().toString().localeAwareCompare(right.data().toString());
if (ret < 0) return true;
if (ret > 0) return false;
// Now use the source model row order to ensure we always get a deterministic sorting even when two items are named the same.
return left.row() < right.row();
}
bool lessThan(const QModelIndex &left, const QModelIndex &right) const override;
};
#endif // PLAYLISTLISTSORTFILTERMODEL_H

View File

@ -0,0 +1,26 @@
/*
* Strawberry Music Player
* This file was part of Clementine.
* Copyright 2010, David Sansome <me@davidsansome.com>
* Copyright 2018-2024, Jonas Kvinge <jonas@jkvinge.net>
*
* 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 "songmimedata.h"
SongMimeData::SongMimeData(QObject *parent) : backend(nullptr) {
Q_UNUSED(parent);
}

View File

@ -2,6 +2,7 @@
* Strawberry Music Player
* This file was part of Clementine.
* Copyright 2010, David Sansome <me@davidsansome.com>
* Copyright 2018-2024, Jonas Kvinge <jonas@jkvinge.net>
*
* Strawberry is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -23,9 +24,6 @@
#include "config.h"
#include <QObject>
#include <QMimeData>
#include "core/shared_ptr.h"
#include "core/mimedata.h"
#include "core/song.h"
@ -36,7 +34,7 @@ class SongMimeData : public MimeData {
Q_OBJECT
public:
explicit SongMimeData(QObject* = nullptr) : MimeData(), backend(nullptr) {}
explicit SongMimeData(QObject *parent = nullptr);
SharedPtr<CollectionBackendInterface> backend;
SongList songs;

View File

@ -0,0 +1,26 @@
/*
* Strawberry Music Player
* Copyright 2021, Jonas Kvinge <jonas@jkvinge.net>
*
* 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 "radiomimedata.h"
RadioMimeData::RadioMimeData(QObject *parent) {
Q_UNUSED(parent);
}

View File

@ -29,7 +29,7 @@ class RadioMimeData : public MimeData {
Q_OBJECT
public:
explicit RadioMimeData(QObject* = nullptr) {}
explicit RadioMimeData(QObject *parent = nullptr);
SongList songs;
};

View File

@ -0,0 +1,29 @@
/*
* Strawberry Music Player
* This file was part of Clementine.
* Copyright 2010, David Sansome <me@davidsansome.com>
*
* 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 "playlistgeneratormimedata.h"
#include "playlistgenerator_fwd.h"
PlaylistGeneratorMimeData::PlaylistGeneratorMimeData(PlaylistGeneratorPtr generator, QObject *parent)
: generator_(generator) {
Q_UNUSED(parent);
}

View File

@ -23,9 +23,6 @@
#include "config.h"
#include <QObject>
#include <QMimeData>
#include "core/mimedata.h"
#include "playlistgenerator_fwd.h"
@ -33,7 +30,7 @@ class PlaylistGeneratorMimeData : public MimeData {
Q_OBJECT
public:
PlaylistGeneratorMimeData(PlaylistGeneratorPtr generator, QObject* = nullptr) : generator_(generator) {}
PlaylistGeneratorMimeData(PlaylistGeneratorPtr generator, QObject *parent = nullptr);
PlaylistGeneratorPtr generator_;
};

View File

@ -0,0 +1,27 @@
/*
* Strawberry Music Player
* This file was part of Clementine.
* Copyright 2011, David Sansome <me@davidsansome.com>
* Copyright 2018-2024, Jonas Kvinge <jonas@jkvinge.net>
*
* 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 "core/shared_ptr.h"
#include "streamsongmimedata.h"
StreamSongMimeData::StreamSongMimeData(SharedPtr<StreamingService> _service, QObject *parent) : service(_service) {
Q_UNUSED(parent);
}

View File

@ -2,6 +2,7 @@
* Strawberry Music Player
* This file was part of Clementine.
* Copyright 2011, David Sansome <me@davidsansome.com>
* Copyright 2018-2024, Jonas Kvinge <jonas@jkvinge.net>
*
* Strawberry is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -31,7 +32,7 @@ class StreamSongMimeData : public MimeData {
Q_OBJECT
public:
explicit StreamSongMimeData(SharedPtr<StreamingService> _service, QObject* = nullptr) : service(_service) {}
explicit StreamSongMimeData(SharedPtr<StreamingService> _service, QObject *parent = nullptr);
SharedPtr<StreamingService> service;
SongList songs;

View File

@ -0,0 +1,28 @@
/*
* Strawberry Music Player
* This file was part of Clementine.
* Copyright 2010, David Sansome <me@davidsansome.com>
*
* 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 <QWidget>
#include <QString>
#include "transcoderoptionsinterface.h"
TranscoderOptionsInterface::TranscoderOptionsInterface(QWidget *parent) : QWidget(parent) {}
TranscoderOptionsInterface::~TranscoderOptionsInterface() = default;

View File

@ -30,8 +30,8 @@ class TranscoderOptionsInterface : public QWidget {
Q_OBJECT
public:
explicit TranscoderOptionsInterface(QWidget *parent) : QWidget(parent) {}
~TranscoderOptionsInterface() override {}
explicit TranscoderOptionsInterface(QWidget *parent);
~TranscoderOptionsInterface() override;
virtual void Load() = 0;
virtual void Save() = 0;