Commit 4b175438 authored by Camilo Higuita's avatar Camilo Higuita

fixes from android since we dont have qt 5.114 and depend on 5.13 still

parent d6184822
...@@ -33,86 +33,89 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. ...@@ -33,86 +33,89 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
class FileLoader : public QObject class FileLoader : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
FileLoader(QObject *parent = nullptr) : QObject(parent) FileLoader(QObject *parent = nullptr) : QObject(parent)
{ {
this->moveToThread(&t); this->moveToThread(&t);
connect(this, &FileLoader::start, this, &FileLoader::getPics); connect(this, &FileLoader::start, this, &FileLoader::getPics);
this->t.start(); this->t.start();
} }
~FileLoader() ~FileLoader()
{ {
t.quit(); t.quit();
t.wait(); t.wait();
} }
void requestPath(const QList<QUrl> &urls, const bool &recursive) void requestPath(const QList<QUrl> &urls, const bool &recursive)
{ {
qDebug()<<"FROM file loader"<< urls; qDebug()<<"FROM file loader"<< urls;
emit this->start(urls, recursive); emit this->start(urls, recursive);
} }
private slots: private slots:
void getPics(QList<QUrl> paths, bool recursive) void getPics(QList<QUrl> paths, bool recursive)
{ {
qDebug()<<"GETTING IMAGES"; qDebug()<<"GETTING IMAGES";
const uint m_bsize = 5000; const uint m_bsize = 5000;
uint i = 0; uint i = 0;
uint batch = 0; uint batch = 0;
FMH::MODEL_LIST res; FMH::MODEL_LIST res;
QList<QUrl> urls; FMH::MODEL_LIST res_batch;
QList<QUrl> urls;
for(const auto &path : paths)
{ for(const auto &path : paths)
if (QFileInfo(path.toLocalFile()).isDir() && path.isLocalFile() && FMH::fileExists(path)) {
{ if (QFileInfo(path.toLocalFile()).isDir() && path.isLocalFile() && FMH::fileExists(path))
QDirIterator it(path.toLocalFile(), FMH::FILTER_LIST[FMH::FILTER_TYPE::IMAGE], QDir::Files, recursive ? QDirIterator::Subdirectories : QDirIterator::NoIteratorFlags); {
QDirIterator it(path.toLocalFile(), FMH::FILTER_LIST[FMH::FILTER_TYPE::IMAGE], QDir::Files, recursive ? QDirIterator::Subdirectories : QDirIterator::NoIteratorFlags);
while (it.hasNext())
{ while (it.hasNext())
const auto url = QUrl::fromLocalFile(it.next()); {
urls << url; const auto url = QUrl::fromLocalFile(it.next());
const QFileInfo info(url.toLocalFile()); urls << url;
FMH::MODEL map = const QFileInfo info(url.toLocalFile());
{ FMH::MODEL map =
{FMH::MODEL_KEY::URL, url.toString()}, {
{FMH::MODEL_KEY::TITLE, info.baseName()}, {FMH::MODEL_KEY::URL, url.toString()},
{FMH::MODEL_KEY::SIZE, QString::number(info.size())}, {FMH::MODEL_KEY::TITLE, info.baseName()},
{FMH::MODEL_KEY::SOURCE, FMH::fileDir(url)}, {FMH::MODEL_KEY::SIZE, QString::number(info.size())},
{FMH::MODEL_KEY::DATE, info.birthTime().toString(Qt::TextDate)}, {FMH::MODEL_KEY::SOURCE, FMH::fileDir(url)},
{FMH::MODEL_KEY::MODIFIED, info.lastModified().toString(Qt::TextDate)}, {FMH::MODEL_KEY::DATE, info.birthTime().toString(Qt::TextDate)},
{FMH::MODEL_KEY::FORMAT, info.suffix()} {FMH::MODEL_KEY::MODIFIED, info.lastModified().toString(Qt::TextDate)},
}; {FMH::MODEL_KEY::FORMAT, info.suffix()}
};
emit itemReady(map);
res << map; emit itemReady(map);
i++; res << map;
res_batch << map;
if(i == m_bsize) //send a batch i++;
{
emit itemsReady(FMH::MODEL_LIST(res.constBegin()+(batch*m_bsize), res.constEnd())); if(i == m_bsize) //send a batch
batch++; {
i = 0; emit itemsReady(res_batch);
} res_batch.clear ();
} batch++;
} i = 0;
} }
emit itemsReady(FMH::MODEL_LIST(res.constBegin()+(batch*m_bsize), res.constEnd())); }
emit finished(res); }
} }
emit itemsReady(res_batch);
emit finished(res);
}
signals: signals:
void finished(FMH::MODEL_LIST items); void finished(FMH::MODEL_LIST items);
void start(QList<QUrl> urls, bool recursive); void start(QList<QUrl> urls, bool recursive);
void itemsReady(FMH::MODEL_LIST items); void itemsReady(FMH::MODEL_LIST items);
void itemReady(FMH::MODEL item); void itemReady(FMH::MODEL item);
private: private:
QThread t; QThread t;
}; };
......
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