mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-18 23:09:42 +01:00
Merge TomahawkSetting*::registerCustomSettingsHandlers
This commit is contained in:
parent
01401816c8
commit
68a225eeaa
@ -1546,10 +1546,54 @@ QMap<QString, QVariant> TomahawkSettings::lastChartIds(){
|
||||
}
|
||||
|
||||
|
||||
inline QDataStream&
|
||||
operator<<( QDataStream& out, const AtticaManager::StateHash& states )
|
||||
{
|
||||
out << TOMAHAWK_SETTINGS_VERSION;
|
||||
out << (quint32)states.count();
|
||||
foreach( const QString& key, states.keys() )
|
||||
{
|
||||
AtticaManager::Resolver resolver = states[ key ];
|
||||
out << key << resolver.version << resolver.scriptPath << (qint32)resolver.state << resolver.userRating << resolver.binary;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
inline QDataStream&
|
||||
operator>>( QDataStream& in, AtticaManager::StateHash& states )
|
||||
{
|
||||
quint32 count = 0, configVersion = 0;
|
||||
in >> configVersion;
|
||||
in >> count;
|
||||
for ( uint i = 0; i < count; i++ )
|
||||
{
|
||||
QString key, version, scriptPath;
|
||||
qint32 state, userRating;
|
||||
bool binary = false;
|
||||
in >> key;
|
||||
in >> version;
|
||||
in >> scriptPath;
|
||||
in >> state;
|
||||
in >> userRating;
|
||||
if ( configVersion > 10 )
|
||||
{
|
||||
// V11 includes 'bool binary' flag
|
||||
in >> binary;
|
||||
}
|
||||
states[ key ] = AtticaManager::Resolver( version, scriptPath, userRating, (AtticaManager::ResolverState)state, binary );
|
||||
}
|
||||
return in;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TomahawkSettings::registerCustomSettingsHandlers()
|
||||
{
|
||||
qRegisterMetaType< Tomahawk::SerializedUpdater >( "Tomahawk::SerializedUpdater" );
|
||||
qRegisterMetaType< Tomahawk::SerializedUpdaters >( "Tomahawk::SerializedUpdaters" );
|
||||
qRegisterMetaTypeStreamOperators< Tomahawk::SerializedUpdaters >( "Tomahawk::SerializedUpdaters" );
|
||||
|
||||
qRegisterMetaType< AtticaManager::StateHash >( "AtticaManager::StateHash" );
|
||||
qRegisterMetaTypeStreamOperators< AtticaManager::StateHash >( "AtticaManager::StateHash" );
|
||||
}
|
||||
|
@ -21,11 +21,12 @@
|
||||
#ifndef TOMAHAWK_SETTINGS_H
|
||||
#define TOMAHAWK_SETTINGS_H
|
||||
|
||||
#include "network/Enums.h"
|
||||
|
||||
#include "DllMacro.h"
|
||||
#include "Typedefs.h"
|
||||
|
||||
#include "network/Enums.h"
|
||||
#include "AtticaManager.h"
|
||||
|
||||
#include <QSettings>
|
||||
#include <QNetworkProxy>
|
||||
#include <QStringList>
|
||||
@ -241,6 +242,7 @@ private:
|
||||
static TomahawkSettings* s_instance;
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE( TomahawkSettings::PrivateListeningMode );
|
||||
Q_DECLARE_METATYPE( TomahawkSettings::PrivateListeningMode )
|
||||
Q_DECLARE_METATYPE( AtticaManager::StateHash )
|
||||
|
||||
#endif
|
||||
|
@ -26,44 +26,6 @@
|
||||
|
||||
using namespace Tomahawk;
|
||||
|
||||
inline QDataStream& operator<<(QDataStream& out, const AtticaManager::StateHash& states)
|
||||
{
|
||||
out << TOMAHAWK_SETTINGS_VERSION;
|
||||
out << (quint32)states.count();
|
||||
foreach( const QString& key, states.keys() )
|
||||
{
|
||||
AtticaManager::Resolver resolver = states[ key ];
|
||||
out << key << resolver.version << resolver.scriptPath << (qint32)resolver.state << resolver.userRating << resolver.binary;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
inline QDataStream& operator>>(QDataStream& in, AtticaManager::StateHash& states)
|
||||
{
|
||||
quint32 count = 0, configVersion = 0;
|
||||
in >> configVersion;
|
||||
in >> count;
|
||||
for ( uint i = 0; i < count; i++ )
|
||||
{
|
||||
QString key, version, scriptPath;
|
||||
qint32 state, userRating;
|
||||
bool binary = false;
|
||||
in >> key;
|
||||
in >> version;
|
||||
in >> scriptPath;
|
||||
in >> state;
|
||||
in >> userRating;
|
||||
if ( configVersion > 10 )
|
||||
{
|
||||
// V11 includes 'bool binary' flag
|
||||
in >> binary;
|
||||
}
|
||||
states[ key ] = AtticaManager::Resolver( version, scriptPath, userRating, (AtticaManager::ResolverState)state, binary );
|
||||
}
|
||||
return in;
|
||||
}
|
||||
|
||||
|
||||
TomahawkSettingsGui*
|
||||
TomahawkSettingsGui::instanceGui()
|
||||
@ -143,11 +105,3 @@ TomahawkSettingsGui::removeAtticaResolverState ( const QString& resolver )
|
||||
resolvers.remove( resolver );
|
||||
setValue( "script/atticaresolverstates", QVariant::fromValue< AtticaManager::StateHash >( resolvers ) );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TomahawkSettingsGui::registerCustomSettingsHandlers()
|
||||
{
|
||||
qRegisterMetaType< AtticaManager::StateHash >( "AtticaManager::StateHash" );
|
||||
qRegisterMetaTypeStreamOperators<AtticaManager::StateHash>("AtticaManager::StateHash");
|
||||
}
|
||||
|
@ -47,11 +47,7 @@ public:
|
||||
|
||||
void setAtticaResolverState( const QString& resolver, AtticaManager::ResolverState state );
|
||||
void removeAtticaResolverState( const QString& resolver );
|
||||
|
||||
static void registerCustomSettingsHandlers();
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(AtticaManager::StateHash);
|
||||
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user