コード例 #1
0
QVariant RegisterSubItem::data(int column, int role) const
{
    switch (role) {
        case RegisterChangedRole:
            return m_changed;

        case RegisterNumberBaseRole:
            return 16;

        case RegisterAsAddressRole:
            return 0;

        case Qt::DisplayRole:
            switch (column) {
                case 0:
                    return subTypeName(m_subKind, m_subSize);
                case 1: {
                    QTC_ASSERT(parent(), return QVariant());
                    RegisterItem *registerItem = static_cast<RegisterItem *>(parent());
                    RegisterValue value = registerItem->m_reg.value;
                    QByteArray ba;
                    for (int i = 0; i != m_count; ++i) {
                        ba += value.subValue(m_subSize, i).toByteArray(16, m_subKind, m_subSize);
                        int tab = 5 * (i + 1) * m_subSize;
                        ba += QByteArray(tab - ba.size(), ' ');
                    }
                    return ba;
                }
            }
        default:
            break;
    }

    return QVariant();
}
コード例 #2
0
ファイル: SCPageEffectFactory.cpp プロジェクト: KDE/koffice
QMap<QString, int> SCPageEffectFactory::subTypesByName() const
{
    QMap<QString, int> nameToType;
    foreach (const int subType, d->subTypes) {
        nameToType.insertMulti(subTypeName(subType), subType);
    }
    return nameToType;
}
コード例 #3
0
QVariant RegisterSubItem::data(int column, int role) const
{
    switch (role) {
        case RegisterChangedRole:
            return m_changed;

        case RegisterFormatRole: {
            RegisterItem *registerItem = static_cast<RegisterItem *>(parent());
            return int(registerItem->m_format);
        }

        case RegisterAsAddressRole:
            return 0;

        case Qt::DisplayRole:
            switch (column) {
                case RegisterNameColumn:
                    return subTypeName(m_subKind, m_subSize, m_subFormat);
                case RegisterValueColumn: {
                    QTC_ASSERT(parent(), return QVariant());
                    RegisterItem *registerItem = static_cast<RegisterItem *>(parent());
                    RegisterValue value = registerItem->m_reg.value;
                    QString ba;
                    for (int i = 0; i != m_count; ++i) {
                        int tab = 5 * (i + 1) * m_subSize;
                        QString b = value.subValue(m_subSize, i).toString(m_subKind, m_subSize, m_subFormat);
                        ba += QString(tab - ba.size() - b.size(), ' ');
                        ba += b;
                    }
                    return ba;
                }
            }

        case Qt::ToolTipRole:
            if (m_subKind == IntegerRegister) {
                if (m_subFormat == CharacterFormat)
                    return RegisterHandler::tr("Content as ASCII Characters");
                if (m_subFormat == SignedDecimalFormat)
                    return RegisterHandler::tr("Content as %1-bit Signed Decimal Values").arg(8 * m_subSize);
                if (m_subFormat == DecimalFormat)
                    return RegisterHandler::tr("Content as %1-bit Unsigned Decimal Values").arg(8 * m_subSize);
                if (m_subFormat == HexadecimalFormat)
                    return RegisterHandler::tr("Content as %1-bit Hexadecimal Values").arg(8 * m_subSize);
                if (m_subFormat == OctalFormat)
                    return RegisterHandler::tr("Content as %1-bit Octal Values").arg(8 * m_subSize);
                if (m_subFormat == BinaryFormat)
                    return RegisterHandler::tr("Content as %1-bit Binary Values").arg(8 * m_subSize);
            }
            if (m_subKind == FloatRegister)
                return RegisterHandler::tr("Content as %1-bit Floating Point Values").arg(8 * m_subSize);

        default:
            break;
    }

    return QVariant();
}