Go to the documentation of this file.
10 #include <QScopedPointer>
34 #undef SORT_METADATA_LIST
178 return sort(&lhs, &rhs);
183 return sort(lhs, rhs);
197 static bool sort(
const QString &lhs,
const QString &rhs)
206 int slashLoc = path.lastIndexOf(
'/', -2) + 1;
207 if (path.endsWith(
"/"))
208 ret = path.mid(slashLoc, path.length() - slashLoc - 1);
210 ret = path.mid(slashLoc);
221 QString host = metadata->
GetHost();
226 if (metadata->
GetFilename().startsWith(hint->getFQPath() +
"/"))
230 metadata->
GetFilename().mid(hint->getFQPath().length());
234 if (insert_chunk.startsWith(dir->
getFQPath() +
"/"))
239 QStringList path = insert_chunk.split(
"/", Qt::SkipEmptyParts);
249 for (
const auto & part : std::as_const(path))
264 return smn->getData();
281 const QString& name, QString fqPath,
bool add_up_dirs,
282 QString host =
"", QString
prefix =
"")
288 sub_node->
SetText(name,
"title");
319 where_to_add->
SetImage(
"buttonimage", imageMap[
"smartimage"]);
345 bool include_updirs);
347 bool filebrowser,
bool flatlist,
349 bool include_updirs);
352 bool flat_list,
int group_type);
375 return std::count_if(list.cbegin(), list.cend(), filtermatch);
394 ret = mp->DeleteFile();
430 const QString &
prefix)
const;
462 bool filebrowser,
bool flatlist,
467 group_type, parental_level, include_updirs);
472 bool flat_list,
int group_type)
550 if ((*dir)->has_entries())
552 bool incUpDir = include_updirs;
558 dst, (*dir)->getName(),
559 (*dir)->getFQPath(), incUpDir, (*dir)->GetHost(),
560 (*dir)->GetPrefix());
569 if (((*entry)->getData()->GetSeason() > 0) ||
570 ((*entry)->getData()->GetEpisode() > 0))
572 QString seas = QString::number((*entry)->getData()->GetSeason());
573 QString ep = QString::number((*entry)->getData()->GetEpisode());
574 QString title = (*entry)->getData()->GetTitle();
575 QString subtitle = (*entry)->getData()->GetSubtitle();
580 QString displayTitle = QString(
"%1 %2x%3 - %4")
581 .arg(title, seas, ep, subtitle);
585 displayTitle = QString(
"%2x%3 - %4")
586 .arg(seas, ep, subtitle);
588 AddFileNode(dst, displayTitle, (*entry)->getData());
590 else if ((*entry)->getData()->GetSubtitle().isEmpty())
593 dst, (*entry)->getData()->GetTitle(), (*entry)->getData());
597 QString TitleSub = QString(
"%1 - %2")
598 .arg((*entry)->getData()->GetTitle(),
599 (*entry)->getData()->GetSubtitle());
619 bool filebrowser,
bool flatlist,
int group_type,
622 refreshList(filebrowser, parental_level, flatlist, group_type);
649 QVariant data = node->
GetData();
666 bool flat_list,
int group_type)
681 LOG(VB_GENERAL, LOG_DEBUG,
"Using Folder mode");
685 LOG(VB_GENERAL, LOG_DEBUG,
"Using Genre mode");
689 LOG(VB_GENERAL, LOG_DEBUG,
"Using Category mode");
693 LOG(VB_GENERAL, LOG_DEBUG,
"Using Year mode");
697 LOG(VB_GENERAL, LOG_DEBUG,
"Using Director mode");
701 LOG(VB_GENERAL, LOG_DEBUG,
"Using Studio mode");
705 LOG(VB_GENERAL, LOG_DEBUG,
"Using Cast Mode");
709 LOG(VB_GENERAL, LOG_DEBUG,
"Using User Rating Mode");
713 LOG(VB_GENERAL, LOG_DEBUG,
"Using Insert Date Mode");
717 LOG(VB_GENERAL, LOG_DEBUG,
"Using TV/Movie Mode");
787 std::back_insert_iterator<metadata_view_list> mli(mlist);
791 #ifdef SORT_METADATA_LIST
793 std::sort(mlist.begin(), mlist.end(), mps);
796 using group_to_node_map = std::map<QString, meta_dir_node *>;
797 group_to_node_map gtnm;
804 for (
auto *data : mlist)
808 std::vector<QString> groups;
809 auto take_second = [](
const auto& item){
return item.second; };
815 const std::vector<std::pair <int, QString> >& genres =
818 std::transform(genres.cbegin(), genres.cend(),
819 std::back_inserter(groups), take_second);
824 groups.push_back(data->GetCategory());
829 groups.push_back(QString::number(data->GetYear()));
834 groups.push_back(data->GetDirector());
839 groups.push_back(data->GetStudio());
844 const std::vector<std::pair<int, QString> >& cast = data->GetCast();
846 std::transform(cast.cbegin(), cast.cend(),
847 std::back_inserter(groups), take_second);
852 int i = data->GetUserRating();
853 groups.push_back(QString::number(i));
858 QDate date = data->GetInsertdate();
861 groups.push_back(
tmp);
866 LOG(VB_GENERAL, LOG_ERR,
"Invalid type of grouping");
875 if (group_node ==
nullptr)
878 group_node = sdn2.
get();
879 gtnm[
"Unknown"] = group_node;
885 for (
const auto& item : groups)
889 if (group_node ==
nullptr)
892 group_node = sdn2.
get();
893 gtnm[item] = group_node;
910 std::back_insert_iterator<metadata_view_list> mli(mlist);
914 #ifdef SORT_METADATA_LIST
916 sort(mlist.begin(), mlist.end(), mps);
927 for (
auto &
p : mlist)
931 if ((
p->GetSeason() > 0) || (
p->GetEpisode() > 0))
937 QObject::tr(
"Season %1").arg(
p->GetSeason()));
958 std::back_insert_iterator<metadata_view_list> mli(mlist);
964 #ifdef SORT_METADATA_LIST
966 std::sort(mlist.begin(), mlist.end(), mps);
970 using prefix_to_node_map = std::map<QString, meta_dir_node *>;
971 prefix_to_node_map ptnm;
978 QString test_prefix(dirs[0]);
981 if (dirs.size() == 1)
984 video_root->
setPath(test_prefix);
986 ptnm.insert(prefix_to_node_map::value_type(test_prefix, video_root));
989 for (
auto & mv : mlist)
1001 using node_to_path_list = std::vector<std::pair<QString, QString> >;
1003 node_to_path_list node_paths;
1006 if (dirs.size() > 1)
1008 auto new_pl = [](
const auto& dir)
1010 std::transform(dirs.cbegin(), dirs.cend(), std::back_inserter(node_paths), new_pl);
1014 node_paths.emplace_back(QObject::tr(
"videos"), dirs[0]);
1021 for (
auto & path : node_paths)
1042 for (
auto & list : ml)
1043 list->FillDataFromFilename(mdlm);
1069 if (node ==
nullptr)
1099 std::back_insert_iterator<VideoListImp::metadata_view_list> bip(flat);
1144 using free_list = std::list<simple_ref_ptr<DirectoryHandler> >;
1149 free_list &dh_free_list,
bool infer_title) :
1156 [[maybe_unused]]
const QString &fq_dir_name)
override
1167 const QString &fq_file_name,
1168 const QString &extension)
1170 handleFile(file_name, fq_file_name, extension,
"");
1174 const QString &fq_file_name,
1175 [[maybe_unused]]
const QString &extension,
1176 const QString &host)
override
1178 const QString& file_string(fq_file_name);
1182 QFileInfo qfi(file_string);
1183 QString title = qfi.completeBaseName();
1187 if (!tmptitle.isEmpty())
1190 myData->SetTitle(title);
1193 myData->SetHost(host);
const VideoFilterSettings & getCurrentVideoFilter() const
QString toString(const QDateTime &raw_dt, uint format)
Returns formatted string representing the time.
call_tree_flat(VideoListImp::metadata_view_list &list)
unsigned int getFilterChangedState()
const VideoMetadata * GetMetadata(void) const
void SetData(QVariant data)
void getExtensionIgnoreList(ext_ignore_list &ext_ignore) const
QString GetText(const QString &name="") const
std::list< simple_ref_ptr< DirectoryHandler > > free_list
bool naturalSortCompare(const QString &a, const QString &b, Qt::CaseSensitivity caseSensitivity=Qt::CaseSensitive)
naturalCompare as a std::sort compatible function (ignoring the third parameter, which is never used)...
void GetInitialMetadata(VideoMetadataListManager::metadata_list *list, meta_dir_node *node)
meta_dir_node m_metadataTree
void refreshList(bool filebrowser, const ParentalLevel &parental_level, bool flat_list, int group_type)
void operator()(smart_dir_node &sdn)
uint visibleChildCount() const
int TryFilter(const VideoFilterSettings &filter) const
void SetImageCb(mgtCbFn fn, void *data)
QVariant GetData(void) const
void fillMetadata(metadata_list_type whence)
VideoMetadata * GetMetadata(void)
void SetImageFromMap(const InfoMap &infoMap)
void SetTextCb(mgtCbFn fn, void *data)
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
QString GetPath(void) const
VideoListImp::metadata_view_list & m_list
void SetStateCb(mgtCbFn fn, void *data)
MythGenericTree * buildVideoList(bool filebrowser, bool flatlist, int group_type, const ParentalLevel &parental_level, bool include_updirs)
QScopedPointer< MythGenericTree > m_videoTreeRoot
QHash< QString, QString > InfoMap
MythGenericTree * addNode(const QString &a_string, int an_int=0, bool selectable_flag=false, bool visible=true)
QString GetPrefix(void) const
void handleFile(const QString &file_name, const QString &fq_file_name, const QString &extension)
bool Delete(int video_id)
meta_dir_node m_metadataViewTree
QStringList GetVideoDirs()
VideoMetadata * GetMetadata()
std::vector< std::pair< QString, bool > > ext_ignore_list
VideoMetadataListManager::metadata_list metadata_list
TreeNodeDataPrivate(QString path, QString host, QString prefix)
class VideoListImp * m_imp
void SetImage(const QString &filename, const QString &name="")
int AddFileNode(MythGenericTree *where_to_add, const QString &name, VideoMetadata *metadata)
static void copy_entries(meta_dir_node &dst, meta_dir_node &src, const VideoFilterSettings &filter)
void handleFile([[maybe_unused]] const QString &file_name, const QString &fq_file_name, [[maybe_unused]] const QString &extension, const QString &host) override
static void copy_filtered_tree(meta_dir_node &dst, meta_dir_node &src, const VideoFilterSettings &filter)
const VideoFilterSettings & getCurrentVideoFilter() const
unsigned int getFilterChangedState(void)
unsigned int count(void) const
void sort_view_data(bool flat_list)
static MythGenericTree * AddDirNode(MythGenericTree *where_to_add, const QString &name, QString fqPath, bool add_up_dirs, QString host="", QString prefix="")
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
void setParentalLevel(ParentalLevel::Level parental_level)
void setCurrentVideoFilter(const VideoFilterSettings &filter)
TreeNodeData & operator=(const TreeNodeData &rhs)
bool refreshNode(MythGenericTree *node)
static meta_dir_node * AddMetadataToDir(VideoMetadata *metadata, meta_dir_node *dir, meta_dir_node *hint=nullptr)
void refreshList(bool filebrowser, const ParentalLevel &parental_level, bool flat_list, int group_type)
@ kSimplify
Do Today/Yesterday/Tomorrow transform.
bool GetBoolSetting(const QString &key, bool defaultval=false)
static FileAssociations & getFileAssociation()
VideoFilterSettings m_videoFilter
void buildFileList(smart_dir_node &directory, metadata_list &metalist, const QString &prefix) const
static QString path_to_node_name(const QString &path)
class TreeNodeDataPrivate * m_d
DirectoryHandler * newDir(const QString &dir_name, [[maybe_unused]] const QString &fq_dir_name) override
bool Delete(unsigned int video_id, VideoList &)
bool ScanVideoDirectory(const QString &start_path, DirectoryHandler *handler, const FileAssociations::ext_ignore_list &ext_disposition, bool list_unknown_extensions)
MythGenericTree * getParent(void) const
smart_dir_node m_directory
unsigned int count() const
metadata_view_list m_metadataViewFlat
static UPNPScanner * Instance(UPNPSubscription *sub=nullptr)
metadata_list_type m_metadataListType
MythGenericTree * buildVideoList(bool filebrowser, bool flatlist, int group_type, const ParentalLevel &parental_level, bool include_updirs)
void tree_view_to_flat(meta_dir_node &tree, VideoListImp::metadata_view_list &flat)
unsigned int getChangedState()
VideoMetadata * m_metadata
void DisplayState(const QString &state, const QString &name="")
VideoMetadataListManager::metadata_list & m_metalist
int TryFilter(const VideoFilterSettings &filter) const
std::vector< VideoMetadata * > metadata_view_list
@ kDateFull
Default local time.
bool refreshNode(MythGenericTree *node)
void buildGroupList(metadata_list_type whence)
void SetText(const QString &text, const QString &name="", const QString &state="")
MythGenericTree * GetTreeRoot()
VideoMetadataListManager m_metadata
dirhandler(smart_dir_node &directory, const QString &prefix, VideoMetadataListManager::metadata_list &metalist, free_list &dh_free_list, bool infer_title)
void setCurrentVideoFilter(const VideoFilterSettings &filter)
bool matches_filter(const VideoMetadata &mdata) const
MythGenericTree * GetTreeRoot(void)
void build_generic_tree(MythGenericTree *dst, meta_dir_node *src, bool include_updirs)
bool meta_less_than(const VideoMetadata &lhs, const VideoMetadata &rhs) const
Compares two VideoMetadata instances.
void update_meta_view(bool flat_list)
const VideoMetadataListManager & getListCache() const
TreeNodeDataPrivate(VideoMetadata *metadata)
QString GetHost(void) const
const VideoMetadataListManager & getListCache(void) const
QString GetPrefix() const