mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-06 14:16:32 +02:00
SHow online/offline status for factory with an account as well
This commit is contained in:
@@ -80,7 +80,7 @@ QSize
|
||||
AccountDelegate::sizeHint( const QStyleOptionViewItem& option, const QModelIndex& index ) const
|
||||
{
|
||||
AccountModel::RowType rowType = static_cast< AccountModel::RowType >( index.data( AccountModel::RowTypeRole ).toInt() );
|
||||
if ( rowType == AccountModel::TopLevelAccount )
|
||||
if ( rowType == AccountModel::TopLevelAccount || rowType == AccountModel::UniqueFactory )
|
||||
return QSize( 200, TOPLEVEL_ACCOUNT_HEIGHT );
|
||||
else if ( rowType == AccountModel::TopLevelFactory )
|
||||
{
|
||||
@@ -212,6 +212,18 @@ AccountDelegate::paint ( QPainter* painter, const QStyleOptionViewItem& option,
|
||||
painter->drawText( btnRect, Qt::AlignCenter, btnText );
|
||||
painter->restore();
|
||||
}
|
||||
else if ( rowType == AccountModel::UniqueFactory )
|
||||
{
|
||||
// Display as usual, except if it has an account, show the status.
|
||||
const QList< Account* > accts = index.data( AccountModel::ChildrenOfFactoryRole ).value< QList< Tomahawk::Accounts::Account* > >();
|
||||
if ( !accts.isEmpty() )
|
||||
{
|
||||
Q_ASSERT( accts.size() == 1 );
|
||||
|
||||
rightEdge = drawStatus( painter, QPointF( rightEdge, center - painter->fontMetrics().height()/2 ), accts.first(), true );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Draw the title and description
|
||||
// title
|
||||
@@ -487,7 +499,7 @@ AccountDelegate::drawRoundedButton( QPainter* painter, const QRect& btnRect ) co
|
||||
|
||||
|
||||
int
|
||||
AccountDelegate::drawStatus( QPainter* painter, const QPointF& rightTopEdge, Account* acct ) const
|
||||
AccountDelegate::drawStatus( QPainter* painter, const QPointF& rightTopEdge, Account* acct, bool drawText ) const
|
||||
{
|
||||
QPixmap p;
|
||||
QString statusText;
|
||||
@@ -512,12 +524,18 @@ AccountDelegate::drawStatus( QPainter* painter, const QPointF& rightTopEdge, Acc
|
||||
const QRect connectIconRect( rightTopEdge.x() - STATUS_ICON_SIZE, yPos, STATUS_ICON_SIZE, STATUS_ICON_SIZE );
|
||||
painter->drawPixmap( connectIconRect, p );
|
||||
|
||||
int leftEdge = connectIconRect.x();
|
||||
// For now, disable text next to icon
|
||||
// int width = painter->fontMetrics().width( statusText );
|
||||
// int statusTextX = connectIconRect.x() - PADDING - width;
|
||||
// painter->drawText( QRect( statusTextX, yPos, width, painter->fontMetrics().height() ), statusText );
|
||||
if ( drawText )
|
||||
{
|
||||
int width = painter->fontMetrics().width( statusText );
|
||||
int statusTextX = connectIconRect.x() - PADDING - width;
|
||||
painter->drawText( QRect( statusTextX, yPos, width, painter->fontMetrics().height() ), statusText );
|
||||
|
||||
return connectIconRect.x();
|
||||
leftEdge = statusTextX;
|
||||
}
|
||||
|
||||
return leftEdge;
|
||||
}
|
||||
|
||||
|
||||
|
@@ -48,7 +48,7 @@ signals:
|
||||
private:
|
||||
void drawRoundedButton( QPainter* painter, const QRect& buttonRect ) const;
|
||||
// Returns new left edge
|
||||
int drawStatus( QPainter* painter, const QPointF& rightTopEdge, Account* acct ) const;
|
||||
int drawStatus( QPainter* painter, const QPointF& rightTopEdge, Account* acct, bool drawText = false ) const;
|
||||
void drawCheckBox( QStyleOptionViewItemV4& opt, QPainter* p, const QWidget* w ) const;
|
||||
void drawConfigWrench( QPainter* painter, QStyleOptionViewItemV4& option, QStyleOptionToolButton& topt ) const;
|
||||
// returns new left edge
|
||||
|
@@ -174,6 +174,9 @@ AccountModel::data( const QModelIndex& index, int role ) const
|
||||
case AccountModelNode::ManualResolverType:
|
||||
case AccountModelNode::UniqueFactoryType:
|
||||
{
|
||||
if ( role == RowTypeRole )
|
||||
return UniqueFactory;
|
||||
|
||||
Account* acct = 0;
|
||||
if ( node->type == AccountModelNode::ManualResolverType )
|
||||
acct = node->resolverAccount;
|
||||
@@ -194,8 +197,6 @@ AccountModel::data( const QModelIndex& index, int role ) const
|
||||
return node->factory->icon();
|
||||
case DescriptionRole:
|
||||
return node->factory->description();
|
||||
case RowTypeRole:
|
||||
return TopLevelFactory;
|
||||
case StateRole:
|
||||
return Uninstalled;
|
||||
case CanRateRole:
|
||||
@@ -218,14 +219,14 @@ AccountModel::data( const QModelIndex& index, int role ) const
|
||||
return acct->enabled() ? Qt::Checked : Qt::Unchecked;
|
||||
case AccountData:
|
||||
return QVariant::fromValue< QObject* >( acct );
|
||||
case RowTypeRole:
|
||||
return TopLevelAccount;
|
||||
case ConnectionStateRole:
|
||||
return acct->connectionState();
|
||||
case HasConfig:
|
||||
return acct->configurationWidget() != 0;
|
||||
case StateRole:
|
||||
return Installed;
|
||||
case ChildrenOfFactoryRole:
|
||||
return QVariant::fromValue< QList< Tomahawk::Accounts::Account* > >( node->accounts );
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
|
@@ -67,7 +67,8 @@ public:
|
||||
|
||||
enum RowType {
|
||||
TopLevelFactory,
|
||||
TopLevelAccount
|
||||
TopLevelAccount,
|
||||
UniqueFactory
|
||||
};
|
||||
|
||||
enum ItemState {
|
||||
@@ -78,7 +79,6 @@ public:
|
||||
Upgrading,
|
||||
Failed,
|
||||
ShippedWithTomahawk, // Built-in account/factory state: Can't uninstall or uninstall, just create
|
||||
UniqueFactory // Shipped with tomahawk but is a unique account
|
||||
};
|
||||
|
||||
explicit AccountModel( QObject* parent = 0 );
|
||||
|
Reference in New Issue
Block a user