Example #1
0
QNetworkReply* Parse::uploadFileData(QByteArray data, QString name)
{

    if (!isReady() || data.isEmpty()) return NULL;

    if (name.isEmpty()) {
        // compute name from content
    }
    setEndPoint( "files/"+name);

    QMimeDatabase db;
    QMimeType mime = db.mimeTypeForData(data);

    initHeaders();
    setHeader(QNetworkRequest::ContentTypeHeader, mime.name().toUtf8());

    m_conn = connect(this, &BaaS::replyFinished, [=]( QJsonDocument json){
        disconnect(m_conn);
        if ( getHttpCode() == 201 ){
            currentObject = json.object();
            // Create fileLit object
            QString mainObj = "{\"url\": \""+currentObject.value("url").toString()+
                    "\",\"file\": {\"name\": \""+currentObject.value("name").toString()+
                                ",\"__type\": \"File\"}}";

            setEndPoint("classes/FilesList");
            create( mainObj);

            emit fileUploaded( currentObject);
        }

    } );

    return request( BaaS::POST, data );
}
void GradientRangeEditor::setGradient( const QGradient &g )
{
	gradientType = g.type();
	stops = g.stops();
	spreadType = g.spread();
	switch( gradientType )
	{
		case QGradient::LinearGradient:
			setStartPoint( ( ( QLinearGradient& )g ).start() );
			setEndPoint( ( ( QLinearGradient& )g ).finalStop() );
			break;

		case QGradient::RadialGradient:
			setStartPoint( ( ( QRadialGradient& )g ).center() );
			setEndPoint( ( ( QRadialGradient& )g ).focalPoint() );
			break;

		default:
			setStartPoint( ( ( QConicalGradient& )g ).center() );
			qreal a = ( ( QConicalGradient& )g ).angle();
			QLineF l( QLineF( 0.0, 0.0, 0.5, 0.0 ) *
							QMatrix().rotate( a ) );
			l.translate( _startPoint );
			setEndPoint( l.p2() );
			break;
	}
}
Example #3
0
void Draw_Ellipse::setRotate(const QPointF &pnt,const QPointF &pnt1)
{
    if(pnt1.x()>pnt.x())
    {
       angle+=0.5;
       item->setRotation(angle);
       Strt_Rect->setRotation(angle);
       End_Rect->setRotation(angle);
       Rot_Rect->setRotation(angle);
    }

    if(pnt.x()>pnt1.x())
    {
       angle-=0.5;
       item->setRotation(angle);
       Strt_Rect->setRotation(angle);
       End_Rect->setRotation(angle);
       Rot_Rect->setRotation(angle);
    }

    item->update();
    Strt_Rect->update();
    End_Rect->update();
    Rot_Rect->update();


    QPointF rot_pnt(item->boundingRect().topLeft()-item->sceneBoundingRect().topLeft());
    QPointF rot_pnt1(item->boundingRect().bottomRight()-item->sceneBoundingRect().bottomRight());

    setStartPoint(item->sceneBoundingRect().topLeft()+rot_pnt);
    setEndPoint(item->sceneBoundingRect().bottomRight()+rot_pnt1);

}
Example #4
0
void Draw_Triangle::setTranslate(QPointF pnt,QPointF pnt1)
{
  if(item->rotation()==0)
  {
     setStartPoint(getStartPnt()-(pnt-pnt1));
       setEndPoint(getEndPnt()-(pnt-pnt1));
       setHeightPoint(getHeightPnt()-(pnt-pnt1));
  }

    item->setPos(item->pos()-(pnt-pnt1));
  item->update();

  for(int i=0;i<handles.size();i++)
  {
    handles[i]->setPos(handles[i]->pos()-(pnt-pnt1));
    handles[i]->update();
  }

    /*Strt_Rect->setPos(Strt_Rect->pos()-(pnt-pnt1));
    End_Rect->setPos(End_Rect->pos()-(pnt-pnt1));
    Height_Rect->setPos(Height_Rect->pos()-(pnt-pnt1));*/
    Rot_Rect->setPos(Rot_Rect->pos()-(pnt-pnt1));
  Rot_Rect->update();
    Bounding_Rect->setPos(Bounding_Rect->pos()-(pnt-pnt1));

}
/**************************************************************************
* Class Star::setPoint - Sets the point where a star is located           *
**************************************************************************/
Star
 &Star::setPoint(const IGPoint2D &pt)
{
  setStartPoint(pt);
  setEndPoint(IPoint(pt.fX+1, pt.fY+1));
  return *this;
}
Example #6
0
bool __RDRenderLogLine::open(const QTime &time)
{
  QString cutname;
  SF_INFO sf_info;

  if(type()==RDLogLine::Cart) {
    ll_cart=new RDCart(cartNumber());
    if(ll_cart->exists()&&(ll_cart->type()==RDCart::Audio)) {
      if(ll_cart->selectCut(&cutname,time)) {
	ll_cut=new RDCut(cutname);
	setStartPoint(ll_cut->startPoint(),RDLogLine::CartPointer);
	setEndPoint(ll_cut->endPoint(),RDLogLine::CartPointer);
	setSegueStartPoint(ll_cut->segueStartPoint(),RDLogLine::CartPointer);
	setSegueEndPoint(ll_cut->segueEndPoint(),RDLogLine::CartPointer);
	QString filename;
	if(GetCutFile(cutname,ll_cut->startPoint(),ll_cut->endPoint(),
		      &filename)) {
	  ll_handle=sf_open(filename,SFM_READ,&sf_info);
	  if(ll_handle!=NULL) {
 	    DeleteCutFile(filename);
	    return true;
	  }
	}
      }
    }
  }
  return false;
}
void GradientRangeEditor::setRadius( const qreal rad )
{
	QLineF l( _startPoint, _endPoint );
	l.setLength( rad );
	setStartPoint( l.p1() );
	setEndPoint( l.p2() );
}
Example #8
0
void Parse::signup( QString username, QString password, QString email )
{
    if (!isReady()) return;

    setEndPoint("users");

    QJsonObject obj{
      {"username", username},
      {"password", password},
      {"email", email}
    };

    setMasterKey("Remy");

    m_conn = connect(this, &BaaS::replyFinished, [=]( QJsonDocument json){
        disconnect(m_conn);
        if ( getHttpCode() == 201 ){
            QJsonObject obj = json.object();
            sessionId = obj.value("sessionToken").toString();
            userId = obj.value("objectId").toString();
            userName = obj.value("username").toString();
            qDebug() << "objectId" << obj.value("objectId").toString();
            qDebug() << "sessionToken" << sessionId;
            qDebug() << "res" << obj;
            emit loginChanged();
        }

    } );

    initHeaders();
    request( BaaS::POST, QJsonDocument(obj).toJson());

    setMasterKey("");
}
Example #9
0
QNetworkReply* Parse::uploadFile(QUrl url, QString name)
{
    QString filePath = url.toLocalFile();
    if (!isReady() || !QFile::exists(filePath)) return NULL;

    if (name.isEmpty()) name = url.fileName();
    setEndPoint( "files/"+name);

    QMimeDatabase db;
    QMimeType mime = db.mimeTypeForFile(filePath);

    QFile file(filePath);
    if (mime.inherits("text/plain")){
        if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
            return NULL;
    }
    else{
        if (!file.open(QIODevice::ReadOnly ))
            return NULL;
    }

    initHeaders();
    setHeader(QNetworkRequest::ContentTypeHeader, mime.name().toUtf8());

    m_conn = connect(this, &BaaS::replyFinished, [=]( QJsonDocument json){
        disconnect(m_conn);
        if ( getHttpCode() == 201 ){
            currentObject = json.object();
            emit fileUploaded( currentObject);
        }

    } );

    return request( BaaS::POST, file.readAll() );
}
Example #10
0
void LineMove::prepare(PageItem_Line* line, bool useOriginAsEndpoint)
{
	m_haveLineItem = (line != NULL);
	if (!m_haveLineItem)
		return;
	m_useOriginAsEndpoint = useOriginAsEndpoint;
	m_line = line;
	setStartPoint(QPointF(m_line->xPos(), m_line->yPos()));
	setEndPoint(QPointF(m_line->xPos() + m_line->width(), m_line->yPos()));
	setRotation(m_line->rotation());
	if (m_useOriginAsEndpoint)
	{
		QPointF tmp = startPoint();
		setStartPoint(endPoint());
		setEndPoint(tmp);
	}
}
Example #11
0
void Parse::pmlList()
{

    if (!isReady()) return;

    setEndPoint("classes/Pml?include=owner&order=-updatedAt&limit=2000");
    get();

}
Example #12
0
void Parse::deleteUser( QString objectId)
{
    if (!isReady() || sessionId.isEmpty()) return;

    setEndPoint("users/" + objectId );

    initHeaders();
    setRawHeader("X-Parse-Session-Token", sessionId.toUtf8());
    request( BaaS::DELETE);
}
void hdLineConnection::updateConnection(int posIdx)
{
	if(startConnector)
	{
		setStartPoint(posIdx, startConnector->findStart(posIdx, this));
	}
	if(endConnector)
	{
		setEndPoint(posIdx, endConnector->findEnd(posIdx, this));
	}
}
Example #14
0
bool Parse::ensureEndPointHasPrefix(QString prefix)
{
    QString endpt = getEndPoint();
    //if ( endpt.left( prefix.length() ) == prefix )
    if (endpt.startsWith( prefix ))
        return true;
    else{
        setEndPoint( prefix + "/" + endpt);
    }
    return false;
}
void ddLineConnection::updateConnection(){
	//DD-TODO: avoid memory leak from thiw new ddPoint
	if(startConnector)
	{
		setStartPoint(startConnector->findStart(this));  
	}
	if(endConnector)
	{
		setEndPoint(endConnector->findEnd(this));
	}
}
//!
//! Updates the position of an end point for a connection that is currently
//! being created.
//!
//! \param scenePosition The position of the mouse pointer over the graphics view in scene coordinates.
//!
void ConnectionGraphicsItem::updatePosition ( const QPointF &scenePosition )
{
    if (!m_connection || !m_temp)
        return;

    if (!m_connection->hasSource())
        setStartPoint(scenePosition);
    else //if (!m_connection->hasTarget())
        setEndPoint(scenePosition);

    update();
}
void GradientRangeEditor::mouseMoveEvent( QMouseEvent * event )
{
	QPointF pos = QPointF(  qreal( event->pos().x() ) / ( width() - 1 ),
							qreal( event->pos().y() ) / ( height() - 1) );

	switch( movedPoint )
	{
		case startMoved:
			setStartPoint( pos );
			break;

		case endMoved:
			setEndPoint( pos );
			break;

		default:
			break;
	}
}
Example #18
0
void LineMove::mousePressEvent(QMouseEvent *m)
{
	PageItem_Line* line = m_doc->m_Selection->count() == 1 ? m_doc->m_Selection->itemAt(0)->asLine() : NULL;
	if (line)
	{
		bool hitsOrigin = m_canvas->hitsCanvasPoint(m->globalPos(), line->xyPos());
		prepare(line, hitsOrigin);
		// now we also know the line's endpoint:
		bool hitsEnd = m_canvas->hitsCanvasPoint(m->globalPos(), endPoint());
		m_haveLineItem = hitsOrigin || hitsEnd;
	}
	else
	{
		FPoint point = m_canvas->globalToCanvas(m->globalPos());
		setStartPoint(QPointF(point.x(), point.y()));
		setEndPoint(QPointF(point.x(), point.y()));
		m_haveLineItem = false;
	}
	if (m_haveLineItem)
		m->accept();
}
Example #19
0
QNetworkReply* Parse::deleteFile(QString fileName)
{
    if (!isReady() || getMasterKey().isEmpty()) return NULL;

    setEndPoint( "files/" + fileName);

    m_conn = connect(this, &BaaS::replyFinished, [=]( QJsonDocument json){
        Q_UNUSED(json);
        disconnect(m_conn);
        if ( isLastRequestSuccessful() ) {
            emit objectDeleted( fileName );

        }
    } );

    initHeaders();
    setRawHeader("X-Parse-Master-Key", getMasterKey().toUtf8());

    return request( BaaS::DELETE );

}
Example #20
0
	//----------
	void Sender::socketLoop() {
		while (this->threadsRunning) {
			this->configMutex.lock();
			auto config = this->config;
			this->configMutex.unlock();

			Packet packet;
			while (this->compressorToSocket->receive(packet)) {
				if (this->socket) {
					auto dataGram = make_shared<ofxAsio::UDP::DataGram>();
					dataGram->setEndPoint(config.endPoint);

					dataGram->getMessage().set(&packet, sizeof(packet));
					this->socket->send(dataGram);
				}
				else {
					OFXSQUASHBUDDIES_WARNING << "Socket not connected, cannot send packets.";
				}
			}
		}
	}
