コード例 #1
0
void CalloutNote::mouseMoveEvent( QGraphicsSceneMouseEvent *event )
{
	
	if(m_isResizing)
	{
		resizeItem( this->Width(), this->Height() );
		ItemBase::mouseMoveEvent( event );
	}
	else 
	{
		QRect rect = m_note->verticalScrollBar()->rect();
		QPointF rectPos = QPointF(m_note->width()/2-rect.width(), -m_note->height()/2);
		rect = QRect(rect.x()+rectPos.x(),rect.y()+rectPos.y(),rect.width(), rect.height());
		QPointF lastPos = event->lastPos(), pos = event->pos();
		if( rect.contains(lastPos.x(), lastPos.y()) && rect.contains(pos.x(), pos.y()))
		{
			//m_note->verticalScrollBar()
			//m_note->verticalScrollBar(
			//document length = maximum() - minimum() + pageStep()	
			int v1 = m_note->verticalScrollBar()->maximum();
			int v2 = m_note->verticalScrollBar()->minimum();
			int pageStep =m_note->verticalScrollBar()->pageStep();
			int length = v1 - v2 + pageStep;
			if(pos.y()<lastPos.y())
		      m_note->verticalScrollBar()->setValue(m_note->verticalScrollBar()->value() - length/50);		
			else if(pos.y()>lastPos.y())
				m_note->verticalScrollBar()->setValue(m_note->verticalScrollBar()->value() + length/50);		
		}
		else 
		{
			ItemBase::mouseMoveEvent( event );
			m_note->setFocus();		
		}
	}
}
コード例 #2
0
ファイル: LabelButton.cpp プロジェクト: citic/botNeumann
void LabelButton::resize(qreal left, qreal top, qreal width, qreal height)
{
	// Update the LayoutItem part of this object
	LayoutItem::resize(left, top, width, height);
	applyPaddings(left, top, width, height);

	// Resize the QGraphicaItem part of this object
	resizeItem(this, left, top, width, height);
}
コード例 #3
0
void StatisticBar::reOrderItems()
{
	int curHeight = 20;

	for( int i = 0; i < this->_1Ditems.size(); i++ )
	{
		QRectF curBounding = this->_1Ditems[i]->boundingRect();
		this->_1Ditems[i]->setPos( QPoint(0, curHeight ) );
		curHeight += curBounding.height()+5;
	}

	curHeight += 11;

	for (int i = 0; i < this->_1DTitems.size(); i++ )
	{
		QRectF curBounding = this->_1DTitems[i]->boundingRect();
		this->_1DTitems[i]->setPos( QPoint(0, curHeight ) );
		curHeight += curBounding.height()+5;
	}

	curHeight += 21;

	for( int i = 0; i < this->_1DitemsFromMat.size(); i++ )
	{
		QRectF curBounding = this->_1DitemsFromMat[i]->boundingRect();
		this->_1DitemsFromMat[i]->setPos( QPoint(0, curHeight ) );
		curHeight += curBounding.height()+5;
	}

	curHeight += 11;

	for (int i = 0; i < this->_1DTitemsFromMat.size(); i++ )
	{
		QRectF curBounding = this->_1DTitemsFromMat[i]->boundingRect();
		this->_1DTitemsFromMat[i]->setPos( QPoint(0, curHeight ) );
		curHeight += curBounding.height()+5;
	}

	if (curHeight == 20)
	{
		curHeight = 50;
	}
	
	resizeItem(QSizeF(this->getSize().width(), curHeight));

	return;
}
コード例 #4
0
void CalloutNote::initUI( OpenGLScene* Scene )
{
	this->m_note = new QTextEdit();		
	this->m_note->setText(getText(_pid, _type, _id));
	m_note->setStyleSheet( "background-color: rgb(215, 200, 145)");			
	this->_myControl = Scene->addWidget( m_note );	
	resizeItem(_size, _size/1.618);	
	//m_note->setMask( this->roundRect( QRect(0, 0, this->Width(),this->Height()), 20)); //QRegion(0, 0, this->Width()/2, this->Height()/2, QRegion::Ellipse) 	
	m_note->setMask( QRect(0, 0, this->Width(),this->Height())); //QRegion(0, 0, this->Width()/2, this->Height()/2, QRegion::Ellipse) 	
	m_note->setFocus();
	myCursor = m_note->textCursor(); //critical to make cursor visible
	m_note->ensureCursorVisible();//useless here
	
	crossRect = QRectF(this->realRect().x()+this->realRect().width()*0.90, this->realRect().y()+this->realRect().height()*0.03, this->realRect().width()*0.08, this->realRect().width()*0.08);	
	minusRect = QRectF(this->realRect().x()+this->realRect().width()*0.80, this->realRect().y()+this->realRect().height()*0.03, this->realRect().width()*0.08, this->realRect().width()*0.08);	

    /* myCursor.insertText(tr("We can emphasize text by "));	
    myCursor.setPosition(QTextCursor::Right, QTextCursor::KeepAnchor);*/

	return;
}
コード例 #5
0
void DrawingPolyItem::setPointPos(int index, const QPointF& scenePos)
{
	resizeItem(point(index), mapToParent(mapFromScene(scenePos)));
}
コード例 #6
0
void CalloutNote::updateNode(int pid, int type, int id, bool setVisible)
{
	/*storeText(_pid,_type,_id,false);
	_pid=pid, _type=type, _id=id;

	QDateTime dateTime = QDateTime::currentDateTime();
	QString dateTimeString = dateTime.toString("dd/mm/yy hh:mm");
	QStringList sNames = dateTimeString.split(" ");			

	QString line;
	line = getText(_pid, _type, _id);
	m_note->setHtml(line);
	
	QString endHtml = "</font>"; //<br>
	line = _scene->userName + ": " + dateTimeString;
	line =  "\">" + line;
	line =  _fontColor + line;
	line = "<font color=\"" + line;//_fontColor
	line = line + "<br>" + endHtml;
	m_note->insertHtml(line);

	line = m_note->toPlainText();
	_preText=line;  
	*/
	//line = m_note->toPlainText();

	/*QString endHtml = "</font><br>";
    QString line;
	line = getText(_pid, _type, _id);
    line.replace("\n","<br>");
	m_note->setHtml(line);

	line = _scene->userName + ": " + dateTimeString;
	line =  "\">" + line;
	line =  _fontColor + line;
	line = "<font color=\"" + line;//_fontColor
	line = line + "<br>" + endHtml;
	m_note->insertHtml(line);
	line = m_note->toPlainText();
     _preText=line;  
	//_preText = m_note->toHtml();	

    //line = m_note->toPlainText();
	//_fontColor
	*/

	QTextCursor txtCursor = m_note->textCursor();
    //position where you want it
	
	resizeItem( fixedWidth, fixedHeight );//add to make resizing work
	_myControl->setVisible(setVisible);
    m_note->setVisible(setVisible);			
	this->setVisible(setVisible);

	if(setVisible)
		this->show();
	else 
		this->hide();
	m_note->setFocus();

	int pos = m_note->find(" ");
    txtCursor.setPosition(_scene->userName.size() + 2 + 15);
    m_note->setTextCursor(txtCursor);
}
コード例 #7
0
void CalloutNote::updateNodeFirstTime(int pid, int type, int id, bool setVisible)
{
	//storeText(_pid,_type,_id);
	_pid=pid, _type=type, _id=id;

	int ID = getNodeID(nodeIDs, pid, type, id);
	vector<int> temp;
	temp.push_back(pid), temp.push_back(type), temp.push_back(id);
	if(ID<0)
	{
		nodeIDs.push_back(temp);
	}

	QDateTime dateTime = QDateTime::currentDateTime();
	QString dateTimeString = dateTime.toString("dd/mm/yy hh:mm");
	QStringList sNames = dateTimeString.split(" ");			

	//m_note->setText(_scene->userName + ": " + dateTimeString + "\n" + "\n" + getText(_pid, _type, _id));	
	//	m_note->insertHtml(_scene->userName + ": " + dateTimeString + "\n" + "\n" + getText(_pid, _type, _id));
	//m_note->insertHtml("<font color=\"DeepPink\">");
		
	QString line, hLine;	
	if(nodeText.size()>0 && nodeText[0].size()>0  )
	{
		line=nodeText[0];	
	    //line = getText(_pid, _type, _id);
		m_note->setHtml(line);
		line = m_note->toPlainText();
		_preText = line;

		hLine = m_note->toHtml();	

		//_preText = m_note->toHtml();	
		//m_note->setPlainText("");
	}
	else
	{
		_preText="";
		hLine ="";
		//_preText = m_note->toHtml();	
	}

	//if(setVisible)
	{	
		/*QString endHtml = "</font><br>";
		line = "<br><font color=\"Black\">" + line;
		line = line + endHtml; //+ "<br>"
		//line = line + line;
		line.replace("\n","<br>");	*/
		if(hLine=="")
		{
			QString endHtml = "</font><br>";
			line = "<br><font color=\"Black\">" + line;
			line = line + endHtml; //+ "<br>"
			//line = line + line;
			line.replace("\n","<br>");
		}
		else
		{
			m_note->setHtml("<br>"+hLine);
		}
		
		line = _scene->userName + ": " + dateTimeString;
		lastInputTime = line;
		line = line + "<br>";
		//line = "<font color=\"Lime\">" + line;
		//line = "<font color=\"" + "#008000\">" + line;
		line =  "\">" + line;
		line =  _fontColor + line;
		line = "<font color=\"" + line;//_fontColor
		m_note->insertHtml(line);
		
		//line = m_note->toPlainText();
		//_preText=line;  

		//_preText = m_note->toHtml();	
		
	}
	//_fontColor
		
    //position where you want it			
	resizeItem( fixedWidth, fixedHeight );//add to make resizing work
	_myControl->setVisible(setVisible);
    m_note->setVisible(setVisible);			
	this->setVisible(setVisible);

	if(setVisible)
		this->show();
	else 
		this->hide();
	m_note->setFocus();

	if(setVisible)
	{
		QTextCursor txtCursor = m_note->textCursor();
	   txtCursor.setPosition(_scene->userName.size() + 2 + 15);
        m_note->setTextCursor(txtCursor);
	}
}