mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-04-20 07:52:30 +02:00
* Removed old junk and cleaned up source: Never include tomahawkapp.h in libtomahawk.
This commit is contained in:
parent
c7c28b0dd7
commit
a7ef75633a
@ -34,10 +34,10 @@
|
||||
#include "QxtHttpServerConnector"
|
||||
#include "QxtHttpSessionManager"
|
||||
|
||||
#include "tomahawk/tomahawkplugin.h"
|
||||
#include "typedefs.h"
|
||||
#include "playlist.h"
|
||||
#include "resolver.h"
|
||||
#include "network/servent.h"
|
||||
|
||||
#include "utils/tomahawkutils.h"
|
||||
|
||||
@ -109,7 +109,6 @@ private:
|
||||
void startHTTP();
|
||||
|
||||
QList<Tomahawk::collection_ptr> m_collections;
|
||||
QList<TomahawkPlugin*> m_plugins;
|
||||
QList<Tomahawk::ExternalResolver*> m_scriptResolvers;
|
||||
|
||||
Database* m_database;
|
||||
|
@ -1,49 +0,0 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||
*
|
||||
* Tomahawk 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.
|
||||
*
|
||||
* Tomahawk 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 Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef TOMAHAWK_PLUGIN_H
|
||||
#define TOMAHAWK_PLUGIN_H
|
||||
|
||||
#include <QString>
|
||||
#include <QtPlugin>
|
||||
|
||||
#include "pluginapi.h"
|
||||
|
||||
class TomahawkPlugin
|
||||
{
|
||||
public:
|
||||
TomahawkPlugin(){};
|
||||
TomahawkPlugin(Tomahawk::PluginAPI * api)
|
||||
: m_api(api) {};
|
||||
|
||||
virtual TomahawkPlugin * factory(Tomahawk::PluginAPI * api) = 0;
|
||||
|
||||
virtual QString name() const = 0;
|
||||
virtual QString description() const = 0;
|
||||
|
||||
protected:
|
||||
Tomahawk::PluginAPI * api() const { return m_api; };
|
||||
|
||||
private:
|
||||
Tomahawk::PluginAPI * m_api;
|
||||
|
||||
};
|
||||
|
||||
Q_DECLARE_INTERFACE(TomahawkPlugin, "org.tomahawk.TomahawkPlugin/1.0")
|
||||
|
||||
#endif
|
@ -1,104 +0,0 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||
*
|
||||
* Tomahawk 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.
|
||||
*
|
||||
* Tomahawk 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 Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "remoteioconnection.h"
|
||||
#include <QFile>
|
||||
|
||||
RemoteIOConnection::RemoteIOConnection(Servent * s, FileTransferSession * fts)
|
||||
: Connection(s), m_fts(fts)
|
||||
{
|
||||
qDebug() << "CTOR " << id() ;
|
||||
}
|
||||
|
||||
RemoteIOConnection::~RemoteIOConnection()
|
||||
{
|
||||
qDebug() << "DTOR " << id() ;
|
||||
}
|
||||
|
||||
QString RemoteIOConnection::id() const
|
||||
{
|
||||
return QString("RemoteIOConnection[%1]").arg(m_fts->fid());
|
||||
}
|
||||
|
||||
void RemoteIOConnection::shutdown(bool wait)
|
||||
{
|
||||
Connection::shutdown(wait);
|
||||
/*if(!wait)
|
||||
{
|
||||
Connection::shutdown(wait);
|
||||
return;
|
||||
}
|
||||
qDebug() << id() << " shutdown requested - waiting until we've received all data TODO";
|
||||
*/
|
||||
}
|
||||
|
||||
void RemoteIOConnection::setup()
|
||||
{
|
||||
if(m_fts->type() == FileTransferSession::RECEIVING)
|
||||
{
|
||||
qDebug() << "RemoteIOConnection in RX mode";
|
||||
return;
|
||||
}
|
||||
|
||||
qDebug() << "RemoteIOConnection in TX mode, fid:" << m_fts->fid();
|
||||
|
||||
QString url("/tmp/test.mp3");
|
||||
qDebug() << "TODO map fid to file://, hardcoded for now";
|
||||
|
||||
qDebug() << "Opening for transmission:" << url;
|
||||
m_readdev = QSharedPointer<QFile>(new QFile(url));
|
||||
m_readdev->open(QIODevice::ReadOnly);
|
||||
if(!m_readdev->isOpen())
|
||||
{
|
||||
qDebug() << "WARNING file is not readable: " << url;
|
||||
shutdown();
|
||||
}
|
||||
// send chunks within our event loop, since we're not in our own thread
|
||||
sendSome();
|
||||
}
|
||||
|
||||
void RemoteIOConnection::handleMsg(QByteArray msg)
|
||||
{
|
||||
Q_ASSERT(m_fts->type() == FileTransferSession::RECEIVING);
|
||||
m_fts->iodevice()->addData(msg);
|
||||
if(msg.length()==0) qDebug() << "Got 0len msg. end?";
|
||||
}
|
||||
|
||||
|
||||
Connection * RemoteIOConnection::clone()
|
||||
{
|
||||
Q_ASSERT(false); return 0;
|
||||
};
|
||||
|
||||
|
||||
void RemoteIOConnection::sendSome()
|
||||
{
|
||||
Q_ASSERT(m_fts->type() == FileTransferSession::SENDING);
|
||||
if(m_readdev->atEnd())
|
||||
{
|
||||
qDebug() << "Sent all. DONE";
|
||||
shutdown(true);
|
||||
return;
|
||||
}
|
||||
QByteArray ba = m_readdev->read(4096);
|
||||
//qDebug() << "Sending " << ba.length() << " bytes of audiofile";
|
||||
sendMsg(ba);
|
||||
QTimer::singleShot(0, this, SLOT(sendSome()));
|
||||
}
|
||||
|
||||
|
@ -1,56 +0,0 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||
*
|
||||
* Tomahawk 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.
|
||||
*
|
||||
* Tomahawk 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 Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef REMOTEIOCONNECTION_H
|
||||
#define REMOTEIOCONNECTION_H
|
||||
|
||||
#include <QIODevice>
|
||||
#include <QMutex>
|
||||
#include <QWaitCondition>
|
||||
#include <QDebug>
|
||||
#include <QSharedPointer>
|
||||
|
||||
#include "controlconnection.h"
|
||||
#include "filetransfersession.h"
|
||||
|
||||
class RemoteIOConnection : public Connection
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
RemoteIOConnection(Servent * s, FileTransferSession * fts);
|
||||
~RemoteIOConnection();
|
||||
QString id() const;
|
||||
|
||||
|
||||
void shutdown(bool wait = false);
|
||||
void setup();
|
||||
void handleMsg(QByteArray msg);
|
||||
Connection * clone();
|
||||
|
||||
signals:
|
||||
|
||||
private slots:
|
||||
void sendSome();
|
||||
|
||||
private:
|
||||
|
||||
FileTransferSession * m_fts;
|
||||
QSharedPointer<QIODevice> m_readdev;
|
||||
};
|
||||
|
||||
#endif // REMOTEIOCONNECTION_H
|
@ -1,119 +0,0 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||
*
|
||||
* Tomahawk 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.
|
||||
*
|
||||
* Tomahawk 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 Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "remoteiodevice.h"
|
||||
|
||||
RemoteIODevice::RemoteIODevice(RemoteIOConnection * c)
|
||||
: m_eof(false), m_totalAdded(0), m_rioconn(c)
|
||||
{
|
||||
qDebug() << "CTOR RemoteIODevice";
|
||||
}
|
||||
|
||||
RemoteIODevice::~RemoteIODevice()
|
||||
{
|
||||
qDebug() << "DTOR RemoteIODevice";
|
||||
m_rioconn->shutdown();
|
||||
}
|
||||
|
||||
void RemoteIODevice::close()
|
||||
{
|
||||
qDebug() << "RemoteIODevice::close";
|
||||
QIODevice::close();
|
||||
deleteLater();
|
||||
}
|
||||
|
||||
bool RemoteIODevice::open ( OpenMode mode )
|
||||
{
|
||||
return QIODevice::open(mode & QIODevice::ReadOnly);
|
||||
}
|
||||
|
||||
qint64 RemoteIODevice::bytesAvailable () const
|
||||
{
|
||||
return m_buffer.length();
|
||||
}
|
||||
|
||||
bool RemoteIODevice::isSequential () const
|
||||
{
|
||||
return true;
|
||||
};
|
||||
|
||||
bool RemoteIODevice::atEnd() const
|
||||
{
|
||||
return m_eof && m_buffer.length() == 0;
|
||||
};
|
||||
|
||||
void RemoteIODevice::addData(QByteArray msg)
|
||||
{
|
||||
m_mut_recv.lock();
|
||||
if(msg.length()==0)
|
||||
{
|
||||
m_eof=true;
|
||||
//qDebug() << "addData finished, entire file received. EOF.";
|
||||
m_mut_recv.unlock();
|
||||
m_wait.wakeAll();
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_buffer.append(msg);
|
||||
m_totalAdded += msg.length();
|
||||
//qDebug() << "RemoteIODevice has seen in total: " << m_totalAdded ;
|
||||
m_mut_recv.unlock();
|
||||
m_wait.wakeAll();
|
||||
emit readyRead();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
qint64 RemoteIODevice::writeData ( const char * data, qint64 maxSize )
|
||||
{
|
||||
Q_ASSERT(false);
|
||||
return 0;
|
||||
}
|
||||
|
||||
qint64 RemoteIODevice::readData ( char * data, qint64 maxSize )
|
||||
{
|
||||
//qDebug() << "RemIO::readData, bytes in buffer: " << m_buffer.length();
|
||||
m_mut_recv.lock();
|
||||
if(m_eof && m_buffer.length() == 0)
|
||||
{
|
||||
// eof
|
||||
qDebug() << "readData called when EOF";
|
||||
m_mut_recv.unlock();
|
||||
return 0;
|
||||
}
|
||||
if(!m_buffer.length())// return 0;
|
||||
{
|
||||
//qDebug() << "WARNING readData when buffer is empty";
|
||||
m_mut_recv.unlock();
|
||||
return 0;
|
||||
}
|
||||
int len;
|
||||
if(maxSize>=m_buffer.length()) // whole buffer
|
||||
{
|
||||
len = m_buffer.length();
|
||||
memcpy(data, m_buffer.constData(), len);
|
||||
m_buffer.clear();
|
||||
} else { // partial
|
||||
len = maxSize;
|
||||
memcpy(data, m_buffer.constData(), len);
|
||||
m_buffer.remove(0,len);
|
||||
}
|
||||
m_mut_recv.unlock();
|
||||
return len;
|
||||
}
|
@ -1,61 +0,0 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||
*
|
||||
* Tomahawk 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.
|
||||
*
|
||||
* Tomahawk 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 Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef REMOTEIODEVICE_H
|
||||
#define REMOTEIODEVICE_H
|
||||
#include <QIODevice>
|
||||
#include <QMutex>
|
||||
#include <QWaitCondition>
|
||||
#include <QDebug>
|
||||
#include <QBuffer>
|
||||
#include "remoteioconnection.h"
|
||||
|
||||
class RemoteIOConnection;
|
||||
|
||||
class RemoteIODevice : public QIODevice
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
RemoteIODevice(RemoteIOConnection * c);
|
||||
~RemoteIODevice();
|
||||
virtual void close();
|
||||
virtual bool open ( OpenMode mode );
|
||||
qint64 bytesAvailable () const;
|
||||
virtual bool isSequential () const;
|
||||
virtual bool atEnd() const;
|
||||
|
||||
public slots:
|
||||
|
||||
void addData(QByteArray msg);
|
||||
|
||||
protected:
|
||||
|
||||
virtual qint64 writeData ( const char * data, qint64 maxSize );
|
||||
virtual qint64 readData ( char * data, qint64 maxSize );
|
||||
|
||||
private:
|
||||
QByteArray m_buffer;
|
||||
QMutex m_mut_wait, m_mut_recv;
|
||||
QWaitCondition m_wait;
|
||||
bool m_eof;
|
||||
int m_totalAdded;
|
||||
|
||||
RemoteIOConnection * m_rioconn;
|
||||
};
|
||||
#endif // REMOTEIODEVICE_H
|
@ -20,7 +20,6 @@ set( libSources
|
||||
album.cpp
|
||||
collection.cpp
|
||||
playlist.cpp
|
||||
pluginapi.cpp
|
||||
query.cpp
|
||||
result.cpp
|
||||
source.cpp
|
||||
@ -157,7 +156,6 @@ set( libHeaders
|
||||
functimeout.h
|
||||
|
||||
collection.h
|
||||
pluginapi.h
|
||||
query.h
|
||||
resolver.h
|
||||
result.h
|
||||
|
@ -26,7 +26,6 @@
|
||||
#include "dynamic/GeneratorInterface.h"
|
||||
|
||||
#include "network/servent.h"
|
||||
#include "tomahawk/tomahawkapp.h"
|
||||
#include "playlist/playlistmanager.h"
|
||||
|
||||
using namespace Tomahawk;
|
||||
|
@ -21,7 +21,6 @@
|
||||
#include <QSqlQuery>
|
||||
|
||||
#include "network/servent.h"
|
||||
#include "tomahawk/tomahawkapp.h"
|
||||
#include "playlist/playlistmanager.h"
|
||||
|
||||
using namespace Tomahawk;
|
||||
|
@ -18,11 +18,11 @@
|
||||
|
||||
#include "CollapsibleControls.h"
|
||||
|
||||
#include "tomahawk/tomahawkapp.h"
|
||||
#include "DynamicControlList.h"
|
||||
#include "DynamicControlWrapper.h"
|
||||
#include "dynamic/GeneratorInterface.h"
|
||||
#include "dynamic/DynamicControl.h"
|
||||
#include "utils/tomahawkutils.h"
|
||||
|
||||
#include <QLabel>
|
||||
#include <QStackedLayout>
|
||||
|
@ -25,11 +25,11 @@
|
||||
#include <QToolButton>
|
||||
#include <QPainter>
|
||||
#include <QGridLayout>
|
||||
#include <QHBoxLayout>
|
||||
|
||||
#include "DynamicControlWrapper.h"
|
||||
#include "dynamic/GeneratorInterface.h"
|
||||
#include "tomahawk/tomahawkapp.h"
|
||||
#include <QHBoxLayout>
|
||||
#include "utils/tomahawkutils.h"
|
||||
|
||||
using namespace Tomahawk;
|
||||
|
||||
|
@ -18,9 +18,10 @@
|
||||
|
||||
#include "DynamicControlWrapper.h"
|
||||
|
||||
#include "tomahawk/tomahawkapp.h"
|
||||
#include "dynamic/DynamicControl.h"
|
||||
#include "utils/tomahawkutils.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QHBoxLayout>
|
||||
#include <QComboBox>
|
||||
#include <QLayout>
|
||||
|
@ -18,14 +18,14 @@
|
||||
|
||||
#include "LoadingSpinner.h"
|
||||
|
||||
#include "tomahawk/tomahawkapp.h"
|
||||
|
||||
#include <QTimeLine>
|
||||
#include <QPaintEvent>
|
||||
#include <QPainter>
|
||||
#include <qmovie.h>
|
||||
#include <QLabel>
|
||||
|
||||
#include "utils/tomahawkutils.h"
|
||||
|
||||
#define ANIM_LENGTH 300
|
||||
|
||||
LoadingSpinner::LoadingSpinner( QWidget* parent )
|
||||
|
@ -1,64 +0,0 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||
*
|
||||
* Tomahawk 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.
|
||||
*
|
||||
* Tomahawk 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 Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "pluginapi.h"
|
||||
|
||||
#include "pipeline.h"
|
||||
#include "sourcelist.h"
|
||||
|
||||
using namespace Tomahawk;
|
||||
|
||||
|
||||
PluginAPI::PluginAPI( Pipeline* p )
|
||||
: m_pipeline( p )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/*void
|
||||
PluginAPI::reportResults( const QString& qid, const QList<QVariantMap>& vresults )
|
||||
{
|
||||
QList< result_ptr > results;
|
||||
foreach( QVariantMap m, vresults )
|
||||
{
|
||||
result_ptr rp( new Result( m ) );
|
||||
results.append( rp );
|
||||
}
|
||||
m_pipeline->reportResults( QID( qid ), results );
|
||||
}*/
|
||||
|
||||
|
||||
void
|
||||
PluginAPI::addSource( source_ptr s )
|
||||
{
|
||||
// SourceList::instance()->add( s );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
PluginAPI::removeSource( source_ptr s )
|
||||
{
|
||||
// SourceList::instance()->remove( s );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
PluginAPI::addResolver( Resolver* r )
|
||||
{
|
||||
Pipeline::instance()->addResolver( r );
|
||||
}
|
@ -1,67 +0,0 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||
*
|
||||
* Tomahawk 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.
|
||||
*
|
||||
* Tomahawk 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 Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef PLUGINAPI_H
|
||||
#define PLUGINAPI_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QSharedPointer>
|
||||
|
||||
#include "collection.h"
|
||||
#include "source.h"
|
||||
|
||||
#include "dllmacro.h"
|
||||
|
||||
/*
|
||||
This is the only API plugins have access to.
|
||||
This class must proxy calls to internal functions, because plugins can't
|
||||
get a pointer to any old object and start calling methods on it.
|
||||
*/
|
||||
|
||||
namespace Tomahawk
|
||||
{
|
||||
class Resolver;
|
||||
class Pipeline;
|
||||
|
||||
class DLLEXPORT PluginAPI : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit PluginAPI( Pipeline * p );
|
||||
|
||||
/// call every time new results are available for a running query
|
||||
// void reportResults( const QString& qid, const QList<QVariantMap>& results );
|
||||
|
||||
/// add/remove sources (which have collections)
|
||||
void addSource( source_ptr s );
|
||||
void removeSource( source_ptr s );
|
||||
|
||||
/// register object capable of searching
|
||||
void addResolver( Resolver * r );
|
||||
|
||||
Pipeline * pipeline() const { return m_pipeline; }
|
||||
|
||||
private:
|
||||
Pipeline * m_pipeline;
|
||||
};
|
||||
|
||||
|
||||
}; //ns
|
||||
|
||||
#endif // PLUGINAPI_H
|
@ -21,7 +21,7 @@
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include "pluginapi.h"
|
||||
#include "query.h"
|
||||
|
||||
#include "dllmacro.h"
|
||||
|
||||
@ -35,7 +35,6 @@
|
||||
*/
|
||||
namespace Tomahawk
|
||||
{
|
||||
class PluginAPI;
|
||||
|
||||
class DLLEXPORT Resolver : public QObject
|
||||
{
|
||||
@ -52,13 +51,8 @@ public:
|
||||
//virtual QWidget * configUI() { return 0; };
|
||||
//etc
|
||||
|
||||
PluginAPI * api() const { return m_api; }
|
||||
|
||||
public slots:
|
||||
virtual void resolve( const Tomahawk::query_ptr& query ) = 0;
|
||||
|
||||
private:
|
||||
PluginAPI * m_api;
|
||||
};
|
||||
|
||||
class DLLEXPORT ExternalResolver : public Resolver
|
||||
|
@ -1,539 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2007 Trolltech ASA. All rights reserved.
|
||||
**
|
||||
** This file is part of the Qt Concurrent project on Trolltech Labs.
|
||||
**
|
||||
** This file may be used under the terms of the GNU General Public
|
||||
** License version 2.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of
|
||||
** this file. Please review the following information to ensure GNU
|
||||
** General Public Licensing requirements will be met:
|
||||
** http://www.trolltech.com/products/qt/opensource.html
|
||||
**
|
||||
** If you are unsure which license is appropriate for your use, please
|
||||
** review the following information:
|
||||
** http://www.trolltech.com/products/qt/licensing.html or contact the
|
||||
** sales department at sales@trolltech.com.
|
||||
**
|
||||
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <QtGui/QtGui>
|
||||
|
||||
#include "modeltest.h"
|
||||
|
||||
Q_DECLARE_METATYPE(QModelIndex)
|
||||
|
||||
/*!
|
||||
Connect to all of the models signals. Whenever anything happens recheck everything.
|
||||
*/
|
||||
ModelTest::ModelTest(QAbstractItemModel *_model, QObject *parent) : QObject(parent), model(_model), fetchingMore(false)
|
||||
{
|
||||
Q_ASSERT(model);
|
||||
|
||||
connect(model, SIGNAL(columnsAboutToBeInserted(const QModelIndex &, int, int)),
|
||||
this, SLOT(runAllTests()));
|
||||
connect(model, SIGNAL(columnsAboutToBeRemoved(const QModelIndex &, int, int)),
|
||||
this, SLOT(runAllTests()));
|
||||
connect(model, SIGNAL(columnsInserted(const QModelIndex &, int, int)),
|
||||
this, SLOT(runAllTests()));
|
||||
connect(model, SIGNAL(columnsRemoved(const QModelIndex &, int, int)),
|
||||
this, SLOT(runAllTests()));
|
||||
connect(model, SIGNAL(dataChanged(const QModelIndex &, const QModelIndex &)),
|
||||
this, SLOT(runAllTests()));
|
||||
connect(model, SIGNAL(headerDataChanged(Qt::Orientation, int, int)),
|
||||
this, SLOT(runAllTests()));
|
||||
connect(model, SIGNAL(layoutAboutToBeChanged ()), this, SLOT(runAllTests()));
|
||||
connect(model, SIGNAL(layoutChanged ()), this, SLOT(runAllTests()));
|
||||
connect(model, SIGNAL(modelReset ()), this, SLOT(runAllTests()));
|
||||
connect(model, SIGNAL(rowsAboutToBeInserted(const QModelIndex &, int, int)),
|
||||
this, SLOT(runAllTests()));
|
||||
connect(model, SIGNAL(rowsAboutToBeRemoved(const QModelIndex &, int, int)),
|
||||
this, SLOT(runAllTests()));
|
||||
connect(model, SIGNAL(rowsInserted(const QModelIndex &, int, int)),
|
||||
this, SLOT(runAllTests()));
|
||||
connect(model, SIGNAL(rowsRemoved(const QModelIndex &, int, int)),
|
||||
this, SLOT(runAllTests()));
|
||||
|
||||
// Special checks for inserting/removing
|
||||
connect(model, SIGNAL(layoutAboutToBeChanged()),
|
||||
this, SLOT(layoutAboutToBeChanged()));
|
||||
connect(model, SIGNAL(layoutChanged()),
|
||||
this, SLOT(layoutChanged()));
|
||||
|
||||
connect(model, SIGNAL(rowsAboutToBeInserted(const QModelIndex &, int, int)),
|
||||
this, SLOT(rowsAboutToBeInserted(const QModelIndex &, int, int)));
|
||||
connect(model, SIGNAL(rowsAboutToBeRemoved(const QModelIndex &, int, int)),
|
||||
this, SLOT(rowsAboutToBeRemoved(const QModelIndex &, int, int)));
|
||||
connect(model, SIGNAL(rowsInserted(const QModelIndex &, int, int)),
|
||||
this, SLOT(rowsInserted(const QModelIndex &, int, int)));
|
||||
connect(model, SIGNAL(rowsRemoved(const QModelIndex &, int, int)),
|
||||
this, SLOT(rowsRemoved(const QModelIndex &, int, int)));
|
||||
|
||||
runAllTests();
|
||||
}
|
||||
|
||||
void ModelTest::runAllTests()
|
||||
{
|
||||
if (fetchingMore)
|
||||
return;
|
||||
nonDestructiveBasicTest();
|
||||
rowCount();
|
||||
columnCount();
|
||||
hasIndex();
|
||||
index();
|
||||
parent();
|
||||
data();
|
||||
}
|
||||
|
||||
/*!
|
||||
nonDestructiveBasicTest tries to call a number of the basic functions (not all)
|
||||
to make sure the model doesn't outright segfault, testing the functions that makes sense.
|
||||
*/
|
||||
void ModelTest::nonDestructiveBasicTest()
|
||||
{
|
||||
Q_ASSERT(model->buddy(QModelIndex()) == QModelIndex());
|
||||
model->canFetchMore(QModelIndex());
|
||||
Q_ASSERT(model->columnCount(QModelIndex()) >= 0);
|
||||
Q_ASSERT(model->data(QModelIndex()) == QVariant());
|
||||
fetchingMore = true;
|
||||
model->fetchMore(QModelIndex());
|
||||
fetchingMore = false;
|
||||
Qt::ItemFlags flags = model->flags(QModelIndex());
|
||||
Q_ASSERT(flags == Qt::ItemIsDropEnabled || flags == 0);
|
||||
model->hasChildren(QModelIndex());
|
||||
model->hasIndex(0, 0);
|
||||
model->headerData(0, Qt::Horizontal);
|
||||
model->index(0, 0);
|
||||
Q_ASSERT(model->index(-1, -1) == QModelIndex());
|
||||
model->itemData(QModelIndex());
|
||||
QVariant cache;
|
||||
model->match(QModelIndex(), -1, cache);
|
||||
model->mimeTypes();
|
||||
Q_ASSERT(model->parent(QModelIndex()) == QModelIndex());
|
||||
Q_ASSERT(model->rowCount() >= 0);
|
||||
QVariant variant;
|
||||
model->setData(QModelIndex(), variant, -1);
|
||||
model->setHeaderData(-1, Qt::Horizontal, QVariant());
|
||||
model->setHeaderData(0, Qt::Horizontal, QVariant());
|
||||
model->setHeaderData(999999, Qt::Horizontal, QVariant());
|
||||
QMap<int, QVariant> roles;
|
||||
model->sibling(0, 0, QModelIndex());
|
||||
model->span(QModelIndex());
|
||||
model->supportedDropActions();
|
||||
}
|
||||
|
||||
/*!
|
||||
Tests model's implementation of QAbstractItemModel::rowCount() and hasChildren()
|
||||
|
||||
Models that are dynamically populated are not as fully tested here.
|
||||
*/
|
||||
void ModelTest::rowCount()
|
||||
{
|
||||
// check top row
|
||||
QModelIndex topIndex = model->index(0, 0, QModelIndex());
|
||||
int rows = model->rowCount(topIndex);
|
||||
Q_ASSERT(rows >= 0);
|
||||
if (rows > 0)
|
||||
Q_ASSERT(model->hasChildren(topIndex) == true);
|
||||
|
||||
QModelIndex secondLevelIndex = model->index(0, 0, topIndex);
|
||||
if (secondLevelIndex.isValid()) { // not the top level
|
||||
// check a row count where parent is valid
|
||||
rows = model->rowCount(secondLevelIndex);
|
||||
Q_ASSERT(rows >= 0);
|
||||
if (rows > 0)
|
||||
Q_ASSERT(model->hasChildren(secondLevelIndex) == true);
|
||||
}
|
||||
|
||||
// The models rowCount() is tested more extensively in checkChildren(),
|
||||
// but this catches the big mistakes
|
||||
}
|
||||
|
||||
/*!
|
||||
Tests model's implementation of QAbstractItemModel::columnCount() and hasChildren()
|
||||
*/
|
||||
void ModelTest::columnCount()
|
||||
{
|
||||
// check top row
|
||||
QModelIndex topIndex = model->index(0, 0, QModelIndex());
|
||||
Q_ASSERT(model->columnCount(topIndex) >= 0);
|
||||
|
||||
// check a column count where parent is valid
|
||||
QModelIndex childIndex = model->index(0, 0, topIndex);
|
||||
if (childIndex.isValid())
|
||||
Q_ASSERT(model->columnCount(childIndex) >= 0);
|
||||
|
||||
// columnCount() is tested more extensively in checkChildren(),
|
||||
// but this catches the big mistakes
|
||||
}
|
||||
|
||||
/*!
|
||||
Tests model's implementation of QAbstractItemModel::hasIndex()
|
||||
*/
|
||||
void ModelTest::hasIndex()
|
||||
{
|
||||
// Make sure that invalid values returns an invalid index
|
||||
Q_ASSERT(model->hasIndex(-2, -2) == false);
|
||||
Q_ASSERT(model->hasIndex(-2, 0) == false);
|
||||
Q_ASSERT(model->hasIndex(0, -2) == false);
|
||||
|
||||
int rows = model->rowCount();
|
||||
int columns = model->columnCount();
|
||||
|
||||
// check out of bounds
|
||||
Q_ASSERT(model->hasIndex(rows, columns) == false);
|
||||
Q_ASSERT(model->hasIndex(rows + 1, columns + 1) == false);
|
||||
|
||||
if (rows > 0)
|
||||
Q_ASSERT(model->hasIndex(0, 0) == true);
|
||||
|
||||
// hasIndex() is tested more extensively in checkChildren(),
|
||||
// but this catches the big mistakes
|
||||
}
|
||||
|
||||
/*!
|
||||
Tests model's implementation of QAbstractItemModel::index()
|
||||
*/
|
||||
void ModelTest::index()
|
||||
{
|
||||
// Make sure that invalid values returns an invalid index
|
||||
Q_ASSERT(model->index(-2, -2) == QModelIndex());
|
||||
Q_ASSERT(model->index(-2, 0) == QModelIndex());
|
||||
Q_ASSERT(model->index(0, -2) == QModelIndex());
|
||||
|
||||
int rows = model->rowCount();
|
||||
int columns = model->columnCount();
|
||||
|
||||
if (rows == 0)
|
||||
return;
|
||||
|
||||
// Catch off by one errors
|
||||
Q_ASSERT(model->index(rows, columns) == QModelIndex());
|
||||
Q_ASSERT(model->index(0, 0).isValid() == true);
|
||||
|
||||
// Make sure that the same index is *always* returned
|
||||
QModelIndex a = model->index(0, 0);
|
||||
QModelIndex b = model->index(0, 0);
|
||||
Q_ASSERT(a == b);
|
||||
|
||||
// index() is tested more extensively in checkChildren(),
|
||||
// but this catches the big mistakes
|
||||
}
|
||||
|
||||
/*!
|
||||
Tests model's implementation of QAbstractItemModel::parent()
|
||||
*/
|
||||
void ModelTest::parent()
|
||||
{
|
||||
// Make sure the model wont crash and will return an invalid QModelIndex
|
||||
// when asked for the parent of an invalid index.
|
||||
Q_ASSERT(model->parent(QModelIndex()) == QModelIndex());
|
||||
|
||||
if (model->rowCount() == 0)
|
||||
return;
|
||||
|
||||
// Column 0 | Column 1 |
|
||||
// QModelIndex() | |
|
||||
// \- topIndex | topIndex1 |
|
||||
// \- childIndex | childIndex1 |
|
||||
|
||||
// Common error test #1, make sure that a top level index has a parent
|
||||
// that is a invalid QModelIndex.
|
||||
QModelIndex topIndex = model->index(0, 0, QModelIndex());
|
||||
Q_ASSERT(model->parent(topIndex) == QModelIndex());
|
||||
|
||||
// Common error test #2, make sure that a second level index has a parent
|
||||
// that is the first level index.
|
||||
if (model->rowCount(topIndex) > 0) {
|
||||
QModelIndex childIndex = model->index(0, 0, topIndex);
|
||||
Q_ASSERT(model->parent(childIndex) == topIndex);
|
||||
}
|
||||
|
||||
// Common error test #3, the second column should NOT have the same children
|
||||
// as the first column in a row.
|
||||
// Usually the second column shouldn't have children.
|
||||
QModelIndex topIndex1 = model->index(0, 1, QModelIndex());
|
||||
if (model->rowCount(topIndex1) > 0) {
|
||||
QModelIndex childIndex = model->index(0, 0, topIndex);
|
||||
QModelIndex childIndex1 = model->index(0, 0, topIndex1);
|
||||
Q_ASSERT(childIndex != childIndex1);
|
||||
}
|
||||
|
||||
// Full test, walk n levels deep through the model making sure that all
|
||||
// parent's children correctly specify their parent.
|
||||
checkChildren(QModelIndex());
|
||||
}
|
||||
|
||||
/*!
|
||||
Called from the parent() test.
|
||||
|
||||
A model that returns an index of parent X should also return X when asking
|
||||
for the parent of the index.
|
||||
|
||||
This recursive function does pretty extensive testing on the whole model in an
|
||||
effort to catch edge cases.
|
||||
|
||||
This function assumes that rowCount(), columnCount() and index() already work.
|
||||
If they have a bug it will point it out, but the above tests should have already
|
||||
found the basic bugs because it is easier to figure out the problem in
|
||||
those tests then this one.
|
||||
*/
|
||||
void ModelTest::checkChildren(const QModelIndex &parent, int currentDepth)
|
||||
{
|
||||
// First just try walking back up the tree.
|
||||
QModelIndex p = parent;
|
||||
while (p.isValid())
|
||||
p = p.parent();
|
||||
|
||||
// For models that are dynamically populated
|
||||
if (model->canFetchMore(parent)) {
|
||||
fetchingMore = true;
|
||||
model->fetchMore(parent);
|
||||
fetchingMore = false;
|
||||
}
|
||||
|
||||
int rows = model->rowCount(parent);
|
||||
int columns = model->columnCount(parent);
|
||||
|
||||
if (rows > 0)
|
||||
Q_ASSERT(model->hasChildren(parent));
|
||||
|
||||
// Some further testing against rows(), columns(), and hasChildren()
|
||||
Q_ASSERT(rows >= 0);
|
||||
Q_ASSERT(columns >= 0);
|
||||
if (rows > 0)
|
||||
Q_ASSERT(model->hasChildren(parent) == true);
|
||||
|
||||
//qDebug() << "parent:" << model->data(parent).toString() << "rows:" << rows
|
||||
// << "columns:" << columns << "parent column:" << parent.column();
|
||||
|
||||
Q_ASSERT(model->hasIndex(rows + 1, 0, parent) == false);
|
||||
for (int r = 0; r < rows; ++r) {
|
||||
if (model->canFetchMore(parent)) {
|
||||
fetchingMore = true;
|
||||
model->fetchMore(parent);
|
||||
fetchingMore = false;
|
||||
}
|
||||
Q_ASSERT(model->hasIndex(r, columns + 1, parent) == false);
|
||||
for (int c = 0; c < columns; ++c) {
|
||||
Q_ASSERT(model->hasIndex(r, c, parent) == true);
|
||||
QModelIndex index = model->index(r, c, parent);
|
||||
// rowCount() and columnCount() said that it existed...
|
||||
Q_ASSERT(index.isValid() == true);
|
||||
|
||||
// index() should always return the same index when called twice in a row
|
||||
QModelIndex modifiedIndex = model->index(r, c, parent);
|
||||
Q_ASSERT(index == modifiedIndex);
|
||||
|
||||
// Make sure we get the same index if we request it twice in a row
|
||||
QModelIndex a = model->index(r, c, parent);
|
||||
QModelIndex b = model->index(r, c, parent);
|
||||
Q_ASSERT(a == b);
|
||||
|
||||
// Some basic checking on the index that is returned
|
||||
Q_ASSERT(index.model() == model);
|
||||
Q_ASSERT(index.row() == r);
|
||||
Q_ASSERT(index.column() == c);
|
||||
// While you can technically return a QVariant usually this is a sign
|
||||
// of an bug in data() Disable if this really is ok in your model.
|
||||
//Q_ASSERT(model->data(index, Qt::DisplayRole).isValid() == true);
|
||||
|
||||
// If the next test fails here is some somewhat useful debug you play with.
|
||||
/*
|
||||
if (model->parent(index) != parent) {
|
||||
qDebug() << r << c << currentDepth << model->data(index).toString()
|
||||
<< model->data(parent).toString();
|
||||
qDebug() << index << parent << model->parent(index);
|
||||
// And a view that you can even use to show the model.
|
||||
//QTreeView view;
|
||||
//view.setModel(model);
|
||||
//view.show();
|
||||
}*/
|
||||
|
||||
// Check that we can get back our real parent.
|
||||
QModelIndex p = model->parent(index);
|
||||
//qDebug() << "child:" << index;
|
||||
//qDebug() << p;
|
||||
//qDebug() << parent;
|
||||
Q_ASSERT(model->parent(index) == parent);
|
||||
|
||||
// recursively go down the children
|
||||
if (model->hasChildren(index) && currentDepth < 10 ) {
|
||||
//qDebug() << r << c << "has children" << model->rowCount(index);
|
||||
checkChildren(index, ++currentDepth);
|
||||
}/* else { if (currentDepth >= 10) qDebug() << "checked 10 deep"; };*/
|
||||
|
||||
// make sure that after testing the children that the index doesn't change.
|
||||
QModelIndex newerIndex = model->index(r, c, parent);
|
||||
Q_ASSERT(index == newerIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
Tests model's implementation of QAbstractItemModel::data()
|
||||
*/
|
||||
void ModelTest::data()
|
||||
{
|
||||
// Invalid index should return an invalid qvariant
|
||||
Q_ASSERT(!model->data(QModelIndex()).isValid());
|
||||
|
||||
if (model->rowCount() == 0)
|
||||
return;
|
||||
|
||||
// A valid index should have a valid QVariant data
|
||||
Q_ASSERT(model->index(0, 0).isValid());
|
||||
|
||||
// shouldn't be able to set data on an invalid index
|
||||
Q_ASSERT(model->setData(QModelIndex(), QLatin1String("foo"), Qt::DisplayRole) == false);
|
||||
|
||||
// General Purpose roles that should return a QString
|
||||
QVariant variant = model->data(model->index(0, 0), Qt::ToolTipRole);
|
||||
if (variant.isValid()) {
|
||||
Q_ASSERT(qVariantCanConvert<QString>(variant));
|
||||
}
|
||||
variant = model->data(model->index(0, 0), Qt::StatusTipRole);
|
||||
if (variant.isValid()) {
|
||||
Q_ASSERT(qVariantCanConvert<QString>(variant));
|
||||
}
|
||||
variant = model->data(model->index(0, 0), Qt::WhatsThisRole);
|
||||
if (variant.isValid()) {
|
||||
Q_ASSERT(qVariantCanConvert<QString>(variant));
|
||||
}
|
||||
|
||||
// General Purpose roles that should return a QSize
|
||||
variant = model->data(model->index(0, 0), Qt::SizeHintRole);
|
||||
if (variant.isValid()) {
|
||||
Q_ASSERT(qVariantCanConvert<QSize>(variant));
|
||||
}
|
||||
|
||||
// General Purpose roles that should return a QFont
|
||||
QVariant fontVariant = model->data(model->index(0, 0), Qt::FontRole);
|
||||
if (fontVariant.isValid()) {
|
||||
Q_ASSERT(qVariantCanConvert<QFont>(fontVariant));
|
||||
}
|
||||
|
||||
// Check that the alignment is one we know about
|
||||
QVariant textAlignmentVariant = model->data(model->index(0, 0), Qt::TextAlignmentRole);
|
||||
if (textAlignmentVariant.isValid()) {
|
||||
int alignment = textAlignmentVariant.toInt();
|
||||
Q_ASSERT(alignment == Qt::AlignLeft ||
|
||||
alignment == Qt::AlignRight ||
|
||||
alignment == Qt::AlignHCenter ||
|
||||
alignment == Qt::AlignJustify ||
|
||||
alignment == Qt::AlignTop ||
|
||||
alignment == Qt::AlignBottom ||
|
||||
alignment == Qt::AlignVCenter ||
|
||||
alignment == Qt::AlignCenter ||
|
||||
alignment == Qt::AlignAbsolute ||
|
||||
alignment == Qt::AlignLeading ||
|
||||
alignment == Qt::AlignTrailing);
|
||||
}
|
||||
|
||||
// General Purpose roles that should return a QColor
|
||||
QVariant colorVariant = model->data(model->index(0, 0), Qt::BackgroundColorRole);
|
||||
if (colorVariant.isValid()) {
|
||||
Q_ASSERT(qVariantCanConvert<QColor>(colorVariant));
|
||||
}
|
||||
|
||||
colorVariant = model->data(model->index(0, 0), Qt::TextColorRole);
|
||||
if (colorVariant.isValid()) {
|
||||
Q_ASSERT(qVariantCanConvert<QColor>(colorVariant));
|
||||
}
|
||||
|
||||
// Check that the "check state" is one we know about.
|
||||
QVariant checkStateVariant = model->data(model->index(0, 0), Qt::CheckStateRole);
|
||||
if (checkStateVariant.isValid()) {
|
||||
int state = checkStateVariant.toInt();
|
||||
Q_ASSERT(state == Qt::Unchecked ||
|
||||
state == Qt::PartiallyChecked ||
|
||||
state == Qt::Checked);
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
Store what is about to be inserted to make sure it actually happens
|
||||
|
||||
\sa rowsInserted()
|
||||
*/
|
||||
void ModelTest::rowsAboutToBeInserted(const QModelIndex &parent, int start, int end)
|
||||
{
|
||||
Q_UNUSED(end);
|
||||
Changing c;
|
||||
c.parent = parent;
|
||||
c.oldSize = model->rowCount(parent);
|
||||
c.last = model->data(model->index(start - 1, 0, parent));
|
||||
c.next = model->data(model->index(start, 0, parent));
|
||||
insert.push(c);
|
||||
}
|
||||
|
||||
/*!
|
||||
Confirm that what was said was going to happen actually did
|
||||
|
||||
\sa rowsAboutToBeInserted()
|
||||
*/
|
||||
void ModelTest::rowsInserted(const QModelIndex & parent, int start, int end)
|
||||
{
|
||||
Changing c = insert.pop();
|
||||
Q_ASSERT(c.parent == parent);
|
||||
Q_ASSERT(c.oldSize + (end - start + 1) == model->rowCount(parent));
|
||||
Q_ASSERT(c.last == model->data(model->index(start - 1, 0, c.parent)));
|
||||
/*
|
||||
if (c.next != model->data(model->index(end + 1, 0, c.parent))) {
|
||||
qDebug() << start << end;
|
||||
for (int i=0; i < model->rowCount(); ++i)
|
||||
qDebug() << model->index(i, 0).data().toString();
|
||||
qDebug() << c.next << model->data(model->index(end + 1, 0, c.parent));
|
||||
}
|
||||
*/
|
||||
Q_ASSERT(c.next == model->data(model->index(end + 1, 0, c.parent)));
|
||||
}
|
||||
|
||||
void ModelTest::layoutAboutToBeChanged()
|
||||
{
|
||||
for (int i = 0; i < qBound(0, model->rowCount(), 100); ++i)
|
||||
changing.append(QPersistentModelIndex(model->index(i, 0)));
|
||||
}
|
||||
|
||||
void ModelTest::layoutChanged()
|
||||
{
|
||||
for (int i = 0; i < changing.count(); ++i) {
|
||||
QPersistentModelIndex p = changing[i];
|
||||
Q_ASSERT(p == model->index(p.row(), p.column(), p.parent()));
|
||||
}
|
||||
changing.clear();
|
||||
}
|
||||
|
||||
/*!
|
||||
Store what is about to be inserted to make sure it actually happens
|
||||
|
||||
\sa rowsRemoved()
|
||||
*/
|
||||
void ModelTest::rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end)
|
||||
{
|
||||
Changing c;
|
||||
c.parent = parent;
|
||||
c.oldSize = model->rowCount(parent);
|
||||
c.last = model->data(model->index(start - 1, 0, parent));
|
||||
c.next = model->data(model->index(end + 1, 0, parent));
|
||||
remove.push(c);
|
||||
}
|
||||
|
||||
/*!
|
||||
Confirm that what was said was going to happen actually did
|
||||
|
||||
\sa rowsAboutToBeRemoved()
|
||||
*/
|
||||
void ModelTest::rowsRemoved(const QModelIndex & parent, int start, int end)
|
||||
{
|
||||
Changing c = remove.pop();
|
||||
Q_ASSERT(c.parent == parent);
|
||||
Q_ASSERT(c.oldSize - (end - start + 1) == model->rowCount(parent));
|
||||
Q_ASSERT(c.last == model->data(model->index(start - 1, 0, c.parent)));
|
||||
Q_ASSERT(c.next == model->data(model->index(start, 0, c.parent)));
|
||||
}
|
||||
|
@ -1,76 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2007 Trolltech ASA. All rights reserved.
|
||||
**
|
||||
** This file is part of the Qt Concurrent project on Trolltech Labs.
|
||||
**
|
||||
** This file may be used under the terms of the GNU General Public
|
||||
** License version 2.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of
|
||||
** this file. Please review the following information to ensure GNU
|
||||
** General Public Licensing requirements will be met:
|
||||
** http://www.trolltech.com/products/qt/opensource.html
|
||||
**
|
||||
** If you are unsure which license is appropriate for your use, please
|
||||
** review the following information:
|
||||
** http://www.trolltech.com/products/qt/licensing.html or contact the
|
||||
** sales department at sales@trolltech.com.
|
||||
**
|
||||
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef MODELTEST_H
|
||||
#define MODELTEST_H
|
||||
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QAbstractItemModel>
|
||||
#include <QtCore/QStack>
|
||||
|
||||
class ModelTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ModelTest(QAbstractItemModel *model, QObject *parent = 0);
|
||||
|
||||
private Q_SLOTS:
|
||||
void nonDestructiveBasicTest();
|
||||
void rowCount();
|
||||
void columnCount();
|
||||
void hasIndex();
|
||||
void index();
|
||||
void parent();
|
||||
void data();
|
||||
|
||||
protected Q_SLOTS:
|
||||
void runAllTests();
|
||||
void layoutAboutToBeChanged();
|
||||
void layoutChanged();
|
||||
void rowsAboutToBeInserted(const QModelIndex &parent, int start, int end);
|
||||
void rowsInserted(const QModelIndex & parent, int start, int end);
|
||||
void rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end);
|
||||
void rowsRemoved(const QModelIndex & parent, int start, int end);
|
||||
|
||||
private:
|
||||
void checkChildren(const QModelIndex &parent, int currentDepth = 0);
|
||||
|
||||
QAbstractItemModel *model;
|
||||
|
||||
struct Changing
|
||||
{
|
||||
QModelIndex parent;
|
||||
int oldSize;
|
||||
QVariant last;
|
||||
QVariant next;
|
||||
};
|
||||
QStack<Changing> insert;
|
||||
QStack<Changing> remove;
|
||||
|
||||
bool fetchingMore;
|
||||
|
||||
QList<QPersistentModelIndex> changing;
|
||||
};
|
||||
|
||||
#endif
|
@ -1,45 +0,0 @@
|
||||
project( tomahawk )
|
||||
cmake_minimum_required(VERSION 2.6)
|
||||
find_package( Qt4 REQUIRED )
|
||||
|
||||
include( ${QT_USE_FILE} )
|
||||
|
||||
|
||||
SET(TOMAHAWK_INC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../include/")
|
||||
|
||||
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${TOMAHAWK_INC_DIR}/..")
|
||||
|
||||
set(cpps
|
||||
fakeplugin.cpp
|
||||
fakecollection.cpp
|
||||
)
|
||||
|
||||
set(hs
|
||||
fakeplugin.h
|
||||
fakecollection.h
|
||||
)
|
||||
|
||||
include_directories(
|
||||
.
|
||||
..
|
||||
${TOMAHAWK_INC_DIR}
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
${QT_INCLUDE_DIR}
|
||||
)
|
||||
|
||||
qt4_wrap_cpp( mocs ${hs} )
|
||||
|
||||
ADD_DEFINITIONS(${QT_DEFINITIONS})
|
||||
ADD_DEFINITIONS(-DQT_PLUGIN)
|
||||
#ADD_DEFINITIONS(-DQT_NO_DEBUG)
|
||||
ADD_DEFINITIONS(-DQT_SHARED)
|
||||
|
||||
add_library(fake SHARED
|
||||
${cpps}
|
||||
${mocs}
|
||||
)
|
||||
|
||||
target_link_libraries(fake
|
||||
${QT_LIBRARIES}
|
||||
${QT_QTSQL_LIBRARIES}
|
||||
)
|
@ -1,45 +0,0 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||
*
|
||||
* Tomahawk 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.
|
||||
*
|
||||
* Tomahawk 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 Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "fakecollection.h"
|
||||
#include "tomahawk/functimeout.h"
|
||||
|
||||
FakeCollection::FakeCollection(QObject *parent) :
|
||||
Collection("FakeCollection", parent)
|
||||
{
|
||||
}
|
||||
|
||||
void FakeCollection::load()
|
||||
{
|
||||
QList<QVariantMap> tracks;
|
||||
QVariantMap t1, t2, t3;
|
||||
t1["artist"] = "0AAAAAArtist 1";
|
||||
t1["track"] = "0TTTTTTrack 1";
|
||||
t1["album"] = "0AAAAAAlbum 1";
|
||||
t1["url"] = "fake://1";
|
||||
t1["filesize"] = 5000000;
|
||||
t1["duration"] = 300;
|
||||
t1["bitrate"] = 192;
|
||||
tracks << t1;
|
||||
|
||||
new Tomahawk::FuncTimeout(5000, boost::bind(&FakeCollection::removeTracks,
|
||||
this, tracks));
|
||||
|
||||
addTracks(tracks);
|
||||
reportFinishedLoading();
|
||||
}
|
@ -1,41 +0,0 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||
*
|
||||
* Tomahawk 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.
|
||||
*
|
||||
* Tomahawk 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 Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef FAKECOLLECTION_H
|
||||
#define FAKECOLLECTION_H
|
||||
#include "tomahawk/collection.h"
|
||||
|
||||
class FakeCollection : public Collection
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit FakeCollection(QObject *parent = 0);
|
||||
~FakeCollection()
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
}
|
||||
|
||||
virtual void load();
|
||||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
|
||||
};
|
||||
|
||||
#endif // FAKECOLLECTION_H
|
@ -1,44 +0,0 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||
*
|
||||
* Tomahawk 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.
|
||||
*
|
||||
* Tomahawk 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 Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "fakeplugin.h"
|
||||
#include "fakecollection.h"
|
||||
|
||||
Q_EXPORT_PLUGIN2(fake, FakePlugin)
|
||||
|
||||
FakePlugin::FakePlugin(Tomahawk::PluginAPI* api)
|
||||
: TomahawkPlugin(api), m_api(api)
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
TomahawkPlugin *
|
||||
FakePlugin::factory(Tomahawk::PluginAPI* api)
|
||||
{
|
||||
return new FakePlugin(api);
|
||||
}
|
||||
|
||||
void FakePlugin::init()
|
||||
{
|
||||
source_ptr src(new Source("Mr. Fake"));
|
||||
collection_ptr coll(new FakeCollection);
|
||||
src->addCollection(coll);
|
||||
m_api->addSource(src);
|
||||
coll->load();
|
||||
};
|
||||
|
@ -1,49 +0,0 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||
*
|
||||
* Tomahawk 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.
|
||||
*
|
||||
* Tomahawk 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 Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef TOMAHAWK_LIB_PLUGIN_H
|
||||
#define TOMAHAWK_LIB_PLUGIN_H
|
||||
#include <QtPlugin>
|
||||
|
||||
#include "tomahawk/plugin_includes.h"
|
||||
|
||||
class FakePlugin : public QObject, public TomahawkPlugin
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(TomahawkPlugin)
|
||||
|
||||
public:
|
||||
|
||||
FakePlugin(){};
|
||||
|
||||
FakePlugin(Tomahawk::PluginAPI* api);
|
||||
TomahawkPlugin * factory(Tomahawk::PluginAPI* api);
|
||||
QString name() const { return "FakePlugin"; };
|
||||
QString description() const { return "Fake stuff, hardcoded"; };
|
||||
|
||||
private:
|
||||
|
||||
void init();
|
||||
|
||||
Tomahawk::PluginAPI* m_api;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -23,6 +23,7 @@
|
||||
|
||||
#include "tomahawk/tomahawkapp.h"
|
||||
#include "artist.h"
|
||||
#include "source.h"
|
||||
#include "network/filetransferconnection.h"
|
||||
#include "network/servent.h"
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user