1
0
mirror of https://github.com/clementine-player/Clementine synced 2024-12-15 10:48:33 +01:00

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;
}
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) {
return GetAlbums(QString(), false, opt);
}

View File

@ -67,6 +67,7 @@ class LibraryBackend : public QObject {
SubdirectoryList SubdirsInDirectory(int id);
QStringList GetAllArtists(const QueryOptions& opt = QueryOptions());
QStringList GetAllArtistsWithAlbums(const QueryOptions& opt = QueryOptions());
SongList GetSongs(const QString& artist, const QString& album, 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
// to bound parameters
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 {
where_clauses_ << QString("%1 = ?").arg(column);
where_clauses_ << QString("%1 %2 ?").arg(column, op);
bound_values_ << value;
}
}

View File

@ -41,7 +41,7 @@ class LibraryQuery {
void SetColumnSpec(const QString& spec) { column_spec_ = spec; }
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 AddCompilationRequirement(bool compilation);

View File

@ -39,7 +39,7 @@ const char* AlbumCoverManager::kSettingsGroup = "CoverManager";
AlbumCoverManager::AlbumCoverManager(NetworkAccessManager* network,
LibraryBackend* backend, QWidget *parent)
: QDialog(parent),
: QMainWindow(parent),
constructed_(false),
ui_(new Ui_CoverManager),
backend_(backend),
@ -173,7 +173,7 @@ void AlbumCoverManager::Reset() {
new QListWidgetItem(all_artists_icon_, tr("All artists"), ui_->artists, All_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())
continue;
@ -336,7 +336,7 @@ void AlbumCoverManager::AlbumCoverFetched(quint64 id, const QImage &image) {
bool AlbumCoverManager::event(QEvent* e) {
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.
// We seem to have to reset them to sensible values each time the contents
// of ui_->albums changes.
@ -344,7 +344,7 @@ bool AlbumCoverManager::event(QEvent* e) {
ui_->albums->verticalScrollBar()->setSingleStep(20);
}
QDialog::event(e);
QMainWindow::event(e);
return false;
}
@ -369,7 +369,7 @@ bool AlbumCoverManager::eventFilter(QObject *obj, QEvent *event) {
context_menu_->popup(e->globalPos());
return true;
}
return false;
return QMainWindow::eventFilter(obj, event);
}
void AlbumCoverManager::ShowFullsize() {

View File

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

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CoverManager</class>
<widget class="QDialog" name="CoverManager">
<widget class="QMainWindow" name="CoverManager">
<property name="geometry">
<rect>
<x>0</x>
@ -17,129 +17,150 @@
<iconset resource="../../data/data.qrc">
<normaloff>:/icon.png</normaloff>:/icon.png</iconset>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QSplitter" name="splitter">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<widget class="QListWidget" name="artists">
<property name="alternatingRowColors">
<bool>true</bool>
<widget class="QWidget" name="centralWidget">
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QSplitter" name="splitter">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<widget class="QListWidget" name="artists">
<property name="alternatingRowColors">
<bool>true</bool>
</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 class="QWidget" name="widget" native="true">
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>0</number>
</property>
<item>
<widget class="QToolButton" name="clear">
<property name="iconSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="LineEdit" name="filter">
<property name="hint" stdset="0">
<string>Enter search terms here</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="view">
<property name="text">
<string>View</string>
</property>
<property name="iconSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
<property name="popupMode">
<enum>QToolButton::MenuButtonPopup</enum>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonTextBesideIcon</enum>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="fetch">
<property name="text">
<string>Fetch Missing Covers</string>
</property>
<property name="iconSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QListWidget" name="albums">
<property name="alternatingRowColors">
<bool>false</bool>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::ExtendedSelection</enum>
</property>
<property name="iconSize">
<size>
<width>120</width>
<height>120</height>
</size>
</property>
<property name="movement">
<enum>QListView::Static</enum>
</property>
<property name="flow">
<enum>QListView::LeftToRight</enum>
</property>
<property name="isWrapping" stdset="0">
<bool>true</bool>
</property>
<property name="resizeMode">
<enum>QListView::Adjust</enum>
</property>
<property name="spacing">
<number>2</number>
</property>
<property name="viewMode">
<enum>QListView::IconMode</enum>
</property>
<property name="uniformItemSizes">
<bool>true</bool>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
<widget class="QWidget" name="layoutWidget">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>0</number>
</property>
<item>
<widget class="QToolButton" name="clear">
<property name="iconSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="LineEdit" name="filter">
<property name="hint" stdset="0">
<string>Enter search terms here</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="view">
<property name="text">
<string>View</string>
</property>
<property name="iconSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
<property name="popupMode">
<enum>QToolButton::MenuButtonPopup</enum>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonTextBesideIcon</enum>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="fetch">
<property name="text">
<string>Fetch Missing Covers</string>
</property>
<property name="iconSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QListWidget" name="albums">
<property name="alternatingRowColors">
<bool>false</bool>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::ExtendedSelection</enum>
</property>
<property name="iconSize">
<size>
<width>120</width>
<height>120</height>
</size>
</property>
<property name="movement">
<enum>QListView::Static</enum>
</property>
<property name="flow">
<enum>QListView::LeftToRight</enum>
</property>
<property name="isWrapping" stdset="0">
<bool>true</bool>
</property>
<property name="resizeMode">
<enum>QListView::Adjust</enum>
</property>
<property name="spacing">
<number>2</number>
</property>
<property name="viewMode">
<enum>QListView::IconMode</enum>
</property>
<property name="uniformItemSizes">
<bool>true</bool>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QStatusBar" name="statusBar"/>
<action name="action_show_fullsize">
<property name="text">
<string>Show fullsize...</string>
@ -179,38 +200,5 @@
<resources>
<include location="../../data/data.qrc"/>
</resources>
<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>
<connections/>
</ui>