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

Proposed by Oliver Wieland
Status: Rejected
Rejected by: Tim Bentley
Proposed branch: lp:~oliwee/openlp/bug-1247025
Merge into: lp:openlp
Diff against target: 85 lines (+24/-5)
2 files modified
openlp/core/lib/mediamanageritem.py (+5/-0)
openlp/core/ui/servicemanager.py (+19/-5)
To merge this branch: bzr merge lp:~oliwee/openlp/bug-1247025
Reviewer Review Type Date Requested Status
Raoul Snyman Needs Information
Tim Bentley Pending
Oliver Wieland Pending
Review via email: mp+193592@code.launchpad.net

This proposal supersedes a proposal from 2013-11-01.

Description of the change

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

To post a comment you must log in.
Revision history for this message
Oliver Wieland (oliwee) wrote : Posted in a previous version of this proposal

This merge proposal works on all positions in the service list, but not on position '0'. This is because in servicemananager.py. line 1300, the position 0 will be handled in a special way.
But I have no idea when this case would be true (without my changes). Could somebody please explain if this case becomes true at all?

review: Needs Information
Revision history for this message
Jonathan Corwin (j-corwin) wrote : Posted in a previous version of this proposal

This behaviour has been bugging me forever, glad someone has been brave enough to dive in! :)

Have you tried out all the various scenarios such as when adding multiple images as a group, dropping in an image group and either side of it, ensuring things are OK when expanded, etc?

Revision history for this message
Oliver Wieland (oliwee) wrote : Posted in a previous version of this proposal

> Have you tried out all the various scenarios such as when adding multiple
> images as a group, dropping in an image group and either side of it, ensuring
> things are OK when expanded, etc?
Not yet. First step for me is to make it working with one item. Multiple selections will not work yet. The other things will come later on...

Revision history for this message
Oliver Wieland (oliwee) wrote : Posted in a previous version of this proposal

By the way, inserting multiple selections via drag'n'drop does not work on trunk either...

Revision history for this message
Oliver Wieland (oliwee) wrote : Posted in a previous version of this proposal

Inserting of multiple selection works now, even on position 0

Revision history for this message
Tim Bentley (trb143) wrote : Posted in a previous version of this proposal

Sorry while this fixes it I am not happy with mediamanageritem updating service manager fields directly.
Pass the value as optional in add_to_service please.

review: Needs Fixing
Revision history for this message
Oliver Wieland (oliwee) wrote :

By testing this code, I remarked a strange behaviour on multiselecting songs:

In the media manager, there are following songs:
A
B
C
D
E
F
G
H

When selecting the songs A to D and add them to the service list via the context menu , the order in the service list is
A
B
C
D

When selecting the songs E to H and add them to the service list in the same matter, I get the order
H
E
F
G

This behaviour confuses me...

Revision history for this message
Raoul Snyman (raoul-snyman) wrote :

Are you going to look into this further?

review: Needs Information
Revision history for this message
Oliver Wieland (oliwee) wrote :

> Are you going to look into this further?
This behaviour seems to be independent of my code, so I will create a New bug report E
when I'm at home again.

Revision history for this message
Samuel Mehrbrodt (sam92) wrote :

@Oliver: Are you going to continue work on this?
Else I can take it over. Just let me know.

Revision history for this message
Tim Bentley (trb143) wrote :

Too old and out of date.
If this is still a problem please fix and resubmit.

Unmerged revisions

2314. By Oliver Wieland

Make adding items to service list via context menu work again
Added setter / getter for drop_position to class ServiceManager

2313. By Oliver Wieland

fix insertion on position '0'

2312. By Oliver Wieland

fix inserting multiple selection into service list via drag'n'drop

2311. By Oliver Wieland

correction of setting position

2310. By Oliver Wieland

changed insert position for inserting an item to the service list via drag'n'drop

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'openlp/core/lib/mediamanageritem.py'
2--- openlp/core/lib/mediamanageritem.py 2013-10-13 20:36:42 +0000
3+++ openlp/core/lib/mediamanageritem.py 2013-11-01 12:59:50 +0000
4@@ -545,8 +545,13 @@
5 self.add_to_service(replace=self.remote_triggered)
6 else:
7 items = self.list_view.selectedIndexes()
8+ _drop_position = self.service_manager.get_drop_position()
9 for item in items:
10+ self.service_manager.set_drop_position(_drop_position)
11 self.add_to_service(item)
12+ if _drop_position != -1:
13+ _drop_position += 1
14+
15
16 def add_to_service_remote(self, message):
17 """
18
19=== modified file 'openlp/core/ui/servicemanager.py'
20--- openlp/core/ui/servicemanager.py 2013-10-13 21:07:28 +0000
21+++ openlp/core/ui/servicemanager.py 2013-11-01 12:59:50 +0000
22@@ -299,7 +299,7 @@
23 Registry().register('service_manager', self)
24 self.service_items = []
25 self.suffixes = []
26- self.drop_position = 0
27+ self.drop_position = -1
28 self.service_id = 0
29 # is a new service and has not been saved
30 self._modified = False
31@@ -1274,7 +1274,7 @@
32 self.live_controller.replace_service_manager_item(newItem)
33 self.set_modified()
34
35- def add_service_item(self, item, rebuild=False, expand=None, replace=False, repaint=True, selected=False):
36+ def add_service_item(self, item, rebuild=False, expand=None, replace=False, repaint=True, selected=False, position=-1):
37 """
38 Add a Service item to the list
39
40@@ -1297,7 +1297,7 @@
41 else:
42 item.render()
43 # nothing selected for dnd
44- if self.drop_position == 0:
45+ if self.drop_position == -1:
46 if isinstance(item, list):
47 for inditem in item:
48 self.service_items.append({'service_item': inditem,
49@@ -1317,7 +1317,7 @@
50 # if rebuilding list make sure live is fixed.
51 if rebuild:
52 self.live_controller.replace_service_manager_item(item)
53- self.drop_position = 0
54+ self.drop_position = -1
55 self.set_modified()
56
57 def make_preview(self):
58@@ -1480,7 +1480,7 @@
59 item.setSelected(True)
60 replace = True
61 else:
62- self.drop_position = self._get_parent_item_data(item)
63+ self.drop_position = self._get_parent_item_data(item) - 1
64 Registry().execute('%s_add_service_item' % plugin, replace)
65
66 def update_theme_list(self, theme_list):
67@@ -1602,4 +1602,18 @@
68 self._application = Registry().get('application')
69 return self._application
70
71+ def get_drop_position(self):
72+ """
73+ Getter for drop_position
74+ Used in: MediaManagerItem
75+ """
76+ return self.drop_position
77+
78+ def set_drop_position(self, drop_position):
79+ """
80+ Setter for drop_position
81+ Used in: MediaManagerItem
82+ """
83+ self.drop_position = drop_position
84+
85 application = property(_get_application)