diff --git a/mythtv/libs/libmythservicecontracts/datacontracts/artworkInfoList.h b/mythtv/libs/libmythservicecontracts/datacontracts/artworkInfoList.h index fafe7cb7425..e4b28428549 100644 --- a/mythtv/libs/libmythservicecontracts/datacontracts/artworkInfoList.h +++ b/mythtv/libs/libmythservicecontracts/datacontracts/artworkInfoList.h @@ -29,7 +29,7 @@ class SERVICE_PUBLIC ArtworkInfoList : public QObject // Q_CLASSINFO Used to augment Metadata for properties. // See datacontracthelper.h for details - + Q_CLASSINFO( "ArtworkInfos", "type=DTC::ArtworkInfo"); Q_PROPERTY( QVariantList ArtworkInfos READ ArtworkInfos DESIGNABLE true ) diff --git a/mythtv/libs/libmythservicecontracts/datacontracts/genre.h b/mythtv/libs/libmythservicecontracts/datacontracts/genre.h new file mode 100644 index 00000000000..22726b59c15 --- /dev/null +++ b/mythtv/libs/libmythservicecontracts/datacontracts/genre.h @@ -0,0 +1,69 @@ +////////////////////////////////////////////////////////////////////////////// +// Program Name: genre.h +// Created : Mar. 08, 2017 +// +// Copyright (c) 2017 Paul Harrison +// +// Licensed under the GPL v2 or later, see COPYING for details +// +////////////////////////////////////////////////////////////////////////////// + +#ifndef GENRE_H_ +#define GENRE_H_ + +#include + +#include "serviceexp.h" +#include "datacontracthelper.h" + +namespace DTC +{ + +///////////////////////////////////////////////////////////////////////////// + +class SERVICE_PUBLIC Genre : public QObject +{ + Q_OBJECT + Q_CLASSINFO( "version" , "1.0" ); + + Q_PROPERTY( QString Name READ Name WRITE setName ) + + PROPERTYIMP ( QString , Name ) + + public: + + static inline void InitializeCustomTypes(); + + public: + + Genre(QObject *parent = 0) + : QObject ( parent ) + { + } + + Genre( const Genre &src ) + { + Copy( src ); + } + + void Copy( const Genre &src ) + { + m_Name = src.m_Name ; + } +}; + +} // namespace DTC + +Q_DECLARE_METATYPE( DTC::Genre ) +Q_DECLARE_METATYPE( DTC::Genre* ) + +namespace DTC +{ +inline void Genre::InitializeCustomTypes() +{ + qRegisterMetaType< Genre >(); + qRegisterMetaType< Genre* >(); +} +} + +#endif diff --git a/mythtv/libs/libmythservicecontracts/datacontracts/genreList.h b/mythtv/libs/libmythservicecontracts/datacontracts/genreList.h new file mode 100644 index 00000000000..94d488d3f37 --- /dev/null +++ b/mythtv/libs/libmythservicecontracts/datacontracts/genreList.h @@ -0,0 +1,89 @@ +////////////////////////////////////////////////////////////////////////////// +// Program Name: genreList.h +// Created : Mar. 08, 2017 +// +// Copyright (c) 2017 Paul Harrison +// +// Licensed under the GPL v2 or later, see COPYING for details +// +////////////////////////////////////////////////////////////////////////////// + +#ifndef GENRELIST_H_ +#define GENRELIST_H_ + +#include +#include + +#include "serviceexp.h" +#include "datacontracthelper.h" + +#include "genre.h" + +namespace DTC +{ + +class SERVICE_PUBLIC GenreList : public QObject +{ + Q_OBJECT + Q_CLASSINFO( "version", "1.0" ); + + // Q_CLASSINFO Used to augment Metadata for properties. + // See datacontracthelper.h for details + + Q_CLASSINFO( "GenreList", "type=DTC::Genre"); + + Q_PROPERTY( QVariantList Genres READ Genres DESIGNABLE true ) + + PROPERTYIMP_RO_REF( QVariantList, Genres ) + + public: + + static inline void InitializeCustomTypes(); + + public: + + GenreList(QObject *parent = 0) + : QObject ( parent ) + { + } + + GenreList( const GenreList &src ) + { + Copy( src ); + } + + void Copy( const GenreList &src ) + { + CopyListContents< Genre >( this, m_Genres, src.m_Genres ); + } + + Genre *AddNewGenre() + { + // We must make sure the object added to the QVariantList has + // a parent of 'this' + + Genre *pObject = new Genre( this ); + m_Genres.append( QVariant::fromValue( pObject )); + + return pObject; + } + +}; + +} // namespace DTC + +Q_DECLARE_METATYPE( DTC::GenreList ) +Q_DECLARE_METATYPE( DTC::GenreList* ) + +namespace DTC +{ +inline void GenreList::InitializeCustomTypes() +{ + qRegisterMetaType< GenreList >(); + qRegisterMetaType< GenreList* >(); + + Genre::InitializeCustomTypes(); +} +} + +#endif diff --git a/mythtv/libs/libmythservicecontracts/datacontracts/videoMetadataInfo.h b/mythtv/libs/libmythservicecontracts/datacontracts/videoMetadataInfo.h index 8ee1bc09d49..00d7e4f88bc 100644 --- a/mythtv/libs/libmythservicecontracts/datacontracts/videoMetadataInfo.h +++ b/mythtv/libs/libmythservicecontracts/datacontracts/videoMetadataInfo.h @@ -19,6 +19,7 @@ #include "datacontracthelper.h" #include "artworkInfoList.h" #include "castMemberList.h" +#include "genreList.h" namespace DTC { @@ -28,7 +29,7 @@ namespace DTC class SERVICE_PUBLIC VideoMetadataInfo : public QObject { Q_OBJECT - Q_CLASSINFO( "version" , "2.0" ); + Q_CLASSINFO( "version" , "2.01" ); Q_PROPERTY( int Id READ Id WRITE setId ) Q_PROPERTY( QString Title READ Title WRITE setTitle ) @@ -65,6 +66,7 @@ class SERVICE_PUBLIC VideoMetadataInfo : public QObject Q_PROPERTY( QObject* Artwork READ Artwork DESIGNABLE SerializeArtwork ) Q_PROPERTY( QObject* Cast READ Cast DESIGNABLE SerializeCast ) + Q_PROPERTY( QObject* Genres READ Genres DESIGNABLE SerializeGenres ) PROPERTYIMP ( int , Id ) PROPERTYIMP ( QString , Title ) @@ -99,11 +101,13 @@ class SERVICE_PUBLIC VideoMetadataInfo : public QObject PROPERTYIMP ( QString , Screenshot ) PROPERTYIMP ( QString , Trailer ) - PROPERTYIMP_PTR( ArtworkInfoList, Artwork ) - PROPERTYIMP_PTR( CastMemberList , Cast ) + PROPERTYIMP_PTR( ArtworkInfoList , Artwork ) + PROPERTYIMP_PTR( CastMemberList , Cast ) + PROPERTYIMP_PTR( GenreList , Genres ) PROPERTYIMP ( bool , SerializeArtwork) PROPERTYIMP ( bool , SerializeCast ) + PROPERTYIMP ( bool , SerializeGenres ) public: @@ -127,8 +131,10 @@ class SERVICE_PUBLIC VideoMetadataInfo : public QObject m_Processed ( false ), m_Artwork ( NULL ), m_Cast ( NULL ), + m_Genres ( NULL ), m_SerializeArtwork( true ), - m_SerializeCast ( true ) + m_SerializeCast ( true ), + m_SerializeGenres ( true ) { } @@ -142,12 +148,17 @@ class SERVICE_PUBLIC VideoMetadataInfo : public QObject m_Id = src.m_Id; m_SerializeArtwork = src.m_SerializeArtwork; m_SerializeCast = src.m_SerializeCast; + m_SerializeGenres = src.m_SerializeGenres; if ( src.m_Artwork != NULL) Artwork()->Copy( src.m_Artwork ); if (src.m_Cast != NULL) Cast()->Copy( src.m_Cast ); + + if (src.m_Genres != NULL) + Genres()->Copy( src.m_Genres ); + } }; @@ -168,6 +179,9 @@ inline void VideoMetadataInfo::InitializeCustomTypes() if (QMetaType::type( "DTC::CastMemberList" ) == 0) CastMemberList::InitializeCustomTypes(); + + if (QMetaType::type( "DTC::GenreMemberList" ) == 0) + GenreList::InitializeCustomTypes(); } } diff --git a/mythtv/libs/libmythservicecontracts/datacontracts/videoMetadataInfoList.h b/mythtv/libs/libmythservicecontracts/datacontracts/videoMetadataInfoList.h index 8c7964748c9..f359c8d0888 100644 --- a/mythtv/libs/libmythservicecontracts/datacontracts/videoMetadataInfoList.h +++ b/mythtv/libs/libmythservicecontracts/datacontracts/videoMetadataInfoList.h @@ -24,7 +24,7 @@ namespace DTC class SERVICE_PUBLIC VideoMetadataInfoList : public QObject { Q_OBJECT - Q_CLASSINFO( "version", "1.01" ); + Q_CLASSINFO( "version", "1.02" ); // Q_CLASSINFO Used to augment Metadata for properties. // See datacontracthelper.h for details diff --git a/mythtv/libs/libmythservicecontracts/libmythservicecontracts.pro b/mythtv/libs/libmythservicecontracts/libmythservicecontracts.pro index e1fb44d412f..024a27cb06c 100644 --- a/mythtv/libs/libmythservicecontracts/libmythservicecontracts.pro +++ b/mythtv/libs/libmythservicecontracts/libmythservicecontracts.pro @@ -60,6 +60,7 @@ HEADERS += datacontracts/frontend.h datacontracts/frontendList.h HEADERS += datacontracts/cutting.h datacontracts/cutList.h HEADERS += datacontracts/backendInfo.h datacontracts/envInfo.h HEADERS += datacontracts/buildInfo.h datacontracts/logInfo.h +HEADERS += datacontracts/genre.h datacontracts/genreList.h HEADERS += enums/recStatus.h diff --git a/mythtv/programs/mythbackend/services/serviceUtil.cpp b/mythtv/programs/mythbackend/services/serviceUtil.cpp index ae42bbbb556..a476c28e7e3 100644 --- a/mythtv/programs/mythbackend/services/serviceUtil.cpp +++ b/mythtv/programs/mythbackend/services/serviceUtil.cpp @@ -349,6 +349,33 @@ void FillArtworkInfoList( DTC::ArtworkInfoList *pArtworkInfoList, // ///////////////////////////////////////////////////////////////////////////// +void FillGenreList(DTC::GenreList* pGenreList, int videoID) +{ + if (!pGenreList) + return; + + MSqlQuery query(MSqlQuery::InitCon()); + query.prepare("SELECT genre from videogenre " + "LEFT JOIN videometadatagenre ON videometadatagenre.idgenre = videogenre.intid " + "WHERE idvideo = :ID;" + "ORDER BY genre;"); + query.bindValue(":ID", videoID); + + if (query.exec() && query.size() > 0) + { + while (query.next()) + { + DTC::Genre *pGenre = pGenreList->AddNewGenre(); + QString genre = query.value(0).toString(); + pGenre->setName(genre); + } + } +} + +///////////////////////////////////////////////////////////////////////////// +// +///////////////////////////////////////////////////////////////////////////// + void FillVideoMetadataInfo ( DTC::VideoMetadataInfo *pVideoMetadataInfo, VideoMetadataListManager::VideoMetadataPtr pMetadata, @@ -436,6 +463,8 @@ void FillVideoMetadataInfo ( .arg(pMetadata->GetScreenshot())); } } + + FillGenreList(pVideoMetadataInfo->Genres(), pVideoMetadataInfo->Id()); } ///////////////////////////////////////////////////////////////////////////// diff --git a/mythtv/programs/mythbackend/services/serviceUtil.h b/mythtv/programs/mythbackend/services/serviceUtil.h index 88f15185dcf..f188be2c2ee 100644 --- a/mythtv/programs/mythbackend/services/serviceUtil.h +++ b/mythtv/programs/mythbackend/services/serviceUtil.h @@ -34,6 +34,7 @@ #include "datacontracts/input.h" #include "datacontracts/castMemberList.h" #include "datacontracts/cutList.h" +#include "datacontracts/genreList.h" #include "programinfo.h" #include "recordingrule.h" @@ -66,6 +67,8 @@ void FillArtworkInfoList( DTC::ArtworkInfoList *pArtworkInfoList, const QString &sInetref, uint nSeason ); +void FillGenreList( DTC::GenreList *pGenreList, int videoID); + void FillVideoMetadataInfo ( DTC::VideoMetadataInfo *pVideoMetadataInfo, VideoMetadataListManager::VideoMetadataPtr pMetadata,