blob: 2713555bd445566ad1efeca2b62f4d864ef284d4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
#ifndef COVERARTDELEGATE_H
#define COVERARTDELEGATE_H
#include <QHash>
#include <QList>
#include <QLinkedList>
#include "library/tableitemdelegate.h"
class CoverInfoRelative;
class TrackModel;
class WLibraryTableView;
class CoverArtDelegate : public TableItemDelegate {
Q_OBJECT
public:
explicit CoverArtDelegate(WLibraryTableView* parent);
~CoverArtDelegate() override = default;
void paintItem(QPainter* painter,
const QStyleOptionViewItem& option,
const QModelIndex& index) const;
signals:
void coverReadyForCell(int row, int column);
private slots:
// If it is true, it must not try to load and search covers.
//
// It means that in this cases it will just draw
// covers which are already in the pixmapcache.
//
// It is useful to handle cases when the user scroll down
// very fast or when they hold an arrow key, because
// in these cases 'paint()' would be called very often
// and it might make CoverDelegate starts many searches,
// which could bring performance issues.
void slotOnlyCachedCoverArt(bool b);
void slotCoverFound(const QObject* pRequestor,
const CoverInfoRelative& info,
QPixmap pixmap, bool fromCache);
private:
QTableView* m_pTableView;
bool m_bOnlyCachedCover;
int m_iCoverColumn;
int m_iCoverSourceColumn;
int m_iCoverTypeColumn;
int m_iCoverLocationColumn;
int m_iCoverHashColumn;
int m_iTrackLocationColumn;
int m_iIdColumn;
// We need to record rows in paint() (which is const) so these are marked
// mutable.
mutable QList<int> m_cacheMissRows;
mutable QHash<quint16, QLinkedList<int> > m_hashToRow;
};
#endif // COVERARTDELEGATE_H
|