mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-20 04:41:36 +02:00
W. T. F. Why can my simple struct no longer be serialized by QVariant.
Even adding destructor/copy constructor didn't help.
This commit is contained in:
@@ -49,7 +49,6 @@ ACLRegistry::ACLRegistry( QObject* parent )
|
|||||||
s_instance = this;
|
s_instance = this;
|
||||||
qRegisterMetaType< ACLRegistry::ACL >( "ACLRegistry::ACL" );
|
qRegisterMetaType< ACLRegistry::ACL >( "ACLRegistry::ACL" );
|
||||||
qRegisterMetaType< ACLRegistry::User >( "ACLRegistry::User" );
|
qRegisterMetaType< ACLRegistry::User >( "ACLRegistry::User" );
|
||||||
|
|
||||||
load();
|
load();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,13 +61,14 @@ ACLRegistry::~ACLRegistry()
|
|||||||
ACLRegistry::ACL
|
ACLRegistry::ACL
|
||||||
ACLRegistry::isAuthorizedUser( const QString& dbid, const QString &username, ACLRegistry::ACL globalType, bool skipEmission )
|
ACLRegistry::isAuthorizedUser( const QString& dbid, const QString &username, ACLRegistry::ACL globalType, bool skipEmission )
|
||||||
{
|
{
|
||||||
|
tDebug() << Q_FUNC_INFO;
|
||||||
if ( QThread::currentThread() != TOMAHAWK_APPLICATION::instance()->thread() )
|
if ( QThread::currentThread() != TOMAHAWK_APPLICATION::instance()->thread() )
|
||||||
{
|
{
|
||||||
if ( !skipEmission )
|
if ( !skipEmission )
|
||||||
QMetaObject::invokeMethod( this, "isAuthorizedUser", Qt::QueuedConnection, Q_ARG( const QString&, dbid ), Q_ARG( const QString &, username ), Q_ARG( ACLRegistry::ACL, globalType ), Q_ARG( bool, skipEmission ) );
|
QMetaObject::invokeMethod( this, "isAuthorizedUser", Qt::QueuedConnection, Q_ARG( const QString&, dbid ), Q_ARG( const QString &, username ), Q_ARG( ACLRegistry::ACL, globalType ), Q_ARG( bool, skipEmission ) );
|
||||||
return ACLRegistry::NotFound;
|
return ACLRegistry::NotFound;
|
||||||
}
|
}
|
||||||
|
tDebug() << Q_FUNC_INFO << "in right thread";
|
||||||
//FIXME: Remove when things are working
|
//FIXME: Remove when things are working
|
||||||
// emit aclResult( dbid, username, ACLRegistry::Stream );
|
// emit aclResult( dbid, username, ACLRegistry::Stream );
|
||||||
// return ACLRegistry::NotFound;
|
// return ACLRegistry::NotFound;
|
||||||
@@ -133,6 +133,7 @@ ACLRegistry::isAuthorizedUser( const QString& dbid, const QString &username, ACL
|
|||||||
void
|
void
|
||||||
ACLRegistry::getUserDecision( ACLRegistry::User user, const QString &username )
|
ACLRegistry::getUserDecision( ACLRegistry::User user, const QString &username )
|
||||||
{
|
{
|
||||||
|
tDebug() << Q_FUNC_INFO;
|
||||||
AclJobItem* job = new AclJobItem( user, username );
|
AclJobItem* job = new AclJobItem( user, username );
|
||||||
m_jobQueue.enqueue( job );
|
m_jobQueue.enqueue( job );
|
||||||
queueNextJob();
|
queueNextJob();
|
||||||
@@ -143,6 +144,7 @@ ACLRegistry::getUserDecision( ACLRegistry::User user, const QString &username )
|
|||||||
void
|
void
|
||||||
ACLRegistry::userDecision( ACLRegistry::User user )
|
ACLRegistry::userDecision( ACLRegistry::User user )
|
||||||
{
|
{
|
||||||
|
tDebug() << Q_FUNC_INFO;
|
||||||
m_cache.append( user );
|
m_cache.append( user );
|
||||||
save();
|
save();
|
||||||
emit aclResult( user.knownDbids.first(), user.knownAccountIds.first(), user.acl );
|
emit aclResult( user.knownDbids.first(), user.knownAccountIds.first(), user.acl );
|
||||||
@@ -197,11 +199,13 @@ ACLRegistry::queueNextJob()
|
|||||||
void
|
void
|
||||||
ACLRegistry::load()
|
ACLRegistry::load()
|
||||||
{
|
{
|
||||||
|
tDebug() << Q_FUNC_INFO;
|
||||||
QVariantList entryList = TomahawkSettings::instance()->aclEntries();
|
QVariantList entryList = TomahawkSettings::instance()->aclEntries();
|
||||||
foreach ( QVariant entry, entryList )
|
foreach ( QVariant entry, entryList )
|
||||||
{
|
{
|
||||||
if ( !entry.isValid() || !entry.canConvert< ACLRegistry::User >() )
|
if ( !entry.isValid() || !entry.canConvert< ACLRegistry::User >() )
|
||||||
continue;
|
continue;
|
||||||
|
tDebug() << Q_FUNC_INFO << "loading entry";
|
||||||
ACLRegistry::User entryUser = entry.value< ACLRegistry::User >();
|
ACLRegistry::User entryUser = entry.value< ACLRegistry::User >();
|
||||||
m_cache.append( entryUser );
|
m_cache.append( entryUser );
|
||||||
}
|
}
|
||||||
@@ -211,8 +215,12 @@ ACLRegistry::load()
|
|||||||
void
|
void
|
||||||
ACLRegistry::save()
|
ACLRegistry::save()
|
||||||
{
|
{
|
||||||
|
tDebug() << Q_FUNC_INFO;
|
||||||
QVariantList entryList;
|
QVariantList entryList;
|
||||||
foreach ( ACLRegistry::User user, m_cache )
|
foreach ( ACLRegistry::User user, m_cache )
|
||||||
|
{
|
||||||
|
tDebug() << Q_FUNC_INFO << "user is " << user.uuid << " with known name " << user.knownAccountIds.first();
|
||||||
entryList.append( QVariant::fromValue< ACLRegistry::User >( user ) );
|
entryList.append( QVariant::fromValue< ACLRegistry::User >( user ) );
|
||||||
|
}
|
||||||
TomahawkSettings::instance()->setAclEntries( entryList );
|
TomahawkSettings::instance()->setAclEntries( entryList );
|
||||||
}
|
}
|
@@ -55,15 +55,27 @@ public:
|
|||||||
|
|
||||||
User()
|
User()
|
||||||
: uuid( QUuid::createUuid().toString() )
|
: uuid( QUuid::createUuid().toString() )
|
||||||
|
, knownDbids()
|
||||||
|
, knownAccountIds()
|
||||||
, acl( ACLRegistry::NotFound )
|
, acl( ACLRegistry::NotFound )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
User( QString p_uuid, QStringList p_knownDbids, QStringList p_knownAccountIds, ACL p_acl )
|
~User()
|
||||||
|
{}
|
||||||
|
|
||||||
|
User( QString p_uuid, QStringList p_knownDbids, QStringList p_knownAccountIds, ACLRegistry::ACL p_acl )
|
||||||
: uuid( p_uuid )
|
: uuid( p_uuid )
|
||||||
, knownDbids( p_knownDbids )
|
, knownDbids( p_knownDbids )
|
||||||
, knownAccountIds( p_knownAccountIds )
|
, knownAccountIds( p_knownAccountIds )
|
||||||
, acl( p_acl )
|
, acl( p_acl )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
User( const User &other )
|
||||||
|
: uuid( other.uuid )
|
||||||
|
, knownDbids( other.knownDbids )
|
||||||
|
, knownAccountIds( other.knownAccountIds )
|
||||||
|
, acl( other.acl )
|
||||||
|
{}
|
||||||
};
|
};
|
||||||
|
|
||||||
ACLRegistry( QObject *parent = 0 );
|
ACLRegistry( QObject *parent = 0 );
|
||||||
|
@@ -642,7 +642,10 @@ TomahawkSettings::aclEntries() const
|
|||||||
void
|
void
|
||||||
TomahawkSettings::setAclEntries( const QVariantList &entries )
|
TomahawkSettings::setAclEntries( const QVariantList &entries )
|
||||||
{
|
{
|
||||||
|
tDebug() << "Setting entries";
|
||||||
setValue( "acl/entries", entries );
|
setValue( "acl/entries", entries );
|
||||||
|
sync();
|
||||||
|
tDebug() << "Done setting entries";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -112,7 +112,7 @@ AclJobDelegate::drawRoundedButton( QPainter* painter, const QRect& btnRect, bool
|
|||||||
bool
|
bool
|
||||||
AclJobDelegate::editorEvent( QEvent* event, QAbstractItemModel* model, const QStyleOptionViewItem& option, const QModelIndex& index )
|
AclJobDelegate::editorEvent( QEvent* event, QAbstractItemModel* model, const QStyleOptionViewItem& option, const QModelIndex& index )
|
||||||
{
|
{
|
||||||
tDebug( LOGVERBOSE ) << Q_FUNC_INFO;
|
//tDebug( LOGVERBOSE ) << Q_FUNC_INFO;
|
||||||
if ( event->type() != QEvent::MouseButtonPress &&
|
if ( event->type() != QEvent::MouseButtonPress &&
|
||||||
event->type() != QEvent::MouseButtonRelease &&
|
event->type() != QEvent::MouseButtonRelease &&
|
||||||
event->type() != QEvent::MouseButtonDblClick &&
|
event->type() != QEvent::MouseButtonDblClick &&
|
||||||
@@ -123,7 +123,7 @@ AclJobDelegate::editorEvent( QEvent* event, QAbstractItemModel* model, const QSt
|
|||||||
{
|
{
|
||||||
QMouseEvent* me = static_cast< QMouseEvent* >( event );
|
QMouseEvent* me = static_cast< QMouseEvent* >( event );
|
||||||
m_savedHoverPos = me->pos();
|
m_savedHoverPos = me->pos();
|
||||||
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "Setting position to " << m_savedHoverPos;
|
//tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "Setting position to " << m_savedHoverPos;
|
||||||
emit update( index );
|
emit update( index );
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@@ -59,8 +59,11 @@ JobStatusDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option,
|
|||||||
if ( allowMultiLine )
|
if ( allowMultiLine )
|
||||||
iconRect.moveTop( opt.rect.top() + opt.rect.height() / 2 - iconRect.height() / 2);
|
iconRect.moveTop( opt.rect.top() + opt.rect.height() / 2 - iconRect.height() / 2);
|
||||||
QPixmap p = index.data( Qt::DecorationRole ).value< QPixmap >();
|
QPixmap p = index.data( Qt::DecorationRole ).value< QPixmap >();
|
||||||
p = p.scaledToHeight( iconRect.height(), Qt::SmoothTransformation );
|
if ( !p.isNull() )
|
||||||
painter->drawPixmap( iconRect, p );
|
{
|
||||||
|
p = p.scaledToHeight( iconRect.height(), Qt::SmoothTransformation );
|
||||||
|
painter->drawPixmap( iconRect, p );
|
||||||
|
}
|
||||||
|
|
||||||
// draw right column if there is one
|
// draw right column if there is one
|
||||||
const QString rCol = index.data( JobStatusModel::RightColumnRole ).toString();
|
const QString rCol = index.data( JobStatusModel::RightColumnRole ).toString();
|
||||||
|
@@ -107,6 +107,7 @@ JobStatusView::customDelegateJobInserted( int row, JobStatusItem* item )
|
|||||||
item->createDelegate( m_view );
|
item->createDelegate( m_view );
|
||||||
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "item delegate is " << item->customDelegate();
|
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "item delegate is " << item->customDelegate();
|
||||||
m_view->setItemDelegateForRow( row, item->customDelegate() );
|
m_view->setItemDelegateForRow( row, item->customDelegate() );
|
||||||
|
m_customDelegateRefCounter[ row ] = m_customDelegateRefCounter[ row ] + 1;
|
||||||
AclJobDelegate* delegate = qobject_cast< AclJobDelegate* >( item->customDelegate() );
|
AclJobDelegate* delegate = qobject_cast< AclJobDelegate* >( item->customDelegate() );
|
||||||
if ( delegate )
|
if ( delegate )
|
||||||
{
|
{
|
||||||
@@ -120,7 +121,9 @@ JobStatusView::customDelegateJobInserted( int row, JobStatusItem* item )
|
|||||||
void
|
void
|
||||||
JobStatusView::customDelegateJobRemoved( int row )
|
JobStatusView::customDelegateJobRemoved( int row )
|
||||||
{
|
{
|
||||||
m_view->setItemDelegateForRow( row, m_view->itemDelegate() );
|
if ( m_customDelegateRefCounter[ row ] == 1 )
|
||||||
|
m_view->setItemDelegateForRow( row, m_view->itemDelegate() );
|
||||||
|
m_customDelegateRefCounter[ row ] = m_customDelegateRefCounter[ row ] - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -61,6 +61,7 @@ private:
|
|||||||
JobStatusModel* m_model;
|
JobStatusModel* m_model;
|
||||||
AnimatedSplitter* m_parent;
|
AnimatedSplitter* m_parent;
|
||||||
mutable int m_cachedHeight;
|
mutable int m_cachedHeight;
|
||||||
|
QHash< int, int > m_customDelegateRefCounter;
|
||||||
|
|
||||||
static JobStatusView* s_instance;
|
static JobStatusView* s_instance;
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user