• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ quint8函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中quint8函数的典型用法代码示例。如果您正苦于以下问题:C++ quint8函数的具体用法?C++ quint8怎么用?C++ quint8使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了quint8函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: int

void HairyBrush::paintParticle(QPointF pos, const KoColor& color, qreal weight)
{
    // opacity top left, right, bottom left, right
    quint8 opacity = color.opacityU8();
    opacity *= weight;

    int ipx = int (pos.x());
    int ipy = int (pos.y());
    qreal fx = pos.x() - ipx;
    qreal fy = pos.y() - ipy;

    quint8 btl = qRound((1.0 - fx) * (1.0 - fy) * opacity);
    quint8 btr = qRound((fx)  * (1.0 - fy) * opacity);
    quint8 bbl = qRound((1.0 - fx) * (fy)  * opacity);
    quint8 bbr = qRound((fx)  * (fy)  * opacity);

    const KoColorSpace * cs = m_dab->colorSpace();

    m_dabAccessor->moveTo(ipx  , ipy);
    btl = quint8(qBound<quint16>(OPACITY_TRANSPARENT_U8, btl + cs->opacityU8(m_dabAccessor->rawData()), OPACITY_OPAQUE_U8));
    memcpy(m_dabAccessor->rawData(), color.data(), cs->pixelSize());
    cs->setOpacity(m_dabAccessor->rawData(), btl, 1);

    m_dabAccessor->moveTo(ipx + 1, ipy);
    btr =  quint8(qBound<quint16>(OPACITY_TRANSPARENT_U8, btr + cs->opacityU8(m_dabAccessor->rawData()), OPACITY_OPAQUE_U8));
    memcpy(m_dabAccessor->rawData(), color.data(), cs->pixelSize());
    cs->setOpacity(m_dabAccessor->rawData(), btr, 1);

    m_dabAccessor->moveTo(ipx, ipy + 1);
    bbl = quint8(qBound<quint16>(OPACITY_TRANSPARENT_U8, bbl + cs->opacityU8(m_dabAccessor->rawData()), OPACITY_OPAQUE_U8));
    memcpy(m_dabAccessor->rawData(), color.data(), cs->pixelSize());
    cs->setOpacity(m_dabAccessor->rawData(), bbl, 1);

    m_dabAccessor->moveTo(ipx + 1, ipy + 1);
    bbr = quint8(qBound<quint16>(OPACITY_TRANSPARENT_U8, bbr + cs->opacityU8(m_dabAccessor->rawData()), OPACITY_OPAQUE_U8));
    memcpy(m_dabAccessor->rawData(), color.data(), cs->pixelSize());
    cs->setOpacity(m_dabAccessor->rawData(), bbr, 1);
}
开发者ID:ChrisJong,项目名称:krita,代码行数:38,代码来源:hairy_brush.cpp


示例2: m_device

/*!
 * Создание транспортного пакета.
 *
 * \param stream     output stream.
 * \param packets    raw virtual packets.
 * \param sequence   packet sequence.
 * \param timestamp  отметка времени.
 * \param options    packet options.
 * \param type       packet type.
 * \param subversion packet subversion.
 */
TransportWriter::TransportWriter(QDataStream *stream, const QList<QByteArray> &packets, quint64 sequence, qint64 timestamp, quint8 options, quint8 type, quint8 subversion)
  : m_device(stream->device()),
    m_size(16)
{
  m_device->seek(0);
  quint32 size = packets.size();
  bool huge = options & Protocol::HugePackets;

  // Расчёт размера пакета и составление карты размеров виртуальных пакетов.
  if (huge)
    m_size += (size * 4);
  else
    m_size += (size * 2);

  quint32 *map = new quint32[size];
  quint32 s = 0;
  for (quint32 i = 0; i < size; ++i) {
    s = packets.at(i).size();
    map[i] = s;
    m_size += s;
  }

  if (timestamp != 0) {
    options |= Protocol::TimeStamp;
    m_size += 8;
  }

  // Запись заголовка пакета.
  *stream << m_size << type << quint8(Protocol::V4) << subversion << options << sequence;

  if (timestamp != 0)
    *stream << timestamp;

  *stream << size;
  // Запись карты размеров виртуальных пакетов.
  if (huge) {
    for (quint32 i = 0; i < size; ++i)
      *stream << map[i];
  } else {
    for (quint32 i = 0; i < size; ++i)
      *stream << quint16(map[i]);
  }

  // Запись тел виртуальных пакетов.
  for (quint32 i = 0; i < size; ++i) {
    stream->writeRawData(packets.at(i).constData(), map[i]);
  }

  delete [] map;
}
开发者ID:Artanomell,项目名称:schat,代码行数:61,代码来源:TransportWriter.cpp


