diff options
| author | Al <26797547+Al12rs@users.noreply.github.com> | 2020-09-01 04:00:04 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-09-01 04:00:04 -0700 |
| commit | 460a068b38ff9c03ec63578fd5a7968f07bd3465 (patch) | |
| tree | 53a7c8bc16dc82ead5fe7245d7668bd167941d65 /src/pluginlist.cpp | |
| parent | fa6136c6711a0b651e2d8b652b78b055f0343c9b (diff) | |
| parent | 6c86a0321ba11c30de2d50c73b785c9bd3818da8 (diff) | |
Merge pull request #1222 from Holt59/ipluginlist-setpriority
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());
|
