예제 #1
0
// Merge a subelement format into an existing message format
void UiStyle::mergeSubElementFormat(QTextCharFormat& fmt, quint32 ftype, quint64 label) const {
  quint64 key = ftype | label;
  fmt.merge(format(key & Q_UINT64_C(0x0000ffffffffff00)));  // label + subelement
  fmt.merge(format(key & Q_UINT64_C(0x0000ffffffffffff)));  // label + subelement + msgtype
  fmt.merge(format(key & Q_UINT64_C(0xffffffffffffff00)));  // label + subelement + nickhash
  fmt.merge(format(key & Q_UINT64_C(0xffffffffffffffff)));  // label + subelement + nickhash + msgtype
}
QT_BEGIN_NAMESPACE
    
// ----------------------------------------------------------------------------
QLongLongValidator::QLongLongValidator(QObject * parent)
    : QValidator(parent),
      b(Q_UINT64_C(0x8000000000000000)), t(Q_UINT64_C(0x7FFFFFFFFFFFFFFF))
{
}
void tst_QBluetoothAddress::tst_comparison_data()
{
    QTest::addColumn<QBluetoothAddress>("address1");
    QTest::addColumn<QBluetoothAddress>("address2");
    QTest::addColumn<bool>("result");

    QTest::newRow("invalid == invalid") << QBluetoothAddress() << QBluetoothAddress() << true;
    QTest::newRow("valid != invalid") << QBluetoothAddress(Q_UINT64_C(0x112233445566)) << QBluetoothAddress() << false;
    QTest::newRow("valid == valid") << QBluetoothAddress(Q_UINT64_C(0x112233445566)) << QBluetoothAddress(Q_UINT64_C(0x112233445566)) << true;
}
void tst_QBluetoothAddress::tst_construction_data()
{
    QTest::addColumn<quint64>("addressUInt");
    QTest::addColumn<QString>("addressS12");
    QTest::addColumn<QString>("addressS17");

    QTest::newRow("11:22:33:44:55:66") << Q_UINT64_C(0x112233445566) << QString("112233445566") << QString("11:22:33:44:55:66");
    QTest::newRow("AA:BB:CC:DD:EE:FF") << Q_UINT64_C(0xAABBCCDDEEFF) << QString("AABBCCDDEEFF") << QString("AA:BB:CC:DD:EE:FF");
    QTest::newRow("aa:bb:cc:dd:ee:ff") << Q_UINT64_C(0xAABBCCDDEEFF) << QString("aabbccddeeff") << QString("AA:BB:CC:DD:EE:FF");
    QTest::newRow("FF:FF:FF:FF:FF:FF") << Q_UINT64_C(0xFFFFFFFFFFFF) << QString("FFFFFFFFFFFF") << QString("FF:FF:FF:FF:FF:FF");
}
void tst_QBluetoothAddress::tst_lessThan_data()
{
    QTest::addColumn<QBluetoothAddress>("address1");
    QTest::addColumn<QBluetoothAddress>("address2");
    QTest::addColumn<bool>("result");

    QTest::newRow("invalid < invalid") << QBluetoothAddress() << QBluetoothAddress() << false;
    QTest::newRow("invalid < valid") << QBluetoothAddress() << QBluetoothAddress(Q_UINT64_C(0x112233445566)) << true;
    QTest::newRow("valid < invalid") << QBluetoothAddress(Q_UINT64_C(0x112233445566)) << QBluetoothAddress() << false;
    QTest::newRow("valid < valid") << QBluetoothAddress(Q_UINT64_C(0x112233445566)) << QBluetoothAddress(Q_UINT64_C(0xAABBCCDDEEFF)) << true;
    QTest::newRow("valid < valid") << QBluetoothAddress(Q_UINT64_C(0xAABBCCDDEEFF)) << QBluetoothAddress(Q_UINT64_C(0x112233445566)) << false;
}
void tst_QBluetoothAddress::tst_assignment()
{
    QBluetoothAddress address(Q_UINT64_C(0x112233445566));

    {
        QBluetoothAddress copy = address;

        QCOMPARE(address.toUInt64(), copy.toUInt64());
    }

    {
        QBluetoothAddress copy1;
        QBluetoothAddress copy2;

        QVERIFY(copy1.isNull());
        QVERIFY(copy2.isNull());

        copy1 = copy2 = address;

        QVERIFY(!copy1.isNull());
        QVERIFY(!copy2.isNull());

        QVERIFY(address.toUInt64() == copy1.toUInt64());
        QVERIFY(address.toUInt64() == copy2.toUInt64());

        copy1.clear();
        QVERIFY(copy1.isNull());
        QVERIFY2(copy1 != address, "Verify that copy1 is a copy of address, the d_ptr are being copied");
    }
}
void
SpotifyIODevice::setDurationMSec( quint32 msec )
{
    quint32 numSamples = ( (quint64)msec * Q_UINT64_C(44100) ) / (quint64)1000;
    quint32 dataChunkSize = numSamples * 2 * 2;
//    qDebug() << "Writing number of samples and data chunk size:" << numSamples << dataChunkSize << "and msec:" << msec;
    // got samples, we can make the header now
    m_header += (const char* )"RIFF";
    quint32 data = 36 + dataChunkSize;
    m_header.append((char*)&data, 4); // The file size LESS the size of the "RIFF" description (4 bytes) and the size of file description (4 bytes). This is usually file size - 8, or 36 + subchunk2 size
    m_header += (const char* )"WAVE"; //The ascii text string "RIFF". mmsystem.h provides the macro FOURCC_RIFF for this purpose.
    /// fmt subchunk
    m_header += (const char* )"fmt "; //
    data = 16;
    m_header.append((char*)&data, 4); // The size of the WAVE type format (2 bytes) + mono/stereo flag (2 bytes) + sample rate (4 bytes) + bytes/sec (4 bytes) + block alignment (2 bytes) + bits/sample (2 bytes). This is usually 16 (or 0x10).
    data = 1;
    m_header.append((char*)&data, 2); // Type of WAVE format. This is a PCM header, or a value of 0x01.
    data = 2;
    m_header.append((char*)&data, 2); // mono (0x01) or stereo (0x02)
    data = 44100;
    m_header.append((char*)&data, 4); // Sample rate.
    data = 44100 * 2 * 16/8;
    m_header.append((char*)&data, 4); // Bytes/Second == SampleRate * NumChannels * BitsPerSample/8
    data = 2 * 16/8;
    m_header.append((char*)&data , 2); // Data block size (bytes) == NumChannels * BitsPerSample/8
    data = 16;
    m_header.append((char*)&data, 2); // bits per sample
    /// data subchunk
    m_header += "data" ;
    m_header.append((char*)&dataChunkSize, 4); // NumSamples * NumChannels * BitsPerSample/8
}
예제 #8
0
void DBParamDlg::accept()
{
  if(dbReteFlg->isChecked()) {
    if(!openDBRemoto())
      return;
  }

  QSettings iniSettings(nomeFile,QSettings::IniFormat);
  if(dbReteFlg->isChecked()) {
    iniSettings.setValue("DATABASE/DBLOCALE","0");
  } else {
    iniSettings.setValue("DATABASE/DBLOCALE","1");
  }
  iniSettings.setValue("DATABASE/DBSERVER",dbServerTxt->text());
  iniSettings.setValue("DATABASE/DBPORT",dbPortaTxt->text());
  iniSettings.setValue("DATABASE/DBLOCALEPATH",dbLocalePathTxt->text());
  iniSettings.setValue("DATABASE/DBNOME",dbNomeTxt->text());
  iniSettings.setValue("DATABASE/DBUTENTE",dbUtenteTxt->text());

  SimpleCrypt* cifratore=new SimpleCrypt(Q_UINT64_C(0x529c2c1779964f9d));
  iniSettings.setValue("DATABASE/DBPASSWORD",cifratore->encryptToString(dbPasswordTxt->text()));
  delete cifratore;

  iniSettings.setValue("CONFIGURAZIONE/IDCASSA",idCassa.toString());
  iniSettings.sync();

  QDialog::accept();
}
예제 #9
0
void tst_QAtomicIntegerXX::fetchAndXor()
{
    QFETCH(LargeInt, value);
    QAtomicInteger<T> atomic(value);

    T zero = 0;
    T pattern = T(Q_UINT64_C(0xcccccccccccccccc));
    T minusOne = T(~0);

    QCOMPARE(atomic.fetchAndXorRelaxed(zero), T(value));
    QCOMPARE(atomic.load(), T(value));
    QCOMPARE(atomic.fetchAndXorRelaxed(pattern), T(value));
    QCOMPARE(atomic.load(), T(value ^ pattern));
    QCOMPARE(atomic.fetchAndXorRelaxed(pattern), T(value ^ pattern));
    QCOMPARE(atomic.load(), T(value));
    QCOMPARE(atomic.fetchAndXorRelaxed(minusOne), T(value));
    QCOMPARE(atomic.load(), T(~value));
    QCOMPARE(atomic.fetchAndXorRelaxed(minusOne), T(~value));
    QCOMPARE(atomic.load(), T(value));

    QCOMPARE(atomic.fetchAndXorAcquire(zero), T(value));
    QCOMPARE(atomic.load(), T(value));
    QCOMPARE(atomic.fetchAndXorAcquire(pattern), T(value));
    QCOMPARE(atomic.load(), T(value ^ pattern));
    QCOMPARE(atomic.fetchAndXorAcquire(pattern), T(value ^ pattern));
    QCOMPARE(atomic.load(), T(value));
    QCOMPARE(atomic.fetchAndXorAcquire(minusOne), T(value));
    QCOMPARE(atomic.load(), T(~value));
    QCOMPARE(atomic.fetchAndXorAcquire(minusOne), T(~value));
    QCOMPARE(atomic.load(), T(value));

    QCOMPARE(atomic.fetchAndXorRelease(zero), T(value));
    QCOMPARE(atomic.load(), T(value));
    QCOMPARE(atomic.fetchAndXorRelease(pattern), T(value));
    QCOMPARE(atomic.load(), T(value ^ pattern));
    QCOMPARE(atomic.fetchAndXorRelease(pattern), T(value ^ pattern));
    QCOMPARE(atomic.load(), T(value));
    QCOMPARE(atomic.fetchAndXorRelease(minusOne), T(value));
    QCOMPARE(atomic.load(), T(~value));
    QCOMPARE(atomic.fetchAndXorRelease(minusOne), T(~value));
    QCOMPARE(atomic.load(), T(value));

    QCOMPARE(atomic.fetchAndXorOrdered(zero), T(value));
    QCOMPARE(atomic.load(), T(value));
    QCOMPARE(atomic.fetchAndXorOrdered(pattern), T(value));
    QCOMPARE(atomic.load(), T(value ^ pattern));
    QCOMPARE(atomic.fetchAndXorOrdered(pattern), T(value ^ pattern));
    QCOMPARE(atomic.load(), T(value));
    QCOMPARE(atomic.fetchAndXorOrdered(minusOne), T(value));
    QCOMPARE(atomic.load(), T(~value));
    QCOMPARE(atomic.fetchAndXorOrdered(minusOne), T(~value));
    QCOMPARE(atomic.load(), T(value));

    QCOMPARE(atomic ^= zero, T(value));
    QCOMPARE(atomic ^= pattern, T(value ^ pattern));
    QCOMPARE(atomic ^= pattern, T(value));
    QCOMPARE(atomic ^= minusOne, T(~value));
    QCOMPARE(atomic ^= minusOne, T(value));
}
예제 #10
0
quint64 ChatUnit::sendMessage(const QString &text)
{
	Message message(text);
	message.setIncoming(false);
	message.setChatUnit(this);
	bool ok = sendMessage(message);
	return ok ? message.id() : Q_UINT64_C(~0);
}
예제 #11
0
bool UIWizardCloneVD::copyVirtualDisk()
{
    /* Gather attributes: */
    CMedium sourceVirtualDisk = field("sourceVirtualDisk").value<CMedium>();
    CMediumFormat mediumFormat = field("mediumFormat").value<CMediumFormat>();
    qulonglong uVariant = field("mediumVariant").toULongLong();
    QString strMediumPath = field("mediumPath").toString();
    qulonglong uSize = field("mediumSize").toULongLong();
    /* Check attributes: */
    AssertReturn(!strMediumPath.isNull(), false);
    AssertReturn(uSize > 0, false);

    /* Get VBox object: */
    CVirtualBox vbox = vboxGlobal().virtualBox();

    /* Create new virtual hard-disk: */
    CMedium virtualDisk = vbox.CreateMedium(mediumFormat.GetName(), strMediumPath, KAccessMode_ReadWrite, KDeviceType_HardDisk);
    if (!vbox.isOk())
    {
        msgCenter().cannotCreateHardDiskStorage(vbox, strMediumPath, this);
        return false;
    }

    /* Compose medium-variant: */
    QVector<KMediumVariant> variants(sizeof(qulonglong)*8);
    for (int i = 0; i < variants.size(); ++i)
    {
        qulonglong temp = uVariant;
        temp &= Q_UINT64_C(1) << i;
        variants[i] = (KMediumVariant)temp;
    }

    /* Copy existing virtual-disk to the new virtual-disk: */
    CProgress progress = sourceVirtualDisk.CloneTo(virtualDisk, variants, CMedium());
    if (!sourceVirtualDisk.isOk())
    {
        msgCenter().cannotCreateHardDiskStorage(sourceVirtualDisk, strMediumPath, this);
        return false;
    }

    /* Show creation progress: */
    msgCenter().showModalProgressDialog(progress, windowTitle(), ":/progress_media_create_90px.png", this);
    if (progress.GetCanceled())
        return false;
    if (!progress.isOk() || progress.GetResultCode() != 0)
    {
        msgCenter().cannotCreateHardDiskStorage(progress, strMediumPath, this);
        return false;
    }

    /* Remember created virtual-disk: */
    m_virtualDisk = virtualDisk;

    /* Just close the created medium, it is not necessary yet: */
    m_virtualDisk.Close();

    return true;
}
예제 #12
0
파일: varint.cpp 프로젝트: pcolby/bipolar
QVariant parseUnsignedVarint(QIODevice &data)
{
    quint64 result = 0;
    for (uchar byte = 0xFF, index = 0; byte >= 0x80; ++index) {
        const QByteArray array = data.read(1);
        if (array.isEmpty()) return QVariant();
        byte = static_cast<uchar>(array.at(0));
        result += (byte & Q_UINT64_C(0x7F)) << (7 * index);
    }
    return result;
}
예제 #13
0
// NOTE: This and the following functions are intimately tied to the values in FormatType. Don't change this
//       until you _really_ know what you do!
QTextCharFormat UiStyle::format(quint32 ftype, quint32 label_) const {
  if(ftype == Invalid)
    return QTextCharFormat();

  quint64 label = (quint64)label_ << 32;

  // check if we have exactly this format readily cached already
  QTextCharFormat fmt = cachedFormat(ftype, label_);
  if(fmt.properties().count())
    return fmt;

  mergeFormat(fmt, ftype, label & Q_UINT64_C(0xffff000000000000));

  for(quint64 mask = Q_UINT64_C(0x0000000100000000); mask <= (quint64)Selected << 32; mask <<=1) {
    if(label & mask)
      mergeFormat(fmt, ftype, mask | Q_UINT64_C(0xffff000000000000));
  }

  setCachedFormat(fmt, ftype, label_);
  return fmt;
}
예제 #14
0
void tst_QNumeric::floatDistance_double_data()
{
    QTest::addColumn<double>("val1");
    QTest::addColumn<double>("val2");
    QTest::addColumn<quint64>("expectedDistance");

    // exponent: 11 bits
    // mantissa: 52 bits
    const quint64 number_of_denormals = (Q_UINT64_C(1) << 52) - 1;  // Set to 0 if denormals are not included

    quint64 _0_to_1 = (Q_UINT64_C(1) << 52) * ((1 << (11-1)) - 2) + 1 + number_of_denormals; // We need +1 to include the 0
    quint64 _1_to_2 = Q_UINT64_C(1) << 52;

    // We don't need +1 because DBL_MAX has all bits set in the mantissa. (Thus mantissa
    // have not wrapped back to 0, which would be the case for 1 in _0_to_1
    quint64 _0_to_DBL_MAX = quint64((Q_UINT64_C(1) << 52) * ((1 << 11) - 2)) + number_of_denormals;

    quint64 _0_to_DBL_MIN = 1 + number_of_denormals;
    QTest::newRow("[0,DBL_MIN]") << 0.0 << DBL_MIN << _0_to_DBL_MIN;
    QTest::newRow("[0,DBL_MAX]") << 0.0 << DBL_MAX << _0_to_DBL_MAX;
    QTest::newRow("[1,1.5]") << 1.0 << 1.5 << (Q_UINT64_C(1) << 51);
    QTest::newRow("[0,1]") << 0.0 << 1.0 << _0_to_1;
    QTest::newRow("[0.5,1]") << 0.5 << 1.0 << (Q_UINT64_C(1) << 52);
    QTest::newRow("[1,2]") << 1.0 << 2.0 << _1_to_2;
    QTest::newRow("[-1,+1]") << -1.0 << +1.0 << 2 * _0_to_1;
    QTest::newRow("[-1,0]") << -1.0 << 0.0 << _0_to_1;
    QTest::newRow("[-1,DBL_MAX]") << -1.0 << DBL_MAX << _0_to_1 + _0_to_DBL_MAX;
    QTest::newRow("[-2,-1") << -2.0 << -1.0 << _1_to_2;
    QTest::newRow("[-1,-2") << -1.0 << -2.0 << _1_to_2;
    QTest::newRow("[DBL_MIN,DBL_MAX]") << DBL_MIN << DBL_MAX << _0_to_DBL_MAX - _0_to_DBL_MIN;
    QTest::newRow("[-DBL_MAX,DBL_MAX]") << -DBL_MAX << DBL_MAX << (2*_0_to_DBL_MAX);
    double denormal = DBL_MIN;
    denormal/=2.0;
    QTest::newRow("denormal") << 0.0 << denormal << _0_to_DBL_MIN/2;
}
예제 #15
0
    int wait_relative(unsigned long time)
    {
        timespec ti;
#ifdef Q_OS_ANDROID
        if (local_cond_timedwait_relative) {
            ti.tv_sec = time / 1000;
            ti.tv_nsec = time % 1000 * Q_UINT64_C(1000) * 1000;
            return local_cond_timedwait_relative(&cond, &mutex, &ti);
        }
#endif
        qt_abstime_for_timeout(&ti, time);
        return pthread_cond_timedwait(&cond, &mutex, &ti);
    }