示例3: request

void PlayerSocket::sendEnemyConnectionInf(const QSharedPointer<PlayerSocket>& enemy, bool serverFlag)
{
    QByteArray bytes;
    QDataStream request(&bytes, QIODevice::ReadWrite);
    request.setVersion(Protocol::QDataStreamVersion);

    request << quint16(0) << quint8(Protocol::GAME_FOUND) << serverFlag;
    request << enemy->getServerPort() << enemy->getHostName().toLatin1().data();
    request.device()->seek(0);
    request << quint16(bytes.size());

    socket->write(bytes);
    socket->flush();
}
开发者ID:SunInJuly,项目名称:SeaBattle,代码行数:14,代码来源:playerSocket.cpp


示例4: QBluetoothServer

void ChatServer::startServer(const QBluetoothAddress& localAdapter)
{
    if (rfcommServer)
        return;

    rfcommServer = new QBluetoothServer(QBluetoothServiceInfo::RfcommProtocol, this);
    connect(rfcommServer, SIGNAL(newConnection()), this, SLOT(clientConnected()));
    bool result = rfcommServer->listen(localAdapter);
    if (!result) {
        qWarning() << "Cannot bind chat server to" << localAdapter.toString();
        return;
    }

    //serviceInfo.setAttribute(QBluetoothServiceInfo::ServiceRecordHandle, (uint)0x00010010);

    QBluetoothServiceInfo::Sequence classId;

    classId << QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::SerialPort));
    serviceInfo.setAttribute(QBluetoothServiceInfo::BluetoothProfileDescriptorList,
                             classId);

    classId.prepend(QVariant::fromValue(QBluetoothUuid(serviceUuid)));

    serviceInfo.setAttribute(QBluetoothServiceInfo::ServiceClassIds, classId);
    serviceInfo.setAttribute(QBluetoothServiceInfo::BluetoothProfileDescriptorList,classId);

    serviceInfo.setAttribute(QBluetoothServiceInfo::ServiceName, tr("Bt Chat Server"));
    serviceInfo.setAttribute(QBluetoothServiceInfo::ServiceDescription,
                             tr("Example bluetooth chat server"));
    serviceInfo.setAttribute(QBluetoothServiceInfo::ServiceProvider, tr("qt-project.org"));

    serviceInfo.setServiceUuid(QBluetoothUuid(serviceUuid));

    serviceInfo.setAttribute(QBluetoothServiceInfo::BrowseGroupList,
                             QBluetoothUuid(QBluetoothUuid::PublicBrowseGroup));

    QBluetoothServiceInfo::Sequence protocolDescriptorList;
    QBluetoothServiceInfo::Sequence protocol;
    protocol << QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::L2cap));
    protocolDescriptorList.append(QVariant::fromValue(protocol));
    protocol.clear();
    protocol << QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::Rfcomm))
             << QVariant::fromValue(quint8(rfcommServer->serverPort()));
    protocolDescriptorList.append(QVariant::fromValue(protocol));
    serviceInfo.setAttribute(QBluetoothServiceInfo::ProtocolDescriptorList,
                             protocolDescriptorList);

    serviceInfo.registerService(localAdapter);
}
开发者ID:ricardopetrere,项目名称:TCC_FTT,代码行数:49,代码来源:chatserver.cpp


示例5: QByteArray

Shred::~Shred() {
    QByteArray * const shred_data = new QByteArray();
    shred_data->reserve(30000);
    QDataStream outstr(shred_data, QIODevice::WriteOnly);
    outstr << CURRENT_SHRED_FORMAT_VERSION;
    outstr.setVersion(DATASTREAM_VERSION);
    outstr << quint8(GetTypeOfShred()) << quint8(weather);
    for (int x=0; x<SHRED_WIDTH; ++x)
    for (int y=0; y<SHRED_WIDTH; ++y) {
        int height = HEIGHT-2;
        for ( ; blocks[x][y][height]->Sub()==AIR; --height);
        for (int z=1; z <= height; ++z) {
            Block * const block = blocks[x][y][z];
            if ( block == Normal(block->Sub()) ) {
                block->SaveNormalToFile(outstr);
            } else {
                block->SaveToFile(outstr);
                delete block; // without unregistering.
            }
        }
        blocks[x][y][HEIGHT-1]->SaveNormalToFile(outstr);
    }
    GetWorld()->SetShredData(shred_data, longitude, latitude);
}
开发者ID:Panzerschrek,项目名称:FREG-3d_2.0,代码行数:24,代码来源:Shred.cpp


