예제 #1
0
    def _sort_items(self, model, itera, iterb, data):
        """
            Sort model
        """
        if not self._updating:
            return False

        a_index = model.get_value(itera, 0)
        b_index = model.get_value(iterb, 0)

        # Static vs static
        if a_index < 0 and b_index < 0:
            return a_index < b_index
        # Static entries always on top
        elif b_index < 0:
            return True
        # Static entries always on top
        if a_index < 0:
            return False
        # String comparaison for non static
        else:
            if self._is_artists:
                a = Lp().artists.get_sortname(a_index)
                b = Lp().artists.get_sortname(b_index)
            else:
                a = model.get_value(itera, 1)
                b = model.get_value(iterb, 1)
            return a.lower() > b.lower()
예제 #2
0
    def _sort_items(self, model, itera, iterb, data):
        """
            Sort model
        """
        if not self._updating:
            return False

        a_index = model.get_value(itera, 0)
        b_index = model.get_value(iterb, 0)

        # Static vs static
        if a_index < 0 and b_index < 0:
            return a_index < b_index
        # Static entries always on top
        elif b_index < 0:
            return True
        # Static entries always on top
        if a_index < 0:
            return False
        # String comparaison for non static
        else:
            if self._is_artists:
                a = Lp().artists.get_sortname(a_index)
                b = Lp().artists.get_sortname(b_index)
            else:
                a = model.get_value(itera, 1)
                b = model.get_value(iterb, 1)
            return a.lower() > b.lower()
예제 #3
0
 def exists_in_db(self):
     """
         Search if item exists in db
         @return bool
     """
     artist_ids = []
     for artist in self.artists:
         artist_id = Lp().artists.get_id(artist)
         artist_ids.append(artist_id)
     if self.is_track:
         for track_id in Lp().tracks.get_ids_for_name(self.name):
             db_artist_ids = Lp().tracks.get_artist_ids(track_id)
             union = list(set(artist_ids) & set(db_artist_ids))
             if union == db_artist_ids:
                 return True
     else:
         album_ids = Lp().albums.get_ids(artist_ids, [])
         album_ids += Lp().albums.get_ids(artist_ids, [Type.CHARTS])
         for album_id in album_ids:
             album_name = Lp().albums.get_name(album_id)
             if album_name.lower() == self.album_name.lower():
                 return True
     return False