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

Exposes the credits database to QML as a list of sections, each carrying its own entries – so the About screen can render one card per category. More...

#include <creditsmodel.h>

Inheritance diagram for CreditsModel:
Collaboration diagram for CreditsModel:

Public Types

enum  CreditRoles { SectionRole = Qt::UserRole + 1 , EntriesRole }
 The roles QML can bind to (mapped to names in roleNames()). More...

Public Member Functions

virtual int rowCount (const QModelIndex &parent) const override
 Number of sections.
virtual QVariant data (const QModelIndex &index, int role) const override
 Value for a section + role.
virtual QHash< int, QByteArray > roleNames () const override
 Role -> QML name map.

Detailed Description

Exposes the credits database to QML as a list of sections, each carrying its own entries – so the About screen can render one card per category.

Section-grouped, not flat
The underlying CreditsDB store is flat (a section-header sentinel entry followed by that section's entries). A flat list model forces the view to interleave headers and rows by hand; for grouped "section cards" the natural shape is one model row per section. So this model regroups the flat store on first use:
  • section – the category name (the card heading);
  • entries – a QVariantList of {name,url,note,license,mandated} maps, iterated by a Repeater inside the card.
The mvc-model convention (shared by every model here)
Each is a QAbstractListModel that adapts a C++ collection (a DB store or a save object) for a QML ListView/Repeater, overriding rowCount()/data()/roleNames().
See also
CreditsDB (the source), Bridge (exposes this as brg.creditsModel).

Definition at line 42 of file creditsmodel.h.

Member Enumeration Documentation

◆ CreditRoles

The roles QML can bind to (mapped to names in roleNames()).

Enumerator
SectionRole 

Category name (the card heading).

EntriesRole 

QVariantList of this section's entry maps.

Definition at line 48 of file creditsmodel.h.

Member Function Documentation

◆ data()

QVariant CreditsModel::data ( const QModelIndex & index,
int role ) const
overridevirtual

Value for a section + role.

Definition at line 67 of file creditsmodel.cpp.

References EntriesRole, and SectionRole.

◆ roleNames()

QHash< int, QByteArray > CreditsModel::roleNames ( ) const
overridevirtual

Role -> QML name map.

Definition at line 90 of file creditsmodel.cpp.

References EntriesRole, and SectionRole.

◆ rowCount()

int CreditsModel::rowCount ( const QModelIndex & parent) const
overridevirtual

Number of sections.

Definition at line 59 of file creditsmodel.cpp.


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