void S11nClipboard::syncFromQt()
{
    QString data( QApplication::clipboard()->text( QClipboard::Clipboard ) );
    delete m_node;
    m_node = 0;
    if( data.isEmpty() )
    {
	Q_EMIT signalUpdated();
	return;
    }
    S11nNode * node = 0;
    {
	char const * ascii = data.toAscii().data();
	std::istringstream buf(ascii ? ascii : "");
	node = s11nlite::load_node( buf );
    }
    m_node = node;
    Q_EMIT signalUpdated();
}
void S11nClipboard::syncToQt()
{
    disconnect(QApplication::clipboard(),SIGNAL(dataChanged()),this,SLOT(syncFromQt()));
    QClipboard * cb = QApplication::clipboard();
    // cb->clear(); doh! Ends up nuking m_node via signal to syncFromQt()!
    if( this->m_node )
    {
	std::ostringstream os;
	if( s11nlite::save( *m_node, os ) )
	{
	    cb->setText( os.str().c_str() );
	}
    }
    else
    {
	cb->clear();
    }
    Q_EMIT signalUpdated();
    connect(QApplication::clipboard(),SIGNAL(dataChanged()),this,SLOT(syncFromQt()));
}
MainWindowImpl::MainWindowImpl( QWidget * parent, Qt::WFlags f) 
    : QMainWindow(parent, f),
      Ui::MainWindow(),
      impl(new Impl)
{

	setupUi(this);
	this->setWindowTitle( QString("QBoard v. %1").arg(qboard::versionString()) );
	connect( this->actionSave, SIGNAL(triggered(bool)), this, SLOT(saveGame()) );
	connect( this->actionLoad, SIGNAL(triggered(bool)), this, SLOT(loadGame()) );
	connect( this->actionNewBoardView, SIGNAL(triggered(bool)), this, SLOT(launchNewBoardView()) );
	connect( this->actionAboutQt, SIGNAL(triggered(bool)), qApp, SLOT(aboutQt()) );
	connect( this->actionAboutQBoard, SIGNAL(triggered(bool)), this, SLOT(aboutQBoard()) );
	connect( this->actionPrint, SIGNAL(triggered(bool)), this, SLOT(printGame()) );
	connect( this->actionHelp, SIGNAL(triggered(bool)), this, SLOT(launchHelp()) );
	connect( this->actionClearBoard, SIGNAL(triggered(bool)), this, SLOT(clearBoard()) );
	connect( this->actionQuickSave, SIGNAL(triggered(bool)), this, SLOT(quickSave()) );
	connect( this->actionQuickLoad, SIGNAL(triggered(bool)), this, SLOT(quickLoad()) );


	impl->gstate.enablePlacemarker(true);

#if ! QBOARD_VERSION
	// For "end user builds" we won't show this action.
	connect( this->actionExperiment, SIGNAL(triggered(bool)), this, SLOT(doSomethingExperimental()) );
	this->actionExperiment->setEnabled(true);
#else
	this->actionExperiment->setEnabled(false);
#endif
	connect( &S11nClipboard::instance(), SIGNAL(signalUpdated()), this, SLOT(clipboardUpdated()) );

	this->actionClearClipboard->setEnabled( 0 != S11nClipboard::instance().contents() );
	connect( this->actionClearClipboard, SIGNAL(triggered(bool)), this, SLOT( clearClipboard() ) );

	QWidget * cli = this->clientArea;
	QLayout * lay = new QGridLayout( cli );
	lay->setSpacing(0);
	lay->setContentsMargins(2,2,2,2);
	QSplitter * splitter = new QSplitter( Qt::Horizontal, cli );
	lay->addWidget( splitter );
	splitter->setHandleWidth(4);

	QSplitter * vsplit = new QSplitter( Qt::Vertical, cli );
	impl->sidebar = vsplit;
	splitter->addWidget( vsplit );
	vsplit->setHandleWidth(4);

	impl->tree = new QBoardHomeView();
	vsplit->addWidget(impl->tree);
	connect( this->actionRefreshFileList, SIGNAL(triggered(bool)), impl->tree, SLOT(refresh()) );
	connect( impl->tree, SIGNAL(itemActivated(QFileInfo const &)), this, SLOT(loadFile(QFileInfo const &)) );
	connect( this->actionToggleBrowserView, SIGNAL(toggled(bool)), this, SLOT(toggleSidebarVisible(bool)) );
	impl->gv = new QBoardView( impl->gstate );
	//impl->gv->enablePlacemarker(true);
	connect( this->actionToggleBoardDragMode, SIGNAL(toggled(bool)),
		impl->gv, SLOT(setHandDragMode(bool)) );
	this->actionToggleBoardDragMode->setChecked(false);

	connect( this->actionCopy, SIGNAL(triggered(bool)), impl->gv, SLOT(clipCopySelected()) );
	connect( this->actionCut, SIGNAL(triggered(bool)), impl->gv, SLOT(clipCutSelected()) );
	connect( this->actionPaste, SIGNAL(triggered(bool)), impl->gv, SLOT(clipPaste()) );

	connect( this->actionSelectAll, SIGNAL(triggered(bool)), impl->gv, SLOT(selectAll()) );
	connect( this->actionZoomIn, SIGNAL(triggered(bool)), impl->gv, SLOT(zoomIn()) );
	connect( this->actionZoomOut, SIGNAL(triggered(bool)), impl->gv, SLOT(zoomOut()) );	
	connect( this->actionZoomReset, SIGNAL(triggered(bool)), impl->gv, SLOT(zoomReset()) );

#define BOGO(A)
	// this->action ## A->setParent(impl->gv);
	BOGO(Copy);
	BOGO(Cut);
	BOGO(Paste);
	BOGO(ZoomIn);
	BOGO(ZoomOut);
	BOGO(ZoomReset);
#undef BOGO

	splitter->addWidget( impl->gv );

	splitter->setStretchFactor(0,2);
	splitter->setStretchFactor(1,3);

	vsplit->addWidget( impl->paw );

	vsplit->setStretchFactor(0,3);
	vsplit->setStretchFactor(1,1);

	if(1)
	{
	    impl->gv->setObjectName("view");
	    QScriptEngine & js( impl->gstate.jsEngine() );
	    QScriptValue jo = js.newQObject( impl->gv, QScriptEngine::QtOwnership );
	    QScriptValue qb = js.globalObject().property("qboard");
	    qb.setProperty("view",jo);
	    qb.setProperty("window",js.newQObject(this, QScriptEngine::QtOwnership ) );
	}

	this->resize(760,600);
}
void PropertyTreeModel::onUpdated(const PropertyRows& rows, bool needApply)
{
    signalUpdated(rows, needApply);
}
Beispiel #5
0
	void DNode::updateFromParent( void )
	{
		updateFromParentImpl();
		signalUpdated(this);
	}