Bug 231044 - lastfm plugin doesn't load any add info
Summary: lastfm plugin doesn't load any add info
Status: RESOLVED FIXED
Alias: None
Product: amarok
Classification: Applications
Component: Services/Last.fm (show other bugs)
Version: 2.3.0
Platform: unspecified Linux
: NOR normal
Target Milestone: ---
Assignee: Amarok Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-03-17 01:26 UTC by Vovochka
Modified: 2010-05-28 23:33 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In: 2.3.2


Attachments
screenshot (119.00 KB, image/png)
2010-03-17 01:27 UTC, Vovochka
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Vovochka 2010-03-17 01:26:03 UTC
Version:           2.3.0 (using 4.4.1 (KDE 4.4.1) "release 225", KDE:KDE4:Factory:Desktop / openSUSE_11.2)
Compiler:          gcc
OS:                Linux (x86_64) release 2.6.31.12-0.1-desktop

When starting amarok with lastfm plugin opened (it was opened when u closed amarok last time) lastfm plugin doesn't load info such as favorite artists, neighbors, friends...

This bug exists since 2.2
Comment 1 Vovochka 2010-03-17 01:27:37 UTC
Created attachment 41702 [details]
screenshot
Comment 2 Myriam Schweingruber 2010-03-17 08:55:14 UTC
Everything works fine here. Are you a last.fm subscriber?
Comment 3 Vovochka 2010-03-17 09:04:28 UTC
Yes :)
Comment 4 Myriam Schweingruber 2010-03-17 09:21:07 UTC
Thank yu for the feedback. Can somebody else reproduce this?
Comment 5 Rick W. Chen 2010-05-17 07:20:20 UTC
I can, I'll look at it soon.
Comment 6 Rick W. Chen 2010-05-18 17:54:17 UTC
I fixed this locally, but it won't be in until the release after next.
Comment 7 Rick W. Chen 2010-05-28 23:01:18 UTC
commit e54907db30e3bd7b59fd3b1dac2386b842e17306
Author: Rick W. Chen <stuffcorpse@archlinux.us>
Date:   Fri May 28 17:15:47 2010 +1200

    Fix Last.fm service browser not updating tree view if it's open upon startup
    
    BUG: 231044

diff --git a/ChangeLog b/ChangeLog
index a593e92..ce352da 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -9,6 +9,8 @@ VERSION 2.3.2-Beta 1
   CHANGES:
 
   BUGFIXES:
+    * Fixed Last.fm service browser not updating its view if it's open on
+      startup. (BR 231044)
     * Fixed clicking on browser categories not honoring mouse settings. (BR 226533)
     * Fixed usability issue with regards to context menu item order when right
       clicking in the playlist widget. (BR 198650)
diff --git a/src/services/lastfm/LastFmTreeModel.cpp b/src/services/lastfm/LastFmTreeModel.cpp
index b679de3..603e260 100644
--- a/src/services/lastfm/LastFmTreeModel.cpp
+++ b/src/services/lastfm/LastFmTreeModel.cpp
@@ -241,13 +241,14 @@ LastFmTreeModel::changeData ( int row, T& old_data, const T& new_data )
 void
 LastFmTreeModel::emitRowChanged( int parent_row, int child_row )
 {
-    QModelIndex parent;
-    if (child_row != -1)
-    parent = index( parent_row, 0 );
-
-    QModelIndex i = index( child_row, 0, parent );
-
-    emit dataChanged( i, i );
+    QModelIndex parent = index( parent_row, 0 );
+    if( child_row != -1 )
+    {
+        QModelIndex i = index( child_row, 0, parent );
+        emit dataChanged( i, i );
+    }
+    else
+        emit dataChanged( parent, parent );
 }
 
 
@@ -284,8 +285,9 @@ LastFmTreeModel::downloadAvatar ( const QString& user, const KUrl& url )
 {
     //     debug() << "downloading " << user << "'s avatar @ "  << url;
     AvatarDownloader* downloader = new AvatarDownloader();
-    downloader->downloadAvatar ( user, url );
-    connect ( downloader, SIGNAL ( signalAvatarDownloaded ( QPixmap ) ), SLOT ( onAvatarDownloaded ( QPixmap ) ) );
+    downloader->downloadAvatar( user, url );
+    connect( downloader, SIGNAL(avatarDownloaded(const QString&, QPixmap)),
+                         SLOT(onAvatarDownloaded(const QString&, QPixmap)) );
 }
 
 void
@@ -316,21 +318,14 @@ LastFmTreeModel::prepareAvatar ( QPixmap& avatar, int size )
 }
 
 void
-LastFmTreeModel::onAvatarDownloaded ( QPixmap avatar )
+LastFmTreeModel::onAvatarDownloaded( const QString &username, QPixmap avatar )
 {
     //     DEBUG_BLOCK
-    QString const username = static_cast<AvatarDownloader*> ( sender() )->username();
-
-    if ( !avatar.isNull() && avatar.height() > 0 && avatar.width() > 0 )
+    if( !avatar.isNull() && avatar.height() > 0 && avatar.width() > 0 )
     {
         int m = m_avatarSize;
 
-        if ( username.toLower() == m_userName.toLower() )
-        {
-            mAvatar = avatar.scaled ( m, m, Qt::KeepAspectRatio, Qt::SmoothTransformation );
-            //             emitRowChanged( LastFm::MyProfile );
-        }
-        else
+        if( username != m_userName )
         {
             avatar = avatar.scaled ( m, m, Qt::KeepAspectRatio, Qt::SmoothTransformation );
 
diff --git a/src/services/lastfm/LastFmTreeModel.h b/src/services/lastfm/LastFmTreeModel.h
index b905d4f..20d3f90 100644
--- a/src/services/lastfm/LastFmTreeModel.h
+++ b/src/services/lastfm/LastFmTreeModel.h
@@ -46,10 +46,10 @@ enum Type
     //         RecentlyPlayed,
     //         RecentlyLoved,
     //         RecentlyBanned,
+    TopArtists,
     MyTags,
     Friends,
     Neighbors,
-    TopArtists,
 
     //         History,
 
@@ -120,11 +120,11 @@ public:
     virtual QMimeData* mimeData( const QModelIndexList &indices ) const;
 
 private slots:
-    void onAvatarDownloaded ( QPixmap );
-    void slotAddNeighbors ();
-    void slotAddFriends ();
-    void slotAddTags ();
-    void slotAddTopArtists ();
+    void onAvatarDownloaded( const QString& username, QPixmap );
+    void slotAddNeighbors();
+    void slotAddFriends();
+    void slotAddTags();
+    void slotAddTopArtists();
 
 private:
     void setupModelData( LastFmTreeItem *parent );