void QmitkPythonSnippets::SaveStringMap(const QString &filename, const QmitkPythonSnippets::QStringMap &) const { MITK_DEBUG("QmitkPythonSnippets") << "saving to xml file " << filename.toStdString(); if( filename.isEmpty() ) { MITK_WARN("QmitkPythonSnippets") << "empty auto save file path given. quit."; return; } QFile file(filename); file.open(QIODevice::WriteOnly); if( !file.isOpen() ) { MITK_WARN("QmitkPythonSnippets") << "could not open file " << filename.toStdString() << " for writing"; return; } QXmlStreamWriter xmlWriter(&file); xmlWriter.setAutoFormatting(true); xmlWriter.writeStartDocument(); xmlWriter.writeStartElement(SNIPPETS_ROOT_XML_ELEMENT_NAME); QStringMap::const_iterator it = d->m_Snippets.begin(); while( it != d->m_Snippets.end() ) { { MITK_DEBUG("QmitkPythonSnippets") << "SNIPPETS_XML_ELEMENT_NAME " << SNIPPETS_XML_ELEMENT_NAME.toStdString(); MITK_DEBUG("QmitkPythonSnippets") << "writing item " << it.key().toStdString(); } xmlWriter.writeStartElement(SNIPPETS_XML_ELEMENT_NAME); xmlWriter.writeAttribute( "key", it.key() ); xmlWriter.writeAttribute( "value", it.value() ); xmlWriter.writeEndElement(); ++it; } xmlWriter.writeEndDocument(); if( file.isOpen() ) file.close(); { MITK_DEBUG("QmitkPythonSnippets") << "SaveStringMap successful "; } }
void Item::restoreFromItemData( const ItemData &itemData ) { move( itemData.x, itemData.y ); if ( canResize() ) setSize( itemData.size ); Item *parentItem = p_itemDocument->itemWithID( itemData.parentId ); if (parentItem) setParentItem(parentItem); else m_baseZ = itemData.z; //BEGIN Restore data const QStringMap::const_iterator stringEnd = itemData.dataString.end(); for ( QStringMap::const_iterator it = itemData.dataString.begin(); it != stringEnd; ++it ) { if ( hasProperty(it.key()) ) property( it.key() )->setValue( it.value() ); } const DoubleMap::const_iterator numberEnd = itemData.dataNumber.end(); for ( DoubleMap::const_iterator it = itemData.dataNumber.begin(); it != numberEnd; ++it ) { if ( hasProperty(it.key()) ) property( it.key() )->setValue( it.value() ); } const QColorMap::const_iterator colorEnd = itemData.dataColor.end(); for ( QColorMap::const_iterator it = itemData.dataColor.begin(); it != colorEnd; ++it ) { if ( hasProperty(it.key()) ) property( it.key() )->setValue( it.value() ); } const BoolMap::const_iterator boolEnd = itemData.dataBool.end(); for ( BoolMap::const_iterator it = itemData.dataBool.begin(); it != boolEnd; ++it ) { if ( hasProperty(it.key()) ) property( it.key() )->setValue( QVariant( it.value() /*, 0*/ ) ); } const QBitArrayMap::const_iterator rawEnd = itemData.dataRaw.end(); for ( QBitArrayMap::const_iterator it = itemData.dataRaw.begin(); it != rawEnd; ++it ) { if ( hasProperty(it.key()) ) property( it.key() )->setValue( it.value() ); } //END Restore Data }
void DrawPart::restoreFromItemData( const ItemData &itemData ) { Item::restoreFromItemData(itemData); const QStringMap::const_iterator stringEnd = itemData.dataString.end(); for ( QStringMap::const_iterator it = itemData.dataString.begin(); it != stringEnd; ++it ) { VariantDataMap::iterator vit = m_variantData.find(it.key()); if ( vit == m_variantData.end() ) continue; if ( vit.value()->type() == Variant::Type::PenStyle ) setDataPenStyle( it.key(), idToPenStyle( it.value() ) ); else if ( vit.value()->type() == Variant::Type::PenCapStyle ) setDataPenCapStyle( it.key(), idToPenCapStyle( it.value() ) ); } }
void QmitkPythonSnippets::Update(const QString &name) { d->m_Name->clear(); d->m_Content->clear(); MITK_DEBUG("QmitkPythonSnippets") << "size of snippets " << d->m_Snippets.size(); QStringMap::const_iterator it = d->m_Snippets.begin(); while( it != d->m_Snippets.end() ) { MITK_DEBUG("QmitkPythonSnippets") << "adding item " << it.key().toStdString(); d->m_Name->addItem( it.key() ); ++it; } int index = d->m_Name->findText( name ); if( index >= 0 ) { MITK_DEBUG("QmitkPythonSnippets") << "selecting index " << index; d->m_Name->setCurrentIndex(index); } }
bool MainWindow::ccliveSupportsHost(const QString& lnk) { const QString host = QUrl(lnk).host(); for (QStringMap::const_iterator iter = hosts.begin(); iter != hosts.end(); ++iter) { QRegExp re( iter.key()); if (re.indexIn(host) != -1) return true; } return false; }
void MicroSettings::restoreFromMicroData( const MicroData µData ) { setPinMappings( microData.pinMappings ); const PinDataMap::const_iterator pinMapEnd = microData.pinMap.end(); for ( PinDataMap::const_iterator it = microData.pinMap.begin(); it != pinMapEnd; ++it ) { PinSettings *pin = pinWithID(it.key()); if (pin) { pin->setState( it.data().state ); pin->setType( it.data().type ); } } const QStringMap::const_iterator variableMapEnd = microData.variableMap.end(); for ( QStringMap::const_iterator it = microData.variableMap.begin(); it != variableMapEnd; ++it ) { setVariable( it.key(), it.data(), true ); } }
QVariant MethodInfo::Invoke( Service *pService, const QStringMap &reqParams ) { HttpRedirectException exception; bool bExceptionThrown = false; QStringMap lowerParams; if (!pService) throw; // Change params to lower case for case-insensitive comparison QStringMap::const_iterator it = reqParams.begin(); for (; it != reqParams.end(); ++it) { lowerParams[it.key().toLower()] = *it; } // -------------------------------------------------------------- // Provide actual parameters received to method // -------------------------------------------------------------- pService->m_parsedParams = lowerParams.keys(); QList<QByteArray> paramNames = m_oMethod.parameterNames(); QList<QByteArray> paramTypes = m_oMethod.parameterTypes(); // ---------------------------------------------------------------------- // Create Parameter array (Can't have more than _MAX_PARAMS parameters).... // switched to static array for performance. // ---------------------------------------------------------------------- void *param[ _MAX_PARAMS ]; int types[ _MAX_PARAMS ]; memset( param, 0, _MAX_PARAMS * sizeof(void *)); memset( types, 0, _MAX_PARAMS * sizeof(int)); try { // -------------------------------------------------------------- // Add a place for the Return value // -------------------------------------------------------------- int nRetIdx = QMetaType::type( m_oMethod.typeName() ); if (nRetIdx != 0) { param[ 0 ] = QMetaType::create( nRetIdx ); types[ 0 ] = nRetIdx; } else { param[ 0 ] = nullptr; types[ 0 ] = 0; } // -------------------------------------------------------------- // Fill in parameters from request values // -------------------------------------------------------------- for( int nIdx = 0; nIdx < paramNames.length(); nIdx++ ) { QString sValue = lowerParams[ paramNames[ nIdx ].toLower() ]; QString sParamType = paramTypes[ nIdx ]; int nId = QMetaType::type( paramTypes[ nIdx ] ); void *pParam = nullptr; if (nId != 0) { pParam = QMetaType::create( nId ); } else { LOG(VB_GENERAL, LOG_ERR, QString("MethodInfo::Invoke - Type unknown '%1'") .arg(sParamType)); } types[nIdx+1] = nId; param[nIdx+1] = pService->ConvertToParameterPtr( nId, sParamType, pParam, sValue ); } #if 0 QThread *currentThread = QThread::currentThread(); QThread *objectThread = pService->thread(); if (currentThread == objectThread) LOG(VB_HTTP, LOG_DEBUG, "*** Threads are same ***"); else LOG(VB_HTTP, LOG_DEBUG, "*** Threads are Different!!! ***"); #endif pService->qt_metacall( QMetaObject::InvokeMetaMethod, m_nMethodIndex, param ); // -------------------------------------------------------------- // Delete param array, skip return parameter since not dynamically // created. // -------------------------------------------------------------- for (int nIdx=1; nIdx < paramNames.length()+1; nIdx++) { if ((types[ nIdx ] != 0) && (param[ nIdx ] != nullptr)) QMetaType::destroy( types[ nIdx ], param[ nIdx ] ); } } catch (QString &sMsg) { LOG(VB_GENERAL, LOG_ERR, QString("MethodInfo::Invoke - An Exception Occurred: %1") .arg(sMsg)); if ((types[ 0 ] != 0) && (param[ 0 ] != nullptr )) QMetaType::destroy( types[ 0 ], param[ 0 ] ); throw; } catch (HttpRedirectException &ex) { bExceptionThrown = true; exception = ex; } catch (...) { LOG(VB_GENERAL, LOG_INFO, "MethodInfo::Invoke - An Exception Occurred" ); } // -------------------------------------------------------------- // return the result after converting to a QVariant // -------------------------------------------------------------- QVariant vReturn; if ( param[ 0 ] != nullptr) { vReturn = pService->ConvertToVariant( types[ 0 ], param[ 0 ] ); if (types[ 0 ] != 0) QMetaType::destroy( types[ 0 ], param[ 0 ] ); } // -------------------------------------------------------------- // Re-throw exception if needed. // -------------------------------------------------------------- if (bExceptionThrown) throw exception; return vReturn; }