----------------------------------------------------------------------------
| 660 | |
| 661 | //---------------------------------------------------------------------------- |
| 662 | QStringList ctkPluginStorageSQL::findResourcesPath(int archiveKey, const QString& path) const |
| 663 | { |
| 664 | QSqlDatabase database = getConnection(); |
| 665 | QSqlQuery query(database); |
| 666 | |
| 667 | QString statement = "SELECT SUBSTR(ResourcePath,?) FROM PluginResources WHERE K=? AND SUBSTR(ResourcePath,1,?)=?"; |
| 668 | |
| 669 | QString resourcePath = path.startsWith('/') ? path : QString("/") + path; |
| 670 | if (!resourcePath.endsWith('/')) |
| 671 | resourcePath += "/"; |
| 672 | |
| 673 | QList<QVariant> bindValues; |
| 674 | bindValues.append(resourcePath.size()+1); |
| 675 | bindValues.append(archiveKey); |
| 676 | bindValues.append(resourcePath.size()); |
| 677 | bindValues.append(resourcePath); |
| 678 | |
| 679 | executeQuery(&query, statement, bindValues); |
| 680 | |
| 681 | QSet<QString> paths; |
| 682 | while (query.next()) |
| 683 | { |
| 684 | QString currPath = query.value(EBindIndex).toString(); |
| 685 | #if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)) |
| 686 | QStringList components = currPath.split('/', Qt::SkipEmptyParts); |
| 687 | #else |
| 688 | QStringList components = currPath.split('/', QString::SkipEmptyParts); |
| 689 | #endif |
| 690 | if (components.size() == 1) |
| 691 | { |
| 692 | paths << components.front(); |
| 693 | } |
| 694 | else if (components.size() == 2) |
| 695 | { |
| 696 | paths << components.front() + "/"; |
| 697 | } |
| 698 | } |
| 699 | |
| 700 | return ctk::qSetToQStringList(paths); |
| 701 | } |
| 702 | |
| 703 | //---------------------------------------------------------------------------- |
| 704 | void ctkPluginStorageSQL::executeQuery(QSqlQuery *query, const QString &statement, const QList<QVariant> &bindValues) const |
no test coverage detected