コード例 #1
0
    def album_row_clicked(self, index: PySide2.QtCore.QModelIndex):
        data = []
        record = index.model().fetch_row(index.row())
        album_id = record['id']

        for song in ArtistAlbum.query.filter(
                ArtistAlbum.id == album_id).first().songs:
            data.append(self._generate_song_row(song))

        self.song_model.updateData(data)
コード例 #2
0
    def artist_row_clicked(self, index: PySide2.QtCore.QModelIndex):
        data = []
        songs = []
        record = index.model().fetch_row(index.row())

        artist = Artist.query.filter(Artist.id == record['id']).first()

        for album in artist.albums:
            count = len(album.songs)
            for song in album.songs:
                songs.append(self._generate_song_row(song))
            data.append({'id': album.id, 'name': album.name, 'count': count})

        self.album_model.updateData(data)
        self.song_model.updateData(songs)
コード例 #3
0
    def artist_row_clicked(self, index: PySide2.QtCore.QModelIndex):
        data = []
        record = index.model().fetch_row(index.row())
        cursor = self.conn.cursor()

        cursor.execute("SELECT * FROM ArtistAlbum where artist_id = ?",
                       [record['id']])
        albums = cursor.fetchall()

        for album in albums:
            cursor.execute(
                "SELECT count() as 'count' FROM Song WHERE album_id=?",
                [album['id']])
            count = cursor.fetchone()['count']
            data.append({
                'id': album['id'],
                'name': album['name'],
                'count': count
            })

        self.album_model.updateData(data)