summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArno <arno@disconnect.de>2018-02-17 05:54:31 +0100
committerArno <arno@disconnect.de>2018-02-17 06:26:42 +0100
commitd3439845817beb78b6036762ee42b428069e0482 (patch)
treef6d5431b00841186bfe35931e12dc38a10f43184
parenta9811e98a0838b6790c76e0f3c38e0786aad3e21 (diff)
downloadBeetPlayer-d3439845817beb78b6036762ee42b428069e0482.tar.gz
BeetPlayer-d3439845817beb78b6036762ee42b428069e0482.tar.bz2
BeetPlayer-d3439845817beb78b6036762ee42b428069e0482.zip
Introduce new class CollectionWidget
It's intended to be the base class/widget for different views of the collection, eg. Artists or Songs. Each collection view should have its own widget to make it easier to keep the state when switching between collection views. Let's see how it turns out :)
-rw-r--r--BeetPlayer.pro6
-rw-r--r--collectionwidget.cpp18
-rw-r--r--collectionwidget.h35
3 files changed, 57 insertions, 2 deletions
diff --git a/BeetPlayer.pro b/BeetPlayer.pro
index ef8c662..7b7da0d 100644
--- a/BeetPlayer.pro
+++ b/BeetPlayer.pro
@@ -34,7 +34,8 @@ SOURCES += main.cpp\
indexerdialog.cpp \
helper.cpp \
webdownloader.cpp \
- webradiodialog.cpp
+ webradiodialog.cpp \
+ collectionwidget.cpp
HEADERS += beetplayer.h \
configurationdialog.h \
@@ -45,7 +46,8 @@ HEADERS += beetplayer.h \
indexerdialog.h \
helper.h \
webdownloader.h \
- webradiodialog.h
+ webradiodialog.h \
+ collectionwidget.h
LIBS += -ltag
diff --git a/collectionwidget.cpp b/collectionwidget.cpp
new file mode 100644
index 0000000..a27041a
--- /dev/null
+++ b/collectionwidget.cpp
@@ -0,0 +1,18 @@
+#include <QTreeView>
+#include <QStandardItem>
+#include <QSortFilterProxyModel>
+#include <QHBoxLayout>
+
+#include "collectionwidget.h"
+
+CollectionWidget::CollectionWidget(QWidget *parent) : QWidget(parent){
+ mView = new QTreeView;
+ mModel = new QStandardItemModel(this);
+ mProxy = new QSortFilterProxyModel(this);
+ mProxy->setSourceModel(mModel);
+ mView->setModel(mProxy);
+ mView->setSortingEnabled(true);
+ QHBoxLayout *mainLayout = new QHBoxLayout;
+ mainLayout->addWidget(mView);
+ setLayout(mainLayout);
+}
diff --git a/collectionwidget.h b/collectionwidget.h
new file mode 100644
index 0000000..86135bb
--- /dev/null
+++ b/collectionwidget.h
@@ -0,0 +1,35 @@
+#ifndef COLLECTIONWIDGET_H
+#define COLLECTIONWIDGET_H
+
+#include <QWidget>
+
+class QTreeView;
+class QStandardItemModel;
+class QSortFilterProxyModel;
+
+class CollectionWidget : public QWidget {
+ Q_OBJECT
+ public:
+ enum CustomRoles { TypeRole = Qt::UserRole + 1, IdRole = Qt::UserRole + 2, FullPathRole = Qt::UserRole + 3, GenreRole = Qt::UserRole + 4, ArtistRole = Qt::UserRole + 5, TitleRole = Qt::UserRole + 6, AlbumRole = Qt::UserRole + 7, LengthRole = Qt::UserRole + 8, UrlRole = Qt::UserRole + 9, RemoteRole = Qt::UserRole + 10 };
+ enum ItemType { Artist, Album, Song, Genre, WebRadio };
+ explicit CollectionWidget(QWidget *parent = nullptr);
+ QTreeView *view() { return mView; }
+ QStandardItemModel *model() { return mModel; }
+ QSortFilterProxyModel *proxy() { return mProxy; }
+ void setHeaders(const QStringList headers) { mHeaders = headers; }
+ const QStringList headers() const { return mHeaders; }
+
+ signals:
+
+ public slots:
+ virtual void populate() { return; }
+
+ private:
+ QTreeView *mView;
+ QStandardItemModel *mModel;
+ QSortFilterProxyModel *mProxy;
+ QStringList mHeaders;
+
+};
+
+#endif // COLLECTIONWIDGET_H