MythTV  master
videometadatalistmanager.h
Go to the documentation of this file.
1 #ifndef VIDEOMETADATALISTMANAGER_H_
2 #define VIDEOMETADATALISTMANAGER_H_
3 
4 #include <list>
5 
6 #include "quicksp.h"
7 #include "videometadata.h"
8 #include "mythmetaexp.h"
9 
11 {
12  public:
14  using metadata_list = std::list<VideoMetadataPtr>;
15 
16  public:
17  static VideoMetadataPtr loadOneFromDatabase(uint id);
18  static void loadAllFromDatabase(metadata_list &items,
19  const QString &sql = "");
20 
21  public:
24 
25  void setList(metadata_list &list);
26  const metadata_list &getList() const;
27 
28  VideoMetadataPtr byFilename(const QString &file_name) const;
29  VideoMetadataPtr byID(unsigned int db_id) const;
30 
31  bool purgeByFilename(const QString &file_name);
32  bool purgeByID(unsigned int db_id);
33 
34  private:
35  class VideoMetadataListManagerImp *m_imp {nullptr};
36 };
37 
39 {
40  public:
41  meta_node(meta_node *parent, bool is_path_root = false) :
42  m_parent(parent), m_path_root(is_path_root) {}
43  virtual ~meta_node() = default;
44 
45  virtual const QString &getName() const = 0;
46  virtual const QString &getPath() const;
47  const QString &getFQPath();
48  void setParent(meta_node *parent);
49  void setPathRoot(bool is_root = true);
50 
51  protected:
52  meta_node *m_parent {nullptr};
53 
54  private:
55  QString m_fq_path;
57  static const QString m_empty_path;
58 };
59 
61 {
62  public:
63  meta_data_node(VideoMetadata *data, meta_node *parent = nullptr) :
64  meta_node(parent), m_data(data) {}
65  const QString &getName() const override; // meta_node
66  const VideoMetadata *getData() const;
67  VideoMetadata *getData();
68 
69  private:
70  VideoMetadata *m_data {nullptr};
71  static const QString m_meta_bug;
72 };
73 
74 class meta_dir_node;
75 
78 
79 using meta_dir_list = std::list<smart_dir_node>;
80 using meta_data_list = std::list<smart_meta_node>;
81 
83 {
84  public:
85  using dir_iterator = meta_dir_list::iterator;
86  using const_dir_iterator = meta_dir_list::const_iterator;
87 
88  using entry_iterator = meta_data_list::iterator;
89  using const_entry_iterator = meta_data_list::const_iterator;
90 
91  public:
92  meta_dir_node(const QString &path, const QString &name = "",
93  meta_dir_node *parent = nullptr, bool is_path_root = false,
94  QString host = "", QString prefix = "",
95  QVariant data = QVariant());
96  meta_dir_node() : meta_node(nullptr) { }
97 
98  void ensureSortFields();
99  void setName(const QString &name);
100  const QString &getName() const override; // meta_node
101  void SetHost(const QString &host);
102  const QString &GetHost() const;
103  void SetPrefix(const QString &prefix);
104  const QString &GetPrefix() const;
105  const QString &getPath() const override; // meta_node
106  const QString &getSortPath() const;
107  void setPath(const QString &path, const QString &sortPath = nullptr);
108  void SetData(const QVariant &data);
109  const QVariant &GetData() const;
110  bool DataIsValid(void) const;
111  smart_dir_node addSubDir(const QString &subdir,
112  const QString &name = "",
113  const QString &host = "",
114  const QString &prefix = "",
115  const QVariant &data = QVariant());
116  void addSubDir(const smart_dir_node &subdir);
117  smart_dir_node getSubDir(const QString &subdir,
118  const QString &name = "",
119  bool create = true,
120  const QString &host = "",
121  const QString &prefix = "",
122  const QVariant &data = QVariant());
123  void addEntry(const smart_meta_node &entry);
124  void clear();
125  bool empty() const;
126  int subdir_count() const;
127  template <typename DirSort, typename EntrySort>
128  void sort(DirSort dir_sort, EntrySort entry_sort)
129  {
130  m_subdirs.sort(dir_sort);
131  m_entries.sort(entry_sort);
132 
133  for (meta_dir_list::iterator p = m_subdirs.begin();
134  p != m_subdirs.end(); ++p)
135  {
136  (*p)->sort(dir_sort, entry_sort);
137  }
138  }
139  dir_iterator dirs_begin();
140  dir_iterator dirs_end();
141  const_dir_iterator dirs_begin() const;
142  const_dir_iterator dirs_end() const;
143  entry_iterator entries_begin();
144  entry_iterator entries_end();
145  const_entry_iterator entries_begin() const;
146  const_entry_iterator entries_end() const;
147  bool has_entries() const;
148 
149  private:
150  QString m_path;
151  QString m_sortPath;
152  QString m_name;
153  QString m_host;
154  QString m_prefix;
157 
158  QVariant m_data;
159 };
160 #endif // VIDEOMETADATALISTMANAGER_H_
static const QString m_meta_bug
meta_data_list::const_iterator const_entry_iterator
std::list< smart_dir_node > meta_dir_list
std::list< smart_meta_node > meta_data_list
meta_data_list m_entries
static void clear(SettingsMap &cache, SettingsMap &overrides, const QString &myKey)
Definition: mythdb.cpp:830
#define META_PUBLIC
Definition: mythmetaexp.h:9
meta_dir_list::const_iterator const_dir_iterator
virtual const QString & getName() const =0
unsigned int uint
Definition: compat.h:140
meta_node(meta_node *parent, bool is_path_root=false)
void sort(DirSort dir_sort, EntrySort entry_sort)
meta_data_node(VideoMetadata *data, meta_node *parent=nullptr)
meta_dir_list::iterator dir_iterator
meta_data_list::iterator entry_iterator
static const QString m_empty_path
virtual const QString & getPath() const
std::list< VideoMetadataPtr > metadata_list