WareshubJsonEditor.hpp
Go to the documentation of this file.
1 /*
2 
3  This file is part of OpenFLUID software
4  Copyright(c) 2007, INRA - Montpellier SupAgro
5 
6 
7  == GNU General Public License Usage ==
8 
9  OpenFLUID is free software: you can redistribute it and/or modify
10  it under the terms of the GNU General Public License as published by
11  the Free Software Foundation, either version 3 of the License, or
12  (at your option) any later version.
13 
14  OpenFLUID is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU General Public License for more details.
18 
19  You should have received a copy of the GNU General Public License
20  along with OpenFLUID. If not, see <http://www.gnu.org/licenses/>.
21 
22 
23  == Other Usage ==
24 
25  Other Usage means a use of OpenFLUID that is inconsistent with the GPL
26  license, and requires a written agreement between You and INRA.
27  Licensees for Other Usage of OpenFLUID may use this file in accordance
28  with the terms contained in the written agreement between You and INRA.
29 
30  */
31 
32 /**
33  @file WareshubJsonEditor.hpp
34  @brief Header of ...
35 
36  @author Aline LIBRES <aline.libres@gmail.com>
37  */
38 
39 
40 #ifndef __OPENFLUID_UIWARESDEV_WARESHUBJSONEDITOR_HPP__
41 #define __OPENFLUID_UIWARESDEV_WARESHUBJSONEDITOR_HPP__
42 
43 
44 #include <rapidjson/document.h>
45 
46 #include <QLineEdit>
47 #include <QComboBox>
48 
49 #include <openfluid/dllexport.hpp>
52 
53 
54 namespace Ui {
55 class WareshubJsonEditor;
56 }
57 
58 
59 namespace openfluid { namespace ui { namespace waresdev {
60 
61 
62 class OPENFLUID_API WareshubJsonEditor: public QWidget, public WareFileEditor
63 {
64  Q_OBJECT
65 
66 
67  private:
68 
69  Ui::WareshubJsonEditor* ui;
70 
71  rapidjson::Document Doc;
72 
73  bool m_IsModified = false;
74 
75  // SPDX License List Version: 2.2 Sep 30, 2015 https://spdx.org/licenses/
76  QStringList m_Licenses = { "0BSD", "AAL", "Abstyles", "Adobe-2006", "Adobe-Glyph", "ADSL", "AFL-1.1", "AFL-1.2",
77  "AFL-2.0", "AFL-2.1", "AFL-3.0", "Afmparse", "AGPL-1.0", "AGPL-3.0", "Aladdin",
78  "AMDPLPA", "AML", "AMPAS", "ANTLR-PD", "Apache-1.0", "Apache-1.1", "Apache-2.0",
79  "APAFML", "APL-1.0", "APSL-1.0", "APSL-1.1", "APSL-1.2", "APSL-2.0", "Artistic-1.0",
80  "Artistic-1.0-cl8", "Artistic-1.0-Perl", "Artistic-2.0", "Bahyph", "Barr", "Beerware",
81  "BitTorrent-1.0", "BitTorrent-1.1", "Borceux", "BSD-2-Clause", "BSD-2-Clause-FreeBSD",
82  "BSD-2-Clause-NetBSD", "BSD-3-Clause", "BSD-3-Clause-Attribution", "BSD-3-Clause-Clear",
83  "BSD-3-Clause-LBNL", "BSD-4-Clause", "BSD-4-Clause-UC", "BSD-Protection", "BSL-1.0",
84  "bzip2-1.0.5", "bzip2-1.0.6", "Caldera", "CATOSL-1.1", "CC-BY-1.0", "CC-BY-2.0",
85  "CC-BY-2.5", "CC-BY-3.0", "CC-BY-4.0", "CC-BY-NC-1.0", "CC-BY-NC-2.0", "CC-BY-NC-2.5",
86  "CC-BY-NC-3.0", "CC-BY-NC-4.0", "CC-BY-NC-ND-1.0", "CC-BY-NC-ND-2.0", "CC-BY-NC-ND-2.5",
87  "CC-BY-NC-ND-3.0", "CC-BY-NC-ND-4.0", "CC-BY-NC-SA-1.0", "CC-BY-NC-SA-2.0",
88  "CC-BY-NC-SA-2.5", "CC-BY-NC-SA-3.0", "CC-BY-NC-SA-4.0", "CC-BY-ND-1.0", "CC-BY-ND-2.0",
89  "CC-BY-ND-2.5", "CC-BY-ND-3.0", "CC-BY-ND-4.0", "CC-BY-SA-1.0", "CC-BY-SA-2.0",
90  "CC-BY-SA-2.5", "CC-BY-SA-3.0", "CC-BY-SA-4.0", "CC0-1.0", "CDDL-1.0", "CDDL-1.1",
91  "CECILL-1.0", "CECILL-1.1", "CECILL-2.0", "CECILL-2.1", "CECILL-B", "CECILL-C",
92  "ClArtistic", "CNRI-Jython", "CNRI-Python", "CNRI-Python-GPL-Compatible", "Condor-1.1",
93  "CPAL-1.0", "CPL-1.0", "CPOL-1.02", "Crossword", "CrystalStacker", "CUA-OPL-1.0",
94  "Cube", "D-FSL-1.0", "diffmark", "DOC", "Dotseqn", "DSDP", "dvipdfm", "ECL-1.0",
95  "ECL-2.0", "EFL-1.0", "EFL-2.0", "eGenix", "Entessa", "EPL-1.0", "ErlPL-1.1",
96  "EUDatagrid", "EUPL-1.0", "EUPL-1.1", "Eurosym", "Fair", "Frameworx-1.0", "FreeImage",
97  "FSFUL", "FSFULLR", "FTL", "GFDL-1.1", "GFDL-1.2", "GFDL-1.3", "Giftware", "GL2PS",
98  "Glide", "Glulxe", "gnuplot", "GPL-1.0", "GPL-2.0", "GPL-3.0", "gSOAP-1.3b",
99  "HaskellReport", "HPND", "IBM-pibs", "ICU", "IJG", "ImageMagick", "iMatix", "Imlib2",
100  "Intel", "Intel-ACPI", "Interbase-1.0", "IPA", "IPL-1.0", "ISC", "JasPer-2.0", "JSON",
101  "Latex2e", "Leptonica", "LGPL-2.0", "LGPL-2.1", "LGPL-3.0", "LGPLLR", "Libpng",
102  "libtiff", "LPL-1.0", "LPL-1.02", "LPPL-1.0", "LPPL-1.1", "LPPL-1.2", "LPPL-1.3a",
103  "LPPL-1.3c", "MakeIndex", "MirOS", "MIT", "MIT-advertising", "MIT-CMU", "MIT-enna",
104  "MIT-feh", "MITNFA", "Motosoto", "mpich2", "MPL-1.0", "MPL-1.1", "MPL-2.0",
105  "MPL-2.0-no-copyleft-exception", "MS-PL", "MS-RL", "MTLL", "Multics", "Mup", "NASA-1.3",
106  "Naumen", "NBPL-1.0", "NCSA", "NetCDF", "Newsletr", "NGPL", "NLPL", "Nokia", "NOSL",
107  "Noweb", "NPL-1.0", "NPL-1.1", "NPOSL-3.0", "NRL", "NTP", "Nunit", "OCLC-2.0",
108  "ODbL-1.0", "OFL-1.0", "OFL-1.1", "OGTSL", "OLDAP-1.1", "OLDAP-1.2", "OLDAP-1.3",
109  "OLDAP-1.4", "OLDAP-2.0", "OLDAP-2.0.1", "OLDAP-2.1", "OLDAP-2.2", "OLDAP-2.2.1",
110  "OLDAP-2.2.2", "OLDAP-2.3", "OLDAP-2.4", "OLDAP-2.5", "OLDAP-2.6", "OLDAP-2.7",
111  "OLDAP-2.8", "OML", "OpenSSL", "OPL-1.0", "OSL-1.0", "OSL-1.1", "OSL-2.0", "OSL-2.1",
112  "OSL-3.0", "PDDL-1.0", "PHP-3.0", "PHP-3.01", "Plexus", "PostgreSQL", "psfrag",
113  "psutils", "Python-2.0", "Qhull", "QPL-1.0", "Rdisc", "RHeCos-1.1", "RPL-1.1",
114  "RPL-1.5", "RPSL-1.0", "RSA-MD", "RSCPL", "Ruby", "SAX-PD", "Saxpath", "SCEA",
115  "Sendmail", "SGI-B-1.0", "SGI-B-1.1", "SGI-B-2.0", "SimPL-2.0", "SISSL", "SISSL-1.2",
116  "Sleepycat", "SMLNJ", "SNIA", "Spencer-86", "Spencer-94", "Spencer-99", "SPL-1.0",
117  "SugarCRM-1.1.3", "SWL", "TCL", "TMate", "TORQUE-1.1", "TOSL", "Unicode-TOU",
118  "Unlicense", "UPL-1.0", "Vim", "VOSTROM", "VSL-1.0", "W3C", "W3C-19980720",
119  "Watcom-1.0", "Wsuipa", "WTFPL", "X11", "Xerox", "XFree86-1.1", "xinetd", "Xnet", "xpp",
120  "XSkat", "YPL-1.0", "YPL-1.1", "Zed", "Zend-2.0", "Zimbra-1.3", "Zimbra-1.4", "Zlib",
121  "zlib-acknowledgement", "ZPL-1.1", "ZPL-2.0", "ZPL-2.1" };
122 
123  QStringList m_Statuses = { "stable", "experimental", "beta" };
124 
125  QMap<QString, WareshubIssueDialog::Issue> m_IssuesByID;
126 
127  void jsonStringArrayToLineEdit(const QString& Key, QLineEdit* LineEdit);
128 
129  void lineEditToJsonStringArray(const QString& Key, QLineEdit* LineEdit);
130 
131  void jsonStringToComboBox(const QString& Key, QComboBox* Combo);
132 
133  void comboBoxToJsonString(const QString& Key, QComboBox* Combo);
134 
135  void jsonIssuesToIssuesMap();
136 
137  void issuesMapToJsonIssues();
138 
139  void updateIssuesTable();
140 
141 
142  private slots:
143 
144  void onChanged();
145 
146  void onRemoveIssueClicked();
147 
148  void onEditIssueClicked();
149 
150  void onAddIssueClicked();
151 
152 
153  signals :
154 
155  void editorChanged(WareFileEditor* Editor, bool Changed);
156 
157  void editorSaved();
158 
159 
160  public:
161 
162  WareshubJsonEditor(const QString& FilePath, QWidget* Parent = nullptr);
163 
165 
166  void saveContent();
167 
168  void saveContentToPath(const QString& Path);
169 
170  void updateContent();
171 
172  bool findReplace(FindReplaceDialog::FindReplaceAction Action, const QString& StringToFind,
173  const QString& StringForReplace, QTextDocument::FindFlags Options, QString& Message);
174 
175  QString getSelectedText();
176 
177  bool isModified();
178 
179  QWidget* getWidget();
180 
182  { }
183 
185  { }
186 
188  { }
189 
190  void copy()
191  { }
192 
193  void cut()
194  { }
195 
196  void paste()
197  { }
198 
199  void selectLine(int /*LineNumber*/)
200  { }
201 
202  void goToLine()
203  { }
204 
206  { }
207 
208  void setFocus()
209  { }
210 
211 };
212 
213 
214 } } } // namespaces
215 
216 
217 #endif /* __OPENFLUID_UIWARESDEV_WARESHUBJSONEDITOR_HPP__ */
void addLineMessage(openfluid::waresdev::WareSrcMsgParser::WareSrcMsg)
Definition: WareshubJsonEditor.hpp:184
void selectLine(int)
Definition: WareshubJsonEditor.hpp:199
Definition: AboutDialog.hpp:51
void setFocus()
Definition: WareshubJsonEditor.hpp:208
Definition: WareshubJsonEditor.hpp:62
void copy()
Definition: WareshubJsonEditor.hpp:190
void updateLineNumberArea()
Definition: WareshubJsonEditor.hpp:187
Header of ...
void updateSettings()
Definition: WareshubJsonEditor.hpp:205
Definition: WareSrcMsgParser.hpp:58
Definition: WareFileEditor.hpp:54
Definition: ApplicationException.hpp:47
void paste()
Definition: WareshubJsonEditor.hpp:196
#define OPENFLUID_API
Definition: dllexport.hpp:87
void clearLineMessages()
Definition: WareshubJsonEditor.hpp:181
void goToLine()
Definition: WareshubJsonEditor.hpp:202
FindReplaceAction
Definition: FindReplaceDialog.hpp:67
void cut()
Definition: WareshubJsonEditor.hpp:193