r22875 by jghali - Refactor ScActionPlugin::handleSelection() for better readability
scribus-commit
scribus-commit at lists.scribus.net
Wed Mar 6 00:06:55 UTC 2019
Author: jghali
Date: Wed Mar 6 00:06:55 2019
New Revision: 22875
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=22875
Log:
Refactor ScActionPlugin::handleSelection() for better readability
Modified:
trunk/Scribus/scribus/scplugin.cpp
Modified: trunk/Scribus/scribus/scplugin.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22875&path=/trunk/Scribus/scribus/scplugin.cpp
==============================================================================
--- trunk/Scribus/scribus/scplugin.cpp (original)
+++ trunk/Scribus/scribus/scplugin.cpp Wed Mar 6 00:06:55 2019
@@ -167,57 +167,52 @@
correctAppMode = true;
else if (ai.forAppMode.contains(doc->appMode))
correctAppMode = true;
- if (correctAppMode)
+
+ if (!correctAppMode)
+ return false;
+
+ if (ai.needsNumObjects == -1)
+ return true;
+
+ if (ai.needsNumObjects > 2)
{
- if (ai.needsNumObjects == -1)
- return true;
-
-
- if (ai.needsNumObjects > 2)
+ bool setter = true;
+ for (int bx = 0; bx < docSelectionCount; ++bx)
{
- bool setter = true;
- for (int bx = 0; bx < docSelectionCount; ++bx)
- {
- if (ai.notSuitableFor.contains(doc->m_Selection->itemAt(bx)->itemType()))
- setter = false;
- }
- return setter;
+ if (ai.notSuitableFor.contains(doc->m_Selection->itemAt(bx)->itemType()))
+ setter = false;
}
-
-
- if (docSelectionCount == ai.needsNumObjects)
+ return setter;
+ }
+
+ if (docSelectionCount != ai.needsNumObjects)
+ return false;
+
+ if (ai.needsNumObjects == 2)
+ {
+ int sel1 = doc->m_Selection->itemAt(0)->itemType();
+ int sel2 = doc->m_Selection->itemAt(1)->itemType();
+ if (ai.notSuitableFor.contains(sel1))
+ return false;
+ if (ai.notSuitableFor.contains(sel2))
+ return false;
+ if ((ai.firstObjectType.count() == 0) && (ai.secondObjectType.count() == 0))
+ return true;
+ if ((ai.firstObjectType.count() == 0) && (ai.secondObjectType.count() != 0))
{
- if (ai.needsNumObjects == 2)
- {
- int sel1 = doc->m_Selection->itemAt(0)->itemType();
- int sel2 = doc->m_Selection->itemAt(1)->itemType();
- if (ai.notSuitableFor.contains(sel1))
- return false;
- if (ai.notSuitableFor.contains(sel2))
- return false;
- if ((ai.firstObjectType.count() == 0) && (ai.secondObjectType.count() == 0))
- return true;
- if ((ai.firstObjectType.count() == 0) && (ai.secondObjectType.count() != 0))
- {
- if ((ai.secondObjectType.contains(sel2)) || (ai.secondObjectType.contains(sel1)))
- return true;
- }
- else if ((ai.firstObjectType.count() != 0) && (ai.secondObjectType.count() == 0))
- {
- if ((ai.firstObjectType.contains(sel2)) || (ai.firstObjectType.contains(sel1)))
- return true;
- }
- if (((ai.firstObjectType.contains(sel1)) && (ai.secondObjectType.contains(sel2))) || ((ai.firstObjectType.contains(sel2)) && (ai.secondObjectType.contains(sel1))))
- return true;
- }
- else if (!ai.notSuitableFor.contains(SelectedType))
+ if ((ai.secondObjectType.contains(sel2)) || (ai.secondObjectType.contains(sel1)))
return true;
- else
- return false;
}
- else
- return false;
+ else if ((ai.firstObjectType.count() != 0) && (ai.secondObjectType.count() == 0))
+ {
+ if ((ai.firstObjectType.contains(sel2)) || (ai.firstObjectType.contains(sel1)))
+ return true;
+ }
+ if (((ai.firstObjectType.contains(sel1)) && (ai.secondObjectType.contains(sel2))) || ((ai.firstObjectType.contains(sel2)) && (ai.secondObjectType.contains(sel1))))
+ return true;
}
+ else if (!ai.notSuitableFor.contains(SelectedType))
+ return true;
else
return false;
}
More information about the scribus-commit
mailing list