| 232 | macro.name = name; |
| 233 | macro.fromPack(pack); |
| 234 | return true; |
| 235 | } |
| 236 | #endif |
| 237 | |
| 238 | void Macro::loadAll() |
| 239 | { |
| 240 | Qi::macroGroups.clear(); |
| 241 | Qi::macroGroups.append(MacroGroup(true, "默认分组")); |
| 242 | |
| 243 | QList<QString> dirs; |
| 244 | { |
| 245 | QDir dir(Qi::macroDir); |
| 246 | dir.setFilter(QDir::Filter::Dirs); |
| 247 | QFileInfoList dirInfos = dir.entryInfoList(); |
| 248 | if (dirInfos.isEmpty()) return; |
| 249 | |
| 250 | dirs.append(Qi::macroDir); |
| 251 | for (auto& i : dirInfos) if (i.fileName() != "." && i.fileName() != "..") dirs.append(i.fileName()); |
| 252 | } |
| 253 | |
| 254 | bool base = true; |
| 255 | for (auto& dir : dirs) |
| 256 | { |
| 257 | QString path = Qi::macroDir; |
| 258 | MacroGroup* group; |
| 259 | if (base) |
| 260 | { |
| 261 | group = &Qi::macroGroups.front(); |
| 262 | base = false; |
| 263 | } |
| 264 | else |
| 265 | { |
| 266 | group = &Qi::macroGroups.append(MacroGroup(false, dir)); |
| 267 | group->name = dir; |
| 268 | path += dir + "/"; |
| 269 | } |
| 270 | |
| 271 | #ifdef Q_ENCRYPT |
| 272 | for (const QFileInfo& file : File::Find(path, QString("*") + Qi::emacroType)) |
| 273 | { |
| 274 | if (file.fileName().compare(Qi::configFile, Qt::CaseInsensitive) == 0) continue; |
| 275 | Macro macro; |
| 276 | macro.groupName = group->name; |
| 277 | macro.groupBase = group->base; |
| 278 | if (LoadEMacro(macro, file.filePath(), file.baseName())) group->macros.append(std::move(macro)); |
| 279 | } |
| 280 | #endif |
| 281 | #if !defined(Q_ENCRYPT) || defined(Q_ENCRYPT_CVT) |
| 282 | for (size_t i = 0; i < Macro::StorageType::QIM + 1; i++) |
| 283 | { |
| 284 | const QString type = i == Macro::StorageType::QIM ? Qi::macroQimType : Qi::macroType; |
| 285 | const QString filter = QString("*") + type; |
| 286 | for (const QFileInfo& file : File::Find(path, filter)) |
| 287 | { |
| 288 | if (file.fileName().compare(Qi::configFile, Qt::CaseInsensitive) == 0) continue; |
| 289 | |
| 290 | Macro macro; |
| 291 | macro.groupName = group->name; |
nothing calls this directly
no test coverage detected