Clementine-audio-player-Mac.../src/playlistitem.h

91 lines
2.5 KiB
C
Raw Normal View History

/* This file is part of Clementine.
Clementine 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.
Clementine 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 Clementine. If not, see <http://www.gnu.org/licenses/>.
*/
2009-12-24 20:16:07 +01:00
#ifndef PLAYLISTITEM_H
#define PLAYLISTITEM_H
#include <QStandardItem>
#include <QUrl>
#include <boost/shared_ptr.hpp>
2009-12-26 23:15:57 +01:00
class Song;
class QSqlQuery;
2009-12-26 23:15:57 +01:00
2009-12-24 20:16:07 +01:00
class PlaylistItem {
public:
PlaylistItem(const QString& type) : type_(type) {}
2009-12-24 20:16:07 +01:00
virtual ~PlaylistItem() {}
static PlaylistItem* NewFromType(const QString& type);
2009-12-29 17:12:08 +01:00
enum Option {
Default = 0x00,
SpecialPlayBehaviour = 0x01,
ContainsMultipleTracks = 0x02,
PauseDisabled = 0x04,
LastFMControls = 0x08,
};
Q_DECLARE_FLAGS(Options, Option);
virtual QString type() const { return type_; }
2009-12-24 20:16:07 +01:00
2009-12-29 17:12:08 +01:00
virtual Options options() const { return Default; }
virtual void InitFromQuery(const QSqlQuery& query) = 0;
void BindToQuery(QSqlQuery* query) const;
2010-01-16 17:12:47 +01:00
virtual void Reload() {}
2009-12-24 20:16:07 +01:00
2009-12-29 20:22:02 +01:00
virtual Song Metadata() const = 0;
2009-12-24 20:16:07 +01:00
2009-12-26 22:35:45 +01:00
// If the item needs to do anything special before it can play (eg. start
// streaming the radio stream), then it should implement StartLoading() and
// return true. If it returns false then the URL from Url() will be passed
// directly to xine instead.
2009-12-29 17:12:08 +01:00
virtual void StartLoading() {}
virtual QUrl Url() const = 0;
2009-12-26 23:15:57 +01:00
// If the item is a radio station that can play another song after one has
// finished then it should do so and return true
2009-12-29 17:12:08 +01:00
virtual void LoadNext() {}
2009-12-26 23:15:57 +01:00
virtual void SetTemporaryMetadata(const Song& metadata) {Q_UNUSED(metadata)}
virtual void ClearTemporaryMetadata() {}
protected:
enum DatabaseColumn {
Column_LibraryId,
Column_Url,
Column_Title,
Column_Artist,
Column_Album,
Column_Length,
Column_RadioService,
};
virtual QVariant DatabaseValue(DatabaseColumn) const {
return QVariant(QVariant::String); }
QString type_;
2009-12-24 20:16:07 +01:00
};
typedef QList<boost::shared_ptr<PlaylistItem> > PlaylistItemList;
2009-12-24 20:16:07 +01:00
2009-12-29 17:12:08 +01:00
Q_DECLARE_OPERATORS_FOR_FLAGS(PlaylistItem::Options);
2009-12-24 20:16:07 +01:00
#endif // PLAYLISTITEM_H