mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-06 14:16:32 +02:00
* Always use tr() when defining user visible text.
This commit is contained in:
@@ -35,6 +35,7 @@
|
|||||||
|
|
||||||
#define TREEVIEW_INDENT_ADD -7
|
#define TREEVIEW_INDENT_ADD -7
|
||||||
|
|
||||||
|
|
||||||
SourceDelegate::SourceDelegate( QAbstractItemView* parent )
|
SourceDelegate::SourceDelegate( QAbstractItemView* parent )
|
||||||
: QStyledItemDelegate( parent )
|
: QStyledItemDelegate( parent )
|
||||||
, m_parent( parent )
|
, m_parent( parent )
|
||||||
@@ -45,11 +46,11 @@ SourceDelegate::SourceDelegate( QAbstractItemView* parent )
|
|||||||
m_dropTypeMap.insert( 3, SourceTreeItem::DropTypeLocalItems );
|
m_dropTypeMap.insert( 3, SourceTreeItem::DropTypeLocalItems );
|
||||||
m_dropTypeMap.insert( 4, SourceTreeItem::DropTypeTop50 );
|
m_dropTypeMap.insert( 4, SourceTreeItem::DropTypeTop50 );
|
||||||
|
|
||||||
m_dropTypeTextMap.insert( 0, "Track" );
|
m_dropTypeTextMap.insert( 0, tr( "Track" ) );
|
||||||
m_dropTypeTextMap.insert( 1, "Album" );
|
m_dropTypeTextMap.insert( 1, tr( "Album" ) );
|
||||||
m_dropTypeTextMap.insert( 2, "Artist" );
|
m_dropTypeTextMap.insert( 2, tr( "Artist" ) );
|
||||||
m_dropTypeTextMap.insert( 3, "Local" );
|
m_dropTypeTextMap.insert( 3, tr( "Local" ) );
|
||||||
m_dropTypeTextMap.insert( 4, "Top 10" );
|
m_dropTypeTextMap.insert( 4, tr( "Top 10" ) );
|
||||||
|
|
||||||
m_dropTypeImageMap.insert( 0, QPixmap( ":/data/images/drop-song.png" ).scaledToWidth( 32, Qt::SmoothTransformation ) );
|
m_dropTypeImageMap.insert( 0, QPixmap( ":/data/images/drop-song.png" ).scaledToWidth( 32, Qt::SmoothTransformation ) );
|
||||||
m_dropTypeImageMap.insert( 1, QPixmap( ":/data/images/drop-album.png" ).scaledToWidth( 32, Qt::SmoothTransformation ) );
|
m_dropTypeImageMap.insert( 1, QPixmap( ":/data/images/drop-album.png" ).scaledToWidth( 32, Qt::SmoothTransformation ) );
|
||||||
@@ -60,11 +61,13 @@ SourceDelegate::SourceDelegate( QAbstractItemView* parent )
|
|||||||
m_dropMimeData = new QMimeData();
|
m_dropMimeData = new QMimeData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SourceDelegate::~SourceDelegate()
|
SourceDelegate::~SourceDelegate()
|
||||||
{
|
{
|
||||||
delete m_dropMimeData;
|
delete m_dropMimeData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QSize
|
QSize
|
||||||
SourceDelegate::sizeHint( const QStyleOptionViewItem& option, const QModelIndex& index ) const
|
SourceDelegate::sizeHint( const QStyleOptionViewItem& option, const QModelIndex& index ) const
|
||||||
{
|
{
|
||||||
@@ -198,8 +201,8 @@ SourceDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, co
|
|||||||
|
|
||||||
painter->restore();
|
painter->restore();
|
||||||
}
|
}
|
||||||
else if ( (type == SourcesModel::StaticPlaylist || type == SourcesModel::CategoryAdd )
|
else if ( ( type == SourcesModel::StaticPlaylist || type == SourcesModel::CategoryAdd ) &&
|
||||||
&& m_expandedMap.contains( index ) && m_expandedMap.value( index )->partlyExpanded() && dropTypeCount( item ) > 0 )
|
m_expandedMap.contains( index ) && m_expandedMap.value( index )->partlyExpanded() && dropTypeCount( item ) > 0 )
|
||||||
{
|
{
|
||||||
// Let Qt paint the original item. We add our stuff after it
|
// Let Qt paint the original item. We add our stuff after it
|
||||||
o.state &= ~QStyle::State_Selected;
|
o.state &= ~QStyle::State_Selected;
|
||||||
@@ -218,7 +221,6 @@ SourceDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, co
|
|||||||
cursorInRect = true;
|
cursorInRect = true;
|
||||||
|
|
||||||
// draw the background
|
// draw the background
|
||||||
|
|
||||||
QLinearGradient linearGradient( itemsRect.topLeft(), itemsRect.bottomLeft() );
|
QLinearGradient linearGradient( itemsRect.topLeft(), itemsRect.bottomLeft() );
|
||||||
linearGradient.setColorAt( 0.0, Qt::white );
|
linearGradient.setColorAt( 0.0, Qt::white );
|
||||||
// linearGradient.setColorAt( 0.8, QColor( 0xd6, 0xd6, 0xd6 ) ); // light grey
|
// linearGradient.setColorAt( 0.8, QColor( 0xd6, 0xd6, 0xd6 ) ); // light grey
|
||||||
@@ -240,8 +242,6 @@ SourceDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, co
|
|||||||
// adjust to one single entry
|
// adjust to one single entry
|
||||||
itemsRect.adjust( 0, 0, -itemsRect.width() + itemWidth, 0 );
|
itemsRect.adjust( 0, 0, -itemsRect.width() + itemWidth, 0 );
|
||||||
|
|
||||||
int count = 0;
|
|
||||||
|
|
||||||
pen.setColor( Qt::white );
|
pen.setColor( Qt::white );
|
||||||
painter->setPen( pen );
|
painter->setPen( pen );
|
||||||
|
|
||||||
@@ -256,12 +256,12 @@ SourceDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, co
|
|||||||
|
|
||||||
SourceTreeItem::DropTypes dropTypes = item->supportedDropTypes( m_dropMimeData );
|
SourceTreeItem::DropTypes dropTypes = item->supportedDropTypes( m_dropMimeData );
|
||||||
|
|
||||||
|
int count = 0;
|
||||||
for ( int i = 0; i < 5; ++i )
|
for ( int i = 0; i < 5; ++i )
|
||||||
{
|
{
|
||||||
if ( !dropTypes.testFlag( m_dropTypeMap.value( i ) ) )
|
if ( !dropTypes.testFlag( m_dropTypeMap.value( i ) ) )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
||||||
if ( count > 0 )
|
if ( count > 0 )
|
||||||
itemsRect.adjust( itemWidth, 0, itemWidth, 0 );
|
itemsRect.adjust( itemWidth, 0, itemWidth, 0 );
|
||||||
|
|
||||||
@@ -289,9 +289,7 @@ SourceDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, co
|
|||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
painter->restore();
|
painter->restore();
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -338,6 +336,7 @@ SourceDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, co
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
SourceDelegate::updateEditorGeometry( QWidget* editor, const QStyleOptionViewItem& option, const QModelIndex& index ) const
|
SourceDelegate::updateEditorGeometry( QWidget* editor, const QStyleOptionViewItem& option, const QModelIndex& index ) const
|
||||||
{
|
{
|
||||||
@@ -346,9 +345,10 @@ SourceDelegate::updateEditorGeometry( QWidget* editor, const QStyleOptionViewIte
|
|||||||
else
|
else
|
||||||
QStyledItemDelegate::updateEditorGeometry( editor, option, index );
|
QStyledItemDelegate::updateEditorGeometry( editor, option, index );
|
||||||
|
|
||||||
editor->setGeometry( editor->geometry().adjusted( 2*TREEVIEW_INDENT_ADD, 0, 0, 0 ) );
|
editor->setGeometry( editor->geometry().adjusted( 2 * TREEVIEW_INDENT_ADD, 0, 0, 0 ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
SourceDelegate::editorEvent ( QEvent* event, QAbstractItemModel* model, const QStyleOptionViewItem& option, const QModelIndex& index )
|
SourceDelegate::editorEvent ( QEvent* event, QAbstractItemModel* model, const QStyleOptionViewItem& option, const QModelIndex& index )
|
||||||
{
|
{
|
||||||
@@ -375,6 +375,7 @@ SourceDelegate::editorEvent ( QEvent* event, QAbstractItemModel* model, const QS
|
|||||||
return QStyledItemDelegate::editorEvent ( event, model, option, index );
|
return QStyledItemDelegate::editorEvent ( event, model, option, index );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
SourceDelegate::dropTypeCount( SourceTreeItem* item ) const
|
SourceDelegate::dropTypeCount( SourceTreeItem* item ) const
|
||||||
{
|
{
|
||||||
@@ -397,14 +398,16 @@ SourceDelegate::dropTypeCount( SourceTreeItem* item ) const
|
|||||||
return menuCount;
|
return menuCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SourceTreeItem::DropType
|
SourceTreeItem::DropType
|
||||||
SourceDelegate::hoveredDropType() const
|
SourceDelegate::hoveredDropType() const
|
||||||
{
|
{
|
||||||
return m_hoveredDropType;
|
return m_hoveredDropType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
SourceDelegate::hovered(const QModelIndex &index, const QMimeData *mimeData)
|
SourceDelegate::hovered( const QModelIndex& index, const QMimeData* mimeData )
|
||||||
{
|
{
|
||||||
if ( !index.isValid() )
|
if ( !index.isValid() )
|
||||||
{
|
{
|
||||||
@@ -414,6 +417,7 @@ SourceDelegate::hovered(const QModelIndex &index, const QMimeData *mimeData)
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !m_expandedMap.contains( index ) )
|
if ( !m_expandedMap.contains( index ) )
|
||||||
{
|
{
|
||||||
foreach ( AnimationHelper *helper, m_expandedMap )
|
foreach ( AnimationHelper *helper, m_expandedMap )
|
||||||
@@ -430,21 +434,22 @@ SourceDelegate::hovered(const QModelIndex &index, const QMimeData *mimeData)
|
|||||||
|
|
||||||
m_expandedMap.insert( m_newDropHoverIndex, new AnimationHelper( m_newDropHoverIndex ) );
|
m_expandedMap.insert( m_newDropHoverIndex, new AnimationHelper( m_newDropHoverIndex ) );
|
||||||
connect( m_expandedMap.value( m_newDropHoverIndex ), SIGNAL( finished( QModelIndex ) ), SLOT( animationFinished( QModelIndex ) ) );
|
connect( m_expandedMap.value( m_newDropHoverIndex ), SIGNAL( finished( QModelIndex ) ), SLOT( animationFinished( QModelIndex ) ) );
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
qDebug() << "expandedMap already contains index" << index;
|
qDebug() << "expandedMap already contains index" << index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
SourceDelegate::dragLeaveEvent()
|
SourceDelegate::dragLeaveEvent()
|
||||||
{
|
{
|
||||||
foreach ( AnimationHelper *helper, m_expandedMap )
|
foreach ( AnimationHelper* helper, m_expandedMap )
|
||||||
{
|
{
|
||||||
helper->collapse( true );
|
helper->collapse( true );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
SourceDelegate::animationFinished( const QModelIndex& index )
|
SourceDelegate::animationFinished( const QModelIndex& index )
|
||||||
{
|
{
|
||||||
|
@@ -448,7 +448,7 @@ SourceTreeView::dragLeaveEvent( QDragLeaveEvent* event )
|
|||||||
setDirtyRegion( m_dropRect );
|
setDirtyRegion( m_dropRect );
|
||||||
|
|
||||||
m_delegate->dragLeaveEvent();
|
m_delegate->dragLeaveEvent();
|
||||||
dataChanged(m_dropIndex, m_dropIndex);
|
dataChanged( m_dropIndex, m_dropIndex );
|
||||||
m_dropIndex = QPersistentModelIndex();
|
m_dropIndex = QPersistentModelIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -594,10 +594,9 @@ SourceTreeView::itemFromIndex( const QModelIndex& index ) const
|
|||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
SourceTreeView::update( const QModelIndex &index )
|
SourceTreeView::update( const QModelIndex &index )
|
||||||
{
|
{
|
||||||
// updateGeometries();
|
|
||||||
// QTreeView::update( index );
|
|
||||||
dataChanged( index, index );
|
dataChanged( index, index );
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user