当前位置: 首页>>代码示例>>C++>>正文


C++ QMap::value方法代码示例

本文整理汇总了C++中QMap::value方法的典型用法代码示例。如果您正苦于以下问题:C++ QMap::value方法的具体用法?C++ QMap::value怎么用?C++ QMap::value使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QMap的用法示例。


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

示例1: main


//.........这里部分代码省略.........
      }
    }
    else
    {
      QgsDebugMsg( "Creating QgsGetRequestHandler" );
      theRequestHandler = new QgsGetRequestHandler();
    }

    QMap<QString, QString> parameterMap;

    try
    {
      parameterMap = theRequestHandler->parseInput();
    }
    catch ( QgsMapServiceException& e )
    {
      QgsDebugMsg( "An exception was thrown during input parsing" );
      theRequestHandler->sendServiceException( e );
      continue;
    }

    QMap<QString, QString>::const_iterator paramIt;

    //set admin config file to wms server object
    QString configFilePath( defaultConfigFilePath );

    paramIt = parameterMap.find( "MAP" );
    if ( paramIt == parameterMap.constEnd() )
    {
      QgsDebugMsg( QString( "Using default configuration file path: %1" ).arg( defaultConfigFilePath ) );
    }
    else
    {
      configFilePath = paramIt.value();
    }

    QgsConfigParser* adminConfigParser = QgsConfigCache::instance()->searchConfiguration( configFilePath );
    if ( !adminConfigParser )
    {
      QgsDebugMsg( "parse error on config file " + configFilePath );
      theRequestHandler->sendServiceException( QgsMapServiceException( "", "Configuration file problem : perhaps you left off the .qgs extension?" ) );
      continue;
    }

    //sld parser might need information about request parameters
    adminConfigParser->setParameterMap( parameterMap );

    //request to WMS?
    QString serviceString;
    paramIt = parameterMap.find( "SERVICE" );
    if ( paramIt == parameterMap.constEnd() )
    {
#ifndef QGISDEBUG
      serviceString = parameterMap.value( "SERVICE", "WMS" );
#else
      QgsDebugMsg( "unable to find 'SERVICE' parameter, exiting..." );
      theRequestHandler->sendServiceException( QgsMapServiceException( "ServiceNotSpecified", "Service not specified. The SERVICE parameter is mandatory" ) );
      delete theRequestHandler;
      continue;
#endif
    }
    else
    {
      serviceString = paramIt.value();
    }
开发者ID:geodenilson,项目名称:Quantum-GIS,代码行数:66,代码来源:qgis_map_serv.cpp

示例2: if


