1 /*
2 # PostgreSQL Database Modeler (pgModeler)
3 #
4 # Copyright 2006-2020 - Raphael Araújo e Silva <raphael@pgmodeler.io>
5 #
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation version 3.
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 # The complete text of GPLv3 is at LICENSE file on source code root directory.
16 # Also, you can get the complete GNU General Public License at <http://www.gnu.org/licenses/>
17 */
18 
19 /**
20 \ingroup libpgmodeler_ui
21 \class ModelExportForm
22 \brief Implements the operations to export a model to a file, image or directly to DBMS.
23 */
24 
25 #ifndef MODEL_EXPORT_FORM_H
26 #define MODEL_EXPORT_FORM_H
27 
28 #include "ui_modelexportform.h"
29 #include "schemaparser.h"
30 #include "modelwidget.h"
31 #include "modelexporthelper.h"
32 #include "htmlitemdelegate.h"
33 #include "fileselectorwidget.h"
34 
35 class ModelExportForm: public QDialog, public Ui::ModelExportForm {
36 	private:
37 		Q_OBJECT
38 
39 		/*! \brief Indicates if the full output generated during the process should be displayed
40 		 * When this attribute is true, only errors and some key info messages are displayed. */
41 		static bool low_verbosity;
42 
43 		//! \brief Custom delegate used to paint html texts in output tree
44 		HtmlItemDelegate *htmlitem_del;
45 
46 		//! \brief Stores the model widget which will be exported
47 		ModelWidget *model;
48 
49 		//! \brief Export helper
50 		ModelExportHelper export_hlp;
51 
52 		//! \brief Thread used to manage the export helper when dealing with dbms export
53 		QThread *export_thread;
54 
55 		//! \brief Auxiliary viewport passed to export helper when dealing with PNG export
56 		QGraphicsView *viewp;
57 
58 		FileSelectorWidget *sql_file_sel,
59 		*img_file_sel,
60 		*dict_file_sel;
61 
62 		void finishExport(const QString &msg);
63 		void enableExportModes(bool value);
64 		void closeEvent(QCloseEvent *event);
exec(void)65 		int exec(void){ return QDialog::Rejected; }
66 
67 	public:
68 		ModelExportForm(QWidget * parent = nullptr, Qt::WindowFlags f = Qt::Widget);
69 
70 		//! \brief Defines if all the output generated during the import process should be displayed
71 		static void setLowVerbosity(bool value);
72 
73 	public slots:
74 		void exec(ModelWidget *model);
75 
76 	private slots:
77 		void selectExportMode();
78 		void exportModel();
79 		void updateProgress(int progress, QString msg, ObjectType obj_type, QString cmd, bool is_code_gen);
80 		void captureThreadError(Exception e);
81 		void cancelExport();
82 		void handleExportFinished();
83 		void handleExportCanceled();
84 		void handleErrorIgnored(QString err_code, QString err_msg, QString cmd);
85 		void editConnections();
86 		void enableExport();
87 		void selectImageFormat();
88 		void selectDataDictType();
89 
90 	signals:
91 		/*! \brief This signal is emitted whenever the user changes the connections settings
92 		within this widget without use the main configurations dialog */
93 		void s_connectionsUpdateRequest();
94 };
95 
96 #endif
97