コード例 #1
0
 def editorEvent(self, event, model, option, index):
     #paket seçim olayında hata var seçim olayı gerçekleşiyor ama packageList sonraki seçimde görüyor
     #geçici çözümle giderildi tamamen çözülmeli
     if event.type() == QEvent.MouseButtonRelease and index.column() == 0 and index.flags() & Qt.ItemIsUserCheckable:
         toggled = Qt.Checked if model.data(index, Qt.CheckStateRole) == QVariant(Qt.Unchecked) else Qt.Unchecked
         self.packageSelected.emit(bool(toggled))
         return model.setData(index, toggled, Qt.CheckStateRole)
     
     __event = QItemDelegate(self).editorEvent(event, model, option, index)
     
     animate_requested = False
     if event.type() == QEvent.MouseButtonRelease and self.animatable:
         if self.rowAnimator.row == index.row():
             epos = event.pos()
             if self.rowAnimator.hoverLinkFilter.link_rect.contains(QPoint(epos.x(), epos.y() + 32)):
                 url = QUrl(QVariant.value(model.data(index, HomepageRole)))
                 QDesktopServices.openUrl(url)
                 return __event
             elif self.rowAnimator.hoverLinkFilter.button_rect.contains(epos, True):
                 self.showPackageDetails(model, index)
                 return __event
         animate_requested = True
     elif event.type() == QEvent.KeyPress and self.animatable:
         # KeyCode 32 : Space key
         if event.key() == 32 and index.column() == index.model().columnCount() - 1:
             animate_requested = True
     if not QVariant.value(model.data(index, DescriptionRole)) == '' and animate_requested:
         self.rowAnimator.animate(index.row())
     return __event
コード例 #2
0
    def roleNames(self):
        """ Return a list of column heading titles.

        :return: list of str column headings
        """
        values = []
        for v in self.my_headings:
            # explicit cast is needed on Qt 5.5.0
            vv = QVariant(v)
            vv.convert(QVariant.ByteArray)
            values.append(vv.value())
        return dict(enumerate(values, 32))
コード例 #3
0
ファイル: SqlBrowserWidget.py プロジェクト: pycom/EricShort
 def showSchema(self, table):
     """
     Public slot to show the schema of a table.
     
     @param table name of the table to be shown (string)
     """
     rec = self.connections.currentDatabase().record(table)
     model = QStandardItemModel(self.table)
     
     model.insertRows(0, rec.count())
     model.insertColumns(0, 7)
     
     model.setHeaderData(0, Qt.Horizontal, "Fieldname")
     model.setHeaderData(1, Qt.Horizontal, "Type")
     model.setHeaderData(2, Qt.Horizontal, "Length")
     model.setHeaderData(3, Qt.Horizontal, "Precision")
     model.setHeaderData(4, Qt.Horizontal, "Required")
     model.setHeaderData(5, Qt.Horizontal, "Auto Value")
     model.setHeaderData(6, Qt.Horizontal, "Default Value")
     
     for i in range(rec.count()):
         fld = rec.field(i)
         model.setData(model.index(i, 0), fld.name())
         if fld.typeID() == -1:
             model.setData(model.index(i, 1),
                           QVariant.typeToName(fld.type()))
         else:
             model.setData(
                 model.index(i, 1), "{0} ({1})".format(
                     QVariant.typeToName(fld.type()), fld.typeID()))
         if fld.length() < 0:
             model.setData(model.index(i, 2), "?")
         else:
             model.setData(model.index(i, 2), fld.length())
         if fld.precision() < 0:
             model.setData(model.index(i, 3), "?")
         else:
             model.setData(model.index(i, 3), fld.precision())
         if fld.requiredStatus() == -1:
             model.setData(model.index(i, 4), "?")
         else:
             model.setData(model.index(i, 4), bool(fld.requiredStatus()))
         model.setData(model.index(i, 5), fld.isAutoValue())
         model.setData(model.index(i, 6), fld.defaultValue())
     
     self.table.setModel(model)
     self.table.setEditTriggers(QAbstractItemView.NoEditTriggers)
     
     self.table.resizeColumnsToContents()
     
     self.updateActions()
