From 9fb110883dc156d8fb2ef2168f3b56496a783a42 Mon Sep 17 00:00:00 2001 From: thomahl <thomahl@stud.ntnu.no> Date: Wed, 18 Mar 2020 11:04:27 +0100 Subject: [PATCH] #54 early-return -> if-else --- soitool/module_list.py | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/soitool/module_list.py b/soitool/module_list.py index 5c72ec6..978d7b7 100644 --- a/soitool/module_list.py +++ b/soitool/module_list.py @@ -164,23 +164,23 @@ class ModuleList(QListWidget): "mulig å låse utvalgte moduler, men la resten optimalt " "pakkes.", ) - # ignoring the drop event by returning early - return - super().dropEvent(event) + else: - # Get origin and destination index of module/attachment - origin = self.original_element_index - destination = self.currentRow() + super().dropEvent(event) - # Update module/attachment priority (order in list): - if ModuleType(self.type) == ModuleType.MAIN_MODULE: - moving_module = self.parent.soi.modules.pop(origin) - self.parent.soi.modules.insert(destination, moving_module) - elif ModuleType(self.type) == ModuleType.ATTACHMENT_MODULE: - moving_module = self.parent.soi.attachments.pop(origin) - self.parent.soi.attachments.insert(destination, moving_module) + # Get origin and destination index of module/attachment + origin = self.original_element_index + destination = self.currentRow() + + # Update module/attachment priority (order in list): + if ModuleType(self.type) == ModuleType.MAIN_MODULE: + moving_module = self.parent.soi.modules.pop(origin) + self.parent.soi.modules.insert(destination, moving_module) + elif ModuleType(self.type) == ModuleType.ATTACHMENT_MODULE: + moving_module = self.parent.soi.attachments.pop(origin) + self.parent.soi.attachments.insert(destination, moving_module) - self.parent.soi.reorganize() + self.parent.soi.reorganize() - self.original_element_index = self.currentRow() + self.original_element_index = self.currentRow() -- GitLab