! \internal */
| 1204 | \internal |
| 1205 | */ |
| 1206 | void PluginManagerPrivate::readPluginPaths() |
| 1207 | { |
| 1208 | qDeleteAll(pluginCategories); |
| 1209 | qDeleteAll(pluginSpecs); |
| 1210 | pluginSpecs.clear(); |
| 1211 | pluginCategories.clear(); |
| 1212 | |
| 1213 | QStringList specFiles; |
| 1214 | QStringList searchPaths = pluginPaths; |
| 1215 | while (!searchPaths.isEmpty()) { |
| 1216 | const QDir dir(searchPaths.takeFirst()); |
| 1217 | const QString pattern = QLatin1String("*.") + extension; |
| 1218 | const QFileInfoList files = dir.entryInfoList(QStringList(pattern), QDir::Files); |
| 1219 | foreach (const QFileInfo &file, files) |
| 1220 | specFiles << file.absoluteFilePath(); |
| 1221 | const QFileInfoList dirs = dir.entryInfoList(QDir::Dirs|QDir::NoDotAndDotDot); |
| 1222 | foreach (const QFileInfo &subdir, dirs) |
| 1223 | searchPaths << subdir.absoluteFilePath(); |
| 1224 | } |
| 1225 | defaultCollection = new PluginCollection(QString()); |
| 1226 | pluginCategories.insert(QString(), defaultCollection); |
| 1227 | |
| 1228 | foreach (const QString &specFile, specFiles) { |
| 1229 | PluginSpec *spec = new PluginSpec; |
| 1230 | spec->d->read(specFile); |
| 1231 | |
| 1232 | PluginCollection *collection = 0; |
| 1233 | // find correct plugin collection or create a new one |
| 1234 | if (pluginCategories.contains(spec->category())) { |
| 1235 | collection = pluginCategories.value(spec->category()); |
| 1236 | } else { |
| 1237 | collection = new PluginCollection(spec->category()); |
| 1238 | pluginCategories.insert(spec->category(), collection); |
| 1239 | } |
| 1240 | if (defaultDisabledPlugins.contains(spec->name())) { |
| 1241 | spec->setDisabledByDefault(true); |
| 1242 | spec->setEnabled(false); |
| 1243 | } |
| 1244 | if (spec->isDisabledByDefault() && forceEnabledPlugins.contains(spec->name())) |
| 1245 | spec->setEnabled(true); |
| 1246 | if (!spec->isDisabledByDefault() && disabledPlugins.contains(spec->name())) |
| 1247 | spec->setEnabled(false); |
| 1248 | |
| 1249 | collection->addPlugin(spec); |
| 1250 | pluginSpecs.append(spec); |
| 1251 | } |
| 1252 | resolveDependencies(); |
| 1253 | // ensure deterministic plugin load order by sorting |
| 1254 | qSort(pluginSpecs.begin(), pluginSpecs.end(), lessThanByPluginName); |
| 1255 | emit q->pluginsChanged(); |
| 1256 | } |
| 1257 | |
| 1258 | void PluginManagerPrivate::resolveDependencies() |
| 1259 | { |