TODO: add global lock TODO: make calls async TODO: only load checkset setlections on demand
| 84 | // TODO: make calls async |
| 85 | // TODO: only load checkset setlections on demand |
| 86 | CheckSetSelectionManager::CheckSetSelectionManager() |
| 87 | : m_checkSetSelectionFileWatcher(new KDirWatch(this)) |
| 88 | { |
| 89 | connect(m_checkSetSelectionFileWatcher, &KDirWatch::dirty, |
| 90 | this, &CheckSetSelectionManager::onCheckSetSelectionsFolderChanged); |
| 91 | |
| 92 | // get all folder where checkSetSelections could be stored |
| 93 | const QStringList dataFolderPaths = |
| 94 | QStandardPaths::standardLocations(QStandardPaths::GenericDataLocation); |
| 95 | |
| 96 | for (const QString& dataFolderPath : dataFolderPaths) { |
| 97 | const QString checkSetSelectionFolderPath = dataFolderPath + checkSetSelectionDirSubPath(); |
| 98 | // watch folder for changes |
| 99 | m_checkSetSelectionFileWatcher->addDir(checkSetSelectionFolderPath, KDirWatch::WatchDirOnly); |
| 100 | |
| 101 | // read current files |
| 102 | onCheckSetSelectionsFolderChanged(checkSetSelectionFolderPath); |
| 103 | } |
| 104 | |
| 105 | // default checkset selection |
| 106 | // While there is no proper config syncing offer in the used frameworks, use a |
| 107 | // single file with the id as content as workaround and watch for it changing |
| 108 | auto* defaultCheckSetSelectionWatcher = new KDirWatch(this); |
| 109 | connect(defaultCheckSetSelectionWatcher, &KDirWatch::created, |
| 110 | this, &CheckSetSelectionManager::onDefaultCheckSetSelectionChanged); |
| 111 | connect(defaultCheckSetSelectionWatcher, &KDirWatch::dirty, |
| 112 | this, &CheckSetSelectionManager::onDefaultCheckSetSelectionChanged); |
| 113 | const QString _defaultCheckSetSelectionFilePath = defaultCheckSetSelectionFilePath(); |
| 114 | |
| 115 | defaultCheckSetSelectionWatcher->addFile(_defaultCheckSetSelectionFilePath); |
| 116 | |
| 117 | onDefaultCheckSetSelectionChanged(_defaultCheckSetSelectionFilePath); |
| 118 | |
| 119 | // report any problems with existing checkset selections? |
| 120 | } |
| 121 | |
| 122 | CheckSetSelectionManager::~CheckSetSelectionManager() = default; |
| 123 |
nothing calls this directly
no test coverage detected