2010-03-24 00:11:46 +01:00
|
|
|
/* This file is part of Clementine.
|
2010-11-20 14:27:10 +01:00
|
|
|
Copyright 2010, David Sansome <me@davidsansome.com>
|
2010-03-24 00:11:46 +01:00
|
|
|
|
|
|
|
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
|
|
|
|
|
2011-03-13 12:43:44 +01:00
|
|
|
#include <QMap>
|
2011-05-29 14:55:18 +02:00
|
|
|
#include <QMetaType>
|
2009-12-24 20:16:07 +01:00
|
|
|
#include <QStandardItem>
|
|
|
|
#include <QUrl>
|
|
|
|
|
2010-08-08 14:36:07 +02:00
|
|
|
#include <boost/enable_shared_from_this.hpp>
|
2010-04-15 00:05:41 +02:00
|
|
|
|
2010-07-10 21:45:29 +02:00
|
|
|
#include "core/song.h"
|
2010-04-14 23:03:00 +02:00
|
|
|
|
2011-11-06 16:12:44 +01:00
|
|
|
class QAction;
|
2010-08-03 20:57:17 +02:00
|
|
|
class SqlRow;
|
2009-12-26 23:15:57 +01:00
|
|
|
|
2010-08-08 14:36:07 +02:00
|
|
|
class PlaylistItem : public boost::enable_shared_from_this<PlaylistItem> {
|
2009-12-24 20:16:07 +01:00
|
|
|
public:
|
2011-03-13 12:43:44 +01:00
|
|
|
PlaylistItem(const QString& type)
|
2012-05-27 19:53:57 +02:00
|
|
|
: type_(type) {}
|
2012-05-27 17:46:16 +02:00
|
|
|
virtual ~PlaylistItem();
|
2009-12-24 20:16:07 +01:00
|
|
|
|
|
|
|
static PlaylistItem* NewFromType(const QString& type);
|
2010-11-27 20:23:52 +01:00
|
|
|
static PlaylistItem* NewFromSongsTable(const QString& table, const Song& song);
|
2009-12-24 20:16:07 +01:00
|
|
|
|
2009-12-29 17:12:08 +01:00
|
|
|
enum Option {
|
|
|
|
Default = 0x00,
|
|
|
|
|
2010-05-18 22:43:10 +02:00
|
|
|
// Disables the "pause" action.
|
2011-04-28 17:10:28 +02:00
|
|
|
PauseDisabled = 0x01,
|
2010-05-18 22:43:10 +02:00
|
|
|
|
|
|
|
// Enables the last.fm "ban" action.
|
2011-04-28 17:10:28 +02:00
|
|
|
LastFMControls = 0x02,
|
2011-11-28 19:19:11 +01:00
|
|
|
|
|
|
|
// Disables the seek slider.
|
|
|
|
SeekDisabled = 0x04,
|
2009-12-29 17:12:08 +01:00
|
|
|
};
|
|
|
|
Q_DECLARE_FLAGS(Options, Option);
|
|
|
|
|
2010-04-14 23:03:00 +02:00
|
|
|
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; }
|
|
|
|
|
2011-11-06 16:12:44 +01:00
|
|
|
virtual QList<QAction*> actions() { return QList<QAction*>(); }
|
|
|
|
|
2010-08-03 20:57:17 +02:00
|
|
|
virtual bool InitFromQuery(const SqlRow& query) = 0;
|
2010-04-14 23:03:00 +02:00
|
|
|
void BindToQuery(QSqlQuery* query) const;
|
2010-01-16 17:12:47 +01:00
|
|
|
virtual void Reload() {}
|
2010-08-08 14:36:07 +02:00
|
|
|
QFuture<void> BackgroundReload();
|
2009-12-24 20:16:07 +01:00
|
|
|
|
2009-12-29 20:22:02 +01:00
|
|
|
virtual Song Metadata() const = 0;
|
2010-03-24 21:58:17 +01:00
|
|
|
virtual QUrl Url() const = 0;
|
2009-12-26 23:15:57 +01:00
|
|
|
|
2010-07-10 21:45:29 +02:00
|
|
|
void SetTemporaryMetadata(const Song& metadata);
|
|
|
|
void ClearTemporaryMetadata();
|
|
|
|
bool HasTemporaryMetadata() const { return temp_metadata_.is_valid(); }
|
2010-04-14 23:03:00 +02:00
|
|
|
|
2011-03-13 12:43:44 +01:00
|
|
|
// Background colors.
|
|
|
|
void SetBackgroundColor(short priority, const QColor& color);
|
2011-03-19 11:22:55 +01:00
|
|
|
bool HasBackgroundColor(short priority) const;
|
2011-03-13 12:43:44 +01:00
|
|
|
void RemoveBackgroundColor(short priority);
|
|
|
|
QColor GetCurrentBackgroundColor() const;
|
|
|
|
bool HasCurrentBackgroundColor() const;
|
|
|
|
|
|
|
|
// Foreground colors.
|
|
|
|
void SetForegroundColor(short priority, const QColor& color);
|
2011-03-19 11:22:55 +01:00
|
|
|
bool HasForegroundColor(short priority) const;
|
2011-03-13 12:43:44 +01:00
|
|
|
void RemoveForegroundColor(short priority);
|
|
|
|
QColor GetCurrentForegroundColor() const;
|
|
|
|
bool HasCurrentForegroundColor() const;
|
2010-11-20 19:49:54 +01:00
|
|
|
|
2010-10-17 23:56:19 +02:00
|
|
|
// Convenience function to find out whether this item is from the local
|
|
|
|
// library, as opposed to a device, a file on disk, or a stream.
|
2011-03-20 17:07:24 +01:00
|
|
|
// Remember that even if this returns true, the library item might be
|
2011-05-29 14:55:18 +02:00
|
|
|
// invalid so you might want to check that its id is not equal to -1
|
2011-03-20 17:07:24 +01:00
|
|
|
// before actually using it.
|
2010-10-17 23:56:19 +02:00
|
|
|
virtual bool IsLocalLibraryItem() const { return false; }
|
|
|
|
|
2010-04-14 23:03:00 +02:00
|
|
|
protected:
|
|
|
|
enum DatabaseColumn {
|
|
|
|
Column_LibraryId,
|
2011-07-15 15:27:50 +02:00
|
|
|
Column_InternetService,
|
2010-04-14 23:03:00 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
virtual QVariant DatabaseValue(DatabaseColumn) const {
|
|
|
|
return QVariant(QVariant::String); }
|
2011-04-27 00:06:58 +02:00
|
|
|
virtual Song DatabaseSongMetadata() const { return Song(); }
|
2010-04-14 23:03:00 +02:00
|
|
|
|
|
|
|
QString type_;
|
2010-07-10 21:45:29 +02:00
|
|
|
|
|
|
|
Song temp_metadata_;
|
2011-03-13 12:43:44 +01:00
|
|
|
|
|
|
|
QMap<short, QColor> background_colors_;
|
|
|
|
QMap<short, QColor> foreground_colors_;
|
2009-12-24 20:16:07 +01:00
|
|
|
};
|
2010-10-16 17:22:14 +02:00
|
|
|
typedef boost::shared_ptr<PlaylistItem> PlaylistItemPtr;
|
|
|
|
typedef QList<PlaylistItemPtr> PlaylistItemList;
|
2009-12-24 20:16:07 +01:00
|
|
|
|
2011-05-29 14:55:18 +02:00
|
|
|
Q_DECLARE_METATYPE(PlaylistItemPtr)
|
2011-05-29 16:08:55 +02:00
|
|
|
Q_DECLARE_METATYPE(QList<PlaylistItemPtr>)
|
2011-05-29 14:55:18 +02:00
|
|
|
Q_DECLARE_OPERATORS_FOR_FLAGS(PlaylistItem::Options)
|
2009-12-29 17:12:08 +01:00
|
|
|
|
2009-12-24 20:16:07 +01:00
|
|
|
#endif // PLAYLISTITEM_H
|