hydrogen 1.2.3
License.h
Go to the documentation of this file.
1/*
2 * Hydrogen
3 * Copyright(c) 2002-2008 by Alex >Comix< Cominu [comix@users.sourceforge.net]
4 * Copyright(c) 2008-2024 The hydrogen development team [hydrogen-devel@lists.sourceforge.net]
5 *
6 * http://www.hydrogen-music.org
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY, without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see https://www.gnu.org/licenses
20 *
21 */
22
23#ifndef LICENSE_H
24#define LICENSE_H
25
26#include <core/Object.h>
27
28#include <QDateTime>
29#include <QString>
30
31namespace H2Core {
32
47class License : public H2Core::Object<License>
48{
50public:
51
52 License( const QString& sLicenseString = "", const QString& sCopyrightHolder = "" );
53 License( const License* pOther );
54 ~License();
55
76
77 static QString LicenseTypeToQString( LicenseType license );
78
79 static QString getGPLLicenseNotice( const QString& sAuthor );
80
81 void parse( const QString& sLicenseString );
82 QString getLicenseString() const;
83 QString getCopyrightHolder() const;
84 void setCopyrightHolder( const QString& sCopyrightHolder );
85
86 bool isCopyleft() const;
87 bool hasAttribution() const;
88
89 LicenseType getType() const;
90 void setType( LicenseType license );
91
92 bool operator==( const License& other ) const {
93 if ( m_license == other.m_license &&
95 if ( m_license == License::Other &&
97 return false;
98 }
99 else {
100 return true;
101 }
102 }
103
104 return false;
105 }
106
107 bool operator!=( const License& other ) const {
108 if ( m_license == other.m_license &&
110 if ( m_license == License::Other &&
112 return true;
113 }
114 else {
115 return false;
116 }
117 }
118
119 return true;
120 }
121
130 QString toQString( const QString& sPrefix = "", bool bShort = true ) const override;
131
132private:
141};
142
144 return m_license;
145}
146inline QString License::getLicenseString() const {
147 return m_sLicenseString;
148}
149inline QString License::getCopyrightHolder() const {
150 return m_sCopyrightHolder;
151}
152inline void License::setCopyrightHolder( const QString& sCopyrightHolder ) {
153 m_sCopyrightHolder = sCopyrightHolder;
154}
156
157 QString sType;
158
159 switch( license ) {
160 case License::CC_0:
161 return "CC0";
162
163 case License::CC_BY:
164 return "CC BY";
165
167 return "CC BY-NC";
168
170 return "CC BY-SA";
171
173 return "CC BY-NC-SA";
174
176 return "CC BY-ND";
177
179 return "CC BY-NC-ND";
180
181 case License::GPL:
182 return "GPL";
183
185 return "All rights reserved";
186
187 case License::Other:
188 return "Other";
189
190 default:
191 return "undefined license";
192 }
193}
194inline QString License::getGPLLicenseNotice( const QString& sAuthor ) {
195 return QString("Copyright (C) %1 %2\n\
196\n\
197 This program is free software: you can redistribute it and/or modify\n\
198 it under the terms of the GNU General Public License as published by\n\
199 the Free Software Foundation, either version 3 of the License, or\n\
200 (at your option) any later version.\n\
201\n\
202 This program is distributed in the hope that it will be useful,\n\
203 but WITHOUT ANY WARRANTY; without even the implied warranty of\n\
204 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n\
205 GNU General Public License for more details.\n\
206\n\
207 You should have received a copy of the GNU General Public License\n\
208 along with this program. If not, see <https://www.gnu.org/licenses/>." )
209 .arg( QDateTime::currentDateTime().toString( "yyyy" ) )
210 .arg( sAuthor );
211}
212};
213
214#endif // LICENSE_H
215
216/* vim: set softtabstop=4 noexpandtab: */
#define H2_OBJECT(name)
Definition Object.h:224
Wrapper class to help Hydrogen deal with the license information specified in a drumkit.
Definition License.h:48
LicenseType
A couple of recognized licenses.
Definition License.h:58
@ GPL
Not a desirable license for audio data but introduced here specifically since it is already used by a...
Definition License.h:68
@ Unspecified
No license set yet.
Definition License.h:74
@ AllRightsReserved
User decides with withhold all rights.
Definition License.h:70
@ Other
All other licenses not specified above.
Definition License.h:72
LicenseType getType() const
Definition License.h:143
bool hasAttribution() const
Definition License.cpp:138
void setCopyrightHolder(const QString &sCopyrightHolder)
Definition License.h:152
QString m_sCopyrightHolder
This variable will not be written to disk.
Definition License.h:140
QString getLicenseString() const
Definition License.h:146
bool operator!=(const License &other) const
Definition License.h:107
QString getCopyrightHolder() const
Definition License.h:149
QString m_sLicenseString
Definition License.h:134
bool operator==(const License &other) const
Definition License.h:92
void setType(LicenseType license)
Definition License.cpp:44
bool isCopyleft() const
Definition License.cpp:128
static QString getGPLLicenseNotice(const QString &sAuthor)
Definition License.h:194
static QString LicenseTypeToQString(LicenseType license)
Definition License.h:155
QString toQString(const QString &sPrefix="", bool bShort=true) const override
Formatted string version for debugging purposes.
Definition License.cpp:151
LicenseType m_license
Definition License.h:133
License(const QString &sLicenseString="", const QString &sCopyrightHolder="")
Definition License.cpp:28
void parse(const QString &sLicenseString)
Definition License.cpp:49