[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    playground/games/granatier/src
From:       Mathias Kraus <k.hias () gmx ! de>
Date:       2009-09-23 22:29:26
Message-ID: 1253744966.509452.3855.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 1027366 by mkraus:

refactoring of gameview.cpp/.h

 M  +23 -15    gameview.cpp  
 M  +46 -45    gameview.h  


--- trunk/playground/games/granatier/src/gameview.cpp #1027365:1027366
@@ -1,4 +1,5 @@
 /*
+ * Copyright 2009 Mathias Kraus <k.hias@gmx.de>
  * Copyright 2007-2008 Thomas Gallinari <tg8187@yahoo.fr>
  * 
  * This program is free software; you can redistribute it and/or
@@ -22,32 +23,39 @@
 #include <QTimer>
 #include <QKeyEvent>
 
-GameView::GameView(Game * p_game) : QGraphicsView(new GameScene(p_game)) {
-	setFocusPolicy(Qt::StrongFocus);
-	// Forward the key press events to the Game instance
-	connect(this, SIGNAL(keyPressed(QKeyEvent*)), p_game, SLOT(keyPressEvent(QKeyEvent*)));
+GameView::GameView(Game * p_game) : QGraphicsView(new GameScene(p_game))
+{
+    setFocusPolicy(Qt::StrongFocus);
+    // Forward the key press events to the Game instance
+    connect(this, SIGNAL(keyPressed(QKeyEvent*)), p_game, SLOT(keyPressEvent(QKeyEvent*)));
     connect(this, SIGNAL(keyReleased(QKeyEvent*)), p_game, SLOT(keyReleaseEvent(QKeyEvent*)));
 }
 
-GameView::~GameView() {
+GameView::~GameView()
+{
 
 }
 
-void GameView::resizeEvent(QResizeEvent*) {
-	fitInView(sceneRect(), Qt::KeepAspectRatio);
+void GameView::resizeEvent(QResizeEvent*)
+{
+    fitInView(sceneRect(), Qt::KeepAspectRatio);
 }
 
-void GameView::focusOutEvent(QFocusEvent*) {
-	// Pause the game if it is not already paused
-	if (((GameScene*)scene())->getGame()->getTimer()->isActive()) {
-		((GameScene*)scene())->getGame()->switchPause();
-	}
+void GameView::focusOutEvent(QFocusEvent*)
+{
+    // Pause the game if it is not already paused
+    if (((GameScene*)scene())->getGame()->getTimer()->isActive())
+    {
+        ((GameScene*)scene())->getGame()->switchPause();
+    }
 }
 
-void GameView::keyPressEvent(QKeyEvent* p_event) {
-	emit(keyPressed(p_event));
+void GameView::keyPressEvent(QKeyEvent* p_event)
+{
+    emit(keyPressed(p_event));
 }
 
-void GameView::keyReleaseEvent(QKeyEvent* p_event) {
+void GameView::keyReleaseEvent(QKeyEvent* p_event)
+{
     emit(keyReleased(p_event));
 }
--- trunk/playground/games/granatier/src/gameview.h #1027365:1027366
@@ -1,4 +1,5 @@
 /*
+ * Copyright 2009 Mathias Kraus <k.hias@gmx.de>
  * Copyright 2007-2008 Thomas Gallinari <tg8187@yahoo.fr>
  * 
  * This program is free software; you can redistribute it and/or
@@ -29,60 +30,60 @@
  */
 class GameView : public QGraphicsView {
 
-	Q_OBJECT
-	
-	public:
+Q_OBJECT
 
-		/**
-		 * Creates a new GameView instance.
-		 * @param p_game the Game instance whose elements have to be drawn
-		 */
-		GameView(Game* p_game);
+public:
 
-		/**
-		 * Deletes the GameView instance.
-		 */
-		~GameView();
+    /**
+      * Creates a new GameView instance.
+      * @param p_game the Game instance whose elements have to be drawn
+      */
+    GameView(Game* p_game);
 
-		/**
-		 * Resizes the items when the view is resized.
-		 * @param p_event the resize event
-		 */
-		void resizeEvent(QResizeEvent* p_event);
+    /**
+      * Deletes the GameView instance.
+      */
+    ~GameView();
 
-	protected:
+    /**
+      * Resizes the items when the view is resized.
+      * @param p_event the resize event
+      */
+    void resizeEvent(QResizeEvent* p_event);
 
-		/**
-		 * Manages the player actions by hanlding the key press events.
-		 * @param p_event the key press event
-		 */
-		void keyPressEvent(QKeyEvent* p_event);
+protected:
 
-        /**
-         * Manages the player actions by hanlding the key release events.
-         * @param p_event the key release event
-         */
-        void keyReleaseEvent(QKeyEvent* p_event);
+    /**
+      * Manages the player actions by hanlding the key press events.
+      * @param p_event the key press event
+      */
+    void keyPressEvent(QKeyEvent* p_event);
 
-		/**
-		 * Pauses the game on focus lost.
-		 * @param p_event the focus event
-		 */
-		void focusOutEvent(QFocusEvent* p_event);
+    /**
+      * Manages the player actions by hanlding the key release events.
+      * @param p_event the key release event
+      */
+    void keyReleaseEvent(QKeyEvent* p_event);
 
-	signals:
+    /**
+      * Pauses the game on focus lost.
+      * @param p_event the focus event
+      */
+    void focusOutEvent(QFocusEvent* p_event);
 
-		/**
-		 * Emitted on key press event for the Game instance
-		 * @param p_event the key press event
-		 */
-		void keyPressed(QKeyEvent* p_event);
-        
-        /**
-         * Emitted on key release event for the Game instance
-         * @param p_event the key release event
-         */
-        void keyReleased(QKeyEvent* p_event);
+signals:
+
+    /**
+      * Emitted on key press event for the Game instance
+      * @param p_event the key press event
+      */
+    void keyPressed(QKeyEvent* p_event);
+    
+    /**
+      * Emitted on key release event for the Game instance
+      * @param p_event the key release event
+      */
+    void keyReleased(QKeyEvent* p_event);
 };
 
 #endif
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic