def data(self,
             index: PySide2.QtCore.QModelIndex,
             role: int = ...) -> typing.Any:
        if role == Qt.DisplayRole:

            if index.column() == 0:
                return index.row()
            else:
                fetcher = self.fetchers[index.column() - 1]
                media = self.playlist.media(
                    index.row())  # type: QtMultimedia.QMediaContent
                path = media.canonicalUrl().toString()
                record = MockDomain.GetByPath(path)
                if record is None:
                    # ruh uh
                    print("Failed to lookup path: ", path)
                return fetcher(record)
Пример #2
0
 def data(self,
          index: PySide2.QtCore.QModelIndex,
          role: int = ...) -> typing.Any:
     if role == Qt.DisplayRole:
         row, col = index.row(), index.column()
         ret = str(self.df.iloc[row, col])
     else:
         ret = None
     return ret
Пример #3
0
 def data(self, index: PySide2.QtCore.QModelIndex, role: int = ...) -> Any:
     if not index.isValid():
         return None
     row = index.row()
     col = index.column()
     if role == Qt.DisplayRole:
         return self._get_column_text(row, col)
     else:
         return None
Пример #4
0
 def data(self,
          index: PySide2.QtCore.QModelIndex,
          role: int = ...) -> typing.Any:
     if role == Qt.DisplayRole:
         record = ParentDir.query.limit(1).offset(
             index.row()).first()  # type: ParentDir
         if index.column() == 0:
             return record.id
         else:
             return record.path
Пример #5
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)
Пример #6
0
 def data(self, index:PySide2.QtCore.QModelIndex, role:int=...) -> Any:
     if not index.isValid():
         return None
     row = index.row()
     if row >= len(self.instance.traces):
         return None
     col = index.column()
     if role == Qt.DisplayRole:
         return self._get_column_text(self.instance.traces[row], col)
     else:
         return None
Пример #7
0
 def data(self, index: PySide2.QtCore.QModelIndex, role: int = ...) -> Any:
     if not index.isValid():
         return None
     row = index.row()
     reg = self._filtered_register_list()[row]
     col = index.column()
     if role == Qt.DisplayRole:
         return self._get_column_text(reg, col)
     elif role == Qt.ForegroundRole:
         return QBrush(Qt.red) if self._did_data_change(reg) else None
     else:
         return None
Пример #8
0
    def data(self,
             index: PySide2.QtCore.QModelIndex,
             role: int = ...) -> typing.Any:
        if not index.isValid():
            return None
        row = index.row()
        if row >= len(self.targets):
            return None
        target = self.targets[row]
        col = index.column()

        if role == Qt.DisplayRole:
            return self._get_column_text(target, col)

        return None
Пример #9
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)
Пример #10
0
    def data(self, index: PySide2.QtCore.QModelIndex, role: int = ...) -> Any:
        if not index.isValid():
            return None
        row = index.row()
        if row >= len(self.log):
            return None
        log = self.log[row]
        col = index.column()

        if role == Qt.DisplayRole:
            return self._get_column_text(log, col)
        elif role == Qt.DecorationRole and col == QLogTableModel.COL_ICON:
            return self._get_column_icon(log)

        return None
Пример #11
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)