示例6: out

void Client::sendRegistration()
{
    QByteArray datagram;
    QDataStream out(&datagram, QIODevice::WriteOnly);
    out.setVersion(QDataStream::Qt_4_7);
    out << quint16(0) << quint8('R');

    out << DeviceManager::getDeviceMac() << DeviceManager::getDeviceIP();
    out << 0xFFFF;

    //out.device()->seek(0);
    //out << quint16(block->size() - sizeof(quint16));

    udpSocket.writeDatagram(datagram, QHostAddress::Broadcast, 6178);
}
开发者ID:gaolinjie,项目名称:taomi,代码行数:15,代码来源:client.cpp


示例7: out

void Client::sendSearchInfo(){
	QByteArray block;
	QDataStream out(&block, QIODevice::WriteOnly);
	out.setVersion(QDataStream::Qt_4_1);
	//if(!userLineEdit->text().isEmpty()){
		out << quint16(0) << quint8('S') << userLineEdit->text();
		out.device()->seek(0);
		out << quint16(block.size() - sizeof(quint16));
		tcpSocket->write(block);
	//}else{
	//	statusLabel->setText("Please enter a file to search for");
	//}

	//ui.label->setText(tr("Sending request..."));
	//printf("Sending Request...\n");
}
开发者ID:mickelfeng,项目名称:Threaded-Client-Server-Application,代码行数:16,代码来源:client.cpp


示例8: QFETCH

void tst_QAsn1Element::octetString()
{
    QFETCH(QByteArray, encoded);
    QFETCH(QByteArray, value);

    // read
    QAsn1Element elem;
    QVERIFY(elem.read(encoded));
    QCOMPARE(elem.type(), quint8(QAsn1Element::OctetStringType));
    QCOMPARE(elem.value(), value);

    // write
    QByteArray buffer;
    QDataStream stream(&buffer, QIODevice::WriteOnly);
    elem.write(stream);
    QCOMPARE(buffer, encoded);
}
开发者ID:venkatarajasekhar,项目名称:Qt,代码行数:17,代码来源:tst_qasn1element.cpp


示例9: CHECK_SIZE_EQUALS

QModbusResponse QModbusServerPrivate::processGetCommEventLogRequest(const QModbusRequest &request)
{
    CHECK_SIZE_EQUALS(request);
    const QVariant tmp = q_func()->value(QModbusServer::DeviceBusy);
    if (tmp.isNull() || (!tmp.isValid())) {
        return QModbusExceptionResponse(request.functionCode(),
                                        QModbusExceptionResponse::ServerDeviceFailure);
    }
    const quint16 deviceBusy = tmp.value<quint16>();

    QVector<quint8> eventLog(int(m_commEventLog.size()));
    std::copy(m_commEventLog.cbegin(), m_commEventLog.cend(), eventLog.begin());

    // 6 -> 3 x 2 Bytes (Status, Event Count and Message Count)
    return QModbusResponse(request.functionCode(), quint8(eventLog.size() + 6), deviceBusy,
                           m_counters[Counter::CommEvent], m_counters[Counter::BusMessage], eventLog);
}
开发者ID:2gis,项目名称:2gisqt5android,代码行数:17,代码来源:qmodbusserver.cpp


示例10: window

void QDirectFBWindowSurface::flush(QWidget *widget, const QRegion &region,
                                   const QPoint &offset)
{
    QWidget *win = window();
    if (!win)
        return;

#if !defined(QT_NO_QWS_PROXYSCREEN) && !defined(QT_NO_GRAPHICSVIEW)
    QWExtra *extra = qt_widget_private(widget)->extraData();
    if (extra && extra->proxyWidget)
        return;
#else
    Q_UNUSED(widget);
#endif

    const quint8 windowOpacity = quint8(win->windowOpacity() * 0xff);
    const QRect windowGeometry = geometry();
#ifdef QT_DIRECTFB_WM
    quint8 currentOpacity;
    Q_ASSERT(dfbWindow);
    dfbWindow->GetOpacity(dfbWindow, &currentOpacity);
    if (currentOpacity != windowOpacity) {
        dfbWindow->SetOpacity(dfbWindow, windowOpacity);
    }

    screen->flipSurface(dfbSurface, flipFlags, region, offset);
#else
    setOpaque(windowOpacity == 0xff);
    if (mode == Offscreen) {
        screen->exposeRegion(region.translated(offset + geometry().topLeft()), 0);
    } else {
        screen->flipSurface(dfbSurface, flipFlags, region, offset);
    }
#endif

#ifdef QT_DIRECTFB_TIMING
    enum { Secs = 3 };
    ++frames;
    if (timer.elapsed() >= Secs * 1000) {
        qDebug("%d fps", int(double(frames) / double(Secs)));
        frames = 0;
        timer.restart();
    }
#endif
    flushPending = false;
}
开发者ID:Blizzard,项目名称:qt4,代码行数:46,代码来源:qdirectfbwindowsurface.cpp


