qint64 qHash(const QFileInfo& fi) { return qHash(fi.absoluteFilePath()); }
QList< GtfsRealtimeTripUpdate >* GtfsRealtimeTripUpdate::fromProtocolBuffer( const QByteArray &data ) { kDebug() << "GTFS-realtime trip updates received" << data.size(); GtfsRealtimeTripUpdates *tripUpdates = new GtfsRealtimeTripUpdates(); transit_realtime::FeedMessage feedMessage; if ( !feedMessage.ParsePartialFromArray(data.constData(), data.size()) ) { kDebug() << "Wrong protocol buffer format" << data.constData(); return tripUpdates; } if ( feedMessage.has_header() && feedMessage.header().gtfs_realtime_version() != "1" && feedMessage.header().gtfs_realtime_version() != "1.0" ) { kDebug() << "Unsupported GTFS-realtime version:" << feedMessage.header().gtfs_realtime_version().data(); return tripUpdates; } kDebug() << "entityCount:" << feedMessage.entity_size(); tripUpdates->reserve( feedMessage.entity_size() ); for ( int i = 0; i < feedMessage.entity_size(); ++i ) { GtfsRealtimeTripUpdate tripUpdate; const transit_realtime::TripUpdate newTripUpdate = feedMessage.entity( i ).trip_update(); const transit_realtime::TripDescriptor newTripDescriptor = newTripUpdate.trip(); tripUpdate.routeId = qHash( QString(newTripDescriptor.route_id().data()) ); tripUpdate.tripId = qHash( QString(newTripDescriptor.trip_id().data()) ); QDate startDate = QDate::fromString( newTripDescriptor.start_date().data() ); tripUpdate.startDateTime = QDateTime( startDate, QTime::fromString(newTripDescriptor.start_time().data()) ); tripUpdate.tripScheduleRelationship = static_cast<TripScheduleRelationship>( newTripDescriptor.schedule_relationship() ); for ( int n = 0; n < newTripUpdate.stop_time_update_size(); ++n ) { GtfsRealtimeStopTimeUpdate stopTimeUpdate; const transit_realtime::TripUpdate::StopTimeUpdate newStopTimeUpdate = newTripUpdate.stop_time_update( n ); stopTimeUpdate.stopId = qHash( QString(newStopTimeUpdate.stop_id().data()) ); stopTimeUpdate.stopSequence = newStopTimeUpdate.stop_sequence(); stopTimeUpdate.arrivalDelay = newStopTimeUpdate.arrival().has_delay() ? qint32(newStopTimeUpdate.arrival().delay()) : -1; stopTimeUpdate.arrivalTime = newStopTimeUpdate.arrival().has_time() ? QDateTime::fromTime_t(newStopTimeUpdate.arrival().time()) : QDateTime(); stopTimeUpdate.arrivalUncertainty = newStopTimeUpdate.arrival().uncertainty(); stopTimeUpdate.departureDelay = newStopTimeUpdate.departure().has_delay() ? qint32(newStopTimeUpdate.departure().delay()) : -1; stopTimeUpdate.departureTime = newStopTimeUpdate.departure().has_time() ? QDateTime::fromTime_t(newStopTimeUpdate.departure().time()) : QDateTime(); stopTimeUpdate.departureUncertainty = newStopTimeUpdate.departure().uncertainty(); stopTimeUpdate.scheduleRelationship = static_cast<GtfsRealtimeStopTimeUpdate::ScheduleRelationship>( newStopTimeUpdate.schedule_relationship() ); tripUpdate.stopTimeUpdates << stopTimeUpdate; } tripUpdates->append( tripUpdate ); } return tripUpdates; }
uint qHash(const QMessageId &id) { return qHash(id.toString()); }
void QNativeWifiEngine::scanComplete() { QMutexLocker locker(&mutex); if (!available()) { locker.unlock(); emit updateCompleted(); return; } // enumerate interfaces WLAN_INTERFACE_INFO_LIST *interfaceList; DWORD result = local_WlanEnumInterfaces(handle, 0, &interfaceList); if (result != ERROR_SUCCESS) { #ifdef BEARER_MANAGEMENT_DEBUG qDebug("%s: WlanEnumInterfaces failed with error %ld\n", __FUNCTION__, result); #endif locker.unlock(); emit updateCompleted(); return; } QStringList previous = accessPointConfigurations.keys(); for (unsigned int i = 0; i < interfaceList->dwNumberOfItems; ++i) { const WLAN_INTERFACE_INFO &interface = interfaceList->InterfaceInfo[i]; WLAN_AVAILABLE_NETWORK_LIST *networkList; result = local_WlanGetAvailableNetworkList(handle, &interface.InterfaceGuid, 3, 0, &networkList); if (result != ERROR_SUCCESS) { #ifdef BEARER_MANAGEMENT_DEBUG qDebug("%s: WlanGetAvailableNetworkList failed with error %ld\n", __FUNCTION__, result); #endif continue; } QStringList seenNetworks; for (unsigned int j = 0; j < networkList->dwNumberOfItems; ++j) { WLAN_AVAILABLE_NETWORK &network = networkList->Network[j]; QString networkName; if (network.strProfileName[0] != 0) { networkName = QString::fromWCharArray(network.strProfileName); } else { networkName = QByteArray(reinterpret_cast<char *>(network.dot11Ssid.ucSSID), network.dot11Ssid.uSSIDLength); } const QString id = QString::number(qHash(QLatin1String("WLAN:") + networkName)); previous.removeAll(id); QNetworkConfiguration::StateFlags state = QNetworkConfiguration::Undefined; if (!(network.dwFlags & WLAN_AVAILABLE_NETWORK_HAS_PROFILE)) state = QNetworkConfiguration::Undefined; if (network.strProfileName[0] != 0) { if (network.bNetworkConnectable) { if (network.dwFlags & WLAN_AVAILABLE_NETWORK_CONNECTED) state = QNetworkConfiguration::Active; else state = QNetworkConfiguration::Discovered; } else { state = QNetworkConfiguration::Defined; } } if (seenNetworks.contains(networkName)) continue; else seenNetworks.append(networkName); if (accessPointConfigurations.contains(id)) { QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(id); bool changed = false; ptr->mutex.lock(); if (!ptr->isValid) { ptr->isValid = true; changed = true; } if (ptr->name != networkName) { ptr->name = networkName; changed = true; } if (ptr->state != state) { ptr->state = state; changed = true; } ptr->mutex.unlock(); if (changed) { locker.unlock(); emit configurationChanged(ptr); locker.relock(); } } else { QNetworkConfigurationPrivatePointer ptr(new QNetworkConfigurationPrivate); ptr->name = networkName; ptr->isValid = true; ptr->id = id; ptr->state = state; ptr->type = QNetworkConfiguration::InternetAccessPoint; ptr->bearerType = QNetworkConfiguration::BearerWLAN; accessPointConfigurations.insert(id, ptr); locker.unlock(); emit configurationAdded(ptr); locker.relock(); } } local_WlanFreeMemory(networkList); } local_WlanFreeMemory(interfaceList); while (!previous.isEmpty()) { QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.take(previous.takeFirst()); locker.unlock(); emit configurationRemoved(ptr); locker.relock(); } locker.unlock(); emit updateCompleted(); }
uint qHash(const YAxis*& yaxis, uint seed) { return qHash(yaxis->id) ^ seed; }
uint qHash(const NodeAbstractProperty &property) { return qHash(AbstractProperty(property)); }
QString SqlUtils::createIdentifier(const QString& text) { uint hash = qHash(text); return QString::number(hash, 16); }
uint qHash (const Dependency& dep) { return qHash (QString::number (dep.Type_) + dep.Name_ + dep.Version_); }
uint qHash(const EwsId &id, uint seed) { return qHash(id.id(), seed) ^ qHash(id.changeKey(), seed) ^ static_cast<uint>(id.type()); }
inline uint qHash(const QSslCertificate &cert) { return qHash(cert.toPem()); }
uint qHash(const Team &team) { return qHash( team.getName() ) ^ qHash( team.getClub() ); }
uint qHash(const KeyType &key) { return qHash(key.foo); }
quint32 qHash(const Ban &b) { return qHash(b.qsHash) ^ qHash(b.haAddress) ^ qHash(b.qsUsername) ^ qHash(b.iMask); }
/*! \since 4.4 Computes a hash key for the QSourceLocation \a location. \relates QSourceLocation */ uint qHash(const QSourceLocation &location) { /* Not the world's best hash function exactly. */ return qHash(location.uri().toString()) + location.line() + location.column(); }
uint qHash(const QVariant &var) { if (!var.isValid() || var.isNull()) return -1; switch (var.type()) { case QVariant::Int: return qHash( var.toInt() ); case QVariant::UInt: return qHash( var.toUInt() ); case QVariant::Bool: return qHash( var.toUInt() ); case QVariant::Double: return qHash( var.toUInt() ); case QVariant::LongLong: return qHash( var.toLongLong() ); case QVariant::ULongLong: return qHash( var.toULongLong() ); case QVariant::String: return qHash( var.toString() ); case QVariant::Char: return qHash( var.toChar() ); case QVariant::StringList: return qHash( var.toString() ); case QVariant::ByteArray: return qHash( var.toByteArray() ); case QVariant::Date: case QVariant::Time: case QVariant::DateTime: case QVariant::Url: case QVariant::Locale: case QVariant::RegExp: return qHash( var.toString() ); case QVariant::Map: case QVariant::List: case QVariant::BitArray: case QVariant::Size: case QVariant::SizeF: case QVariant::Rect: case QVariant::LineF: case QVariant::Line: case QVariant::RectF: case QVariant::Point: case QVariant::UserType: case QVariant::Invalid: default: Q_ASSERT(false); } // could not generate a hash for the given variant Q_ASSERT(false); return 0; }
void BlockIdentifier::parseDefinition(JSONObject *b, BlockInfo *parent, int pack) { int id; if (parent == NULL) { id = b->at("id")->asNumber(); } else { id = parent->id; int data = b->at("data")->asNumber(); id |= data << 12; } BlockInfo *block = new BlockInfo(); block->id = id; if (b->has("name")) block->setName(b->at("name")->asString()); else if (parent != NULL) block->setName(parent->getName()); else block->setName("Unknown"); block->enabled = true; if (b->has("transparent")) { block->transparent = b->at("transparent")->asBool(); block->rendernormal = false; // for most cases except the following if (b->has("rendercube")) block->rendernormal = b->at("rendercube")->asBool(); block->spawninside = false; // for most cases except the following if (b->has("spawninside")) block->spawninside = b->at("spawninside")->asBool(); } else if (parent != NULL) { block->transparent = parent->transparent; block->rendernormal = parent->rendernormal; block->spawninside = parent->spawninside; } else { block->transparent = false; block->rendernormal = true; block->spawninside = false; } if (b->has("liquid")) block->liquid = b->at("liquid")->asBool(); else if (parent != NULL) block->liquid = parent->liquid; else block->liquid = false; if (b->has("canProvidePower")) block->providepower = b->at("canProvidePower")->asBool(); else if (parent != NULL) block->providepower = parent->providepower; else block->providepower = false; if (b->has("alpha")) block->alpha = b->at("alpha")->asNumber(); else if (parent != NULL) block->alpha = parent->alpha; else block->alpha = 1.0; QColor blockcolor; if (b->has("color")) { QString colorname = b->at("color")->asString(); if (colorname.length() == 6) { // check if this is an old color definition with missing '#' bool ok; colorname.toInt(&ok,16); if (ok) colorname.push_front('#'); } blockcolor.setNamedColor(colorname); assert(blockcolor.isValid()); } else if (parent != NULL) { // copy brightest color from parent blockcolor = parent->colors[15]; } else { // use hashed by name instead quint32 hue = qHash(block->getName()); blockcolor.setHsv(hue % 360, 255, 255); } // pre-calculate light spectrum for (int i = 0; i < 16; i++) { // calculate light attenuation similar to Minecraft // except base 90% here, were Minecraft is using 80% per level double light_factor = pow(0.90,15-i); block->colors[i].setRgb(light_factor*blockcolor.red(), light_factor*blockcolor.green(), light_factor*blockcolor.blue(), 255*block->alpha ); } // biome dependant color if (b->has("biomeGrass")) block->setBiomeGrass( b->at("biomeGrass")->asBool() ); if (b->has("biomeFoliage")) block->setBiomeFoliage( b->at("biomeFoliage")->asBool() ); // variant reduction mask if (b->has("mask")) block->mask = b->at("mask")->asNumber(); else if (b->has("variants")) block->mask = 0x0f; else block->mask = 0x00; if (b->has("variants")) { JSONArray *variants = dynamic_cast<JSONArray *>(b->at("variants")); int vlen = variants->length(); for (int j = 0; j < vlen; j++) parseDefinition(dynamic_cast<JSONObject *>(variants->at(j)), block, pack); } blocks[id].append(block); packs[pack].append(block); }
/*! \fn uint qHash(const QPimSource &s) \ingroup pim \relates QPimSource Returns a hash value for the source \a s. */ QTOPIAPIM_EXPORT uint qHash(const QPimSource &s) { return qHash(s.context) + qHash(s.identity); }
uint qHash(const Vertex& vertex, uint seed = 0) { return qHash(vertex.originalIndex, seed); }
uint qHash(std::string a,uint b) { return qHash(QString(a.c_str()), b); }
uint qHash(const KCConditional& c) { return qHash(c.value1); }
/*! \internal \relates QApplicationArgument Computes a hash key on \a argument's name and returns it. */ uint qHash(const QApplicationArgument &argument) { return qHash(argument.name()); }
uint qHash(const RSubSessionBase& key) { return qHash(key.SubSessionHandle()); }
void QNativeWifiEngine::connectToId(const QString &id) { QMutexLocker locker(&mutex); if (!available()) { locker.unlock(); emit connectionError(id, InterfaceLookupError); return; } WLAN_INTERFACE_INFO_LIST *interfaceList; DWORD result = local_WlanEnumInterfaces(handle, 0, &interfaceList); if (result != ERROR_SUCCESS) { #ifdef BEARER_MANAGEMENT_DEBUG qDebug("%s: WlanEnumInterfaces failed with error %ld\n", __FUNCTION__, result); #endif locker.unlock(); emit connectionError(id, InterfaceLookupError); return; } QString profile; for (unsigned int i = 0; i < interfaceList->dwNumberOfItems; ++i) { const WLAN_INTERFACE_INFO &interface = interfaceList->InterfaceInfo[i]; WLAN_AVAILABLE_NETWORK_LIST *networkList; result = local_WlanGetAvailableNetworkList(handle, &interface.InterfaceGuid, 3, 0, &networkList); if (result != ERROR_SUCCESS) { #ifdef BEARER_MANAGEMENT_DEBUG qDebug("%s: WlanGetAvailableNetworkList failed with error %ld\n", __FUNCTION__, result); #endif continue; } for (unsigned int j = 0; j < networkList->dwNumberOfItems; ++j) { WLAN_AVAILABLE_NETWORK &network = networkList->Network[j]; profile = QString::fromWCharArray(network.strProfileName); if (qHash(QLatin1String("WLAN:") + profile) == id.toUInt()) break; else profile.clear(); } local_WlanFreeMemory(networkList); if (!profile.isEmpty()) { WLAN_CONNECTION_PARAMETERS parameters; parameters.wlanConnectionMode = wlan_connection_mode_profile; parameters.strProfile = reinterpret_cast<LPCWSTR>(profile.utf16()); parameters.pDot11Ssid = 0; parameters.pDesiredBssidList = 0; parameters.dot11BssType = dot11_BSS_type_any; parameters.dwFlags = 0; DWORD result = local_WlanConnect(handle, &interface.InterfaceGuid, ¶meters, 0); if (result != ERROR_SUCCESS) { #ifdef BEARER_MANAGEMENT_DEBUG qDebug("%s: WlanConnect failed with error %ld\n", __FUNCTION__, result); #endif locker.unlock(); emit connectionError(id, ConnectError); locker.relock(); break; } break; } } local_WlanFreeMemory(interfaceList); if (profile.isEmpty()) { locker.unlock(); emit connectionError(id, InterfaceLookupError); } }
uint qHash(const QUrl &url) { return qHash(url.toString()); }
int *getLock(volatile void *addr) { return locks[qHash(const_cast<void *>(addr)) % 256]; }
void tst_QHash::qhash() { { QBitArray a1; QBitArray a2; QVERIFY(qHash(a1) == 0); a1.resize(1); a1.setBit(0, true); a2.resize(1); a2.setBit(0, false); uint h1 = qHash(a1); uint h2 = qHash(a2); QVERIFY(h1 != h2); a2.setBit(0, true); QVERIFY(h1 == qHash(a2)); a1.fill(true, 8); a1.resize(7); h1 = qHash(a1); a2.fill(true, 7); h2 = qHash(a2); QVERIFY(h1 == h2); a2.setBit(0, false); uint h3 = qHash(a2); QVERIFY(h2 != h3); a2.setBit(0, true); QVERIFY(h2 == qHash(a2)); a2.setBit(6, false); uint h4 = qHash(a2); QVERIFY(h2 != h4); a2.setBit(6, true); QVERIFY(h2 == qHash(a2)); QVERIFY(h3 != h4); } { QPair<int, int> p12(1, 2); QPair<int, int> p21(2, 1); QVERIFY(qHash(p12) == qHash(p12)); QVERIFY(qHash(p21) == qHash(p21)); QVERIFY(qHash(p12) != qHash(p21)); QPair<int, int> pA(0x12345678, 0x12345678); QPair<int, int> pB(0x12345675, 0x12345675); QVERIFY(qHash(pA) != qHash(pB)); } }
void QGenericEngine::doRequestUpdate() { #ifndef QT_NO_NETWORKINTERFACE QMutexLocker locker(&mutex); // Immediately after connecting with a wireless access point // QNetworkInterface::allInterfaces() will sometimes return an empty list. Calling it again a // second time results in a non-empty list. If we loose interfaces we will end up removing // network configurations which will break current sessions. QList<QNetworkInterface> interfaces = QNetworkInterface::allInterfaces(); if (interfaces.isEmpty()) interfaces = QNetworkInterface::allInterfaces(); QStringList previous = accessPointConfigurations.keys(); // create configuration for each interface while (!interfaces.isEmpty()) { QNetworkInterface interface = interfaces.takeFirst(); if (!interface.isValid()) continue; // ignore loopback interface if (interface.flags() & QNetworkInterface::IsLoopBack) continue; // ignore WLAN interface handled in separate engine if (qGetInterfaceType(interface.name()) == QNetworkConfiguration::BearerWLAN) continue; uint identifier; if (interface.index()) identifier = qHash(QLatin1String("generic:") + QString::number(interface.index())); else identifier = qHash(QLatin1String("generic:") + interface.hardwareAddress()); const QString id = QString::number(identifier); previous.removeAll(id); QString name = interface.humanReadableName(); if (name.isEmpty()) name = interface.name(); QNetworkConfiguration::StateFlags state = QNetworkConfiguration::Defined; if ((interface.flags() & QNetworkInterface::IsRunning) && !interface.addressEntries().isEmpty()) state |= QNetworkConfiguration::Active; if (accessPointConfigurations.contains(id)) { QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(id); bool changed = false; ptr->mutex.lock(); if (!ptr->isValid) { ptr->isValid = true; changed = true; } if (ptr->name != name) { ptr->name = name; changed = true; } if (ptr->id != id) { ptr->id = id; changed = true; } if (ptr->state != state) { ptr->state = state; changed = true; } ptr->mutex.unlock(); if (changed) { locker.unlock(); emit configurationChanged(ptr); locker.relock(); } } else { QNetworkConfigurationPrivatePointer ptr(new QNetworkConfigurationPrivate); ptr->name = name; ptr->isValid = true; ptr->id = id; ptr->state = state; ptr->type = QNetworkConfiguration::InternetAccessPoint; ptr->bearerType = qGetInterfaceType(interface.name()); accessPointConfigurations.insert(id, ptr); configurationInterface.insert(id, interface.name()); locker.unlock(); emit configurationAdded(ptr); locker.relock(); } } while (!previous.isEmpty()) { QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.take(previous.takeFirst()); configurationInterface.remove(ptr->id); locker.unlock(); emit configurationRemoved(ptr); locker.relock(); } locker.unlock(); #endif emit updateCompleted(); }
static int mixp_main(int &argc, char **argv) { //Print the logo qDebug("MediaInfoXP v%u.%02u, built on %s at %s.", mixp_versionMajor, mixp_versionMinor, mixp_buildDate, mixp_buildTime); qDebug("Copyright (c) 2004-%s LoRd_MuldeR <*****@*****.**>. Some rights reserved.", &mixp_buildDate[7]); qDebug("Built with Qt v%s, running with Qt v%s.\n", QT_VERSION_STR, qVersion()); //Print library version qDebug("This application is powerd by MUtils library v%u.%02u (%s, %s).\n", MUtils::Version::lib_version_major(), MUtils::Version::lib_version_minor(), MUTILS_UTF8(MUtils::Version::lib_build_date().toString(Qt::ISODate)), MUTILS_UTF8(MUtils::Version::lib_build_time().toString(Qt::ISODate))); //Create application QScopedPointer<QApplication> application(new QApplication(argc, argv)); //Create IPC QScopedPointer<MUtils::IPCChannel> ipcChannel(new MUtils::IPCChannel("mediainfo-xp", qHash(QString("%0@%1").arg(QString::fromLatin1(mixp_buildDate), QString::fromLatin1(mixp_buildTime))), "instance")); const int ipcMode = ipcChannel->initialize(); if((ipcMode != MUtils::IPCChannel::RET_SUCCESS_MASTER) && (ipcMode != MUtils::IPCChannel::RET_SUCCESS_SLAVE)) { qFatal("The IPC initialization has failed!"); return EXIT_FAILURE; } //Handle multiple instances if(ipcMode == MUtils::IPCChannel::RET_SUCCESS_SLAVE) { mixp_handle_multi_instance(ipcChannel.data()); return EXIT_SUCCESS; } //Get temp folder const QString tempFolder = MUtils::temp_folder(); qDebug("TEMP folder is:\n%s\n", QDir::toNativeSeparators(tempFolder).toUtf8().constData()); //Create main window QScopedPointer<CMainWindow> mainWindow(new CMainWindow(tempFolder, ipcChannel.data())); mainWindow->show(); //Run application const int exit_code = application->exec(); qDebug("\nTime to say goodbye... (%d)\n", exit_code); return exit_code; }
uint qHash(const QDeclarativeJS::NameId &id) { return qHash(id.asString()); }
uint Expression::ComputeHashCode() const { return qHash(this); }