forked from openlp/openlp
Added detection logic to wizard.
This commit is contained in:
parent
d85ede45b8
commit
3a9820528a
@ -38,7 +38,9 @@ from PyQt4 import QtCore, QtGui
|
|||||||
from openlp.core.lib import Receiver, Settings, SettingsManager, translate
|
from openlp.core.lib import Receiver, Settings, SettingsManager, translate
|
||||||
from openlp.core.lib.ui import UiStrings, critical_error_message_box
|
from openlp.core.lib.ui import UiStrings, critical_error_message_box
|
||||||
from openlp.core.ui.wizard import OpenLPWizard, WizardStrings
|
from openlp.core.ui.wizard import OpenLPWizard, WizardStrings
|
||||||
|
from openlp.plugins.songs.lib.db import Song
|
||||||
from openlp.plugins.songs.lib.importer import SongFormat, SongFormatSelect
|
from openlp.plugins.songs.lib.importer import SongFormat, SongFormatSelect
|
||||||
|
from openlp.plugins.songs.lib.duplicatesongfinder import DuplicateSongFinder
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -88,6 +90,7 @@ class DuplicateSongRemovalForm(OpenLPWizard):
|
|||||||
self.verticalLayout.setObjectName('verticalLayout')
|
self.verticalLayout.setObjectName('verticalLayout')
|
||||||
self.duplicateSearchProgressBar = QtGui.QProgressBar(self.searchingPage)
|
self.duplicateSearchProgressBar = QtGui.QProgressBar(self.searchingPage)
|
||||||
self.duplicateSearchProgressBar.setObjectName(u'duplicateSearchProgressBar')
|
self.duplicateSearchProgressBar.setObjectName(u'duplicateSearchProgressBar')
|
||||||
|
self.duplicateSearchProgressBar.setFormat(WizardStrings.PercentSymbolFormat)
|
||||||
self.verticalLayout.addWidget(self.duplicateSearchProgressBar)
|
self.verticalLayout.addWidget(self.duplicateSearchProgressBar)
|
||||||
self.foundDuplicatesEdit = QtGui.QPlainTextEdit(self.searchingPage)
|
self.foundDuplicatesEdit = QtGui.QPlainTextEdit(self.searchingPage)
|
||||||
self.foundDuplicatesEdit.setUndoRedoEnabled(False)
|
self.foundDuplicatesEdit.setUndoRedoEnabled(False)
|
||||||
@ -115,7 +118,20 @@ class DuplicateSongRemovalForm(OpenLPWizard):
|
|||||||
"""
|
"""
|
||||||
Called when changing to a page other than the progress page.
|
Called when changing to a page other than the progress page.
|
||||||
"""
|
"""
|
||||||
pass
|
if self.page(pageId) == self.searchingPage:
|
||||||
|
maxSongs = self.plugin.manager.get_object_count(Song)
|
||||||
|
if maxSongs == 0 or maxSongs == 1:
|
||||||
|
return
|
||||||
|
# with x songs we have x*(x-1)/2 comparisons
|
||||||
|
maxProgressCount = maxSongs*(maxSongs-1)/2
|
||||||
|
self.duplicateSearchProgressBar.setMaximum(maxProgressCount)
|
||||||
|
songs = self.plugin.manager.get_all_objects(Song)
|
||||||
|
for outerSongCounter in range(maxSongs-1):
|
||||||
|
for innerSongCounter in range(outerSongCounter+1, maxSongs):
|
||||||
|
doubleFinder = DuplicateSongFinder()
|
||||||
|
if doubleFinder.songsProbablyEqual(songs[outerSongCounter], songs[innerSongCounter]):
|
||||||
|
self.foundDuplicatesEdit.appendPlainText(songs[outerSongCounter].title + " = " + songs[innerSongCounter].title)
|
||||||
|
self.duplicateSearchProgressBar.setValue(self.duplicateSearchProgressBar.value()+1)
|
||||||
|
|
||||||
def onAddButtonClicked(self):
|
def onAddButtonClicked(self):
|
||||||
pass
|
pass
|
||||||
@ -128,6 +144,7 @@ class DuplicateSongRemovalForm(OpenLPWizard):
|
|||||||
Set default form values for the song import wizard.
|
Set default form values for the song import wizard.
|
||||||
"""
|
"""
|
||||||
self.restart()
|
self.restart()
|
||||||
|
self.duplicateSearchProgressBar.setValue(0)
|
||||||
self.foundDuplicatesEdit.clear()
|
self.foundDuplicatesEdit.clear()
|
||||||
|
|
||||||
def performWizard(self):
|
def performWizard(self):
|
||||||
|
@ -45,7 +45,6 @@ from openlp.plugins.songs.lib import clean_song, upgrade, SongMediaItem, \
|
|||||||
from openlp.plugins.songs.lib.db import init_schema, Song
|
from openlp.plugins.songs.lib.db import init_schema, Song
|
||||||
from openlp.plugins.songs.lib.importer import SongFormat
|
from openlp.plugins.songs.lib.importer import SongFormat
|
||||||
from openlp.plugins.songs.lib.olpimport import OpenLPSongImport
|
from openlp.plugins.songs.lib.olpimport import OpenLPSongImport
|
||||||
from openlp.plugins.songs.lib.duplicatesongfinder import DuplicateSongFinder
|
|
||||||
from openlp.plugins.songs.forms.duplicatesongremovalform import \
|
from openlp.plugins.songs.forms.duplicatesongremovalform import \
|
||||||
DuplicateSongRemovalForm
|
DuplicateSongRemovalForm
|
||||||
|
|
||||||
@ -172,20 +171,20 @@ class SongsPlugin(Plugin):
|
|||||||
"""
|
"""
|
||||||
Search for duplicates in the song database.
|
Search for duplicates in the song database.
|
||||||
"""
|
"""
|
||||||
maxSongs = self.manager.get_object_count(Song)
|
#maxSongs = self.manager.get_object_count(Song)
|
||||||
if maxSongs == 0:
|
#if maxSongs == 0:
|
||||||
return
|
# return
|
||||||
QtGui.QMessageBox.information(self.formParent,
|
#QtGui.QMessageBox.information(self.formParent,
|
||||||
"Find duplicates called", "Called...")
|
# "Find duplicates called", "Called...")
|
||||||
songs = self.manager.get_all_objects(Song)
|
#songs = self.manager.get_all_objects(Song)
|
||||||
for outerSongCounter in range(maxSongs-1):
|
#for outerSongCounter in range(maxSongs-1):
|
||||||
for innerSongCounter in range(outerSongCounter+1, maxSongs):
|
# for innerSongCounter in range(outerSongCounter+1, maxSongs):
|
||||||
doubleFinder = DuplicateSongFinder()
|
# doubleFinder = DuplicateSongFinder()
|
||||||
if doubleFinder.songsProbablyEqual(songs[outerSongCounter],
|
# if doubleFinder.songsProbablyEqual(songs[outerSongCounter],
|
||||||
songs[innerSongCounter]):
|
# songs[innerSongCounter]):
|
||||||
QtGui.QMessageBox.information(self.formParent,
|
# QtGui.QMessageBox.information(self.formParent,
|
||||||
"Double found", str(innerSongCounter) + " " +
|
# "Double found", str(innerSongCounter) + " " +
|
||||||
str(outerSongCounter))
|
# str(outerSongCounter))
|
||||||
if not hasattr(self, u'duplicate_removal_wizard'):
|
if not hasattr(self, u'duplicate_removal_wizard'):
|
||||||
self.duplicate_removal_wizard = \
|
self.duplicate_removal_wizard = \
|
||||||
DuplicateSongRemovalForm(self.formParent, self)
|
DuplicateSongRemovalForm(self.formParent, self)
|
||||||
|
Loading…
Reference in New Issue
Block a user