summaryrefslogtreecommitdiffstats
path: root/playerwidget.cpp
diff options
context:
space:
mode:
authorArno <arno@disconnect.de>2017-02-25 08:31:41 +0100
committerArno <arno@disconnect.de>2017-02-25 08:31:41 +0100
commitffa50a24296688d1c6e9f4de2315bbd494f86cf6 (patch)
treedc8907443a6830456e0b896a075f0b39fcbb9ed1 /playerwidget.cpp
parent1530584c9b942d07e331323867072b6a9809119b (diff)
downloadBeetPlayer-ffa50a24296688d1c6e9f4de2315bbd494f86cf6.tar.gz
BeetPlayer-ffa50a24296688d1c6e9f4de2315bbd494f86cf6.tar.bz2
BeetPlayer-ffa50a24296688d1c6e9f4de2315bbd494f86cf6.zip
Rethink GUI
While figuring out how to populate the album view, I realized that I don't want to view my music by albums, only by artist, maybe by genre... So I removed the QComboBox for the different sort orders and concentrated on the filter, which is a good thing (tm). Just make the filter find anything you need. Name/Title is already implemented. Have to think about genre/year...
Diffstat (limited to 'playerwidget.cpp')
-rw-r--r--playerwidget.cpp60
1 files changed, 24 insertions, 36 deletions
diff --git a/playerwidget.cpp b/playerwidget.cpp
index e46990e..5df9951 100644
--- a/playerwidget.cpp
+++ b/playerwidget.cpp
@@ -1,4 +1,3 @@
-#include <QComboBox>
#include <QGroupBox>
#include <QLineEdit>
#include <QPushButton>
@@ -9,54 +8,43 @@
#include <QSplitter>
#include <QStandardItemModel>
#include <QStandardItem>
-#include <QSortFilterProxyModel>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QSqlDatabase>
#include <QSqlQuery>
#include "playerwidget.h"
+#include "beetplayerproxy.h"
PlayerWidget::PlayerWidget(QWidget *parent) : QWidget(parent){
setupGui();
}
void PlayerWidget::setupGui(){
+ //THE view
+ mView = new QTreeView;
+ mViewModel = new QStandardItemModel;
+ mViewProxy = new BeetPlayerProxy;
+ mViewProxy->setSourceModel(mViewModel);
+ mView->setModel(mViewProxy);
+
//filter
QGroupBox *filterGB = new QGroupBox(tr("Filter"));
mFilter = new QLineEdit;
connect(mFilter, SIGNAL(returnPressed()), this, SLOT(doFilter()));
QPushButton *filterB = new QPushButton(tr("Go!"));
connect(filterB, SIGNAL(clicked()), this, SLOT(doFilter()));
+ QPushButton *clearFilterB = new QPushButton(tr("Clear"));
+ connect(clearFilterB, SIGNAL(clicked()), this, SLOT(clearFilter()));
QHBoxLayout *filterLayout = new QHBoxLayout;
filterLayout->addWidget(mFilter);
filterLayout->addWidget(filterB);
+ filterLayout->addWidget(clearFilterB);
filterGB->setLayout(filterLayout);
- //show by
- QGroupBox *sortByGB = new QGroupBox(tr("Show by"));
- mSortBy = new QComboBox;
- mSortBy->addItems(QStringList() << tr("Artists") << tr("Albums") << tr("Genres"));
- connect(mSortBy, SIGNAL(currentIndexChanged(QString)), this, SLOT(populateBy(QString)));
- QPushButton *refreshSortB = new QPushButton(tr("Refresh"));
- connect(refreshSortB, SIGNAL(clicked()), this, SLOT(refreshSort()));
- QHBoxLayout *sortByL = new QHBoxLayout;
- sortByL->addWidget(mSortBy);
- sortByL->addWidget(refreshSortB);
- sortByL->setStretchFactor(mSortBy, 3);
- sortByGB->setLayout(sortByL);
-
- //THE view
- mView = new QTreeView;
- mViewModel = new QStandardItemModel;
- mViewProxy = new QSortFilterProxyModel;
- mViewProxy->setSourceModel(mViewModel);
- mView->setModel(mViewProxy);
-
//left widget
QWidget *leftWidget = new QWidget;
QVBoxLayout *leftWidgetL = new QVBoxLayout;
- leftWidgetL->addWidget(sortByGB);
leftWidgetL->addWidget(filterGB);
leftWidgetL->addWidget(mView);
leftWidget->setLayout(leftWidgetL);
@@ -110,20 +98,10 @@ void PlayerWidget::setupGui(){
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addWidget(splitter);
setLayout(mainLayout);
- refreshSort();
-}
-
-void PlayerWidget::populateBy(QString selector){
- if(selector == tr("Artists")){
- populateByArtist();
- }
+ populate();
}
-void PlayerWidget::refreshSort(){
- populateBy(mSortBy->currentText());
-}
-
-void PlayerWidget::populateByArtist(){
+void PlayerWidget::populate(){
//prepare Queries
QSqlDatabase db = QSqlDatabase::database("beetplayerdb");
QSqlQuery artistsQ(db);
@@ -131,7 +109,7 @@ void PlayerWidget::populateByArtist(){
QSqlQuery albumQ(db);
albumQ.prepare("SELECT DISTINCT(songs.ialbums_id), talbum_name, siyear FROM songs, albums WHERE songs.iartists_id = :artistid AND songs.ialbums_id = albums.ialbums_id ORDER BY siyear ASC");
QSqlQuery songQ(db);
- songQ.prepare("SELECT sipos, ttitle, tfullpath FROM songs WHERE ialbums_id = :alid AND iartists_id = :arid ORDER BY sipos ASC");
+ songQ.prepare("SELECT sipos, ttitle, tfullpath, igenres_id FROM songs WHERE ialbums_id = :alid AND iartists_id = :arid ORDER BY sipos ASC");
//reset view+model
mView->setSortingEnabled(false);
@@ -170,8 +148,18 @@ void PlayerWidget::populateByArtist(){
curSong->setData(Song, TypeRole);
curSong->setData(songQ.value(0), IdRole);
curSong->setData(songQ.value(2), FullPathRole);
+ curSong->setData(songQ.value(3), GenreRole);
curAlbum->appendRow(curSong);
}
}
}
}
+
+void PlayerWidget::doFilter(){
+ mViewProxy->setFilterRegExp(QRegExp(mFilter->text()));
+}
+
+void PlayerWidget::clearFilter(){
+ mFilter->setText(QString());
+ doFilter();
+}