2014-04-29 12:17:25 +00:00
|
|
|
#ifndef CSV_DOC_LOADER_H
|
|
|
|
#define CSV_DOC_LOADER_H
|
|
|
|
|
|
|
|
#include <map>
|
2022-10-19 17:02:00 +00:00
|
|
|
#include <string>
|
2014-04-29 12:17:25 +00:00
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
#include <QWidget>
|
|
|
|
|
2022-10-19 17:02:00 +00:00
|
|
|
class QCloseEvent;
|
2014-05-03 11:01:29 +00:00
|
|
|
class QLabel;
|
|
|
|
class QProgressBar;
|
2014-05-06 07:39:39 +00:00
|
|
|
class QDialogButtonBox;
|
2014-05-10 11:18:40 +00:00
|
|
|
class QListWidget;
|
2014-05-10 11:29:28 +00:00
|
|
|
class QVBoxLayout;
|
2014-05-03 11:01:29 +00:00
|
|
|
|
2014-04-29 12:17:25 +00:00
|
|
|
namespace CSMDoc
|
|
|
|
{
|
|
|
|
class Document;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace CSVDoc
|
|
|
|
{
|
|
|
|
class LoadingDocument : public QWidget
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
2014-05-03 14:44:50 +00:00
|
|
|
CSMDoc::Document* mDocument;
|
2021-07-23 07:34:27 +00:00
|
|
|
QLabel* mTotalRecordsLabel;
|
|
|
|
QLabel* mRecordsLabel;
|
|
|
|
QProgressBar* mTotalProgress;
|
2014-05-03 13:33:35 +00:00
|
|
|
QProgressBar* mRecordProgress;
|
2014-05-06 07:39:39 +00:00
|
|
|
bool mAborted;
|
|
|
|
QDialogButtonBox* mButtons;
|
|
|
|
QLabel* mError;
|
2014-05-10 11:18:40 +00:00
|
|
|
QListWidget* mMessages;
|
2014-05-10 11:29:28 +00:00
|
|
|
QVBoxLayout* mLayout;
|
2021-07-23 07:34:27 +00:00
|
|
|
int mRecords;
|
2014-06-26 09:41:21 +00:00
|
|
|
int mTotalRecords;
|
2021-07-23 07:34:27 +00:00
|
|
|
int mFilesLoaded;
|
2014-05-03 11:01:29 +00:00
|
|
|
|
2014-05-03 15:14:17 +00:00
|
|
|
private:
|
2020-10-16 18:18:54 +00:00
|
|
|
void closeEvent(QCloseEvent* event) override;
|
2014-05-03 15:14:17 +00:00
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
public:
|
2020-10-16 18:18:54 +00:00
|
|
|
LoadingDocument(CSMDoc::Document* document);
|
2014-05-03 15:14:17 +00:00
|
|
|
|
2014-06-26 09:41:21 +00:00
|
|
|
void nextStage(const std::string& name, int totalRecords);
|
2014-04-29 12:17:25 +00:00
|
|
|
|
|
|
|
void nextRecord(int records);
|
2014-05-03 11:01:29 +00:00
|
|
|
|
2014-06-26 09:41:21 +00:00
|
|
|
void abort(const std::string& error);
|
2014-05-03 13:33:35 +00:00
|
|
|
|
2014-06-26 09:41:21 +00:00
|
|
|
void addMessage(const std::string& message);
|
2014-05-03 14:44:50 +00:00
|
|
|
|
2014-05-06 07:39:39 +00:00
|
|
|
private slots:
|
|
|
|
|
2014-05-10 11:18:40 +00:00
|
|
|
void cancel();
|
|
|
|
|
2014-05-03 14:44:50 +00:00
|
|
|
signals:
|
|
|
|
|
|
|
|
void cancel(CSMDoc::Document* document);
|
2014-05-06 07:39:39 +00:00
|
|
|
///< Stop loading process.
|
2014-05-03 14:44:50 +00:00
|
|
|
|
2014-05-06 07:39:39 +00:00
|
|
|
void close(CSMDoc::Document* document);
|
|
|
|
///< Close stopped loading process.
|
2014-04-29 12:17:25 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class Loader : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
std::map<CSMDoc::Document*, LoadingDocument*> mDocuments;
|
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
public:
|
2014-04-29 12:17:25 +00:00
|
|
|
Loader();
|
|
|
|
|
2021-05-19 00:53:55 +00:00
|
|
|
~Loader() override;
|
2014-04-29 12:17:25 +00:00
|
|
|
|
2014-05-03 14:44:50 +00:00
|
|
|
signals:
|
|
|
|
|
|
|
|
void cancel(CSMDoc::Document* document);
|
|
|
|
|
2014-05-06 07:39:39 +00:00
|
|
|
void close(CSMDoc::Document* document);
|
|
|
|
|
2014-04-29 12:17:25 +00:00
|
|
|
public slots:
|
|
|
|
|
2014-04-29 12:27:44 +00:00
|
|
|
void add(CSMDoc::Document* document);
|
2014-04-29 12:17:25 +00:00
|
|
|
|
|
|
|
void loadingStopped(CSMDoc::Document* document, bool completed, const std::string& error);
|
2014-05-03 11:01:29 +00:00
|
|
|
|
2014-06-26 09:41:21 +00:00
|
|
|
void nextStage(CSMDoc::Document* document, const std::string& name, int totalRecords);
|
2014-05-03 13:33:35 +00:00
|
|
|
|
2014-06-26 09:41:21 +00:00
|
|
|
void nextRecord(CSMDoc::Document* document, int records);
|
2014-05-10 11:18:40 +00:00
|
|
|
|
|
|
|
void loadMessage(CSMDoc::Document* document, const std::string& message);
|
2014-04-29 12:17:25 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|