File: playqueueview.h

package info (click to toggle)
cantata 3.4.0.ds1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 20,428 kB
  • sloc: cpp: 109,584; perl: 1,366; xml: 722; python: 139; lex: 110; sh: 105; yacc: 78; makefile: 8
file content (152 lines) | stat: -rw-r--r-- 4,066 bytes parent folder | download
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
/*
 * Cantata
 *
 * Copyright (c) 2011-2022 Craig Drummond <craig.p.drummond@gmail.com>
 *
 * ----
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; see the file COPYING.  If not, write to
 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301, USA.
 */

#ifndef PLAYQUEUEVIEW_H
#define PLAYQUEUEVIEW_H

#include "groupedview.h"
#include "itemview.h"
#include "listview.h"
#include "mpd-interface/song.h"
#include "tableview.h"
#include <QAbstractItemView>
#include <QImage>
#include <QPainter>
#include <QPixmap>
#include <QPropertyAnimation>
#include <QSet>
#include <QStackedWidget>

class QAbstractItemModel;
class QAction;
class Action;
class QItemSelectionModel;
class QModelIndex;
class Spinner;
class PlayQueueView;
class MessageOverlay;

class PlayQueueTreeView : public TableView {
public:
	PlayQueueTreeView(PlayQueueView* p);
	~PlayQueueTreeView() override {}
	void paintEvent(QPaintEvent* e) override;

private:
	PlayQueueView* view;
};

class PlayQueueGroupedView : public GroupedView {
public:
	PlayQueueGroupedView(PlayQueueView* p);
	~PlayQueueGroupedView() override;
	void paintEvent(QPaintEvent* e) override;

private:
	PlayQueueView* view;
};

class PlayQueueView : public QStackedWidget {
	Q_OBJECT
	Q_PROPERTY(float fade READ fade WRITE setFade)

public:
	enum BackgroundImage {
		BI_None,
		BI_Cover,
		BI_Custom
	};

	PlayQueueView(QWidget* parent = nullptr);
	~PlayQueueView() override;

	void readConfig();
	void saveConfig();
	void saveHeader();
	void setMode(ItemView::Mode m);
	bool isGrouped() const { return ItemView::Mode_GroupedTree == mode; }
	void setAutoExpand(bool ae);
	bool isAutoExpand() const;
	void setStartClosed(bool sc);
	bool isStartClosed() const;
	void setFilterActive(bool f);
	void updateRows(qint32 row, quint16 curAlbum, bool scroll, bool forceScroll = false);
	void scrollTo(const QModelIndex& index, QAbstractItemView::ScrollHint hint);
	QModelIndex indexAt(const QPoint& point);
	void setModel(QAbstractItemModel* m) { view()->setModel(m); }
	void addAction(QAction* a);
	void setFocus();
	bool hasFocus();
	QAbstractItemModel* model() { return view()->model(); }
	bool haveSelectedItems();
	bool haveUnSelectedItems();
	void setCurrentIndex(const QModelIndex& idx) { view()->setCurrentIndex(idx); }
	void clearSelection();
	QAbstractItemView* view() const;
	bool hasFocus() const;
	QModelIndexList selectedIndexes(bool sorted = true) const;
	QList<Song> selectedSongs() const;
	float fade() { return fadeValue; }
	void setFade(double value);
	void updatePalette();
	Action* removeFromAct() { return removeFromAction; }

public Q_SLOTS:
	void showSpinner();
	void hideSpinner();
	void setImage(const QImage& img);
	void streamFetchStatus(const QString& msg);
	void searchActive(bool a);

Q_SIGNALS:
	void itemsSelected(bool);
	void doubleClicked(const QModelIndex&);
	void cancelStreamFetch();
	void focusSearch(const QString& text);

private:
	void drawBackdrop(QWidget* widget, const QSize& size);

private:
	Action* removeFromAction;
	ItemView::Mode mode;
	PlayQueueGroupedView* groupedView;
	PlayQueueTreeView* treeView;
	Spinner* spinner;
	MessageOverlay* msgOverlay;

	BackgroundImage backgroundImageType;
	QPropertyAnimation animator;
	QImage curentCover;
	QPixmap curentBackground;
	QPixmap previousBackground;
	QSize lastBgndSize;
	double fadeValue;
	int backgroundOpacity;
	int backgroundBlur;
	QString customBackgroundFile;
	friend class PlayQueueGroupedView;
	friend class PlayQueueTreeView;
};

#endif