1 /***************************************************************************
2 * copyright : (C) 2005-2006 Seb Ruiz <ruiz@kde.org> *
3 **************************************************************************/
5 /***************************************************************************
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. *
12 ***************************************************************************/
14 #ifndef AMAROK_STATISTICS_H
15 #define AMAROK_STATISTICS_H
17 #include "MainWindow.h"
19 #include <K3ListView> //baseclass
20 #include <KDialog> //baseclass
29 class StatisticsDetailedItem
;
31 class Statistics
: public KDialog
36 explicit Statistics( QWidget
*parent
= 0, const char *name
= 0 );
39 static Statistics
*instance() { return s_instance
; }
43 void slotSetFilterTimeout();
46 StatisticsList
*m_listView
;
47 KLineEdit
*m_lineEdit
;
50 static Statistics
*s_instance
;
53 class StatisticsList
: public K3ListView
58 explicit StatisticsList( QWidget
*parent
, const char *name
=0 );
61 QString
filter() { return m_filter
; }
62 void setFilter( const QString
&filter
) { m_filter
= filter
; }
68 void itemClicked( Q3ListViewItem
*item
);
69 void showContextMenu( Q3ListViewItem
*item
, const QPoint
&p
, int );
70 void startHover( Q3ListViewItem
*item
);
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
;
90 /// The listview items which are the headers for the categories
91 class StatisticsItem
: public QObject
, public K3ListViewItem
96 StatisticsItem( QString text
, StatisticsList
*parent
, K3ListViewItem
*after
=0, const char *name
=0 );
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
);
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
115 static const int ANIM_INTERVAL
= 18;
116 static const int ANIM_MAX
= 20;
119 void slotAnimTimer();
122 QColor
blendColors( const QColor
& color1
, const QColor
& color2
, int percent
);
134 /// Listview items for the children of expanded items (the actual results)
135 class StatisticsDetailedItem
: public K3ListViewItem
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
};
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
169 #endif /* AMAROK_STATISTICS_H */