Re-implement tag editing, etc, from folders view.
This commit is contained in:
@@ -680,7 +680,7 @@ QList<Song> LibraryDb::getTracks(const QString &artistId, const QString &albumId
|
||||
query.exec();
|
||||
DBUG << query.executedQuery();
|
||||
while (query.next()) {
|
||||
songs.append(getSong(&(query.realQuery())));
|
||||
songs.append(getSong(query.realQuery()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -705,6 +705,25 @@ QList<Song> LibraryDb::getTracks(const QString &artistId, const QString &albumId
|
||||
}
|
||||
|
||||
#ifndef CANTATA_WEB
|
||||
QList<Song> LibraryDb::songs(const QStringList &files, bool allowPlaylists) const
|
||||
{
|
||||
QList<Song> songList;
|
||||
foreach (const QString &f, files) {
|
||||
SqlQuery query("*", *db);
|
||||
query.addWhere("file", f);
|
||||
query.exec();
|
||||
DBUG << query.executedQuery();
|
||||
if (query.next()) {
|
||||
Song song=getSong(query.realQuery());
|
||||
if (allowPlaylists || Song::Playlist!=song.type) {
|
||||
songList.append(song);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return songList;
|
||||
}
|
||||
|
||||
QList<LibraryDb::Album> LibraryDb::getAlbumsWithArtist(const QString &artist)
|
||||
{
|
||||
QList<LibraryDb::Album> albums;
|
||||
@@ -827,30 +846,30 @@ bool LibraryDb::createTable(const QString &q)
|
||||
return true;
|
||||
}
|
||||
|
||||
Song LibraryDb::getSong(const QSqlQuery *query)
|
||||
Song LibraryDb::getSong(const QSqlQuery &query)
|
||||
{
|
||||
Song s;
|
||||
s.file=query->value(0).toString();
|
||||
s.artist=query->value(1).toString();
|
||||
s.albumartist=query->value(3).toString();
|
||||
s.setComposer(query->value(5).toString());
|
||||
s.album=query->value(6).toString();
|
||||
QString val=query->value(7).toString();
|
||||
s.file=query.value(0).toString();
|
||||
s.artist=query.value(1).toString();
|
||||
s.albumartist=query.value(3).toString();
|
||||
s.setComposer(query.value(5).toString());
|
||||
s.album=query.value(6).toString();
|
||||
QString val=query.value(7).toString();
|
||||
if (!val.isEmpty() && val!=s.album) {
|
||||
s.setMbAlbumId(val);
|
||||
}
|
||||
s.title=query->value(9).toString();
|
||||
s.genre=query->value(10).toString();
|
||||
s.track=query->value(11).toUInt();
|
||||
s.disc=query->value(12).toUInt();
|
||||
s.time=query->value(13).toUInt();
|
||||
s.year=query->value(14).toUInt();
|
||||
s.type=(Song::Type)query->value(15).toUInt();
|
||||
val=query->value(4).toString();
|
||||
s.title=query.value(9).toString();
|
||||
s.genre=query.value(10).toString();
|
||||
s.track=query.value(11).toUInt();
|
||||
s.disc=query.value(12).toUInt();
|
||||
s.time=query.value(13).toUInt();
|
||||
s.year=query.value(14).toUInt();
|
||||
s.type=(Song::Type)query.value(15).toUInt();
|
||||
val=query.value(4).toString();
|
||||
if (!val.isEmpty() && val!=s.albumArtist()) {
|
||||
s.setArtistSort(val);
|
||||
}
|
||||
val=query->value(8).toString();
|
||||
val=query.value(8).toString();
|
||||
if (!val.isEmpty() && val!=s.album) {
|
||||
s.setAlbumSort(val);
|
||||
}
|
||||
|
||||
@@ -115,6 +115,7 @@ public:
|
||||
QList<Album> getAlbums(const QString &artistId=QString(), const QString &genre=QString(), const QString &sort=QString());
|
||||
QList<Song> getTracks(const QString &artistId, const QString &albumId, const QString &genre=QString(), const QString &sort=QString());
|
||||
#ifndef CANTATA_WEB
|
||||
QList<Song> songs(const QStringList &files, bool allowPlaylists=false) const;
|
||||
QList<Album> getAlbumsWithArtist(const QString &artist);
|
||||
QSet<QString> get(const QString &type);
|
||||
void getDetails(QSet<QString> &artists, QSet<QString> &albumArtists, QSet<QString> &composers, QSet<QString> &albums, QSet<QString> &genres);
|
||||
@@ -132,7 +133,7 @@ protected Q_SLOTS:
|
||||
|
||||
protected:
|
||||
bool createTable(const QString &q);
|
||||
static Song getSong(const QSqlQuery *query);
|
||||
static Song getSong(const QSqlQuery &query);
|
||||
|
||||
protected:
|
||||
virtual void reset();
|
||||
|
||||
@@ -114,7 +114,7 @@ Song MpdLibraryDb::getCoverSong(const QString &artistId, const QString &albumId)
|
||||
query->exec();
|
||||
DBUG << "coverquery" << query->executedQuery() << query->size();
|
||||
while (query->next()) {
|
||||
return getSong(query);
|
||||
return getSong(*query);
|
||||
}
|
||||
}
|
||||
return Song();
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include "support/messagebox.h"
|
||||
#include "support/action.h"
|
||||
#include "support/utils.h"
|
||||
#include "models/mpdlibrarymodel.h"
|
||||
#include "stdactions.h"
|
||||
#include <QDesktopServices>
|
||||
#include <QUrl>
|
||||
@@ -190,24 +191,22 @@ void FolderPage::openFileManager()
|
||||
|
||||
QList<Song> FolderPage::selectedSongs(EmptySongMod esMod, bool allowPlaylists) const
|
||||
{
|
||||
// QList<Song> songs=MusicLibraryModel::self()->songs(selectedFiles(allowPlaylists), ES_None!=esMod);
|
||||
QList<Song> songs=MpdLibraryModel::self()->songs(selectedFiles(allowPlaylists), ES_None!=esMod);
|
||||
|
||||
// if (ES_None!=esMod) {
|
||||
// QList<Song>::Iterator it(songs.begin());
|
||||
// QList<Song>::Iterator end(songs.end());
|
||||
// for (; it!=end; ++it) {
|
||||
// if ((*it).isEmpty()) {
|
||||
// if (ES_GuessTags==esMod) {
|
||||
// (*it).guessTags();
|
||||
// }
|
||||
// (*it).fillEmptyFields();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
if (ES_None!=esMod) {
|
||||
QList<Song>::Iterator it(songs.begin());
|
||||
QList<Song>::Iterator end(songs.end());
|
||||
for (; it!=end; ++it) {
|
||||
if ((*it).isEmpty()) {
|
||||
if (ES_GuessTags==esMod) {
|
||||
(*it).guessTags();
|
||||
}
|
||||
(*it).fillEmptyFields();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// return songs;
|
||||
return QList<Song>();
|
||||
// TODO!!!!
|
||||
return songs;
|
||||
}
|
||||
|
||||
QStringList FolderPage::selectedFiles(bool allowPlaylists) const
|
||||
|
||||
@@ -375,6 +375,11 @@ QList<Song> SqlLibraryModel::getAlbumTracks(const Song &song) const
|
||||
return QList<Song>();
|
||||
}
|
||||
|
||||
QList<Song> SqlLibraryModel::songs(const QStringList &files, bool allowPlaylists) const
|
||||
{
|
||||
return db->songs(files, allowPlaylists);
|
||||
}
|
||||
|
||||
QList<LibraryDb::Album> SqlLibraryModel::getArtistAlbums(const QString &artist) const
|
||||
{
|
||||
return db->getAlbumsWithArtist(artist);
|
||||
|
||||
@@ -155,6 +155,7 @@ public:
|
||||
QModelIndex findArtistIndex(const QString &artist);
|
||||
QSet<QString> getArtists() const;
|
||||
QList<Song> getAlbumTracks(const Song &song) const;
|
||||
QList<Song> songs(const QStringList &files, bool allowPlaylists=false) const;
|
||||
QList<LibraryDb::Album> getArtistAlbums(const QString &artist) const;
|
||||
void getDetails(QSet<QString> &artists, QSet<QString> &albumArtists, QSet<QString> &composers, QSet<QString> &albums, QSet<QString> &genres);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user