コード例 #4
0
    def setValue(self, property, val):
        if (self.propertyToData.contains(property)):
            if type(val)!=QVariant:
                val = QVariant(val)
            if (val.type() != QVariant.PointF and not val.canConvert(QVariant.PointF)):
                return
            p = val.value()
            d = self.propertyToData[property]
            d.value = QVariant(p)
            if (d.x):
                d.x.setValue(p.x())
            if (d.y):
                d.y.setValue(p.y())
            self.propertyToData[property] = d
            self.propertyChangedSignal.emit(property)
            self.valueChangedSignal.emit(property, p)
            return

        super(VariantManager, self).setValue(property, val)
コード例 #5
0
ファイル: __init__.py プロジェクト: PisiLinuxRepos/project
    def settings(self, key, default):
        value = None
        if self.session.ConfigType == 'ini':
            # FIXME we dont need to force everytime.
            if path.exists(str(self.config_file)):
                settings = self.parse(self.config_file, force = True)
            else:
                return default
            
            _value = settings.value(key)
            variant_value=QVariant(_value)
            if not variant_value.typeName()=='QString':
                # Sometimes kdeglobals stores values without quotes
                #_value = _value.toStringList()
                if _value:
                    value = _value.join(',')
            else:
                value = unicode(_value)
            if not value or value == '':
                logging.debug('Switching to default conf')
                alternateConfig = self.session.DefaultConfigPath or \
                        path.join(self.install_prefix, self.session.ConfigFile)
                settings = self.parse(alternateConfig, force = True)
                value = unicode(settings.value(key, default))

        elif self.session.ConfigType == 'xml':
            settings = self.parse(self.config_file, 'xml').getTag('property')
            def getval(settings, key):
                for tag in settings.tags():
                    if tag.getAttribute('name') == key:
                        return tag.getAttribute('value')
            value = getval(settings, key)
            if not value or value == '':
                alternateConfig = self.session.DefaultConfigPath or \
                        path.join(self.install_prefix, self.session.ConfigFile)
                settings = self.parse(alternateConfig, 'xml',
                        force = True).getTag('property')
                value = getval(settings, key)

        elif self.session.ConfigType == 'env':
            value = getenv(key)

        return value or default
コード例 #6
0
 def decodeMimeData(self, the_bytearray: QByteArray):
     """see:
     https://wiki.python.org/moin/PyQt/Handling%20Qt's%20internal%20item%20MIME%20type
     http://doc.qt.io/qt-5.5/datastreamformat.html
     """
     data = {}
     ds = QDataStream(the_bytearray)
     while not ds.atEnd():
         item = []
         row = ds.readInt32()
         column = ds.readInt32()
         number_of_items = ds.readInt32()
         # print("rc:", row, column, number_of_items)
         for i in range(number_of_items):
             key = ds.readInt32()
             value = QVariant()
             ds >> value
             item.append((value.value(), Qt.ItemDataRole(key)))
         data[(row, column)] = item
     return data
コード例 #7
0
    def showPackageDetails(self, model, index):

        def _getter(role):
            return model.data(index, role)

        name = _getter(NameRole)
        summary = _getter(SummaryRole)
        description = _getter(DescriptionRole)
        installed = True if str(QVariant.value(model.data(index, InstalledRole)))=="True" else False
        
        self.webDialog.showPackageDetails(name, installed, summary, description)
コード例 #8
0
    def notify(self, summary, body, actions=[]):
        varRPlaceId = QVariant(0)
        varRPlaceId.convert(QVariant.UInt)
        varActions = QVariant(actions)
        varActions.convert(QVariant.StringList)

        msg = self.call("Notify",
            "Deepin Screenshot",
            varRPlaceId,
            "deepin-screenshot",
            summary,
            body, varActions, {}, -1)
        reply = QDBusReply(msg)
        return reply.value()
