示例#1
0
文件: insideBase.cpp 项目: q4a/attal
void InsideBaseView::slot_removeMessage()
{
	TRACE("count %d", _listM.count());

	if( !_listM.isEmpty() ) {
		_listM.removeFirst();
	}
	emit sig_update();
}
示例#2
0
文件: insideBase.cpp 项目: q4a/attal
InsideBaseView::InsideBaseView( InsideBase * baseScene, QWidget * parent )
	: QGraphicsView( baseScene , parent)
{
	TRACE("InsideBaseView scene %p", baseScene );

	viewport()->setMouseTracking( true ) ;
	_selected = 0;
	_scene = baseScene;
	update();
	connect( this, SIGNAL( sig_update() ), scene(), SLOT( update() ) );
}
示例#3
0
文件: insideBase.cpp 项目: q4a/attal
void InsideBaseView::newMessage( QString string)
{
	TRACE("message %s", qPrintable( string ) );

	if( _listM.count() > 6 ) {
		_listM.removeFirst();
	}

	_listM.append( string );
	QTimer::singleShot( 15000, this, SLOT( slot_removeMessage() ) );
	emit sig_update();
}
示例#4
0
文件: insideBase.cpp 项目: q4a/attal
/** handles mouse move event */
void InsideBaseView::mouseMoveEvent( QMouseEvent * e )
{
	QPointF pos = mapToScene( e->pos());
	QList<QGraphicsItem *> list;
	QList<QGraphicsItem *> list2 = scene()->items( pos );
	
	uint nbItems2 = (uint) list2.count();
	for( unsigned int i = 0; i < nbItems2; i++ ) {
		if( list2[ i ]->type() == InsideBuilding::RTTI ) {
			if( ( (InsideBuilding*)list2[ i ] )->hit( pos ) ) {
				list.append( list2[ i ] );
			}
		}
	}
	
	if( _scene->getNewBase()==true){
		_selected = 0;
		emit sig_update();
		_scene->setNewBase(false);
	}

	uint nbItems = (uint) list.count();
	for( unsigned int i = 0; i < nbItems; i++ ) {	
		if( _selected ) {
			if( _selected != (InsideBuilding*)list[i] ) {
				_selected->deselect();
				_selected = (InsideBuilding*)list[i];
				_selected->select();
				update();
			} 				
		} else {
			_selected = (InsideBuilding*)list[i];
			_selected->select();
			update();
		} 
	}
	
	if( ( list.count() == 0 ) && _selected ) {
		_selected->deselect();
		_selected = 0;
		update();
	}
}
示例#5
0
QReversiGameView::QReversiGameView(QWidget *parent, QReversiGame *game)
  : QWidget(parent, "gameview")
{
  // Store a pointer to the game.
  m_game = game;

  // The widget stuff
  createView();

  // Other initializations.
  m_humanColor = Nobody;

  // Connect the game to the view.
  connect(m_game, SIGNAL(sig_newGame()), this, SLOT(newGame()));
  connect(m_game, SIGNAL(sig_move(uint, Move&)),
	  this,   SLOT(moveMade(uint, Move&)));
  connect(m_game, SIGNAL(sig_update()),  this, SLOT(updateView()));
  // The sig_gameOver signal is not used by the view.

  // Reemit the signal from the board.
  connect(m_boardView, SIGNAL(signalSquareClicked(int, int)),
	  this,        SLOT(squareClicked(int, int)));
}
示例#6
0
文件: insideBase.cpp 项目: q4a/attal
/** handles mouse move event */
void InsideBaseView::scrollContentsBy( int dx, int dy )
{
	QGraphicsView::scrollContentsBy( dx, dy );
	emit sig_update();
}