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

Method data

kdevplatform/debugger/framestack/framestackmodel.cpp:176–240  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

174}
175
176QVariant FrameStackModel::data(const QModelIndex& index, int role) const
177{
178 Q_D(const FrameStackModel);
179
180 if (!index.internalId()) {
181 //thread
182 if (d->m_threads.count() <= index.row()) return QVariant();
183 const ThreadItem &thread = d->m_threads.at(index.row());
184 if (index.column() == 0) {
185 if (role == Qt::DisplayRole) {
186 if (thread.nr == d->m_crashedThreadIndex) {
187 return i18nc("#thread-id at function-name or address", "#%1 at %2 (crashed)", thread.nr, thread.name);
188 } else {
189 return i18nc("#thread-id at function-name or address", "#%1 at %2", thread.nr, thread.name);
190 }
191 } else if (role == Qt::ForegroundRole) {
192 if (thread.nr == d->m_crashedThreadIndex) {
193 KColorScheme scheme(QPalette::Active);
194 return scheme.foreground(KColorScheme::NegativeText).color();
195 }
196 }
197 }
198 } else {
199 //frame
200 if (static_cast<quintptr>(d->m_threads.count()) < index.internalId()) return QVariant();
201 const ThreadItem &thread = d->m_threads.at(index.internalId()-1);
202 const auto& threadFrames = d->m_frames[thread.nr];
203 if (index.row() >= threadFrames.size())
204 return QVariant();
205 const FrameItem& frame = threadFrames.at(index.row());
206 if (index.column() == 0) {
207 if (role == Qt::DisplayRole) {
208 return QVariant(QString::number(frame.nr));
209 }
210 } else if (index.column() == 1) {
211 if (role == Qt::DisplayRole) {
212 return QVariant(frame.name);
213 }
214 } else if (index.column() == 2) {
215 if (role == Qt::DisplayRole) {
216 QString ret = ICore::self()->projectController()
217 ->prettyFileName(frame.file, IProjectController::FormatPlain);
218 if (frame.line != -1) {
219 ret += QLatin1Char(':') + QString::number(frame.line + 1);
220 }
221 return ret;
222 } else if (role == Qt::DecorationRole) {
223 QMimeType mime = QMimeDatabase().mimeTypeForUrl(frame.file);
224 return QIcon::fromTheme(mime.iconName());
225 } else if (role == Qt::ForegroundRole) {
226 const auto fileName = frame.file.toLocalFile();
227 auto cacheIt = d->m_fileExistsCache.find(fileName);
228 if (cacheIt == d->m_fileExistsCache.end()) {
229 cacheIt = d->m_fileExistsCache.insert(fileName, QFileInfo::exists(fileName));
230 }
231 const bool fileExists = cacheIt.value();
232 if (!fileExists) {
233 KColorScheme scheme(QPalette::Active);

Callers

nothing calls this directly

Calls 14

projectControllerMethod · 0.80
toLocalFileMethod · 0.80
QVariantClass · 0.50
countMethod · 0.45
rowMethod · 0.45
atMethod · 0.45
columnMethod · 0.45
sizeMethod · 0.45
prettyFileNameMethod · 0.45
iconNameMethod · 0.45
findMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected