| 80 | } |
| 81 | |
| 82 | void PluginManager::sort(bool ascending) |
| 83 | { |
| 84 | std::sort(m_plugins.begin(), m_plugins.end(), [ascending](const PluginInfo &p1, const PluginInfo &p2) { |
| 85 | if(!p1.isLoaded() && !p2.isLoaded()) { |
| 86 | return ascending ? p1.name() < p2.name() : p1.name() > p2.name(); |
| 87 | } |
| 88 | if(!p1.isLoaded()) { |
| 89 | return !ascending; |
| 90 | } |
| 91 | if(!p2.isLoaded()) { |
| 92 | return ascending; |
| 93 | } |
| 94 | int priority1 = p1.pluginInstance()->metadata()["priority"].toInt(); |
| 95 | int priority2 = p2.pluginInstance()->metadata()["priority"].toInt(); |
| 96 | return ascending ? priority1 < priority2 : priority1 > priority2; |
| 97 | }); |
| 98 | |
| 99 | qDebug(CAT_PLUGINMANAGER) << "New plugin order:"; |
| 100 | for(const PluginInfo &plugin : qAsConst(m_plugins)) { |
| 101 | qDebug(CAT_PLUGINMANAGER) << plugin.name(); |
| 102 | } |
| 103 | } |
| 104 | |
| 105 | void PluginManager::clear() { m_plugins.clear(); } |
| 106 | |