From 46a411844acc1b5b04045c1463548d8bed7a9512 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bara?= Date: Sat, 21 May 2011 12:19:35 +0000 Subject: [PATCH] some more corrections of the python API for cover providers; still not working ;) --- src/covers/albumcoverfetcher.h | 3 + src/generated_cpp/clementine/clementine0.cpp | 89 ++----------------- src/generated_cpp/clementine/clementine0.h | 42 +++++---- .../clementine/clementine_init.cpp | 2 +- src/main.cpp | 3 + src/scripting/python/pythonengine.cpp | 5 ++ .../python/typesystem_clementine.xml | 3 +- 7 files changed, 40 insertions(+), 107 deletions(-) diff --git a/src/covers/albumcoverfetcher.h b/src/covers/albumcoverfetcher.h index f174f3f9a..1f3a72a21 100644 --- a/src/covers/albumcoverfetcher.h +++ b/src/covers/albumcoverfetcher.h @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -53,10 +54,12 @@ struct CoverSearchResult { // an URL of a cover image described by this CoverSearchResult QString image_url; }; +Q_DECLARE_METATYPE(CoverSearchResult); // This is a complete result of a single search request (a list of results, each // describing one image, actually). typedef QList CoverSearchResults; +Q_DECLARE_METATYPE(CoverSearchResults); // This class searches for album covers for a given query or artist/album and // returns URLs. It's NOT thread-safe. diff --git a/src/generated_cpp/clementine/clementine0.cpp b/src/generated_cpp/clementine/clementine0.cpp index 5e3ba7b33..9230040aa 100644 --- a/src/generated_cpp/clementine/clementine0.cpp +++ b/src/generated_cpp/clementine/clementine0.cpp @@ -148,15 +148,15 @@ void PythonQtWrapper_AlbumCoverFetcherSearch::Start(AlbumCoverFetcherSearch* the -CoverSearchResults PythonQtShell_CoverProvider::ParseReply(QNetworkReply* reply) +QList PythonQtShell_CoverProvider::ParseReply(QNetworkReply* reply) { if (_wrapper) { PyObject* obj = PyObject_GetAttrString((PyObject*)_wrapper, "ParseReply"); PyErr_Clear(); if (obj && !PythonQtSlotFunction_Check(obj)) { - static const char* argumentList[] ={"CoverSearchResults" , "QNetworkReply*"}; + static const char* argumentList[] ={"QList" , "QNetworkReply*"}; static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList); - CoverSearchResults returnValue; + QList returnValue; void* args[2] = {NULL, (void*)&reply}; PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true); if (result) { @@ -165,7 +165,7 @@ if (_wrapper) { if (args[0]==NULL) { PythonQt::priv()->handleVirtualOverloadReturnError("ParseReply", methodInfo, result); } else { - returnValue = *((CoverSearchResults*)args[0]); + returnValue = *((QList*)args[0]); } } } @@ -174,7 +174,7 @@ if (_wrapper) { return returnValue; } } - return CoverSearchResults(); + return QList(); } QNetworkReply* PythonQtShell_CoverProvider::SendRequest(const QString& query) { @@ -485,84 +485,9 @@ CoverProviders* PythonQtWrapper_CoverProviders::static_CoverProviders_instance( -CoverSearchResults* PythonQtWrapper_CoverSearchResults::new_CoverSearchResults() +CoverSearchResult* PythonQtWrapper_CoverSearchResult::new_CoverSearchResult() { -return new CoverSearchResults(); } - -void PythonQtWrapper_CoverSearchResults::clear(CoverSearchResults* theWrappedObject) -{ - ( theWrappedObject->clear()); -} - -int PythonQtWrapper_CoverSearchResults::count(CoverSearchResults* theWrappedObject) const -{ - return ( theWrappedObject->count()); -} - -void PythonQtWrapper_CoverSearchResults::detachShared(CoverSearchResults* theWrappedObject) -{ - ( theWrappedObject->detachShared()); -} - -bool PythonQtWrapper_CoverSearchResults::empty(CoverSearchResults* theWrappedObject) const -{ - return ( theWrappedObject->empty()); -} - -bool PythonQtWrapper_CoverSearchResults::isEmpty(CoverSearchResults* theWrappedObject) const -{ - return ( theWrappedObject->isEmpty()); -} - -int PythonQtWrapper_CoverSearchResults::length(CoverSearchResults* theWrappedObject) const -{ - return ( theWrappedObject->length()); -} - -void PythonQtWrapper_CoverSearchResults::move(CoverSearchResults* theWrappedObject, int from, int to) -{ - ( theWrappedObject->move(from, to)); -} - -void PythonQtWrapper_CoverSearchResults::pop_back(CoverSearchResults* theWrappedObject) -{ - ( theWrappedObject->pop_back()); -} - -void PythonQtWrapper_CoverSearchResults::pop_front(CoverSearchResults* theWrappedObject) -{ - ( theWrappedObject->pop_front()); -} - -void PythonQtWrapper_CoverSearchResults::removeAt(CoverSearchResults* theWrappedObject, int i) -{ - ( theWrappedObject->removeAt(i)); -} - -void PythonQtWrapper_CoverSearchResults::removeFirst(CoverSearchResults* theWrappedObject) -{ - ( theWrappedObject->removeFirst()); -} - -void PythonQtWrapper_CoverSearchResults::removeLast(CoverSearchResults* theWrappedObject) -{ - ( theWrappedObject->removeLast()); -} - -void PythonQtWrapper_CoverSearchResults::setSharable(CoverSearchResults* theWrappedObject, bool sharable) -{ - ( theWrappedObject->setSharable(sharable)); -} - -int PythonQtWrapper_CoverSearchResults::size(CoverSearchResults* theWrappedObject) const -{ - return ( theWrappedObject->size()); -} - -void PythonQtWrapper_CoverSearchResults::swap(CoverSearchResults* theWrappedObject, int i, int j) -{ - ( theWrappedObject->swap(i, j)); -} +return new PythonQtShell_CoverSearchResult(); } diff --git a/src/generated_cpp/clementine/clementine0.h b/src/generated_cpp/clementine/clementine0.h index 96df75b81..1aaf1dd2e 100644 --- a/src/generated_cpp/clementine/clementine0.h +++ b/src/generated_cpp/clementine/clementine0.h @@ -67,7 +67,7 @@ class PythonQtShell_CoverProvider : public CoverProvider public: PythonQtShell_CoverProvider(const QString& name, QObject* parent = &CoverProviders::instance()):CoverProvider(name, parent),_wrapper(NULL) {}; -virtual CoverSearchResults ParseReply(QNetworkReply* reply); +virtual QList ParseReply(QNetworkReply* reply); virtual QNetworkReply* SendRequest(const QString& query); virtual void childEvent(QChildEvent* arg__1); virtual void customEvent(QEvent* arg__1); @@ -133,31 +133,29 @@ void delete_CoverProviders(CoverProviders* obj) { delete obj; } -class PythonQtWrapper_CoverSearchResults : public QObject +class PythonQtShell_CoverSearchResult : public CoverSearchResult +{ +public: + PythonQtShell_CoverSearchResult():CoverSearchResult(),_wrapper(NULL) {}; + + + PythonQtInstanceWrapper* _wrapper; +}; + +class PythonQtWrapper_CoverSearchResult : public QObject { Q_OBJECT public: public slots: -CoverSearchResults* new_CoverSearchResults(); -CoverSearchResults* new_CoverSearchResults(const CoverSearchResults& other) { -CoverSearchResults* a = new CoverSearchResults(); -*((CoverSearchResults*)a) = other; +CoverSearchResult* new_CoverSearchResult(); +CoverSearchResult* new_CoverSearchResult(const CoverSearchResult& other) { +PythonQtShell_CoverSearchResult* a = new PythonQtShell_CoverSearchResult(); +*((CoverSearchResult*)a) = other; return a; } -void delete_CoverSearchResults(CoverSearchResults* obj) { delete obj; } - void clear(CoverSearchResults* theWrappedObject); - int count(CoverSearchResults* theWrappedObject) const; - void detachShared(CoverSearchResults* theWrappedObject); - bool empty(CoverSearchResults* theWrappedObject) const; - bool isEmpty(CoverSearchResults* theWrappedObject) const; - int length(CoverSearchResults* theWrappedObject) const; - void move(CoverSearchResults* theWrappedObject, int from, int to); - void pop_back(CoverSearchResults* theWrappedObject); - void pop_front(CoverSearchResults* theWrappedObject); - void removeAt(CoverSearchResults* theWrappedObject, int i); - void removeFirst(CoverSearchResults* theWrappedObject); - void removeLast(CoverSearchResults* theWrappedObject); - void setSharable(CoverSearchResults* theWrappedObject, bool sharable); - int size(CoverSearchResults* theWrappedObject) const; - void swap(CoverSearchResults* theWrappedObject, int i, int j); +void delete_CoverSearchResult(CoverSearchResult* obj) { delete obj; } +void py_set_description(CoverSearchResult* theWrappedObject, QString description){ theWrappedObject->description = description; } +QString py_get_description(CoverSearchResult* theWrappedObject){ return theWrappedObject->description; } +void py_set_image_url(CoverSearchResult* theWrappedObject, QString image_url){ theWrappedObject->image_url = image_url; } +QString py_get_image_url(CoverSearchResult* theWrappedObject){ return theWrappedObject->image_url; } }; diff --git a/src/generated_cpp/clementine/clementine_init.cpp b/src/generated_cpp/clementine/clementine_init.cpp index 096bca97a..657363e1c 100644 --- a/src/generated_cpp/clementine/clementine_init.cpp +++ b/src/generated_cpp/clementine/clementine_init.cpp @@ -7,7 +7,7 @@ PythonQt::priv()->registerClass(&AlbumCoverFetcherSearch::staticMetaObject, "Cle PythonQt::priv()->registerClass(&CoverProvider::staticMetaObject, "Clementine", PythonQtCreateObject, PythonQtSetInstanceWrapperOnShell, module, 0); PythonQt::priv()->registerClass(&CoverProviderFactory::staticMetaObject, "Clementine", PythonQtCreateObject, PythonQtSetInstanceWrapperOnShell, module, 0); PythonQt::priv()->registerClass(&CoverProviders::staticMetaObject, "Clementine", PythonQtCreateObject, NULL, module, 0); -PythonQt::priv()->registerCPPClass("CoverSearchResults", "", "Clementine", PythonQtCreateObject, NULL, module, 0); +PythonQt::priv()->registerCPPClass("CoverSearchResult", "", "Clementine", PythonQtCreateObject, PythonQtSetInstanceWrapperOnShell, module, 0); PythonQt::priv()->registerCPPClass("Directory", "", "Clementine", PythonQtCreateObject, PythonQtSetInstanceWrapperOnShell, module, 0); PythonQt::priv()->registerClass(&LibraryBackend::staticMetaObject, "Clementine", PythonQtCreateObject, PythonQtSetInstanceWrapperOnShell, module, 0); PythonQt::priv()->registerClass(&LibraryBackendInterface::staticMetaObject, "Clementine", PythonQtCreateObject, PythonQtSetInstanceWrapperOnShell, module, 0); diff --git a/src/main.cpp b/src/main.cpp index 56d9a9180..a67e824bf 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -37,6 +37,7 @@ #include "core/song.h" #include "core/taskmanager.h" #include "core/utilities.h" +#include "covers/albumcoverfetcher.h" #include "covers/artloader.h" #include "covers/coverproviders.h" #include "engines/enginebase.h" @@ -188,6 +189,8 @@ int main(int argc, char *argv[]) { g_type_init(); g_set_application_name(QCoreApplication::applicationName().toLocal8Bit()); + qRegisterMetaType("CoverSearchResult"); + qRegisterMetaType("CoverSearchResults"); qRegisterMetaType("Directory"); qRegisterMetaType("DirectoryList"); qRegisterMetaType("Subdirectory"); diff --git a/src/scripting/python/pythonengine.cpp b/src/scripting/python/pythonengine.cpp index 477c467e8..2cdde8948 100644 --- a/src/scripting/python/pythonengine.cpp +++ b/src/scripting/python/pythonengine.cpp @@ -29,6 +29,7 @@ #include "core/song.h" #include "core/player.h" #include "core/taskmanager.h" +#include "covers/albumcoverfetcher.h" #include "covers/coverproviders.h" #include "library/library.h" #include "library/librarybackend.h" @@ -94,6 +95,8 @@ bool PythonEngine::EnsureInitialised() { PythonQtConvertListOfValueTypeToPythonList); PythonQtConv::registerMetaTypeToPythonConverter(qMetaTypeId(), PythonQtConvertListOfValueTypeToPythonList); + PythonQtConv::registerMetaTypeToPythonConverter(qMetaTypeId(), + PythonQtConvertListOfValueTypeToPythonList); PythonQtConv::registerPythonToMetaTypeConverter(qMetaTypeId(), PythonQtConvertPythonListToListOfValueType); @@ -101,6 +104,8 @@ bool PythonEngine::EnsureInitialised() { PythonQtConvertPythonListToListOfValueType); PythonQtConv::registerPythonToMetaTypeConverter(qMetaTypeId(), PythonQtConvertPythonListToListOfValueType); + PythonQtConv::registerPythonToMetaTypeConverter(qMetaTypeId(), + PythonQtConvertPythonListToListOfValueType); connect(python_qt, SIGNAL(pythonStdOut(QString)), SLOT(PythonStdOut(QString))); connect(python_qt, SIGNAL(pythonStdErr(QString)), SLOT(PythonStdErr(QString))); diff --git a/src/scripting/python/typesystem_clementine.xml b/src/scripting/python/typesystem_clementine.xml index 904c44e27..7d18368b0 100644 --- a/src/scripting/python/typesystem_clementine.xml +++ b/src/scripting/python/typesystem_clementine.xml @@ -12,8 +12,7 @@ - - +