示例11: quint8

void KisColor::initHSX(Type type, float h, float s, float x, float a)
{
	// an offset that is added to the m_coreData buffer to make sure
	// the struct created with the placement new operator is aligned at 16 bytes
	// this is required by Eigen for vectorization
	m_offset = quint8(16 - (reinterpret_cast<size_t>(m_coreData) % 16)) % 16;
	
    switch(type)
    {
        case HSY: { new (m_coreData + m_offset) CoreImpl<HSYType>; } break;
        case HSV: { new (m_coreData + m_offset) CoreImpl<HSVType>; } break;
        case HSL: { new (m_coreData + m_offset) CoreImpl<HSLType>; } break;
        case HSI: { new (m_coreData + m_offset) CoreImpl<HSIType>; } break;
    }
    
    core()->type = type;
    core()->setHSX(h, s, x, a);
}
开发者ID:KDE,项目名称:krita,代码行数:18,代码来源:kis_color.cpp


示例12: Coach

void WorldSession::SendCoachInformation()
{
    Coach* coach = new Coach(this);
    if (!coach->LoadFromDB())
    {
        delete coach;
        OnClose();
        return;
    }

    WorldPacket data(SMSG_COACH_INFORMATIONS);

    // unserializeIdAndName
    data << coach->GetGuid();
    data.WriteString(coach->GetName());

    // unserializeLook
    data << coach->GetSkinColorIndex();
    data << coach->GetHairColorIndex();
    data << coach->GetGender();

    // unserializeEquipment
    data << quint16(0); // length
    // todo

    // unserializeCardInventory
    data << quint16(0); // length
    // todo

    // unserializeLockedSet
    data << quint16(0); // length

    // unserializeLaddersStrength
    data << quint8(0); // count
    // todo

    SendPacket(data);

    // World login
    SendEnterInstance();
}
开发者ID:KevinSupertramp,项目名称:dArena,代码行数:41,代码来源:CoachHandler.cpp


示例13: testQOfonoCallVolume

    void testQOfonoCallVolume()
    {

        QSignalSpy mutedChanged(m, SIGNAL(mutedChanged(const bool)));
        QSignalSpy speakerVolumeChanged(m, SIGNAL(speakerVolumeChanged(const quint8)));
        QSignalSpy microphoneVolumeChanged(m, SIGNAL(microphoneVolumeChanged(const quint8)));
        QSignalSpy spfail(m, SIGNAL(setSpeakerVolumeFailed()));
        QSignalSpy mvfail(m, SIGNAL(setMicrophoneVolumeFailed()));

        QOfonoModem modem;
        modem.setModemPath(m->modemPath());
        modem.setPowered(false);
        QTest::qWait(5000);
        modem.setPowered(true);
        QTest::qWait(5000);
        modem.setOnline(true);
        QTest::qWait(5000);

        m->setMuted(true);
        QTest::qWait(2000);
        QCOMPARE(mutedChanged.count(), 1);
        QVERIFY(mutedChanged.takeFirst().at(0).toBool()==bool(true));
        QVERIFY(m->muted()==bool(true));

        m->setMuted(false);
        QTest::qWait(2000);
        QCOMPARE(mutedChanged.count(), 1);
        QVERIFY(mutedChanged.takeFirst().at(0).toBool()==bool(false));
        QVERIFY(m->muted()==bool(false));


        m->setSpeakerVolume(quint8(15));
        QTest::qWait(2000);
        QCOMPARE(speakerVolumeChanged.count(), 1);
        QCOMPARE(quint8(speakerVolumeChanged.takeFirst().at(0).toUInt()), quint8(15));
        QCOMPARE(m->speakerVolume(),quint8(15));

        m->setSpeakerVolume(quint8(250));
        QTest::qWait(2000);
        QCOMPARE(spfail.count(), 1);

        m->setMicrophoneVolume(quint8(10));
        QTest::qWait(2000);
        QCOMPARE(mvfail.count(), 1);

    }
