コード例 #1
0
ファイル: video_player.py プロジェクト: blacksong/wechat_pyui
 def rowCount(self, parent=QModelIndex()):
     return self.m_playlist.mediaCount() if self.m_playlist is not None and not parent.isValid() else 0
コード例 #2
0
 def insertItem(self, index, item):
     self.beginInsertRows(QModelIndex(), index, index)
     self._items.insert(index, item)
     self.endInsertRows()
     self.itemsChanged.emit()
コード例 #3
0
 def columnCount(self, parent=QModelIndex()):
     return self.TOTAL_FIELDS
コード例 #4
0
 def removeColumns(self, start, end, parent=QModelIndex()):
     self.beginRemoveColumns(parent, start, end - 1)
     del self.columns[start:end]
     self.endRemoveRows()
     return True
コード例 #5
0
 def columnCount(self, parent=QModelIndex()):
     return self.col_count
コード例 #6
0
    def index(self, row, column, parent=QModelIndex()):
        if parent.isValid():
            return QModelIndex()

        return self.createIndex(row, column)
コード例 #7
0
 def insertColumn(self, col_id, col, parent=QModelIndex()):
     self.beginInsertColumns(parent, col_id, col_id)
     self.columns.insert(col_id, col)
     self.endInsertColumns()
     return True
コード例 #8
0
 def rowCount(self, parent=QModelIndex()):
     """Get count of active downloads."""
     if parent.isValid():
         # We don't have children
         return 0
     return len(self)
コード例 #9
0
 def rowCount(self, parent=QModelIndex()):
     return len(self.artists)
コード例 #10
0
ファイル: util.py プロジェクト: bitcoinkatia/electrum-omni
 def set_current_idx(self, set_current: QPersistentModelIndex):
     if set_current:
         assert isinstance(set_current, QPersistentModelIndex)
         assert set_current.isValid()
         self.selectionModel().select(QModelIndex(set_current), QItemSelectionModel.SelectCurrent)
コード例 #11
0
 def parent(self, child: QModelIndex):
     return QModelIndex()
コード例 #12
0
ファイル: history_list.py プロジェクト: iveronanomi/electrum
    def create_menu(self, position: QPoint):
        org_idx: QModelIndex = self.indexAt(position)
        idx = self.proxy.mapToSource(org_idx)
        if not idx.isValid():
            # can happen e.g. before list is populated for the first time
            return
        tx_item = self.hm.transactions.value_from_pos(idx.row())
        column = idx.column()
        column_title = self.hm.headerData(column, Qt.Horizontal, Qt.DisplayRole)
        column_data = self.hm.data(idx, Qt.DisplayRole).value()
        if tx_item.get('lightning'):
            return
        tx_hash = tx_item['txid']
        tx = self.wallet.db.get_transaction(tx_hash)
        if not tx:
            return
        tx_URL = block_explorer_URL(self.config, 'tx', tx_hash)
        height = self.wallet.get_tx_height(tx_hash).height
        is_relevant, is_mine, v, fee = self.wallet.get_wallet_delta(tx)
        is_unconfirmed = height <= 0
        #pr_key = self.wallet.invoices.paid.get(tx_hash)
        menu = QMenu()
        if height in [TX_HEIGHT_FUTURE, TX_HEIGHT_LOCAL]:
            menu.addAction(_("Remove"), lambda: self.remove_local_tx(tx_hash))
        menu.addAction(_("Copy Transaction ID"), lambda: self.parent.app.clipboard().setText(tx_hash))

        amount_columns = [HistoryColumns.AMOUNT, HistoryColumns.BALANCE,
                          HistoryColumns.FIAT_VALUE, HistoryColumns.FIAT_ACQ_PRICE, HistoryColumns.FIAT_CAP_GAINS]
        if column in amount_columns:
            column_data = column_data.strip()
        menu.addAction(_("Copy {}").format(column_title), lambda: self.parent.app.clipboard().setText(column_data))
        for c in self.editable_columns:
            if self.isColumnHidden(c): continue
            label = self.hm.headerData(c, Qt.Horizontal, Qt.DisplayRole)
            # TODO use siblingAtColumn when min Qt version is >=5.11
            persistent = QPersistentModelIndex(org_idx.sibling(org_idx.row(), c))
            menu.addAction(_("Edit {}").format(label), lambda p=persistent: self.edit(QModelIndex(p)))
        menu.addAction(_("Details"), lambda: self.show_transaction(tx_hash))
        if is_unconfirmed and tx:
            # note: the current implementation of RBF *needs* the old tx fee
            rbf = is_mine and not tx.is_final() and fee is not None
            if rbf:
                menu.addAction(_("Increase fee"), lambda: self.parent.bump_fee_dialog(tx))
            else:
                child_tx = self.wallet.cpfp(tx, 0)
                if child_tx:
                    menu.addAction(_("Child pays for parent"), lambda: self.parent.cpfp(tx, child_tx))
        #if pr_key:
        #    menu.addAction(read_QIcon("seal"), _("View invoice"), lambda: self.parent.show_invoice(pr_key))
        if tx_URL:
            menu.addAction(_("View on block explorer"), lambda: webopen(tx_URL))
        menu.exec_(self.viewport().mapToGlobal(position))
