mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-06 22:26:32 +02:00
Finish adding filter imlpementation
This commit is contained in:
@@ -306,6 +306,7 @@ set( libSources
|
|||||||
accounts/AccountManager.cpp
|
accounts/AccountManager.cpp
|
||||||
accounts/Account.cpp
|
accounts/Account.cpp
|
||||||
accounts/AccountModel.cpp
|
accounts/AccountModel.cpp
|
||||||
|
accounts/AccountModelFilterProxy.cpp
|
||||||
accounts/ResolverAccount.cpp
|
accounts/ResolverAccount.cpp
|
||||||
|
|
||||||
sip/SipPlugin.cpp
|
sip/SipPlugin.cpp
|
||||||
@@ -447,6 +448,7 @@ set( libHeaders
|
|||||||
accounts/Account.h
|
accounts/Account.h
|
||||||
accounts/AccountManager.h
|
accounts/AccountManager.h
|
||||||
accounts/AccountModel.h
|
accounts/AccountModel.h
|
||||||
|
accounts/AccountModelFilterProxy.h
|
||||||
accounts/ResolverAccount.h
|
accounts/ResolverAccount.h
|
||||||
|
|
||||||
EchonestCatalogSynchronizer.h
|
EchonestCatalogSynchronizer.h
|
||||||
|
@@ -31,12 +31,14 @@ accountTypeToString( AccountType type )
|
|||||||
switch ( type )
|
switch ( type )
|
||||||
{
|
{
|
||||||
case SipType:
|
case SipType:
|
||||||
return tr( "Friend Finders" );
|
return QObject::tr( "Friend Finders" );
|
||||||
case ResolverType:
|
case ResolverType:
|
||||||
return tr( "Music Finders" );
|
return QObject::tr( "Music Finders" );
|
||||||
case InfoType:
|
case InfoType:
|
||||||
return tr( "Status Updaters" );
|
return QObject::tr( "Status Updaters" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -188,5 +188,5 @@ public:
|
|||||||
Q_DECLARE_INTERFACE( Tomahawk::Accounts::AccountFactory, "tomahawk.AccountFactory/1.0" )
|
Q_DECLARE_INTERFACE( Tomahawk::Accounts::AccountFactory, "tomahawk.AccountFactory/1.0" )
|
||||||
|
|
||||||
Q_DECLARE_METATYPE( QList< Tomahawk::Accounts::Account* > )
|
Q_DECLARE_METATYPE( QList< Tomahawk::Accounts::Account* > )
|
||||||
|
Q_DECLARE_METATYPE( Tomahawk::Accounts::AccountTypes )
|
||||||
#endif
|
#endif
|
||||||
|
@@ -115,6 +115,8 @@ AccountModel::data( const QModelIndex& index, int role ) const
|
|||||||
return QVariant::fromValue< QList< Tomahawk::Accounts::Account* > >( node->accounts );
|
return QVariant::fromValue< QList< Tomahawk::Accounts::Account* > >( node->accounts );
|
||||||
case HasConfig:
|
case HasConfig:
|
||||||
return !node->accounts.isEmpty();
|
return !node->accounts.isEmpty();
|
||||||
|
case AccountTypeRole:
|
||||||
|
return QVariant::fromValue< AccountTypes >( node->factory->types() );
|
||||||
default:
|
default:
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
@@ -144,6 +146,8 @@ AccountModel::data( const QModelIndex& index, int role ) const
|
|||||||
return c.downloads();
|
return c.downloads();
|
||||||
case CanRateRole:
|
case CanRateRole:
|
||||||
return true;
|
return true;
|
||||||
|
case AccountTypeRole:
|
||||||
|
return QVariant::fromValue< AccountTypes >( AccountTypes( ResolverType ) );
|
||||||
case VersionRole:
|
case VersionRole:
|
||||||
return c.version();
|
return c.version();
|
||||||
case UserHasRatedRole:
|
case UserHasRatedRole:
|
||||||
@@ -207,6 +211,8 @@ AccountModel::data( const QModelIndex& index, int role ) const
|
|||||||
return Uninstalled;
|
return Uninstalled;
|
||||||
case CanRateRole:
|
case CanRateRole:
|
||||||
return false;
|
return false;
|
||||||
|
case AccountTypeRole:
|
||||||
|
return QVariant::fromValue< AccountTypes >( node->factory->types() );
|
||||||
default:
|
default:
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
@@ -233,6 +239,8 @@ AccountModel::data( const QModelIndex& index, int role ) const
|
|||||||
return Installed;
|
return Installed;
|
||||||
case ChildrenOfFactoryRole:
|
case ChildrenOfFactoryRole:
|
||||||
return QVariant::fromValue< QList< Tomahawk::Accounts::Account* > >( node->accounts );
|
return QVariant::fromValue< QList< Tomahawk::Accounts::Account* > >( node->accounts );
|
||||||
|
case AccountTypeRole:
|
||||||
|
return QVariant::fromValue< AccountTypes >( acct->types() );
|
||||||
default:
|
default:
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
@@ -57,6 +57,7 @@ public:
|
|||||||
// used by individual accounts
|
// used by individual accounts
|
||||||
AccountData = Qt::UserRole + 28, // raw plugin
|
AccountData = Qt::UserRole + 28, // raw plugin
|
||||||
CanRateRole = Qt::UserRole + 32,
|
CanRateRole = Qt::UserRole + 32,
|
||||||
|
AccountTypeRole = Qt::UserRole + 33,
|
||||||
|
|
||||||
CheckboxClickedRole = Qt::UserRole + 29, // the checkbox for this row was toggled
|
CheckboxClickedRole = Qt::UserRole + 29, // the checkbox for this row was toggled
|
||||||
AddAccountButtonRole = Qt::UserRole + 30, // the add account button
|
AddAccountButtonRole = Qt::UserRole + 30, // the add account button
|
||||||
|
@@ -20,11 +20,13 @@
|
|||||||
|
|
||||||
#include "AccountModel.h"
|
#include "AccountModel.h"
|
||||||
|
|
||||||
|
|
||||||
using namespace Tomahawk;
|
using namespace Tomahawk;
|
||||||
using namespace Accounts;
|
using namespace Accounts;
|
||||||
|
|
||||||
AccountModelFilterProxy::AccountModelFilterProxy( QObject* parent )
|
AccountModelFilterProxy::AccountModelFilterProxy( QObject* parent )
|
||||||
: QSortFilterProxyModel(parent)
|
: QSortFilterProxyModel(parent)
|
||||||
|
, m_filterType( NoType )
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -35,10 +37,20 @@ AccountModelFilterProxy::filterAcceptsRow( int sourceRow, const QModelIndex& sou
|
|||||||
if ( m_filterType == NoType )
|
if ( m_filterType == NoType )
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
const QModeIndex idx = sourceParent.child( sourceRow, 0 );
|
const QModelIndex idx = sourceModel()->index( sourceRow, 0, sourceParent );
|
||||||
const AccountModel::RowType rowType = static_cast< AccountModel::RowType >( idx.data( AccountModel::RowTypeRole ).toInt() );
|
const AccountTypes types = static_cast< AccountTypes >( idx.data( AccountModel::AccountTypeRole ).value< AccountTypes >() );
|
||||||
|
|
||||||
|
|
||||||
|
return types.testFlag( m_filterType );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
AccountModelFilterProxy::setFilterType( AccountType type )
|
||||||
|
{
|
||||||
|
if ( type == m_filterType )
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_filterType = type;
|
||||||
|
invalidate();
|
||||||
|
}
|
||||||
|
@@ -19,11 +19,15 @@
|
|||||||
#ifndef ACCOUNTMODELFILTERPROXY_H
|
#ifndef ACCOUNTMODELFILTERPROXY_H
|
||||||
#define ACCOUNTMODELFILTERPROXY_H
|
#define ACCOUNTMODELFILTERPROXY_H
|
||||||
|
|
||||||
#include <QSortFilterProxyModel>
|
|
||||||
#include "Account.h"
|
#include "Account.h"
|
||||||
|
#include "dllmacro.h"
|
||||||
|
|
||||||
|
#include <QSortFilterProxyModel>
|
||||||
|
|
||||||
class AccountModelFilterProxy : public QSortFilterProxyModel
|
namespace Tomahawk {
|
||||||
|
namespace Accounts {
|
||||||
|
|
||||||
|
class DLLEXPORT AccountModelFilterProxy : public QSortFilterProxyModel
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
@@ -38,4 +42,7 @@ private:
|
|||||||
Tomahawk::Accounts::AccountType m_filterType;
|
Tomahawk::Accounts::AccountType m_filterType;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
#endif // ACCOUNTMODELFILTERPROXY_H
|
#endif // ACCOUNTMODELFILTERPROXY_H
|
||||||
|
@@ -81,15 +81,6 @@ main( int argc, char *argv[] )
|
|||||||
AEInstallEventHandler( 'GURL', 'GURL', h, 0, false );
|
AEInstallEventHandler( 'GURL', 'GURL', h, 0, false );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* // Unity hack taken from Clementine's main.cpp
|
|
||||||
#ifdef Q_OS_LINUX
|
|
||||||
// In 11.04 Ubuntu decided that the system tray should be reserved for certain
|
|
||||||
// whitelisted applications. Tomahawk will override this setting and insert
|
|
||||||
// itself into the list of whitelisted apps.
|
|
||||||
setenv( "QT_X11_NO_NATIVE_MENUBAR", "1", true );
|
|
||||||
UbuntuUnityHack hack;
|
|
||||||
#endif*/
|
|
||||||
|
|
||||||
TomahawkApp a( argc, argv );
|
TomahawkApp a( argc, argv );
|
||||||
|
|
||||||
// MUST register StateHash ****before*** initing TomahawkSettingsGui as constructor of settings does upgrade before Gui subclass registers type
|
// MUST register StateHash ****before*** initing TomahawkSettingsGui as constructor of settings does upgrade before Gui subclass registers type
|
||||||
|
@@ -52,6 +52,7 @@
|
|||||||
#include "accounts/AccountModel.h"
|
#include "accounts/AccountModel.h"
|
||||||
#include "accounts/Account.h"
|
#include "accounts/Account.h"
|
||||||
#include "accounts/AccountManager.h"
|
#include "accounts/AccountManager.h"
|
||||||
|
#include <accounts/AccountModelFilterProxy.h>
|
||||||
#include "utils/logger.h"
|
#include "utils/logger.h"
|
||||||
#include "AccountFactoryWrapper.h"
|
#include "AccountFactoryWrapper.h"
|
||||||
|
|
||||||
@@ -113,8 +114,10 @@ SettingsDialog::SettingsDialog( QWidget *parent )
|
|||||||
connect( accountDelegate, SIGNAL( update( QModelIndex ) ), ui->accountsView, SLOT( update( QModelIndex ) ) );
|
connect( accountDelegate, SIGNAL( update( QModelIndex ) ), ui->accountsView, SLOT( update( QModelIndex ) ) );
|
||||||
|
|
||||||
m_accountModel = new AccountModel( this );
|
m_accountModel = new AccountModel( this );
|
||||||
|
m_accountProxy = new AccountModelFilterProxy( m_accountModel );
|
||||||
|
m_accountProxy->setSourceModel( m_accountModel );
|
||||||
|
|
||||||
ui->accountsView->setModel( m_accountModel );
|
ui->accountsView->setModel( m_accountProxy );
|
||||||
|
|
||||||
connect( m_accountModel, SIGNAL( createAccount( Tomahawk::Accounts::AccountFactory* ) ), this, SLOT( createAccountFromFactory( Tomahawk::Accounts::AccountFactory* ) ) );
|
connect( m_accountModel, SIGNAL( createAccount( Tomahawk::Accounts::AccountFactory* ) ), this, SLOT( createAccountFromFactory( Tomahawk::Accounts::AccountFactory* ) ) );
|
||||||
|
|
||||||
@@ -427,12 +430,20 @@ SettingsDialog::onLastFmFinished()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
SettingsDialog::accountsFilterChanged( int )
|
||||||
|
{
|
||||||
|
AccountType filter = static_cast< AccountType >( ui->accountsFilterCombo->itemData( ui->accountsFilterCombo->currentIndex() ).toInt() );
|
||||||
|
m_accountProxy->setFilterType( filter );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
SettingsDialog::openAccountConfig( Account* account, bool showDelete )
|
SettingsDialog::openAccountConfig( Account* account, bool showDelete )
|
||||||
{
|
{
|
||||||
if( account->configurationWidget() )
|
if( account->configurationWidget() )
|
||||||
{
|
{
|
||||||
#if 0
|
#ifndef Q_OS_MAC
|
||||||
DelegateConfigWrapper dialog( account->configurationWidget(), QString("%1 Configuration" ).arg( account->accountFriendlyName() ), this );
|
DelegateConfigWrapper dialog( account->configurationWidget(), QString("%1 Configuration" ).arg( account->accountFriendlyName() ), this );
|
||||||
dialog.setShowDelete( showDelete );
|
dialog.setShowDelete( showDelete );
|
||||||
QWeakPointer< DelegateConfigWrapper > watcher( &dialog );
|
QWeakPointer< DelegateConfigWrapper > watcher( &dialog );
|
||||||
|
@@ -46,6 +46,7 @@ namespace Tomahawk
|
|||||||
class Account;
|
class Account;
|
||||||
class AccountFactory;
|
class AccountFactory;
|
||||||
class Account;
|
class Account;
|
||||||
|
class AccountModelFilterProxy;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -114,6 +115,7 @@ private:
|
|||||||
ProxyDialog m_proxySettings;
|
ProxyDialog m_proxySettings;
|
||||||
bool m_rejected;
|
bool m_rejected;
|
||||||
Tomahawk::Accounts::AccountModel* m_accountModel;
|
Tomahawk::Accounts::AccountModel* m_accountModel;
|
||||||
|
Tomahawk::Accounts::AccountModelFilterProxy* m_accountProxy;
|
||||||
LoadingSpinner* m_sipSpinner;
|
LoadingSpinner* m_sipSpinner;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user