From 3d951d012aeee1ba12b497588e20c475efd75aad Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser Date: Mon, 25 Aug 2014 17:13:28 +0200 Subject: [PATCH] * Removed obsolete PlaylistLargeItemDelegate. --- src/libtomahawk/CMakeLists.txt | 1 - src/libtomahawk/ViewManager.cpp | 1 - src/libtomahawk/playlist/ContextView.cpp | 1 - src/libtomahawk/playlist/FlexibleTreeView.cpp | 5 - src/libtomahawk/playlist/FlexibleView.cpp | 1 - .../playlist/PlaylistLargeItemDelegate.cpp | 279 ------------------ .../playlist/PlaylistLargeItemDelegate.h | 58 ---- src/libtomahawk/widgets/HistoryWidget.cpp | 4 - src/tomahawk/sourcetree/SourcesModel.cpp | 5 - src/tomahawk/sourcetree/items/SourceItem.cpp | 4 - 10 files changed, 359 deletions(-) delete mode 100644 src/libtomahawk/playlist/PlaylistLargeItemDelegate.cpp delete mode 100644 src/libtomahawk/playlist/PlaylistLargeItemDelegate.h diff --git a/src/libtomahawk/CMakeLists.txt b/src/libtomahawk/CMakeLists.txt index bd50974d5..4201c450e 100644 --- a/src/libtomahawk/CMakeLists.txt +++ b/src/libtomahawk/CMakeLists.txt @@ -72,7 +72,6 @@ set( libGuiSources playlist/RecentlyAddedModel.cpp playlist/RecentlyPlayedModel.cpp playlist/AlbumItemDelegate.cpp - playlist/PlaylistLargeItemDelegate.cpp playlist/TrackItemDelegate.cpp playlist/PlaylistChartItemDelegate.cpp playlist/PlayableItem.cpp diff --git a/src/libtomahawk/ViewManager.cpp b/src/libtomahawk/ViewManager.cpp index a062156ba..4c3742a3a 100644 --- a/src/libtomahawk/ViewManager.cpp +++ b/src/libtomahawk/ViewManager.cpp @@ -42,7 +42,6 @@ #include "playlist/InboxModel.h" #include "playlist/InboxView.h" #include "playlist/TrackItemDelegate.h" -#include "playlist/PlaylistLargeItemDelegate.h" #include "playlist/RecentlyPlayedModel.h" #include "playlist/dynamic/widgets/DynamicWidget.h" #include "resolvers/ScriptCollection.h" diff --git a/src/libtomahawk/playlist/ContextView.cpp b/src/libtomahawk/playlist/ContextView.cpp index 83c331e09..02766d1a2 100644 --- a/src/libtomahawk/playlist/ContextView.cpp +++ b/src/libtomahawk/playlist/ContextView.cpp @@ -30,7 +30,6 @@ #include "playlist/PlaylistModel.h" #include "playlist/TrackView.h" #include "playlist/GridView.h" -#include "playlist/PlaylistLargeItemDelegate.h" #include "playlist/TrackItemDelegate.h" #include "playlist/TrackDetailView.h" #include "PlayableProxyModelPlaylistInterface.h" diff --git a/src/libtomahawk/playlist/FlexibleTreeView.cpp b/src/libtomahawk/playlist/FlexibleTreeView.cpp index e48962fc5..d072b4d48 100644 --- a/src/libtomahawk/playlist/FlexibleTreeView.cpp +++ b/src/libtomahawk/playlist/FlexibleTreeView.cpp @@ -31,7 +31,6 @@ #include "playlist/TreeView.h" #include "playlist/GridView.h" #include "playlist/ModeHeader.h" -#include "playlist/PlaylistLargeItemDelegate.h" #include "PlayableProxyModelPlaylistInterface.h" #include "TomahawkSettings.h" #include "utils/ImageRegistry.h" @@ -70,10 +69,6 @@ FlexibleTreeView::FlexibleTreeView( QWidget* parent, QWidget* extraHeader ) m_columnView->setColumnHidden( PlayableModel::Filesize, true ); // Hide filesize column per default m_columnView->setColumnHidden( PlayableModel::Composer, true ); // Hide composer column per default*/ -/* PlaylistLargeItemDelegate* del = new PlaylistLargeItemDelegate( PlaylistLargeItemDelegate::LovedTracks, m_trackView, m_trackView->proxyModel() ); - m_trackView->setPlaylistItemDelegate( del ); - m_trackView->proxyModel()->setStyle( PlayableProxyModel::Large );*/ - m_stack = new QStackedWidget(); setLayout( new QVBoxLayout() ); TomahawkUtils::unmarginLayout( layout() ); diff --git a/src/libtomahawk/playlist/FlexibleView.cpp b/src/libtomahawk/playlist/FlexibleView.cpp index 5522b71b7..89412c7c9 100644 --- a/src/libtomahawk/playlist/FlexibleView.cpp +++ b/src/libtomahawk/playlist/FlexibleView.cpp @@ -30,7 +30,6 @@ #include "playlist/PlaylistModel.h" #include "playlist/TrackView.h" #include "playlist/GridView.h" -#include "playlist/PlaylistLargeItemDelegate.h" #include "playlist/TrackItemDelegate.h" #include "playlist/TrackDetailView.h" #include "PlayableProxyModelPlaylistInterface.h" diff --git a/src/libtomahawk/playlist/PlaylistLargeItemDelegate.cpp b/src/libtomahawk/playlist/PlaylistLargeItemDelegate.cpp deleted file mode 100644 index f21a20e51..000000000 --- a/src/libtomahawk/playlist/PlaylistLargeItemDelegate.cpp +++ /dev/null @@ -1,279 +0,0 @@ -/* === This file is part of Tomahawk Player - === - * - * Copyright 2010-2011, Christian Muehlhaeuser - * Copyright 2013, Teo Mrnjavac - * - * Tomahawk is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Tomahawk is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Tomahawk. If not, see . - */ - -#include "PlaylistLargeItemDelegate.h" - -#include -#include -#include - -#include "Query.h" -#include "Result.h" -#include "Artist.h" -#include "Source.h" -#include "SourceList.h" - -#include "PlaylistView.h" -#include "PlayableModel.h" -#include "PlayableItem.h" -#include "PlayableProxyModel.h" -#include "TrackView.h" -#include "ViewHeader.h" - -#include "utils/TomahawkUtilsGui.h" -#include "utils/Logger.h" - -// Forward Declarations breaking QSharedPointer -#if QT_VERSION < QT_VERSION_CHECK( 5, 0, 0 ) - #include "utils/PixmapDelegateFader.h" -#endif - - -using namespace Tomahawk; - - -PlaylistLargeItemDelegate::PlaylistLargeItemDelegate( DisplayMode mode, TrackView* parent, PlayableProxyModel* proxy ) - : PlaylistItemDelegate( parent, proxy ) - , m_view( parent ) - , m_model( proxy ) - , m_mode( mode ) -{ -} - - -QSize -PlaylistLargeItemDelegate::sizeHint( const QStyleOptionViewItem& option, const QModelIndex& index ) const -{ - QSize size = QStyledItemDelegate::sizeHint( option, index ); - - int rowHeight = option.fontMetrics.height() + 5; - size.setHeight( rowHeight * 2.5 ); - - return size; -} - - -void -PlaylistLargeItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const -{ - PlayableItem* item = m_model->itemFromIndex( m_model->mapToSource( index ) ); - Q_ASSERT( item ); - - QStyleOptionViewItemV4 opt = option; - prepareStyleOption( &opt, index, item ); - - bool isUnlistened = true; - if ( m_mode == Inbox ) - { - QList< Tomahawk::SocialAction > socialActions = item->query()->queryTrack()->allSocialActions(); - foreach ( const Tomahawk::SocialAction& sa, socialActions ) - { - if ( sa.action.toString() == "Inbox" && sa.value.toBool() == false ) - { - isUnlistened = false; - break; - } - } - } - - opt.text.clear(); - - qApp->style()->drawControl( QStyle::CE_ItemViewItem, &opt, painter ); - - if ( m_view->header()->visualIndex( index.column() ) > 0 ) - return; - - const track_ptr track = item->query()->track(); - - //TODO: lowerText isn't displayed any more, get rid of the code path once we have an alternative - QString lowerText; - - if ( m_mode == RecentlyPlayed && item->playbackLog().source ) - { - QString playtime = TomahawkUtils::ageToString( QDateTime::fromTime_t( item->playbackLog().timestamp ), true ); - - if ( item->playbackLog().source->isLocal() ) - lowerText = QString( tr( "played %1 by you", "e.g. played 3 hours ago by you" ) ).arg( playtime ); - else - lowerText = QString( tr( "played %1 by %2", "e.g. played 3 hours ago by SomeSource" ) ).arg( playtime ).arg( item->playbackLog().source->friendlyName() ); - } - - if ( m_mode == LatestAdditions && item->query()->numResults() ) - { - QString playtime = TomahawkUtils::ageToString( QDateTime::fromTime_t( item->query()->results().first()->modificationTime() ), true ); - lowerText = QString( tr( "added %1", "e.g. added 3 hours ago" ) ).arg( playtime ); - } - - if ( m_mode == LovedTracks ) - lowerText = item->query()->queryTrack()->socialActionDescription( "Love", Track::Detailed ); - else if ( m_mode == Inbox ) - lowerText = item->query()->queryTrack()->socialActionDescription( "Inbox", Track::Detailed ); - - painter->save(); - { - QRect r = opt.rect.adjusted( 4, 6, 0, -6 ); - - // Paint Now Playing Speaker Icon - if ( item->isPlaying() || - ( m_mode == Inbox && isUnlistened ) ) - { - const int pixMargin = 4; - const int pixHeight = r.height() - pixMargin * 2; - QRect npr = r.adjusted( pixMargin, pixMargin + 1, pixHeight - r.width() + pixMargin, -pixMargin + 1 ); - if ( item->isPlaying() ) - { - painter->drawPixmap( npr, TomahawkUtils::defaultPixmap( TomahawkUtils::NowPlayingSpeaker, TomahawkUtils::Original, npr.size() ) ); - r.adjust( pixHeight + 2 * pixMargin, 0, 0, 0 ); - } - else - { - npr = npr.adjusted( 0, npr.height() / 4, -npr.width() / 2, -npr.height() / 4 ); - painter->drawPixmap( npr, TomahawkUtils::defaultPixmap( TomahawkUtils::InboxNewItem, TomahawkUtils::Original, npr.size() ) ); - r.adjust( npr.width() + 2 * pixMargin, 0, 0, 0 ); - } - } - - painter->setPen( opt.palette.text().color() ); - - r.adjust( 4, 0, -16, 0 ); - QRect leftRect; - - if ( hoveringOver() == index && !index.data().toString().isEmpty() && index.column() == 0 ) - { - leftRect = drawInfoButton( painter, r, index, 0.9 ); - } - else - { - leftRect = drawCover( painter, r, item, index ); - } - - leftRect.setX( leftRect.left() + 8 ); - QRect rightRect = r.adjusted( r.width() - m_smallBoldFontMetrics.width( TomahawkUtils::timeToString( track->duration() ) ), 0, 0, 0 ); - { - const QRect leftRectBefore = leftRect; - leftRect = drawSourceIcon( painter, leftRect, item, 0.5 ); - rightRect.moveLeft( rightRect.left() - ( leftRectBefore.width() - leftRect.width() ) ); - } - - QFont bigBoldFont = m_bigBoldFont; - bigBoldFont.setPointSize( TomahawkUtils::defaultFontSize() + 3 ); - bigBoldFont.setWeight( 99 ); - - painter->setFont( bigBoldFont ); - const QString text = painter->fontMetrics().elidedText( track->track(), Qt::ElideRight, leftRect.width() ); - painter->drawText( leftRect, text, m_topOption ); - - painter->setFont( m_smallFont ); - QTextDocument textDoc; -// if ( track->album().isEmpty() ) - textDoc.setHtml( tr( "%1", "e.g. by SomeArtist" ).arg( track->artist() ) ); -/* else - textDoc.setHtml( tr( "by %1 on %2", "e.g. by SomeArtist on SomeAlbum" ).arg( track->artist() ).arg( track->album() ) );*/ - textDoc.setDocumentMargin( 0 ); - textDoc.setDefaultFont( painter->font() ); - textDoc.setDefaultTextOption( m_topOption ); - - if ( !( option.state & QStyle::State_Selected || item->isPlaying() ) ) - { - QColor mid = opt.palette.mid().color(); - //HACK: adjust small text shade based on a guess if normal text is darker or lighter - // than normal background. - if ( opt.palette.text().color().lightness() < opt.palette.base().color().lightness() ) - painter->setPen( mid.darker( 140 ) ); - else - painter->setPen( mid.lighter( 140 ) ); - } - - if ( textDoc.idealWidth() <= leftRect.width() ) - drawRichText( painter, opt, leftRect.adjusted( 0, QFontMetrics( bigBoldFont ).height() + 1, 0, 0 ), Qt::AlignTop, textDoc ); - - //TODO: replace usage of lowerText which is not drawn any more with appropriate loveBox/sentBox style boxes - textDoc.setHtml( lowerText ); - textDoc.setDocumentMargin( 0 ); - textDoc.setDefaultFont( painter->font() ); - textDoc.setDefaultTextOption( m_bottomOption ); - - if ( textDoc.idealWidth() > leftRect.width() ) - textDoc.setHtml( item->query()->queryTrack()->socialActionDescription( "Love", Track::Short ) ); - -// drawRichText( painter, opt, leftRect, Qt::AlignBottom, textDoc ); - - leftRect = rightRect.adjusted( -128, 4, 0, -4 ); - leftRect.setWidth( 96 ); - if ( m_mode == Inbox ) - { - QDateTime earliestTimestamp = QDateTime::currentDateTime(); - QList< Tomahawk::source_ptr > sources; - foreach ( const Tomahawk::SocialAction& sa, item->query()->queryTrack()->socialActions( "Inbox", QVariant() /*neither true nor false!*/, true ) ) - { - QDateTime saTimestamp = QDateTime::fromTime_t( sa.timestamp.toInt() ); - if ( saTimestamp < earliestTimestamp && saTimestamp.toTime_t() > 0 ) - earliestTimestamp = saTimestamp; - - sources << sa.source; - } - - QString timeString = TomahawkUtils::ageToString( earliestTimestamp, true ); - - drawGenericBox( painter, opt, leftRect, timeString, sources, index ); - } - else if ( m_mode == RecentlyPlayed ) - { - if ( item->playbackLog().source ) - { - QList< Tomahawk::source_ptr > sources; - sources << item->playbackLog().source; - - QString playtime = TomahawkUtils::ageToString( QDateTime::fromTime_t( item->playbackLog().timestamp ), true ); - - drawGenericBox( painter, opt, leftRect, playtime, sources, index ); - } - } - else if ( m_mode == LatestAdditions ) - { - if ( item->query()->numResults() ) - { - QList< Tomahawk::source_ptr > sources; - - QString modtime = TomahawkUtils::ageToString( QDateTime::fromTime_t( item->query()->results().first()->modificationTime() ), true ); - - drawGenericBox( painter, opt, leftRect, modtime, sources, index ); - } - } - else - { - drawLoveBox( painter, leftRect, item, index ); - } - - if ( track->duration() > 0 ) - { - painter->setPen( opt.palette.text().color() ); - painter->setFont( m_smallBoldFont ); - painter->drawText( rightRect, TomahawkUtils::timeToString( track->duration() ), m_centerRightOption ); - } - } - painter->restore(); -} - - -void -PlaylistLargeItemDelegate::modelChanged() -{ - PlaylistItemDelegate::modelChanged(); -} diff --git a/src/libtomahawk/playlist/PlaylistLargeItemDelegate.h b/src/libtomahawk/playlist/PlaylistLargeItemDelegate.h deleted file mode 100644 index f5387c2c4..000000000 --- a/src/libtomahawk/playlist/PlaylistLargeItemDelegate.h +++ /dev/null @@ -1,58 +0,0 @@ -/* === This file is part of Tomahawk Player - === - * - * Copyright 2010-2011, Christian Muehlhaeuser - * - * Tomahawk is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Tomahawk is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Tomahawk. If not, see . - */ - -#ifndef PLAYLISTLARGEITEMDELEGATE_H -#define PLAYLISTLARGEITEMDELEGATE_H - -#include -#include -#include - -#include "PlaylistItemDelegate.h" -#include "DllMacro.h" -#include "Typedefs.h" - -class PlayableItem; -class PlayableProxyModel; -class TrackView; - -class DLLEXPORT PlaylistLargeItemDelegate : public PlaylistItemDelegate -{ -Q_OBJECT - -public: - enum DisplayMode - { LovedTracks, RecentlyPlayed, LatestAdditions, Inbox }; - - PlaylistLargeItemDelegate( DisplayMode mode, TrackView* parent, PlayableProxyModel* proxy ); - - virtual QSize sizeHint( const QStyleOptionViewItem& option, const QModelIndex& index ) const; - -protected: - void paint( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const; - -protected slots: - virtual void modelChanged(); - -private: - TrackView* m_view; - PlayableProxyModel* m_model; - DisplayMode m_mode; -}; - -#endif // PLAYLISTLARGEITEMDELEGATE_H diff --git a/src/libtomahawk/widgets/HistoryWidget.cpp b/src/libtomahawk/widgets/HistoryWidget.cpp index 6dc42fdc1..a4604206e 100644 --- a/src/libtomahawk/widgets/HistoryWidget.cpp +++ b/src/libtomahawk/widgets/HistoryWidget.cpp @@ -25,7 +25,6 @@ #include "playlist/RecentlyPlayedModel.h" #include "playlist/TrackView.h" -#include "playlist/PlaylistLargeItemDelegate.h" #include "utils/TomahawkStyle.h" #include "utils/TomahawkUtilsGui.h" #include "utils/Logger.h" @@ -89,9 +88,6 @@ HistoryWidget::HistoryWidget( const source_ptr& source, QWidget* parent ) else m_model->setDescription( tr( "%1's recently played tracks" ).arg( source->friendlyName() ) ); -/* PlaylistLargeItemDelegate* del = new PlaylistLargeItemDelegate( PlaylistLargeItemDelegate::RecentlyPlayed, trackView(), trackView()->proxyModel() ); - trackView()->setPlaylistItemDelegate( del );*/ - trackView()->setIndentation( 0 ); trackView()->setUniformRowHeights( false ); diff --git a/src/tomahawk/sourcetree/SourcesModel.cpp b/src/tomahawk/sourcetree/SourcesModel.cpp index 2b3ff704f..e6130ffd0 100644 --- a/src/tomahawk/sourcetree/SourcesModel.cpp +++ b/src/tomahawk/sourcetree/SourcesModel.cpp @@ -322,11 +322,6 @@ SourcesModel::appendGroups() boost::bind( &ViewManager::newReleasesWidget, ViewManager::instance() ) ); newReleases->setSortValue( 7 ); -/* GenericPageItem* recent = new GenericPageItem( this, m_browse, tr( "Recently Played" ), ImageRegistry::instance()->icon( RESPATH "images/recently-played.svg" ), - boost::bind( &ViewManager::showRecentPlaysPage, ViewManager::instance() ), - boost::bind( &ViewManager::recentPlaysWidget, ViewManager::instance() ) ); - recent->setSortValue( 8 );*/ - m_collectionsGroup = new GroupItem( this, m_rootItem, tr( "Friends" ), 4 ); m_cloudGroup = new GroupItem( this, m_rootItem, tr( "Cloud" ), 5 ); diff --git a/src/tomahawk/sourcetree/items/SourceItem.cpp b/src/tomahawk/sourcetree/items/SourceItem.cpp index 3e07e7bec..f0b5b9c96 100644 --- a/src/tomahawk/sourcetree/items/SourceItem.cpp +++ b/src/tomahawk/sourcetree/items/SourceItem.cpp @@ -38,7 +38,6 @@ #include "playlist/PlaylistView.h" #include "playlist/RecentlyAddedModel.h" #include "playlist/RecentlyPlayedModel.h" -#include "playlist/PlaylistLargeItemDelegate.h" #include "sip/PeerInfo.h" #include "sip/SipPlugin.h" #include "widgets/HistoryWidget.h" @@ -620,9 +619,6 @@ SourceItem::latestAdditionsClicked() else raModel->setDescription( tr( "Latest additions to %1's collection" ).arg( m_source->friendlyName() ) ); -/* PlaylistLargeItemDelegate* del = new PlaylistLargeItemDelegate( PlaylistLargeItemDelegate::LatestAdditions, pv->trackView(), pv->trackView()->proxyModel() ); - pv->trackView()->setPlaylistItemDelegate( del );*/ - pv->setPlayableModel( raModel ); pv->trackView()->sortByColumn( PlayableModel::Age, Qt::DescendingOrder ); pv->detailedView()->sortByColumn( PlayableModel::Age, Qt::DescendingOrder );