* Select files in the current directory. * @param paths file names * @return true if files found and selected. */
| 417 | * @return true if files found and selected. |
| 418 | */ |
| 419 | bool Kid3Cli::selectFile(const QStringList& paths) |
| 420 | { |
| 421 | bool ok = true; |
| 422 | FileProxyModel* model = m_app->getFileProxyModel(); |
| 423 | for (const QString& fileName : paths) { |
| 424 | QModelIndex index = model->index(fileName); |
| 425 | if (!index.isValid() && fileName.startsWith(QLatin1Char(':'))) { |
| 426 | // The FileSystemModel considers paths starting with a colon as invalid, |
| 427 | // retry with a relative path. See also comment about QResource in |
| 428 | // Kid3Application::openDirectory(). |
| 429 | index = model->index(QLatin1String("./") + fileName); |
| 430 | } |
| 431 | if (index.isValid()) { |
| 432 | m_app->getFileSelectionModel()->setCurrentIndex( |
| 433 | index, QItemSelectionModel::Select | QItemSelectionModel::Rows); |
| 434 | } else { |
| 435 | ok = false; |
| 436 | } |
| 437 | } |
| 438 | return ok; |
| 439 | } |
| 440 | |
| 441 | /** |
| 442 | * Update the currently selected files from the frame tables. |
no test coverage detected