1 /* This file is part of Clementine.
2    Copyright 2012, David Sansome <me@davidsansome.com>
3    Copyright 2014, Krzysztof Sobiecki <sobkas@gmail.com>
4    Copyright 2014, John Maguire <john.maguire@gmail.com>
5 
6    Clementine is free software: you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation, either version 3 of the License, or
9    (at your option) any later version.
10 
11    Clementine is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15 
16    You should have received a copy of the GNU General Public License
17    along with Clementine.  If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 #ifndef INTERNET_PODCASTS_PODCASTEPISODE_H_
21 #define INTERNET_PODCASTS_PODCASTEPISODE_H_
22 
23 #include "core/song.h"
24 
25 #include <QSharedDataPointer>
26 #include <QSqlQuery>
27 #include <QUrl>
28 #include <QVariantMap>
29 
30 class Podcast;
31 
32 class PodcastEpisode {
33  public:
34   PodcastEpisode();
35   PodcastEpisode(const PodcastEpisode& other);
36   ~PodcastEpisode();
37 
38   static const QStringList kColumns;
39   static const QString kColumnSpec;
40   static const QString kJoinSpec;
41   static const QString kBindSpec;
42   static const QString kUpdateSpec;
43 
44   void InitFromQuery(const QSqlQuery& query);
45   void BindToQuery(QSqlQuery* query) const;
46 
47   Song ToSong(const Podcast& podcast) const;
48 
is_valid()49   bool is_valid() const { return database_id() != -1; }
50 
51   int database_id() const;
52   int podcast_database_id() const;
53   const QString& title() const;
54   const QString& description() const;
55   const QString& author() const;
56   const QDateTime& publication_date() const;
57   int duration_secs() const;
58   const QUrl& url() const;
59   bool listened() const;
60   const QDateTime& listened_date() const;
61   bool downloaded() const;
62   const QUrl& local_url() const;
63   const QVariantMap& extra() const;
64   QVariant extra(const QString& key) const;
65 
66   void set_database_id(int v);
67   void set_podcast_database_id(int v);
68   void set_title(const QString& v);
69   void set_description(const QString& v);
70   void set_author(const QString& v);
71   void set_publication_date(const QDateTime& v);
72   void set_duration_secs(int v);
73   void set_url(const QUrl& v);
74   void set_listened(bool v);
75   void set_listened_date(const QDateTime& v);
76   void set_downloaded(bool v);
77   void set_local_url(const QUrl& v);
78   void set_extra(const QVariantMap& v);
79   void set_extra(const QString& key, const QVariant& value);
80 
81   PodcastEpisode& operator=(const PodcastEpisode& other);
82 
83  private:
84   struct Private;
85   QSharedDataPointer<Private> d;
86 };
87 Q_DECLARE_METATYPE(PodcastEpisode)
88 
89 typedef QList<PodcastEpisode> PodcastEpisodeList;
90 Q_DECLARE_METATYPE(QList<PodcastEpisode>)
91 
92 #endif  // INTERNET_PODCASTS_PODCASTEPISODE_H_
93