RTXI  3.0.0
The Real-Time eXperiment Interface Reference Manual
rtxi_wizard.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2011 Georgia Institute of Technology, University of Utah,
3  Weill Cornell Medical College
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 #ifndef RTXI_WIZARD_H
20 #define RTXI_WIZARD_H
21 
22 #include <QDir>
23 #include <QListWidget>
24 #include <QNetworkAccessManager>
25 #include <QNetworkReply>
26 #include <QProgressDialog>
27 #include <QTextEdit>
28 #include <map>
29 
30 #include "widgets.hpp"
31 
32 namespace RTXIWizard
33 {
34 
35 constexpr std::string_view MODULE_NAME = "Module Wizard";
36 
37 class Panel : public Widgets::Panel
38 {
39  Q_OBJECT
40 
41 public:
42  Panel(QMainWindow* mwindow, Event::Manager* ev_manager);
43  void installFromString(const std::string& module_name);
44  void rebuildListWidgets();
45 
46 private slots:
47  void cloneModule();
48  void getRepos();
49  void getReadme();
50  void updateButton();
51  void parseRepos();
52  void parseReadme();
53 
54 private:
55  QDir install_prefix;
56 
57  struct module_t
58  {
59  QUrl readme_url;
60  QUrl clone_url;
61  QString readme;
62  bool installed = false;
63  };
64 
65  std::map<QString, module_t> modules;
66  void initParameters();
67  enum button_mode_t
68  {
69  DOWNLOAD,
70  UPDATE
71  } button_mode {DOWNLOAD};
72 
73  QNetworkAccessManager qnam;
74  QNetworkReply* reposNetworkReply = nullptr;
75  QNetworkReply* readmeNetworkReply = nullptr;
76  QProgressDialog* progressDialog = nullptr;
77 
78  QTextEdit* readmeWindow = nullptr;
79  QListWidget* availableListWidget = nullptr;
80  QListWidget* installedListWidget = nullptr;
81 
82  QPushButton* cloneButton = nullptr;
83  QPushButton* syncButton = nullptr;
84 
85  std::vector<QString> exclude_list;
86 };
87 
88 class Plugin : public Widgets::Plugin
89 {
90 public:
91  explicit Plugin(Event::Manager* ev_manager)
92  : Widgets::Plugin(ev_manager, std::string(RTXIWizard::MODULE_NAME))
93  {
94  }
95 }; // class Plugin
96 
97 std::unique_ptr<Widgets::Plugin> createRTXIPlugin(Event::Manager* ev_manager);
98 
99 Widgets::Panel* createRTXIPanel(QMainWindow* main_window,
100  Event::Manager* ev_manager);
101 
102 std::unique_ptr<Widgets::Component> createRTXIComponent(
103  Widgets::Plugin* host_plugin);
104 
106 
107 } // namespace RTXIWizard
108 
109 #endif
void installFromString(const std::string &module_name)
Panel(QMainWindow *mwindow, Event::Manager *ev_manager)
Definition: rtxi_wizard.cpp:40
Plugin(Event::Manager *ev_manager)
Definition: rtxi_wizard.hpp:91
Widgets::FactoryMethods getFactories()
std::unique_ptr< Widgets::Plugin > createRTXIPlugin(Event::Manager *ev_manager)
constexpr std::string_view MODULE_NAME
Definition: rtxi_wizard.hpp:35
Widgets::Panel * createRTXIPanel(QMainWindow *main_window, Event::Manager *ev_manager)
std::unique_ptr< Widgets::Component > createRTXIComponent(Widgets::Plugin *host_plugin)
Definition: rt.hpp:35