add mp3 and ogg torrent url info to JamendoAlbum
[amarok.git] / src / Statistics.h
blob072e7d9e00588ae84c61c61e81041d3f428f0a8a
1 /***************************************************************************
2 * copyright : (C) 2005-2006 Seb Ruiz <ruiz@kde.org> *
3 **************************************************************************/
5 /***************************************************************************
6 * *
7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. *
11 * *
12 ***************************************************************************/
14 #ifndef AMAROK_STATISTICS_H
15 #define AMAROK_STATISTICS_H
17 #include "MainWindow.h"
19 #include <K3ListView> //baseclass
20 #include <KDialog> //baseclass
23 class KLineEdit;
24 class QColor;
25 class QTimer;
27 class StatisticsList;
28 class StatisticsItem;
29 class StatisticsDetailedItem;
31 class Statistics : public KDialog
33 Q_OBJECT
35 public:
36 explicit Statistics( QWidget *parent = 0, const char *name = 0 );
37 ~Statistics();
39 static Statistics *instance() { return s_instance; }
41 private slots:
42 void slotSetFilter();
43 void slotSetFilterTimeout();
45 private:
46 StatisticsList *m_listView;
47 KLineEdit *m_lineEdit;
48 QTimer *m_timer;
50 static Statistics *s_instance;
53 class StatisticsList : public K3ListView
55 Q_OBJECT
57 public:
58 explicit StatisticsList( QWidget *parent, const char *name=0 );
59 ~StatisticsList() {}
61 QString filter() { return m_filter; }
62 void setFilter( const QString &filter ) { m_filter = filter; }
63 void renderView();
64 void refreshView();
66 private slots:
67 void clearHover();
68 void itemClicked( Q3ListViewItem *item );
69 void showContextMenu( Q3ListViewItem *item, const QPoint &p, int );
70 void startHover( Q3ListViewItem *item );
72 private:
73 void startDrag();
74 void viewportPaintEvent( QPaintEvent* );
75 void expandInformation( StatisticsItem *item, bool refresh=false );
76 static QString subText( const QString &score, const QString &rating );
78 StatisticsItem *m_trackItem;
79 StatisticsItem *m_mostplayedItem;
80 StatisticsItem *m_artistItem;
81 StatisticsItem *m_albumItem;
82 StatisticsItem *m_genreItem;
83 StatisticsItem *m_newestItem;
85 Q3ListViewItem *m_currentItem;
86 QString m_filter;
87 bool m_expanded;
90 /// The listview items which are the headers for the categories
91 class StatisticsItem : public QObject, public K3ListViewItem
93 Q_OBJECT
95 public:
96 StatisticsItem( QString text, StatisticsList *parent, K3ListViewItem *after=0, const char *name=0 );
97 ~StatisticsItem() {}
99 void paintCell( QPainter *p, const QColorGroup &cg, int column, int width, int align );
100 void paintFocus( QPainter*, const QColorGroup& , const QRect& ) {} //reimp
101 void setIcon( const QString &icon );
103 void enterHover();
104 void leaveHover();
106 void setExpanded( const bool b ) { m_isExpanded = b; }
107 const bool isExpanded() { return m_isExpanded; }
109 void setSubtext( QString t ) { m_subText = t; }
111 int rtti() const { return RTTI; }
112 static const int RTTI = 1000; //header item
114 protected:
115 static const int ANIM_INTERVAL = 18;
116 static const int ANIM_MAX = 20;
118 private slots:
119 void slotAnimTimer();
121 private:
122 QColor blendColors( const QColor& color1, const QColor& color2, int percent );
124 QTimer *m_animTimer;
125 bool m_animEnter;
126 int m_animCount;
128 bool m_isActive;
129 bool m_isExpanded;
131 QString m_subText;
134 /// Listview items for the children of expanded items (the actual results)
135 class StatisticsDetailedItem : public K3ListViewItem
137 public:
138 StatisticsDetailedItem( const QString &text, const QString &subtext, StatisticsItem *parent,
139 StatisticsDetailedItem *after=0, const char *name=0 );
140 ~StatisticsDetailedItem() {}
142 enum ItemType { NONE, TRACK, ARTIST, ALBUM, GENRE, HISTORY };
144 void setup();
145 void paintCell( QPainter *p, const QColorGroup &cg, int column, int width, int align );
147 void setItemType( const ItemType t ) { m_type = t; }
148 const ItemType itemType() { return m_type; }
150 void setUrl( QString &url ) { m_url = url; }
151 const QString url() { return m_url; }
153 void setSubtext( QString t ) { m_subText = t; }
154 QString getSQL(); //get the sql query for all the urls the item represents
155 KUrl::List getURLs();
157 void paintFocus( QPainter*, const QColorGroup& , const QRect& ) {} //reimp
159 int rtti() const { return RTTI; }
160 static const int RTTI = 1001; //detailed item
162 private:
163 ItemType m_type;
164 QString m_url;
165 QString m_subText;
169 #endif /* AMAROK_STATISTICS_H */