| 264 | } |
| 265 | |
| 266 | void BufferFormatSpecifier::updateFormatList() |
| 267 | { |
| 268 | QString sel; |
| 269 | |
| 270 | RDTreeWidgetItem *item = ui->savedList->selectedItem(); |
| 271 | if(item) |
| 272 | sel = item->text(0); |
| 273 | |
| 274 | { |
| 275 | QSignalBlocker block(ui->savedList); |
| 276 | int vs = ui->savedList->verticalScrollBar()->value(); |
| 277 | ui->savedList->beginUpdate(); |
| 278 | |
| 279 | ui->savedList->clear(); |
| 280 | |
| 281 | int selidx = -1; |
| 282 | |
| 283 | if(!m_AutoFormat.isEmpty()) |
| 284 | { |
| 285 | item = new RDTreeWidgetItem({tr("<Auto-generated>")}); |
| 286 | item->setItalic(true); |
| 287 | ui->savedList->addTopLevelItem(item); |
| 288 | |
| 289 | if(item->text(0) == sel) |
| 290 | selidx = 0; |
| 291 | } |
| 292 | |
| 293 | QStringList formats = globalFormatList->getFormats(); |
| 294 | |
| 295 | for(QString f : formats) |
| 296 | { |
| 297 | if(f == sel) |
| 298 | selidx = ui->savedList->topLevelItemCount(); |
| 299 | |
| 300 | ui->savedList->addTopLevelItem(new RDTreeWidgetItem({f})); |
| 301 | } |
| 302 | |
| 303 | { |
| 304 | item = new RDTreeWidgetItem({tr("New...")}); |
| 305 | if(item->text(0) == sel) |
| 306 | selidx = ui->savedList->topLevelItemCount(); |
| 307 | item->setEditable(0, true); |
| 308 | ui->savedList->addTopLevelItem(item); |
| 309 | } |
| 310 | |
| 311 | if(selidx >= 0) |
| 312 | ui->savedList->setSelectedItem(ui->savedList->topLevelItem(selidx)); |
| 313 | |
| 314 | ui->savedList->resizeColumnToContents(0); |
| 315 | |
| 316 | ui->savedList->endUpdate(); |
| 317 | ui->savedList->verticalScrollBar()->setValue(vs); |
| 318 | } |
| 319 | |
| 320 | on_savedList_itemSelectionChanged(); |
| 321 | } |
| 322 | |
| 323 | void BufferFormatSpecifier::on_savedList_keyPress(QKeyEvent *event) |
nothing calls this directly
no test coverage detected