Commit 1c3f0e52 authored by Camilo higuita's avatar Camilo higuita

more fixes

parent 8a885393
......@@ -136,7 +136,7 @@ bool CollectionDB::check_existance(const QString &tableName, const QString &sear
return false;
}
if (query.next())
if (query.first())
return true;
return false;
......
......@@ -87,8 +87,8 @@ int main(int argc, char *argv[])
const auto currentSources = vvave.getSourceFolders();
const QStringList sources = currentSources.isEmpty() ? BAE::defaultSources : currentSources;
vvave.scanDir(sources);
// if(!urls.isEmpty())
// bae.openUrls(urls);
if(!urls.isEmpty())
vvave.openUrls(urls);
});
auto context = engine.rootContext();
......
......@@ -442,6 +442,21 @@ Maui.ApplicationWindow
text: qsTr("Sources...")
icon.name: "folder-add"
onTriggered: sourcesDialog.open()
},
Maui.MenuItem
{
text: qsTr("Open...")
icon.name: "folder-add"
onTriggered:
{
fmDialog.onlyDirs = false
fmDialog.filterType = FMList.AUDIO
fmDialog.show(function(paths)
{
vvave.openUrls(paths)
})
}
}
// Maui.Menu
......@@ -1016,6 +1031,10 @@ Maui.ApplicationWindow
currentBabe = mainPlaylist.list.get(currentTrackIndex).fav == "1"
}
onOpenFiles: Player.playAll(tracks)
onOpenFiles:
{
Player.appendTracksAt(tracks, 0)
Player.playAt(0)
}
}
}
......@@ -16,7 +16,7 @@ function playTrack(index)
if(currentTrack.artwork && currentTrack.artwork.length && currentTrack.artwork !== "NONE")
currentArtwork = currentTrack.artwork
else bae.loadCover(currentTrack.url)
// else bae.loadCover(currentTrack.url)
progressBar.enabled = true
......@@ -24,8 +24,8 @@ function playTrack(index)
{
root.title = currentTrack.title + " - " +currentTrack.artist
if(!root.active)
bae.notifySong(currentTrack.url)
// if(!root.active)
// bae.notifySong(currentTrack.url)
}
// if(currentTrack.lyrics.length < 1)
......@@ -116,7 +116,7 @@ function shuffle()
function playAt(index)
{
if((index < mainPlaylist.listView.count) && (mainPlaylist.listView.count > 0) && (index > -1))
if((index < mainPlaylist.listView.count) && (index > -1))
{
currentTrackIndex = index
mainPlaylist.listView.currentIndex = currentTrackIndex
......
......@@ -11,6 +11,12 @@
#include <QtConcurrent>
#include <QFuture>
#ifdef STATIC_MAUIKIT
#include "fm.h"
#else
#include <MauiKit/fm.h>
#endif
/*
* Sets upthe app default config paths
* BrainDeamon to get collection information
......@@ -53,13 +59,17 @@ vvave::~vvave() {}
void vvave::runBrain()
{
QFutureWatcher<void> *watcher = new QFutureWatcher<void>;
QObject::connect(watcher, &QFutureWatcher<void>::finished, [=]()
QObject::connect(watcher, &QFutureWatcher<void>::finished, watcher, &QFutureWatcher<void>::deleteLater);
QObject::connect(qApp, &QCoreApplication::aboutToQuit, [=]()
{
watcher->deleteLater();
if(watcher)
watcher->future().waitForFinished();
});
auto func = [=]()
{
// the album artworks package
......@@ -97,7 +107,6 @@ void vvave::checkCollection(const QStringList &paths, std::function<void(uint)>
cb(newTracks);
watcher->deleteLater();
});
const auto func = [&paths]() -> uint
{
auto newPaths = paths;
......@@ -114,7 +123,6 @@ void vvave::checkCollection(const QStringList &paths, std::function<void(uint)>
}
//// PUBLIC SLOTS
QVariantList vvave::sourceFolders()
......@@ -136,18 +144,62 @@ QString vvave::moodColor(const int &index)
void vvave::scanDir(const QStringList &paths)
{
this->checkCollection(paths, [this](uint size)
this->checkCollection(paths, [=](uint size)
{
emit this->refreshTables(size);
runBrain();
// runBrain();
});
}
QStringList vvave::getSourceFolders()
{
const auto folders = this->db->getSourcesFolders();
qDebug()<< folders;
return folders;
return this->db->getSourcesFolders();
}
void vvave::openUrls(const QStringList &urls)
{
if(urls.isEmpty()) return;
QVariantList data;
TagInfo info;
for(QString url : urls)
if(db->check_existance(BAE::TABLEMAP[BAE::TABLE::TRACKS], FMH::MODEL_NAME[FMH::MODEL_KEY::URL], url))
{
const auto value = this->db->getDBData(QStringList() << url).first();
data << FM::toMap(value);
}
else
{
if(info.feed(url))
{
auto album = BAE::fixString(info.getAlbum());
auto track= info.getTrack();
auto title = BAE::fixString(info.getTitle()); /* to fix*/
auto artist = BAE::fixString(info.getArtist());
auto genre = info.getGenre();
auto sourceUrl = QFileInfo(url).dir().path();
auto duration = info.getDuration();
auto year = info.getYear();
data << QVariantMap({
{FMH::MODEL_NAME[FMH::MODEL_KEY::URL], url},
{FMH::MODEL_NAME[FMH::MODEL_KEY::TRACK], QString::number(track)},
{FMH::MODEL_NAME[FMH::MODEL_KEY::TITLE], title},
{FMH::MODEL_NAME[FMH::MODEL_KEY::ARTIST], artist},
{FMH::MODEL_NAME[FMH::MODEL_KEY::ALBUM], album},
{FMH::MODEL_NAME[FMH::MODEL_KEY::DURATION],QString::number(duration)},
{FMH::MODEL_NAME[FMH::MODEL_KEY::GENRE], genre},
{FMH::MODEL_NAME[FMH::MODEL_KEY::SOURCE], sourceUrl},
{FMH::MODEL_NAME[FMH::MODEL_KEY::FAV],"0"},
{FMH::MODEL_NAME[FMH::MODEL_KEY::RELEASEDATE], QString::number(year)}
});
}
}
qDebug()<<"opening urls " << urls << data;
emit this->openFiles(data);
}
......
......@@ -25,6 +25,7 @@ signals:
void refreshTracks();
void refreshAlbums();
void refreshArtists();
void openFiles(QVariantList tracks);
public slots:
///DB Interfaces
......@@ -34,9 +35,7 @@ public slots:
void scanDir(const QStringList &paths = BAE::defaultSources);
QStringList getSourceFolders();
void openUrls(const QStringList &urls);
};
#endif // VVAVE_H
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