コード例 #1
0
 def setSelectedEntry(self, entry):
     """Set the selected entry.
     """
     Logger.debug('MediaCollection.setSelectedEntry(%s)' % entry)
     previousSelection = self.selectedEntry
     self.selectedEntry = entry
     if (self.selectedEntry):  # store selected entry for next program run
         path = entry.getPath()
         path = path[len(Installer.getMediaPath()) + 1:]  # remove "/" as well
         self.setConfiguration(GlobalConfigurationOptions.LastMedia, path)
     if (previousSelection != self.selectedEntry):
         self.changedAspect('selection')
コード例 #2
0
 def setRootDirectory (self, rootDir, processIndicator):
     """Change the root directory to process a different image set.
     
     String rootDir
     PhasedProgressBar progressIndicator
     """
     processIndicator.beginPhase(3)
     self.rootDirectory = os.path.normpath(rootDir)
     # clear all data
     self.selectedEntry = None
     self.initialEntry = None
     CachingController.clear()
     # set up the configuration persistence
     #TODO: Must move to app to be available while mediacollection is created
     self.configuration = SecureConfigParser(Installer.getConfigurationFilePath())
     self.configuration.read(Installer.getConfigurationFilePath())
     if (not self.configuration.has_section(GUIId.AppTitle)):
         self.configuration.add_section(GUIId.AppTitle)
     #
     if (os.path.exists(Installer.getNamesFilePath())): 
         self.organizedByDate = False
         self.organizationStrategy = OrganizationByName
         filterClass = FilterByName
     else:
         self.organizedByDate = True
         self.organizationStrategy = OrganizationByDate
         filterClass = FilterByDate  
     self.organizationStrategy.setModel(self)
     processIndicator.beginStep(_('Reading tag definitions'))
     self.classHandler = MediaClassHandler(Installer.getClassFilePath())
     if (self.classHandler.isLegalElement(MediaCollection.ReorderTemporaryTag)):
         index = 1
         tag = ('%s%d' % (MediaCollection.ReorderTemporaryTag, index))
         while (self.classHandler.isLegalElement(tag)):
             index = (index + 1)
             tag = ('%s%d' % (tag, index))
         MediaCollection.ReorderTemporaryTag = tag
         Logger.warning('MediaCollection.setRootDirectory(): Temporary reordering tag changed to "%s"' % tag)
     # read groups and images
     self.root = Entry.createInstance(self, self.rootDirectory)
     self.loadSubentries(self.root, processIndicator)  # implicit progressIndicator.beginStep()
     processIndicator.beginStep(_('Calculating collection properties'))
     self.cacheCollectionProperties()
     self.filter = filterClass(self) 
     self.filter.addObserverForAspect(self, 'filterChanged')
     self.filteredEntries = self.getCollectionSize()
     # select initial entry
     if (os.path.exists(Installer.getInitialFilePath())):
         self.initialEntry = Entry.createInstance(self, Installer.getInitialFilePath())
     path = self.getConfiguration(GlobalConfigurationOptions.LastMedia)
     if (path):
         if (not os.path.isabs(path)):  # TODO: unconditional when relative path is stored for last media
             path = os.path.join(Installer.getMediaPath(), path)
         entry = self.getEntry(path=path)
         if (entry):
             Logger.info('MediaCollection.setRootDirectory(): selecting "%s" from last run.' % path)
             if (entry.isGroup() 
                 and (100 < len(entry.getSubEntries()))):
                 entry = entry.getSubEntries()[0]
                 Logger.info('MediaColleection.setRootDirectory(): Reselected "%s" because initial group contained more than 100 entries.' % entry)
             self.setSelectedEntry(entry)
         else:
             Logger.info('MediaCollection.setRootDirectory(): last viewed media "%s" does not exist.' % path)
             self.setSelectedEntry(self.root)
     else: 
         Logger.info('MediaCollection.setRootDirectory(): last viewed media not saved')
         self.setSelectedEntry(self.root)