diff options
| author | Mikaël Capelle <capelle.mikael@gmail.com> | 2020-08-30 14:03:49 +0200 |
|---|---|---|
| committer | Mikaël Capelle <capelle.mikael@gmail.com> | 2020-08-30 14:03:49 +0200 |
| commit | 6c86a0321ba11c30de2d50c73b785c9bd3818da8 (patch) | |
| tree | 69c8f1ae33bb50b7ec93032ed82e3877f50cd226 /src/pluginlist.cpp | |
| parent | f0e94c26aebae6f86a59ed974e433f96e77faec7 (diff) | |
Add IPluginList::setPriority implementation.
Diffstat (limited to 'src/pluginlist.cpp')
| -rw-r--r-- | src/pluginlist.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/pluginlist.cpp b/src/pluginlist.cpp index c2667557..67ca0133 100644 --- a/src/pluginlist.cpp +++ b/src/pluginlist.cpp @@ -766,6 +766,29 @@ int PluginList::priority(const QString &name) const }
}
+bool PluginList::setPriority(const QString& name, int newPriority) {
+
+ if (newPriority < 0 || newPriority >= static_cast<int>(m_ESPsByPriority.size())) {
+ return false;
+ }
+
+ auto oldPriority = priority(name);
+ if (oldPriority == -1) {
+ return false;
+ }
+
+ int rowIndex = findPluginByPriority(oldPriority);
+
+ // We need to increment newPriority if its above the old one, otherwise the
+ // plugin is place right below the new priority.
+ if (oldPriority < newPriority) {
+ newPriority += 1;
+ }
+ changePluginPriority({ rowIndex }, newPriority);
+
+ return true;
+}
+
int PluginList::loadOrder(const QString &name) const
{
auto iter = m_ESPsByName.find(name.toLower());
|
