Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

part 1 of YouListWidget work

  • Loading branch information...
commit d19da7203441d2069cb974c10c8683f386211145 1 parent 14c4415
doug mansell authored September 07, 2009
2  app/radio/widgets/MultiStarterWidget.cpp
@@ -52,7 +52,7 @@ MultiStarterWidget::MultiStarterWidget(bool advanced, int maxSources, QWidget *p
52 52
     
53 53
     QTabWidget* tabwidget = new QTabWidget();
54 54
 
55  
-    tabwidget->addTab(new YouListWidget(this), tr("You"));
  55
+    tabwidget->addTab(new YouListWidget(lastfm::ws::Username, this), tr("You"));
56 56
     
57 57
     m_artists = new SourceSelectorWidget(new ArtistSearch());    
58 58
     tabwidget->addTab(m_artists, tr("Artists"));
51  app/radio/widgets/YouListWidget.cpp
... ...
@@ -0,0 +1,51 @@
  1
+/*
  2
+   Copyright 2005-2009 Last.fm Ltd. 
  3
+
  4
+   This file is part of the Last.fm Desktop Application Suite.
  5
+
  6
+   lastfm-desktop is free software: you can redistribute it and/or modify
  7
+   it under the terms of the GNU General Public License as published by
  8
+   the Free Software Foundation, either version 3 of the License, or
  9
+   (at your option) any later version.
  10
+
  11
+   lastfm-desktop is distributed in the hope that it will be useful,
  12
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
  13
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14
+   GNU General Public License for more details.
  15
+
  16
+   You should have received a copy of the GNU General Public License
  17
+   along with lastfm-desktop.  If not, see <http://www.gnu.org/licenses/>.
  18
+*/
  19
+
  20
+#include "YouListWidget.h"
  21
+#include <lastfm.h>
  22
+
  23
+
  24
+YouListWidget::YouListWidget(const QString& username, QWidget* parent)
  25
+    : QTreeWidget(parent) 
  26
+{
  27
+    QString displayName = (username == lastfm::ws::Username) ? "Your " : username + "'s ";
  28
+
  29
+    setAlternatingRowColors( true );
  30
+    setHeaderHidden( true );
  31
+    setExpandsOnDoubleClick( false );
  32
+    setItemsExpandable( false );
  33
+    setIndentation( 10 );
  34
+    setRootIsDecorated( false );
  35
+    QList<QTreeWidgetItem*> headerItems;
  36
+    QTreeWidgetItem* h;
  37
+    headerItems << (h = new QTreeWidgetItem( QStringList() << displayName + "Stations" ));
  38
+    h->addChild( new QTreeWidgetItem( QStringList() << displayName + "Library" ));
  39
+    h->addChild( new QTreeWidgetItem( QStringList() << displayName + "Loved Tracks" ));
  40
+    h->addChild( new QTreeWidgetItem( QStringList() << displayName + "Recommendations" ));
  41
+    h->addChild( new QTreeWidgetItem( QStringList() << displayName + "Neighbourhood" ));
  42
+
  43
+    headerItems << new QTreeWidgetItem( QStringList() << displayName + "Friends" );
  44
+    headerItems << new QTreeWidgetItem( QStringList() << displayName + "Artists" );
  45
+    headerItems << new QTreeWidgetItem( QStringList() << displayName + "Tags" );
  46
+    headerItems << new QTreeWidgetItem( QStringList() << displayName + "Playlists" );
  47
+
  48
+    addTopLevelItems( headerItems );
  49
+    h->setExpanded( true );
  50
+    h->setFlags( h->flags() & ~Qt::ItemIsSelectable );
  51
+}
45  app/radio/widgets/YouListWidget.h
... ...
@@ -1,3 +1,22 @@
  1
+/*
  2
+   Copyright 2005-2009 Last.fm Ltd. 
  3
+
  4
+   This file is part of the Last.fm Desktop Application Suite.
  5
+
  6
+   lastfm-desktop is free software: you can redistribute it and/or modify
  7
+   it under the terms of the GNU General Public License as published by
  8
+   the Free Software Foundation, either version 3 of the License, or
  9
+   (at your option) any later version.
  10
+
  11
+   lastfm-desktop is distributed in the hope that it will be useful,
  12
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
  13
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14
+   GNU General Public License for more details.
  15
+
  16
+   You should have received a copy of the GNU General Public License
  17
+   along with lastfm-desktop.  If not, see <http://www.gnu.org/licenses/>.
  18
+*/
  19
+
1 20
 #ifndef YOU_LIST_WIDGET_H_
2 21
 #define YOU_LIST_WIDGET_H_
3 22
 
@@ -6,29 +25,9 @@
6 25
 class YouListWidget : public QTreeWidget
7 26
 {
8 27
     Q_OBJECT
  28
+
9 29
 public:
10  
-    YouListWidget( QWidget* parent )
11  
-    :QTreeWidget( parent ) {
12  
-        setAlternatingRowColors( true );
13  
-        setHeaderHidden( true );
14  
-        setExpandsOnDoubleClick( false );
15  
-        setItemsExpandable( false );
16  
-        setIndentation( 10 );
17  
-        setRootIsDecorated( false );
18  
-        QList<QTreeWidgetItem*> headerItems;
19  
-        QTreeWidgetItem* h;
20  
-        headerItems << (h = new QTreeWidgetItem( QStringList() << tr( "Your Stations" )));
21  
-        h->addChild( new QTreeWidgetItem( QStringList() << "Your Library"));
22  
-        h->addChild( new QTreeWidgetItem( QStringList() << "Your Loved Tracks"));
23  
-        h->addChild( new QTreeWidgetItem( QStringList() << "Your Recommendations"));
24  
-
25  
-        headerItems << new QTreeWidgetItem( QStringList() << tr( "Your Artists" ));
26  
-        headerItems << new QTreeWidgetItem( QStringList() << tr( "Your Tags" ));
27  
-    
28  
-        addTopLevelItems( headerItems );
29  
-        h->setExpanded( true );
30  
-        h->setFlags( h->flags() & ~Qt::ItemIsSelectable );
31  
-    }
  30
+    YouListWidget(const QString& username, QWidget* parent = 0);
32 31
 };
33 32
 
34  
-#endif //YOU_LIST_WIDGET_H_
  33
+#endif // YOU_LIST_WIDGET_H_

0 notes on commit d19da72

Please sign in to comment.
Something went wrong with that request. Please try again.