Example #21
0
void
VNode::grow(const Vector2& targetPoint, bool& reachedTarget,
            VINENODES& newChildren, VINENODES& staleChildren)
{
    incrementGrowth();
    setEndPoint();

    float distance = sqrt( pow((targetPoint.X - endPoint().X),2) + pow((targetPoint.Y - endPoint().Y),2) );
    reachedTarget = bool(distance <= GrowthIncrement);

    if(!reachedTarget)
    {
        if(maxLengthReached())
        {
            staleChildren.push_back(this);
            addRandomizedChildren(endPoint(), targetPoint);
            int sz = (int)m_children.size();
            for( int i=0; i<sz; ++i )
                newChildren.push_back(m_children[i]);
        }
    }
}
Example #22
0
void Parse::passwordReset( QString email)
{
    if (!isReady()) return;

    setEndPoint("requestPasswordReset");

    QJsonObject obj{
      {"email", email}
    };

    m_conn = connect(this, &BaaS::replyFinished, [=]( QJsonDocument json){
        disconnect(m_conn);
        Q_UNUSED(json);
        if ( isLastRequestSuccessful() ) {

        }

    } );

    initHeaders();
    request( BaaS::POST, QJsonDocument(obj).toJson() );
}
Example #23
0
void Parse::logout( )
{
    if (!isReady()) return;

    setEndPoint("logout");

    m_conn = connect(this, &BaaS::replyFinished, [=]( QJsonDocument json){
        disconnect(m_conn);
        Q_UNUSED(json);
        if ( isLastRequestSuccessful() ) {
            sessionId = "";
            userId = "";
            userName = "";

            removeRawHeader("X-Parse-Session-Token");
            emit loginChanged();
        }

    } );

    initHeaders();
    request( BaaS::POST);
}
Example #24
0
void Parse::login( QString username, QString password )
{
    setHostURI(Cloud::getValueFor("serverURL",""));

    if (!isReady()) return;

    QUrlQuery postData;
    postData.addQueryItem("username", username);
    postData.addQueryItem("password", password);

    setEndPoint( "login?" + postData.toString() ); //TODO improve me : not use endpoint to give url encoded params

    initHeaders();
    if (registerInstallationOnLogin)
        setRawHeader("X-Parse-Installation-Id", "1");

    m_conn = connect(this, &BaaS::replyFinished, [=]( QJsonDocument json){
        disconnect(m_conn);
        if ( isLastRequestSuccessful() ) { //getHttpCode() == 201 ){
            QJsonObject obj = json.object();
            sessionId = obj.value("sessionToken").toString();
            userId = obj.value("objectId").toString();
            userName = obj.value("username").toString();
//            qWarning()<<obj;
            qWarning() << "objectId" << obj.value("objectId").toString();
            qWarning() << "sessionToken" << sessionId;
            setRawHeader("X-Parse-Session-Token", sessionId.toUtf8());
            emit loginChanged();
        }

    } );

    request( BaaS::GET);


}
Example #25
0
bool UdpClient::setEndPoint(const IPEndPoint& remoteEP, MAC& remoteMAC)
{
    return(setEndPoint(remoteEP.ip, remoteEP.port, remoteMAC, 0));
}
Example #26
0
void DragLine::mouseMoveEvent(QGraphicsSceneMouseEvent *e) {
  // setEndPoint(mapToParent(e->pos()));
  setEndPoint(endPoint() + e->pos() - e->lastPos());
  e->accept();
}
Example #27
0
bool UdpClient::setEndPoint(const IPEndPoint& remoteEP, MAC& remoteMAC, unsigned short localPort)
{
    return(setEndPoint(remoteEP.ip, remoteEP.port, remoteMAC, localPort));
}
Example #28
0
bool UdpClient::setEndPoint(const IPv4& remoteIP, unsigned short remotePort, MAC& remoteMAC)
{
    return(setEndPoint(remoteIP, remotePort, remoteMAC, 0));
}
void GradientRangeEditor::setAngle( const qreal a )
{
	QLineF l = QLineF( _startPoint, _endPoint ) * QMatrix().rotate( a - angle() );
	setStartPoint( l.p1() );
	setEndPoint( l.p2() );
}
bool ArrowMarker::eventFilter(QObject *, QEvent *e)
{
	switch(e->type()) {
		case QEvent::MouseButtonPress:
			{
				const QMouseEvent *me = (const QMouseEvent *)e;
				if (me->button() != Qt::LeftButton)
					return false;
				QRect handler = QRect (QPoint(0,0), QSize(10, 10));
				handler.moveCenter (startPoint());
				if (handler.contains(me->pos()))
				{
					QApplication::setOverrideCursor(QCursor(Qt::SizeAllCursor), true);
					d_op = MoveStart;
					return true;
				}
				handler.moveCenter (endPoint());
				if (handler.contains(me->pos()))
				{
					QApplication::setOverrideCursor(QCursor(Qt::SizeAllCursor), true);
					d_op = MoveEnd;
					return true;
				}
				int d = qRound(width() + (int)floor(headLength()*tan(M_PI*headAngle()/180.0) + 0.5));
				if (dist(me->pos().x(),me->pos().y()) <= d)
				{
					QApplication::setOverrideCursor(QCursor(Qt::SizeAllCursor), true);
					d_op = MoveBoth;
					d_op_startat = me->pos()-startPoint();
					return true;
				}
				return false;
			}
		case QEvent::MouseMove:
			{
				const QMouseEvent *me = (const QMouseEvent *)e;
				switch(d_op) {
					case MoveStart:
						setStartPoint(me->pos());
						plot()->replot();
						return true;
					case MoveEnd:
						setEndPoint(me->pos());
						plot()->replot();
						return true;
					case MoveBoth:
						setEndPoint(endPoint()+me->pos()-d_op_startat-startPoint());
						setStartPoint(me->pos()-d_op_startat);
						plot()->replot();
						return true;
					default:
						return false;
				}
			}
		case QEvent::MouseButtonRelease:
			{
				const QMouseEvent *me = (const QMouseEvent *)e;
				switch(d_op) {
					case MoveStart:
						setStartPoint(me->pos());
						plot()->replot();
						d_op = None;
						QApplication::restoreOverrideCursor();
						return true;
					case MoveEnd:
						setEndPoint(me->pos());
						plot()->replot();
						d_op = None;
						QApplication::restoreOverrideCursor();
						return true;
					case MoveBoth:
						setXValue(plot()->invTransform(xAxis(), me->pos().x()-d_op_startat.x()));
						setYValue(plot()->invTransform(yAxis(), me->pos().y()-d_op_startat.y()));
						plot()->replot();
						d_op = None;
						QApplication::restoreOverrideCursor();
						return true;
					default:
						d_op = None;
						QApplication::restoreOverrideCursor();
						return false;
				}
			}
		case QEvent::MouseButtonDblClick:
			{
				const QMouseEvent *me = (const QMouseEvent *)e;
				if (me->button() != Qt::LeftButton)
					return false;
				LineDialog *ld = new LineDialog(this, plot()->window());
				ld->exec();
				return true;
			}
		default:
			return false;
	}
}