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