| 43 | */ |
| 44 | |
| 45 | SyncthingModels::SyncthingModels(Data::SyncthingConnection &connection, QQmlEngine *engine, QObject *parent) |
| 46 | : QObject(parent) |
| 47 | , m_connection(connection) |
| 48 | , m_dirModel(connection) |
| 49 | , m_sortFilterDirModel(&m_dirModel) |
| 50 | , m_devModel(connection) |
| 51 | , m_sortFilterDevModel(&m_devModel) |
| 52 | , m_recentChangesModel(connection) |
| 53 | #ifdef SYNCTHINGWIDGETS_GUI_QTQUICK |
| 54 | , m_engine(engine) |
| 55 | #endif |
| 56 | { |
| 57 | #ifndef SYNCTHINGWIDGETS_GUI_QTQUICK |
| 58 | Q_UNUSED(engine) |
| 59 | #endif |
| 60 | |
| 61 | // set SD card paths to show SD card icons via directory model |
| 62 | #ifdef Q_OS_ANDROID |
| 63 | qDebug() << "Loading external storage paths"; |
| 64 | auto extStoragePaths = externalStoragePaths(); |
| 65 | auto sdCardPaths = QStringList(); |
| 66 | if (extStoragePaths.size() > 1) { |
| 67 | static constexpr auto storagePrefix = QLatin1String("/storage/"); |
| 68 | sdCardPaths.reserve(extStoragePaths.size() - 1); |
| 69 | for (auto i = extStoragePaths.begin() + 1, end = extStoragePaths.end(); i != end; ++i) { |
| 70 | if (const auto &path = *i; path.startsWith(storagePrefix)) { |
| 71 | if (const auto volumeEnd = path.indexOf(QChar('/'), storagePrefix.size()); volumeEnd > 0) { |
| 72 | sdCardPaths.emplace_back(QStringView(path.data(), volumeEnd + 1)); |
| 73 | } |
| 74 | } |
| 75 | } |
| 76 | } |
| 77 | m_dirModel.setSdCardPaths(sdCardPaths); |
| 78 | #endif |
| 79 | |
| 80 | m_sortFilterDirModel.sort(0, Qt::AscendingOrder); |
| 81 | m_sortFilterDevModel.sort(0, Qt::AscendingOrder); |
| 82 | |
| 83 | // show info when override/revert has been triggered |
| 84 | #ifdef SYNCTHINGWIDGETS_GUI_QTQUICK |
| 85 | connect(&m_connection, &Data::SyncthingConnection::overrideTriggered, this, |
| 86 | [this](const QString &dirId) { emit info(tr("Triggered override of \"%1\"").arg(dirDisplayName(dirId))); }); |
| 87 | connect(&m_connection, &Data::SyncthingConnection::revertTriggered, this, |
| 88 | [this](const QString &dirId) { emit info(tr("Triggered revert of \"%1\"").arg(dirDisplayName(dirId))); }); |
| 89 | #endif |
| 90 | } |
| 91 | |
| 92 | SyncthingModels::SyncthingModels(SyncthingData &data, QQmlEngine *engine, QObject *parent) |
| 93 | : SyncthingModels(*data.connection(), engine, parent) |
nothing calls this directly
no test coverage detected