KAboutLicense
#include <KAboutLicense>
Public Types | |
enum | LicenseKey { Custom = -2 , File = -1 , Unknown = 0 , GPL = 1 , GPL_V2 = GPL , LGPL = 2 , LGPL_V2 = LGPL , BSDL = 3 , Artistic = 4 , GPL_V3 = 5 , LGPL_V3 = 6 , LGPL_V2_1 = 7 , MIT = 8 } |
enum | NameFormat { ShortName , FullName } |
enum | VersionRestriction { OnlyThisVersion , OrLaterVersions } |
Properties | |
KAboutLicense::LicenseKey | key |
QString | name |
QString | spdx |
QString | text |
Public Member Functions | |
KAboutLicense () | |
KAboutLicense (const KAboutLicense &other) | |
KAboutLicense::LicenseKey | key () const |
QString | name (KAboutLicense::NameFormat formatName=ShortName) const |
KAboutLicense & | operator= (const KAboutLicense &other) |
QString | spdx () const |
QString | text () const |
Static Public Member Functions | |
static KAboutLicense | byKeyword (const QString &keyword) |
Detailed Description
This class is used to store information about a license.
The license can be one of some predefined, one given as text or one that can be loaded from a file. This class is used in the KAboutData class. Explicitly creating a KAboutLicense object is not possible. If the license is wanted for a KDE component having KAboutData object, use KAboutData::licenses() to get the licenses for that component. If the license is for a non-code resource and given by a keyword (e.g. in .desktop files), try using KAboutLicense::byKeyword().
Definition at line 186 of file kaboutdata.h.
Member Enumeration Documentation
◆ LicenseKey
Describes the license of the software; for more information see: https://spdx.org/licenses/.
Enumerator | |
---|---|
Custom | Custom license. |
File | License set from text file, see setLicenseFromPath() |
Unknown | Unknown license. |
GPL | GPL. |
GPL_V2 | GPL_V2, this has the same value as LicenseKey::GPL, see https://spdx.org/licenses/GPL-2.0.html. |
LGPL | LGPL. |
LGPL_V2 | LGPL_V2, this has the same value as LicenseKey::LGPL, see https://spdx.org/licenses/LGPL-2.0-only.html. |
BSDL | BSDL, see https://spdx.org/licenses/BSD-2-Clause.html. |
Artistic | Artistic, see https://spdx.org/licenses/Artistic-2.0.html. |
GPL_V3 | GPL_V3, see https://spdx.org/licenses/GPL-3.0.html. |
LGPL_V3 | LGPL_V3, see https://spdx.org/licenses/LGPL-3.0-only.html. |
LGPL_V2_1 | LGPL_V2_1.
|
MIT | MIT.
|
Definition at line 200 of file kaboutdata.h.
◆ NameFormat
Format of the license name.
Definition at line 220 of file kaboutdata.h.
◆ VersionRestriction
Whether later versions of the license are allowed.
Definition at line 229 of file kaboutdata.h.
Property Documentation
◆ key
|
read |
Definition at line 191 of file kaboutdata.h.
◆ name
|
read |
Definition at line 189 of file kaboutdata.h.
◆ spdx
|
read |
Definition at line 192 of file kaboutdata.h.
◆ text
|
read |
Definition at line 190 of file kaboutdata.h.
Constructor & Destructor Documentation
◆ KAboutLicense() [1/2]
|
explicit |
- Since
- 5.53
Definition at line 167 of file kaboutdata.cpp.
◆ KAboutLicense() [2/2]
KAboutLicense::KAboutLicense | ( | const KAboutLicense & | other | ) |
Copy constructor.
Performs a deep copy.
- Parameters
-
other object to copy
Definition at line 187 of file kaboutdata.cpp.
◆ ~KAboutLicense()
KAboutLicense::~KAboutLicense | ( | ) |
Definition at line 192 of file kaboutdata.cpp.
Member Function Documentation
◆ byKeyword()
|
static |
Fetch a known license by a keyword/spdx ID.
Frequently the license data is provided by a terse keyword-like string, e.g. by a field in a .desktop file. Using this method, an application can get hold of a proper KAboutLicense object, providing that the license is one of the several known to KDE, and use it to present more human-readable information to the user.
Keywords are matched by stripping all whitespace and lowercasing. The known keywords correspond to the KAboutLicense::LicenseKey enumeration, e.g. any of "LGPLV3", "LGPLv3", "LGPL v3" would match KAboutLicense::LGPL_V3. If there is no match for the keyword, a valid license object is still returned, with its name and text informing about a custom license, and its key equal to KAboutLicense::Custom.
- Parameters
-
keyword The license keyword.
- Returns
- The license object.
- See also
- KAboutLicense::LicenseKey
Definition at line 372 of file kaboutdata.cpp.
◆ key()
KAboutLicense::LicenseKey KAboutLicense::key | ( | ) | const |
Returns the license key.
- Returns
- The license key as element of KAboutLicense::LicenseKey enum.
Definition at line 367 of file kaboutdata.cpp.
◆ name()
QString KAboutLicense::name | ( | KAboutLicense::NameFormat | formatName = ShortName | ) | const |
Returns the license name.
Default argument
- Since
- 5.53
- Returns
- The license name as a string.
Definition at line 310 of file kaboutdata.cpp.
◆ operator=()
KAboutLicense & KAboutLicense::operator= | ( | const KAboutLicense & | other | ) |
Assignment operator.
Performs a deep copy.
- Parameters
-
other object to copy
Definition at line 361 of file kaboutdata.cpp.
◆ spdx()
QString KAboutLicense::spdx | ( | ) | const |
Returns the SPDX license expression of this license.
If the underlying license cannot be expressed as a SPDX expression a null string is returned.
- Note
- SPDX expression are expansive constructs. If you parse the return value, do it in a SPDX specification compliant manner by splitting on whitespaces to discard unwanted information or by using a complete SPDX license expression parser.
- SPDX identifiers are case-insensitive. Do not use case-sensitive checks on the return value.
- See also
- https://spdx.org/licenses
- Returns
- SPDX license expression or QString() if the license has no identifier. Compliant with SPDX 2.1.
- Since
- 5.37
Definition at line 290 of file kaboutdata.cpp.
◆ text()
QString KAboutLicense::text | ( | ) | const |
Returns the full license text.
If the licenseType argument of the constructor has been used, any text defined by setLicenseText is ignored, and the standard text for the chosen license will be returned.
- Returns
- The license text.
Definition at line 208 of file kaboutdata.cpp.
The documentation for this class was generated from the following files:
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:08:22 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.