00001 #ifndef METADATA_H_
00002 #define METADATA_H_
00003
00004 #include <qstring.h>
00005
00006 #include <utility>
00007 #include <vector>
00008
00009 #include "parentalcontrols.h"
00010
00011 class MSqlQuery;
00012 class MetadataListManager;
00013
00014 enum { VIDEO_YEAR_DEFAULT = 1895 };
00015
00016 struct SortData;
00017
00018 class Metadata
00019 {
00020 public:
00021 typedef std::pair<int, QString> genre_entry;
00022 typedef std::pair<int, QString> country_entry;
00023 typedef std::pair<int, QString> cast_entry;
00024 typedef std::vector<genre_entry> genre_list;
00025 typedef std::vector<country_entry> country_list;
00026 typedef std::vector<cast_entry> cast_list;
00027
00028 public:
00029 class SortKey
00030 {
00031 public:
00032 SortKey();
00033 SortKey(const SortData &data);
00034 SortKey(const SortKey &other);
00035 SortKey &operator=(const SortKey &rhs);
00036 ~SortKey();
00037
00038 bool isSet() const;
00039 void Clear();
00040
00041 public:
00042 SortData *m_sd;
00043 };
00044
00045 public:
00046 static SortKey GenerateDefaultSortKey(const Metadata &m, bool ignore_case);
00047 static QString FilenameToTitle(const QString &file_name);
00048 static QString trimTitle(const QString &title, bool ignore_case);
00049 static QString getPlayer(const Metadata *item);
00050 static QString getPlayer(const Metadata *item, QString &internal_mrl);
00051 static QString getPlayCommand(const Metadata *item);
00052 static bool getPlayer(const QString &extension, QString &player,
00053 bool &use_default);
00054
00055 public:
00056 Metadata(const QString &filename = "", const QString &coverfile = "",
00057 const QString &title = "", int year = VIDEO_YEAR_DEFAULT,
00058 const QString &inetref = "", const QString &director = "",
00059 const QString &plot = "", float userrating = 0.0,
00060 const QString &rating = "", int length = 0,
00061 int id = 0,
00062 ParentalLevel::Level showlevel = ParentalLevel::plLowest,
00063 int categoryID = 0,
00064 int childID = -1, bool browse = true,
00065 const QString &playcommand = "", const QString &category = "",
00066 const genre_list &genres = genre_list(),
00067 const country_list &countries = country_list(),
00068 const cast_list &cast = cast_list());
00069 ~Metadata();
00070 Metadata(MSqlQuery &query);
00071 Metadata(const Metadata &rhs);
00072 Metadata &operator=(const Metadata &rhs);
00073
00074
00075 bool hasSortKey() const;
00076 const SortKey &getSortKey() const;
00077 void setSortKey(const SortKey &sort_key);
00078
00079
00080 void setFlatIndex(int index);
00081 int getFlatIndex() const;
00082
00083 const QString &getPrefix() const;
00084 void setPrefix(const QString &prefix);
00085
00086 const QString &Title() const;
00087 void setTitle(const QString& title);
00088
00089 int Year() const;
00090 void setYear(int year);
00091
00092 const QString &InetRef() const;
00093 void setInetRef(const QString &inetRef);
00094
00095 const QString &Director() const;
00096 void setDirector(const QString &director);
00097
00098 const QString &Plot() const;
00099 void setPlot(const QString &plot);
00100
00101 float UserRating() const;
00102 void setUserRating(float userRating);
00103
00104 const QString &Rating() const;
00105 void setRating(const QString &rating);
00106
00107 int Length() const;
00108 void setLength(int length);
00109
00110 unsigned int ID() const;
00111 void setID(int id);
00112
00113 int ChildID() const;
00114 void setChildID(int childID);
00115
00116 bool Browse() const;
00117 void setBrowse(bool browse);
00118
00119 const QString &PlayCommand() const;
00120 void setPlayCommand(const QString &playCommand);
00121
00122 ParentalLevel::Level ShowLevel() const;
00123 void setShowLevel(ParentalLevel::Level showLevel);
00124
00125 const QString& Filename() const;
00126 void setFilename(const QString &filename);
00127
00128 QString getFilenameNoPrefix() const;
00129
00130 const QString &CoverFile() const;
00131 void setCoverFile(const QString &coverFile);
00132
00133 const QString &Category() const;
00134
00135
00136 const genre_list &Genres() const;
00137 void setGenres(const genre_list &genres);
00138
00139 const cast_list &getCast() const;
00140 void setCast(const cast_list &cast);
00141
00142 const country_list &Countries() const;
00143 void setCountries(const country_list &countries);
00144
00145 int getCategoryID() const;
00146 void setCategoryID(int id);
00147
00148 void dumpToDatabase();
00149 void updateDatabase();
00150
00151 bool fillDataFromFilename(const MetadataListManager &cache);
00152
00153
00154 bool deleteFile();
00155
00156
00157 bool dropFromDB();
00158
00160 void Reset();
00161
00162 private:
00163 class MetadataImp *m_imp;
00164 };
00165
00166 bool operator==(const Metadata &a, const Metadata &b);
00167 bool operator!=(const Metadata &a, const Metadata &b);
00168
00169 bool operator<(const Metadata::SortKey &lhs, const Metadata::SortKey &rhs);
00170
00171 #endif