Documentation for OpenFLUID 2.2.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
WareshubIssueDialog.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 WareshubIssueDialog.hpp
34 
35  @author Aline LIBRES <aline.libres@gmail.com>
36  @author Jean-Christophe FABRE <jean-christophe.fabre@inra.fr>
37 */
38 
39 
40 #ifndef __OPENFLUID_UICOMMON_WARESHUBISSUEDIALOG_HPP__
41 #define __OPENFLUID_UICOMMON_WARESHUBISSUEDIALOG_HPP__
42 
43 
44 #include <QDate>
45 
46 #include <openfluid/dllexport.hpp>
49 
50 
51 namespace Ui {
52 class WareshubIssueDialog;
53 }
54 
55 
56 namespace openfluid { namespace ui { namespace common {
57 
58 
60 {
61  Q_OBJECT
62 
63 
64  public:
65 
66  struct Issue
67  {
68  unsigned int m_ID = 0;
69  QString m_Title;
70  QString m_Creator;
71  QDateTime m_DateCreation;
72  QString m_State;
73  QString m_Description;
74  QString m_Tags;
75 
76  Issue() :
77  m_DateCreation(QDateTime::currentDateTime())
78  {
79  }
80 
82  {
83  m_ID = Issue.ID;
84  m_Title = QString::fromStdString(Issue.Title);
85  m_Description = QString::fromStdString(Issue.Description);
86  m_Creator = QString::fromStdString(Issue.Creator);
87  m_DateCreation = QDateTime::fromString(QString::fromStdString(Issue.CreatedAt.getAsISOString()),
88  "yyyy-MM-dd HH:mm:ss");
89 
90  m_Tags = QString::fromStdString(openfluid::tools::join(Issue.Tags, ";"));
91  m_State = Issue.IsOpen ? "open" : "closed";
92  }
93 
94 
95  Issue(const openfluid::thirdparty::json& IssueJson) : Issue(openfluid::ware::WareIssue::fromJSON(IssueJson))
96  {
97  }
98 
99 
101  {
103  Issue.ID = m_ID;
104  Issue.Title = m_Title.toStdString();
105  Issue.Description = m_Description.toStdString();
106  Issue.Creator = m_Creator.toStdString();
107  Issue.CreatedAt = openfluid::core::DateTime::fromISOString(m_DateCreation.toString(
108  "yyyy-MM-dd HH:mm:ss").toStdString());
109  Issue.IsOpen = m_State.toStdString() != "closed";
110 
111  for (const auto& T : openfluid::tools::split(m_Tags.toStdString(), ';'))
112  {
113  Issue.Tags.push_back(T);
114  }
115  return Issue;
116  }
117 
118 
119  };
120 
121 
122  private slots:
123 
124  void onChanged();
125 
126 
127  private:
128 
129  Ui::WareshubIssueDialog* ui;
130 
131  QList<unsigned int> m_IDs;
132 
133  QString m_DefaultMessage;
134 
135  //TODO Add tag list
136 
137  QStringList m_Statuses = { "open", "closed" };
138 
139 
140  public:
141 
142  WareshubIssueDialog(const QList<unsigned int>& IDs, QWidget* Parent = nullptr, const Issue& I = Issue());
143 
145 
147 
148 };
149 
150 
151 } } } // namespaces
152 
153 
154 #endif /* __OPENFLUID_UICOMMON_WARESHUBISSUEDIALOG_HPP__ */
static DateTime fromISOString(const std::string &DateTimeStr)
Definition: MessageDialog.hpp:56
Definition: WareshubIssueDialog.hpp:60
WareshubIssueDialog(const QList< unsigned int > &IDs, QWidget *Parent=nullptr, const Issue &I=Issue())
Definition: WareIssues.hpp:60
#define OPENFLUID_API
Definition: dllexport.hpp:86
Definition: AboutDialog.hpp:51
nlohmann::ordered_json json
Definition: JSON.hpp:52
std::vector< std::string > OPENFLUID_API split(const std::string &Str, const char Sep, bool KeepEmpty=false)
std::string OPENFLUID_API join(const std::vector< std::string > &Vect, const std::string &Sep)
Definition: ApplicationException.hpp:47
Definition: WareshubIssueDialog.hpp:67
openfluid::ware::WareIssue toWareIssue() const
Definition: WareshubIssueDialog.hpp:100
QString m_State
Definition: WareshubIssueDialog.hpp:72
QString m_Title
Definition: WareshubIssueDialog.hpp:69
Issue()
Definition: WareshubIssueDialog.hpp:76
QString m_Description
Definition: WareshubIssueDialog.hpp:73
Issue(const openfluid::ware::WareIssue &Issue)
Definition: WareshubIssueDialog.hpp:81
QString m_Tags
Definition: WareshubIssueDialog.hpp:74
Issue(const openfluid::thirdparty::json &IssueJson)
Definition: WareshubIssueDialog.hpp:95
QDateTime m_DateCreation
Definition: WareshubIssueDialog.hpp:71
QString m_Creator
Definition: WareshubIssueDialog.hpp:70