src/documentloader.h

Sat, 19 Nov 2016 22:57:18 +0200

author
Teemu Piippo <teemu@hecknology.net>
date
Sat, 19 Nov 2016 22:57:18 +0200
changeset 1060
940b3e565ac3
parent 1014
f0a8ecb6a357
child 1072
9ce9496427f2
permissions
-rw-r--r--

Display error string if unable to write a crash log.

980
4a95c6b06ebe Split LDFileLoader (now LDDocumentLoader) into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
1 /*
4a95c6b06ebe Split LDFileLoader (now LDDocumentLoader) into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
2 * LDForge: LDraw parts authoring CAD
1014
f0a8ecb6a357 Happy new year 2016!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 980
diff changeset
3 * Copyright (C) 2013 - 2016 Teemu Piippo
980
4a95c6b06ebe Split LDFileLoader (now LDDocumentLoader) into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
4 *
4a95c6b06ebe Split LDFileLoader (now LDDocumentLoader) into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
5 * This program is free software: you can redistribute it and/or modify
4a95c6b06ebe Split LDFileLoader (now LDDocumentLoader) into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
6 * it under the terms of the GNU General Public License as published by
4a95c6b06ebe Split LDFileLoader (now LDDocumentLoader) into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
7 * the Free Software Foundation, either version 3 of the License, or
4a95c6b06ebe Split LDFileLoader (now LDDocumentLoader) into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
8 * (at your option) any later version.
4a95c6b06ebe Split LDFileLoader (now LDDocumentLoader) into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
9 *
4a95c6b06ebe Split LDFileLoader (now LDDocumentLoader) into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
10 * This program is distributed in the hope that it will be useful,
4a95c6b06ebe Split LDFileLoader (now LDDocumentLoader) into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
4a95c6b06ebe Split LDFileLoader (now LDDocumentLoader) into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4a95c6b06ebe Split LDFileLoader (now LDDocumentLoader) into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
13 * GNU General Public License for more details.
4a95c6b06ebe Split LDFileLoader (now LDDocumentLoader) into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
14 *
4a95c6b06ebe Split LDFileLoader (now LDDocumentLoader) into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License
4a95c6b06ebe Split LDFileLoader (now LDDocumentLoader) into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
4a95c6b06ebe Split LDFileLoader (now LDDocumentLoader) into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
17 */
4a95c6b06ebe Split LDFileLoader (now LDDocumentLoader) into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
18
4a95c6b06ebe Split LDFileLoader (now LDDocumentLoader) into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
19 #pragma once
4a95c6b06ebe Split LDFileLoader (now LDDocumentLoader) into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
20 #include "main.h"
4a95c6b06ebe Split LDFileLoader (now LDDocumentLoader) into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
21
4a95c6b06ebe Split LDFileLoader (now LDDocumentLoader) into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
22 //
4a95c6b06ebe Split LDFileLoader (now LDDocumentLoader) into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
23 // DocumentLoader
4a95c6b06ebe Split LDFileLoader (now LDDocumentLoader) into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
24 //
4a95c6b06ebe Split LDFileLoader (now LDDocumentLoader) into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
25 // Loads the given file and parses it to LDObjects. It's a separate class so as to be able to do the work progressively
4a95c6b06ebe Split LDFileLoader (now LDDocumentLoader) into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
26 // through the event loop, allowing the program to maintain responsivity during loading.
4a95c6b06ebe Split LDFileLoader (now LDDocumentLoader) into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
27 //
4a95c6b06ebe Split LDFileLoader (now LDDocumentLoader) into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
28 class DocumentLoader : public QObject
4a95c6b06ebe Split LDFileLoader (now LDDocumentLoader) into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
29 {
4a95c6b06ebe Split LDFileLoader (now LDDocumentLoader) into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
30 Q_OBJECT
4a95c6b06ebe Split LDFileLoader (now LDDocumentLoader) into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
31
4a95c6b06ebe Split LDFileLoader (now LDDocumentLoader) into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
32 public:
4a95c6b06ebe Split LDFileLoader (now LDDocumentLoader) into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
33 DocumentLoader (bool onForeground = false, QObject* parent = 0);
4a95c6b06ebe Split LDFileLoader (now LDDocumentLoader) into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
34
4a95c6b06ebe Split LDFileLoader (now LDDocumentLoader) into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
35 Q_SLOT void abort();
4a95c6b06ebe Split LDFileLoader (now LDDocumentLoader) into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
36 bool hasAborted();
4a95c6b06ebe Split LDFileLoader (now LDDocumentLoader) into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
37 bool isDone() const;
4a95c6b06ebe Split LDFileLoader (now LDDocumentLoader) into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
38 bool isOnForeground() const;
4a95c6b06ebe Split LDFileLoader (now LDDocumentLoader) into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
39 const LDObjectList& objects() const;
4a95c6b06ebe Split LDFileLoader (now LDDocumentLoader) into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
40 int progress() const;
4a95c6b06ebe Split LDFileLoader (now LDDocumentLoader) into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
41 void read (QIODevice* fp);
4a95c6b06ebe Split LDFileLoader (now LDDocumentLoader) into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
42 Q_SLOT void start();
4a95c6b06ebe Split LDFileLoader (now LDDocumentLoader) into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
43 int warningCount() const;
4a95c6b06ebe Split LDFileLoader (now LDDocumentLoader) into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
44
4a95c6b06ebe Split LDFileLoader (now LDDocumentLoader) into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
45 private:
4a95c6b06ebe Split LDFileLoader (now LDDocumentLoader) into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
46 class OpenProgressDialog* m_progressDialog;
4a95c6b06ebe Split LDFileLoader (now LDDocumentLoader) into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
47 LDObjectList m_objects;
4a95c6b06ebe Split LDFileLoader (now LDDocumentLoader) into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
48 QStringList m_lines;
4a95c6b06ebe Split LDFileLoader (now LDDocumentLoader) into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
49 int m_progress;
4a95c6b06ebe Split LDFileLoader (now LDDocumentLoader) into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
50 int m_warningCount;
4a95c6b06ebe Split LDFileLoader (now LDDocumentLoader) into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
51 bool m_isDone;
4a95c6b06ebe Split LDFileLoader (now LDDocumentLoader) into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
52 bool m_hasAborted;
4a95c6b06ebe Split LDFileLoader (now LDDocumentLoader) into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
53 bool m_isOnForeground;
4a95c6b06ebe Split LDFileLoader (now LDDocumentLoader) into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
54
4a95c6b06ebe Split LDFileLoader (now LDDocumentLoader) into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
55 private slots:
4a95c6b06ebe Split LDFileLoader (now LDDocumentLoader) into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
56 void work (int i);
4a95c6b06ebe Split LDFileLoader (now LDDocumentLoader) into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
57
4a95c6b06ebe Split LDFileLoader (now LDDocumentLoader) into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
58 signals:
4a95c6b06ebe Split LDFileLoader (now LDDocumentLoader) into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
59 void progressUpdate (int progress);
4a95c6b06ebe Split LDFileLoader (now LDDocumentLoader) into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
60 void workDone();
4a95c6b06ebe Split LDFileLoader (now LDDocumentLoader) into its own files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
61 };

mercurial