itom  4.1.0
pyCodeFormatter.h
1 /* ********************************************************************
2  itom software
3  URL: http://www.uni-stuttgart.de/ito
4  Copyright (C) 2020, Institut fuer Technische Optik (ITO),
5  Universitaet Stuttgart, Germany
6 
7  This file is part of itom.
8 
9  itom is free software; you can redistribute it and/or modify it
10  under the terms of the GNU Library General Public Licence as published by
11  the Free Software Foundation; either version 2 of the Licence, or (at
12  your option) any later version.
13 
14  itom is distributed in the hope that it will be useful, but
15  WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library
17  General Public Licence for more details.
18 
19  You should have received a copy of the GNU Library General Public License
20  along with itom. If not, see <http://www.gnu.org/licenses/>.
21 
22 *********************************************************************** */
23 
24 #pragma once
25 
26 #include <qobject.h>
27 #include <qprocess.h>
28 #include <qstring.h>
29 #include <qsharedpointer.h>
30 #include <qprogressdialog.h>
31 
32 #include "common/retVal.h"
33 
34 namespace ito
35 {
36 
37  class PyCodeFormatter : public QObject
38  {
39  Q_OBJECT
40  public:
41  PyCodeFormatter(QObject *parent = nullptr);
42  ~PyCodeFormatter();
43 
44  ito::RetVal startFormatting(const QString &cmd, const QString &code, QWidget *dialogParent = nullptr);
45 
46  private:
47  QProcess m_process;
48  QString m_currentCode;
49  QString m_currentError;
50  QSharedPointer<QProgressDialog> m_progressDialog;
51  bool m_isCancelling;
52 
53  ito::RetVal getPythonPath(QString &path) const;
54 
55 
56  private slots:
57  void errorOccurred(QProcess::ProcessError error);
58  void finished(int exitCode, QProcess::ExitStatus exitStatus);
59  void readyReadStandardError();
60  void readyReadStandardOutput();
61  void started();
62  void cancelRequested();
63 
64  signals:
65  void formattingDone(bool success, QString code);
66 
67  };
68 
69 }; // end namepsace ito
Definition: pyCodeFormatter.h:37
Class for managing status values (like errors or warning)
Definition: retVal.h:54
Definition: apiFunctionsGraph.cpp:39