Re-add genre combo to library view. Only visible if grouping by artist or album
This commit is contained in:
@@ -448,7 +448,7 @@ set(CANTATA_SRCS ${CANTATA_CORE_SRCS} ${CANTATA_SRCS}
|
||||
widgets/sizewidget.cpp widgets/servicestatuslabel.cpp widgets/spacerwidget.cpp widgets/songdialog.cpp widgets/stretchheaderview.cpp
|
||||
widgets/tableview.cpp widgets/thinsplitterhandle.cpp widgets/coverwidget.cpp widgets/ratingwidget.cpp widgets/notelabel.cpp
|
||||
widgets/selectorlabel.cpp widgets/titlewidget.cpp widgets/multipagewidget.cpp widgets/singlepagewidget.cpp widgets/stackedpagewidget.cpp
|
||||
widgets/mirrormenu.cpp
|
||||
widgets/mirrormenu.cpp widgets/genrecombo.cpp
|
||||
context/lyricsettings.cpp context/ultimatelyricsprovider.cpp context/ultimatelyrics.cpp context/lyricsdialog.cpp
|
||||
context/contextwidget.cpp context/view.cpp context/artistview.cpp context/albumview.cpp context/songview.cpp context/contextengine.cpp
|
||||
context/wikipediaengine.cpp context/wikipediasettings.cpp context/othersettings.cpp context/contextsettings.cpp context/togglelist.cpp
|
||||
@@ -472,7 +472,7 @@ set(CANTATA_MOC_HDRS ${CANTATA_CORE_MOC_HDRS} ${CANTATA_MOC_HDRS}
|
||||
widgets/playqueueview.h widgets/groupedview.h widgets/actionitemdelegate.h widgets/volumeslider.h widgets/singlepagewidget.h
|
||||
widgets/searchwidget.h widgets/messageoverlay.h widgets/servicestatuslabel.h widgets/stretchheaderview.h widgets/tableview.h
|
||||
widgets/coverwidget.h widgets/ratingwidget.h widgets/selectorlabel.h widgets/titlewidget.h widgets/multipagewidget.h
|
||||
widgets/stackedpagewidget.h widgets/mirrormenu.h
|
||||
widgets/stackedpagewidget.h widgets/mirrormenu.h widgets/genrecombo.h
|
||||
context/togglelist.h context/ultimatelyrics.h context/ultimatelyricsprovider.h context/lyricsdialog.h
|
||||
context/contextwidget.h context/artistview.h context/albumview.h context/songview.h context/view.h context/contextengine.h
|
||||
context/wikipediaengine.h context/wikipediasettings.h context/othersettings.h context/lastfmengine.h context/metaengine.h
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
explicitly selected.
|
||||
7. Allow to set keyboard shortcuts for ratings actions. Default to Alt+0 (No
|
||||
rating), Alt+1 (1 star), etc.
|
||||
8. Re-add genre combo to library view. Only visible if grouping by artist or
|
||||
album.
|
||||
|
||||
2.0.1
|
||||
-----
|
||||
|
||||
@@ -665,6 +665,8 @@ QList<LibraryDb::Artist> LibraryDb::getArtists(const QString &genre)
|
||||
query.setFilter(filter);
|
||||
if (!genre.isEmpty()) {
|
||||
query.addWhere("genre", genre);
|
||||
} else if (!genreFilter.isEmpty()) {
|
||||
query.addWhere("genre", genreFilter);
|
||||
}
|
||||
query.exec();
|
||||
DBUG << query.executedQuery();
|
||||
@@ -702,6 +704,8 @@ QList<LibraryDb::Album> LibraryDb::getAlbums(const QString &artistId, const QStr
|
||||
}
|
||||
if (!genre.isEmpty()) {
|
||||
query.addWhere("genre", genre);
|
||||
} else if (!genreFilter.isEmpty()) {
|
||||
query.addWhere("genre", genreFilter);
|
||||
}
|
||||
query.exec();
|
||||
DBUG << query.executedQuery() << timer.elapsed();
|
||||
@@ -783,6 +787,8 @@ QList<Song> LibraryDb::getTracks(const QString &artistId, const QString &albumId
|
||||
}
|
||||
if (!genre.isEmpty()) {
|
||||
query.addWhere("genre", genre);
|
||||
} else if (!genreFilter.isEmpty()) {
|
||||
query.addWhere("genre", genreFilter);
|
||||
}
|
||||
query.exec();
|
||||
DBUG << query.executedQuery();
|
||||
@@ -886,6 +892,8 @@ LibraryDb::Album LibraryDb::getRandomAlbum(const QString &genre, const QString &
|
||||
}
|
||||
if (!genre.isEmpty()) {
|
||||
query.addWhere("genre", genre);
|
||||
} else if (!genreFilter.isEmpty()) {
|
||||
query.addWhere("genre", genreFilter);
|
||||
}
|
||||
query.exec();
|
||||
DBUG << query.executedQuery();
|
||||
@@ -926,6 +934,9 @@ QSet<QString> LibraryDb::get(const QString &type)
|
||||
return detailsCache[type];
|
||||
}
|
||||
QSet<QString> set;
|
||||
if (!db) {
|
||||
return set;
|
||||
}
|
||||
SqlQuery query("distinct "+type, *db);
|
||||
query.exec();
|
||||
DBUG << query.executedQuery();
|
||||
@@ -959,7 +970,7 @@ bool LibraryDb::songExists(const Song &song)
|
||||
return query.next();
|
||||
}
|
||||
|
||||
bool LibraryDb::setFilter(const QString &f)
|
||||
bool LibraryDb::setFilter(const QString &f, const QString &genre)
|
||||
{
|
||||
QString newFilter=f.trimmed().toLower();
|
||||
|
||||
@@ -979,11 +990,10 @@ bool LibraryDb::setFilter(const QString &f)
|
||||
newFilter=tokens.join(" ");
|
||||
DBUG << newFilter;
|
||||
}
|
||||
if (newFilter!=filter) {
|
||||
filter=newFilter;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
bool modified=newFilter!=filter || genre!=genreFilter;
|
||||
filter=newFilter;
|
||||
genreFilter=genre;
|
||||
return modified;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -131,7 +131,7 @@ public:
|
||||
QSet<QString> get(const QString &type);
|
||||
void getDetails(QSet<QString> &artists, QSet<QString> &albumArtists, QSet<QString> &composers, QSet<QString> &albums, QSet<QString> &genres);
|
||||
bool songExists(const Song &song);
|
||||
bool setFilter(const QString &f);
|
||||
bool setFilter(const QString &f, const QString &genre=QString());
|
||||
const QString & getFilter() const { return filter; }
|
||||
int getCurrentVersion() const { return currentVersion; }
|
||||
#endif
|
||||
@@ -164,6 +164,7 @@ protected:
|
||||
QSqlQuery *insertSongQuery;
|
||||
QElapsedTimer timer;
|
||||
QString filter;
|
||||
QString genreFilter;
|
||||
#ifndef CANTATA_WEB
|
||||
QMap<QString, QSet<QString> > detailsCache;
|
||||
#endif
|
||||
|
||||
@@ -32,13 +32,14 @@
|
||||
#include "support/localize.h"
|
||||
#include "support/messagebox.h"
|
||||
#include "support/actioncollection.h"
|
||||
//#include "support/combobox.h"
|
||||
#include "models/mpdlibrarymodel.h"
|
||||
#include "widgets/menubutton.h"
|
||||
#include "widgets/genrecombo.h"
|
||||
|
||||
LibraryPage::LibraryPage(QWidget *p)
|
||||
: SinglePageWidget(p)
|
||||
{
|
||||
genreCombo=new GenreCombo(this);
|
||||
connect(StdActions::self()->addRandomAlbumToPlayQueueAction, SIGNAL(triggered()), SLOT(addRandomAlbum()));
|
||||
connect(MPDConnection::self(), SIGNAL(updatingLibrary(time_t)), view, SLOT(updating()));
|
||||
connect(MPDConnection::self(), SIGNAL(updatedLibrary()), view, SLOT(updated()));
|
||||
@@ -47,22 +48,12 @@ LibraryPage::LibraryPage(QWidget *p)
|
||||
connect(view, SIGNAL(itemsSelected(bool)), this, SLOT(controlActions()));
|
||||
connect(view, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(itemDoubleClicked(const QModelIndex &)));
|
||||
view->setModel(MpdLibraryModel::self());
|
||||
|
||||
// groupCombo=new ComboBox(this);
|
||||
// groupCombo->addItem(i18n("Genre"), SqlLibraryModel::T_Genre);
|
||||
// groupCombo->addItem(i18n("Atists"), SqlLibraryModel::T_Artist);
|
||||
// groupCombo->addItem(i18n("Albums"), SqlLibraryModel::T_Album);
|
||||
connect(MpdLibraryModel::self(), SIGNAL(modelReset()), this, SLOT(modelReset()));
|
||||
|
||||
// Settings...
|
||||
Configuration config(metaObject()->className());
|
||||
view->setMode(ItemView::Mode_DetailedTree);
|
||||
MpdLibraryModel::self()->load(config);
|
||||
// for (int i=0; i<groupCombo->count(); ++i) {
|
||||
// if (groupCombo->itemData(i).toInt()==MpdLibraryModel::self()->topLevel()) {
|
||||
// groupCombo->setCurrentIndex(i);
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
|
||||
config.beginGroup(SqlLibraryModel::groupingStr(MpdLibraryModel::self()->topLevel()));
|
||||
view->load(config);
|
||||
@@ -91,6 +82,7 @@ LibraryPage::LibraryPage(QWidget *p)
|
||||
<< MenuItem(i18n("Artist"), SqlLibraryModel::T_Artist)
|
||||
<< MenuItem(i18n("Album"), SqlLibraryModel::T_Album),
|
||||
MpdLibraryModel::self()->topLevel(), this, SLOT(groupByChanged())));
|
||||
genreCombo->setVisible(SqlLibraryModel::T_Genre!=MpdLibraryModel::self()->topLevel());
|
||||
|
||||
menu->addAction(libraryAlbumSortAction);
|
||||
menu->addAction(albumAlbumSortAction);
|
||||
@@ -100,8 +92,9 @@ LibraryPage::LibraryPage(QWidget *p)
|
||||
albumAlbumSortAction->setVisible(SqlLibraryModel::T_Album==MpdLibraryModel::self()->topLevel());
|
||||
libraryAlbumSortAction->setVisible(SqlLibraryModel::T_Album!=MpdLibraryModel::self()->topLevel());
|
||||
showArtistImagesAction->setVisible(SqlLibraryModel::T_Album!=MpdLibraryModel::self()->topLevel());
|
||||
init(ReplacePlayQueue|AppendToPlayQueue, QList<QWidget *>() << menu/* << groupCombo*/);
|
||||
// connect(groupCombo, SIGNAL(activated(int)), SLOT(groupByChanged()));
|
||||
genreCombo->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
|
||||
init(ReplacePlayQueue|AppendToPlayQueue, QList<QWidget *>() << menu << genreCombo);
|
||||
connect(genreCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(doSearch()));
|
||||
view->addAction(StdActions::self()->addToStoredPlaylistAction);
|
||||
view->addAction(CustomActions::self());
|
||||
#ifdef TAGLIB_FOUND
|
||||
@@ -279,6 +272,11 @@ void LibraryPage::setView(int v)
|
||||
showArtistImagesAction->setVisible(SqlLibraryModel::T_Album!=MpdLibraryModel::self()->topLevel() && ItemView::Mode_IconTop!=view->viewMode());
|
||||
}
|
||||
|
||||
void LibraryPage::modelReset()
|
||||
{
|
||||
genreCombo->update(MpdLibraryModel::self()->getGenres());
|
||||
}
|
||||
|
||||
void LibraryPage::groupByChanged()
|
||||
{
|
||||
QAction *act=qobject_cast<QAction *>(sender());
|
||||
@@ -286,7 +284,6 @@ void LibraryPage::groupByChanged()
|
||||
return;
|
||||
}
|
||||
int mode=act->property(constValProp).toInt();
|
||||
// int mode=groupCombo->itemData(groupCombo->currentIndex()).toInt();
|
||||
|
||||
Configuration config(metaObject()->className());
|
||||
config.beginGroup(SqlLibraryModel::groupingStr(MpdLibraryModel::self()->topLevel()));
|
||||
@@ -296,6 +293,7 @@ void LibraryPage::groupByChanged()
|
||||
albumAlbumSortAction->setVisible(SqlLibraryModel::T_Album==MpdLibraryModel::self()->topLevel());
|
||||
libraryAlbumSortAction->setVisible(SqlLibraryModel::T_Album!=MpdLibraryModel::self()->topLevel());
|
||||
showArtistImagesAction->setVisible(SqlLibraryModel::T_Album!=MpdLibraryModel::self()->topLevel() && ItemView::Mode_IconTop!=view->viewMode());
|
||||
genreCombo->setVisible(SqlLibraryModel::T_Genre!=MpdLibraryModel::self()->topLevel());
|
||||
|
||||
config.endGroup();
|
||||
config.beginGroup(SqlLibraryModel::groupingStr(MpdLibraryModel::self()->topLevel()));
|
||||
@@ -413,7 +411,8 @@ void LibraryPage::addRandomAlbum()
|
||||
|
||||
void LibraryPage::doSearch()
|
||||
{
|
||||
MpdLibraryModel::self()->search(view->searchText());
|
||||
MpdLibraryModel::self()->search(view->searchText(),
|
||||
genreCombo->isHidden() || genreCombo->currentIndex()<=0 ? QString() : genreCombo->currentText());
|
||||
}
|
||||
|
||||
void LibraryPage::controlActions()
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
#include "widgets/singlepagewidget.h"
|
||||
|
||||
class Action;
|
||||
//class ComboBox;
|
||||
class GenreCombo;
|
||||
|
||||
class LibraryPage : public SinglePageWidget
|
||||
{
|
||||
@@ -60,6 +60,7 @@ public Q_SLOTS:
|
||||
void itemDoubleClicked(const QModelIndex &);
|
||||
|
||||
private Q_SLOTS:
|
||||
void modelReset();
|
||||
void groupByChanged();
|
||||
void libraryAlbumSortChanged();
|
||||
void albumAlbumSortChanged();
|
||||
@@ -73,7 +74,7 @@ private:
|
||||
void controlActions();
|
||||
|
||||
private:
|
||||
// ComboBox *groupCombo;
|
||||
GenreCombo *genreCombo;
|
||||
QAction *viewAction;
|
||||
QAction *showArtistImagesAction;
|
||||
QAction *libraryAlbumSortAction;
|
||||
|
||||
@@ -74,6 +74,7 @@ SearchPage::SearchPage(QWidget *p)
|
||||
view->load(config);
|
||||
MenuButton *menu=new MenuButton(this);
|
||||
menu->addActions(createViewActions(QList<ItemView::Mode>() << ItemView::Mode_List << ItemView::Mode_Table));
|
||||
statsLabel->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
|
||||
init(ReplacePlayQueue|AppendToPlayQueue, QList<QWidget *>() << menu << statsLabel);
|
||||
|
||||
view->addAction(StdActions::self()->addToStoredPlaylistAction);
|
||||
|
||||
@@ -199,9 +199,9 @@ void SqlLibraryModel::libraryUpdated()
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
void SqlLibraryModel::search(const QString &str)
|
||||
void SqlLibraryModel::search(const QString &str, const QString &genre)
|
||||
{
|
||||
if (db->setFilter(str)) {
|
||||
if (db->setFilter(str, genre)) {
|
||||
libraryUpdated();
|
||||
}
|
||||
}
|
||||
@@ -518,6 +518,11 @@ QModelIndex SqlLibraryModel::findArtistIndex(const QString &artist)
|
||||
return QModelIndex();
|
||||
}
|
||||
|
||||
QSet<QString> SqlLibraryModel::getGenres() const
|
||||
{
|
||||
return db->get("genre");
|
||||
}
|
||||
|
||||
QSet<QString> SqlLibraryModel::getArtists() const
|
||||
{
|
||||
return db->get("albumArtist");
|
||||
|
||||
@@ -143,7 +143,7 @@ public:
|
||||
virtual void load(Configuration &config);
|
||||
virtual void save(Configuration &config);
|
||||
|
||||
void search(const QString &str);
|
||||
void search(const QString &str, const QString &genre=QString());
|
||||
|
||||
Qt::ItemFlags flags(const QModelIndex &index) const;
|
||||
QModelIndex index(int row, int column, const QModelIndex &parent) const;
|
||||
@@ -161,6 +161,7 @@ public:
|
||||
QModelIndex findSongIndex(const Song &song);
|
||||
QModelIndex findAlbumIndex(const QString &artist, const QString &album);
|
||||
QModelIndex findArtistIndex(const QString &artist);
|
||||
QSet<QString> getGenres() const;
|
||||
QSet<QString> getArtists() const;
|
||||
QList<Song> getAlbumTracks(const QString &artistId, const QString &albumId) const;
|
||||
QList<Song> getAlbumTracks(const Song &song) const { return getAlbumTracks(song.artistOrComposer(), song.albumId()); }
|
||||
|
||||
@@ -35,6 +35,7 @@ SoundCloudWidget::SoundCloudWidget(SoundCloudService *s, QWidget *p)
|
||||
{
|
||||
statsLabel=new SqueezedTextLabel(this);
|
||||
view->setModel(s);
|
||||
statsLabel->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
|
||||
init(ReplacePlayQueue|AppendToPlayQueue, QList<QWidget *>() << statsLabel);
|
||||
view->alwaysShowHeader();
|
||||
view->setPermanentSearch();
|
||||
|
||||
@@ -55,9 +55,9 @@ SinglePageWidget::SinglePageWidget(QWidget *p)
|
||||
QGridLayout *layout=new QGridLayout(this);
|
||||
view=new ItemView(this);
|
||||
layout->addWidget(view, 1, 0, 1, 5);
|
||||
layout->addItem(new QSpacerItem(0, 0, QSizePolicy::MinimumExpanding, QSizePolicy::Preferred), 2, 1, 1, 1);
|
||||
// layout->addItem(new QSpacerItem(0, 0, QSizePolicy::MinimumExpanding, QSizePolicy::Preferred), 2, 1, 1, 1);
|
||||
layout->addWidget(new SizeWidget(this), 2, 2, 1, 1);
|
||||
layout->addItem(new QSpacerItem(0, 0, QSizePolicy::MinimumExpanding, QSizePolicy::Preferred), 2, 3, 1, 1);
|
||||
// layout->addItem(new QSpacerItem(0, 0, QSizePolicy::MinimumExpanding, QSizePolicy::Preferred), 2, 3, 1, 1);
|
||||
layout->setMargin(0);
|
||||
layout->setSpacing(0);
|
||||
connect(view, SIGNAL(searchItems()), this, SIGNAL(searchItems()));
|
||||
|
||||
Reference in New Issue
Block a user