Fix the height of items in the album cover manager, don't show artists with no albums, and add a status bar (currently unused)

This commit is contained in:
David Sansome 2010-06-11 22:35:41 +00:00
parent 6e73fc19a8
commit 7e1b54a779
7 changed files with 172 additions and 167 deletions

View File

@ -334,6 +334,22 @@ QStringList LibraryBackend::GetAllArtists(const QueryOptions& opt) {
return ret; return ret;
} }
QStringList LibraryBackend::GetAllArtistsWithAlbums(const QueryOptions& opt) {
LibraryQuery query(opt);
query.SetColumnSpec("DISTINCT artist");
query.AddCompilationRequirement(false);
query.AddWhere("album", "", "!=");
QMutexLocker l(db_->Mutex());
if (!ExecQuery(&query)) return QStringList();
QStringList ret;
while (query.Next()) {
ret << query.Value(0).toString();
}
return ret;
}
LibraryBackend::AlbumList LibraryBackend::GetAllAlbums(const QueryOptions &opt) { LibraryBackend::AlbumList LibraryBackend::GetAllAlbums(const QueryOptions &opt) {
return GetAlbums(QString(), false, opt); return GetAlbums(QString(), false, opt);
} }

View File

@ -67,6 +67,7 @@ class LibraryBackend : public QObject {
SubdirectoryList SubdirsInDirectory(int id); SubdirectoryList SubdirsInDirectory(int id);
QStringList GetAllArtists(const QueryOptions& opt = QueryOptions()); QStringList GetAllArtists(const QueryOptions& opt = QueryOptions());
QStringList GetAllArtistsWithAlbums(const QueryOptions& opt = QueryOptions());
SongList GetSongs(const QString& artist, const QString& album, const QueryOptions& opt = QueryOptions()); SongList GetSongs(const QString& artist, const QString& album, const QueryOptions& opt = QueryOptions());
bool HasCompilations(const QueryOptions& opt = QueryOptions()); bool HasCompilations(const QueryOptions& opt = QueryOptions());

View File

@ -48,14 +48,14 @@ LibraryQuery::LibraryQuery(const QueryOptions& options) {
} }
} }
void LibraryQuery::AddWhere(const QString& column, const QVariant& value) { void LibraryQuery::AddWhere(const QString& column, const QVariant& value, const QString& op) {
// Do integers inline - sqlite seems to get confused when you pass integers // Do integers inline - sqlite seems to get confused when you pass integers
// to bound parameters // to bound parameters
if (value.type() == QVariant::Int) if (value.type() == QVariant::Int)
where_clauses_ << QString("%1 = %2").arg(column, value.toString()); where_clauses_ << QString("%1 %2 %3").arg(column, op, value.toString());
else { else {
where_clauses_ << QString("%1 = ?").arg(column); where_clauses_ << QString("%1 %2 ?").arg(column, op);
bound_values_ << value; bound_values_ << value;
} }
} }

View File