开发者ID:amtep,项目名称:libqofono,代码行数:46,代码来源:tst_qofonocallvolume.cpp


示例14: getSeatNO

void Client::sendOrder()
{
    quint16 seatNO = getSeatNO();

    block = new QByteArray();
    QDataStream out(block, QIODevice::WriteOnly);
    out.setVersion(QDataStream::Qt_4_7);
    out << quint16(0) << quint8('O');

    QSqlQuery query;
    query.exec("SELECT * FROM unsentModel");

    quint32 orderNO = 0;
    QString name = "";
    QString image = "";
    float price = 0;
    quint16 num = 0;
    while (query.next()) {
        if (orderNO == 0) {
            orderNO = query.value(0).toUInt();
            out << quint32(orderNO) << quint16(seatNO) << DeviceManager::getDeviceMac();
        }
        name = query.value(1).toString();
        image = query.value(2).toString();
        price = query.value(3).toFloat();
        num = query.value(4).toUInt();
        out << 0x1111 << name  << price << num;
    }
    query.exec("DELETE FROM unsentModel");
    out << 0xFFFF;

    out.device()->seek(0);
    out << quint16(block->size() - sizeof(quint16));

    QString serverIP = DeviceManager::getServerIP();
    connectToServer(serverIP);
    emit sendOrderComplete();
}
开发者ID:gaolinjie,项目名称:taomi,代码行数:38,代码来源:client.cpp


示例15: stream

void VoxelFile::save_fp(QFile & fp)
{
    QDataStream stream(&fp);
    stream.setByteOrder(QDataStream::LittleEndian);
    stream << x_size;
    stream << y_size;
    stream << z_size;
    stream << x_offset;
    stream << y_offset;
    stream << z_offset;
    stream.writeRawData((char*)data, x_size * y_size * z_size);
    stream.writeRawData((char*)global_palette, 256 * 3);
    stream << quint8(points.size());
    ReferencePoints::const_iterator it;
    for (it = points.begin(); it != points.end(); it++) {
        const ReferencePoint & point = *it;
        write_cstring(stream, point.name);
        stream << point.x;
        stream << point.y;
        stream << point.z;
    }
    save_palette();
}
开发者ID:Dakror,项目名称:voxie,代码行数:23,代码来源:voxel.cpp


示例16: quint32

void DiscoverClient::updateListEndpoints()
{
    m_address_list.clear();

    for (const QHostAddress &address : QNetworkInterface::allAddresses())
    {
        if (address.protocol() == QAbstractSocket::IPv4Protocol)
        {
            quint32 ip = address.toIPv4Address();

            quint8 octets[4];
            quint32 parts[4];

            for (int i = 1; i <= 4; i++)
            {
                quint32 num = (ip / quint32(qPow(256, 4 - i)));
                ip = (ip - num * quint32(qPow(256, 4 - i)));
                octets[i - 1] = quint8(num);
            }

            for (int i = 1; i <= 4; i++)
            {
                parts[i - 1] = (octets[i - 1] * quint32(qPow(256, 4 - i)));
            }

            parts[4 - 1] = 255;

            quint32 new_ip = (parts[0] + parts[1] + parts[2] + parts[3]);

            QHostAddress address(ip);

            QHostAddress address_broadcast(new_ip);

            m_address_list.append(address_broadcast);
        }
    }
}
开发者ID:antonypro,项目名称:AudioStreaming,代码行数:37,代码来源:discoverclient.cpp


示例17: getFileExtension