//.........这里部分代码省略.........
	      keys << "screen separation";
	      keys << "gap";
	      keys << "cap style";
	      keys << "arrow direction";
	      keys << "arrows for all";
	      keys << "gap";
	      keys << "animate";
	      keys << "interpolate";
	      keys << "animation speed";
	      keys << "gap";
	      keys << "same for all";
	      keys << "clip";
	      keys << "blend with volume";
	      keys << "allow editing";
	      keys << "command";
	      keys << "commandhelp";
	      keys << "message";
	      

	      propertyEditor.set("Path Group Parameters", plist, keys);

	      
	      QMap<QString, QPair<QVariant, bool> > vmap;

	      if (propertyEditor.exec() == QDialog::Accepted)
		vmap = propertyEditor.get();
	      else
		return true;

	      keys = vmap.keys();

	      for(int ik=0; ik<keys.count(); ik++)
		{
		  QPair<QVariant, bool> pair = vmap.value(keys[ik]);


		  if (pair.second)
		    {
		      if (keys[ik] == "color")
			{
			  QGradientStops stops = propertyEditor.getGradientStops(keys[ik]);
			  m_paths[i]->setStops(stops);
			}
		      else if (keys[ik] == "opacity")
			m_paths[i]->setOpacity(pair.first.toDouble());
		      else if (keys[ik] == "scale type")
			m_paths[i]->setScaleType(pair.first.toBool());
		      else if (keys[ik] == "sections")
			m_paths[i]->setSections(pair.first.toInt());
		      else if (keys[ik] == "smoothness")
			m_paths[i]->setSegments(pair.first.toInt());
		      else if (keys[ik] == "sparseness")
			m_paths[i]->setSparseness(pair.first.toInt());
		      else if (keys[ik] == "screen separation")
			m_paths[i]->setSeparation(pair.first.toInt());
		      else if (keys[ik] == "depthcue")
			m_paths[i]->setDepthcue(pair.first.toBool());
		      else if (keys[ik] == "animate")
			m_paths[i]->setAnimate(pair.first.toBool());
		      else if (keys[ik] == "interpolate")
			m_paths[i]->setAllowInterpolate(pair.first.toBool());
		      else if (keys[ik] == "animation speed")
			m_paths[i]->setAnimateSpeed(pair.first.toInt());
		      else if (keys[ik] == "cap style")
			m_paths[i]->setCapType(pair.first.toInt());
		      else if (keys[ik] == "arrow direction")
开发者ID:Elavina6,项目名称:drishti,代码行数:67,代码来源:pathgroups.cpp

示例3: identifyRasterLayer

bool QgsMapToolIdentify::identifyRasterLayer( QList<IdentifyResult> *results, QgsRasterLayer *layer, QgsPoint point, const QgsRectangle& viewExtent, double mapUnitsPerPixel )
{
  QgsDebugMsg( "point = " + point.toString() );
  if ( !layer )
    return false;

  QgsRasterDataProvider *dprovider = layer->dataProvider();
  if ( !dprovider )
    return false;

  int capabilities = dprovider->capabilities();
  if ( !( capabilities & QgsRasterDataProvider::Identify ) )
    return false;

  QgsPoint pointInCanvasCrs = point;
  try
  {
    point = toLayerCoordinates( layer, point );
  }
  catch ( QgsCsException &cse )
  {
    Q_UNUSED( cse );
    QgsDebugMsg( QString( "coordinate not reprojectable: %1" ).arg( cse.what() ) );
    return false;
  }
  QgsDebugMsg( QString( "point = %1 %2" ).arg( point.x() ).arg( point.y() ) );

  if ( !layer->extent().contains( point ) )
    return false;

  QMap< QString, QString > attributes, derivedAttributes;

  QgsRaster::IdentifyFormat format = QgsRasterDataProvider::identifyFormatFromName( layer->customProperty( "identify/format" ).toString() );

  // check if the format is really supported otherwise use first supported format
  if ( !( QgsRasterDataProvider::identifyFormatToCapability( format ) & capabilities ) )
  {
    if ( capabilities & QgsRasterInterface::IdentifyFeature ) format = QgsRaster::IdentifyFormatFeature;
    else if ( capabilities & QgsRasterInterface::IdentifyValue ) format = QgsRaster::IdentifyFormatValue;
    else if ( capabilities & QgsRasterInterface::IdentifyHtml ) format = QgsRaster::IdentifyFormatHtml;
    else if ( capabilities & QgsRasterInterface::IdentifyText ) format = QgsRaster::IdentifyFormatText;
    else return false;
  }

  QgsRasterIdentifyResult identifyResult;
  // We can only use current map canvas context (extent, width, height) if layer is not reprojected,
  if ( mCanvas->hasCrsTransformEnabled() && dprovider->crs() != mCanvas->mapSettings().destinationCrs() )
  {
    // To get some reasonable response for point/line WMS vector layers we must
    // use a context with approximately a resolution in layer CRS units
    // corresponding to current map canvas resolution (for examplei UMN Mapserver
    // in msWMSFeatureInfo() -> msQueryByRect() is using requested pixel
    // + TOLERANCE (layer param) for feature selection)
    //
    QgsRectangle r;
    r.setXMinimum( pointInCanvasCrs.x() - mapUnitsPerPixel / 2. );
    r.setXMaximum( pointInCanvasCrs.x() + mapUnitsPerPixel / 2. );
    r.setYMinimum( pointInCanvasCrs.y() - mapUnitsPerPixel / 2. );
    r.setYMaximum( pointInCanvasCrs.y() + mapUnitsPerPixel / 2. );
    r = toLayerCoordinates( layer, r ); // will be a bit larger
    // Mapserver (6.0.3, for example) does not work with 1x1 pixel box
    // but that is fixed (the rect is enlarged) in the WMS provider
    identifyResult = dprovider->identify( point, format, r, 1, 1 );
  }
  else
  {
    // It would be nice to use the same extent and size which was used for drawing,
    // so that WCS can use cache from last draw, unfortunately QgsRasterLayer::draw()
    // is doing some tricks with extent and size to allign raster to output which
    // would be difficult to replicate here.
    // Note: cutting the extent may result in slightly different x and y resolutions
    // and thus shifted point calculated back in QGIS WMS (using average resolution)
    //viewExtent = dprovider->extent().intersect( &viewExtent );

    // Width and height are calculated from not projected extent and we hope that
    // are similar to source width and height used to reproject layer for drawing.
    // TODO: may be very dangerous, because it may result in different resolutions
    // in source CRS, and WMS server (QGIS server) calcs wrong coor using average resolution.
    int width = qRound( viewExtent.width() / mapUnitsPerPixel );
    int height = qRound( viewExtent.height() / mapUnitsPerPixel );

    QgsDebugMsg( QString( "viewExtent.width = %1 viewExtent.height = %2" ).arg( viewExtent.width() ).arg( viewExtent.height() ) );
    QgsDebugMsg( QString( "width = %1 height = %2" ).arg( width ).arg( height ) );
    QgsDebugMsg( QString( "xRes = %1 yRes = %2 mapUnitsPerPixel = %3" ).arg( viewExtent.width() / width ).arg( viewExtent.height() / height ).arg( mapUnitsPerPixel ) );

    identifyResult = dprovider->identify( point, format, viewExtent, width, height );
  }

  derivedAttributes.insert( tr( "(clicked coordinate)" ), point.toString() );

  if ( identifyResult.isValid() )
  {
    QMap<int, QVariant> values = identifyResult.results();
    QgsGeometry geometry;
    if ( format == QgsRaster::IdentifyFormatValue )
    {
      Q_FOREACH ( int bandNo, values.keys() )
      {
        QString valueString;
        if ( values.value( bandNo ).isNull() )
//.........这里部分代码省略.........
开发者ID:Benardi-atmadja,项目名称:QGIS,代码行数:101,代码来源:qgsmaptoolidentify.cpp

示例4: service

void SoftwareController::service(HttpRequest& request, HttpResponse& response) {
    MainWindow *mw_ptr = (MainWindow *) rm_ptr->mw_ptr;
    QMap<QString, TableItem *> map;

    //map.insert("", new TableItem(rm_ptr, "", "", mw_ptr->ui->));
    map.insert("mode", new TableItem(rm_ptr, "mode", "run in Mini Mide", mw_ptr->ui->checkBox_mini_mode));
    //map.insert("toolbar", new TableItem(rm_ptr, "toolbar", "Show ToolBar", mw_ptr->toolBarIsVisible);
    map.insert("ontop", new TableItem(rm_ptr, "ontop", "be on top in mini mode", mw_ptr->ui->checkBox_be_on_the_top));
    map.insert("intray", new TableItem(rm_ptr, "intray", "hide in tray after start-up", mw_ptr->ui->checkBox_sw_hideInTray));
    //map.insert("language", new TableItem(rm_ptr, "language", "", mw_ptr->UsedLanguage);

    map.insert("flag", new TableItem(rm_ptr, "flag", "Send RDS time stamps", mw_ptr->ui->checkBox_rds_time));
    map.insert("interval", new TableItem(rm_ptr, "interval", "RDS time stamps interval", mw_ptr->ui->spinBox_rds_time_int));

    map.insert("softcfg", new TableItem(rm_ptr, "softcfg", "Use software config instead of EEPROM", mw_ptr->ui->checkBox_rewriteCfg));
    map.insert("autoconnect", new TableItem(rm_ptr, "autoconnect", "Auto-connect device to FmStick software", mw_ptr->ui->checkBox_sw_autoconnect));
    map.insert("liveedit", new TableItem(rm_ptr, "liveedit", "Enable live-editing device's parameters", mw_ptr->ui->checkBox_sw_live_edit));
    map.insert("http_serve", new TableItem(rm_ptr, "http_serve", "Enable remote HTTP access (WARNING!)", mw_ptr->ui->checkBox_sw_remote));
    map.insert("http_port", new TableItem(rm_ptr, "http_port", "HTTP port (WARNING!)", mw_ptr->ui->spinBox_sw_remote_port));
    map.insert("http_login", new TableItem(rm_ptr, "http_login", "HTTP login (WARNING!)", mw_ptr->ui->lineEdit_sw_remote_login));
    map.insert("http_password", new TableItem(rm_ptr, "http_password", "HTTP password (WARNING!)", mw_ptr->ui->lineEdit_sw_remote_pwd));

    response.setHeader("Content-Type", "text/html; charset=UTF-8");
    QFile file(":/fmstick/html/index.html");
    if (file.open(QIODevice::ReadOnly)) {
        response.write(file.readAll());
        file.close();
    }

    response.write("<div class=\"logo_style\">"
                   "<img src=\"/images/Administrative Tools-64 (1).png\">"
                   "<h2>Software Configuration Controller</h2>");
    response.write("</div><div class=\"container\">");

    QString action(request.getParameter("action"));

    bool have_any_action=FALSE;
    if (map.contains(action)) {
        TableItem *table_data = map.value(action);
        response.write(table_data->doHTMLParse(&request));
        have_any_action=TRUE;
    }

    if(!have_any_action && action == "Software_custom"){
        qDebug() << "TODO: custom_Software action";
        have_any_action=TRUE;
    }
    if(have_any_action){
        response.write("<br/><a href=\"/sw\">[Back To Software Section]</a> | <a href=\"/\">[Back To Main Section]</a>");
    } else {
        response.write("<form><input type=\"hidden\" name=\"action\" value=\"dummy\">"
                       "<div class=\"row\">"
                       "<div class=\"prop\">"
                       "<p><b>Property</b></p>"
                       "</div>"
                       "<div class=\"val\">"
                       "<p><b>Value</b></p>"
                       "</div>"
                       "<div class=\"submit\">"
                       "<p><b>Action</b></p>"
                       "</div>"
                       "<div class=\"tooltip\">"
                       "<p><b>Tooltip</b></p>"
                       "</div>"
                       "</div></form>");
        QMapIterator<QString, TableItem *> i(map);
        while (i.hasNext()) {
            i.next();
            response.write(i.value()->GenHTMLForm());
        }
#if 0
        /* forcer */
        QString Software_custom = QString(
                    "<form method=\"post\">"
                    "  <input type=\"hidden\" name=\"action\" value=\"Software_custom\">"
                    "<div class=\"form_info\">Custom Software message:</div>"
                    "<div class=\"form_editor\">"
                    "<input type=\"text\" name=\"Software_custom_b\" value=\"4000\" size=\"4\">"
                    "<input type=\"text\" name=\"Software_custom_c\" value=\"0000\" size=\"4\">"
                    "<input type=\"text\" name=\"Software_custom_d\" value=\"0000\" size=\"4\">"
                    "Circular:<input type=\"checkbox\" name=\"Software_custom_circular\" value=\"0\">"
                    "</div>"
                    "<div class=\"form_submitter\"><input type=\"submit\" value=\"&gt;&gt;\"></div>"
                    "<div class=\"form_tooltip\"></div>"
                    "</form>");
         response.write(Software_custom.toUtf8());
#endif
    }

    response.write("</div></div></div></body></html>", true);

}
开发者ID:ghostro,项目名称:fmstick,代码行数:92,代码来源:softwarecontroller.cpp

示例5: buildStyleSheet

void QgisAppStyleSheet::buildStyleSheet( const QMap<QString, QVariant>& opts )
{
  QString ss = QString( "" );


  // QgisApp-wide font
  QString fontSize = opts.value( "fontPointSize" ).toString();
  QgsDebugMsg( QString( "fontPointSize: %1" ).arg( fontSize ) );
  if ( fontSize.isEmpty() ) { return; }

  QString fontFamily = opts.value( "fontFamily" ).toString();
  QgsDebugMsg( QString( "fontFamily: %1" ).arg( fontFamily ) );
  if ( fontFamily.isEmpty() ) { return; }

  ss += QString( "* { font: %1pt \"%2\"} " ).arg( fontSize ).arg( fontFamily );

  // QGroupBox and QgsCollapsibleGroupBox, mostly for Ubuntu and Mac
  bool gbxCustom = opts.value( "groupBoxCustom" ).toBool();
  QgsDebugMsg( QString( "groupBoxCustom: %1" ).arg( gbxCustom ) );
  bool gbxBoldTitle = opts.value( "groupBoxBoldTitle" ).toBool();
  QgsDebugMsg( QString( "groupBoxBoldTitle: %1" ).arg( gbxBoldTitle ) );
  bool sidebar = opts.value( "sidebarStyle" ).toBool();
  if ( gbxCustom || gbxBoldTitle )
  {
    ss += "QGroupBox{";
    if ( gbxBoldTitle )
    {
      // doesn't work for QGroupBox::title
      ss += QString( "color: rgb(%1,%1,%1);" ).arg( mMacStyle ? 25 : 60 );
      ss += "font-weight: bold;";
    }
    if ( gbxCustom )
    {
      ss += QString( "background-color: rgba(0,0,0,%1%);" )
            .arg( mWinOS && mStyle.startsWith( "windows" ) ? 0 : 3 );
      ss += "border: 1px solid rgba(0,0,0,20%);";
      ss += "border-radius: 5px;";
      ss += "margin-top: 2.5ex;";
      ss += QString( "margin-bottom: %1ex;" ).arg( mMacStyle ? 1.5 : 1 );
    }
    ss += "} ";
    if ( gbxCustom )
    {
      ss += "QGroupBox:flat{";
      ss += "background-color: rgba(0,0,0,0);";
      ss += "border: rgba(0,0,0,0);";
      ss += "} ";

      ss += "QGroupBox::title{";
      ss += "subcontrol-origin: margin;";
      ss += "subcontrol-position: top left;";
      ss += "margin-left: 6px;";
      if ( !( mWinOS && mStyle.startsWith( "windows" ) ) && !mOxyStyle )
      {
        ss += "background-color: rgba(0,0,0,0);";
      }
      ss += "} ";
    }
  }

  if ( sidebar )
  {
    QString style = "QListWidget#mOptionsListWidget {"
                    "    background-color: rgb(69, 69, 69, 220);"
                    "    outline: 0;"
                    "}"
                    "QListWidget#mOptionsListWidget::item {"
                    "    color: white;"
                    "    padding: 3px;"
                    "}"
                    "QListWidget#mOptionsListWidget::item::selected {"
                    "    color: black;"
                    "    background-color:palette(Window);"
                    "    padding-right: 0px;"
                    "}";
    ss += style;
  }

  //fix background issue for gnome desktop
  if ( mLinuxOS && mGtkStyle && !sidebar )
  {
    ss += "QListWidget#mOptionsListWidget{";
    ss += "background-color: white;";
    ss += "} ";
  }

  // Fix selection color on loosing focus (Windows)
  const QPalette palette = qApp->palette();

  ss += QString( "QTableView {"
                 "selection-background-color: %1;"
                 "selection-color: %2;"
                 "}" )
        .arg( palette.highlight().color().name() )
        .arg( palette.highlightedText().color().name() );

  QgsDebugMsg( QString( "Stylesheet built: %1" ).arg( ss ) );

  emit appStyleSheetChanged( ss );
}
开发者ID:ACorradini,项目名称:QGIS,代码行数:100,代码来源:qgisappstylesheet.cpp

示例6: if

/**
 * @brief Get's the correct object from the device.
 * !Important! Release Device after using the returned object
 * @param pathItems A QStringList containing the items of the filepath
 * @return QPair with the object and its device. pair.fist is a nullpointer if the object doesn't exist or for root or, depending on the pathItems size device (1), storage (2) or file (>=3)
 */
QPair<void*, LIBMTP_mtpdevice_t*> MTPSlave::getPath ( const QString& path )
{
    QStringList pathItems = path.split ( QLatin1Char ( '/' ), QString::SkipEmptyParts );

    kDebug ( KIO_MTP ) << path << pathItems.size();

    QPair<void*, LIBMTP_mtpdevice_t*> ret;

    // Don' handle the root directory
    if ( pathItems.size() <= 0 )
    {
        return ret;
    }

    QMap<QString, LIBMTP_raw_device_t*> devices = getRawDevices();

    if ( devices.contains ( pathItems.at ( 0 ) ) )
    {
        LIBMTP_mtpdevice_t *device = LIBMTP_Open_Raw_Device_Uncached ( devices.value ( pathItems.at ( 0 ) ) );

        // return specific device
        if ( pathItems.size() == 1 )
        {
            ret.first = device;
            ret.second = device;

            kDebug(KIO_MTP) << "returning LIBMTP_mtpdevice_t";
        }

        if ( pathItems.size() > 2 )
        {
            // Query Cache after we have the device
            uint32_t c_fileID = fileCache->queryPath ( path );
            if ( c_fileID != 0 )
            {
                kDebug() << "Match found in cache, checking device";

                LIBMTP_file_t* file = LIBMTP_Get_Filemetadata ( device, c_fileID );
                if ( file )
                {
                    kDebug ( KIO_MTP ) << "Found file in cache";
                    ret.first = file;
                    ret.second = device;

                    kDebug(KIO_MTP) << "returning LIBMTP_file_t";

                    return ret;
                }
            }
            // Query cache for parent
            else if ( pathItems.size() > 3 )
            {
                QString parentPath = convertToPath ( pathItems, pathItems.size() - 1 );
                uint32_t c_parentID = fileCache->queryPath ( parentPath );

                kDebug() << "Match for parent found in cache, checking device";

                LIBMTP_file_t* parent = LIBMTP_Get_Filemetadata ( device, c_parentID );
                if ( parent )
                {
                    kDebug ( KIO_MTP ) << "Found parent in cache";
                    fileCache->addPath( parentPath, c_parentID );

                    QMap<QString, LIBMTP_file_t*> files = getFiles ( device, parent->storage_id, c_parentID );

                    if ( files.contains ( pathItems.last() ) )
                    {
                        LIBMTP_file_t* file = files.value( pathItems.last() );

                        ret.first = file;
                        ret.second = device;

                        kDebug(KIO_MTP) << "returning LIBMTP_file_t";

                        fileCache->addPath( path, file->item_id );
                    }

                    return ret;
                }
            }
        }

        QMap<QString, LIBMTP_devicestorage_t*> storages = getDevicestorages ( device );

        if ( pathItems.size() > 1 && storages.contains ( pathItems.at ( 1 ) ) )
        {
            LIBMTP_devicestorage_t *storage = storages.value ( pathItems.at ( 1 ) );

            if ( pathItems.size() == 2 )
            {
                ret.first = storage;
                ret.second = device;

                kDebug(KIO_MTP) << "returning LIBMTP_devicestorage_t";
//.........这里部分代码省略.........
开发者ID:Arakmar,项目名称:kio-mtp,代码行数:101,代码来源:kio_mtp.cpp

示例7: insertUV

void UVManager::insertUV(QString code, QString titre, QMap<QString,int> cat,bool a, bool p){
    DatabaseManager& db = DatabaseManager::getInstanceDB();


    db.updateTableUV(a,p,code,titre,cat.value("CS"),cat.value("TM"),cat.value("TSH"),cat.value("SP"));
}
开发者ID:MikeNkunku,项目名称:Student-Recorder,代码行数:6,代码来源:UTProfiler.cpp

示例8: upload

int FlickrPrivate::upload(const FlickrPhoto &photo,
                          const FlickrRequest &request,
                          void* userData) {
    QByteArray boundary = generateBoundary();
    QByteArray payload;
    QDataStream dataStream(&payload, QIODevice::WriteOnly);

    QMap<QString,QString> map = photo.args;

    map.insert("api_key", _apiKey);
    if(!_token.isEmpty()) {
        map.insert("auth_token", _token);
    }

    bool uploading = photo.photoId.isEmpty();
    if(!uploading){
        map.insert("photo_id", photo.photoId);
    }

    QMapIterator<QString, QString> i(map);
    QStringList keyList;
    while(i.hasNext())
    {
        i.next();
        keyList << i.key();
    }
    qSort(keyList.begin(), keyList.end());

    QString apiSig(_apiSecret);
    for(int i = 0; i < keyList.size(); ++i) {
        apiSig.append(keyList.at(i) + map.value(keyList.at(i)));

        QByteArray field = constructField(keyList.at(i),map.value(keyList.at(i)),boundary);
        dataStream.writeRawData(field.data(), field.length());

    }

    apiSig = md5(apiSig);

    QByteArray sigField = constructField("api_sig", apiSig, boundary);
    dataStream.writeRawData(sigField.data(), sigField.length());

    QByteArray fileField = constructField("photo", "", boundary, photo.file);
    dataStream.writeRawData(fileField.data(), fileField.length());

    QFile file(photo.file);
    file.open(QIODevice::ReadOnly);
    while(!file.atEnd()) {
        QByteArray line = file.readLine();
        dataStream.writeRawData(line.data(),line.length());
    }

    file.close();

    QByteArray endField;
    endField.append("\r\n--");
    endField.append(boundary);
    endField.append("--\r\n\r\n");
    dataStream.writeRawData(endField.data(), endField.length());

    QString urlTmp("http://api.flickr.com/services/");
    urlTmp.append((uploading)?"upload/":"replace/");

    QNetworkRequest uploadRequest(urlTmp);
    uploadRequest.setRawHeader("Content-Type","multipart/form-data; boundary="+boundary);
    uploadRequest.setRawHeader("Host","ww.api.flickr.com");

    _requestCounter++;
    RequestData requestData;
    requestData.request = request.requests;
    requestData.userData = userData;
    requestData.requestId = _requestCounter;

    QNetworkReply *reply = _networkAccessManager->post(uploadRequest,payload);
    connect(reply,SIGNAL(uploadProgress(qint64, qint64)),
            this, SLOT(uploadProgress(qint64, qint64)));

    requestDataMap.insert(reply,requestData);
    return requestData.requestId;
}
开发者ID:sepych,项目名称:QtFlickr,代码行数:80,代码来源:flickr_p.cpp

示例9: simulatorCache

QVariantMap simulatorCache(int i, QIODevice *connection,
	const QSqlDatabase& db, const QSqlDatabase& user_db,
	const QVariantMap& action, const QString& email)
{
	Q_UNUSED(email);
	Q_UNUSED(user_db);
	Q_UNUSED(connection);

	QVariantMap map;

	// Check for the 'lang' paramater
	if( !action.contains("lang") )
		return param_error(tr("simulator_cache action"), tr("lang"),
			tr("action %1").arg(i));

	bool reload = false;
	if( action.contains("reload") )
	{
		if( !action.value("reload").canConvert(QVariant::Bool) )
			return herror("simulator_cache action", tr("reload must be a "
				"boolean value for action %1").arg(i));

		reload = action.value("reload").toBool();
	}

	QString lang = action.value("lang").toString().toLower();
	if(lang != "en" && lang != "ja")
		return herror("simulator_cache action", tr("parmater 'lang' for action "
			"%1 contains an illegal value").arg(i));

	if(simulator_cache.contains(lang) && !reload)
		return simulator_cache.value(lang);

	QString sql = "SELECT db_skills.id id, db_skills.name_{$lang} name, "
		"db_skills.icon icon, db_affinity.name_{$lang} affinity, "
		"db_expert.name_{$lang} expert, db_category.name_{$lang} category, "
		"db_skills.mp_cost mp_cost, db_skills.hp_cost hp_cost, "
		"db_skills.mag_cost mag_cost, db_action_type.name_{$lang} action_type, "
		"db_skills.desc_{$lang} desc, db_skills.class class, "
		"db_skills.rank rank, db_skills.inheritance inheritance, "
		"db_related_stat.name_{$lang} related_stat FROM db_skills LEFT JOIN "
		"db_affinity ON db_skills.affinity = db_affinity.id LEFT JOIN "
		"db_expert ON db_skills.expert = db_expert.id LEFT JOIN db_category ON "
		"db_skills.category = db_category.id LEFT JOIN db_action_type ON "
		"db_skills.action_type = db_action_type.id LEFT JOIN db_related_stat "
		"ON db_skills.related_stat = db_related_stat.id "
		"WHERE db_skills.player_only = 0 OR db_skills.player_only = 'false'";
	sql = sql.replace("{$lang}", lang);

	QSqlQuery query(db);
	if( !query.prepare(sql) )
		return herror_sql(db, "simulator_cache action", tr("SQL error for "
			"action %1: %2").arg(i).arg( query.lastError().text() ));

	if( !query.exec() )
		return herror_sql(db, "simulator_cache action", tr("SQL error for "
			"action %1: %2").arg(i).arg( query.lastError().text() ));

	QVariantList skills;
	while( query.next() )
	{
		QSqlRecord record = query.record();

		QVariantMap skill;
		for(int j = 0; j < record.count(); j++)
			skill[record.fieldName(j)] = record.value(j);

		skills << skill;
	}

	map["skills"] = skills;

	sql = "SELECT id, name_{$lang} name, desc_{$lang} desc FROM db_traits";
	sql = sql.replace("{$lang}", lang);

	if( !query.prepare(sql) )
		return herror_sql(db, "simulator_cache action", tr("SQL error for "
			"action %1: %2").arg(i).arg( query.lastError().text() ));

	if( !query.exec() )
		return herror_sql(db, "simulator_cache action", tr("SQL error for "
			"action %1: %2").arg(i).arg( query.lastError().text() ));

	QVariantList traits;
	while( query.next() )
	{
		QSqlRecord record = query.record();

		QVariantMap trait;
		for(int j = 0; j < record.count(); j++)
			trait[record.fieldName(j)] = record.value(j);

		traits << trait;
	}

	map["traits"] = traits;

	sql = "SELECT db_devils.id id, db_devils.name_{$lang} name, "
		"db_devils.icon icon, db_devils.lvl lvl, db_genus.name_{$lang} genus, "
		"db_growth_type.name_{$lang} growth_type, db_devils.lnc lnc, "
//.........这里部分代码省略.........
开发者ID:erikku,项目名称:frosty,代码行数:101,代码来源:SimulatorActions.cpp

示例10: loadSettings

bool ContextPrivate::loadSettings( QSettings &pSettings, bool pPartial )
{
	QSettings		CFG( pSettings.fileName(), pSettings.format() );

	QList<QSharedPointer<fugio::NodeInterface>>		NodeLst;

	QMap<QUuid,QUuid>		NodeMap;
	QMap<QUuid,QUuid>		PinsMap;

	pSettings.beginGroup( "nodes" );

	for( const QString &K : pSettings.childKeys() )
	{
		QString			NodeName     = K;
		const QUuid		NodeOrigUuid = fugio::utils::string2uuid( K );
		const QUuid		NodeUuid     = ( findNode( NodeOrigUuid ).isNull() ? NodeOrigUuid : QUuid::createUuid() );
		const QUuid		ControlUuid  = fugio::utils::string2uuid( pSettings.value( K ).toString() );
		QVariantHash	NodeData;

		if( CFG.childGroups().contains( K ) )
		{
			CFG.beginGroup( K );

			NodeName = CFG.value( "name", NodeName ).toString();

			if( CFG.childGroups().contains( "settings" ) )
			{
				QStringList		VarBse;

				CFG.beginGroup( "settings" );

				loadNodeSettings( CFG, NodeData, VarBse );

				CFG.endGroup();
			}

			CFG.endGroup();
		}

		QSharedPointer<fugio::NodeInterface>	N = createNode( NodeName, NodeUuid, ControlUuid, NodeData );

		if( !N )
		{
			qWarning() << "Can't create node" << NodeName;

			continue;
		}

		NodeLst << N;

		NodeMap.insert( NodeUuid, NodeOrigUuid );
	}

	pSettings.endGroup();

	//-------------------------------------------------------------------------

	for( QSharedPointer<fugio::NodeInterface> N : NodeLst )
	{
		const QUuid		NodeUuid = N->uuid();
		const QUuid		OrigUuid = NodeMap.value( N->uuid() );

		// do this before we registerNode() to give everyone a chance to record the relabel
		// and look up data

		if( NodeUuid != OrigUuid )
		{
			emit qobject()->nodeRelabled( OrigUuid, NodeUuid );
		}

		registerNode( N );

		pSettings.beginGroup( fugio::utils::uuid2string( OrigUuid ) );

		N->loadSettings( pSettings, PinsMap, pPartial );

		pSettings.endGroup();
	}

	//-------------------------------------------------------------------------

//	CFG.beginGroup( "connections" );

//	foreach( const QString &NodeDst, CFG.childGroups() )
//	{
//		CF2.beginGroup( NodeDst );

//		foreach( const QString &PinDst, CFG.childKeys() )
//		{
//			QStringList		 SrcList = CFG.value( PinDst ).toString().split( '\\' );

//			if( SrcList.size() != 2 )
//			{
//				continue;
//			}

//			mConnectionMap.insert( ConnectionPair( SrcList.at( 0 ), SrcList.at( 1 ) ), ConnectionPair( NodeDst, PinDst ) );
//		}

//		CFG.endGroup();
//.........这里部分代码省略.........
开发者ID:bigfug,项目名称:Fugio,代码行数:101,代码来源:contextprivate.cpp

示例11: computeAutoColor

QString Conversion::computeAutoColor(const wvWare::Word97::SHD& shd, const QString& bgColor, const QString& fontColor)
{
    // NOTE: by definition, see
    // http://social.msdn.microsoft.com/Forums/en-US/os_binaryfile/thread/a02a9a24-efb6-4ba0-a187-0e3d2704882b

#ifdef CONVERSION_DEBUG_SHD
    qDebug() << Q_FUNC_INFO;
    qDebug() << "bgColor:" << bgColor;
    qDebug() << "fontColor:" << fontColor;
    qDebug() << "ipat:" << shd.ipat;
    qDebug() << "cvBack:" << hex << shd.cvBack;
    qDebug() << "cvFore:" << hex << shd.cvFore;
#endif

    if (shd.isShdAuto() || shd.isShdNil()) {
        return contrastColor(bgColor);
    }

    QColor foreColor;
    QColor backColor;

    if (shd.cvFore == wvWare::Word97::cvAuto) {
        if (fontColor.isEmpty()) {
            foreColor = QColor(contrastColor(bgColor));
        } else {
            foreColor = QColor(fontColor);
        }
    } else {
        foreColor = QColor(QRgb(shd.cvFore));
    }

    if (shd.cvBack == wvWare::Word97::cvAuto) {
        if (bgColor.isEmpty()) {
            backColor = QColor(Qt::white).name();
        } else {
            backColor = QColor(bgColor);
        }
    } else {
        backColor = QColor(QRgb(shd.cvBack));
    }

    int luminosity = 0;

    if (shd.ipat == ipatAuto) {
        luminosity = luma(backColor);
    }
    else if (shd.ipat == ipatSolid) {
        luminosity = luma(foreColor);
    }
    else if ((shd.ipat > 13) && (shd.ipat < 34)) {
        luminosity = 61;
    } else {
        if (SHADING_TABLE.contains(shd.ipat)) {
            qreal pct = SHADING_TABLE.value(shd.ipat);
            luminosity = yMix( luma(foreColor), luma(backColor), pct);
        } else {
            // this should not happen, but it's binary data
            luminosity = 61;
        }
    }

#ifdef CONVERSION_DEBUG_SHD
    qDebug() << "ooooooooooooooooooooooooooooooo    chp: oooooooooooooooo bgColor:" << bgColor;
    qDebug() << "fontColor:" << fontColor;
    qDebug() << (shd.cvFore == wvWare::Word97::cvAuto);
    qDebug() << (shd.cvBack == wvWare::Word97::cvAuto);
    qDebug() << "ipat" << shd.ipat;
    qDebug() << "fore" << QString::number(shd.cvFore | 0xff000000, 16).right(6) << foreColor.name();
    qDebug() << "back" << QString::number(shd.cvBack | 0xff000000, 16).right(6) << backColor.name();
    qDebug() << "luminosity " << luminosity;
#endif

    if (luminosity <= 60) { // it is dark color
        // window background color
        return QColor(Qt::white).name();
    } else {
        // window text color
        return QColor(Qt::black).name();
    }

} //computeAutoColor
开发者ID:abhishekmurthy,项目名称:Calligra,代码行数:81,代码来源:conversion.cpp

示例12: processAlgorithm

QVariantMap QgsSplitWithLinesAlgorithm::processAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback )
{
  std::unique_ptr< QgsFeatureSource > source( parameterAsSource( parameters, QStringLiteral( "INPUT" ), context ) );
  if ( !source )
    throw QgsProcessingException( invalidSourceError( parameters, QStringLiteral( "INPUT" ) ) );

  std::unique_ptr< QgsFeatureSource > linesSource( parameterAsSource( parameters, QStringLiteral( "LINES" ), context ) );
  if ( !linesSource )
    throw QgsProcessingException( invalidSourceError( parameters, QStringLiteral( "LINES" ) ) );

  bool sameLayer = parameters.value( QStringLiteral( "INPUT" ) ) == parameters.value( QStringLiteral( "LINES" ) );

  QString dest;
  std::unique_ptr< QgsFeatureSink > sink( parameterAsSink( parameters, QStringLiteral( "OUTPUT" ), context, dest, source->fields(),
                                          QgsWkbTypes::multiType( source->wkbType() ),  source->sourceCrs() ) );
  if ( !sink )
    throw QgsProcessingException( invalidSinkError( parameters, QStringLiteral( "OUTPUT" ) ) );

  QgsSpatialIndex spatialIndex;
  QMap< QgsFeatureId, QgsGeometry > splitGeoms;
  QgsFeatureRequest request;
  request.setSubsetOfAttributes( QgsAttributeList() );
  request.setDestinationCrs( source->sourceCrs(), context.transformContext() );

  QgsFeatureIterator splitLines = linesSource->getFeatures( request );
  QgsFeature aSplitFeature;
  while ( splitLines.nextFeature( aSplitFeature ) )
  {
    if ( feedback->isCanceled() )
    {
      break;
    }

    splitGeoms.insert( aSplitFeature.id(), aSplitFeature.geometry() );
    spatialIndex.addFeature( aSplitFeature );
  }

  QgsFeature outFeat;
  QgsFeatureIterator features = source->getFeatures();

  double step = source->featureCount() > 0 ? 100.0 / source->featureCount() : 1;
  int i = 0;
  QgsFeature inFeatureA;
  while ( features.nextFeature( inFeatureA ) )
  {
    i++;
    if ( feedback->isCanceled() )
    {
      break;
    }

    if ( !inFeatureA.hasGeometry() )
    {
      sink->addFeature( inFeatureA, QgsFeatureSink::FastInsert );
      continue;
    }

    QgsGeometry inGeom = inFeatureA.geometry();
    outFeat.setAttributes( inFeatureA.attributes() );

    QVector< QgsGeometry > inGeoms = inGeom.asGeometryCollection();

    const QgsFeatureIds lines = spatialIndex.intersects( inGeom.boundingBox() ).toSet();
    if ( !lines.empty() ) // has intersection of bounding boxes
    {
      QVector< QgsGeometry > splittingLines;

      // use prepared geometries for faster intersection tests
      std::unique_ptr< QgsGeometryEngine > engine;

      for ( QgsFeatureId line : lines )
      {
        // check if trying to self-intersect
        if ( sameLayer && inFeatureA.id() == line )
          continue;

        QgsGeometry splitGeom = splitGeoms.value( line );
        if ( !engine )
        {
          engine.reset( QgsGeometry::createGeometryEngine( inGeom.constGet() ) );
          engine->prepareGeometry();
        }

        if ( engine->intersects( splitGeom.constGet() ) )
        {
          QVector< QgsGeometry > splitGeomParts = splitGeom.asGeometryCollection();
          splittingLines.append( splitGeomParts );
        }
      }

      if ( !splittingLines.empty() )
      {
        for ( const QgsGeometry &splitGeom : qgis::as_const( splittingLines ) )
        {
          QVector<QgsPointXY> splitterPList;
          QVector< QgsGeometry > outGeoms;

          // use prepared geometries for faster intersection tests
          std::unique_ptr< QgsGeometryEngine > splitGeomEngine( QgsGeometry::createGeometryEngine( splitGeom.constGet() ) );
          splitGeomEngine->prepareGeometry();
//.........这里部分代码省略.........
开发者ID:phborba,项目名称:QGIS,代码行数:101,代码来源:qgsalgorithmsplitwithlines.cpp

示例13: QString

bool QXmppSaslClientDigestMd5::respond(const QByteArray &challenge, QByteArray &response)
{
    Q_UNUSED(challenge);
    const QByteArray digestUri = QString("%1/%2").arg(serviceType(), host()).toUtf8();

    if (m_step == 0) {
        response = QByteArray();
        m_step++;
        return true;
    } else if (m_step == 1) {
        const QMap<QByteArray, QByteArray> input = QXmppSaslDigestMd5::parseMessage(challenge);

        if (!input.contains("nonce")) {
            warning("QXmppSaslClientDigestMd5 : Invalid input on step 1");
            return false;
        }

        // determine realm
        const QByteArray realm = input.value("realm");

        // determine quality of protection
        const QList<QByteArray> qops = input.value("qop", "auth").split(',');
        if (!qops.contains("auth")) {
            warning("QXmppSaslClientDigestMd5 : Invalid quality of protection");
            return false;
        }

        m_nonce = input.value("nonce");
        m_secret = QCryptographicHash::hash(
            username().toUtf8() + ":" + realm + ":" + password().toUtf8(),
            QCryptographicHash::Md5);

        // Build response
        QMap<QByteArray, QByteArray> output;
        output["username"] = username().toUtf8();
        if (!realm.isEmpty())
            output["realm"] = realm;
        output["nonce"] = m_nonce;
        output["qop"] = "auth";
        output["cnonce"] = m_cnonce;
        output["nc"] = m_nc;
        output["digest-uri"] = digestUri;
        output["response"] = calculateDigest("AUTHENTICATE", digestUri, m_secret, m_nonce, m_cnonce, m_nc);
        output["charset"] = "utf-8";

        response = QXmppSaslDigestMd5::serializeMessage(output);
        m_step++;
        return true;
    } else if (m_step == 2) {
        const QMap<QByteArray, QByteArray> input = QXmppSaslDigestMd5::parseMessage(challenge);

        // check new challenge
        if (input.value("rspauth") != calculateDigest(QByteArray(), digestUri, m_secret, m_nonce, m_cnonce, m_nc)) {
            warning("QXmppSaslClientDigestMd5 : Invalid challenge on step 2");
            return false;
        }

        response = QByteArray();
        m_step++;
        return true;
    } else {
        warning("QXmppSaslClientDigestMd5 : Invalid step");
        return false;
    }
}
开发者ID:Lerentis,项目名称:qxmpp,代码行数:65,代码来源:QXmppSasl.cpp

示例14:

const PalettePreset::Coeffs PalettePreset::CoeffsGet(const QString &name)
{
    return presets.value(name);
}
开发者ID:PheeL79,项目名称:lightpen,代码行数:4,代码来源:palette_preset.cpp

示例15: keyword


//.........这里部分代码省略.........
        QString keyword(QStringLiteral("%count"));
        extraParams.insert(QStringLiteral("resultmessage"), i18n("Found %1 scenes.", keyword));
        extraParams.insert(QStringLiteral("resize_profile"), QStringLiteral("160"));
        if (ui.store_data->isChecked()) {
            // We want to save result as clip metadata
            extraParams.insert(QStringLiteral("storedata"), QStringLiteral("1"));
        }
        if (ui.zone_only->isChecked()) {
            // We want to analyze only clip zone
            extraParams.insert(QStringLiteral("zoneonly"), QStringLiteral("1"));
        }
        if (ui.add_markers->isChecked()) {
            // We want to create markers
            extraParams.insert(QStringLiteral("addmarkers"), QString::number(ui.marker_type->currentIndex()));
            extraParams.insert(QStringLiteral("label"), i18n("Scene "));
        }
        if (ui.cut_scenes->isChecked()) {
            // We want to cut scenes
            extraParams.insert(QStringLiteral("cutscenes"), QStringLiteral("1"));
        }
        delete d;
        
        for (int i = 0; i < clips.count(); i++) {
            // Set clip specific infos

            // in and out
            int in = 0;
            int out = -1;
            ProjectClip *clip = clips.at(i);
            if (extraParams.contains(QStringLiteral("zoneonly"))) {
                // Analyse clip zone only, remove in / out and replace with zone
                QPoint zone = clip->zone();
                in = zone.x();
                out = zone.y();
            }
            producerParams.insert(QStringLiteral("in"), QString::number(in));
            producerParams.insert(QStringLiteral("out"), QString::number(out));
            producerParams.insert(QStringLiteral("producer"), sources.at(i));
            
            // Destination
            // Since this job is only doing analysis, we have a null consumer and no destination
            MeltJob *job = new MeltJob(clip->clipType(), clip->clipId(), producerParams, filterParams, consumerParams, extraParams);
            job->description = i18n("Auto split");
            jobs.insert(clip, job);
        }
        return jobs;
    }
    if (filterName == QLatin1String("vidstab")) {
        // vidstab 
        QPointer<ClipStabilize> d = new ClipStabilize(sources, filterName);
        if (d->exec() == QDialog::Accepted) {
            QMap <QString, QString> producerParams = d->producerParams();
            QMap <QString, QString> filterParams = d->filterParams();
            QMap <QString, QString> consumerParams = d->consumerParams();
            QMap <QString, QString> extraParams;
            extraParams.insert(QStringLiteral("producer_profile"), QStringLiteral("1"));
            QString destination = d->destination();
            QUrl trffile;
            for (int i = 0; i < clips.count(); i++) {
                // Set clip specific infos

                // in and out
                int in = 0;
                int out = -1;
                ProjectClip *clip = clips.at(i);
                if (extraParams.contains(QStringLiteral("zoneonly"))) {
                    // Analyse clip zone only, remove in / out and replace with zone
                    QPoint zone = clip->zone();
                    in = zone.x();
                    out = zone.y();
                }
                producerParams.insert(QStringLiteral("in"), QString::number(in));
                producerParams.insert(QStringLiteral("out"), QString::number(out));
                producerParams.insert(QStringLiteral("producer"), sources.at(i));

                // Consumer
                QString consumerName = consumerParams.value(QStringLiteral("consumer"));
                if (clips.count() == 1) {
                    // We only have one clip, destination points to the final url
                    consumerParams.insert(QStringLiteral("consumer"), consumerName + ':' + destination);
                    trffile = QUrl::fromLocalFile(destination + ".trf");
                } else {
                    // Filter several clips, destination points to a folder
                    QString mltfile = destination + clip->url().fileName() + ".mlt";
                    consumerParams.insert(QStringLiteral("consumer"), consumerName + ':' + mltfile);
                    trffile = QUrl::fromLocalFile(mltfile + ".trf");
                }
                // Append a 'filename' parameter for saving vidstab data
                filterParams.insert(QStringLiteral("filename"), trffile.path());
                MeltJob *job = new MeltJob(clip->clipType(), clip->clipId(), producerParams, filterParams, consumerParams, extraParams);
                job->setAddClipToProject(d->autoAddClip());
                job->description = d->desc();
                jobs.insert(clip, job);
            }
        }
        delete d;
        return jobs;
    }
    return jobs;
}
开发者ID:kamalmostafa,项目名称:kdenlive,代码行数:101,代码来源:filterjob.cpp


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