mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-13 09:34:53 +02:00
Add Qt5 variant for qobject2qvariant
This commit is contained in:
@@ -59,7 +59,7 @@ QVariant
|
||||
DatabaseCommand_CreateDynamicPlaylist::playlistV() const
|
||||
{
|
||||
if( m_v.isNull() )
|
||||
return QJson::QObjectHelper::qobject2qvariant( (QObject*)m_playlist.data() );
|
||||
return TomahawkUtils::qobject2qvariant( (QObject*)m_playlist.data() );
|
||||
else
|
||||
return m_v;
|
||||
}
|
||||
|
@@ -61,7 +61,7 @@ QVariant
|
||||
DatabaseCommand_CreatePlaylist::playlistV() const
|
||||
{
|
||||
if( m_v.isNull() )
|
||||
return QJson::QObjectHelper::qobject2qvariant( (QObject*)m_playlist.data() );
|
||||
return TomahawkUtils::qobject2qvariant( (QObject*)m_playlist.data() );
|
||||
else
|
||||
return m_v;
|
||||
}
|
||||
|
@@ -21,7 +21,6 @@
|
||||
|
||||
#include "Typedefs.h"
|
||||
#include "DatabaseCommandLoggable.h"
|
||||
#include "qjson/qobjecthelper.h"
|
||||
|
||||
#include "DllMacro.h"
|
||||
|
||||
|
@@ -80,7 +80,7 @@ DatabaseCommand_SetDynamicPlaylistRevision::controlsV()
|
||||
{
|
||||
foreach ( const dyncontrol_ptr& control, m_controls )
|
||||
{
|
||||
m_controlsV << QJson::QObjectHelper::qobject2qvariant( control.data() );
|
||||
m_controlsV << TomahawkUtils::qobject2qvariant( control.data() );
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -301,7 +301,7 @@ DatabaseCommand_SetPlaylistRevision::addedentriesV() const
|
||||
if ( !pe->isValid() )
|
||||
continue;
|
||||
|
||||
QVariant v = QJson::QObjectHelper::qobject2qvariant( pe.data() );
|
||||
QVariant v = TomahawkUtils::qobject2qvariant( pe.data() );
|
||||
vlist << v;
|
||||
}
|
||||
return vlist;
|
||||
|
@@ -21,7 +21,6 @@
|
||||
|
||||
#include "DatabaseCommandLoggable.h"
|
||||
#include "Playlist.h"
|
||||
#include "qjson/qobjecthelper.h"
|
||||
|
||||
#include "DllMacro.h"
|
||||
|
||||
|
@@ -279,7 +279,7 @@ DatabaseWorker::logOp( DatabaseCommandLoggable* command )
|
||||
oplogquery.prepare( "INSERT INTO oplog(source, guid, command, singleton, compressed, json) "
|
||||
"VALUES(?, ?, ?, ?, ?, ?)" );
|
||||
|
||||
QVariantMap variant = QJson::QObjectHelper::qobject2qvariant( command );
|
||||
QVariantMap variant = TomahawkUtils::qobject2qvariant( command );
|
||||
QByteArray ba = TomahawkUtils::toJson( variant );
|
||||
|
||||
// qDebug() << "OP JSON:" << ba.isNull() << ba << "from:" << variant; // debug
|
||||
|
@@ -25,8 +25,6 @@
|
||||
#include <QList>
|
||||
#include <QPointer>
|
||||
|
||||
#include <qjson/qobjecthelper.h>
|
||||
|
||||
#include "DatabaseCommand.h"
|
||||
|
||||
namespace Tomahawk
|
||||
|
@@ -848,6 +848,27 @@ compareVersionStrings( const QString& first, const QString& second )
|
||||
}
|
||||
|
||||
|
||||
QVariantMap
|
||||
qobject2qvariant( const QObject* object )
|
||||
{
|
||||
#if QT_VERSION >= QT_VERSION_CHECK( 5, 0, 0 )
|
||||
const QMetaObject* metaObject = object->metaObject();
|
||||
QVariantMap map;
|
||||
for ( int i = 0; i < metaObject->propertyCount(); ++i )
|
||||
{
|
||||
QMetaProperty metaproperty = metaObject->property( i );
|
||||
if ( metaproperty.isReadable() )
|
||||
{
|
||||
map[ QLatin1String( metaproperty.name() ) ] = object->property( metaproperty.name() );
|
||||
}
|
||||
}
|
||||
return map;
|
||||
#else
|
||||
return QJson::QObjectHelper::qobject2qvariant( object );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
qvariant2qobject( const QVariantMap& variant, QObject* object )
|
||||
{
|
||||
@@ -869,9 +890,8 @@ qvariant2qobject( const QVariantMap& variant, QObject* object )
|
||||
}
|
||||
}
|
||||
#else
|
||||
QJson::QObjectHelper::qvariant2qobject( variant, objects );
|
||||
QJson::QObjectHelper::qvariant2qobject( variant, object );
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@@ -208,6 +208,7 @@ namespace TomahawkUtils
|
||||
*/
|
||||
|
||||
/* QJson */
|
||||
DLLEXPORT QVariantMap qobject2qvariant( const QObject* object );
|
||||
DLLEXPORT void qvariant2qobject( const QVariantMap& variant, QObject* object );
|
||||
DLLEXPORT QVariant parseJson( const QByteArray& jsonData, bool* ok = 0 );
|
||||
DLLEXPORT QByteArray toJson( const QVariant &variant, bool* ok = 0 );
|
||||
|
Reference in New Issue
Block a user