Commit a11112a1 authored by camilo higuita's avatar camilo higuita

more windows fixes on the fielloader and taginfo

parent e0cda226
......@@ -87,10 +87,10 @@ int main(int argc, char *argv[])
QObject::connect(&engine, &QQmlApplicationEngine::objectCreated, [&]()
{
qDebug()<<"FINISHED LOADING QML APP";
// const auto currentSources = vvave.getSourceFolders();
// vvave.scanDir(currentSources.isEmpty() ? BAE::defaultSources : currentSources);
// if(!urls.isEmpty())
// vvave.openUrls(urls);
const auto currentSources = vvave.getSourceFolders();
vvave.scanDir(currentSources.isEmpty() ? BAE::defaultSources : currentSources);
if(!urls.isEmpty())
vvave.openUrls(urls);
});
auto context = engine.rootContext();
......
......@@ -394,7 +394,7 @@ Maui.ApplicationWindow
{
id: _drawer
focus: true
width: visible ? Math.min(Kirigami.Units.gridUnit * (Kirigami.Settings.isMobile? 18 : 15), root.width) : 0
width: visible ? Math.min(Kirigami.Units.gridUnit * (Kirigami.Settings.isMobile? 18 : 20), root.width) : 0
modal: !isWide
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutsideParent
height: _drawer.modal ? implicitHeight - _mainPage.footer.height : implicitHeight
......@@ -591,11 +591,11 @@ Maui.ApplicationWindow
{
id: tracksView
// Connections
// {
// target: vvave
// onRefreshTables: tracksView.list.refresh()
// }
Connections
{
target: vvave
onRefreshTables: tracksView.list.refresh()
}
Connections
{
......
......@@ -2,6 +2,7 @@
#include "db/collectionDB.h"
#include "utils/brain.h"
#include <QtConcurrent>
#include "downloader.h"
AlbumsModel::AlbumsModel(QObject *parent) : MauiList(parent),
db(CollectionDB::getInstance())
......@@ -122,8 +123,8 @@ void AlbumsModel::setList()
this->sortList();
emit this->postListChanged();
//if(this->query == AlbumsModel::QUERY::ALBUMS)
//this->fetchInformation();
if(this->query == AlbumsModel::QUERY::ALBUMS)
this->fetchInformation();
}
void AlbumsModel::fetchInformation()
......
......@@ -44,14 +44,13 @@ static inline uint getTracks(const QList<QUrl>& paths)
if(urls.isEmpty())
return newTracks;
TagInfo info;
for(const auto &url : urls)
{
if(db->check_existance(BAE::TABLEMAP[BAE::TABLE::TRACKS], FMH::MODEL_NAME[FMH::MODEL_KEY::URL], url.toString()))
continue;
if(!info.feed(url.toLocalFile()))
TagInfo info(url.toLocalFile());
if(info.isNull())
continue;
const auto track = info.getTrack();
......@@ -63,7 +62,6 @@ static inline uint getTracks(const QList<QUrl>& paths)
const auto duration = info.getDuration();
const auto year = info.getYear();
qDebug()<< "GETTING TRACKS 3" << url << title << album << artist;
FMH::MODEL trackMap =
{
......
......@@ -20,20 +20,29 @@
using namespace BAE;
TagInfo::TagInfo(QObject *parent) : QObject(parent)
{}
TagInfo::TagInfo(const QString &url, QObject *parent) : QObject(parent)
{
this->path = url;
QFileInfo _file(this->path);
if(_file.isReadable())
{
qDebug()<< ">>>FILE is READABLE" << _file.baseName() << url;
this->file = new TagLib::FileRef(this->path.toStdWString().c_str());
}
else
this->file = new TagLib::FileRef(nullptr);
}
TagInfo::~TagInfo()
{
qDebug()<< "DELETING TAGINFO";
delete this->file;
// delete this->file;
}
bool TagInfo::feed(const QString &url)
bool TagInfo::isNull()
{
this->path = url;
this->file = new TagLib::FileRef(this->path.toStdWString().c_str());
return !file->isNull();
return this->file->isNull() && this->file->tag() == nullptr ;
}
QString TagInfo::getAlbum() const
......@@ -60,7 +69,7 @@ QString TagInfo::getArtist() const
: SLANG[W::UNKNOWN];
}
int TagInfo::getTrack() const { /*return static_cast<signed int>(file.tag()->track());*/ return 0; }
int TagInfo::getTrack() const { return static_cast<signed int>(file->tag()->track()); }
QString TagInfo::getGenre() const
{
......@@ -91,7 +100,7 @@ QString TagInfo::getComment() const
const auto value = QString::fromStdWString(file->tag()->comment().toWString());
return !value.isEmpty()
?value
: SLANG[W::UNKNOWN];
: SLANG[W::UNKNOWN];
}
QByteArray TagInfo::getCover() const
......
......@@ -18,9 +18,9 @@ class TagInfo : public QObject
Q_OBJECT
public:
TagInfo(QObject *parent = nullptr);
TagInfo(const QString &url, QObject *parent = nullptr);
~TagInfo();
bool feed(const QString &url);
bool isNull();
QString getAlbum() const;
QString getTitle() const;
QString getArtist() const;
......@@ -43,6 +43,7 @@ public:
private:
TagLib::FileRef *file;
QString path;
wchar_t * m_path;
};
#endif // TAGINFO_H
......@@ -44,25 +44,6 @@ vvave::vvave(QObject *parent) : QObject(parent),
vvave::~vvave() {}
void vvave::checkCollection(const QStringList &paths, std::function<void(uint)> cb)
{
QFutureWatcher<uint> *watcher = new QFutureWatcher<uint>;
connect(watcher, &QFutureWatcher<uint>::finished, [cb, watcher]()
{
const uint newTracks = watcher->future().result();
qDebug()<< "FINISHED SCANING CXOLLECTION";
if(cb)
cb(newTracks);
});
const auto func = [=]() -> uint
{
return FLoader::getTracks(QUrl::fromStringList(paths));
};
QFuture<uint> t1 = QtConcurrent::run(func);
watcher->setFuture(t1);
}
void vvave::emitSignal()
{
......@@ -102,8 +83,21 @@ QStringList vvave::moodColors()
void vvave::scanDir(const QStringList &paths)
{
this->checkCollection(paths, [=](uint size) {emit this->refreshTables(size);});
}
QFutureWatcher<uint> *watcher = new QFutureWatcher<uint>;
connect(watcher, &QFutureWatcher<uint>::finished, [&, watcher]()
{
qDebug()<< "FINISHED SCANING CXOLLECTION";
emit this->refreshTables( watcher->future().result());
watcher->deleteLater();
});
const auto func = [=]() -> uint
{
return FLoader::getTracks(QUrl::fromStringList(paths));
};
QFuture<uint> t1 = QtConcurrent::run(func);
watcher->setFuture(t1);}
QStringList vvave::getSourceFolders()
{
......@@ -124,8 +118,8 @@ void vvave::openUrls(const QStringList &urls)
data << FMH::toMap(this->db->getDBData(QStringList() << _url.toString()).first());
}else
{
TagInfo info;
if(info.feed(_url.toLocalFile()))
TagInfo info(_url.toLocalFile());
if(!info.isNull())
{
const auto album = BAE::fixString(info.getAlbum());
const auto track= info.getTrack();
......
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