Пример #1
0
QString YaDayUse::ui()
{
	QFile file(uiPath());
	if (!QFile::exists(uiPath())) {
		QUuid uuid = QUuid::createUuid();

		if (file.open(QIODevice::WriteOnly)) {
			QTextStream text(&file);
			text.setCodec("UTF-8");
			text << uuid.toString();

			return uuid.toString();
		}
	}

	if (file.open(QIODevice::ReadOnly)) {
		QTextStream text(&file);
		text.setCodec("UTF-8");
		QString str = text.readLine();

		QRegExp rx("\\{[\\da-fA-F]{8}(-[\\da-fA-F]{4}){3}-[\\da-fA-F]{12}\\}");
		if (rx.exactMatch(str)) {
			return str;
		}
	}

	return "na";
}
Пример #2
0
 void init(QObject* widgetObject, QObject* qmlObject) {
     widgetObject->setUserData(USER_DATA_ID, this);
     qmlObject->setUserData(USER_DATA_ID, this);
     qmlObject->setObjectName(uuid.toString());
     // Make sure we can find it again in the future
     Q_ASSERT(VrMenu::_instance->findMenuObject(uuid.toString()));
 }
Пример #3
0
void ConnectionManager::setDefaultProxy(const QUuid &AProxyId)
{
	if (defaultProxy()!=AProxyId && (AProxyId.isNull() || proxyList().contains(AProxyId)))
	{
		LOG_INFO(QString("Default proxy changed, id=%1").arg(AProxyId.toString()));
		Options::node(OPV_PROXY_DEFAULT).setValue(AProxyId.toString());
	}
}
Пример #4
0
void ConnectionManager::removeProxy(const QUuid &AProxyId)
{
	if (proxyList().contains(AProxyId))
	{
		LOG_INFO(QString("Proxy removed, id=%1").arg(AProxyId.toString()));
		if (defaultProxy() == AProxyId)
			setDefaultProxy(QUuid());
		Options::node(OPV_PROXY_ROOT).removeChilds("proxy",AProxyId.toString());
		emit proxyRemoved(AProxyId);
	}
}
Пример #5
0
CalendarItem CalendarItem::createNewTodoItem(QString summary, QString calendar) {
    QUuid uuid = QUuid::createUuid();
    QString uuidString = uuid.toString();
    uuidString.replace("{", "").replace("}", "");

    CalendarItem calItem;
    calItem.setSummary(summary);
    calItem.setCalendar(calendar);
    calItem.setUrl(QUrl(getCurrentCalendarUrl() + "qownnotes-" + uuidString + ".ics"));
    calItem.setICSData(
            "BEGIN:VCALENDAR\nVERSION:2.0\nPRODID:ownCloud Calendar\nCALSCALE:GREGORIAN\nBEGIN:VTODO\nEND:VTODO\nEND:VCALENDAR");
    calItem.setUid(uuidString);

    QDateTime dateTime = QDateTime::currentDateTime();
    calItem.setCreated(dateTime);
    calItem.setModified(dateTime);

    calItem.generateNewICSData();

    if (calItem.store()) {
        qDebug() << __func__ << " - 'calItem': " << calItem;
        qDebug() << __func__ << " - 'calItem.getICSData()': " << calItem.getICSData();
    }

    return calItem;
}
Пример #6
0
bool CNetwork::RoutePacket(QUuid& pTargetGUID, G2Packet* pPacket)
{
	CG2Node* pNode = 0;
	CEndPoint pAddr;

	if(m_oRoutingTable.Find(pTargetGUID, &pNode, &pAddr))
	{
		if(pNode)
		{
			pNode->SendPacket(pPacket, true, false);
			systemLog.postLog(tr("CNetwork::RoutePacket %1 Packet: %2 routed to neighbour: %3").arg(pTargetGUID.toString()).arg(pPacket->GetType()).arg(pNode->m_oAddress.toString().toAscii().constData()), LogSeverity::Debug);
			//qDebug() << "CNetwork::RoutePacket " << pTargetGUID.toString() << " Packet: " << pPacket->GetType() << " routed to neighbour: " << pNode->m_oAddress.toString().toAscii().constData();
			return true;
		}
		else if(!pAddr.isNull())
		{
			Datagrams.SendPacket(pAddr, pPacket, true);
			systemLog.postLog(tr("CNetwork::RoutePacket %1 Packet: %2 routed to remote node: %3").arg(pTargetGUID.toString()).arg(pPacket->GetType()).arg(pNode->m_oAddress.toString().toAscii().constData()), LogSeverity::Debug);
			//qDebug() << "CNetwork::RoutePacket " << pTargetGUID.toString() << " Packet: " << pPacket->GetType() << " routed to remote node: " << pNode->m_oAddress.toString().toAscii().constData();
			return true;
		}
		systemLog.postLog(tr("CNetwork::RoutePacket - No node and no address!"), LogSeverity::Debug);
		//qDebug() << "CNetwork::RoutePacket - weird thing, should not happen...";
	}

	qDebug() << "CNetwork::RoutePacket " << pTargetGUID.toString() << " Packet: " << pPacket->GetType() << " DROPPED!";
	return false;
}
Пример #7
0
NavitAdapter::NavitAdapter()
{
    QAction* loadFile = new QAction(tr("Load Navit file..."), this);
    loadFile->setData(theUid.toString());
    connect(loadFile, SIGNAL(triggered()), SLOT(onLoadFile()));
    theMenu = new QMenu();
    theMenu->addAction(loadFile);

    loaded = false;

//    loaded = navit.setFilename("C:/home/cbro/Merkaartor/osm_bbox_11.3,47.9,11.7,48.2.bin");
//    loaded = navit.setFilename("C:/home/cbro/Merkaartor/osm_bbox_4.2,50.7,4.6,50.9.bin");
//    loaded = navit.setFilename("C:/home/cbro/Merkaartor/belgium.navit.bin");

    MasPaintStyle theStyle;
    theStyle.loadPainters(":/Styles/Mapnik.mas");
    for (int i=0; i<theStyle.painterSize(); ++i) {
        thePrimitivePainters.append(PrimitivePainter(*theStyle.getPainter(i)));
    }

    QStringList osmAttr = attrmap.split("\n", QString::SkipEmptyParts);
    foreach (QString l, osmAttr) {
        QStringList flds = l.split("\t", QString::SkipEmptyParts);
        item_type typ = item_from_name(flds[2].toLatin1().data());
        if (typ == type_none)
            continue;
        NavitFeature f;
        QStringList sl = flds[1].split(",");
        foreach(QString t, sl) {
            QStringList kv = t.split("=");
            f.Tags.append(qMakePair(kv[0], kv[1]));
        }
Пример #8
0
IConnectionProxy ConnectionManager::proxyById(const QUuid &AProxyId) const
{
	static const IConnectionProxy noProxy = {" "+tr("<No Proxy>"), QNetworkProxy(QNetworkProxy::NoProxy) };

	if (!AProxyId.isNull())
	{
		OptionsNode pnode;
		QList<QUuid> plist = proxyList();
		if (plist.contains(AProxyId))
			pnode = Options::node(OPV_PROXY_ITEM,AProxyId.toString());
		else if (plist.contains(defaultProxy()))
			pnode = Options::node(OPV_PROXY_ITEM,defaultProxy().toString());

		if (!pnode.isNull())
		{
			IConnectionProxy proxy;
			proxy.name = pnode.value("name").toString();
			proxy.proxy.setType((QNetworkProxy::ProxyType)pnode.value("type").toInt());
			proxy.proxy.setHostName(pnode.value("host").toString());
			proxy.proxy.setPort(pnode.value("port").toInt());
			proxy.proxy.setUser(pnode.value("user").toString());
			proxy.proxy.setPassword(Options::decrypt(pnode.value("pass").toByteArray()).toString());
			return proxy;
		}
	}

	return noProxy;
}
Пример #9
0
QScriptValue quuidToScriptValue(QScriptEngine* engine, const QUuid& uuid) {
    if (uuid.isNull()) {
        return QScriptValue::NullValue;
    }
    QScriptValue obj(uuid.toString());
    return obj;
}
Пример #10
0
//----------------------------------------------------------------------------
void ctkExampleDicomAppLogic::onDataAvailable()
{
  QString s;
  const ctkDicomAppHosting::AvailableData& data = getIncomingAvailableData();
  if(this->AppWidget == 0)
    {
    qCritical() << "Button is null!";
    return;
    }
  s = "Received notifyDataAvailable with patients.count()= " + QString().setNum(data.patients.count());
  if(data.patients.count()>0)
    {
    s=s+" name:"+data.patients.begin()->name+" studies.count(): "+QString().setNum(data.patients.begin()->studies.count());
    if(data.patients.begin()->studies.count()>0)
    {
      s=s+" series.count():" + QString().setNum(data.patients.begin()->studies.begin()->series.count());
      if(data.patients.begin()->studies.begin()->series.count()>0)
      {
        s=s+" uid:" + data.patients.begin()->studies.begin()->series.begin()->seriesUID;
//        QUuid uuid("93097dc1-caf9-43a3-a814-51a57f8d861d");//data.patients.begin()->studies.begin()->series.begin()->seriesUID);
        QUuid uuid = data.patients.begin()->studies.begin()->series.begin()->objectDescriptors.begin()->descriptorUUID;
        s=s+" uuid:"+uuid.toString();
      }
    }
  }
  else
  {
    s = s+", objectDescriptors.count()= " + QString().setNum(data.objectDescriptors.count());
  }
  ui.ReceivedDataInformation->setText(s);
  ui.LoadDataButton->setEnabled(true);
}
Пример #11
0
/// @todo Create a new Corpus with this Session.
Session* Session::create ( const Content* p_content ) {
    const QStringList l_lst = p_content->pages().join ( "\n" ).simplified().trimmed().replace ( ".", ".\n" ).split ( "\n", QString::SkipEmptyParts );
    qDebug () << "Session has " << l_lst.length() << "potential sentences.";
    const QUuid l_uuid = QUuid::createUuid();
    Corpus* l_corpus = Corpus::create ( l_lst );

    if ( !l_corpus ) {
        qDebug() << "Failed to create corpus for session.";
        return 0;
    }

    // create element data
    QDomElement l_sessElem = s_dom->createElement ( "Session" );
    QDomElement l_dateElem = s_dom->createElement ( "Date" );

    l_dateElem.setAttribute ( "created", QDateTime::currentDateTimeUtc().toString ( Qt::SystemLocaleDate ) );
    l_dateElem.setAttribute ( "completed", "-1" );
    l_sessElem.setAttribute ( "uuid", l_uuid.toString() );
    l_sessElem.setAttribute ( "content", p_content->uuid().toString() );
    l_sessElem.setAttribute ( "corpus", l_corpus->uuid() );

    s_dom->documentElement().appendChild ( l_sessElem );
    s_dom->documentElement().appendChild ( l_dateElem );

    QFile* l_file = new QFile ( Core::configurationPath().path() + "/sessions.xml" );
    l_file->open ( QIODevice::WriteOnly | QIODevice::Truncate );
    QTextStream l_str ( l_file );
    s_dom->save ( l_str, 4 );
    l_file->close();

    init();

    return Session::obtain ( l_uuid );
}
//----------------------------------------------------------------------------
ctkDicomSoapUUID::ctkDicomSoapUUID(const QString& name, const QUuid& uuid)
  : QtSoapStruct(QtSoapQName(name))
{
  QString uuidstring(uuid.toString());
  uuidstring.remove(0,1).chop(1);
  this->insert(new QtSoapSimpleType(QtSoapQName("Uuid"),uuidstring));
}
Пример #13
0
GdalAdapter::GdalAdapter()
    : poDataset(0), isLatLon(false)
{
    GDALAllRegister();

    QAction* loadImage = new QAction(tr("Load file(s)..."), this);
    loadImage->setData(theUid.toString());
    connect(loadImage, SIGNAL(triggered()), SLOT(onLoadImage()));
    QAction* setSource = new QAction(tr("Specify \"source\" tag..."), this);
    setSource->setData(theUid.toString());
    connect(setSource, SIGNAL(triggered()), SLOT(onSetSourceTag()));

    theMenu = new QMenu();
    theMenu->addAction(loadImage);
    theMenu->addAction(setSource);
}
Пример #14
0
QString DeviceSettings::generateNewUDN()
{
    QUuid uuid = QUuid::createUuid().toString();
    QString uuidString
        = uuid.toString().replace('{', ' ').replace('}', ' ').trimmed();
    return QString("uuid:%1").arg(uuidString);
}
Пример #15
0
QString LinkDoodService::createMsgId()
{
    QUuid id = QUuid::createUuid();
    QString strId = id.toString();
    qDebug() << "Uuid:" << strId;
    return strId;
}
Пример #16
0
scriptable::ScriptableModelPointer GraphicsScriptingInterface::getModel(const QUuid& uuid) {
    QString error;
    bool success;
    QString providerType = "unknown";
    if (auto nestable = DependencyManager::get<SpatialParentFinder>()->find(uuid, success).lock()) {
        providerType = SpatiallyNestable::nestableTypeToString(nestable->getNestableType());
        if (auto provider = getModelProvider(uuid)) {
            auto modelObject = provider->getScriptableModel();
            const bool found = !modelObject.objectID.isNull();
            if (found && uuid == AVATAR_SELF_ID) {
                // special case override so that scripts can rely on matching intput/output UUIDs
                modelObject.objectID = AVATAR_SELF_ID;
            }
            if (modelObject.objectID == uuid) {
                if (modelObject.meshes.size()) {
                    auto modelWrapper = scriptable::make_scriptowned<scriptable::ScriptableModel>(modelObject);
                    modelWrapper->setObjectName(providerType+"::"+uuid.toString()+"::model");
                    return modelWrapper;
                } else {
                    error = "no meshes available: " + modelObject.objectID.toString();
                }
            } else {
                error = QString("objectID mismatch: %1 (result contained %2 meshes)").arg(modelObject.objectID.toString()).arg(modelObject.meshes.size());
            }
        } else {
            error = "model provider unavailable";
        }
    } else {
        error = "model object not found";
    }
    jsThrowError(QString("failed to get meshes from %1 provider for uuid %2 (%3)").arg(providerType).arg(uuid.toString()).arg(error));
    return nullptr;
}
Пример #17
0
QString CDoodChatManagerModel::createLocalId()
{
    QUuid id = QUuid::createUuid();
    QString strId = id.toString();
    qDebug() << "Uuid:" << strId;
    return strId;
}
Пример #18
0
void SaveFile::operator()(HdrCreationItem& currentItem)
{
    QUuid uuid = QUuid::createUuid();
    QString inputFilename = currentItem.filename();

    QString tempdir = LuminanceOptions().getTempDir();

    QString outputFilename = tempdir + "/" + uuid.toString() + ".tif";
    currentItem.setConvertedFilename(outputFilename);

    qDebug() << QString("SaveFile: Saving data for %1 to %2 on %3").arg(inputFilename).arg(outputFilename).arg(tempdir);

    // save pfs::Frame as tiff 16bits or 32bits
    try
    {
        Params p;
        p.set("tiff_mode", m_mode); // 16bits or 32bits
        p.set("min_luminance", m_minLum); 
        p.set("max_luminance", m_maxLum); 
        p.set("deflateCompression", m_deflateCompression); 
        
        FrameWriterPtr writer = FrameWriterFactory::open(
				QFile::encodeName(outputFilename).constData(), p);
        writer->write( *currentItem.frame(), p );

    }
    catch (std::runtime_error& err)
    {
        qDebug() << QString("SaveFile: Cannot save %1: %2")
                    .arg(currentItem.filename())
                    .arg(QString::fromStdString(err.what()));
    }
}
/*!
    Unregisters the DBus object
*/
void ObjectEndPoint::unregisterObjectDBus(const QRemoteServiceRegister::Entry& entry, const QUuid& id)
{
    uint hash = qHash(id.toString());
    QString objPath = "/" + entry.interfaceName() + "/" + entry.version() +
        "/" + QString::number(hash);
    objPath.replace(QString("."), QString("/"));
    connection->unregisterObject(objPath, QDBusConnection::UnregisterTree);
}
Пример #20
0
uint16_t OctreeElement::getSourceNodeUUIDKey(const QUuid& sourceUUID) {
    uint16_t key = KEY_FOR_NULL;
    QString sourceUUIDString = sourceUUID.toString();
    if (_mapSourceUUIDsToKeys.end() != _mapSourceUUIDsToKeys.find(sourceUUIDString)) {
        key = _mapSourceUUIDsToKeys[sourceUUIDString];
    }
    return key;
}
Пример #21
0
void ensureUserIdExists(Helpers::AppSettings *settings) {
    QLatin1String userIdKey = QLatin1String(Constants::USER_AGENT_ID);

    if (!settings->contains(userIdKey)) {
        QUuid uuid = QUuid::createUuid();
        settings->setValue(userIdKey, uuid.toString());
    }
}
Пример #22
0
void TorServiceInterface::autorizeConnection(const QUuid &connection, const bool allow)
{
    if (auto peer = getPeer(connection)) {
        peer->authorize(allow);
    } else {
        LFLOG_WARN << "No peer with id " << connection.toString();
    }
}
Пример #23
0
void ConsoleWidget::saveContext(const QUuid &AContextId)
{
	OptionsNode node = Options::node(OPV_CONSOLE_CONTEXT_ITEM, AContextId.toString());
	node.setValue(ui.cmbStreamJid->currentIndex()>0 ? ui.cmbStreamJid->itemData(ui.cmbStreamJid->currentIndex()).toString() : QString::null,"streamjid");

	QStringList conditions;
	for (int i=0; i<ui.ltwConditions->count(); i++)
		conditions.append(ui.ltwConditions->item(i)->text());
	node.setValue(conditions,"conditions");

	node.setValue(ui.chbWordWrap->isChecked(),"word-wrap");
	node.setValue(ui.chbHilightXML->checkState(),"highlight-xml");

	Options::setFileValue(saveGeometry(),"console.context.window-geometry",AContextId.toString());
	Options::setFileValue(ui.sptHSplitter->saveState(),"console.context.hsplitter-state",AContextId.toString());
	Options::setFileValue(ui.sptVSplitter->saveState(),"console.context.vsplitter-state",AContextId.toString());
}
Пример #24
0
void ScriptUUID::print(const QString& label, const QUuid& id) {
    QString message = QString("%1 %2").arg(qPrintable(label));
    message = message.arg(id.toString());
    qCDebug(scriptengine) << message;
    if (ScriptEngine* scriptEngine = qobject_cast<ScriptEngine*>(engine())) {
        scriptEngine->print(message);
    }
}
Пример #25
0
/*!
    Unregisters the DBus object
*/
void ObjectEndPoint::unregisterObjectDBus(const QRemoteServiceRegister::Entry& entry, const QUuid& id)
{
    uint hash = qHash(id.toString());
    QString objPath = QLatin1Char('/') + entry.interfaceName() + QLatin1Char('/') + entry.version() +
        QLatin1Char('/') + QString::number(hash);
    objPath.replace(QLatin1Char('.'), QLatin1Char('/'));
    QDBusConnection::sessionBus().unregisterObject(objPath, QDBusConnection::UnregisterTree);
}
Пример #26
0
void HeriotSettings::setWindowSetting(const QUuid &uuid, const QString &name, const QVariant &value)
{
    this->beginGroup(HeriotSettings::windows);
    this->beginGroup(uuid.toString());
    this->setValue(name, value);
    this->endGroup();
    this->endGroup();
}
Пример #27
0
static QString stripCurlyBraces(const QUuid &uuid)
{
    if (uuid.isNull())
        return QString();
    QString result = uuid.toString().toUpper();
    result.chop(1);
    result.remove(0, 1);
    return result;
}
Пример #28
0
QString JSKitLocalStorage::getStorageFileFor(const QUuid &uuid)
{
    QDir dataDir(QStandardPaths::writableLocation(QStandardPaths::DataLocation));
    dataDir.mkpath("js-storage");
    QString fileName = uuid.toString();
    fileName.remove('{');
    fileName.remove('}');
    return dataDir.absoluteFilePath("js-storage/" + fileName + ".ini");
}
Пример #29
0
Файл: node.cpp Проект: Suneal/qt
/*!
  Returns this node's Universally Unique IDentifier as a
  QString. Creates the UUID first, if it has not been created.
 */
QString Node::guid() const
{
    if (uuid.isEmpty()) {
        QUuid quuid = QUuid::createUuid();
        QString t = quuid.toString();
        uuid = "id-" + t.mid(1,t.length()-2);
    }
    return uuid;
}
Пример #30
0
void KoRdfFoaF::updateFromEditorData()
{
    if (m_uri.size() <= 0) {
        QUuid u = QUuid::createUuid();
        m_uri = u.toString();
        kDebug(30015) << "no uuid, created one:" << u.toString();
    }
    QString predBase = "http://xmlns.com/foaf/0.1/";
    kDebug(30015) << "name:" << m_name << " newV:" << editWidget.name->text();
    setRdfType(predBase + "Person");
    updateTriple(m_name, editWidget.name->text(), predBase + "name");
    updateTriple(m_nick, editWidget.nick->text(), predBase + "nick");
    updateTriple(m_homePage, editWidget.url->text(), predBase + "homepage");
    updateTriple(m_phone, editWidget.phone->text(), predBase + "phone");
    if (documentRdf()) {
        const_cast<KoDocumentRdf*>(documentRdf())->emitSemanticObjectUpdated(hKoRdfSemanticItem(this));
    }
}