コード例 #9
0
    def notify(self, summary, body):
        replaceId = QVariant(0)
        replaceId.convert(QVariant.UInt)
        actions = QVariant([])
        actions.convert(QVariant.StringList)

        msg = self.call(
            "Notify",
            "Deepin Movie",
            replaceId,
            "deepin-movie",
            summary, body,
            actions, {}, -1)

        reply = QDBusReply(msg)
        return reply.value if reply.isValid() else None
コード例 #10
0
ファイル: JPModel.py プロジェクト: golden7602/ProjectM
 def _getDecoration(self, Index: QModelIndex) -> QVariant():
     """返回 (QColor, QIcon or QPixmap)"""
     return QVariant()
コード例 #11
0
ファイル: table_model.py プロジェクト: jonnybach/cli_ui
 def headerData(self, sect, orient, role=None):
     if orient == Qt.Horizontal and role == Qt.DisplayRole:
         return QVariant(self._headers[sect])
     return QVariant()
コード例 #12
0
ファイル: dbus_interfaces.py プロジェクト: fpemud/DMovie
 def uninhibit(self, cookie=None):
     if self._inhibit_cookie:
         arg = QVariant(cookie or self._inhibit_cookie)
         arg.convert(QVariant.UInt)
         self.call('UnInhibit', arg)
コード例 #13
0
ファイル: result.py プロジェクト: jkennedy-usgs/sgp-gsadjust
 def setData(self, index, value, role):
     if role == Qt.UserRole:
         self._data = []
         return QVariant()
コード例 #14
0
def _as_uint32(x: int) -> QVariant:
    """Convert the given int to an uint32 for DBus."""
    variant = QVariant(x)
    assert variant.convert(QVariant.UInt)
    return variant
コード例 #15
0
 def data(self, index, role):
     if role == Qt.EditRole:
         return self.arraydata[index.row()][index.column()]
     if role == Qt.DisplayRole:
         return QVariant(self.arraydata[index.row()][index.column()])
     return QVariant()
コード例 #16
0
ファイル: treewidget.py プロジェクト: bsrnesraa/dxf2gcode-prj
    def data(self, column):
        if self.content != None and column == 0:
           return QVariant(self.content)

        return QVariant()
コード例 #17
0
 def runWithArguments(self, arguments):
     arguments = QVariant(arguments)
     arguments.convert(QVariant.StringList)
     self.call("RunWithArguments", arguments)
コード例 #18
0
    def data(self, index, role=Qt.DisplayRole):
        if not index.isValid():
            return QVariant()

        item = index.internalPointer()
        return item.data(index.column(), role)
コード例 #19
0
ファイル: q3dview.py プロジェクト: nsashi/Qgis2threejs
 def setData(self, data):
     self.data = QVariant(data)
コード例 #20
0
 def headerData(self, col, orientation, role):
     if orientation == Qt.Horizontal and role == Qt.DisplayRole:
         return QVariant(self.headerdata[col])
     if orientation != Qt.Horizontal and role == Qt.DisplayRole:
         return QVariant('')
     return QVariant()
コード例 #21
0
 def data(self, index, role):
     if not index.isValid():
         return QVariant()
     return self._items[index.row()][self._role_names[role].decode("utf-8")]
コード例 #22
0
    def data(self, index, role):
        row = index.row()
        col = index.column()

        if not index.isValid():
            return QVariant()

        source_data = self.transfers_data[row][col]
        state_data = self.transfers_data[row][
            HistoryTableModel.columns_types.index('state')]
        block_data = self.transfers_data[row][
            HistoryTableModel.columns_types.index('block_number')]

        if state_data == Transaction.VALIDATED and block_data:
            current_confirmations = self.blockchain_processor.current_buid(
                self.app.currency).number - block_data
        else:
            current_confirmations = 0

        if role == Qt.DisplayRole:
            if col == HistoryTableModel.columns_types.index('pubkey'):
                return "<p>" + source_data.replace('\n', "<br>") + "</p>"
            if col == HistoryTableModel.columns_types.index('date'):
                ts = self.blockchain_processor.adjusted_ts(
                    self.connection.currency, source_data)
                return QLocale.toString(
                    QLocale(),
                    QDateTime.fromTime_t(ts).date(),
                    QLocale.dateFormat(QLocale(),
                                       QLocale.ShortFormat)) + " BAT"
            if col == HistoryTableModel.columns_types.index('amount'):
                amount = self.app.current_ref.instance(
                    source_data, self.connection.currency, self.app,
                    block_data).diff_localized(False, False)
                return amount
            return source_data

        if role == Qt.FontRole:
            font = QFont()
            if state_data == Transaction.AWAITING or \
                    (state_data == Transaction.VALIDATED and current_confirmations < MAX_CONFIRMATIONS):
                font.setItalic(True)
            elif state_data == Transaction.REFUSED:
                font.setItalic(True)
            elif state_data == Transaction.TO_SEND:
                font.setBold(True)
            else:
                font.setItalic(False)
            return font

        if role == Qt.ForegroundRole:
            if state_data == Transaction.REFUSED:
                return QColor(Qt.darkGray)
            elif state_data == Transaction.TO_SEND:
                return QColor(Qt.blue)
            if col == HistoryTableModel.columns_types.index('amount'):
                if source_data < 0:
                    return QColor(Qt.darkRed)
                elif state_data == HistoryTableModel.DIVIDEND:
                    return QColor(Qt.darkBlue)
            if state_data == Transaction.AWAITING or \
                    (state_data == Transaction.VALIDATED and current_confirmations == 0):
                return QColor("#ffb000")

        if role == Qt.TextAlignmentRole:
            if HistoryTableModel.columns_types.index('amount'):
                return Qt.AlignRight | Qt.AlignVCenter
            if col == HistoryTableModel.columns_types.index('date'):
                return Qt.AlignCenter

        if role == Qt.ToolTipRole:
            if col == HistoryTableModel.columns_types.index('date'):
                ts = self.blockchain_processor.adjusted_ts(
                    self.connection.currency, source_data)
                return QDateTime.fromTime_t(ts).toString(
                    Qt.SystemLocaleLongDate)

            if state_data == Transaction.VALIDATED or state_data == Transaction.AWAITING:
                if current_confirmations >= MAX_CONFIRMATIONS:
                    return None
                elif self.app.parameters.expert_mode:
                    return self.tr("{0} / {1} confirmations").format(
                        current_confirmations, MAX_CONFIRMATIONS)
                else:
                    confirmation = current_confirmations / MAX_CONFIRMATIONS * 100
                    confirmation = 100 if confirmation > 100 else confirmation
                    return self.tr("Confirming... {0} %").format(
                        QLocale().toString(float(confirmation), 'f', 0))
コード例 #23
0
ファイル: playlists.py プロジェクト: zhangf911/FeelUOwn
 def headerData(self, section, orientation, role=Qt.DisplayRole):
     # XXX: 实际不产生任何效果
     if role == Qt.DisplayRole and orientation == Qt.Horizontal:
         return '播放列表'
     return QVariant()
コード例 #24
0
ファイル: history_list.py プロジェクト: spatocode/electrum
 def data(self, index: QModelIndex, role: Qt.ItemDataRole) -> QVariant:
     # note: this method is performance-critical.
     # it is called a lot, and so must run extremely fast.
     assert index.isValid()
     col = index.column()
     tx_item = self.transactions.value_from_pos(index.row())
     tx_hash = tx_item['txid']
     conf = tx_item['confirmations']
     txpos = tx_item['txpos_in_block'] or 0
     height = tx_item['height']
     try:
         status, status_str = self.tx_status_cache[tx_hash]
     except KeyError:
         tx_mined_info = self.tx_mined_info_from_tx_item(tx_item)
         status, status_str = self.parent.wallet.get_tx_status(
             tx_hash, tx_mined_info)
     if role == Qt.UserRole:
         # for sorting
         d = {
             HistoryColumns.STATUS_ICON:
             # height breaks ties for unverified txns
             # txpos breaks ties for verified same block txns
             (status, conf, -height, -txpos),
             HistoryColumns.STATUS_TEXT:
             status_str,
             HistoryColumns.DESCRIPTION:
             tx_item['label'],
             HistoryColumns.COIN_VALUE:
             tx_item['value'].value,
             HistoryColumns.RUNNING_COIN_BALANCE:
             tx_item['balance'].value,
             HistoryColumns.FIAT_VALUE:
             tx_item['fiat_value'].value
             if 'fiat_value' in tx_item else None,
             HistoryColumns.FIAT_ACQ_PRICE:
             tx_item['acquisition_price'].value
             if 'acquisition_price' in tx_item else None,
             HistoryColumns.FIAT_CAP_GAINS:
             tx_item['capital_gain'].value
             if 'capital_gain' in tx_item else None,
             HistoryColumns.TXID:
             tx_hash,
         }
         return QVariant(d[col])
     if role not in (Qt.DisplayRole, Qt.EditRole):
         if col == HistoryColumns.STATUS_ICON and role == Qt.DecorationRole:
             return QVariant(read_QIcon(TX_ICONS[status]))
         elif col == HistoryColumns.STATUS_ICON and role == Qt.ToolTipRole:
             return QVariant(
                 str(conf) + _(" confirmation" +
                               ("s" if conf != 1 else "")))
         elif col > HistoryColumns.DESCRIPTION and role == Qt.TextAlignmentRole:
             return QVariant(Qt.AlignRight | Qt.AlignVCenter)
         elif col != HistoryColumns.STATUS_TEXT and role == Qt.FontRole:
             monospace_font = QFont(MONOSPACE_FONT)
             return QVariant(monospace_font)
         elif col == HistoryColumns.DESCRIPTION and role == Qt.DecorationRole \
                 and self.parent.wallet.invoices.paid.get(tx_hash):
             return QVariant(read_QIcon("seal"))
         elif col in (HistoryColumns.DESCRIPTION, HistoryColumns.COIN_VALUE) \
                 and role == Qt.ForegroundRole and tx_item['value'].value < 0:
             red_brush = QBrush(QColor("#BC1E1E"))
             return QVariant(red_brush)
         elif col == HistoryColumns.FIAT_VALUE and role == Qt.ForegroundRole \
                 and not tx_item.get('fiat_default') and tx_item.get('fiat_value') is not None:
             blue_brush = QBrush(QColor("#1E1EFF"))
             return QVariant(blue_brush)
         return QVariant()
     if col == HistoryColumns.STATUS_TEXT:
         return QVariant(status_str)
     elif col == HistoryColumns.DESCRIPTION:
         return QVariant(tx_item['label'])
     elif col == HistoryColumns.COIN_VALUE:
         value = tx_item['value'].value
         v_str = self.parent.format_amount(value,
                                           is_diff=True,
                                           whitespaces=True)
         return QVariant(v_str)
     elif col == HistoryColumns.RUNNING_COIN_BALANCE:
         balance = tx_item['balance'].value
         balance_str = self.parent.format_amount(balance, whitespaces=True)
         return QVariant(balance_str)
     elif col == HistoryColumns.FIAT_VALUE and 'fiat_value' in tx_item:
         value_str = self.parent.fx.format_fiat(tx_item['fiat_value'].value)
         return QVariant(value_str)
     elif col == HistoryColumns.FIAT_ACQ_PRICE and \
             tx_item['value'].value < 0 and 'acquisition_price' in tx_item:
         # fixme: should use is_mine
         acq = tx_item['acquisition_price'].value
         return QVariant(self.parent.fx.format_fiat(acq))
     elif col == HistoryColumns.FIAT_CAP_GAINS and 'capital_gain' in tx_item:
         cg = tx_item['capital_gain'].value
         return QVariant(self.parent.fx.format_fiat(cg))
     elif col == HistoryColumns.TXID:
         return QVariant(tx_hash)
     return QVariant()
コード例 #25
0
 def showItems(self, items, startupId=""):
     urize = lambda x: "file://%s" % x.replace("file://", "")
     uris = QVariant(map(urize, items))
     uris.convert(QVariant.StringList)
     self.call("ShowItems", uris, "")
コード例 #26
0
ファイル: dbus_thumbnailer.py プロジェクト: Grumbel/dirtool
def dbus_as(value):
    var = QVariant(value)
    ret = var.convert(QVariant.StringList)
    assert ret, "QVariant conversion failure: {}".format(value)
    return var
コード例 #27
0
    def paintInfoColumn(self, painter, option, index, width_limit = 0):
        left = option.rect.left() + 3
        top = option.rect.top()
        width = option.rect.width() - width_limit

        pixmap = QPixmap(option.rect.size())
        pixmap.fill(Qt.transparent)

        p = QPainter(pixmap)
        p.setRenderHint(QPainter.Antialiasing, True)
        p.translate(-option.rect.topLeft())

        textInner = 2 * ICON_PADDING + ROW_HEIGHT - 10
        itemHeight = ROW_HEIGHT + 2 * ICON_PADDING

        margin = left + ICON_PADDING - 10

        title = QVariant.value(index.model().data(index, NameRole))
        summary = QVariant.value(index.model().data(index, SummaryRole))
        ptype = QVariant.value(index.model().data(index, TypeRole))
        
        rate = int(QVariant.value(index.model().data(index, RateRole))) if QVariant.value(index.model().data(index, RateRole))!= None  else 0
        
        installed = True if QVariant.value(index.model().data(index, InstalledRole))=="True" else False
        
        # We need to request update if its not possible to get meta data about the package
        try:
            # Get Package Icon if exists
            _icon = QVariant.value(index.model().data(index, Qt.DecorationRole))
        except:
            p.end()
            painter.drawPixmap(option.rect.topLeft(), pixmap)
            self.parent.requestUpdate()
            return

        icon = None

        if _icon:
            overlay = [CHECK_ICON] if installed else []
            KIconLoader._forceCache = True
            pix = KIconLoader.loadOverlayed(_icon, overlay, 32)
            if not pix.isNull():
                icon = QIcon(pix.scaled(QSize(32, 32), Qt.KeepAspectRatio, Qt.SmoothTransformation))
            KIconLoader._forceCache = False
               

        if not icon:
            icon = self.defaultIcon if not installed else self.defaultInstalledIcon

        # Paint the Icon
        icon.paint(p, margin, top + ICON_PADDING, ROW_HEIGHT, ROW_HEIGHT, Qt.AlignCenter)

        fix_pos = 0
        if index.model().columnCount() <= 1:
            fix_pos = 22

        if config.USE_APPINFO:
            # Rating Stars
            for _rt_i in range(5):
                self._rt_0.paint(p, width + 10 * _rt_i - 30 - fix_pos, top + ROW_HEIGHT / 4, 10, 10, Qt.AlignCenter)
            for _rt_i in range(rate):
                self._rt_1.paint(p, width + 10 * _rt_i - 30 - fix_pos, top + ROW_HEIGHT / 4, 10, 10, Qt.AlignCenter)
        
        foregroundColor = option.palette.color(QPalette.Text)
        p.setPen(foregroundColor)

        # Package Name
        p.setFont(self.boldFont)
        p.drawText(left + textInner, top, width - textInner, itemHeight / 2,Qt.AlignBottom | Qt.AlignLeft, title) # 
                
        tagWidth = 0

        _component_width = 0
        if self.parent.showComponents:
            component = str(QVariant.value(index.model().data(index, ComponentRole)))
            widthOfTitle = self.boldFontFM.width(title) + 6 + left + textInner

            p.setFont(self.tagFont)
            rect = self.tagFontFM.boundingRect(option.rect, Qt.TextWordWrap, component)
            p.setPen(LIGHTGREEN)
            p.setBrush(LIGHTGREEN)
            p.drawRoundedRect(widthOfTitle , top + 12, rect.width() + 4, rect.height(), 10, 10)
            p.setPen(DARKGREEN)
            p.drawText(widthOfTitle + 2, top + 12, rect.width(), rect.height(), Qt.AlignCenter, component)
            p.setPen(foregroundColor)
            _component_width = rect.width() + 8

        if self.parent.showIsA:
            isa = str(QVariant.value(index.model().data(index, IsaRole)))
            if not isa == '':
                widthOfTitle = self.boldFontFM.width(title) + 6 + left + textInner + _component_width

                p.setFont(self.tagFont)
                rect = self.tagFontFM.boundingRect(option.rect, Qt.TextWordWrap, isa)
                p.setPen(LIGHTBLUE)
                p.setBrush(LIGHTBLUE)
                p.drawRoundedRect(widthOfTitle , top + 12, rect.width() + 4, rect.height(), 10, 10)
                p.setPen(DARKVIOLET)
                p.drawText(widthOfTitle + 2, top + 12, rect.width(), rect.height(), Qt.AlignCenter, isa)
                p.setPen(foregroundColor)
                _component_width += rect.width() + 8

        if ptype not in ('None', 'normal'):
            widthOfTitle = self.boldFontFM.width(title) + 6 + left + textInner + _component_width
            p.setFont(self.tagFont)
            rect = self.tagFontFM.boundingRect(option.rect, Qt.TextWordWrap, self.types[ptype][1])
            p.setPen(self.types[ptype][0])
            p.setBrush(self.types[ptype][0])
            p.drawRoundedRect(widthOfTitle, top + 12, rect.width() + 4, rect.height(), 10, 10)
            p.setPen(WHITE)
            p.drawText(widthOfTitle + 2, top + 12, rect.width(), rect.height(), Qt.AlignCenter, self.types[ptype][1])
            p.setPen(foregroundColor)
            tagWidth = rect.width()

        # Package Summary
        p.setFont(self.normalFont)
        foregroundColor.setAlpha(160)
        p.setPen(foregroundColor)
        elided_summary = self.normalFontFM.elidedText(summary, Qt.ElideRight, width - textInner - tagWidth - 22)
        p.drawText(left + textInner, top + itemHeight / 2, width - textInner, itemHeight / 2, Qt.TextDontClip, elided_summary)
        foregroundColor.setAlpha(255)
        p.setPen(foregroundColor)

        buttonStyle = None
        if self.rowAnimator.currentRow() == index.row():
            description = str(QVariant.value(index.model().data(index, DescriptionRole)))
            size = str(QVariant.value(index.model().data(index, SizeRole)))
            homepage = str(QVariant.value(index.model().data(index, HomepageRole)))
            installedVersion = str(QVariant.value(index.model().data(index, InstalledVersionRole)))
            version = str(QVariant.value(index.model().data(index, VersionRole)))

            # Package Detail Label
            position = top + ROW_HEIGHT

            p.setFont(self.normalDetailFont)
            baseRect = QRect(left, position, width - 8, option.rect.height())
            rect = self.normalDetailFontFM.boundingRect(baseRect, Qt.TextWordWrap | Qt.TextDontClip, description)
            p.drawText(left + 2, position, width - 8, rect.height(), Qt.TextWordWrap | Qt.TextDontClip, description)

            # Package Detail Homepage
            position += rect.height() + 4

            p.setFont(self.boldDetailFont)
            p.drawText(left + ICON_SIZE , position, width - textInner, itemHeight / 2, Qt.AlignLeft, self._titles['website'])

            p.setFont(self.normalDetailFont)
            homepage = self.normalDetailFontFM.elidedText(homepage, Qt.ElideRight, width - self._titleFM['website'])
            rect = self.normalDetailFontFM.boundingRect(option.rect, Qt.TextSingleLine, homepage)
            self.rowAnimator.hoverLinkFilter.link_rect = QRect(left + self._titleFM['website'] + 2, position + 2 + 32, rect.width(), rect.height())

            p.setPen(option.palette.color(QPalette.Link))
            p.drawText(left + self._titleFM['website'], position, width, rect.height(), Qt.TextSingleLine, homepage)
            p.setPen(foregroundColor)

            # Package Detail Version
            position += rect.height()

            p.setFont(self.boldDetailFont)
            p.drawText(left + ICON_SIZE , position, width - textInner, itemHeight / 2, Qt.AlignLeft, self._titles['release'])

            p.setFont(self.normalDetailFont)
            rect = self.normalDetailFontFM.boundingRect(option.rect, Qt.TextWordWrap, version)
            p.drawText(left + self._titleFM['release'], position, width, rect.height(), Qt.TextWordWrap, version)

            if not installedVersion == '' or not installedVersion == None:
                position += rect.height()

                p.setFont(self.boldDetailFont)
                p.drawText(left + ICON_SIZE , position, width - textInner, itemHeight / 2, Qt.AlignLeft, self._titles['installVers'])

                p.setFont(self.normalDetailFont)
                rect = self.normalDetailFontFM.boundingRect(option.rect, Qt.TextWordWrap, installedVersion)
                p.drawText(left + self._titleFM['installVers'], position, width, rect.height(), Qt.TextWordWrap, installedVersion)

            # Package Detail Repository
            repository = QVariant.value(index.model().data(index, RepositoryRole))
            if not repository == '':
                repository = _translate("Packaga Manager",'Unknown')  if repository == 'N/A' else repository
                position += rect.height()

                p.setFont(self.boldDetailFont)
                p.drawText(left + ICON_SIZE , position, width - textInner, itemHeight / 2, Qt.AlignLeft, self._titles['repository'])

                p.setFont(self.normalDetailFont)
                p.drawText(left + self._titleFM['repository'], position, width, itemHeight / 2, Qt.TextWordWrap, repository)

            # Package Detail Size
            position += rect.height()

            p.setFont(self.boldDetailFont)
            p.drawText(left + ICON_SIZE , position, width - textInner, itemHeight / 2, Qt.AlignLeft, self._titles['size'])

            p.setFont(self.normalDetailFont)
            p.drawText(left + self._titleFM['size'], position, width, itemHeight / 2, Qt.TextWordWrap, size)
            position += rect.height()
            self.rowAnimator.max_height = position - top + 8

            # Package More info button
            opt = QStyleOptionViewItem(option)

            buttonStyle = QStyleOptionButton()
            if option.state & QStyle.State_MouseOver or option.state & QStyle.State_HasFocus:
                buttonStyle.state |= QStyle.State_HasFocus
            
            buttonStyle.state |= QStyle.State_Enabled
            buttonStyle.text = _translate("Packaga Manager","Details")

            buttonStyle.rect = QRect(width - 100, position - 22, 100, 22)

        p.end()

        # FIXME
        # if option.state & QStyle.State_HasFocus and self.animatable:
        #     option.state |= QStyle.State_MouseOver
            # Use Plastique style to draw focus rect like MouseOver effect of Oxygen.
            # self.plastik.drawPrimitive(QStyle.PE_FrameLineEdit, option, painter, None)

        if not self.rowAnimator.running() and buttonStyle:
            if self.show_details_button and (installed or config.USE_APPINFO):
                PackageDelegate.AppStyle().drawControl(QStyle.CE_PushButton, buttonStyle, painter, None)
                self.rowAnimator.hoverLinkFilter.button_rect = QRect(buttonStyle.rect)

        painter.drawPixmap(option.rect.topLeft(), pixmap)
        del pixmap
コード例 #28
0
ファイル: dbus_thumbnailer.py プロジェクト: Grumbel/dirtool
def dbus_uint(value):
    var = QVariant(value)
    ret = var.convert(QVariant.UInt)
    assert ret, "QVariant conversion failure: {}".format(value)
    return var
コード例 #29
0
ファイル: q3dview.py プロジェクト: nsashi/Qgis2threejs
 def __init__(self, parent=None):
     QObject.__init__(self, parent)
     self._parent = parent
     self.data = QVariant()
コード例 #30
0
ファイル: treewidget.py プロジェクト: bsrnesraa/dxf2gcode-prj
   def headerData(self, column, orientation, role):
       if (orientation == Qt.Horizontal and
                role == Qt.DisplayRole):
           return QVariant("Content")

       return QVariant()