bool AkaiFileHandler::writePgmFileMPC1000( QStringList sampleNames,
                                           const QString fileBaseName,
                                           const QString outputDirPath,
                                           const QString tempDirPath,
                                           const SamplerAudioSource::EnvelopeSettings& envelopes,
                                           const bool isOverwriteEnabled )
{
    const QString fileName = fileBaseName + getFileExtension();

    if ( QDir( outputDirPath ).exists( fileName ) && ! isOverwriteEnabled )
    {
        return false;
    }

    while ( sampleNames.size() > MPC1000_Profile::NUM_PADS )
    {
        sampleNames.removeLast();
    }

    QByteArray pgmData( MPC1000_PGM::FILE_SIZE, PADDING );

    bool isSuccessful = getTemplateDataMPC1000( pgmData );

    if ( isSuccessful )
    {
        quint8 noteNum = Midi::MIDDLE_C;

        for ( quint8 padNum = 0; padNum < sampleNames.size(); padNum++ )
        {
            // Add sample name to PGM data
            {
                QByteArray sampleName = sampleNames.at( padNum ).toLatin1().leftJustified( MPC1000_PGM::SAMPLE_NAME_SIZE, PADDING, true );

                const int pos = MPC1000_PGM::PAD_DATA_START + ( padNum * MPC1000_PGM::PAD_DATA_SIZE );

                pgmData.replace( pos, MPC1000_PGM::SAMPLE_NAME_SIZE, sampleName );
            }

            // Add sample volume level
            {
                const int pos = MPC1000_PGM::PAD_DATA_START + ( padNum * MPC1000_PGM::PAD_DATA_SIZE ) + MPC1000_PGM::LEVEL_OFFSET;

                QByteArray level;
                level += quint8( 100 );

                pgmData.replace( pos, 1, level );
            }

            // Add play mode
            {
                const int pos = MPC1000_PGM::PAD_DATA_START + ( padNum * MPC1000_PGM::PAD_DATA_SIZE ) + MPC1000_PGM::PLAY_MODE_OFFSET;

                QByteArray playMode;
                playMode += envelopes.oneShotSettings.at( padNum ) ? (char) 0x0     // 0 - One shot is set
                                                                   : quint8( 1 );   // 1 - One shot is not set

                pgmData.replace( pos, 1, playMode );
            }

            // Add attack
            {
                const int pos = MPC1000_PGM::PAD_DATA_START + ( padNum * MPC1000_PGM::PAD_DATA_SIZE ) + MPC1000_PGM::ATTACK_OFFSET;

                QByteArray attack;
                attack += quint8( envelopes.attackValues.at( padNum ) * 100 );

                pgmData.replace( pos, 1, attack );
            }

            // Add decay
            {
                const int pos = MPC1000_PGM::PAD_DATA_START + ( padNum * MPC1000_PGM::PAD_DATA_SIZE ) + MPC1000_PGM::DECAY_OFFSET;

                QByteArray decay;
                decay += quint8( envelopes.releaseValues.at( padNum ) * 100 );

                pgmData.replace( pos, 1, decay );
            }

            // Add decay mode
            {
                const int pos = MPC1000_PGM::PAD_DATA_START + ( padNum * MPC1000_PGM::PAD_DATA_SIZE ) + MPC1000_PGM::DECAY_MODE_OFFSET;

                QByteArray decayMode;
                decayMode += (char) 0x0;

                pgmData.replace( pos, 1, decayMode );
            }

            // Add "pad" -> "MIDI note" mapping
            {
                const int pos = MPC1000_PGM::PAD_MIDI_DATA_START + padNum;

                QByteArray value;
                value += noteNum;

                pgmData.replace( pos, 1, value );
            }

            // Add "MIDI note" -> "pad" mapping
//.........这里部分代码省略.........
开发者ID:conradjones,项目名称:shuriken,代码行数:101,代码来源:akaifilehandler.cpp


示例18: d

QMimeMagicRule::QMimeMagicRule(const QString &typeStr,
                               const QByteArray &theValue,
                               const QString &offsets,
                               const QByteArray &theMask,
                               QString *errorString) :
    d(new QMimeMagicRulePrivate)
{
    d->value = theValue;
    d->mask = theMask;
    d->matchFunction = 0;

    d->type = QMimeMagicRule::type(typeStr.toLatin1());
    if (d->type == Invalid) {
        *errorString = QStringLiteral("Type %s is not supported").arg(typeStr);
    }

    // Parse for offset as "1" or "1:10"
    const int colonIndex = offsets.indexOf(QLatin1Char(':'));
    const QString startPosStr = colonIndex == -1 ? offsets : offsets.mid(0, colonIndex);
    const QString endPosStr   = colonIndex == -1 ? offsets : offsets.mid(colonIndex + 1);
    if (!QMimeTypeParserBase::parseNumber(startPosStr, &d->startPos, errorString) ||
        !QMimeTypeParserBase::parseNumber(endPosStr, &d->endPos, errorString)) {
        d->type = Invalid;
        return;
    }

    if (d->value.isEmpty()) {
        d->type = Invalid;
        if (errorString)
            *errorString = QLatin1String("Invalid empty magic rule value");
        return;
    }

    if (d->type >= Host16 && d->type <= Byte) {
        bool ok;
        d->number = d->value.toUInt(&ok, 0); // autodetect
        if (!ok) {
            d->type = Invalid;
            if (errorString)
                *errorString = QString::fromLatin1("Invalid magic rule value \"%1\"").arg(
                        QString::fromLatin1(d->value));
            return;
        }
        d->numberMask = !d->mask.isEmpty() ? d->mask.toUInt(&ok, 0) : 0; // autodetect
    }

    switch (d->type) {
    case String:
        d->pattern = makePattern(d->value);
        d->pattern.squeeze();
        if (!d->mask.isEmpty()) {
            if (d->mask.size() < 4 || !d->mask.startsWith("0x")) {
                d->type = Invalid;
                if (errorString)
                    *errorString = QString::fromLatin1("Invalid magic rule mask \"%1\"").arg(
                            QString::fromLatin1(d->mask));
                return;
            }
            const QByteArray &tempMask = QByteArray::fromHex(QByteArray::fromRawData(
                                                     d->mask.constData() + 2, d->mask.size() - 2));
            if (tempMask.size() != d->pattern.size()) {
                d->type = Invalid;
                if (errorString)
                    *errorString = QString::fromLatin1("Invalid magic rule mask size \"%1\"").arg(
                            QString::fromLatin1(d->mask));
                return;
            }
            d->mask = tempMask;
        } else {
            d->mask.fill(char(-1), d->pattern.size());
        }
        d->mask.squeeze();
        d->matchFunction = matchString;
        break;
    case Byte:
        if (d->number <= quint8(-1)) {
            if (d->numberMask == 0)
                d->numberMask = quint8(-1);
            d->matchFunction = matchNumber<quint8>;
        }
        break;
    case Big16:
    case Host16:
    case Little16:
        if (d->number <= quint16(-1)) {
            d->number = d->type == Little16 ? qFromLittleEndian<quint16>(d->number) : qFromBigEndian<quint16>(d->number);
            if (d->numberMask == 0)
                d->numberMask = quint16(-1);
            d->matchFunction = matchNumber<quint16>;
        }
        break;
    case Big32:
    case Host32:
    case Little32:
        if (d->number <= quint32(-1)) {
            d->number = d->type == Little32 ? qFromLittleEndian<quint32>(d->number) : qFromBigEndian<quint32>(d->number);
            if (d->numberMask == 0)
                d->numberMask = quint32(-1);
            d->matchFunction = matchNumber<quint32>;
        }
//.........这里部分代码省略.........
开发者ID:2gis,项目名称:2gisqt5android,代码行数:101,代码来源:qmimemagicrule.cpp


示例19: qDebug

/*!
  Creates the RFCOMM server and starts to listen for the incoming connections.
  Returns true if the server was started successfully, false otherwise.
*/
bool BluetoothServer::startServer()
{
    qDebug() << "Bluetoothserver::startServer(): =>";

    if (mServiceUuid == 0) {
        qDebug() << "BluetoothServer::startServer(): No service information set!";
        return false;
    }

    if (mRfcommServer) {
        qDebug() << "BluetoothServer::startServer(): Already started!";
        return false;
    }

    mSockets.clear();
    mLastErrorString = "";

    Common::resetBuffer();

    qDebug() << "Bluetoothserver::startServer(): Creating a server";
    // Create the server
    mRfcommServer = new QRfcommServer(this);
    connect(mRfcommServer, SIGNAL(newConnection()), this, SLOT(onNewConnection()));
    qDebug() << "Bluetoothserver::startServer(): Server created";

#ifdef Q_WS_HARMATTAN
    if (!mRfcommServer->listen(QBluetoothAddress(), 11))
#else
    if (!mRfcommServer->listen())
#endif
    {
        qDebug() << "BluetoothServer::startServer():"
                 << "Error: mRfcommServer is not listening!";
        delete mRfcommServer;
        mRfcommServer = 0;
        return false;
    }

    qDebug() << "BluetoothServer::startServer(): Server is using port"
             << mRfcommServer->serverPort();

    mServiceInfo.setAttribute(QBluetoothServiceInfo::ServiceRecordHandle, (uint)0x00010010);

#if !defined(Q_WS_SIMULATOR) && !defined(DISABLE_BLUETOOTH)
    // Class Uuuid must contain at least one entry
    QBluetoothServiceInfo::Sequence classId;
    classId << QVariant::fromValue(QBluetoothUuid(mServiceUuid));
    mServiceInfo.setAttribute(QBluetoothServiceInfo::ServiceClassIds, classId);
#endif

    mServiceInfo.setServiceAvailability(1);

    qDebug() << "BluetoothServer::startServer(): Using service info:"
             << mServiceInfo.attribute(QBluetoothServiceInfo::ServiceName).toString()
             << mServiceInfo.attribute(QBluetoothServiceInfo::ServiceProvider).toString();

    // Set the Service UUID set
    mServiceInfo.setServiceUuid(QBluetoothUuid(mServiceUuid));

    // Set service discoverability
    mServiceInfo.setAttribute(QBluetoothServiceInfo::BrowseGroupList,
                              QBluetoothUuid(QBluetoothUuid::PublicBrowseGroup));

#if !defined(Q_WS_SIMULATOR) && !defined(DISABLE_BLUETOOTH)
    // Protocol descriptor list
    QBluetoothServiceInfo::Sequence protocolDescriptorList;
    QBluetoothServiceInfo::Sequence protocol;

    protocol.clear();
    protocol << QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::Rfcomm))
             << QVariant::fromValue(quint8(mRfcommServer->serverPort()));
    protocolDescriptorList.append(QVariant::fromValue(protocol));

    mServiceInfo.setAttribute(QBluetoothServiceInfo::ProtocolDescriptorList,
                              protocolDescriptorList);
#endif

    // Register the service
    if (mServiceInfo.registerService()) {
        qDebug() << "BluetoothServer::startServer():"
                 << "Service registered. Waiting for clients to connect.";
    }
    else {
        qDebug() << "BluetoothServer::startServer():"
                 << "Failed to register the service!";
        delete mRfcommServer;
        mRfcommServer = 0;
        return false;
    }


    qDebug() << "Bluetoothserver::startServer(): <=";


    return true;
}
开发者ID:ltomuta,项目名称:connectivity-qml-plugin,代码行数:100,代码来源:bluetoothserver.cpp


示例20: registeredChanged

void QDeclarativeBluetoothService::setRegistered(bool registered)
{

    d->m_needsRegistration = registered;

    if(!d->m_componentComplete){
        return;
    }

    if(!registered) {
        if(!d->m_service)
            return;
        d->m_service->unregisterService();
        emit registeredChanged();
    }

    if(!d->m_service){
        d->m_service = new QBluetoothServiceInfo();
    }


    delete d->m_listen;
    d->m_listen = 0;

    d->listen();
    connect(d->m_listen, SIGNAL(newConnection()), this, SLOT(new_connection()));


    d->m_service->setAttribute(QBluetoothServiceInfo::ServiceRecordHandle, (uint)0x00010010);

//    QBluetoothServiceInfo::Sequence classId;
////    classId << QVariant::fromVhttp://theunderstatement.com/alue(QBluetoothUuid(serviceUuid));
//    classId << QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::SerialPort));
//    d->m_service->setAttribute(QBluetoothServiceInfo::ServiceClassIds, classId);

    d->m_service->setAttribute(QBluetoothServiceInfo::ServiceName, d->m_name);
    d->m_service->setAttribute(QBluetoothServiceInfo::ServiceDescription,
                             d->m_description);

    d->m_service->setServiceUuid(QBluetoothUuid(d->m_uuid));

    qDebug() << "name/uuid" << d->m_name << d->m_uuid << d->m_port;

    d->m_service->setAttribute(QBluetoothServiceInfo::BrowseGroupList,
                             QBluetoothUuid(QBluetoothUuid::PublicBrowseGroup));

    QBluetoothServiceInfo::Sequence protocolDescriptorList;
    QBluetoothServiceInfo::Sequence protocol;

    qDebug() << "Port" << d->m_port;

    if(d->m_protocol == "l2cap"){
        protocol << QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::L2cap))
                 << QVariant::fromValue(quint16(d->m_port));
        protocolDescriptorList.append(QVariant::fromValue(protocol));
    }
    else if(d->m_protocol == "rfcomm"){
        protocol << QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::Rfcomm))
                 << QVariant::fromValue(quint8(d->m_port));
        protocolDescriptorList.append(QVariant::fromValue(protocol));
    }
    else {
        qWarning() << "No protocol specified for bluetooth service";
    }
    d->m_service->setAttribute(QBluetoothServiceInfo::ProtocolDescriptorList,
                             protocolDescriptorList);

    if(d->m_service->registerService()) {
        qDebug() << "registered";
        emit registeredChanged();
    }
    else {
        qDebug() << "Failed";
    }
}
开发者ID:KDE,项目名称:android-qt-mobility,代码行数:75,代码来源:qdeclarativebluetoothservice.cpp



注:本文中的quint8函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ quitGame函数代码示例发布时间:2022-05-30
下一篇:
C++ quint32函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap