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  const QString &bindValue = "");
21 
22  public:
25 
26  void setList(metadata_list &list);
27  const metadata_list &getList() const;
28 
29  VideoMetadataPtr byFilename(const QString &file_name) const;
30  VideoMetadataPtr byID(unsigned int db_id) const;
31 
32  bool purgeByFilename(const QString &file_name);
33  bool purgeByID(unsigned int db_id);
34 
35  private:
36  class VideoMetadataListManagerImp *m_imp {nullptr};
37 };
38 
40 {
41  public:
42  meta_node(meta_node *parent, bool is_path_root = false) :
43  m_parent(parent), m_pathRoot(is_path_root) {}
44  virtual ~meta_node() = default;
45 
46  virtual const QString &getName() const = 0;
47  virtual const QString &getPath() const;
48  const QString &getFQPath();
49  void setParent(meta_node *parent);
50  void setPathRoot(bool is_root = true);
51 
52  protected:
53  meta_node *m_parent {nullptr};
54 
55  private:
56  QString m_fqPath;
57  bool m_pathRoot;
58  static const QString kEmptyPath;
59 };
60 
62 {
63  public:
64  meta_data_node(VideoMetadata *data, meta_node *parent = nullptr) :
65  meta_node(parent), m_data(data) {}
66  const QString &getName() const override; // meta_node
67  const VideoMetadata *getData() const;
68  VideoMetadata *getData();
69 
70  private:
71  VideoMetadata *m_data {nullptr};
72  static const QString kMetaBug;
73 };
74 
75 class meta_dir_node;
76 
79 
80 using meta_dir_list = std::list<smart_dir_node>;
81 using meta_data_list = std::list<smart_meta_node>;
82 
84 {
85  public:
86  using dir_iterator = meta_dir_list::iterator;
87  using const_dir_iterator = meta_dir_list::const_iterator;
88 
89  using entry_iterator = meta_data_list::iterator;
90  using const_entry_iterator = meta_data_list::const_iterator;
91 
92  public:
93  meta_dir_node(const QString &path, const QString &name = "",
94  meta_dir_node *parent = nullptr, bool is_path_root = false,
95  QString host = "", QString prefix = "",
96  QVariant data = QVariant());
97  meta_dir_node() : meta_node(nullptr) { }
98 
99  void ensureSortFields();
100  void setName(const QString &name);
101  const QString &getName() const override; // meta_node
102  void SetHost(const QString &host);
103  const QString &GetHost() const;
104  void SetPrefix(const QString &prefix);
105  const QString &GetPrefix() const;
106  const QString &getPath() const override; // meta_node
107  const QString &getSortPath() const;
108  void setPath(const QString &path, const QString &sortPath = nullptr);
109  void SetData(const QVariant &data);
110  const QVariant &GetData() const;
111  bool DataIsValid(void) const;
112  smart_dir_node addSubDir(const QString &subdir,
113  const QString &name = "",
114  const QString &host = "",
115  const QString &prefix = "",
116  const QVariant &data = QVariant());
117  void addSubDir(const smart_dir_node &subdir);
118  smart_dir_node getSubDir(const QString &subdir,
119  const QString &name = "",
120  bool create = true,
121  const QString &host = "",
122  const QString &prefix = "",
123  const QVariant &data = QVariant());
124  void addEntry(const smart_meta_node &entry);
125  void clear();
126  bool empty() const;
127  int subdir_count() const;
128  template <typename DirSort, typename EntrySort>
129  void sort(DirSort dir_sort, EntrySort entry_sort)
130  {
131  m_subdirs.sort(dir_sort);
132  m_entries.sort(entry_sort);
133 
134  for (auto & subdir : m_subdirs)
135  {
136  if (subdir == nullptr)
137  continue;
138  subdir->sort(dir_sort, entry_sort);
139  }
140  }
141  dir_iterator dirs_begin();
142  dir_iterator dirs_end();
143  const_dir_iterator dirs_begin() const;
144  const_dir_iterator dirs_end() const;
145  entry_iterator entries_begin();
146  entry_iterator entries_end();
147  const_entry_iterator entries_begin() const;
148  const_entry_iterator entries_end() const;
149  bool has_entries() const;
150 
151  private:
152  QString m_path;
153  QString m_sortPath;
154  QString m_name;
155  QString m_host;
156  QString m_prefix;
159 
160  QVariant m_data;
161 };
162 #endif // VIDEOMETADATALISTMANAGER_H_
meta_node
Definition: videometadatalistmanager.h:39
VideoMetadata
Definition: videometadata.h:24
meta_dir_node::m_name
QString m_name
Definition: videometadatalistmanager.h:154
meta_dir_node::meta_dir_node
meta_dir_node()
Definition: videometadatalistmanager.h:97
meta_dir_node::m_sortPath
QString m_sortPath
Definition: videometadatalistmanager.h:153
meta_dir_node::const_dir_iterator
meta_dir_list::const_iterator const_dir_iterator
Definition: videometadatalistmanager.h:87
videometadata.h
meta_dir_node::m_host
QString m_host
Definition: videometadatalistmanager.h:155
VideoMetadataListManager
Definition: videometadatalistmanager.h:10
meta_dir_node::const_entry_iterator
meta_data_list::const_iterator const_entry_iterator
Definition: videometadatalistmanager.h:90
meta_dir_node::sort
void sort(DirSort dir_sort, EntrySort entry_sort)
Definition: videometadatalistmanager.h:129
simple_ref_ptr
Definition: quicksp.h:24
meta_dir_node::m_subdirs
meta_dir_list m_subdirs
Definition: videometadatalistmanager.h:157
meta_node::kEmptyPath
static const QString kEmptyPath
Definition: videometadatalistmanager.h:58
meta_dir_node::entry_iterator
meta_data_list::iterator entry_iterator
Definition: videometadatalistmanager.h:89
meta_dir_node
Definition: videometadatalistmanager.h:83
meta_node::meta_node
meta_node(meta_node *parent, bool is_path_root=false)
Definition: videometadatalistmanager.h:42
meta_dir_node::dir_iterator
meta_dir_list::iterator dir_iterator
Definition: videometadatalistmanager.h:86
meta_dir_node::m_entries
meta_data_list m_entries
Definition: videometadatalistmanager.h:158
meta_data_node::meta_data_node
meta_data_node(VideoMetadata *data, meta_node *parent=nullptr)
Definition: videometadatalistmanager.h:64
mythmetaexp.h
meta_node::getName
virtual const QString & getName() const =0
hardwareprofile.distros.mythtv_data.data_mythtv.prefix
string prefix
Definition: data_mythtv.py:40
meta_data_node::kMetaBug
static const QString kMetaBug
Definition: videometadatalistmanager.h:72
meta_dir_node::m_prefix
QString m_prefix
Definition: videometadatalistmanager.h:156
clear
static void clear(SettingsMap &cache, SettingsMap &overrides, const QString &myKey)
Definition: mythdb.cpp:896
meta_node::m_pathRoot
bool m_pathRoot
Definition: videometadatalistmanager.h:57
meta_dir_node::m_data
QVariant m_data
Definition: videometadatalistmanager.h:160
uint
unsigned int uint
Definition: compat.h:81
meta_data_node
Definition: videometadatalistmanager.h:61
meta_node::getPath
virtual const QString & getPath() const
Definition: videometadatalistmanager.cpp:197
meta_dir_node::m_path
QString m_path
Definition: videometadatalistmanager.h:152
VideoMetadataListManagerImp
Definition: videometadatalistmanager.cpp:7
meta_node::m_fqPath
QString m_fqPath
Definition: videometadatalistmanager.h:56
meta_dir_list
std::list< smart_dir_node > meta_dir_list
Definition: videometadatalistmanager.h:80
VideoMetadataListManager::metadata_list
std::list< VideoMetadataPtr > metadata_list
Definition: videometadatalistmanager.h:14
quicksp.h
meta_data_list
std::list< smart_meta_node > meta_data_list
Definition: videometadatalistmanager.h:81
META_PUBLIC
#define META_PUBLIC
Definition: mythmetaexp.h:9