Exemplo n.º 1
0
bool QGILineBinder::serialize( S11nNode & dest ) const
{
    using namespace s11n::qt;
	if( ! this->Serializable::serialize( dest ) ) return false;
	if( ! impl->ends.first || ! impl->ends.second ) return false;
	// We must ensure that the "pos" property is synced, but we have
	// to violate constness to do it :/
	QGILineBinder * ncthis = const_cast<QGILineBinder*>( this );
	ncthis->setProperty( "pos", this->pos() );
	if( this->metaObject()->propertyCount() )
	{
		S11nNode & pr( s11n::create_child( dest, "properties" ) );
		if( ! QObjectProperties_s11n()( pr, *this ) ) return false;
	}
	QObjectProperties_s11n proxy;
	QObject const * qobj = impl->ends.first; // kludge to avoid an ambiguity
	if( ! proxy(s11n::create_child( dest, "first" ), *qobj) ) return false;
	qobj = impl->ends.second;
	if( ! proxy(s11n::create_child( dest, "second" ), *qobj) ) return false;
	/**
	To avoid offset calculations, we save the absolute LineNode
	positions instead of our m_pts member. This still has the problem
	that if the hard-coded size of the LineNodes changes between
	serializations, we'll place the line slightly differently
	than before when we load.
	*/
	Impl::PointPair pts( impl->ends.first->pos(), impl->ends.second->pos() );
	return s11n::serialize_subnode( dest, "pos", pts );
}
Exemplo n.º 2
0
void MenuHandlerLineNode::doMenu( QGILineNode *gvi, QGraphicsSceneContextMenuEvent * ev )
{
	ev->accept();
	QString label("Line...");
	QMenu * menu = new QMenu(label);
	menu->addAction(label)->setEnabled(false);
	menu->addAction(QIcon(":/QBoard/icon/button_cancel.png"), QString("Destroy Line"),
		this,SLOT(scheduleLineDestruction()) );
	menu->addSeparator();
	//QObject::connect( this, SIGNAL(aboutToShow()), this, SLOT(updateView()) );
	QGILineBinder * line = dynamic_cast<QGILineBinder*>( gvi->parentItem() );
	if( ! line )
	{ // fixme: report an error here.
		delete menu;
		return;
	}
	impl->line = line;
	impl->node = gvi;

	QMenu * menuLine = menu->addMenu("Line");
	menuLine->addMenu( QObjectPropertyMenu::makeColorMenu(line, "color", "alpha" ) );
	menuLine->addMenu( QObjectPropertyMenu::makePenStyleMenu(line, "style" ) );
	menuLine->addMenu( QObjectPropertyMenu::makeNumberListMenu("Width", line, "width",1,10,1) );

	QMenu * mdot = QObjectPropertyMenu::makeColorMenu( gvi,  "color" );
	mdot->setTitle("Dot");
	menu->addMenu( mdot );

	QMenu * menuArrows = menu->addMenu("Arrows");
	QAction * act = menuArrows->addAction("Toggle arrows",line, SLOT(toggleArrows()) );
	QVariant var( line->property("drawArrows") );
	int doArrow = var.isValid() ? var.toInt() : 0;
	if( doArrow )
	{
		act->setCheckable(true);
		act->setChecked(true);
	}
	menuArrows->addMenu( QObjectPropertyMenu::makeNumberListMenu("Size", line, "arrowSize",8,24,2) );

	menu->addSeparator();
	menu->addAction(QIcon(":/QBoard/icon/help.png"),"Help...", this, SLOT(showHelp()) );

	menu->exec( ev->screenPos() );
	delete menu;
	// Reminder: do not act on gvi or line after menu->exec(), as the exec might have
	// destroyed them! This means we can't do obj->update() to update their appearance
	// from here. We use QObject::event() in gvi/line to catch the updates instead.
}
Exemplo n.º 3
0
	~Impl()
	{
		if( delLine )
		{
			line->destroyLine();
		}
	}
Exemplo n.º 4
0
void MainWindowImpl::addLine()
{
	QGILineNode * ln = new QGILineNode;
	QGILineNode * rn = new QGILineNode;
	ln->setProperty("color", "#ffff00");
	rn->setProperty("color", "#ff0000");
	rn->setPos(50,50);
	ln->setPos(50,100);
	QGILineBinder * ed = new QGILineBinder(ln,rn);
#if 0
	ed->setProperty("lineColor", "#00ffff");
#endif
	ed->setProperty("lineWidth", 2 );
	ed->setProperty("lineStyle", Qt::DotLine );
	impl->gstate.addItem(ed,true);

}