@ -41,7 +41,7 @@ class LibraryQuery {
void SetColumnSpec(const QString& spec) { column_spec_ = spec; } void SetColumnSpec(const QString& spec) { column_spec_ = spec; }
void SetOrderBy(const QString& order_by) { order_by_ = order_by; } void SetOrderBy(const QString& order_by) { order_by_ = order_by; }
void AddWhere(const QString& column, const QVariant& value); void AddWhere(const QString& column, const QVariant& value, const QString& op = "=");
void AddWhereLike(const QString& column, const QVariant& value); void AddWhereLike(const QString& column, const QVariant& value);
void AddCompilationRequirement(bool compilation); void AddCompilationRequirement(bool compilation);

View File

@ -39,7 +39,7 @@ const char* AlbumCoverManager::kSettingsGroup = "CoverManager";
AlbumCoverManager::AlbumCoverManager(NetworkAccessManager* network, AlbumCoverManager::AlbumCoverManager(NetworkAccessManager* network,
LibraryBackend* backend, QWidget *parent) LibraryBackend* backend, QWidget *parent)
: QDialog(parent), : QMainWindow(parent),
constructed_(false), constructed_(false),
ui_(new Ui_CoverManager), ui_(new Ui_CoverManager),
backend_(backend), backend_(backend),
@ -173,7 +173,7 @@ void AlbumCoverManager::Reset() {
new QListWidgetItem(all_artists_icon_, tr("All artists"), ui_->artists, All_Artists); new QListWidgetItem(all_artists_icon_, tr("All artists"), ui_->artists, All_Artists);
new QListWidgetItem(artist_icon_, tr("Various artists"), ui_->artists, Various_Artists); new QListWidgetItem(artist_icon_, tr("Various artists"), ui_->artists, Various_Artists);
foreach (const QString& artist, backend_->GetAllArtists()) { foreach (const QString& artist, backend_->GetAllArtistsWithAlbums()) {
if (artist.isEmpty()) if (artist.isEmpty())
continue; continue;
@ -336,7 +336,7 @@ void AlbumCoverManager::AlbumCoverFetched(quint64 id, const QImage &image) {
bool AlbumCoverManager::event(QEvent* e) { bool AlbumCoverManager::event(QEvent* e) {
if (constructed_) { if (constructed_) {
// I think KDE styles override these, and ScrollPerItem really confusing // I think KDE styles override these, and ScrollPerItem is really confusing
// when you have huge items. // when you have huge items.
// We seem to have to reset them to sensible values each time the contents // We seem to have to reset them to sensible values each time the contents
// of ui_->albums changes. // of ui_->albums changes.
@ -344,7 +344,7 @@ bool AlbumCoverManager::event(QEvent* e) {
ui_->albums->verticalScrollBar()->setSingleStep(20); ui_->albums->verticalScrollBar()->setSingleStep(20);
} }
QDialog::event(e); QMainWindow::event(e);
return false; return false;
} }
@ -369,7 +369,7 @@ bool AlbumCoverManager::eventFilter(QObject *obj, QEvent *event) {
context_menu_->popup(e->globalPos()); context_menu_->popup(e->globalPos());
return true; return true;
} }
return false; return QMainWindow::eventFilter(obj, event);
} }
void AlbumCoverManager::ShowFullsize() { void AlbumCoverManager::ShowFullsize() {

View File

@ -17,7 +17,7 @@
#ifndef ALBUMCOVERMANAGER_H #ifndef ALBUMCOVERMANAGER_H
#define ALBUMCOVERMANAGER_H #define ALBUMCOVERMANAGER_H
#include <QDialog> #include <QMainWindow>
#include <QIcon> #include <QIcon>
#include "gtest/gtest_prod.h" #include "gtest/gtest_prod.h"
@ -33,7 +33,7 @@ class Ui_CoverManager;
class QListWidgetItem; class QListWidgetItem;
class QMenu; class QMenu;
class AlbumCoverManager : public QDialog { class AlbumCoverManager : public QMainWindow {
Q_OBJECT Q_OBJECT
public: public:
AlbumCoverManager(NetworkAccessManager* network, LibraryBackend* backend, AlbumCoverManager(NetworkAccessManager* network, LibraryBackend* backend,

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0"> <ui version="4.0">
<class>CoverManager</class> <class>CoverManager</class>
<widget class="QDialog" name="CoverManager"> <widget class="QMainWindow" name="CoverManager">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
@ -17,6 +17,7 @@
<iconset resource="../../data/data.qrc"> <iconset resource="../../data/data.qrc">
<normaloff>:/icon.png</normaloff>:/icon.png</iconset> <normaloff>:/icon.png</normaloff>:/icon.png</iconset>
</property> </property>
<widget class="QWidget" name="centralWidget">
<layout class="QVBoxLayout" name="verticalLayout_2"> <layout class="QVBoxLayout" name="verticalLayout_2">
<property name="margin"> <property name="margin">
<number>0</number> <number>0</number>
@ -30,9 +31,27 @@
<property name="alternatingRowColors"> <property name="alternatingRowColors">
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="uniformItemSizes">
<bool>true</bool>
</property>
</widget> </widget>
<widget class="QWidget" name="layoutWidget"> <widget class="QWidget" name="widget" native="true">
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing"> <property name="spacing">
@ -140,6 +159,8 @@
</widget> </widget>
</item> </item>
</layout> </layout>
</widget>
<widget class="QStatusBar" name="statusBar"/>
<action name="action_show_fullsize"> <action name="action_show_fullsize">
<property name="text"> <property name="text">
<string>Show fullsize...</string> <string>Show fullsize...</string>
@ -179,38 +200,5 @@
<resources> <resources>
<include location="../../data/data.qrc"/> <include location="../../data/data.qrc"/>
</resources> </resources>
<connections> <connections/>
<connection>
<sender>clear</sender>
<signal>clicked()</signal>
<receiver>filter</receiver>
<slot>clear()</slot>
<hints>
<hint type="sourcelabel">
<x>329</x>
<y>13</y>
</hint>
<hint type="destinationlabel">
<x>367</x>
<y>14</y>
</hint>
</hints>
</connection>
<connection>
<sender>clear</sender>
<signal>clicked()</signal>
<receiver>filter</receiver>
<slot>setFocus()</slot>
<hints>
<hint type="sourcelabel">
<x>334</x>
<y>20</y>
</hint>
<hint type="destinationlabel">
<x>401</x>
<y>13</y>
</hint>
</hints>
</connection>
</connections>
</ui> </ui>