Pokered Save Editor 2
Pokemon Red & Blue save file editor - Qt 6 C++/QML
Loading...
Searching...
No Matches
CreditDBEntry Struct Reference

One credits entry – and the canonical example of the "DB entry" pattern. More...

#include <creditdbentry.h>

Inheritance diagram for CreditDBEntry:
Collaboration diagram for CreditDBEntry:

Public Member Functions

QString getSection () const
 < Credits section heading.
QString getName () const
QString getUrl () const
QString getNote () const
QString getLicense () const
QString getMandated () const
void qmlProtect (const QQmlEngine *const engine) const
 Pin to C++ ownership (anti-GC).

Protected Member Functions

 CreditDBEntry ()
 Empty entry (protected – built by the DB).
 CreditDBEntry (QJsonValue &data)
 Build from a JSON value.
 CreditDBEntry (QString section)
 Build a section-header entry.
void qmlRegister () const
 Register this entry type with QML.

Static Protected Member Functions

static void process (QJsonObject &data)
 Parse JSON and append entries to CreditsDB's store.

Protected Attributes

QString section = ""
 Backing field (read via getSection()).
QString name = ""
 Backing field (read via getName()).
QString url = ""
 Backing field (read via getUrl()).
QString note = ""
 Backing field (read via getNote()).
QString license = ""
 Backing field (read via getLicense()).
QString mandated = ""
 Backing field (read via getMandated()).

Friends

class CreditsDB
 The owning DB constructs/populates these entries.

Detailed Description

One credits entry – and the canonical example of the "DB entry" pattern.

The DB-entry convention (shared by every *DBEntry struct here)
  • A QObject struct whose data fields are protected (write-once, set during load from JSON), exposed to QML and C++ through public getters wired as Q_PROPERTY ... READ. Always read via the getter (getName()), never the field.
  • Protected constructors take the JSON (QJsonValue&) or a key; a static process() parses the JSON and appends entries to the owning DB's store.
  • The owning DB is a friend (it constructs/populates entries).
  • Richer entries also add a deepLink() that resolves cross-references after all DBs are loaded (e.g. a move's type, an evolution's target). Credits has no links, so it has none – but the pattern is the same everywhere else.
See also
CreditsDB (its database), DB (the aggregate), the db system map.

Definition at line 42 of file creditdbentry.h.

Constructor & Destructor Documentation

◆ CreditDBEntry() [1/3]

CreditDBEntry::CreditDBEntry ( )
protected

Empty entry (protected – built by the DB).

Definition at line 31 of file creditdbentry.cpp.

References qmlRegister().

Referenced by process().

◆ CreditDBEntry() [2/3]

CreditDBEntry::CreditDBEntry ( QJsonValue & data)
protected

Build from a JSON value.

Definition at line 35 of file creditdbentry.cpp.

References license, mandated, name, note, qmlRegister(), and url.

◆ CreditDBEntry() [3/3]

CreditDBEntry::CreditDBEntry ( QString section)
protected

Build a section-header entry.

Definition at line 46 of file creditdbentry.cpp.

References qmlRegister(), and section.

Member Function Documentation

◆ getLicense()

QString CreditDBEntry::getLicense ( ) const
See also
getLicense property.

Definition at line 63 of file creditdbentry.cpp.

References license.

◆ getMandated()

QString CreditDBEntry::getMandated ( ) const
See also
getMandated property.

Definition at line 53 of file creditdbentry.cpp.

References mandated.

◆ getName()

QString CreditDBEntry::getName ( ) const
See also
getName property.

Definition at line 78 of file creditdbentry.cpp.

References name.

◆ getNote()

QString CreditDBEntry::getNote ( ) const
See also
getNote property.

Definition at line 68 of file creditdbentry.cpp.

References note.

◆ getSection()

QString CreditDBEntry::getSection ( ) const

< Credits section heading.

Credited name. Associated URL. Free-text note. License text/name. Mandated-attribution text.

See also
getSection property.

Definition at line 83 of file creditdbentry.cpp.

References section.

◆ getUrl()

QString CreditDBEntry::getUrl ( ) const
See also
getUrl property.

Definition at line 73 of file creditdbentry.cpp.

References url.

◆ process()

void CreditDBEntry::process ( QJsonObject & data)
staticprotected

Parse JSON and append entries to CreditsDB's store.

Definition at line 88 of file creditdbentry.cpp.

References CreditDBEntry(), CreditsDB::inst(), and section.

Referenced by CreditsDB::load().

◆ qmlProtect()

void CreditDBEntry::qmlProtect ( const QQmlEngine *const engine) const

Pin to C++ ownership (anti-GC).

Definition at line 58 of file creditdbentry.cpp.

References Utility::qmlProtectUtil().

◆ qmlRegister()

void CreditDBEntry::qmlRegister ( ) const
protected

Register this entry type with QML.

Definition at line 107 of file creditdbentry.cpp.

Referenced by CreditDBEntry(), CreditDBEntry(), and CreditDBEntry().

◆ CreditsDB

friend class CreditsDB
friend

The owning DB constructs/populates these entries.

Definition at line 77 of file creditdbentry.h.

References CreditsDB.

Referenced by CreditsDB.

Member Data Documentation

◆ license

QString CreditDBEntry::license = ""
protected

Backing field (read via getLicense()).

Definition at line 74 of file creditdbentry.h.

Referenced by CreditDBEntry(), and getLicense().

◆ mandated

QString CreditDBEntry::mandated = ""
protected

Backing field (read via getMandated()).

Definition at line 75 of file creditdbentry.h.

Referenced by CreditDBEntry(), and getMandated().

◆ name

QString CreditDBEntry::name = ""
protected

Backing field (read via getName()).

Definition at line 71 of file creditdbentry.h.

Referenced by CreditDBEntry(), and getName().

◆ note

QString CreditDBEntry::note = ""
protected

Backing field (read via getNote()).

Definition at line 73 of file creditdbentry.h.

Referenced by CreditDBEntry(), and getNote().

◆ section

QString CreditDBEntry::section = ""
protected

Backing field (read via getSection()).

Definition at line 70 of file creditdbentry.h.

Referenced by CreditDBEntry(), getSection(), and process().

◆ url

QString CreditDBEntry::url = ""
protected

Backing field (read via getUrl()).

Definition at line 72 of file creditdbentry.h.

Referenced by CreditDBEntry(), and getUrl().


The documentation for this struct was generated from the following files: