File indexing completed on 2024-05-12 15:54:51

0001 /*
0002  * SPDX-FileCopyrightText: (C) 2014  Vishesh Handa <me@vhanda.in>
0003  *
0004  * SPDX-License-Identifier: LGPL-2.1-or-later
0005  */
0006 
0007 #ifndef PROCESSOR_H
0008 #define PROCESSOR_H
0009 
0010 #include <QObject>
0011 #include <QStringList>
0012 
0013 #include "committimer.h"
0014 #include "reversegeocoder.h"
0015 
0016 namespace Koko
0017 {
0018 class Processor : public QObject
0019 {
0020     Q_OBJECT
0021     Q_PROPERTY(float initialProgress READ initialProgress NOTIFY initialProgressChanged)
0022     Q_PROPERTY(int numFiles READ numFiles NOTIFY numFilesChanged)
0023     Q_PROPERTY(bool finished READ finished NOTIFY finishedChanged)
0024 public:
0025     explicit Processor(QObject *parent = nullptr);
0026     ~Processor() = default;
0027 
0028     float initialProgress() const;
0029     int numFiles() const;
0030 
0031     bool finished() const
0032     {
0033         return m_initialScanDone;
0034     }
0035 
0036 signals:
0037     void initialProgressChanged();
0038     void numFilesChanged();
0039     void finishedChanged();
0040 
0041 public slots:
0042     Q_INVOKABLE void addFile(const QString &filePath);
0043     Q_INVOKABLE void removeFile(const QString &filePath);
0044     void initialScanCompleted();
0045 
0046 private slots:
0047     void process();
0048     void slotFinished();
0049 
0050 private:
0051     QStringList m_files;
0052     int m_numFiles;
0053     bool m_processing;
0054 
0055     CommitTimer m_commitTimer;
0056     ReverseGeoCoder m_geoCoder;
0057     bool m_initialScanDone;
0058 };
0059 
0060 }
0061 #endif // PROCESSOR_H