| 288 | } |
| 289 | |
| 290 | QVariant QuickOpenModel::data(const QModelIndex& index, int role) const |
| 291 | { |
| 292 | QuickOpenDataPointer d = getItem(index.row()); |
| 293 | |
| 294 | if (!d) { |
| 295 | return QVariant(); |
| 296 | } |
| 297 | |
| 298 | switch (role) { |
| 299 | case KTextEditor::CodeCompletionModel::ItemSelected: { |
| 300 | QString desc = d->htmlDescription(); |
| 301 | if (desc.isEmpty()) { |
| 302 | return QVariant(); |
| 303 | } else { |
| 304 | return desc; |
| 305 | } |
| 306 | } |
| 307 | |
| 308 | case KTextEditor::CodeCompletionModel::IsExpandable: |
| 309 | return d->isExpandable(); |
| 310 | case KTextEditor::CodeCompletionModel::ExpandingWidget: { |
| 311 | QWidget* w = d->expandingWidget(); |
| 312 | if (w && m_expandingWidgetHeightIncrease) { |
| 313 | w->resize(w->width(), w->height() + m_expandingWidgetHeightIncrease); |
| 314 | } |
| 315 | return QVariant::fromValue(w); |
| 316 | } |
| 317 | case ExpandingTree::ProjectPathRole: |
| 318 | // TODO: put this into the QuickOpenDataBase API |
| 319 | // we cannot do this in 5.0, cannot change ABI |
| 320 | if (auto projectFile = dynamic_cast<const ProjectFileData*>(d.constData())) { |
| 321 | return QVariant::fromValue(projectFile->projectPath()); |
| 322 | } else if (auto duchainItem = dynamic_cast<const DUChainItemData*>(d.constData())) { |
| 323 | return QVariant::fromValue(duchainItem->projectPath()); |
| 324 | } |
| 325 | } |
| 326 | |
| 327 | if (index.column() == 1) { //This column contains the actual content |
| 328 | switch (role) { |
| 329 | case Qt::DecorationRole: |
| 330 | return d->icon(); |
| 331 | |
| 332 | case Qt::DisplayRole: |
| 333 | return d->text(); |
| 334 | case KTextEditor::CodeCompletionModel::HighlightingMethod: |
| 335 | return KTextEditor::CodeCompletionModel::CustomHighlighting; |
| 336 | case KTextEditor::CodeCompletionModel::CustomHighlight: |
| 337 | return d->highlighting(); |
| 338 | } |
| 339 | } else if (index.column() == 0) { //This column only contains the expanded/not expanded icon |
| 340 | switch (role) { |
| 341 | case Qt::DecorationRole: |
| 342 | { |
| 343 | if (isExpandable(index)) { |
| 344 | //Show the expanded/unexpanded handles |
| 345 | if (isExpanded(index)) { |
| 346 | return QIcon::fromTheme(QStringLiteral("arrow-down")); |
| 347 | } else { |