| 156 | } |
| 157 | |
| 158 | bool SymbolView::setSymbolPath(const QString &path) |
| 159 | { |
| 160 | d->currentMode = Symbol; |
| 161 | d->view->setModel(&d->symbolModel); |
| 162 | d->symbolModel.clear(); |
| 163 | const auto &docSymbolList = SymbolManager::instance()->documentSymbols(path); |
| 164 | if (docSymbolList.isEmpty()) { |
| 165 | const auto &symbolInfoList = SymbolManager::instance()->symbolInformations(path); |
| 166 | if (symbolInfoList.isEmpty()) |
| 167 | return false; |
| 168 | |
| 169 | for (const auto &info : symbolInfoList) { |
| 170 | QStandardItem *item = new QStandardItem(info.name); |
| 171 | item->setToolTip(info.name); |
| 172 | item->setIcon(SymbolManager::instance()->iconFromKind(static_cast<SymbolManager::SymbolKind>(info.kind))); |
| 173 | item->setData(path, FilePathRole); |
| 174 | item->setData(QVariant::fromValue(info.location.range), SymbolRangeRole); |
| 175 | d->symbolModel.appendRow(item); |
| 176 | } |
| 177 | } else { |
| 178 | for (const auto &symbol : docSymbolList) { |
| 179 | QStandardItem *item = d->createSymbolItem(path, symbol); |
| 180 | d->symbolModel.appendRow(item); |
| 181 | } |
| 182 | } |
| 183 | |
| 184 | return true; |
| 185 | } |
| 186 | |
| 187 | void SymbolView::select(const QString &text) |
| 188 | { |
no test coverage detected