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

Method data

launcher/minecraft/mod/TexturePackFolderModel.cpp:65–122  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

63}
64
65QVariant TexturePackFolderModel::data(const QModelIndex& index, int role) const
66{
67 if (!validateIndex(index))
68 return {};
69
70 int row = index.row();
71 int column = index.column();
72
73 switch (role) {
74 case Qt::DisplayRole:
75 switch (column) {
76 case NameColumn:
77 return m_resources[row]->name();
78 case DateColumn:
79 return m_resources[row]->dateTimeChanged();
80 case SizeColumn:
81 return m_resources[row]->sizeStr();
82 default:
83 return {};
84 }
85 case Qt::ToolTipRole:
86 if (column == NameColumn) {
87 if (at(row)->isSymLinkUnder(instDirPath())) {
88 return m_resources[row]->internal_id() +
89 tr("\nWarning: This resource is symbolically linked from elsewhere. Editing it will also change the original."
90 "\nCanonical Path: %1")
91 .arg(at(row)->fileinfo().canonicalFilePath());
92 ;
93 }
94 if (at(row)->isMoreThanOneHardLink()) {
95 return m_resources[row]->internal_id() +
96 tr("\nWarning: This resource is hard linked elsewhere. Editing it will also change the original.");
97 }
98 }
99
100 return m_resources[row]->internal_id();
101 case Qt::DecorationRole: {
102 if (column == NameColumn && (at(row)->isSymLinkUnder(instDirPath()) || at(row)->isMoreThanOneHardLink()))
103 return APPLICATION->getThemedIcon("status-yellow");
104 if (column == ImageColumn) {
105 return at(row)->image({ 32, 32 }, Qt::AspectRatioMode::KeepAspectRatioByExpanding);
106 }
107 return {};
108 }
109 case Qt::SizeHintRole:
110 if (column == ImageColumn) {
111 return QSize(32, 32);
112 }
113 return {};
114 case Qt::CheckStateRole:
115 if (column == ActiveColumn) {
116 return m_resources[row]->enabled() ? Qt::Checked : Qt::Unchecked;
117 }
118 return {};
119 default:
120 return {};
121 }
122}

Callers

nothing calls this directly

Calls 11

dateTimeChangedMethod · 0.80
sizeStrMethod · 0.80
internal_idMethod · 0.80
canonicalFilePathMethod · 0.80
fileinfoMethod · 0.80
getThemedIconMethod · 0.80
enabledMethod · 0.80
nameMethod · 0.45
isSymLinkUnderMethod · 0.45
isMoreThanOneHardLinkMethod · 0.45
imageMethod · 0.45

Tested by

no test coverage detected