MCPcopy Create free account
hub / github.com/PolyMC/PolyMC / data

Method data

launcher/minecraft/mod/ResourcePackFolderModel.cpp:49–99  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

47}
48
49QVariant ResourcePackFolderModel::data(const QModelIndex& index, int role) const
50{
51 if (!validateIndex(index))
52 return {};
53
54 int row = index.row();
55 int column = index.column();
56
57 switch (role) {
58 case Qt::DisplayRole:
59 switch (column) {
60 case NameColumn:
61 return m_resources[row]->name();
62 case PackFormatColumn: {
63 auto resource = at(row);
64 auto pack_format = resource->packFormat();
65 if (pack_format == 0)
66 return tr("Unrecognized");
67
68 auto version_bounds = resource->compatibleVersions();
69 if (version_bounds.first.toString().isEmpty())
70 return QString::number(pack_format);
71
72 return QString("%1 (%2 - %3)")
73 .arg(QString::number(pack_format), version_bounds.first.toString(), version_bounds.second.toString());
74 }
75 case DateColumn:
76 return m_resources[row]->dateTimeChanged();
77
78 default:
79 return {};
80 }
81
82 case Qt::ToolTipRole: {
83 if (column == PackFormatColumn) {
84 //: The string being explained by this is in the format: ID (Lower version - Upper version)
85 return tr("The resource pack format ID, as well as the Minecraft versions it was designed for.");
86 }
87 return m_resources[row]->internal_id();
88 }
89 case Qt::CheckStateRole:
90 switch (column) {
91 case ActiveColumn:
92 return at(row)->enabled() ? Qt::Checked : Qt::Unchecked;
93 default:
94 return {};
95 }
96 default:
97 return {};
98 }
99}
100
101QVariant ResourcePackFolderModel::headerData(int section, Qt::Orientation orientation, int role) const
102{

Callers

nothing calls this directly

Calls 9

QStringClass · 0.85
packFormatMethod · 0.80
compatibleVersionsMethod · 0.80
isEmptyMethod · 0.80
dateTimeChangedMethod · 0.80
internal_idMethod · 0.80
enabledMethod · 0.80
nameMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected