def rowCount(self, parent: PySide2.QtCore.QModelIndex = ...):
        if not parent.isValid():
            parent_node = self.root
        else:
            parent_node = parent.internalPointer()

        return len(parent_node.children)
    def index(self, row: int, column: int, parent: PySide2.QtCore.QModelIndex = ...):
        if not parent.isValid():
            parent_node = self.root
        else:
            parent_node = parent.internalPointer()

        child_node = parent_node.children[row]
        return self.createIndex(row, column, child_node)
示例#3
0
 def rowCount(self, parent: PySide2.QtCore.QModelIndex = ...) -> int:
     if parent.column() > 0:
         return 0
     if not parent.isValid():
         parent_item = self.root_item
     else:
         parent_item = parent.internalPointer()
     return parent_item.children_count()
示例#4
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
示例#5
0
 def data(self,
          index: PySide2.QtCore.QModelIndex,
          role: int = ...) -> typing.Any:
     if index.isValid() is False:
         return None
     if role != Qt.DisplayRole:
         return None
     item = index.internalPointer()
     return item.data(index.column())
示例#6
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
    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)
示例#8
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
示例#9
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
示例#10
0
 def parent(
         self,
         child: PySide2.QtCore.QModelIndex = ...
 ) -> PySide2.QtCore.QModelIndex:
     if not child.isValid():
         return QModelIndex()
     child_item = child.internalPointer()
     parent_item = child_item.parent()
     if (parent_item == self.root_item):
         return QModelIndex()
     return self.createIndex(parent_item.row(), 0, parent_item)
    def data(self, index: PySide2.QtCore.QModelIndex, role: int = ...):
        if not index.isValid():
            return None

        node = index.internalPointer()
        if role == Qt.DisplayRole:
            if node.is_leaf:
                return "{}: {}".format(node.name, node.value)
            else:
                return "{} [{}]".format(node.name, node.class_name)

        return None
示例#12
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
示例#13
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)
    def data(self, index: PySide2.QtCore.QModelIndex, role: int = ...):
        if not index.isValid():
            return None

        node = index.internalPointer()
        if role == Qt.DisplayRole:
            column = index.column()
            if column == 0:
                return node.value.timestamp
            elif column == 1:
                return node.value.server
            elif column == 2:
                return node.value.source
            elif column == 3:
                return len(node.value.packets)
示例#15
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
示例#16
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
示例#17
0
    def index(self,
              row: int,
              column: int,
              parent: PySide2.QtCore.QModelIndex = ...
              ) -> PySide2.QtCore.QModelIndex:
        if not self.hasIndex(row, column, parent):
            return QModelIndex()
        if not parent.isValid():
            parent_item = self.root_item
        else:
            parent_item = parent.internalPointer()

        child_item = parent_item.child(row)
        if child_item:
            return self.createIndex(row, column, child_item)
        return QModelIndex()
    def data(self, index: PySide2.QtCore.QModelIndex, role: int = ...):
        if not index.isValid():
            return None

        node = index.internalPointer()
        if role == Qt.DisplayRole:
            column = index.column()
            if column == 0:
                return self.name_resolver.get(node,
                                              '../../../../../../server').value
            elif column == 1:
                return node.value.code
            elif column == 2:
                return self.name_resolver.get(node, './content').class_name
            elif column == 3:
                return self.name_resolver.get(node,
                                              './content/content').class_name
    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)
示例#20
0
    def setEditorData(self, editor: QWidget, index: PySide2.QtCore.QModelIndex):
        editor: PathBrowseWidget
        path = index.data(Qt.EditRole)
        editor.set_path(path)

        if not self._path_been_set:
            self._path_been_set = True
            if not path:
                editor.browse()
示例#21
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)
    def parent(self, index: PySide2.QtCore.QModelIndex):
        if not index.isValid:
            return QModelIndex()

        child_node = index.internalPointer()
        if not child_node:
            return QModelIndex()

        parent_node = child_node.parent
        if parent_node == self.root:
            return QModelIndex()

        row = parent_node.parent.children.index(parent_node)
        return self.createIndex(row, 0, parent_node)
    def rowCount(self, parent: PySide2.QtCore.QModelIndex = ...):
        if not parent.isValid():
            return len(self.root.children)

        return 0
    def rowCount(self, parent: PySide2.QtCore.QModelIndex = ...):
        if not parent.isValid():
            return len(self.message_list)

        return 0
示例#25
0
 def columnCount(self, parent: PySide2.QtCore.QModelIndex = ...) -> int:
     if parent.isValid():
         # print(parent.internalPointer().columnCount())
         return parent.internalPointer().columnCount()
     # print(self.root_item.column_count())
     return self.root_item.column_count()
示例#26
0
 def table_row_double_clicked(self, index: PySide2.QtCore.QModelIndex):
     ts_code = index.data(MainTableModel.PRIMARY_KEY_ROLE)
     print(ts_code)
     self.view_model.set_curr_selected_stock(ts_code)
示例#27
0
 def setEditorData(self, editor: QWidget,
                   index: PySide2.QtCore.QModelIndex):
     editor: ColorEditWidget
     color = index.data(Qt.DecorationRole)
     editor.set_color(color)
示例#28
0
 def flags(
         self,
         index: PySide2.QtCore.QModelIndex) -> PySide2.QtCore.Qt.ItemFlags:
     if not index.isValid():
         return Qt.NoItemFlags
     return QAbstractItemModel.flags(self, index)