示例#1
0
    def extractMovieTreeAsList(self, treeIter):
        """
        Extract the movie data from the movieTreeStore in the form of a list.

        Recursively construct a list of the movies and series in the rows and
        child rows of the store.
        The base treeIter should point to the tree root, i.e.,
        movieTreeStore.get_iter_first().
        The list is sorted by title before returning.
        """

        list = []
        while treeIter:
            if self.movieList.movieTreeStore[treeIter][-1]:
                seriesList = []
                if self.movieList.movieTreeStore.iter_has_child(treeIter):
                    childIter = \
                        self.movieList.movieTreeStore.iter_children(treeIter)
                    seriesList.extend(self.extractMovieTreeAsList(childIter))
                    list.append(
                        MovieSeries.fromList(
                            self.movieList.movieTreeStore[treeIter],
                            seriesList))
            else:
                list.append(
                    Movie.fromList(self.movieList.movieTreeStore[treeIter]))

            treeIter = self.movieList.movieTreeStore.iter_next(treeIter)

        return sorted(list, key=lambda item: item.title)
示例#2
0
    def on_copyAction_activate(self, widget):
        """
        Handler for the movie copy action. Add a duplicate movie entity to the
        list.
        """

        # the status bar context
        contextId = self.statusbar.get_context_id(COPY)

        # select the movie/series to change
        treeIndex, movieEntity = self.getMovieOrSeriesFromSelection(contextId,
                                                                    COPY)
        if not movieEntity:
            return
        seriesIndex = None
        copiedMovieEntity = copiedSeriesIndex = None

        if isinstance(movieEntity, MovieSeries):
            copiedMovieEntity = MovieSeries.fromList(movieEntity.toList(), [])
        else:
            copiedSeriesIndex = self.findParentMovieSeries(treeIndex)
            copiedMovieEntity = Movie.fromList(movieEntity.toList())

        # update the model and display
        self.addMovieEntity(contextId, COPY, Gtk.ResponseType.OK,
                            None,
                            None, None,
                            copiedMovieEntity, copiedSeriesIndex)
示例#3
0
    def extractMovieTreeAsList(self, treeIter):
        """
        Extract the movie data from the movieTreeStore in the form of a list.

        Recursively construct a list of the movies and series in the rows and
        child rows of the store.
        The base treeIter should point to the tree root, i.e.,
        movieTreeStore.get_iter_first().
        The list is sorted by title before returning.
        """

        list = []
        while treeIter:
            if self.movieList.movieTreeStore[treeIter][-1]:
                seriesList = []
                if self.movieList.movieTreeStore.iter_has_child(treeIter):
                    childIter = \
                        self.movieList.movieTreeStore.iter_children(treeIter)
                    seriesList.extend(self.extractMovieTreeAsList(childIter))
                    list.append(
    MovieSeries.fromList(self.movieList.movieTreeStore[treeIter], seriesList))
            else:
                list.append(
    Movie.fromList(self.movieList.movieTreeStore[treeIter]))

            treeIter = self.movieList.movieTreeStore.iter_next(treeIter)

        return sorted(list, key=lambda item:item.title)
示例#4
0
    def getMovieOrSeriesFromSelection(self, contextId, context):
        """
        Obtain a movie or series from the currently-selected treeView row.
        """

        # get the current movie selection
        parentModel, parentIter = self.movieTreeSelection.get_selected()

        treeModel = self.movieTreeStore
        treeIndex = getChildModelSelection(parentModel, parentIter)
        if treeIndex is None:
            self.displaySelectMovieErrorMessage(contextId, context)
            return None, None
        if treeModel[treeIndex][-1]:
            childIter = treeModel.iter_children(treeIndex)
            seriesList = self.movieListIO.extractMovieTreeAsList(childIter)
            return treeIndex, MovieSeries.fromList(treeModel[treeIndex],
                                                   seriesList)
        else:
            return treeIndex, Movie.fromList(treeModel[treeIndex])