Beispiel #1
0
QGeoRouteReply* QGeoRoutingManagerEngineNokia::updateRoute(const QGeoRoute &route, const QGeoCoordinate &position)
{
    QString reqString = updateRouteRequestString(route, position);

    if (reqString.isEmpty() ||  m_serviceDisabled) {
        QGeoRouteReply *reply = new QGeoRouteReply(QGeoRouteReply::UnsupportedOptionError, "The given route request options are not supported by this service provider.", this);
        emit error(reply, reply->error(), reply->errorString());
        return reply;
    }

    QNetworkReply *networkReply = m_networkManager->get(QNetworkRequest(QUrl(reqString)));
    QGeoRouteRequest updateRequest(route.request());
    updateRequest.setTravelModes(route.travelMode());
    QGeoRouteReplyNokia *reply = new QGeoRouteReplyNokia(updateRequest, networkReply, this);

    connect(reply,
            SIGNAL(finished()),
            this,
            SLOT(routeFinished()));

    connect(reply,
            SIGNAL(error(QGeoRouteReply::Error, QString)),
            this,
            SLOT(routeError(QGeoRouteReply::Error, QString)));

    return reply;
}
Beispiel #2
0
int qmapcontrol::MapControl::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QWidget::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: mouseEventCoordinate((*reinterpret_cast< const QMouseEvent*(*)>(_a[1])),(*reinterpret_cast< const QPointF(*)>(_a[2]))); break;
        case 1: boxDragged((*reinterpret_cast< const QRectF(*)>(_a[1]))); break;
        case 2: geometryClicked((*reinterpret_cast< Geometry*(*)>(_a[1])),(*reinterpret_cast< QPoint(*)>(_a[2]))); break;
        case 3: viewChanged((*reinterpret_cast< const QPointF(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break;
        case 4: zoomIn(); break;
        case 5: zoomOut(); break;
        case 6: setZoom((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 7: scrollLeft((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 8: scrollLeft(); break;
        case 9: scrollRight((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 10: scrollRight(); break;
        case 11: scrollUp((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 12: scrollUp(); break;
        case 13: scrollDown((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 14: scrollDown(); break;
        case 15: scroll((*reinterpret_cast< const QPoint(*)>(_a[1]))); break;
        case 16: updateRequest((*reinterpret_cast< QRect(*)>(_a[1]))); break;
        case 17: updateRequestNew(); break;
        case 18: resize((*reinterpret_cast< const QSize(*)>(_a[1]))); break;
        case 19: tick(); break;
        case 20: loadingFinished(); break;
        case 21: positionChanged((*reinterpret_cast< Geometry*(*)>(_a[1]))); break;
        default: ;
        }
        _id -= 22;
    }
    return _id;
}
    void LayerManager::addLayer(Layer* layer)
    {
        mylayers.append(layer);

        layer->setSize(size);

        connect(layer, SIGNAL(updateRequest(QRectF)),
                this, SLOT(updateRequest(QRectF)));
        connect(layer, SIGNAL(updateRequest()),
                this, SLOT(updateRequest()));

        if (mylayers.size()==1)
        {
            setView(QPointF(0,0));
        }
    }
Beispiel #4
0
void QDeclarativeTextEditPrivate::init()
{
    Q_Q(QDeclarativeTextEdit);

    q->setSmooth(smooth);
    q->setAcceptedMouseButtons(Qt::LeftButton);
    q->setFlag(QGraphicsItem::ItemHasNoContents, false);
    q->setFlag(QGraphicsItem::ItemAcceptsInputMethod);

    control = new QTextControl(q);
    control->setIgnoreUnusedNavigationEvents(true);

    QObject::connect(control, SIGNAL(updateRequest(QRectF)), q, SLOT(updateImgCache(QRectF)));

    QObject::connect(control, SIGNAL(textChanged()), q, SLOT(q_textChanged()));
    QObject::connect(control, SIGNAL(selectionChanged()), q, SIGNAL(selectionChanged()));
    QObject::connect(control, SIGNAL(selectionChanged()), q, SLOT(updateSelectionMarkers()));
    QObject::connect(control, SIGNAL(cursorPositionChanged()), q, SLOT(updateSelectionMarkers()));
    QObject::connect(control, SIGNAL(cursorPositionChanged()), q, SIGNAL(cursorPositionChanged()));

    document = control->document();
    document->setDefaultFont(font);
    document->setDocumentMargin(textMargin);
    document->setUndoRedoEnabled(false); // flush undo buffer.
    document->setUndoRedoEnabled(true);
    updateDefaultTextOption();
}
Beispiel #5
0
int qmapcontrol::Layer::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QObject::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: geometryClicked((*reinterpret_cast< Geometry*(*)>(_a[1])),(*reinterpret_cast< QPoint(*)>(_a[2]))); break;
        case 1: updateRequest((*reinterpret_cast< QRectF(*)>(_a[1]))); break;
        case 2: updateRequest(); break;
        case 3: setVisible((*reinterpret_cast< bool(*)>(_a[1]))); break;
        default: ;
        }
        _id -= 4;
    }
    return _id;
}
void Update::updateFinished(QNetworkReply *reply)
{
    reply->deleteLater();

    QString update_url = reply->property("update_url").toString();

    if (reply->error())
        hUpdateResults[update_url] = QString::null;
    else
    {
        QVariant possibleRedirectUrl = reply->attribute(QNetworkRequest::RedirectionTargetAttribute);
        if (!possibleRedirectUrl.toUrl().isEmpty())
        {
            updateRequest("GET", possibleRedirectUrl.toString(), update_url);
            return;
        }

        QString strUpdateXml = reply->readAll();

        hUpdateResults[update_url] = strUpdateXml;
    }

    if (hUpdateResults.size() == 1)
    {
        checkUpdateGithub();
    }
    else if (hUpdateResults.size() == 2)
    {
        int updateSourceforge = fastParseVersion(hUpdateResults.value(UPDATE_URL_SOURCEFORGE));
        int updateGithub = fastParseVersion(hUpdateResults.value(UPDATE_URL_GITHUB));

        if ((updateSourceforge != 0) && (updateGithub != 0))
        {
            if (updateSourceforge >= updateGithub)
                saveUpdate(hUpdateResults.value(UPDATE_URL_SOURCEFORGE));
            else
                saveUpdate(hUpdateResults.value(UPDATE_URL_GITHUB));

            if (!Settings::instance()->get("motd").isEmpty())
            {
                QString strMOTD = Settings::instance()->get("motd");
                QString strMessageOfTheDay = QString("%Fb%%1 %2").arg(tr("Message Of The Day:"), strMOTD);
                Message::instance()->showMessage(STATUS_WINDOW, strMessageOfTheDay, MessageDefault);
            }

            if (Settings::instance()->get("available_version") != "0.0.0.0")
            {
                QString strVersionStatus = fullParseVersion();

                // save status
                Settings::instance()->set("version_status", strVersionStatus);

                if (Settings::instance()->get("updates") == "true")
                    Notification::instance()->refreshUpdate();
            }
        }
    }
}
Beispiel #7
0
 void Layer::sendGeometryToBack(Geometry *geometry)
 {
     if ( !geometry || !geometries.contains( geometry ) )
     {
         return;
     }
     geometries.removeAll(geometry);
     geometries.append(geometry);
     emit(updateRequest());
 }
Beispiel #8
0
Status updateShardCollectionsEntry(OperationContext* opCtx,
                                   const BSONObj& query,
                                   const BSONObj& update,
                                   const BSONObj& inc,
                                   const bool upsert) {
    invariant(query.hasField("_id"));
    if (upsert) {
        // If upserting, this should be an update from the config server that does not have shard
        // refresh information.
        invariant(!update.hasField(ShardCollectionType::refreshing()));
        invariant(!update.hasField(ShardCollectionType::refreshSequenceNumber()));
        invariant(inc.isEmpty());
    }

    // Want to modify the document, not replace it.
    BSONObjBuilder updateBuilder;
    updateBuilder.append("$set", update);
    if (!inc.isEmpty()) {
        updateBuilder.append("$inc", inc);
    }

    std::unique_ptr<BatchedUpdateDocument> updateDoc(new BatchedUpdateDocument());
    updateDoc->setQuery(query);
    updateDoc->setUpdateExpr(updateBuilder.obj());
    updateDoc->setUpsert(upsert);

    std::unique_ptr<BatchedUpdateRequest> updateRequest(new BatchedUpdateRequest());
    updateRequest->addToUpdates(updateDoc.release());

    BatchedCommandRequest request(updateRequest.release());
    request.setNS(NamespaceString(ShardCollectionType::ConfigNS));
    request.setWriteConcern(kLocalWriteConcern.toBSON());
    BSONObj cmdObj = request.toBSON();

    try {
        DBDirectClient client(opCtx);

        rpc::UniqueReply commandResponse = client.runCommandWithMetadata(
            "config", cmdObj.firstElementFieldName(), rpc::makeEmptyMetadata(), cmdObj);
        BSONObj responseReply = commandResponse->getCommandReply().getOwned();

        Status commandStatus = getStatusFromCommandResult(commandResponse->getCommandReply());
        if (!commandStatus.isOK()) {
            return commandStatus;
        }

        return Status::OK();
    } catch (const DBException& ex) {
        return {ex.toStatus().code(),
                str::stream() << "Failed to apply the update '" << request.toString()
                              << "' to config.collections"
                              << causedBy(ex.toStatus())};
    }
}
Beispiel #9
0
		void InterfacePageAdmin::display(
			ostream& stream,
			const server::Request& _request
		) const	{

			AdminActionFunctionRequest<InterfacePageUpdateAction,InterfacePageAdmin> updateRequest(_request, *this);
			updateRequest.getAction()->setPage(const_pointer_cast<InterfacePage>(_page));

			PropertiesHTMLTable p(updateRequest.getHTMLForm());
			stream << p.open();
			stream << p.cell("Code source", p.getForm().getTextAreaInput(InterfacePageUpdateAction::PARAMETER_SOURCE, _page->getSource(), 50, 100, false));
			stream << p.close();

		}
Beispiel #10
0
void CodeEditor::updateDebugLine(int number)
{
    //number > 0 => highlight line
    //number == -1 => exit from debug mode
    //number == -2 => does not highlight any line, but does not exit from debug mode
    //last case for waiting program stops on next instruction or breakpoint
    if (number == -1)
        setDebugMode(false);
    else
        setDebugMode(true);
    if (number != -2)
        currentDebugLine = number;

    //create rectangle of line number area and highlight debug line throw updateRequest()
    QRect lineNumberAreaRect(lineNumberArea->x(), lineNumberArea->y(),
                             lineNumberArea->width(), lineNumberArea->height());
    emit updateRequest(lineNumberAreaRect, 0);

    highlightDebugLine(number);
    highlightCurrentLine();
}
Beispiel #11
0
void QLabelPrivate::ensureTextControl() const
{
    Q_Q(const QLabel);
    if (!isTextLabel)
        return;
    if (!control) {
        control = new QWidgetTextControl(const_cast<QLabel *>(q));
        control->document()->setUndoRedoEnabled(false);
        control->document()->setDefaultFont(q->font());
        control->setTextInteractionFlags(textInteractionFlags);
        control->setOpenExternalLinks(openExternalLinks);
        control->setPalette(q->palette());
        control->setFocus(q->hasFocus());
        QObject::connect(control, SIGNAL(updateRequest(QRectF)),
                         q, SLOT(update()));
        QObject::connect(control, SIGNAL(linkHovered(QString)),
                         q, SLOT(_q_linkHovered(QString)));
        QObject::connect(control, SIGNAL(linkActivated(QString)),
                         q, SIGNAL(linkActivated(QString)));
        textLayoutDirty = true;
        textDirty = true;
    }
}
Beispiel #12
0
    void Layer::removeGeometry(Geometry* geometry, bool qDeleteObject)
    {
        if ( !geometry )
        {
            return;
        }

        QRectF boundingBox = geometry->boundingBox();

        foreach( Geometry* geo, geometries )
        {
            if ( geo && geo == geometry )
            {
                disconnect(geometry);
                geometries.removeAll( geometry );
                if (qDeleteObject)
                {
                    delete geo;
                    geo = 0;
                }
            }
        }
        emit(updateRequest(boundingBox));
    }
Beispiel #13
0
std::unique_ptr<BatchedUpdateRequest> ShardIdentityType::createUpsertForAddShard() const {
    invariant(validate().isOK());

    std::unique_ptr<BatchedUpdateDocument> updateDoc(new BatchedUpdateDocument());

    BSONObjBuilder query;
    query.append("_id", "shardIdentity");
    query.append("shardName", getShardName());
    query.append("clusterId", getClusterId());
    updateDoc->setQuery(query.obj());

    BSONObjBuilder update;
    BSONObjBuilder setConfigBuilder(update.subobjStart("$set"));
    setConfigBuilder.append(configsvrConnString(), getConfigsvrConnString().toString());
    setConfigBuilder.doneFast();
    updateDoc->setUpdateExpr(update.obj());

    updateDoc->setUpsert(true);

    std::unique_ptr<BatchedUpdateRequest> updateRequest(new BatchedUpdateRequest());
    updateRequest->addToUpdates(updateDoc.release());

    return updateRequest;
}
void Update::checkUpdateSourceforge()
{
    updateRequest("POST", UPDATE_URL_SOURCEFORGE, UPDATE_URL_SOURCEFORGE);
}
int
ParserCWHandler::getURL( const MC2String& urlStr, 
                         const MC2String& postData,
                         uint32 peerIP, uint32 fromByte, uint32 toByte,
                         LangTypes::language_t clientLang,
                         const HttpHeader* inHeaders,
                         HttpHeader& outHeaders, MC2String& reply,
                         uint32& startByte, uint32& endByte )
{
   uint32 startTime = TimeUtility::getCurrentTime();

   // Work with url
   MC2String serverURLStr( urlStr );
   mc2dbg2 << "serverURLStr " << serverURLStr << endl;
   updateRequest( serverURLStr, clientLang );

   bool fetchedThruProxy = false;
   if ( serverURLStr.find( "://sendThruProxyServer" ) != MC2String::npos ) {
      // This url should be fetched thru the proxy server
      
      // Remove 'sendThruProxyServer' from URL
      STLStringUtility::replaceString( serverURLStr, 
                                       "://sendThruProxyServer/",
                                       "://" );

      URL url(serverURLStr);
      HttpBody outBody;
      HttpVariableContainer myVar;
      myVar.https = ( serverURLStr.find( "https://" ) != MC2String::npos );
      
      // Fetch the url thru proxy server. If proxy fails it will be fetched without
      // proxy below.
      fetchedThruProxy =
         HttpProxyFunctions::fetchThruProxy( url, &outHeaders, &outBody, m_thread, &myVar );
      if ( fetchedThruProxy ) {
         // Successfully fetched thru proxy
         reply.append( outBody.getBody(), outBody.getBodyLength() );      
      } 
   }
   
   // Work with url
   mc2dbg2 << "serverURLStr " << serverURLStr << endl;
   updateRequest( serverURLStr, clientLang );
   URL url2( serverURLStr );
   int ures = 0;
   uint32 timeout = Properties::getUint32Property( "CW_TIMEOUT", 
                                                   5000 );
   
   if ( ! fetchedThruProxy ) {
      if ( serverURLStr.find( "internalInThisProcess" ) != MC2String::npos ) {
         // Handle internally
         reply.clear();
         if ( serverURLStr.find("/TMap/") != MC2String::npos ) {
            MC2String urlParam = STLStringUtility::basename( url2.getFile() );
            if ( !urlParam.empty() ) {
               DataBuffer* d = m_thread->getTileMap( urlParam.c_str() );
               if ( d != NULL ) {
                  ures = 200;
                  reply.append( reinterpret_cast<char*>( d->getBufferAddress() ),
                                d->getCurrentOffset() );
                  outHeaders.setStartLine( 200 );
               } else {
                  outHeaders.setStartLine( 503 );
               }
               delete d;
            }
         }
      }  else {
         // Send request using the parserthreads urlfetcher
         URLFetcher* f = m_thread->getURLFetcher();
         HttpHeader sendHeaders; // Extra headers to send
         // TODO: Add byterange using fromByte and toByte if not 0,MAX_UINT32
         //       so we don't download whole file all the time.
         MC2String peerIPstr = NetUtility::ip2str( peerIP );
         sendHeaders.addHeaderLine( "X-Forwarded-For", peerIPstr );
         
         static const MC2String notForwardHeadersStr[] = {
            "X-WAYF-CT",
            HttpHeaderLines::CONTENT_TYPE,
            HttpHeaderLines::CONTENT_LENGTH,
            HttpHeaderLines::CONNECTION,
            HttpHeaderLines::TRANSFER_ENCODING,
            HttpHeaderLines::X_FORWARDED_FOR,
            HttpHeaderLines::PROXY_CONNECTION,
            HttpHeaderLines::HOST,
            HttpHeaderLines::TE,
            HttpHeaderLines::TRAILER,
            HttpHeaderLines::KEEP_ALIVE,
            HttpHeaderLines::PROXY_AUTHENTICATE,
            HttpHeaderLines::PROXY_AUTHORIZATION,
            HttpHeaderLines::UPGRADE,
         };
         // TODO: Also remove all headers in Connection: header. Like
         //       "Connection: Keep-Alive, Trailer" should delete those two.
         static const set< MC2String, strNoCaseCompareLess > notForwardHeaders( 
            BEGIN_ARRAY( notForwardHeadersStr ), 
            END_ARRAY( notForwardHeadersStr ) );
         
         if ( inHeaders != NULL ) {
            const HttpHeader::HeaderMap& headers = inHeaders->getHeaderMap();
            for ( HttpHeader::HeaderMap::const_iterator it = headers.begin() ;
                  it != headers.end() ; ++it ) {
               if ( notForwardHeaders.find( it->first ) == 
                    notForwardHeaders.end() ) {
                  sendHeaders.addHeaderLine( it->first, *it->second );
               }
            }
         }
         
         if ( postData.empty() ) {
            ures = f->get(  reply, outHeaders, url2, 
                            timeout, &sendHeaders );
         } else {
            if ( inHeaders->getHeaderValue( "X-WAYF-CT" ) != NULL ) {
               sendHeaders.addHeaderLine( 
                  HttpHeaderLines::CONTENT_TYPE,
                  *inHeaders->getHeaderValue( "X-WAYF-CT" ) );
            } else {
               sendHeaders.addHeaderLine( 
                  HttpHeaderLines::CONTENT_TYPE, 
                  "application/x-www-form-urlencoded" );
            }
            ures = f->post( reply, outHeaders, url2, postData, 
                            timeout, &sendHeaders );
         }
         // Reset user agent
         //f->setDefaultUserAgent();
      }
   } // if (! fetchedThruProxy )
   
   // Remove chunked-encoding from reply (if present)
   const MC2String teh( "Transfer-Encoding" );
   const MC2String* te = outHeaders.getHeaderValue( &teh );
   if ( te != NULL && ( te->find( "chunked") != MC2String::npos ) ) {
      outHeaders.deleteHeaderLine( &teh );
   }
      
   // Check if web updated user
   const MC2String wfidh( "X-WFID-UPDATE" );
   const MC2String* wfid = outHeaders.getHeaderValue( &wfidh );
   if ( wfid != NULL ) {
      // Remove the uin from user cache
      uint32 uin = STLStringUtility::strtoul( *wfid );
      m_group->removeUserFromCache( uin );

      // And remove the header
      outHeaders.deleteHeaderLine( &wfidh );
   }

   // Make reply
   const MC2String eol( "\r\n" );
   if ( fromByte > toByte ) {
      toByte = fromByte;
   }
   const uint32 maxBytes = toByte - fromByte;
   uint32 lastByte = uint32( MAX( int32(reply.size()) - 1, 0 ) );
   startByte = MIN( fromByte, lastByte );
   endByte = startByte + MIN( lastByte - startByte, maxBytes );

   if ( ures > 0 && reply.size() > 0 && 
        (endByte != lastByte || startByte != 0) ) 
   {
      // Set byte range in reply
      MC2String rangeStr( "bytes " );
      STLStringUtility::uint2str( startByte, rangeStr );
      rangeStr.append( "-" );
      STLStringUtility::uint2str( endByte, rangeStr );
      rangeStr.append( "/" );
      STLStringUtility::uint2str( reply.size(), rangeStr ); // Real size
      outHeaders.addHeaderLine( "Content-Range", rangeStr );
      rangeStr = "";
      STLStringUtility::uint2str( endByte - startByte + 1, rangeStr );
      // Set right content length
      outHeaders.addHeaderLine( "Content-Length", rangeStr );
      // Set startline with 206 Partial Content
      MC2String responce( outHeaders.getStartLine()->substr( 0, 9 ) );
      responce.append( "206 Partial Content" );
      responce.append( eol );
      outHeaders.setStartLine( new MC2String( responce ) );
   } else if ( ures < 0 || outHeaders.getStartLine() == NULL ) {
      if ( TimeUtility::getCurrentTime() - startTime >= timeout ) {
         outHeaders.setStartLine( 503 );
      } else {
         outHeaders.setStartLine( 500 );
      }
   } else {
      // Set startline with eol
      outHeaders.setStartLine( 
         new MC2String( StringUtility::trimStartEnd( 
                           *outHeaders.getStartLine() ) + eol ) );
   }

   return ures;
}
void Update::checkUpdateGithub()
{
    updateRequest("GET", UPDATE_URL_GITHUB, UPDATE_URL_GITHUB);
}
Beispiel #17
0
 void Geometry::setVisible(bool visible)
 {
     this->visible = visible;
     emit(updateRequest(boundingBox()));
 }
Beispiel #18
0
    Status WriteCmd::explain(OperationContext* txn,
                             const std::string& dbname,
                             const BSONObj& cmdObj,
                             ExplainCommon::Verbosity verbosity,
                             BSONObjBuilder* out) const {
        // For now we only explain update and delete write commands.
        if ( BatchedCommandRequest::BatchType_Update != _writeType &&
             BatchedCommandRequest::BatchType_Delete != _writeType ) {
            return Status( ErrorCodes::IllegalOperation,
                           "Only update and delete write ops can be explained" );
        }

        // Parse the batch request.
        BatchedCommandRequest request( _writeType );
        std::string errMsg;
        if ( !request.parseBSON( cmdObj, &errMsg ) || !request.isValid( &errMsg ) ) {
            return Status( ErrorCodes::FailedToParse, errMsg );
        }

        // Note that this is a runCommmand, and therefore, the database and the collection name
        // are in different parts of the grammar for the command. But it's more convenient to
        // work with a NamespaceString. We built it here and replace it in the parsed command.
        // Internally, everything work with the namespace string as opposed to just the
        // collection name.
        NamespaceString nsString(dbname, request.getNS());
        request.setNSS(nsString);

        // Do the validation of the batch that is shared with non-explained write batches.
        Status isValid = WriteBatchExecutor::validateBatch( request );
        if (!isValid.isOK()) {
            return isValid;
        }

        // Explain must do one additional piece of validation: For now we only explain
        // singleton batches.
        if ( request.sizeWriteOps() != 1u ) {
            return Status( ErrorCodes::InvalidLength,
                           "explained write batches must be of size 1" );
        }

        // Get a reference to the singleton batch item (it's the 0th item in the batch).
        BatchItemRef batchItem( &request, 0 );

        if ( BatchedCommandRequest::BatchType_Update == _writeType ) {
            // Create the update request.
            UpdateRequest updateRequest( nsString );
            updateRequest.setQuery( batchItem.getUpdate()->getQuery() );
            updateRequest.setUpdates( batchItem.getUpdate()->getUpdateExpr() );
            updateRequest.setMulti( batchItem.getUpdate()->getMulti() );
            updateRequest.setUpsert( batchItem.getUpdate()->getUpsert() );
            updateRequest.setUpdateOpLog( true );
            UpdateLifecycleImpl updateLifecycle( true, updateRequest.getNamespaceString() );
            updateRequest.setLifecycle( &updateLifecycle );
            updateRequest.setExplain();

            // Explained updates can yield.
            updateRequest.setYieldPolicy(PlanExecutor::YIELD_AUTO);

            OpDebug* debug = &txn->getCurOp()->debug();

            ParsedUpdate parsedUpdate( txn, &updateRequest );
            Status parseStatus = parsedUpdate.parseRequest();
            if ( !parseStatus.isOK() ) {
                return parseStatus;
            }

            // Explains of write commands are read-only, but we take write locks so
            // that timing info is more accurate.
            AutoGetDb autoDb( txn, nsString.db(), MODE_IX );
            Lock::CollectionLock colLock( txn->lockState(), nsString.ns(), MODE_IX );

            // We check the shard version explicitly here rather than using Client::Context,
            // as Context can do implicit database creation if the db does not exist. We want
            // explain to be a no-op that reports a trivial EOF plan against non-existent dbs
            // or collections.
            ensureShardVersionOKOrThrow( nsString.ns() );

            // Get a pointer to the (possibly NULL) collection.
            Collection* collection = NULL;
            if ( autoDb.getDb() ) {
                collection = autoDb.getDb()->getCollection( txn, nsString.ns() );
            }

            PlanExecutor* rawExec;
            uassertStatusOK(getExecutorUpdate(txn, collection, &parsedUpdate, debug, &rawExec));
            boost::scoped_ptr<PlanExecutor> exec(rawExec);

            // Explain the plan tree.
            Explain::explainStages( exec.get(), verbosity, out );
            return Status::OK();
        }
        else {
            invariant( BatchedCommandRequest::BatchType_Delete == _writeType );

            // Create the delete request.
            DeleteRequest deleteRequest( nsString );
            deleteRequest.setQuery( batchItem.getDelete()->getQuery() );
            deleteRequest.setMulti( batchItem.getDelete()->getLimit() != 1 );
            deleteRequest.setUpdateOpLog(true);
            deleteRequest.setGod( false );
            deleteRequest.setExplain();

            // Explained deletes can yield.
            deleteRequest.setYieldPolicy(PlanExecutor::YIELD_AUTO);

            ParsedDelete parsedDelete(txn, &deleteRequest);
            Status parseStatus = parsedDelete.parseRequest();
            if (!parseStatus.isOK()) {
                return parseStatus;
            }

            // Explains of write commands are read-only, but we take write locks so that timing
            // info is more accurate.
            AutoGetDb autoDb(txn, nsString.db(), MODE_IX);
            Lock::CollectionLock colLock(txn->lockState(), nsString.ns(), MODE_IX);

            // We check the shard version explicitly here rather than using Client::Context,
            // as Context can do implicit database creation if the db does not exist. We want
            // explain to be a no-op that reports a trivial EOF plan against non-existent dbs
            // or collections.
            ensureShardVersionOKOrThrow( nsString.ns() );

            // Get a pointer to the (possibly NULL) collection.
            Collection* collection = NULL;
            if (autoDb.getDb()) {
                collection = autoDb.getDb()->getCollection(txn, nsString.ns());
            }

            PlanExecutor* rawExec;
            uassertStatusOK(getExecutorDelete(txn, collection, &parsedDelete, &rawExec));
            boost::scoped_ptr<PlanExecutor> exec(rawExec);

            // Explain the plan tree.
            Explain::explainStages(exec.get(), verbosity, out);
            return Status::OK();
        }
    }
Beispiel #19
0
 void Layer::setVisible(bool visible)
 {
     this->visible = visible;
     emit(updateRequest());
 }
Beispiel #20
0
//--------------------------------------------------------------
void guiPubMed::guiEvent(ofxUIEventArgs &e){
	string name = e.widget->getName();
	int kind = e.widget->getKind();
	ofLogVerbose("guiPubMed")<< "-- New event from: " << name;
	
	// Get the current searchBar number
	if (ofIsStringInString(name, "_")){
		vector<string> splitted	= ofSplitString(name, "_");
		currentSearchBar = ofToInt(splitted[1]);
	}
    
	
	//---------------------------------------------
	if(name == "Search"){
		if(e.widget->getState() == OFX_UI_STATE_OVER)
		{
			ofLogVerbose("guiPubMed")<< "Search Button: Start";
			sendRequest();
		}
    }
	//---------------------------------------------
	else if(name == "textField_"+ofToString(currentSearchBar))
	{
		ofxUITextInput *t = (ofxUITextInput *) e.widget;
		ofLogVerbose("guiPubMed") << "TextInput current text: " << t->getTextString();
		ofLogVerbose("guiPubMed") << "getTriggerType " << t->getTriggerType() << endl;

		if(t->getInputTriggerType() ==  OFX_UI_TEXTINPUT_ON_ENTER){
			textString[currentSearchBar]	=	t->getTextString();
			ofLogVerbose("guiPubMed")<< "ON ENTER: " << textString[currentSearchBar] << endl;
		}else if(t->getInputTriggerType() == OFX_UI_TEXTINPUT_ON_FOCUS){
			//t->setTextString("");
			ofLogVerbose("guiPubMed")<< "ON FOCUS: " << textString[currentSearchBar] << endl;
		}else if(t->getInputTriggerType() == OFX_UI_TEXTINPUT_ON_UNFOCUS){
			textString[currentSearchBar]	=	t->getTextString();
			ofLogVerbose("guiPubMed")<< "ON BLUR: textinut: " << textString[currentSearchBar] << endl;
		}
	}

	//---------------------------------------------
	else if(name == "And")
	{
		ofLogVerbose("guiPubMed") << "AND";
		if(searchBars == currentSearchBar)	cout << "ADDED" << endl,		letsAddNewSearchField = true;
		conjuctiontypeString[currentSearchBar] = andOrNotRequest[0];

	}
	else if(name == "Or")
	{
		ofLogVerbose("guiPubMed") << "OR";
		if(searchBars == currentSearchBar)	cout << "ADDED" << endl,		letsAddNewSearchField = true;
		conjuctiontypeString[currentSearchBar] = andOrNotRequest[1];

	}
	else if(name == "Not")
	{
		ofLogVerbose("guiPubMed") << "NOT";
		if(searchBars == currentSearchBar)	cout << "ADDED" << endl,		letsAddNewSearchField = true;
		conjuctiontypeString[currentSearchBar] = andOrNotRequest[2];

	}
	else if(name == "-")
	{
		ofLogVerbose("guiPubMed") << "-";
		if(searchBars == currentSearchBar){
			bRemoveSearchField = true;
		}
		else{
		}
	}
	else if(name == "textFieldDataFrom_"+ofToString(currentSearchBar))
	{
		ofxUITextInput *t = (ofxUITextInput *) e.widget;
		ofLogVerbose("guiPubMed") << "Date TextInput current text: " << t->getTextString();
		ofLogVerbose("guiPubMed") << "Date getTriggerType " << t->getTriggerType() << endl;
		if(t->getInputTriggerType() ==  OFX_UI_TEXTINPUT_ON_ENTER)
		{
			fromDateString[currentSearchBar] = t->getTextString();
			ofLogVerbose("guiPubMed")<< "ON ENTER:";
		}else if(t->getInputTriggerType() == OFX_UI_TEXTINPUT_ON_FOCUS)
		{
			//???
			ofLogVerbose("guiPubMed")<< "ON FOCUS:";
		}else if(t->getInputTriggerType() == OFX_UI_TEXTINPUT_ON_UNFOCUS)
		{
			fromDateString[currentSearchBar] = t->getTextString();
			ofLogVerbose("guiPubMed")<< "ON BLUR:";
		}

	}
	else if(name == "textFieldDataTo_"+ofToString(currentSearchBar))
	{
		ofxUITextInput *t = (ofxUITextInput *) e.widget;
		ofLogVerbose("guiPubMed") << "Date TextInput current text: " << t->getTextString();
		ofLogVerbose("guiPubMed") << "Date getTriggerType " << t->getTriggerType() << endl;
		if(t->getInputTriggerType() ==  OFX_UI_TEXTINPUT_ON_ENTER)
		{
			toDateString[currentSearchBar] = t->getTextString();
			ofLogVerbose("guiPubMed")<< "ON ENTER:";
		}else if(t->getInputTriggerType() == OFX_UI_TEXTINPUT_ON_FOCUS)
		{
			toDateString[currentSearchBar] = t->getTextString();
			ofLogVerbose("guiPubMed")<< "ON FOCUS:";
		}else if(t->getInputTriggerType() == OFX_UI_TEXTINPUT_ON_UNFOCUS)
		{
			toDateString[currentSearchBar] = t->getTextString();
			ofLogVerbose("guiPubMed")<< "ON BLUR:";
		}
	}
	else
	{	//DROPDOWN MENU
		int myit = 0;
		for(vector<string>::iterator it = myVisibleSelItems.begin(); it != myVisibleSelItems.end(); ++it)
		{
			if ((*it)==name)
			{
				ofLogVerbose("guiPubMed")<< "Dropdown_"<< currentSearchBar <<" "<< (*it);
				//Get type of reference
				reftypeString[currentSearchBar]= myRequestSelItems[myit];
				
				//Select mode
				//Date mode
				bool bFoundDataType = false;
				int idFound = -1;
				for(int i = 0; i<myVisibleDatasSelItems.size();i++){
					//Check if == and not a already Datatype
					if(name.compare(myVisibleDatasSelItems[i]) == 0 && !myDataTypeSelected[currentSearchBar]){
							
						//If searchfield is Active change to data
						ofLogVerbose("guiPubMed") << "Change textinput to Data Inputs i=" << i << endl;
						bool changedone = changeSearchFieldToData(currentSearchBar);
						if(changedone)myDataTypeSelected[currentSearchBar] = true;
						bFoundDataType = true;
						idFound = i;
					}
					else if(name.compare(myVisibleDatasSelItems[i]) == 0){
						bFoundDataType = true;
					}
				}
				//Normal TextField Mode
				if(!bFoundDataType){
					//If that's normal search field type (so not found any datatype ) then return to thar format
					for(int i = 0; i< myVisibleSelItems.size();i++){
						//Check if == and That was Datatype
						if(name.compare(myVisibleSelItems[i]) == 0 && myDataTypeSelected[currentSearchBar]){
							bool changedone = changeDataToSearchField(currentSearchBar);
							if(changedone)myDataTypeSelected[currentSearchBar] = false;
							ofLogVerbose("guiPubMed") << "Change Data Inputs to textinput id=" << i << endl;
						}
					}
				}
			}
			myit++;
		}
	}
	
	//Finally update current textInpunt and parameters into the requests string
	updateRequest();
	cout << endl;
}
Beispiel #21
0
    Status WriteCmd::explain(OperationContext* txn,
                             const std::string& dbname,
                             const BSONObj& cmdObj,
                             ExplainCommon::Verbosity verbosity,
                             BSONObjBuilder* out) const {
        // For now we only explain update and delete write commands.
        if ( BatchedCommandRequest::BatchType_Update != _writeType &&
             BatchedCommandRequest::BatchType_Delete != _writeType ) {
            return Status( ErrorCodes::IllegalOperation,
                           "Only update and delete write ops can be explained" );
        }

        // Parse the batch request.
        BatchedCommandRequest request( _writeType );
        std::string errMsg;
        if ( !request.parseBSON( cmdObj, &errMsg ) || !request.isValid( &errMsg ) ) {
            return Status( ErrorCodes::FailedToParse, errMsg );
        }

        // Note that this is a runCommmand, and therefore, the database and the collection name
        // are in different parts of the grammar for the command. But it's more convenient to
        // work with a NamespaceString. We built it here and replace it in the parsed command.
        // Internally, everything work with the namespace string as opposed to just the
        // collection name.
        NamespaceString nsString(dbname, request.getNS());
        request.setNS(nsString.ns());

        // Do the validation of the batch that is shared with non-explained write batches.
        Status isValid = WriteBatchExecutor::validateBatch( request );
        if (!isValid.isOK()) {
            return isValid;
        }

        // Explain must do one additional piece of validation: For now we only explain
        // singleton batches.
        if ( request.sizeWriteOps() != 1u ) {
            return Status( ErrorCodes::InvalidLength,
                           "explained write batches must be of size 1" );
        }

        // Get a reference to the singleton batch item (it's the 0th item in the batch).
        BatchItemRef batchItem( &request, 0 );

        if ( BatchedCommandRequest::BatchType_Update == _writeType ) {
            // Create the update request.
            UpdateRequest updateRequest( txn, nsString );
            updateRequest.setQuery( batchItem.getUpdate()->getQuery() );
            updateRequest.setUpdates( batchItem.getUpdate()->getUpdateExpr() );
            updateRequest.setMulti( batchItem.getUpdate()->getMulti() );
            updateRequest.setUpsert( batchItem.getUpdate()->getUpsert() );
            updateRequest.setUpdateOpLog( true );
            UpdateLifecycleImpl updateLifecycle( true, updateRequest.getNamespaceString() );
            updateRequest.setLifecycle( &updateLifecycle );
            updateRequest.setExplain();

            // Explained updates can yield.
            updateRequest.setYieldPolicy(PlanExecutor::YIELD_AUTO);

            // Use the request to create an UpdateExecutor, and from it extract the
            // plan tree which will be used to execute this update.
            UpdateExecutor updateExecutor( &updateRequest, &txn->getCurOp()->debug() );
            Status prepStatus = updateExecutor.prepare();
            if ( !prepStatus.isOK() ) {
                return prepStatus;
            }

            // Explains of write commands are read-only, but we take an exclusive lock so
            // that timing info is more accurate.
            Lock::DBLock dlk(txn->lockState(), nsString.db(), MODE_IX);
            Client::Context ctx(txn, nsString);

            Status prepInLockStatus = updateExecutor.prepareInLock(ctx.db());
            if ( !prepInLockStatus.isOK() ) {
                return prepInLockStatus;
            }

            // Executor registration and yield policy is handled internally by the update executor.
            PlanExecutor* exec = updateExecutor.getPlanExecutor();

            // Explain the plan tree.
            return Explain::explainStages( exec, verbosity, out );
        }
        else {
            invariant( BatchedCommandRequest::BatchType_Delete == _writeType );

            // Create the delete request.
            DeleteRequest deleteRequest( txn, nsString );
            deleteRequest.setQuery( batchItem.getDelete()->getQuery() );
            deleteRequest.setMulti( batchItem.getDelete()->getLimit() != 1 );
            deleteRequest.setUpdateOpLog(true);
            deleteRequest.setGod( false );
            deleteRequest.setExplain();

            // Explained deletes can yield.
            deleteRequest.setYieldPolicy(PlanExecutor::YIELD_AUTO);

            // Use the request to create a DeleteExecutor, and from it extract the
            // plan tree which will be used to execute this update.
            DeleteExecutor deleteExecutor( &deleteRequest );
            Status prepStatus = deleteExecutor.prepare();
            if ( !prepStatus.isOK() ) {
                return prepStatus;
            }

            // Explains of write commands are read-only, but we take a write lock so that timing
            // info is more accurate.
            Lock::DBLock dlk(txn->lockState(), nsString.db(), MODE_IX);
            Client::Context ctx(txn, nsString);

            Status prepInLockStatus = deleteExecutor.prepareInLock(ctx.db());
            if ( !prepInLockStatus.isOK()) {
                return prepInLockStatus;
            }

            // Executor registration and yield policy is handled internally by the delete executor.
            PlanExecutor* exec = deleteExecutor.getPlanExecutor();

            // Explain the plan tree.
            return Explain::explainStages( exec, verbosity, out );
        }
    }
Beispiel #22
0
/*!
 *	\~english
 *	Reimplemented QDataTable function.
 *	\~russian
 *	Переопределяет функцию QDataTable. Если контейнер wJournal, может испускаеть сигналы insertRequest(), updateRequest(), deleteRequest(), viewRequest()
 *	\~
 */
void
wDBTable::contentsContextMenuEvent ( QContextMenuEvent * e )
{
	Q3Table::contentsContextMenuEvent( e );
	QString str, ctype;

	if ( containerType() == "wDocument" || containerType() == "wCatalogue" ) {
   	// Переопределяем всплывающее по правой кнопке мыши меню для табличной части документа
   	// Во-первых, для его локализации
	// Во-вторых, чтобы добавляемая в табличную часть строка всегда вставлялась самой последней.
   		enum {
    		IdInsert=0,
   			IdUpdate,
    		IdDelete,
		};

		QPointer<Q3PopupMenu> popupForDoc = new Q3PopupMenu( this );
		int id[ 3 ];
		id[ IdInsert ] 	= popupForDoc->insertItem( tr( "New" ) );
		id[ IdUpdate ] 	= popupForDoc->insertItem( tr( "Edit" ) );
		id[ IdDelete ] 	= popupForDoc->insertItem( tr( "Delete" ) );

		if ( !sqlCursor() || isReadOnly() || !numCols() ) {
			popupForDoc->setItemEnabled(id[ IdInsert ], false );
			popupForDoc->setItemEnabled(id[ IdUpdate ], false );
			popupForDoc->setItemEnabled(id[ IdDelete ], false );
		}

		int r = popupForDoc->exec( e->globalPos() );
		delete (Q3PopupMenu*) popupForDoc;
		if(r==id[IdInsert]) {
			beginInsert();
		} else if(r==id[IdUpdate]) {
			keyPressEvent( new QKeyEvent( QEvent::KeyPress, Qt::Key_F2, 0, Qt::NoButton));
		} else if(r==id[IdDelete]) {
			Q3DataTable::deleteCurrent();
		}
	}


	if ( containerType() == "wJournal" )
	{
		//id = currentRecord()->value(0).toLongLong();
       		enum {
	    		IdInsert=0,
	   		IdUpdate,
	    		IdDelete,
	    		IdView,
			IdRefresh };
		QPointer<Q3PopupMenu> popup = new Q3PopupMenu( this );
		int id[ 5 ];
		id[ IdInsert ] = popup->insertItem( tr( "New" ) );
		id[ IdUpdate ] = popup->insertItem( tr( "Edit" ) );
		id[ IdDelete ] = popup->insertItem( tr( "Delete" ) );
		id[ IdView ] = popup->insertItem( tr( "View" ) );
		id[ IdRefresh ] = popup->insertItem( tr( "Refresh" ) );
		int r = popup->exec( e->globalPos() );
		delete (Q3PopupMenu*) popup;
		if(r==id[IdInsert])
			emit(insertRequest());
		else
			if(r==id[IdUpdate])
				emit(updateRequest());
			else
				if(r==id[IdDelete])
					emit(deleteRequest());
				else
					if(r==id[IdView])
						emit(viewRequest());
						if(r==id[IdRefresh])
							{
								//recalculate();
								refresh();
							}
	}
	e->accept();

}
Beispiel #23
0
 void Layer::setSize(QSize size)
 {
     this->size = size;
     screenmiddle = QPoint(size.width()/2, size.height()/2);
     emit(updateRequest());
 }