MCPcopy Create free account
hub / github.com/KDE/kdevelop / data

Method data

kdevplatform/shell/problemmodel.cpp:119–179  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

117}
118
119QVariant ProblemModel::data(const QModelIndex& index, int role) const
120{
121 Q_D(const ProblemModel);
122
123 if (!index.isValid())
124 return QVariant();
125
126 QUrl baseDirectory = d->m_problems->currentDocument().toUrl().adjusted(QUrl::RemoveFilename);
127 IProblem::Ptr p = problemForIndex(index);
128 if (!p.constData()) {
129 if (role == Qt::DisplayRole && index.column() == Error) {
130 auto *node = reinterpret_cast<ProblemStoreNode*>(index.internalPointer());
131 if (node) {
132 return node->label();
133 }
134 }
135 return {};
136 }
137
138 if (role == SeverityRole) {
139 return p->severity();
140 } else if (role == ProblemRole) {
141 return QVariant::fromValue(p);
142 }
143
144 switch (role) {
145 case Qt::DisplayRole:
146 switch (index.column()) {
147 case Source:
148 return p->sourceString();
149 case Error:
150 return p->description();
151 case File:
152 return displayUrl(p->finalLocation().document.toUrl().adjusted(QUrl::NormalizePathSegments), baseDirectory);
153 case Line:
154 if (p->finalLocation().isValid()) {
155 return QString::number(p->finalLocation().start().line() + 1);
156 }
157 break;
158 case Column:
159 if (p->finalLocation().isValid()) {
160 return QString::number(p->finalLocation().start().column() + 1);
161 }
162 break;
163 }
164 break;
165
166 case Qt::DecorationRole:
167 if (index.column() == Error) {
168 return IProblem::iconForSeverity(p->severity());
169 }
170 break;
171 case Qt::ToolTipRole:
172 return p->explanation();
173
174 default:
175 break;
176 }

Callers 15

setupActionsMethod · 0.45
addRuntimesMethod · 0.45
formatFileMethod · 0.45
ProblemModelMethod · 0.45
storeMethod · 0.45
beautifySourceMethod · 0.45
beautifyLineMethod · 0.45
allowAllLanguagesFunction · 0.45
removePluginViewMethod · 0.45
interfaceMethod · 0.45
setupActionsMethod · 0.45
openProjectMethod · 0.45

Calls 12

displayUrlFunction · 0.85
QVariantClass · 0.50
isValidMethod · 0.45
toUrlMethod · 0.45
columnMethod · 0.45
severityMethod · 0.45
sourceStringMethod · 0.45
descriptionMethod · 0.45
finalLocationMethod · 0.45
lineMethod · 0.45
startMethod · 0.45
explanationMethod · 0.45

Tested by 5

~TestFileMethod · 0.36
initializeMethod · 0.36
flushOutputMethod · 0.36
runTestsFunction · 0.36
DeclarationTestFunction · 0.36