예제 #16
0
	void test_appendNumber()
	{
		QByteArray ba;

		ba = QByteArray(); Pillow::ByteArrayHelpers::appendNumber<int, 10>(ba, 0);
		QCOMPARE(ba, QByteArray("0"));
		ba = QByteArray(); Pillow::ByteArrayHelpers::appendNumber<int, 10>(ba, Q_UINT64_C(9876));
		QCOMPARE(ba, QByteArray("9876"));
		ba = QByteArray(); Pillow::ByteArrayHelpers::appendNumber<quint64, 10>(ba, Q_UINT64_C(12345678901234));
		QCOMPARE(ba, QByteArray("12345678901234"));
		ba = QByteArray(); Pillow::ByteArrayHelpers::appendNumber<int, 10>(ba, -23456);
		QCOMPARE(ba, QByteArray("-23456"));
		ba = QByteArray(); Pillow::ByteArrayHelpers::appendNumber<qint64, 10>(ba, Q_INT64_C(-12345678901234));
		QCOMPARE(ba, QByteArray("-12345678901234"));

		ba = QByteArray();
		ba.reserve(1024);
		Pillow::ByteArrayHelpers::appendNumber<int, 10>(ba, 0);
		QCOMPARE(ba, QByteArray("0"));
		Pillow::ByteArrayHelpers::appendNumber<int, 10>(ba, Q_UINT64_C(9876));
		QCOMPARE(ba, QByteArray("09876"));
		Pillow::ByteArrayHelpers::appendNumber<quint64, 10>(ba, Q_UINT64_C(12345678901234));
		QCOMPARE(ba, QByteArray("0987612345678901234"));
		Pillow::ByteArrayHelpers::appendNumber<int, 10>(ba, -23456);
		QCOMPARE(ba, QByteArray("0987612345678901234-23456"));
		Pillow::ByteArrayHelpers::appendNumber<qint64, 10>(ba, Q_INT64_C(-12345678901234));
		QCOMPARE(ba, QByteArray("0987612345678901234-23456-12345678901234"));

		ba = QByteArray();
		Pillow::ByteArrayHelpers::appendNumber<int, 16>(ba, 15);
		QCOMPARE(ba, QByteArray("f"));
		Pillow::ByteArrayHelpers::appendNumber<int, 16>(ba, 16);
		QCOMPARE(ba, QByteArray("f10"));
		Pillow::ByteArrayHelpers::appendNumber<int, 16>(ba, 255);
		QCOMPARE(ba, QByteArray("f10ff"));
		Pillow::ByteArrayHelpers::appendNumber<int, 16>(ba, 256);
		QCOMPARE(ba, QByteArray("f10ff100"));
	}
