MCPcopy Create free account
hub / github.com/FreesmTeam/FreesmLauncher / data

Method data

launcher/minecraft/mod/ResourcePackFolderModel.cpp:62–139  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

60}
61
62QVariant ResourcePackFolderModel::data(const QModelIndex& index, int role) const
63{
64 if (!validateIndex(index))
65 return {};
66
67 int row = index.row();
68 int column = index.column();
69
70 switch (role) {
71 case Qt::DisplayRole:
72 switch (column) {
73 case NameColumn:
74 return m_resources[row]->name();
75 case PackFormatColumn: {
76 auto resource = at(row);
77 auto pack_format = resource->packFormat();
78 if (pack_format == 0)
79 return tr("Unrecognized");
80
81 auto version_bounds = resource->compatibleVersions();
82 if (version_bounds.first.toString().isEmpty())
83 return QString::number(pack_format);
84
85 return QString("%1 (%2 - %3)")
86 .arg(QString::number(pack_format), version_bounds.first.toString(), version_bounds.second.toString());
87 }
88 case DateColumn:
89 return m_resources[row]->dateTimeChanged();
90 case SizeColumn:
91 return m_resources[row]->sizeStr();
92
93 default:
94 return {};
95 }
96 case Qt::DecorationRole: {
97 if (column == NameColumn && (at(row)->isSymLinkUnder(instDirPath()) || at(row)->isMoreThanOneHardLink()))
98 return APPLICATION->getThemedIcon("status-yellow");
99 if (column == ImageColumn) {
100 return at(row)->image({ 32, 32 }, Qt::AspectRatioMode::KeepAspectRatioByExpanding);
101 }
102 return {};
103 }
104 case Qt::ToolTipRole: {
105 if (column == PackFormatColumn) {
106 //: The string being explained by this is in the format: ID (Lower version - Upper version)
107 return tr("The resource pack format ID, as well as the Minecraft versions it was designed for.");
108 }
109 if (column == NameColumn) {
110 if (at(row)->isSymLinkUnder(instDirPath())) {
111 return m_resources[row]->internal_id() +
112 tr("\nWarning: This resource is symbolically linked from elsewhere. Editing it will also change the original."
113 "\nCanonical Path: %1")
114 .arg(at(row)->fileinfo().canonicalFilePath());
115 ;
116 }
117 if (at(row)->isMoreThanOneHardLink()) {
118 return m_resources[row]->internal_id() +
119 tr("\nWarning: This resource is hard linked elsewhere. Editing it will also change the original.");

Callers

nothing calls this directly

Calls 15

QStringClass · 0.85
dateTimeChangedMethod · 0.80
sizeStrMethod · 0.80
getThemedIconMethod · 0.80
internal_idMethod · 0.80
canonicalFilePathMethod · 0.80
fileinfoMethod · 0.80
enabledMethod · 0.80
nameMethod · 0.45
packFormatMethod · 0.45
compatibleVersionsMethod · 0.45
isEmptyMethod · 0.45

Tested by

no test coverage detected