Commit 49e34e92 authored by Camilo higuita's avatar Camilo higuita

fix issue with opening external images

parent b3a7a4af
...@@ -67,6 +67,8 @@ QStringList openFiles(const QStringList &files) ...@@ -67,6 +67,8 @@ QStringList openFiles(const QStringList &files)
urls.insert(0, QString(files.first())); urls.insert(0, QString(files.first()));
} }
qDebug()<<"TRYING TO OPEN FILES<<" << urls;
return urls; return urls;
} }
......
...@@ -132,7 +132,7 @@ bool DBActions::insertPic(const PIX::DB &img) ...@@ -132,7 +132,7 @@ bool DBActions::insertPic(const PIX::DB &img)
bool DBActions::addPic(const QString &url) bool DBActions::addPic(const QString &url)
{ {
if(!this->checkExistance(PIX::TABLEMAP[PIX::TABLE::IMAGES], PIX::KEYMAP[PIX::KEY::URL],url)) if(!this->checkExistance(PIX::TABLEMAP[PIX::TABLE::IMAGES], PIX::KEYMAP[PIX::KEY::URL], url))
{ {
QFileInfo info(url); QFileInfo info(url);
auto title = info.baseName(); auto title = info.baseName();
...@@ -147,12 +147,14 @@ bool DBActions::addPic(const QString &url) ...@@ -147,12 +147,14 @@ bool DBActions::addPic(const QString &url)
{PIX::KEY::RATE, "0"}, {PIX::KEY::RATE, "0"},
{PIX::KEY::COLOR, ""}, {PIX::KEY::COLOR, ""},
{PIX::KEY::SOURCES_URL, sourceUrl}, {PIX::KEY::SOURCES_URL, sourceUrl},
{PIX::KEY::PIC_DATE, info.created().toString()}, {PIX::KEY::PIC_DATE, info.birthTime().toString()},
{PIX::KEY::FORMAT, format} {PIX::KEY::FORMAT, format}
}; };
return this->insertPic(picMap); return this->insertPic(picMap);
} }
return false;
} }
bool DBActions::removePic(const QString &url) bool DBActions::removePic(const QString &url)
...@@ -201,8 +203,6 @@ bool DBActions::addTag(const QString &tag) ...@@ -201,8 +203,6 @@ bool DBActions::addTag(const QString &tag)
return false; return false;
} }
bool DBActions::albumTag(const QString &tag, const QString &album) bool DBActions::albumTag(const QString &tag, const QString &album)
{ {
this->addTag(tag); this->addTag(tag);
...@@ -276,7 +276,6 @@ QVariantList DBActions::getFolders() ...@@ -276,7 +276,6 @@ QVariantList DBActions::getFolders()
// {"mime", "inode/directory"}, // {"mime", "inode/directory"},
// {"icon", "folder"}, // {"icon", "folder"},
// {"path", i[PIX::KEY::URL]} // {"path", i[PIX::KEY::URL]}
// }; // };
} }
return res; return res;
......
...@@ -53,7 +53,6 @@ public: ...@@ -53,7 +53,6 @@ public:
this->go = true; this->go = true;
QMetaObject::invokeMethod(this, "getPics", Q_ARG(QStringList, paths)); QMetaObject::invokeMethod(this, "getPics", Q_ARG(QStringList, paths));
} }
void nextTrack() void nextTrack()
...@@ -65,7 +64,7 @@ public slots: ...@@ -65,7 +64,7 @@ public slots:
void getPics(QStringList paths) void getPics(QStringList paths)
{ {
qDebug()<<"GETTING TRACKS FROM SETTINGS"; qDebug()<<"GETTING IMAGES";
QStringList urls; QStringList urls;
...@@ -73,12 +72,16 @@ public slots: ...@@ -73,12 +72,16 @@ public slots:
if (QFileInfo(path).isDir()) if (QFileInfo(path).isDir())
{ {
QDirIterator it(path, PIX::formats, QDir::Files, QDirIterator::Subdirectories); QDirIterator it(path, PIX::formats, QDir::Files, QDirIterator::Subdirectories);
while (it.hasNext()) urls<<it.next();
} else if (QFileInfo(path).isFile()) urls<<path; while (it.hasNext())
urls << it.next();
}else if (QFileInfo(path).isFile())
urls << path;
int newPics = 0; int newPics = 0;
if(urls.size()>0)
if(urls.size() > 0)
{ {
for(auto url : urls) for(auto url : urls)
{ {
...@@ -92,6 +95,7 @@ public slots: ...@@ -92,6 +95,7 @@ public slots:
} }
this->t.msleep(100); this->t.msleep(100);
emit this->finished(newPics); emit this->finished(newPics);
this->go = false; this->go = false;
} }
......
...@@ -229,7 +229,7 @@ Maui.ApplicationWindow ...@@ -229,7 +229,7 @@ Maui.ApplicationWindow
target: pix target: pix
onRefreshViews: PIX.refreshViews() onRefreshViews: PIX.refreshViews()
onViewPics: VIEWER.open(pics, 0) onViewPics: VIEWER.openExternalPics(pics, 0)
} }
Connections Connections
......
...@@ -52,9 +52,12 @@ Pix::Pix(QObject *parent) : DBActions(parent) ...@@ -52,9 +52,12 @@ Pix::Pix(QObject *parent) : DBActions(parent)
connect(this->fileLoader, &FileLoader::finished,[this](int size) connect(this->fileLoader, &FileLoader::finished,[this](int size)
{ {
emit refreshViews({{PIX::TABLEMAP[TABLE::ALBUMS], true}, Q_UNUSED(size);
{PIX::TABLEMAP[TABLE::TAGS], true}, emit refreshViews({
{PIX::TABLEMAP[TABLE::IMAGES], true}}); {PIX::TABLEMAP[TABLE::ALBUMS], true},
{PIX::TABLEMAP[TABLE::TAGS], true},
{PIX::TABLEMAP[TABLE::IMAGES], true}
});
}); });
} }
...@@ -88,7 +91,7 @@ void Pix::openPics(const QStringList &pics) ...@@ -88,7 +91,7 @@ void Pix::openPics(const QStringList &pics)
{PIX::KEYMAP[PIX::KEY::RATE], "0"}, {PIX::KEYMAP[PIX::KEY::RATE], "0"},
{PIX::KEYMAP[PIX::KEY::COLOR], ""}, {PIX::KEYMAP[PIX::KEY::COLOR], ""},
{PIX::KEYMAP[PIX::KEY::SOURCES_URL], sourceUrl}, {PIX::KEYMAP[PIX::KEY::SOURCES_URL], sourceUrl},
{PIX::KEYMAP[PIX::KEY::PIC_DATE], info.created().toString()}, {PIX::KEYMAP[PIX::KEY::PIC_DATE], info.birthTime().toString()},
{PIX::KEYMAP[PIX::KEY::FORMAT], format} {PIX::KEYMAP[PIX::KEY::FORMAT], format}
}; };
...@@ -115,15 +118,12 @@ void Pix::populateDB(const QStringList &paths) ...@@ -115,15 +118,12 @@ void Pix::populateDB(const QStringList &paths)
QStringList newPaths; QStringList newPaths;
for(auto path : paths) for(auto path : paths)
{
if(path.startsWith("file://")) if(path.startsWith("file://"))
newPaths << path.replace("file://", ""); newPaths << path.replace("file://", "");
else else
newPaths<<path; newPaths << path;
qDebug()<<"paths to scan"<<newPaths; qDebug()<<"paths to scan"<<newPaths;
}
fileLoader->requestPath(newPaths); fileLoader->requestPath(newPaths);
} }
......
...@@ -4,8 +4,8 @@ ...@@ -4,8 +4,8 @@
function open(model, index) function open(model, index)
{ {
pixViewer.roll.rollList.model = model
pixViewer.viewer.list.model = model pixViewer.viewer.list.model = model
pixViewer.roll.rollList.model = pixViewer.viewer.list.model
view(index) view(index)
...@@ -14,6 +14,15 @@ function open(model, index) ...@@ -14,6 +14,15 @@ function open(model, index)
} }
function openExternalPics(pics, index)
{
pixViewer.viewer.populate(pics)
pixViewer.roll.rollList.model = pixViewer.viewer.list.model
view(index)
if(currentView !== views.viewer)
currentView = views.viewer
}
function view(index) function view(index)
{ {
pixViewer.currentPicIndex = index pixViewer.currentPicIndex = index
......
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