コード例 #13
0
ファイル: video_player.py プロジェクト: blacksong/wechat_pyui
 def index(self, row, column, parent=QModelIndex()):
     return self.createIndex(row, column) if self.m_playlist is not None and not parent.isValid() and row >= 0 and row < self.m_playlist.mediaCount() and column >= 0 and column < self.ColumnCount else QModelIndex()
コード例 #14
0
ファイル: video_player.py プロジェクト: blacksong/wechat_pyui
 def columnCount(self, parent=QModelIndex()):
     return self.ColumnCount if not parent.isValid() else 0
コード例 #15
0
    def rowCount(self, parent=QModelIndex()):
        if parent.isValid():
            return 0

        return self._rowcount
コード例 #16
0
 def rowCount(self, _=QModelIndex()):
     return len(self._songs)
コード例 #17
0
 def columnCount(self, parent=QModelIndex()):
     return len(self.columns)
コード例 #18
0
    def table_clicked(self, index):
        index = QModelIndex(index)

        # ind.__setattr__('column',0)
        row, col = index.row(), index.column()
        ind = self.model.index(row, 2)
        image = list(self.model.itemData(QModelIndex(ind)).values())[0]

        ind = self.model.index(row, 3)
        xyMax = list(self.model.itemData(QModelIndex(ind)).values())[0]
        xyMax = xyMax.replace('[', '').replace(']', '').split()
        xyMax = [int(float(i)) for i in xyMax]
        xyMax = [tuple(xyMax[i + 0:2 + i]) for i in range(0, len(xyMax), 2)]

        ind = self.model.index(row, 4)
        xyMin = list(self.model.itemData(QModelIndex(ind)).values())[0]
        xyMin = xyMin.replace('[', '').replace(']', '').split()
        xyMin = [int(float(i)) for i in xyMin]
        xyMin = [tuple(xyMin[i + 0:2 + i]) for i in range(0, len(xyMin), 2)]

        ind = self.model.index(row, 7)
        center = list(self.model.itemData(QModelIndex(ind)).values())[0]
        center = center.replace('[', '').replace(']', '').split()
        center = [int(float(i)) for i in center]
        center = [tuple(center[i + 0:2 + i]) for i in range(0, len(center), 2)]
        print(center)

        classes = self.cfg['category'].split(',')
        ind = self.model.index(row, 0)
        label = list(self.model.itemData(QModelIndex(ind)).values())[0]
        label = label.replace('[', '').replace(']', '').split()

        # xyMin=ast.literal_eval(xyMin.replace(' ', ','))

        classes = self.cfg['category'].split(',')

        name = str(image.split('\\')[-1])
        image = cv2.imread(image)

        objs = []

        for i in range(len(xyMax)):
            y1, x1 = xyMin[i]
            y2, x2 = xyMax[i]
            #
            #
            print(i, 'value: ', x1, y1, x2, y2)
            #
            #
            start_point = (x1, y1)
            end_point = (x2, y2)
            color = (255, 0, 0)
            thickness = 2
            objs.append("{}-{}".format(i + 1, classes[int(label[i])]))
            cv2.putText(
                image, '{}-{}({})'.format(i + 1, classes[int(label[i])],
                                          label[i]), (x1, y1 - 10),
                cv2.FONT_HERSHEY_SIMPLEX, 0.3, (0, 0, 255), 1)
            image = cv2.rectangle(image, start_point, end_point, color,
                                  thickness)
            image = cv2.circle(image, (center[i][1], center[i][0]), 2,
                               (0, 0, 255), -1)

        util.Qlogging(
            self.ui.textBrowser,
            '{} has {} objects: \\n {}'.format(name, len(xyMax), objs), 'red')

        cv2.imshow(name, image)
        cv2.waitKey(4000)
        cv2.destroyAllWindows()
