← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~trb143/openlp/fbeta3 into lp:openlp

 

Tim Bentley has proposed merging lp:~trb143/openlp/fbeta3 into lp:openlp.

Requested reviews:
  OpenLP Core (openlp-core)
Related bugs:
  Bug #763583 in OpenLP: "Songs should be able to be Cloned"
  https://bugs.launchpad.net/openlp/+bug/763583

For more details, see:
https://code.launchpad.net/~trb143/openlp/fbeta3/+merge/66638

Add ability to clone a song with a full copy of it.
-- 
https://code.launchpad.net/~trb143/openlp/fbeta3/+merge/66638
Your team OpenLP Core is requested to review the proposed merge of lp:~trb143/openlp/fbeta3 into lp:openlp.
=== modified file 'openlp/core/lib/mediamanageritem.py'
--- openlp/core/lib/mediamanageritem.py	2011-06-12 16:02:52 +0000
+++ openlp/core/lib/mediamanageritem.py	2011-07-01 17:02:37 +0000
@@ -288,6 +288,7 @@
                 self.listView, u':/general/general_add.png',
                 translate('OpenLP.MediaManagerItem',
                 '&Add to selected Service Item'), self.onAddEditClick)
+        self.addCustomContextActions()
         # Create the context menu and add all actions from the listView.
         self.menu = QtGui.QMenu()
         self.menu.addActions(self.listView.actions())
@@ -301,6 +302,13 @@
             QtCore.SIGNAL('customContextMenuRequested(QPoint)'),
             self.contextMenu)
 
+    def addCustomContextActions(self):
+        """
+        Implement this method in your descendent media manager item to
+        add any context menu items. This method is called automatically.
+        """
+        pass
+
     def initialise(self):
         """
         Implement this method in your descendent media manager item to

=== modified file 'openlp/plugins/songs/lib/mediaitem.py'
--- openlp/plugins/songs/lib/mediaitem.py	2011-06-29 06:53:15 +0000
+++ openlp/plugins/songs/lib/mediaitem.py	2011-07-01 17:02:37 +0000
@@ -35,7 +35,8 @@
 from openlp.core.lib import MediaManagerItem, Receiver, ItemCapabilities, \
     translate, check_item_selected, PluginStatus
 from openlp.core.lib.searchedit import SearchEdit
-from openlp.core.lib.ui import UiStrings
+from openlp.core.lib.ui import UiStrings, context_menu_action, \
+    context_menu_separator
 from openlp.plugins.songs.forms import EditSongForm, SongMaintenanceForm, \
     SongImportForm, SongExportForm
 from openlp.plugins.songs.lib import OpenLyrics, SongXML, VerseType, \
@@ -128,6 +129,13 @@
             QtCore.SIGNAL(u'searchTypeChanged(int)'),
             self.onSearchTextButtonClick)
 
+    def addCustomContextActions(self):
+        context_menu_separator(self.listView)
+        context_menu_action(
+            self.listView, u':/general/general_add.png',
+            translate('OpenLP.MediaManagerItem',
+            '&Clone.'), self.onCloneClick)
+
     def onFocus(self):
         self.searchTextEdit.setFocus()
 
@@ -366,6 +374,23 @@
                 self.plugin.manager.delete_object(Song, item_id)
             self.onSearchTextButtonClick()
 
+    def onCloneClick(self):
+        """
+        Clone a Song
+        """
+        log.debug(u'onCloneClick')
+        if check_item_selected(self.listView, UiStrings().SelectEdit):
+            self.editItem = self.listView.currentItem()
+            item_id = (self.editItem.data(QtCore.Qt.UserRole)).toInt()[0]
+            old_song = self.plugin.manager.get_object(Song, item_id)
+            song_xml = self.openLyrics.song_to_xml(old_song)
+            new_song_id = self.openLyrics.xml_to_song(song_xml)
+            new_song = self.plugin.manager.get_object(Song, new_song_id)
+            new_song.title = u'%s <%s>' % (new_song.title,
+                translate('SongsPlugin.MediaItem', 'copy'))
+            self.plugin.manager.save_object(new_song)
+        self.onSongListLoad()
+
     def generateSlideData(self, service_item, item=None, xmlVersion=False):
         log.debug(u'generateSlideData (%s:%s)' % (service_item, item))
         item_id = self._getIdOfItemToGenerate(item, self.remoteSong)