예제 #17
0
void Sudoku::cargarPartida(){
    SimpleCrypt crypto(Q_UINT64_C(0x0c2ad4a4acb9f023));
            QFile archivo(":/recursos/partida.txt");
            if (archivo.exists(":/recursos/partida.txt")){
                archivo.open(QFile::ReadOnly);
                QTextStream stream(&archivo);
                QString crypt=stream.readAll();
                QString linea=crypto.decryptToString(crypt);
                pasarStringAMatriz(linea);
                pasarMatrizAUI();
            } else {
                QMessageBox::critical(this,"Error","No existe el archivo ");
            }
            archivo.close();
}
예제 #18
0
void tst_QByteArray::number()
{
    QCOMPARE(QString(QByteArray::number((quint64) 0)),
	    QString(QByteArray("0")));
    QCOMPARE(QString(QByteArray::number(Q_UINT64_C(0xFFFFFFFFFFFFFFFF))),
	    QString(QByteArray("18446744073709551615")));
    QCOMPARE(QString(QByteArray::number(Q_INT64_C(0xFFFFFFFFFFFFFFFF))),
	    QString(QByteArray("-1")));
    QCOMPARE(QString(QByteArray::number(qint64(0))),
	    QString(QByteArray("0")));
    QCOMPARE(QString(QByteArray::number(Q_INT64_C(0x7FFFFFFFFFFFFFFF))),
	    QString(QByteArray("9223372036854775807")));
    QCOMPARE(QString(QByteArray::number(Q_INT64_C(0x8000000000000000))),
	    QString(QByteArray("-9223372036854775808")));
}
예제 #19
0
파일: TestGui.cpp 프로젝트: debfx/keepassx
void TestGui::testDatabaseSettings()
{
    triggerAction("actionChangeDatabaseSettings");
    QWidget* dbSettingsWidget = m_dbWidget->findChild<QWidget*>("databaseSettingsWidget");
    QSpinBox* transformRoundsSpinBox = dbSettingsWidget->findChild<QSpinBox*>("transformRoundsSpinBox");
    transformRoundsSpinBox->setValue(100);
    QTest::keyClick(transformRoundsSpinBox, Qt::Key_Enter);
    // wait for modified timer
    QTRY_COMPARE(m_tabWidget->tabText(m_tabWidget->currentIndex()), QString("Save*"));
    QCOMPARE(m_db->transformRounds(), Q_UINT64_C(100));

    triggerAction("actionDatabaseSave");
    QCOMPARE(m_tabWidget->tabText(m_tabWidget->currentIndex()), QString("Save"));

    checkDatabase();
}
예제 #20
0
파일: chatchannel.cpp 프로젝트: xujb/qutim
void ChatChannel::markRead(quint64 id)
{
	if (id == Q_UINT64_C(0xffffffffffffffff)) {
		m_unread.clear();
		emit unreadChanged(m_unread);
		emit unreadCountChanged(m_unread.count());
		return;
	}
	for (int i = 0; i < m_unread.size(); ++i) {
		if (m_unread.at(i).id() == id) {
			m_unread.removeAt(i);
			emit unreadChanged(m_unread);
			emit unreadCountChanged(m_unread.count());
			return;
		}
	}
}
예제 #21
0
파일: settings.cpp 프로젝트: bochi/kueued
QString Settings::bugzillaPassword()
{
    // I know this is not really secure, but how would one hide the 
    // encryption key in OSS software? :P
    // At least it's not in the config file in cleartext...
    
    QSettings settings( "/etc/kueued.conf", QSettings::NativeFormat);
    SimpleCrypt crypto( Q_UINT64_C( 0424632454124622 ) );
    QString pw;
    
    if ( !settings.value( "bugzillaPassword" ).toString().isEmpty() )
    {
        pw = crypto.decryptToString( settings.value( "bugzillaPassword" ).toString() );
    }

    return pw;
}
예제 #22
0
void qt_abstime_for_timeout(timespec *ts, int timeout)
{
#ifdef Q_OS_MAC
    // on Mac, qt_gettime() (on qelapsedtimer_mac.cpp) returns ticks related to the Mach absolute time
    // that doesn't work with pthread
    // Mac also doesn't have clock_gettime
    struct timeval tv;
    gettimeofday(&tv, 0);
    ts->tv_sec = tv.tv_sec;
    ts->tv_nsec = tv.tv_usec * 1000;
#else
    *ts = qt_gettime();
#endif

    ts->tv_sec += timeout / 1000;
    ts->tv_nsec += timeout % 1000 * Q_UINT64_C(1000) * 1000;
    normalizedTimespec(*ts);
}
예제 #23
0
void Sudoku::on_actionGuardar_partida_triggered()
{
    SimpleCrypt crypto(Q_UINT64_C(0x0c2ad4a4acb9f023));
    if (QMessageBox::Yes == QMessageBox::question(this, "Guardar", "¿Desea guardar la partida actual?", QMessageBox::Yes|QMessageBox::No)){
        pasarUIAMatriz();
        QString linea=pasarMatrizAString();
        QString crypted=crypto.encryptToString(linea);
        QFile archivo(":/recursos/partida.txt");
        if ( !archivo.open(QIODevice::WriteOnly)) {
            QMessageBox::critical(this,"Error!","La partida no se pudo guardar");
        } else {
            QTextStream stream(&archivo);
            stream << crypted;
            stream.flush();
            QMessageBox::information(this,"Guardado!","La partida se ha guardado con éxito");
        }
    }
}
예제 #24
0
quint64 UtilObject::processTime() {
	static char buffer[BUFSIZ];
	static const quint64 tick = sysconf(_SC_CLK_TCK);
	int pid, ppid, pgrp, session, tty_nr, tpgid; uint flags;
	unsigned long int minflt, cminflt, majflt, cmajflt, utime, stime; char comm[256], state;
	const auto fd = open("/proc/self/stat", O_RDONLY);
	if (fd < 0)
		return 0;
	int len = ::read(fd, buffer, BUFSIZ);
	if (len > 0) {
		buffer[len] = '\0';
		len = sscanf(buffer
			, "%d %s %c %d %d %d %d %d %u %lu %lu %lu %lu %lu %lu"
			, &pid, comm, &state, &ppid, &pgrp, &session, &tty_nr, &tpgid, &flags
			, &minflt, &cminflt, &majflt, &cmajflt, &utime, &stime);
	}
	close(fd);
	return len > 0 ? quint64(utime + stime)*Q_UINT64_C(1000000)/tick : 0;
}
예제 #25
0
bool XmlParser::characters( const QString &ch )
{
    if ( important ) {
        if ( parsingUser ) {
            parseUserInfo(ch);
        } else {
            if ( currentTag == TAG_STATUS_ID && entry.id == Q_UINT64_C(0) ) {
                entry.id = ch.toULongLong();
            } else if ( currentTag == TAG_USER_TEXT && entry.text.isNull() ) {
                entry.originalText = ch;
                entry.originalText.replace( "&lt;", "<" );
                entry.originalText.replace( "&gt;", ">" );
                entry.text = textToHtml( entry.originalText );
            } else if ( currentTag == TAG_USER_TIMESTAMP && entry.timestamp.isNull() ) {
                entry.timestamp = toDateTime( ch ); //utc
                /* It's better to leave UTC timestamp alone; Additional member localTime is added to store local time when
         user's system supports timezones. */
                entry.localTime = entry.timestamp.addSecs( timeShift ); //now - utc
            } else if ( currentTag == TAG_INREPLYTO_STATUS_ID && entry.inReplyToStatusId == 0) {
                if( !ch.trimmed().isEmpty() ) {
                    /* In reply to status id exists and is not empty; Hack for dealing with tags that are opened and closed
           at the same time, e.g. <in_reply_to_screen_name/>  */
                    entry.hasInReplyToStatusId = true;
                    entry.inReplyToStatusId = ch.toULongLong();
                }
            } else if ( currentTag == TAG_INREPLYTO_SCREEN_NAME && entry.hasInReplyToStatusId ) {
                /* When hasInReplyToStatusId is true, inReplyToScreenName should be present, but it won't hurt to check it again
         just in case */
                if( !ch.trimmed().isEmpty() ) {
                    entry.inReplyToScreenName = ch;
                }
            } else if ( currentTag == TAG_FAVORITED && !favoritedSet ) {
                if ( ch.compare("false") == 0 )
                    entry.favorited = false;
                else
                    entry.favorited = true;
                favoritedSet = true;
            }
        }
    }

    return true;
}
예제 #26
0
bool XmlParserDirectMsg::characters( const QString &ch )
{
    if ( important ) {
        if (parsingSender)
            parseUserInfo(ch);
        else {
            if ( currentTag == TAG_STATUS_ID && entry.id == Q_UINT64_C(0) ) {
                entry.id = ch.toULongLong();
            } else if ( currentTag == TAG_USER_TEXT && entry.text.isNull() ) {
                entry.originalText = ch;
                entry.text = textToHtml( ch );
            } else if ( currentTag == TAG_USER_TIMESTAMP && entry.timestamp.isNull() ) {
                entry.timestamp = toDateTime( ch );
                entry.localTime = entry.timestamp.addSecs( timeShift );
            }
        }
    }
    return true;
}
예제 #27
0
void ObjectsLocationTests::testLocation_data()
{
    QTest::addColumn<qulonglong>("timestamp");
    QTest::addColumn<float>("latitude");
    QTest::addColumn<float>("longitude");
    QTest::addColumn<qint32>("accuracy");
    QTest::addColumn<qint32>("speed");
    QTest::addColumn<qint32>("heading");
    QTest::addColumn<qint32>("altitude");
    QTest::addColumn<qint32>("altitudeAccuracy");

    QTest::newRow("location1")
        << Q_UINT64_C(1340366314362)
        << (float) 49.6664083
        << (float) 17.1053383
        << 25
        << -1
        << -1
        << 0
        << -1;
}
예제 #28
0
void ObjectsLocationTests::testDefaultLocation_data()
{
    QTest::addColumn<qulonglong>("timestamp");
    QTest::addColumn<float>("latitude");
    QTest::addColumn<float>("longitude");
    QTest::addColumn<qint32>("accuracy");
    QTest::addColumn<qint32>("speed");
    QTest::addColumn<qint32>("heading");
    QTest::addColumn<qint32>("altitude");
    QTest::addColumn<qint32>("altitudeAccuracy");

    QTest::newRow("defaultLocation")
        << Q_UINT64_C(0)
        << (float) 91
        << (float) 181
        << -1
        << -1
        << -1
        << 0
        << -1;
}
예제 #29
0
void DBParamDlg::setNomeFile(const QString val) {

  nomeFile=val;
  QString dbLocalePath=QString("%1/GCAS.fbd").arg(QCoreApplication::applicationDirPath());
  QFile f(dbLocalePath);
  dbLocalePathTxt->setText(f.fileName());

  QFile iniFile(nomeFile);
  if (iniFile.exists()) {
    QSettings iniSettings(nomeFile,QSettings::IniFormat);
    dbUtenteTxt->setText(iniSettings.value("DATABASE/DBUTENTE").toString());
    SimpleCrypt* cifratore=new SimpleCrypt(Q_UINT64_C(0x529c2c1779964f9d));
    dbPasswordTxt->setText(cifratore->decryptToString(iniSettings.value("DATABASE/DBPASSWORD").toString()));
    dbServerTxt->setText(iniSettings.value("DATABASE/DBSERVER").toString());
    dbPortaTxt->setValue(iniSettings.value("DATABASE/DBPORT").toInt());
    dbLocalePathTxt->setText(iniSettings.value("DATABASE/DBLOCALEPATH").toString());
    if(!iniSettings.value("DATABASE/DBLOCALE").toBool())
      dbReteFlg->click();
    delete cifratore;
    idCassa=iniSettings.value("CONFIGURAZIONE/IDCASSA").toString();
  } else {
    idCassa=QUuid::createUuid();
  }
}
예제 #30
0
Query::Query()
{
	m_nMinimumSize = 0;
	m_nMaximumSize = Q_UINT64_C( 0xffffffffffffffff );
}