2016-05-29 20:52:07 +00:00
|
|
|
# Copyright 2016 Hardcoded Software (http://www.hardcoded.net)
|
2014-10-13 19:08:59 +00:00
|
|
|
#
|
2015-01-03 21:33:16 +00:00
|
|
|
# This software is licensed under the "GPLv3" License as described in the "LICENSE" file,
|
2014-10-13 19:08:59 +00:00
|
|
|
# which should be included with this package. The terms are also available at
|
2015-01-03 21:33:16 +00:00
|
|
|
# http://www.gnu.org/licenses/gpl-3.0.html
|
2009-06-01 09:55:11 +00:00
|
|
|
|
2011-09-20 22:40:27 +00:00
|
|
|
from core_se import __appname__
|
|
|
|
from core_se.app import DupeGuru as DupeGuruModel
|
2011-04-12 11:22:29 +00:00
|
|
|
from core.directories import Directories as DirectoriesBase, DirectoryState
|
2016-05-30 02:37:38 +00:00
|
|
|
from core.app import AppMode
|
2016-05-31 02:27:59 +00:00
|
|
|
import core_pe.photo
|
2009-06-01 09:55:11 +00:00
|
|
|
|
2010-10-04 13:29:00 +00:00
|
|
|
from ..base.app import DupeGuru as DupeGuruBase
|
2016-05-30 02:37:38 +00:00
|
|
|
from .details_dialog import DetailsDialog as DetailsDialogStandard
|
|
|
|
from ..me.details_dialog import DetailsDialog as DetailsDialogMusic
|
2016-05-31 02:27:59 +00:00
|
|
|
from ..pe.details_dialog import DetailsDialog as DetailsDialogPicture
|
2016-05-30 02:37:38 +00:00
|
|
|
from .results_model import ResultsModel as ResultsModelStandard
|
|
|
|
from ..me.results_model import ResultsModel as ResultsModelMusic
|
2016-05-31 02:27:59 +00:00
|
|
|
from ..pe.results_model import ResultsModel as ResultsModelPicture
|
2010-10-04 13:29:00 +00:00
|
|
|
from .preferences import Preferences
|
2016-05-30 02:37:38 +00:00
|
|
|
from .preferences_dialog import PreferencesDialog as PreferencesDialogStandard
|
|
|
|
from ..me.preferences_dialog import PreferencesDialog as PreferencesDialogMusic
|
2016-05-31 02:27:59 +00:00
|
|
|
from ..pe.preferences_dialog import PreferencesDialog as PreferencesDialogPicture
|
|
|
|
from ..pe.photo import File as PlatSpecificPhoto
|
2009-06-01 09:55:11 +00:00
|
|
|
|
2009-06-10 09:46:24 +00:00
|
|
|
class Directories(DirectoriesBase):
|
|
|
|
ROOT_PATH_TO_EXCLUDE = frozenset(['windows', 'program files'])
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2009-06-10 09:46:24 +00:00
|
|
|
def _default_state_for_path(self, path):
|
|
|
|
result = DirectoriesBase._default_state_for_path(self, path)
|
|
|
|
if result is not None:
|
|
|
|
return result
|
|
|
|
if len(path) == 2 and path[1].lower() in self.ROOT_PATH_TO_EXCLUDE:
|
2011-04-12 11:22:29 +00:00
|
|
|
return DirectoryState.Excluded
|
2009-06-10 09:46:24 +00:00
|
|
|
|
2009-06-01 09:55:11 +00:00
|
|
|
class DupeGuru(DupeGuruBase):
|
2011-09-20 22:40:27 +00:00
|
|
|
MODELCLASS = DupeGuruModel
|
2010-04-07 16:04:58 +00:00
|
|
|
EDITION = 'se'
|
2009-06-01 09:55:11 +00:00
|
|
|
LOGO_NAME = 'logo_se'
|
2011-01-21 12:57:54 +00:00
|
|
|
NAME = __appname__
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2011-11-28 15:27:17 +00:00
|
|
|
PREFERENCES_CLASS = Preferences
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2009-06-10 09:46:24 +00:00
|
|
|
def _setup(self):
|
|
|
|
self.directories = Directories()
|
|
|
|
DupeGuruBase._setup(self)
|
2016-05-31 02:27:59 +00:00
|
|
|
core_pe.photo.PLAT_SPECIFIC_PHOTO_CLASS = PlatSpecificPhoto
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2009-06-01 09:55:11 +00:00
|
|
|
def _update_options(self):
|
|
|
|
DupeGuruBase._update_options(self)
|
2016-05-29 20:52:07 +00:00
|
|
|
self.model.options['min_match_percentage'] = self.prefs.filter_hardness
|
|
|
|
self.model.options['word_weighting'] = self.prefs.word_weighting
|
|
|
|
self.model.options['match_similar_words'] = self.prefs.match_similar
|
2009-06-01 09:55:11 +00:00
|
|
|
threshold = self.prefs.small_file_threshold if self.prefs.ignore_small_files else 0
|
2016-05-29 20:52:07 +00:00
|
|
|
self.model.options['size_threshold'] = threshold * 1024 # threshold is in KB. the scanner wants bytes
|
2016-05-30 02:37:38 +00:00
|
|
|
scanned_tags = set()
|
|
|
|
if self.prefs.scan_tag_track:
|
|
|
|
scanned_tags.add('track')
|
|
|
|
if self.prefs.scan_tag_artist:
|
|
|
|
scanned_tags.add('artist')
|
|
|
|
if self.prefs.scan_tag_album:
|
|
|
|
scanned_tags.add('album')
|
|
|
|
if self.prefs.scan_tag_title:
|
|
|
|
scanned_tags.add('title')
|
|
|
|
if self.prefs.scan_tag_genre:
|
|
|
|
scanned_tags.add('genre')
|
|
|
|
if self.prefs.scan_tag_year:
|
|
|
|
scanned_tags.add('year')
|
|
|
|
self.model.options['scanned_tags'] = scanned_tags
|
2016-05-31 02:27:59 +00:00
|
|
|
self.model.options['match_scaled'] = self.prefs.match_scaled
|
2016-05-30 02:37:38 +00:00
|
|
|
|
|
|
|
@property
|
|
|
|
def DETAILS_DIALOG_CLASS(self):
|
2016-05-31 02:27:59 +00:00
|
|
|
if self.model.app_mode == AppMode.Picture:
|
|
|
|
return DetailsDialogPicture
|
|
|
|
elif self.model.app_mode == AppMode.Music:
|
2016-05-30 02:37:38 +00:00
|
|
|
return DetailsDialogMusic
|
|
|
|
else:
|
|
|
|
return DetailsDialogStandard
|
|
|
|
|
|
|
|
@property
|
|
|
|
def RESULT_MODEL_CLASS(self):
|
2016-05-31 02:27:59 +00:00
|
|
|
if self.model.app_mode == AppMode.Picture:
|
|
|
|
return ResultsModelPicture
|
|
|
|
elif self.model.app_mode == AppMode.Music:
|
2016-05-30 02:37:38 +00:00
|
|
|
return ResultsModelMusic
|
|
|
|
else:
|
|
|
|
return ResultsModelStandard
|
|
|
|
|
|
|
|
@property
|
|
|
|
def PREFERENCES_DIALOG_CLASS(self):
|
2016-05-31 02:27:59 +00:00
|
|
|
if self.model.app_mode == AppMode.Picture:
|
|
|
|
return PreferencesDialogPicture
|
|
|
|
elif self.model.app_mode == AppMode.Music:
|
2016-05-30 02:37:38 +00:00
|
|
|
return PreferencesDialogMusic
|
|
|
|
else:
|
|
|
|
return PreferencesDialogStandard
|
2014-10-13 19:08:59 +00:00
|
|
|
|