Commit 9dcfbce1 authored by Camilo Higuita's avatar Camilo Higuita

more fixes on brainz to get ready for release

parent 0db14be5
......@@ -18,5 +18,5 @@ DISTFILES += \
RESOURCES += android.qrc
ANDROID_PACKAGE_SOURCE_DIR = $$PWD/src
ANDROID_PACKAGE_SOURCE_DIR = $$PWD/
}
......@@ -20,7 +20,7 @@ var GET = {
playlistTracks_ : "select t.* , al.artwork from tracks t inner join albums al on t.album = al.album and t.artist = al.artist inner join tracks_playlists pl on pl.url = t.url where pl.playlist = \"%1\" order by strftime(\"%s\", pl.addDate) desc",
playlists: "select * from playlists order by strftime(\"%s\", addDate) desc",
genres: "select genre as tag from tracks",
genres: "select distinct genre as tag from tracks",
tags : "select distinct tag from tags where context = 'tag' limit 1000",
trackTags : "select distinct tag from tracks_tags where context = 'tag' and tag collate nocase not in (select artist from artists) and tag in (select tag from tracks_tags group by tag having count(url) > 1) order by tag collate nocase limit 1000",
......
......@@ -397,6 +397,7 @@ bool CollectionDB::albumTrack(const DB &track, const QString &value)
return true;
}
bool CollectionDB::playedTrack(const QString &url, const int &increment)
{
auto queryTxt = QString("UPDATE %1 SET %2 = %2 + %3 WHERE %4 = \"%5\"").arg(TABLEMAP[TABLE::TRACKS],
......@@ -458,7 +459,7 @@ bool CollectionDB::wikiAlbum(const DB &track, QString value)
auto album = track[KEY::ALBUM];
auto queryStr = QString("UPDATE %1 SET %2 = \"%3\" WHERE %4 = \"%5\" AND %6 = \"%7\"").arg(
TABLEMAP[TABLE::ALBUMS],
TABLEMAP[TABLE::ALBUMS],
KEYMAP[KEY::WIKI], value.replace("\"","\"\""),
KEYMAP[KEY::ALBUM],
album,KEYMAP[KEY::ARTIST], artist);
......@@ -655,7 +656,7 @@ QVariantList CollectionDB::getSearchedTracks(const KEY &where, const QString &se
"SELECT t.* FROM %1 t INNER JOIN %9 art ON t.%8 = art.%8 WHERE art.%4 LIKE \"%%5%\" COLLATE NOCASE "
"UNION "
"SELECT DISTINCT t.* FROM %1 t INNER JOIN %9 at ON t.%8 = at.%4 WHERE at.%8 LIKE \"%%5%\" COLLATE NOCASE").arg(
TABLEMAP[TABLE::TRACKS],
TABLEMAP[TABLE::TRACKS],
TABLEMAP[TABLE::TRACKS_TAGS],
KEYMAP[KEY::URL],
KEYMAP[where],
......@@ -830,7 +831,7 @@ bool CollectionDB::removeTrack(const QString &path)
QSqlQuery CollectionDB::getQuery(const QString &queryTxt)
{
return QSqlQuery(queryTxt, this->m_db);
return QSqlQuery(queryTxt, this->m_db);
}
bool CollectionDB::removeSource(const QString &url)
......@@ -842,7 +843,7 @@ bool CollectionDB::removeSource(const QString &url)
qDebug() << queryTxt;
auto query = this->getQuery(queryTxt);
if(query.exec())
{
{
queryTxt = QString("DELETE FROM %1 WHERE %2 LIKE \"%3%\"").arg(TABLEMAP[TABLE::SOURCES],
KEYMAP[KEY::URL],path);
query.prepare(queryTxt);
......@@ -875,35 +876,35 @@ void CollectionDB::insertArtwork(const DB &track)
switch(albumType(track))
{
case TABLE::ALBUMS :
{
auto queryStr = QString("UPDATE %1 SET %2 = \"%3\" WHERE %4 = \"%5\" AND %6 = \"%7\"").arg(TABLEMAP[TABLE::ALBUMS],
KEYMAP[KEY::ARTWORK],
path.isEmpty() ? SLANG[W::NONE] : path,
KEYMAP[KEY::ALBUM],
album,
KEYMAP[KEY::ARTIST],
artist);
auto query = this->getQuery(queryStr);
if(!query.exec())qDebug()<<"COULDNT Artwork[cover] inerted into DB"<<artist<<album;
break;
case TABLE::ALBUMS :
{
auto queryStr = QString("UPDATE %1 SET %2 = \"%3\" WHERE %4 = \"%5\" AND %6 = \"%7\"").arg(TABLEMAP[TABLE::ALBUMS],
KEYMAP[KEY::ARTWORK],
path.isEmpty() ? SLANG[W::NONE] : path,
KEYMAP[KEY::ALBUM],
album,
KEYMAP[KEY::ARTIST],
artist);
auto query = this->getQuery(queryStr);
if(!query.exec())qDebug()<<"COULDNT Artwork[cover] inerted into DB"<<artist<<album;
break;
}
case TABLE::ARTISTS:
{
auto queryStr = QString("UPDATE %1 SET %2 = \"%3\" WHERE %4 = \"%5\"").arg(TABLEMAP[TABLE::ARTISTS],
KEYMAP[KEY::ARTWORK],
path.isEmpty() ? SLANG[W::NONE] : path,
KEYMAP[KEY::ARTIST],
artist);
auto query = this->getQuery(queryStr);
if(!query.exec())qDebug()<<"COULDNT Artwork[head] inerted into DB"<<artist;
}
case TABLE::ARTISTS:
{
auto queryStr = QString("UPDATE %1 SET %2 = \"%3\" WHERE %4 = \"%5\"").arg(TABLEMAP[TABLE::ARTISTS],
KEYMAP[KEY::ARTWORK],
path.isEmpty() ? SLANG[W::NONE] : path,
KEYMAP[KEY::ARTIST],
artist);
auto query = this->getQuery(queryStr);
if(!query.exec())qDebug()<<"COULDNT Artwork[head] inerted into DB"<<artist;
break;
break;
}
default: return;
}
default: return;
}
emit artworkInserted(track);
......@@ -957,7 +958,7 @@ bool CollectionDB::cleanArtists()
{
// delete from artists where artist in (select artist from artists except select distinct artist from tracks);
auto queryTxt=QString("DELETE FROM %1 WHERE %2 IN (SELECT %2 FROM %1 EXCEPT SELECT DISTINCT %2 FROM %3)").arg(
TABLEMAP[TABLE::ARTISTS],
TABLEMAP[TABLE::ARTISTS],
KEYMAP[KEY::ARTIST],
TABLEMAP[TABLE::TRACKS]
);
......@@ -971,7 +972,7 @@ bool CollectionDB::cleanArtists()
bool CollectionDB::removeFolder(const QString &url)
{
auto queryTxt=QString("DELETE FROM %1 WHERE %2 LIKE \"%3%\"").arg(
TABLEMAP[TABLE::FOLDERS],
TABLEMAP[TABLE::FOLDERS],
KEYMAP[KEY::URL], url);
qDebug()<<queryTxt;
......@@ -992,7 +993,7 @@ bool CollectionDB::cleanAlbums()
{
// delete from albums where (album, artist) in (select a.album, a.artist from albums a except select distinct album, artist from tracks);
auto queryTxt=QString("DELETE FROM %1 WHERE (%2, %3) IN (SELECT %2, %3 FROM %1 EXCEPT SELECT DISTINCT %2, %3 FROM %4)").arg(
TABLEMAP[TABLE::ALBUMS],
TABLEMAP[TABLE::ALBUMS],
KEYMAP[KEY::ALBUM],
KEYMAP[KEY::ARTIST],
TABLEMAP[TABLE::TRACKS]
......
......@@ -16,116 +16,115 @@
#include "../utils/bae.h"
enum sourceTypes
{
{
LOCAL, ONLINE, DEVICE
};
};
class CollectionDB : public QObject
{
Q_OBJECT
public:
explicit CollectionDB( QObject *parent = nullptr);
~CollectionDB() override;
bool insert(const QString &tableName, const QVariantMap &insertData);
bool update(const QString &tableName, const BAE::DB &updateData, const QVariantMap &where);
bool update(const QString &table, const QString &column, const QVariant &newValue, const QVariant &op, const QString &id);
bool remove();
bool execQuery(QSqlQuery &query) const;
bool execQuery(const QString &queryTxt);
/*basic public actions*/
void prepareCollectionDB() const;
bool check_existance(const QString &tableName, const QString &searchId, const QString &search);
/* usefull actions */
void insertArtwork(const BAE::DB &track);
void addTrack(const BAE::DB &track);
bool updateTrack(const BAE::DB &track);
Q_INVOKABLE bool rateTrack(const QString &path, const int &value);
Q_INVOKABLE bool colorTagTrack(const QString &path, const QString &value);
Q_INVOKABLE QString trackColorTag(const QString &path);
bool lyricsTrack(const BAE::DB &track, const QString &value);
Q_INVOKABLE bool playedTrack(const QString &url, const int &increment = 1);
bool wikiTrack(const BAE::DB &track, const QString &value);
bool tagsTrack(const BAE::DB &track, const QString &value, const QString &context);
bool albumTrack(const BAE::DB &track, const QString &value);
bool trackTrack(const BAE::DB &track, const QString &value);
bool wikiArtist(const BAE::DB &track, const QString &value);
bool tagsArtist(const BAE::DB &track, const QString &value, const QString &context = "");
bool wikiAlbum(const BAE::DB &track, QString value);
bool tagsAlbum(const BAE::DB &track, const QString &value, const QString &context = "");
Q_INVOKABLE bool addPlaylist(const QString &title);
bool addFolder(const QString &url);
bool removeFolder(const QString &url);
BAE::DB_LIST getDBData(const QStringList &urls);
BAE::DB_LIST getDBData(const QString &queryTxt);
QVariantList getDBDataQML(const QString &queryTxt);
QStringList dataToList(const BAE::DB_LIST &list, const BAE::KEY &key);
BAE::DB_LIST getAlbumTracks(const QString &album, const QString &artist, const BAE::KEY &orderBy = BAE::KEY::TRACK, const BAE::W &order = BAE::W::ASC);
BAE::DB_LIST getArtistTracks(const QString &artist, const BAE::KEY &orderBy = BAE::KEY::ALBUM, const BAE::W &order = BAE::W::ASC);
BAE::DB_LIST getBabedTracks(const BAE::KEY &orderBy = BAE::KEY::PLAYED, const BAE::W &order = BAE::W::DESC);
QVariantList getSearchedTracks(const BAE::KEY &where, const QString &search);
BAE::DB_LIST getPlaylistTracks(const QString &playlist, const BAE::KEY &orderBy = BAE::KEY::ADD_DATE, const BAE::W &order = BAE::W::DESC);
BAE::DB_LIST getMostPlayedTracks(const int &greaterThan = 1,const int &limit = 50, const BAE::KEY &orderBy = BAE::KEY::PLAYED, const BAE::W &order = BAE::W::DESC);
BAE::DB_LIST getFavTracks(const int &stars = 1,const int &limit = 50, const BAE::KEY &orderBy = BAE::KEY::STARS, const BAE::W &order = BAE::W::DESC);
BAE::DB_LIST getRecentTracks(const int &limit = 50, const BAE::KEY &orderBy = BAE::KEY::ADD_DATE, const BAE::W &order = BAE::W::DESC);
BAE::DB_LIST getOnlineTracks(const BAE::KEY &orderBy = BAE::KEY::ADD_DATE, const BAE::W &order = BAE::W::DESC);
Q_INVOKABLE QStringList getSourcesFolders();
QStringList getTrackTags(const QString &path);
Q_INVOKABLE int getTrackStars(const QString &path);
// QStringList getArtistTags(const QString &artist);
// QStringList getAlbumTags(const QString &album, const QString &artist);
QStringList getArtistAlbums(const QString &artist);
Q_INVOKABLE QStringList getPlaylists();
Q_INVOKABLE bool removePlaylistTrack(const QString &url, const QString &playlist);
Q_INVOKABLE bool removePlaylist(const QString &playlist);
Q_INVOKABLE void removeMissingTracks();
bool removeArtist(const QString &artist);
bool cleanArtists();
bool removeAlbum(const QString &album, const QString &artist);
bool cleanAlbums();
Q_INVOKABLE bool removeSource(const QString &url);
Q_INVOKABLE bool removeTrack(const QString &path);
QSqlQuery getQuery(const QString &queryTxt);
/*useful tools*/
sourceTypes sourceType(const QString &url);
void openDB(const QString &name);
private:
QString name;
QSqlDatabase m_db;
/*basic actions*/
public slots:
void closeConnection();
void test();
signals:
void trackInserted();
void artworkInserted(const BAE::DB &albumMap);
void DBactionFinished();
void albumsCleaned(const int &amount);
void artistsCleaned(const int &amount);
Q_OBJECT
public:
explicit CollectionDB( QObject *parent = nullptr);
~CollectionDB() override;
bool insert(const QString &tableName, const QVariantMap &insertData);
bool update(const QString &tableName, const BAE::DB &updateData, const QVariantMap &where);
bool update(const QString &table, const QString &column, const QVariant &newValue, const QVariant &op, const QString &id);
bool remove();
bool execQuery(QSqlQuery &query) const;
bool execQuery(const QString &queryTxt);
/*basic public actions*/
void prepareCollectionDB() const;
bool check_existance(const QString &tableName, const QString &searchId, const QString &search);
/* usefull actions */
void insertArtwork(const BAE::DB &track);
void addTrack(const BAE::DB &track);
bool updateTrack(const BAE::DB &track);
Q_INVOKABLE bool rateTrack(const QString &path, const int &value);
Q_INVOKABLE bool colorTagTrack(const QString &path, const QString &value);
Q_INVOKABLE QString trackColorTag(const QString &path);
bool lyricsTrack(const BAE::DB &track, const QString &value);
Q_INVOKABLE bool playedTrack(const QString &url, const int &increment = 1);
bool wikiTrack(const BAE::DB &track, const QString &value);
bool tagsTrack(const BAE::DB &track, const QString &value, const QString &context);
bool albumTrack(const BAE::DB &track, const QString &value);
bool trackTrack(const BAE::DB &track, const QString &value);
bool wikiArtist(const BAE::DB &track, const QString &value);
bool tagsArtist(const BAE::DB &track, const QString &value, const QString &context = "");
bool wikiAlbum(const BAE::DB &track, QString value);
bool tagsAlbum(const BAE::DB &track, const QString &value, const QString &context = "");
Q_INVOKABLE bool addPlaylist(const QString &title);
bool addFolder(const QString &url);
bool removeFolder(const QString &url);
BAE::DB_LIST getDBData(const QStringList &urls);
BAE::DB_LIST getDBData(const QString &queryTxt);
QVariantList getDBDataQML(const QString &queryTxt);
QStringList dataToList(const BAE::DB_LIST &list, const BAE::KEY &key);
BAE::DB_LIST getAlbumTracks(const QString &album, const QString &artist, const BAE::KEY &orderBy = BAE::KEY::TRACK, const BAE::W &order = BAE::W::ASC);
BAE::DB_LIST getArtistTracks(const QString &artist, const BAE::KEY &orderBy = BAE::KEY::ALBUM, const BAE::W &order = BAE::W::ASC);
BAE::DB_LIST getBabedTracks(const BAE::KEY &orderBy = BAE::KEY::PLAYED, const BAE::W &order = BAE::W::DESC);
QVariantList getSearchedTracks(const BAE::KEY &where, const QString &search);
BAE::DB_LIST getPlaylistTracks(const QString &playlist, const BAE::KEY &orderBy = BAE::KEY::ADD_DATE, const BAE::W &order = BAE::W::DESC);
BAE::DB_LIST getMostPlayedTracks(const int &greaterThan = 1,const int &limit = 50, const BAE::KEY &orderBy = BAE::KEY::PLAYED, const BAE::W &order = BAE::W::DESC);
BAE::DB_LIST getFavTracks(const int &stars = 1,const int &limit = 50, const BAE::KEY &orderBy = BAE::KEY::STARS, const BAE::W &order = BAE::W::DESC);
BAE::DB_LIST getRecentTracks(const int &limit = 50, const BAE::KEY &orderBy = BAE::KEY::ADD_DATE, const BAE::W &order = BAE::W::DESC);
BAE::DB_LIST getOnlineTracks(const BAE::KEY &orderBy = BAE::KEY::ADD_DATE, const BAE::W &order = BAE::W::DESC);
Q_INVOKABLE QStringList getSourcesFolders();
QStringList getTrackTags(const QString &path);
Q_INVOKABLE int getTrackStars(const QString &path);
// QStringList getArtistTags(const QString &artist);
// QStringList getAlbumTags(const QString &album, const QString &artist);
QStringList getArtistAlbums(const QString &artist);
Q_INVOKABLE QStringList getPlaylists();
Q_INVOKABLE bool removePlaylistTrack(const QString &url, const QString &playlist);
Q_INVOKABLE bool removePlaylist(const QString &playlist);
Q_INVOKABLE void removeMissingTracks();
bool removeArtist(const QString &artist);
bool cleanArtists();
bool removeAlbum(const QString &album, const QString &artist);
bool cleanAlbums();
Q_INVOKABLE bool removeSource(const QString &url);
Q_INVOKABLE bool removeTrack(const QString &path);
QSqlQuery getQuery(const QString &queryTxt);
/*useful tools*/
sourceTypes sourceType(const QString &url);
void openDB(const QString &name);
private:
QString name;
QSqlDatabase m_db;
/*basic actions*/
public slots:
void closeConnection();
void test();
signals:
void trackInserted();
void artworkInserted(const BAE::DB &albumMap);
void DBactionFinished();
void albumsCleaned(const int &amount);
void artistsCleaned(const int &amount);
};
......
......@@ -125,8 +125,8 @@ Kirigami.ApplicationWindow
property int toolBarHeight : isMobile ? 48 : toolBarIconSize *2
property int miniArtSize : isMobile ? 40 : 34
property int columnWidth: Kirigami.Units.gridUnit * 18
property int coverSize: isMobile ? Math.sqrt(root.width*root.height)*0.4 : columnWidth * 0.65
property int columnWidth: Kirigami.Units.gridUnit * 15
property int coverSize: isMobile ? Math.sqrt(root.width*root.height)*0.4 : columnWidth * 0.8
property int currentView : viewsIndex.tracks
/*USEFUL PROPS*/
......
......@@ -109,7 +109,6 @@ void YouTube::processFinished_totally(const int &state,const DB &info,const QPro
TagInfo tag;
if(exitStatus == QProcess::NormalExit)
{
if(BAE::fileExists(file))
{
tag.feed(file);
......@@ -143,7 +142,9 @@ void YouTube::processFinished_totally(const int &state,const DB &info,const QPro
TagInfo tag;
tag.feed(track[KEY::URL]);
if(!res[PULPO::ONTOLOGY::TRACK][PULPO::INFO::METADATA][PULPO::CONTEXT::ALBUM_TITLE].toString().isEmpty())
auto albumRes = res[PULPO::ONTOLOGY::TRACK][PULPO::INFO::METADATA][PULPO::CONTEXT::ALBUM_TITLE].toString();
if(!albumRes.isEmpty() && albumRes != BAE::SLANG[W::UNKNOWN])
tag.setAlbum(res[PULPO::ONTOLOGY::TRACK][PULPO::INFO::METADATA][PULPO::CONTEXT::ALBUM_TITLE].toString());
else tag.setAlbum(track[KEY::TITLE]);
......@@ -194,7 +195,7 @@ void YouTube::processFinished_totally(const int &state,const DB &info,const QPro
CollectionDB con(nullptr);
con.addTrack(trackMap);
// con.trackPlaylist(file, track[KEY::PLAYLIST]);
// con.trackPlaylist({file}, track[KEY::PLAYLIST]);
if(this->ids.isEmpty()) emit this->done();
......
......@@ -137,23 +137,19 @@ function appendTracksAt(tracks, at)
{
if(tracks)
for(var i in tracks)
{
if(tracks[i].url !== mainPlaylist.list.model.get(at).url)
mainPlaylist.list.model.insert(parseInt(at)+parseInt(i), tracks[i])
}
mainPlaylist.list.model.insert(parseInt(at)+parseInt(i), tracks[i])
}
function appendTrack(track)
{
if(track)
{
root.mainPlaylist.list.model.append(track)
root.animFooter.running = true
mainPlaylist.list.model.append(track)
animFooter.running = true
if(root.sync === true)
{
root.infoMsgAnim()
addToPlaylist([track.url], root.syncPlaylist)
infoMsgAnim()
addToPlaylist([track.url], syncPlaylist)
}
}
......@@ -175,7 +171,7 @@ function addTrack(track)
if(track)
{
appendTrack(track)
root.mainPlaylist.list.positionViewAtEnd()
mainPlaylist.list.positionViewAtEnd()
}
}
......@@ -186,7 +182,7 @@ function appendAll(tracks)
for(var i in tracks)
appendTrack(tracks[i])
root.mainPlaylist.list.positionViewAtEnd()
mainPlaylist.list.positionViewAtEnd()
}
}
......@@ -214,13 +210,13 @@ function cleanPlaylist()
{
var urls = []
for(var i = 0; i < root.mainPlaylist.list.count; i++)
for(var i = 0; i < mainPlaylist.list.count; i++)
{
var url = root.mainPlaylist.list.model.get(i).url
var url = mainPlaylist.list.model.get(i).url
if(urls.indexOf(url)<0)
urls.push(url)
else root.mainPlaylist.list.model.remove(i)
else mainPlaylist.list.model.remove(i)
}
}
......@@ -233,7 +229,7 @@ function playAll(tracks)
infoMsg = ""
mainPlaylist.table.clearTable()
root.pageStack.currentIndex = 0
pageStack.currentIndex = 0
for(var i in tracks)
appendTrack(tracks[i])
......@@ -256,12 +252,7 @@ function addToPlaylist(urls, playlist)
if(urls.length > 0)
{
bae.trackPlaylist(urls, playlist)
// for(var i in urls)
// bae.trackPlaylist(urls[i], playlist)
bae.notify(playlist, urls.length + " tracks added to the playlist:\n"+urls.join("\n"))
}
}
This diff is collapsed.
......@@ -40,6 +40,24 @@ public slots:
void artistInfo();
void albumInfo();
void artworks();
void tags();
void wikis();
void albumArtworks();
void albumTags();
void albumWikis();
void artistArtworks();
void artistTags();
void artistWikis();
void trackArtworks();
void trackLyrics();
void trackTags();
void trackWikis();
private:
QThread t;
Pulpo pulpo;
......
......@@ -56,7 +56,7 @@ BabeGrid
edge: Qt.RightEdge
interactive: false
focus: true
modal: isMobile
modal: false
dragMargin: 0
margins: 0
spacing: 0
......
......@@ -56,7 +56,7 @@ BabeGrid
edge: Qt.RightEdge
interactive: false
focus: true
modal: isMobile
modal: false
dragMargin: 0
margins: 0
spacing: 0
......
......@@ -30,7 +30,7 @@ Kirigami.PageRow
clip: true
separatorVisible: wideMode
initialPage:[playlistList, playlistViewDrawer]
initialPage: [playlistList, playlistViewDrawer]
defaultColumnWidth: Kirigami.Units.gridUnit * 15
interactive: false
......@@ -223,6 +223,10 @@ Kirigami.PageRow
function populate(query)
{
if(!playlistViewRoot.wideMode)
playlistViewRoot.currentIndex = 1
playlistQuery = query
filterList.clearTable()
......
......@@ -128,10 +128,7 @@ BabeList
playlistViewRoot.populate(Q.GET.playlistTracks_.arg(playlist));
break;
}
if(!playlistViewRoot.wideMode)
playlistViewRoot.currentIndex = 1
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment