src/documentloader.h

changeset 1288
d1e45f90654b
parent 1287
f1da43b7f5c6
child 1289
ec5a38d19cf5
equal deleted inserted replaced
1287:f1da43b7f5c6 1288:d1e45f90654b
1 /*
2 * LDForge: LDraw parts authoring CAD
3 * Copyright (C) 2013 - 2017 Teemu Piippo
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19 #pragma once
20 #include "main.h"
21 #include "model.h"
22
23 struct LDHeader;
24
25 //
26 // DocumentLoader
27 //
28 // Loads the given file and parses it to LDObjects. It's a separate class so as to be able to do the work progressively
29 // through the event loop, allowing the program to maintain responsivity during loading.
30 //
31 class DocumentLoader : public QObject
32 {
33 Q_OBJECT
34
35 public:
36 DocumentLoader(
37 Model* model,
38 LDHeader& header,
39 bool onForeground = false,
40 QObject* parent = nullptr,
41 );
42
43 Q_SLOT void abort();
44 bool hasAborted();
45 bool isDone() const;
46 bool isOnForeground() const;
47 const QVector<LDObject*>& objects() const;
48 int progress() const;
49 void read (QIODevice* fp);
50 Q_SLOT void start();
51 int warningCount() const;
52
53 private:
54 class OpenProgressDialog* m_progressDialog;
55 Model* _model;
56 LDHeader& _header;
57 QStringList m_lines;
58 int m_progress;
59 int m_warningCount = 0;
60 bool m_isDone = false;
61 bool m_hasAborted = false;
62 const bool m_isOnForeground = false;
63
64 private slots:
65 void work (int i);
66
67 signals:
68 void progressUpdate (int progress);
69 void workDone();
70 void parseErrorMessage(QString message);
71 };

mercurial