1
0
mirror of https://github.com/clementine-player/Clementine synced 2024-12-16 11:19:18 +01:00

some more corrections of the python API for cover providers; still not working ;)

This commit is contained in:
Paweł Bara 2011-05-21 12:19:35 +00:00
parent 5234798a7f
commit 46a411844a
7 changed files with 40 additions and 107 deletions

View File

@ -21,6 +21,7 @@
#include <QHash>
#include <QImage>
#include <QList>
#include <QMetaType>
#include <QNetworkAccessManager>
#include <QObject>
#include <QQueue>
@ -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<CoverSearchResult> 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.

View File

@ -148,15 +148,15 @@ void PythonQtWrapper_AlbumCoverFetcherSearch::Start(AlbumCoverFetcherSearch* the
CoverSearchResults PythonQtShell_CoverProvider::ParseReply(QNetworkReply* reply)
QList<CoverSearchResult > 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<CoverSearchResult >" , "QNetworkReply*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
CoverSearchResults returnValue;
QList<CoverSearchResult > 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<CoverSearchResult >*)args[0]);
}
}
}
@ -174,7 +174,7 @@ if (_wrapper) {
return returnValue;
}
}
return CoverSearchResults();
return QList<CoverSearchResult >();
}
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(); }

View File

@ -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<CoverSearchResult > 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; }
};

View File

@ -7,7 +7,7 @@ PythonQt::priv()->registerClass(&AlbumCoverFetcherSearch::staticMetaObject, "Cle
PythonQt::priv()->registerClass(&CoverProvider::staticMetaObject, "Clementine", PythonQtCreateObject<PythonQtWrapper_CoverProvider>, PythonQtSetInstanceWrapperOnShell<PythonQtShell_CoverProvider>, module, 0);
PythonQt::priv()->registerClass(&CoverProviderFactory::staticMetaObject, "Clementine", PythonQtCreateObject<PythonQtWrapper_CoverProviderFactory>, PythonQtSetInstanceWrapperOnShell<PythonQtShell_CoverProviderFactory>, module, 0);
PythonQt::priv()->registerClass(&CoverProviders::staticMetaObject, "Clementine", PythonQtCreateObject<PythonQtWrapper_CoverProviders>, NULL, module, 0);
PythonQt::priv()->registerCPPClass("CoverSearchResults", "", "Clementine", PythonQtCreateObject<PythonQtWrapper_CoverSearchResults>, NULL, module, 0);
PythonQt::priv()->registerCPPClass("CoverSearchResult", "", "Clementine", PythonQtCreateObject<PythonQtWrapper_CoverSearchResult>, PythonQtSetInstanceWrapperOnShell<PythonQtShell_CoverSearchResult>, module, 0);
PythonQt::priv()->registerCPPClass("Directory", "", "Clementine", PythonQtCreateObject<PythonQtWrapper_Directory>, PythonQtSetInstanceWrapperOnShell<PythonQtShell_Directory>, module, 0);
PythonQt::priv()->registerClass(&LibraryBackend::staticMetaObject, "Clementine", PythonQtCreateObject<PythonQtWrapper_LibraryBackend>, PythonQtSetInstanceWrapperOnShell<PythonQtShell_LibraryBackend>, module, 0);
PythonQt::priv()->registerClass(&LibraryBackendInterface::staticMetaObject, "Clementine", PythonQtCreateObject<PythonQtWrapper_LibraryBackendInterface>, PythonQtSetInstanceWrapperOnShell<PythonQtShell_LibraryBackendInterface>, module, 0);

View File

@ -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>("CoverSearchResult");
qRegisterMetaType<CoverSearchResults>("CoverSearchResults");
qRegisterMetaType<Directory>("Directory");
qRegisterMetaType<DirectoryList>("DirectoryList");
qRegisterMetaType<Subdirectory>("Subdirectory");

View File

@ -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<SongList, Song>);
PythonQtConv::registerMetaTypeToPythonConverter(qMetaTypeId<DirectoryList>(),
PythonQtConvertListOfValueTypeToPythonList<DirectoryList, Directory>);
PythonQtConv::registerMetaTypeToPythonConverter(qMetaTypeId<CoverSearchResults>(),
PythonQtConvertListOfValueTypeToPythonList<CoverSearchResults, CoverSearchResult>);
PythonQtConv::registerPythonToMetaTypeConverter(qMetaTypeId<SongList>(),
PythonQtConvertPythonListToListOfValueType<SongList, Song>);
@ -101,6 +104,8 @@ bool PythonEngine::EnsureInitialised() {
PythonQtConvertPythonListToListOfValueType<SongList, Song>);
PythonQtConv::registerPythonToMetaTypeConverter(qMetaTypeId<DirectoryList>(),
PythonQtConvertPythonListToListOfValueType<DirectoryList, Directory>);
PythonQtConv::registerPythonToMetaTypeConverter(qMetaTypeId<CoverSearchResults>(),
PythonQtConvertPythonListToListOfValueType<CoverSearchResults, CoverSearchResult>);
connect(python_qt, SIGNAL(pythonStdOut(QString)), SLOT(PythonStdOut(QString)));
connect(python_qt, SIGNAL(pythonStdErr(QString)), SLOT(PythonStdErr(QString)));

View File

@ -12,8 +12,7 @@
<enum-type name="Song::FileType" />
<enum-type name="UrlHandler_LoadResult::Type" />
<value-type name="CoverSearchResults" />
<value-type name="CoverSearchResult" />
<value-type name="Directory" />
<value-type name="LibraryBackendInterface::Album" />
<value-type name="QueryOptions" />