cover providers are now recreated every search (this will lead to simpler API of theirs in a moment)

initial migration from SIP -> PythonQt in cover providers
This commit is contained in:
Paweł Bara 2011-05-17 17:53:36 +00:00
parent 69b2942566
commit d1d177769a
17 changed files with 864 additions and 31 deletions

View File

@ -98,6 +98,7 @@ set(SOURCES
covers/albumcoverloader.cpp
covers/artloader.cpp
covers/coverprovider.cpp
covers/coverproviderfactory.cpp
covers/coverproviders.cpp
covers/kittenloader.cpp
@ -319,6 +320,7 @@ set(HEADERS
covers/albumcoverloader.h
covers/artloader.h
covers/coverprovider.h
covers/coverproviderfactory.h
covers/coverproviders.h
covers/kittenloader.h
@ -600,6 +602,7 @@ endif(ENABLE_VISUALISATIONS)
if(HAVE_LIBLASTFM)
list(APPEND SOURCES
covers/lastfmcoverprovider.cpp
covers/lastfmcoverproviderfactory.cpp
radio/fixlastfm.cpp
radio/lastfmconfig.cpp
radio/lastfmservice.cpp
@ -612,6 +615,7 @@ if(HAVE_LIBLASTFM)
)
list(APPEND HEADERS
covers/lastfmcoverprovider.h
covers/lastfmcoverproviderfactory.h
radio/lastfmconfig.h
radio/lastfmservice.h
radio/lastfmstationdialog.h

View File

@ -54,7 +54,7 @@ void AlbumCoverFetcherSearch::TerminateSearch() {
}
void AlbumCoverFetcherSearch::Start() {
QList<CoverProvider*> providers_list = CoverProviders::instance().List();
QList<CoverProvider*> providers_list = CoverProviders::instance().List(this);
providers_left_ = providers_list.size();
// end this search before it even began if there are no providers...

View File

@ -0,0 +1,21 @@
/* This file is part of Clementine.
Copyright 2010, David Sansome <me@davidsansome.com>
Clementine is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Clementine is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
*/
#include "coverproviderfactory.h"
CoverProviderFactory::CoverProviderFactory(QObject* parent)
: QObject(parent) {}

View File

@ -0,0 +1,38 @@
/* This file is part of Clementine.
Copyright 2010, David Sansome <me@davidsansome.com>
Clementine is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Clementine is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef COVERPROVIDERFACTORY_H
#define COVERPROVIDERFACTORY_H
#include "coverproviders.h"
#include <QObject>
class AlbumCoverFetcherSearch;
class CoverProvider;
class CoverProviderFactory : public QObject {
Q_OBJECT
public:
CoverProviderFactory(QObject* parent = &CoverProviders::instance());
virtual ~CoverProviderFactory() {}
virtual CoverProvider* CreateCoverProvider(AlbumCoverFetcherSearch* parent) = 0;
};
#endif // COVERPROVIDERFACTORY_H

View File

@ -16,54 +16,58 @@
*/
#include "config.h"
#include "coverprovider.h"
#include "coverproviderfactory.h"
#include "coverproviders.h"
#ifdef HAVE_LIBLASTFM
# include "lastfmcoverprovider.h"
# include "lastfmcoverproviderfactory.h"
#endif
CoverProviders::CoverProviders()
{
// registering built-in providers...
// registering built-in provider factories...
// every built-in provider needs an explicit parent; otherwise,
// every built-in provider factory needs an explicit parent; otherwise,
// the default parent, namely CoverProviders::instance(), will
// cause an infinite recursion here
#ifdef HAVE_LIBLASTFM
cover_providers_.append(new LastFmCoverProvider(this));
cover_provider_factories_.append(new LastFmCoverProviderFactory(this));
#endif
}
void CoverProviders::AddCoverProvider(CoverProvider* provider) {
void CoverProviders::AddCoverProviderFactory(CoverProviderFactory* factory) {
{
QMutexLocker locker(&mutex_);
Q_UNUSED(locker);
cover_providers_.append(provider);
connect(provider, SIGNAL(destroyed()), SLOT(RemoveCoverProvider()));
cover_provider_factories_.append(factory);
connect(factory, SIGNAL(destroyed()), SLOT(RemoveCoverProviderFactory()));
}
}
void CoverProviders::RemoveCoverProvider() {
// qobject_cast doesn't work here with providers created by python
CoverProvider* provider = static_cast<CoverProvider*>(sender());
void CoverProviders::RemoveCoverProviderFactory() {
// qobject_cast doesn't work here with factories created by python
CoverProviderFactory* factory = static_cast<CoverProviderFactory*>(sender());
if (provider) {
if (factory) {
{
QMutexLocker locker(&mutex_);
Q_UNUSED(locker);
cover_providers_.removeAll(provider);
cover_provider_factories_.removeAll(factory);
}
}
}
const QList<CoverProvider*> CoverProviders::List() {
const QList<CoverProvider*> CoverProviders::List(AlbumCoverFetcherSearch* parent) {
{
QMutexLocker locker(&mutex_);
Q_UNUSED(locker);
return QList<CoverProvider*>(cover_providers_);
QList<CoverProvider*> result;
foreach(CoverProviderFactory* factory, cover_provider_factories_) {
result.append(factory->CreateCoverProvider(parent));
}
return result;
}
}

View File

@ -21,11 +21,13 @@
#include <QMutex>
#include <QObject>
class AlbumCoverFetcherSearch;
class CoverProvider;
class CoverProviderFactory;
// This is a singleton, a global repository for cover providers. Each one of those has to register
// with CoverProviders instance by invoking "CoverProviders::instance().AddCoverProvider(this)".
// Providers are automatically unregistered from the repository when they are deleted.
// This is a singleton, a global repository for factories of cover providers. Each one of those has to register
// with CoverProviders' instance by invoking "CoverProviders::instance().AddCoverProviderFactory(this)".
// Factories are automatically unregistered from the repository when they are deleted.
// The class is thread safe except for the initialization.
class CoverProviders : public QObject {
Q_OBJECT
@ -37,25 +39,26 @@ public:
return instance_;
}
// Let's a cover provider to register itself in the repository.
void AddCoverProvider(CoverProvider* provider);
// Let's a cover provider factory to register itself in the repository.
void AddCoverProviderFactory(CoverProviderFactory* factory);
// Returns a list of the currently registered cover providers.
const QList<CoverProvider*> List();
// Returns true if this repository has at least one registered provider.
bool HasAnyProviders() { return !List().isEmpty(); }
// Creates a list of cover providers, one for every registered factory. Providers that get created will
// be children of the given AlbumCoverFetcherSearch's instance.
QList<CoverProvider*> List(AlbumCoverFetcherSearch* parent);
// Returns true if this repository has at least one registered provider factory.
bool HasAnyProviderFactories() { return !cover_provider_factories_.isEmpty(); }
~CoverProviders() {}
private slots:
void RemoveCoverProvider();
void RemoveCoverProviderFactory();
private:
CoverProviders();
CoverProviders(CoverProviders const&);
void operator=(CoverProviders const&);
QList<CoverProvider*> cover_providers_;
QList<CoverProviderFactory*> cover_provider_factories_;
QMutex mutex_;
};

View File

@ -0,0 +1,28 @@
/* This file is part of Clementine.
Copyright 2010, David Sansome <me@davidsansome.com>
Clementine is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Clementine is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
*/
#include "albumcoverfetchersearch.h"
#include "coverproviderfactory.h"
#include "lastfmcoverprovider.h"
#include "lastfmcoverproviderfactory.h"
LastFmCoverProviderFactory::LastFmCoverProviderFactory(QObject* parent)
: CoverProviderFactory(parent) {}
CoverProvider* LastFmCoverProviderFactory::CreateCoverProvider(AlbumCoverFetcherSearch* parent) {
return new LastFmCoverProvider(parent);
}

View File

@ -0,0 +1,38 @@
/* This file is part of Clementine.
Copyright 2010, David Sansome <me@davidsansome.com>
Clementine is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Clementine is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef LASTFMCOVERPROVIDERFACTORY_H
#define LASTFMCOVERPROVIDERFACTORY_H
#include "coverproviderfactory.h"
#include <QObject>
class AlbumCoverFetcherSearch;
class CoverProvider;
class LastFmCoverProviderFactory : public CoverProviderFactory {
Q_OBJECT
public:
LastFmCoverProviderFactory(QObject* parent);
~LastFmCoverProviderFactory() {}
CoverProvider* CreateCoverProvider(AlbumCoverFetcherSearch* parent);
};
#endif // LASTFMCOVERPROVIDERFACTORY_H

View File

@ -1,5 +1,6 @@
include_directories(
${CMAKE_SOURCE_DIR}/src/core
${CMAKE_SOURCE_DIR}/src/covers
${CMAKE_SOURCE_DIR}/src/radio
${CMAKE_CURRENT_SOURCE_DIR}/clementine
${PYTHON_INCLUDE_DIRS}

View File

@ -3,11 +3,17 @@
#include <PythonQtMethodInfo.h>
#include <PythonQtSignalReceiver.h>
#include <QVariant>
#include <albumcoverfetcher.h>
#include <albumcoverfetchersearch.h>
#include <coverprovider.h>
#include <coverproviderfactory.h>
#include <coverproviders.h>
#include <qabstractitemmodel.h>
#include <qabstractnetworkcache.h>
#include <qbytearray.h>
#include <qcoreevent.h>
#include <qdatastream.h>
#include <qimage.h>
#include <qiodevice.h>
#include <qlist.h>
#include <qnetworkrequest.h>
@ -22,6 +28,543 @@
#include <radioservice.h>
#include <urlhandler.h>
void PythonQtShell_AlbumCoverFetcherSearch::childEvent(QChildEvent* arg__1)
{
if (_wrapper) {
PyObject* obj = PyObject_GetAttrString((PyObject*)_wrapper, "childEvent");
PyErr_Clear();
if (obj && !PythonQtSlotFunction_Check(obj)) {
static const char* argumentList[] ={"" , "QChildEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
}
}
AlbumCoverFetcherSearch::childEvent(arg__1);
}
void PythonQtShell_AlbumCoverFetcherSearch::customEvent(QEvent* arg__1)
{
if (_wrapper) {
PyObject* obj = PyObject_GetAttrString((PyObject*)_wrapper, "customEvent");
PyErr_Clear();
if (obj && !PythonQtSlotFunction_Check(obj)) {
static const char* argumentList[] ={"" , "QEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
}
}
AlbumCoverFetcherSearch::customEvent(arg__1);
}
bool PythonQtShell_AlbumCoverFetcherSearch::event(QEvent* arg__1)
{
if (_wrapper) {
PyObject* obj = PyObject_GetAttrString((PyObject*)_wrapper, "event");
PyErr_Clear();
if (obj && !PythonQtSlotFunction_Check(obj)) {
static const char* argumentList[] ={"bool" , "QEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
bool returnValue;
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) {
args[0] = PythonQtConv::ConvertPythonToQt(methodInfo->parameters().at(0), result, false, NULL, &returnValue);
if (args[0]!=&returnValue) {
if (args[0]==NULL) {
PythonQt::priv()->handleVirtualOverloadReturnError("event", methodInfo, result);
} else {
returnValue = *((bool*)args[0]);
}
}
}
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return returnValue;
}
}
return AlbumCoverFetcherSearch::event(arg__1);
}
bool PythonQtShell_AlbumCoverFetcherSearch::eventFilter(QObject* arg__1, QEvent* arg__2)
{
if (_wrapper) {
PyObject* obj = PyObject_GetAttrString((PyObject*)_wrapper, "eventFilter");
PyErr_Clear();
if (obj && !PythonQtSlotFunction_Check(obj)) {
static const char* argumentList[] ={"bool" , "QObject*" , "QEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(3, argumentList);
bool returnValue;
void* args[3] = {NULL, (void*)&arg__1, (void*)&arg__2};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) {
args[0] = PythonQtConv::ConvertPythonToQt(methodInfo->parameters().at(0), result, false, NULL, &returnValue);
if (args[0]!=&returnValue) {
if (args[0]==NULL) {
PythonQt::priv()->handleVirtualOverloadReturnError("eventFilter", methodInfo, result);
} else {
returnValue = *((bool*)args[0]);
}
}
}
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return returnValue;
}
}
return AlbumCoverFetcherSearch::eventFilter(arg__1, arg__2);
}
void PythonQtShell_AlbumCoverFetcherSearch::timerEvent(QTimerEvent* arg__1)
{
if (_wrapper) {
PyObject* obj = PyObject_GetAttrString((PyObject*)_wrapper, "timerEvent");
PyErr_Clear();
if (obj && !PythonQtSlotFunction_Check(obj)) {
static const char* argumentList[] ={"" , "QTimerEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
}
}
AlbumCoverFetcherSearch::timerEvent(arg__1);
}
void PythonQtWrapper_AlbumCoverFetcherSearch::Start(AlbumCoverFetcherSearch* theWrappedObject)
{
( theWrappedObject->Start());
}
CoverSearchResults 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 PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
CoverSearchResults returnValue;
void* args[2] = {NULL, (void*)&reply};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) {
args[0] = PythonQtConv::ConvertPythonToQt(methodInfo->parameters().at(0), result, false, NULL, &returnValue);
if (args[0]!=&returnValue) {
if (args[0]==NULL) {
PythonQt::priv()->handleVirtualOverloadReturnError("ParseReply", methodInfo, result);
} else {
returnValue = *((CoverSearchResults*)args[0]);
}
}
}
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return returnValue;
}
}
return CoverSearchResults();
}
QNetworkReply* PythonQtShell_CoverProvider::SendRequest(const QString& query)
{
if (_wrapper) {
PyObject* obj = PyObject_GetAttrString((PyObject*)_wrapper, "SendRequest");
PyErr_Clear();
if (obj && !PythonQtSlotFunction_Check(obj)) {
static const char* argumentList[] ={"QNetworkReply*" , "const QString&"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
QNetworkReply* returnValue;
void* args[2] = {NULL, (void*)&query};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) {
args[0] = PythonQtConv::ConvertPythonToQt(methodInfo->parameters().at(0), result, false, NULL, &returnValue);
if (args[0]!=&returnValue) {
if (args[0]==NULL) {
PythonQt::priv()->handleVirtualOverloadReturnError("SendRequest", methodInfo, result);
} else {
returnValue = *((QNetworkReply**)args[0]);
}
}
}
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return returnValue;
}
}
return 0;
}
void PythonQtShell_CoverProvider::childEvent(QChildEvent* arg__1)
{
if (_wrapper) {
PyObject* obj = PyObject_GetAttrString((PyObject*)_wrapper, "childEvent");
PyErr_Clear();
if (obj && !PythonQtSlotFunction_Check(obj)) {
static const char* argumentList[] ={"" , "QChildEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
}
}
CoverProvider::childEvent(arg__1);
}
void PythonQtShell_CoverProvider::customEvent(QEvent* arg__1)
{
if (_wrapper) {
PyObject* obj = PyObject_GetAttrString((PyObject*)_wrapper, "customEvent");
PyErr_Clear();
if (obj && !PythonQtSlotFunction_Check(obj)) {
static const char* argumentList[] ={"" , "QEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
}
}
CoverProvider::customEvent(arg__1);
}
bool PythonQtShell_CoverProvider::event(QEvent* arg__1)
{
if (_wrapper) {
PyObject* obj = PyObject_GetAttrString((PyObject*)_wrapper, "event");
PyErr_Clear();
if (obj && !PythonQtSlotFunction_Check(obj)) {
static const char* argumentList[] ={"bool" , "QEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
bool returnValue;
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) {
args[0] = PythonQtConv::ConvertPythonToQt(methodInfo->parameters().at(0), result, false, NULL, &returnValue);
if (args[0]!=&returnValue) {
if (args[0]==NULL) {
PythonQt::priv()->handleVirtualOverloadReturnError("event", methodInfo, result);
} else {
returnValue = *((bool*)args[0]);
}
}
}
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return returnValue;
}
}
return CoverProvider::event(arg__1);
}
bool PythonQtShell_CoverProvider::eventFilter(QObject* arg__1, QEvent* arg__2)
{
if (_wrapper) {
PyObject* obj = PyObject_GetAttrString((PyObject*)_wrapper, "eventFilter");
PyErr_Clear();
if (obj && !PythonQtSlotFunction_Check(obj)) {
static const char* argumentList[] ={"bool" , "QObject*" , "QEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(3, argumentList);
bool returnValue;
void* args[3] = {NULL, (void*)&arg__1, (void*)&arg__2};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) {
args[0] = PythonQtConv::ConvertPythonToQt(methodInfo->parameters().at(0), result, false, NULL, &returnValue);
if (args[0]!=&returnValue) {
if (args[0]==NULL) {
PythonQt::priv()->handleVirtualOverloadReturnError("eventFilter", methodInfo, result);
} else {
returnValue = *((bool*)args[0]);
}
}
}
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return returnValue;
}
}
return CoverProvider::eventFilter(arg__1, arg__2);
}
void PythonQtShell_CoverProvider::timerEvent(QTimerEvent* arg__1)
{
if (_wrapper) {
PyObject* obj = PyObject_GetAttrString((PyObject*)_wrapper, "timerEvent");
PyErr_Clear();
if (obj && !PythonQtSlotFunction_Check(obj)) {
static const char* argumentList[] ={"" , "QTimerEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
}
}
CoverProvider::timerEvent(arg__1);
}
CoverProvider* PythonQtWrapper_CoverProvider::new_CoverProvider(const QString& name, QObject* parent)
{
return new PythonQtShell_CoverProvider(name, parent); }
QString PythonQtWrapper_CoverProvider::name(CoverProvider* theWrappedObject) const
{
return ( theWrappedObject->name());
}
CoverProvider* PythonQtShell_CoverProviderFactory::CreateCoverProvider(AlbumCoverFetcherSearch* parent)
{
if (_wrapper) {
PyObject* obj = PyObject_GetAttrString((PyObject*)_wrapper, "CreateCoverProvider");
PyErr_Clear();
if (obj && !PythonQtSlotFunction_Check(obj)) {
static const char* argumentList[] ={"CoverProvider*" , "AlbumCoverFetcherSearch*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
CoverProvider* returnValue;
void* args[2] = {NULL, (void*)&parent};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) {
args[0] = PythonQtConv::ConvertPythonToQt(methodInfo->parameters().at(0), result, false, NULL, &returnValue);
if (args[0]!=&returnValue) {
if (args[0]==NULL) {
PythonQt::priv()->handleVirtualOverloadReturnError("CreateCoverProvider", methodInfo, result);
} else {
returnValue = *((CoverProvider**)args[0]);
}
}
}
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return returnValue;
}
}
return 0;
}
void PythonQtShell_CoverProviderFactory::childEvent(QChildEvent* arg__1)
{
if (_wrapper) {
PyObject* obj = PyObject_GetAttrString((PyObject*)_wrapper, "childEvent");
PyErr_Clear();
if (obj && !PythonQtSlotFunction_Check(obj)) {
static const char* argumentList[] ={"" , "QChildEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
}
}
CoverProviderFactory::childEvent(arg__1);
}
void PythonQtShell_CoverProviderFactory::customEvent(QEvent* arg__1)
{
if (_wrapper) {
PyObject* obj = PyObject_GetAttrString((PyObject*)_wrapper, "customEvent");
PyErr_Clear();
if (obj && !PythonQtSlotFunction_Check(obj)) {
static const char* argumentList[] ={"" , "QEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
}
}
CoverProviderFactory::customEvent(arg__1);
}
bool PythonQtShell_CoverProviderFactory::event(QEvent* arg__1)
{
if (_wrapper) {
PyObject* obj = PyObject_GetAttrString((PyObject*)_wrapper, "event");
PyErr_Clear();
if (obj && !PythonQtSlotFunction_Check(obj)) {
static const char* argumentList[] ={"bool" , "QEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
bool returnValue;
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) {
args[0] = PythonQtConv::ConvertPythonToQt(methodInfo->parameters().at(0), result, false, NULL, &returnValue);
if (args[0]!=&returnValue) {
if (args[0]==NULL) {
PythonQt::priv()->handleVirtualOverloadReturnError("event", methodInfo, result);
} else {
returnValue = *((bool*)args[0]);
}
}
}
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return returnValue;
}
}
return CoverProviderFactory::event(arg__1);
}
bool PythonQtShell_CoverProviderFactory::eventFilter(QObject* arg__1, QEvent* arg__2)
{
if (_wrapper) {
PyObject* obj = PyObject_GetAttrString((PyObject*)_wrapper, "eventFilter");
PyErr_Clear();
if (obj && !PythonQtSlotFunction_Check(obj)) {
static const char* argumentList[] ={"bool" , "QObject*" , "QEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(3, argumentList);
bool returnValue;
void* args[3] = {NULL, (void*)&arg__1, (void*)&arg__2};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) {
args[0] = PythonQtConv::ConvertPythonToQt(methodInfo->parameters().at(0), result, false, NULL, &returnValue);
if (args[0]!=&returnValue) {
if (args[0]==NULL) {
PythonQt::priv()->handleVirtualOverloadReturnError("eventFilter", methodInfo, result);
} else {
returnValue = *((bool*)args[0]);
}
}
}
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return returnValue;
}
}
return CoverProviderFactory::eventFilter(arg__1, arg__2);
}
void PythonQtShell_CoverProviderFactory::timerEvent(QTimerEvent* arg__1)
{
if (_wrapper) {
PyObject* obj = PyObject_GetAttrString((PyObject*)_wrapper, "timerEvent");
PyErr_Clear();
if (obj && !PythonQtSlotFunction_Check(obj)) {
static const char* argumentList[] ={"" , "QTimerEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
}
}
CoverProviderFactory::timerEvent(arg__1);
}
CoverProviderFactory* PythonQtWrapper_CoverProviderFactory::new_CoverProviderFactory(QObject* parent)
{
return new PythonQtShell_CoverProviderFactory(parent); }
void PythonQtWrapper_CoverProviders::AddCoverProviderFactory(CoverProviders* theWrappedObject, CoverProviderFactory* factory)
{
( theWrappedObject->AddCoverProviderFactory(factory));
}
bool PythonQtWrapper_CoverProviders::HasAnyProviderFactories(CoverProviders* theWrappedObject)
{
return ( theWrappedObject->HasAnyProviderFactories());
}
const QList<CoverProvider* > PythonQtWrapper_CoverProviders::List(CoverProviders* theWrappedObject, AlbumCoverFetcherSearch* parent)
{
return ( theWrappedObject->List(parent));
}
CoverProviders* PythonQtWrapper_CoverProviders::static_CoverProviders_instance()
{
return &(CoverProviders::instance());
}
CoverSearchResults* PythonQtWrapper_CoverSearchResults::new_CoverSearchResults()
{
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::reserve(CoverSearchResults* theWrappedObject, int size)
{
( theWrappedObject->reserve(size));
}
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));
}
void PythonQtShell_NetworkAccessManager::childEvent(QChildEvent* arg__1)
{
if (_wrapper) {

View File

@ -1,12 +1,18 @@
#include <PythonQt.h>
#include <QObject>
#include <QVariant>
#include <albumcoverfetcher.h>
#include <albumcoverfetchersearch.h>
#include <coverprovider.h>
#include <coverproviderfactory.h>
#include <coverproviders.h>
#include <network.h>
#include <qabstractitemmodel.h>
#include <qabstractnetworkcache.h>
#include <qbytearray.h>
#include <qcoreevent.h>
#include <qdatastream.h>
#include <qimage.h>
#include <qiodevice.h>
#include <qlist.h>
#include <qnetworkrequest.h>
@ -23,6 +29,134 @@
class PythonQtShell_AlbumCoverFetcherSearch : public AlbumCoverFetcherSearch
{
public:
virtual void childEvent(QChildEvent* arg__1);
virtual void customEvent(QEvent* arg__1);
virtual bool event(QEvent* arg__1);
virtual bool eventFilter(QObject* arg__1, QEvent* arg__2);
virtual void timerEvent(QTimerEvent* arg__1);
PythonQtInstanceWrapper* _wrapper;
};
class PythonQtWrapper_AlbumCoverFetcherSearch : public QObject
{ Q_OBJECT
public:
public slots:
void delete_AlbumCoverFetcherSearch(AlbumCoverFetcherSearch* obj) { delete obj; }
void Start(AlbumCoverFetcherSearch* theWrappedObject);
};
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 QNetworkReply* SendRequest(const QString& query);
virtual void childEvent(QChildEvent* arg__1);
virtual void customEvent(QEvent* arg__1);
virtual bool event(QEvent* arg__1);
virtual bool eventFilter(QObject* arg__1, QEvent* arg__2);
virtual void timerEvent(QTimerEvent* arg__1);
PythonQtInstanceWrapper* _wrapper;
};
class PythonQtWrapper_CoverProvider : public QObject
{ Q_OBJECT
public:
public slots:
CoverProvider* new_CoverProvider(const QString& name, QObject* parent = &CoverProviders::instance());
void delete_CoverProvider(CoverProvider* obj) { delete obj; }
QString name(CoverProvider* theWrappedObject) const;
};
class PythonQtShell_CoverProviderFactory : public CoverProviderFactory
{
public:
PythonQtShell_CoverProviderFactory(QObject* parent = &CoverProviders::instance()):CoverProviderFactory(parent),_wrapper(NULL) {};
virtual CoverProvider* CreateCoverProvider(AlbumCoverFetcherSearch* parent);
virtual void childEvent(QChildEvent* arg__1);
virtual void customEvent(QEvent* arg__1);
virtual bool event(QEvent* arg__1);
virtual bool eventFilter(QObject* arg__1, QEvent* arg__2);
virtual void timerEvent(QTimerEvent* arg__1);
PythonQtInstanceWrapper* _wrapper;
};
class PythonQtWrapper_CoverProviderFactory : public QObject
{ Q_OBJECT
public:
public slots:
CoverProviderFactory* new_CoverProviderFactory(QObject* parent = &CoverProviders::instance());
void delete_CoverProviderFactory(CoverProviderFactory* obj) { delete obj; }
};
class PythonQtWrapper_CoverProviders : public QObject
{ Q_OBJECT
public:
public slots:
void delete_CoverProviders(CoverProviders* obj) { delete obj; }
void AddCoverProviderFactory(CoverProviders* theWrappedObject, CoverProviderFactory* factory);
bool HasAnyProviderFactories(CoverProviders* theWrappedObject);
const QList<CoverProvider* > List(CoverProviders* theWrappedObject, AlbumCoverFetcherSearch* parent);
CoverProviders* static_CoverProviders_instance();
};
class PythonQtWrapper_CoverSearchResults : public QObject
{ Q_OBJECT
public:
public slots:
CoverSearchResults* new_CoverSearchResults();
CoverSearchResults* new_CoverSearchResults(const CoverSearchResults& other) {
CoverSearchResults* a = new CoverSearchResults();
*((CoverSearchResults*)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 reserve(CoverSearchResults* theWrappedObject, int size);
void setSharable(CoverSearchResults* theWrappedObject, bool sharable);
int size(CoverSearchResults* theWrappedObject) const;
void swap(CoverSearchResults* theWrappedObject, int i, int j);
};
class PythonQtShell_NetworkAccessManager : public NetworkAccessManager
{
public:

View File

@ -3,6 +3,11 @@
void PythonQt_init_Clementine(PyObject* module) {
PythonQt::priv()->registerClass(&AlbumCoverFetcherSearch::staticMetaObject, "Clementine", PythonQtCreateObject<PythonQtWrapper_AlbumCoverFetcherSearch>, PythonQtSetInstanceWrapperOnShell<PythonQtShell_AlbumCoverFetcherSearch>, module, 0);
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()->registerClass(&NetworkAccessManager::staticMetaObject, "Clementine", PythonQtCreateObject<PythonQtWrapper_NetworkAccessManager>, PythonQtSetInstanceWrapperOnShell<PythonQtShell_NetworkAccessManager>, module, 0);
PythonQt::priv()->registerClass(&NetworkTimeouts::staticMetaObject, "Clementine", PythonQtCreateObject<PythonQtWrapper_NetworkTimeouts>, PythonQtSetInstanceWrapperOnShell<PythonQtShell_NetworkTimeouts>, module, 0);
PythonQt::priv()->registerClass(&RadioModel::staticMetaObject, "Clementine", PythonQtCreateObject<PythonQtWrapper_RadioModel>, NULL, module, 0);

View File

@ -20,6 +20,11 @@
#include "core/network.h"
#include "core/urlhandler.h"
#include "covers/albumcoverfetcher.h"
#include "covers/albumcoverfetchersearch.h"
#include "covers/coverprovider.h"
#include "covers/coverproviderfactory.h"
#include "covers/coverproviders.h"
#include "radio/radiomodel.h"
#include "radio/radioservice.h"

View File

@ -9,8 +9,17 @@
<enum-type name="RadioService::AddMode" />
<enum-type name="UrlHandler::LoadResult::Type" />
<value-type name="CoverSearchResults" />
<value-type name="UrlHandler::LoadResult" />
<object-type name="AlbumCoverFetcherSearch">
<modify-function signature="timerEvent(QTimerEvent*)">
<remove/>
</modify-function>
</object-type>
<object-type name="CoverProvider" />
<object-type name="CoverProviderFactory" />
<object-type name="CoverProviders" />
<object-type name="NetworkAccessManager" />
<object-type name="NetworkTimeouts">
<modify-function signature="timerEvent(QTimerEvent*)">

View File

@ -258,7 +258,7 @@ void AlbumCoverManager::Reset() {
}
void AlbumCoverManager::ResetFetchCoversButton() {
ui_->fetch->setEnabled(CoverProviders::instance().HasAnyProviders());
ui_->fetch->setEnabled(CoverProviders::instance().HasAnyProviderFactories());
}
void AlbumCoverManager::ArtistChanged(QListWidgetItem* current) {
@ -454,7 +454,7 @@ bool AlbumCoverManager::eventFilter(QObject *obj, QEvent *event) {
album_cover_choice_controller_->cover_from_url_action()->setEnabled(context_menu_items_.size() == 1);
album_cover_choice_controller_->show_cover_action()->setEnabled(some_with_covers && context_menu_items_.size() == 1);
album_cover_choice_controller_->unset_cover_action()->setEnabled(some_with_covers);
album_cover_choice_controller_->search_for_cover_action()->setEnabled(CoverProviders::instance().HasAnyProviders());
album_cover_choice_controller_->search_for_cover_action()->setEnabled(CoverProviders::instance().HasAnyProviderFactories());
QContextMenuEvent* e = static_cast<QContextMenuEvent*>(event);
context_menu_->popup(e->globalPos());

View File

@ -430,7 +430,7 @@ void EditTagDialog::UpdateSummaryTab(const Song& song) {
else
ui_->filename->setText(song.url().toString());
album_cover_choice_controller_->search_for_cover_action()->setEnabled(CoverProviders::instance().HasAnyProviders());
album_cover_choice_controller_->search_for_cover_action()->setEnabled(CoverProviders::instance().HasAnyProviderFactories());
}
void EditTagDialog::UpdateStatisticsTab(const Song& song) {

View File

@ -379,7 +379,7 @@ void NowPlayingWidget::contextMenuEvent(QContextMenuEvent* e) {
// initial 'enabled' values depending on the kitty mode
album_cover_choice_controller_->cover_from_file_action()->setEnabled(!aww_);
album_cover_choice_controller_->cover_from_url_action()->setEnabled(!aww_);
album_cover_choice_controller_->search_for_cover_action()->setEnabled(!aww_ && CoverProviders::instance().HasAnyProviders());
album_cover_choice_controller_->search_for_cover_action()->setEnabled(!aww_ && CoverProviders::instance().HasAnyProviderFactories());
album_cover_choice_controller_->unset_cover_action()->setEnabled(!aww_);
album_cover_choice_controller_->show_cover_action()->setEnabled(!aww_);