← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~oliwee/openlp/bug-1247025 into lp:openlp

 

Oliver Wieland has proposed merging lp:~oliwee/openlp/bug-1247025 into lp:openlp.

Requested reviews:
  Oliver Wieland (oliwee)
  Tim Bentley (trb143)
Related bugs:
  Bug #1247025 in OpenLP: "Wrong position when drag and drop an item in the service list"
  https://bugs.launchpad.net/openlp/+bug/1247025

For more details, see:
https://code.launchpad.net/~oliwee/openlp/bug-1247025/+merge/193592

Fixes bug #1247025
Changes the position where a new item will be inserted in the service list via drag'n'drop

Example: service list
A
B
C

item D will be dropped on B's position:
A
B D
C

Before:
A
B
D
C

After:
A
D
B
C
-- 
https://code.launchpad.net/~oliwee/openlp/bug-1247025/+merge/193592
Your team OpenLP Core is subscribed to branch lp:openlp.
=== modified file 'openlp/core/lib/mediamanageritem.py'
--- openlp/core/lib/mediamanageritem.py	2013-10-13 20:36:42 +0000
+++ openlp/core/lib/mediamanageritem.py	2013-11-01 12:59:50 +0000
@@ -545,8 +545,13 @@
                 self.add_to_service(replace=self.remote_triggered)
             else:
                 items = self.list_view.selectedIndexes()
+                _drop_position = self.service_manager.get_drop_position()
                 for item in items:
+                    self.service_manager.set_drop_position(_drop_position)
                     self.add_to_service(item)
+                    if _drop_position != -1:
+                        _drop_position += 1
+                    
 
     def add_to_service_remote(self, message):
         """

=== modified file 'openlp/core/ui/servicemanager.py'
--- openlp/core/ui/servicemanager.py	2013-10-13 21:07:28 +0000
+++ openlp/core/ui/servicemanager.py	2013-11-01 12:59:50 +0000
@@ -299,7 +299,7 @@
         Registry().register('service_manager', self)
         self.service_items = []
         self.suffixes = []
-        self.drop_position = 0
+        self.drop_position = -1
         self.service_id = 0
         # is a new service and has not been saved
         self._modified = False
@@ -1274,7 +1274,7 @@
                 self.live_controller.replace_service_manager_item(newItem)
                 self.set_modified()
 
-    def add_service_item(self, item, rebuild=False, expand=None, replace=False, repaint=True, selected=False):
+    def add_service_item(self, item, rebuild=False, expand=None, replace=False, repaint=True, selected=False, position=-1):
         """
         Add a Service item to the list
 
@@ -1297,7 +1297,7 @@
         else:
             item.render()
             # nothing selected for dnd
-            if self.drop_position == 0:
+            if self.drop_position == -1:
                 if isinstance(item, list):
                     for inditem in item:
                         self.service_items.append({'service_item': inditem,
@@ -1317,7 +1317,7 @@
             # if rebuilding list make sure live is fixed.
             if rebuild:
                 self.live_controller.replace_service_manager_item(item)
-        self.drop_position = 0
+        self.drop_position = -1
         self.set_modified()
 
     def make_preview(self):
@@ -1480,7 +1480,7 @@
                             item.setSelected(True)
                             replace = True
                     else:
-                        self.drop_position = self._get_parent_item_data(item)
+                        self.drop_position = self._get_parent_item_data(item) - 1
                 Registry().execute('%s_add_service_item' % plugin, replace)
 
     def update_theme_list(self, theme_list):
@@ -1602,4 +1602,18 @@
                 self._application = Registry().get('application')
             return self._application
 
+    def get_drop_position(self):
+        """
+        Getter for drop_position
+        Used in: MediaManagerItem
+        """
+        return self.drop_position
+        
+    def set_drop_position(self,  drop_position):
+        """
+        Setter for drop_position
+        Used in: MediaManagerItem
+        """
+        self.drop_position = drop_position
+        
     application = property(_get_application)


Follow ups