コード例 #19
0
 def parent(self, index):
     return QModelIndex()
コード例 #20
0
    def create_menu(self, position):
        from electrum_mona.wallet import Multisig_Wallet
        is_multisig = isinstance(self.wallet, Multisig_Wallet)
        can_delete = self.wallet.can_delete_address()
        selected = self.selected_in_column(self.Columns.ADDRESS)
        if not selected:
            return
        multi_select = len(selected) > 1
        addrs = [self.item_from_index(item).text() for item in selected]
        menu = QMenu()
        if not multi_select:
            idx = self.indexAt(position)
            if not idx.isValid():
                return
            item = self.item_from_index(idx)
            if not item:
                return
            addr = addrs[0]
            addr_column_title = self.std_model.horizontalHeaderItem(self.Columns.LABEL).text()
            addr_idx = idx.sibling(idx.row(), self.Columns.LABEL)
            self.add_copy_menu(menu, idx)
            menu.addAction(_('Details'), lambda: self.parent.show_address(addr))
            persistent = QPersistentModelIndex(addr_idx)
            menu.addAction(_("Edit {}").format(addr_column_title), lambda p=persistent: self.edit(QModelIndex(p)))
            #menu.addAction(_("Request payment"), lambda: self.parent.receive_at(addr))
            if self.wallet.can_export():
                menu.addAction(_("Private key"), lambda: self.parent.show_private_key(addr))
            if not is_multisig and not self.wallet.is_watching_only():
                menu.addAction(_("Sign/verify message"), lambda: self.parent.sign_verify_message(addr))
                menu.addAction(_("Encrypt/decrypt message"), lambda: self.parent.encrypt_message(addr))
            if can_delete:
                menu.addAction(_("Remove from wallet"), lambda: self.parent.remove_address(addr))
            addr_URL = block_explorer_URL(self.config, 'addr', addr)
            if addr_URL:
                menu.addAction(_("View on block explorer"), lambda: webopen(addr_URL))

            if not self.wallet.is_frozen_address(addr):
                menu.addAction(_("Freeze"), lambda: self.parent.set_frozen_state_of_addresses([addr], True))
            else:
                menu.addAction(_("Unfreeze"), lambda: self.parent.set_frozen_state_of_addresses([addr], False))

        coins = self.wallet.get_spendable_coins(addrs)
        if coins:
            menu.addAction(_("Spend from"), lambda: self.parent.utxo_list.set_spend_list(coins))

        run_hook('receive_menu', menu, addrs, self.wallet)
        menu.exec_(self.viewport().mapToGlobal(position))
コード例 #21
0
 def removeColumn(self, col_id, parent=QModelIndex()):
     self.beginRemoveColumns(parent, col_id, col_id)
     del self.columns[col_id]
     self.endRemoveRows()
     return True
コード例 #22
0
ファイル: app.py プロジェクト: DominikPott/todo
 def rowCount(self, parent=QModelIndex()):
     return len(self.notes)
コード例 #23
0
 def hasChildren(self, index=QModelIndex()):
     return not index.isValid()
コード例 #24
0
    def rowCount(self, parent=QModelIndex()):
        if not self.hasChildren(parent):
            return 0

        return len(self.getNode(parent).children)
コード例 #25
0
 def selectedIndex(self):
     """Returns the selected index in the treeView."""
     if self.mw.treeWorld.selectedIndexes():
         return self.mw.treeWorld.currentIndex()
     else:
         return QModelIndex()
コード例 #26
0
 def appendRow(self, row, parent=QModelIndex()):
     self.insertRow(self.rowCount(parent), row, parent)
コード例 #27
0
 def refresh_items(self):
     self.model.dataChanged.emit(QModelIndex(), QModelIndex())
コード例 #28
0
    def getNode(self, index=QModelIndex()):
        if index.isValid():
            return index.internalPointer() or self.root

        return self.root
コード例 #29
0
 def rowCount(self, parent=QModelIndex()):
     return len(self.masternodes)
コード例 #30
0
ファイル: video_player.py プロジェクト: blacksong/wechat_pyui
 def beginRemoveItems(self, start, end):
     self.beginRemoveRows(QModelIndex(), start, end)