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

List:       kde-commits
Subject:    KDE/kdegames/ksame
From:       Henrique Pinto <henrique.pinto () kdemail ! net>
Date:       2006-11-12 1:35:28
Message-ID: 1163295328.495775.10205.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 604219 by henrique:

 * Cleanups


 M  +0 -2      CMakeLists.txt  
 M  +36 -37    KSameWidget.cpp  
 M  +29 -36    KSameWidget.h  
 D             StoneField.cpp  
 D             StoneField.h  
 D             StoneWidget.cpp  
 D             StoneWidget.h  
 M  +1 -1      board.h  


--- trunk/KDE/kdegames/ksame/CMakeLists.txt #604218:604219
@@ -7,8 +7,6 @@
 
 set(ksame_SRCS 
     main.cpp 
-    StoneField.cpp 
-    StoneWidget.cpp 
     KSameWidget.cpp
     board.cpp
     view.cpp
--- trunk/KDE/kdegames/ksame/KSameWidget.cpp #604218:604219
@@ -44,7 +44,6 @@
 #include <kstdaction.h>
 #include <kinputdialog.h>
 
-#include "StoneWidget.h"
 #include "view.h"
 #include <QGraphicsScene>
 #include <QTimer>
@@ -56,28 +55,25 @@
              KMainWindow(parent)
 {
 	KStdGameAction::gameNew(this, SLOT(newGame()), actionCollection(), "game_new");
-	restart = KStdGameAction::restart( this, SLOT( m_restart() ), actionCollection(), \
"game_restart" ); +	m_restartAction = KStdGameAction::restart( this, SLOT( \
restartGame() ), actionCollection(), "game_restart" );  \
KStdGameAction::highscores(this, SLOT(showHighScoreDialog()), actionCollection(), \
"game_highscores");  KStdGameAction::quit(this, SLOT(close()), actionCollection(), \
                "game_quit");
-	m_undo = KStdGameAction::undo( this, SLOT( undo() ), actionCollection(), \
"edit_undo" ); +	m_undoAction = KStdGameAction::undo( this, SLOT( undo() ), \
actionCollection(), "edit_undo" );  
-	random = new KToggleAction(i18n("&Random Board"), actionCollection(), \
                "random_m_board");
-	showNumberRemaining = new KToggleAction(i18n("&Show Number Remaining"), \
                actionCollection(), "showNumberRemaining");
-	connect(showNumberRemaining, SIGNAL(triggered(bool) ), \
SLOT(showNumberRemainingToggled())); +	m_randomBoardAction = new \
KToggleAction(i18n("&Random Board"), actionCollection(), "random_m_board"); \
+	m_showNumberRemainingAction = new KToggleAction(i18n("&Show Number Remaining"), \
actionCollection(), "showNumberRemaining"); +	connect(m_showNumberRemainingAction, \
SIGNAL(triggered(bool) ), SLOT(showNumberRemainingToggled()));  
 	KStdAction::configureNotifications(this, SLOT(configureNotifications()),
                actionCollection());
 
-	status=statusBar();
-	status->insertItem(i18n("Colors: XX"),1,1);
-	status->insertItem(i18n("Board: XXXXXX"),2,1);
-	status->insertItem(i18n("Marked: 0"),3,1);
-	status->insertItem(i18n("Score: 0"),4,1);
+	m_statusBar = statusBar();
+	m_statusBar->insertItem( i18n( "Colors: XX" ), 1, 1 );
+	m_statusBar->insertItem( i18n( "Board: XXXXXX" ), 2, 1 );
+	m_statusBar->insertItem( i18n( "Marked: 0" ), 3, 1 );
+	m_statusBar->insertItem( i18n( "Score: 0" ), 4, 1 );
 
 	
-	stone = new StoneWidget(this,15,10);
-	stone->hide();
-
 	m_board = new KSame::Board( this );
 	connect( m_board, SIGNAL( scoreChanged( quint32 ) ),           this, SLOT( \
setScore( quint32 ) ) );  connect( m_board, SIGNAL( newCountOfMarkedStones( int ) ),  \
this, SLOT( setMarked( int ) ) ); @@ -90,7 +86,7 @@
 
 	setupGUI(KMainWindow::Save | Keys | Create | ToolBar );
 
-	random->setChecked( true );
+	m_randomBoardAction->setChecked( true );
 
 	if ( !qApp->isSessionRestored() )
 		QTimer::singleShot( 0, this, SLOT( newGame() ) );
@@ -98,46 +94,50 @@
 	KConfig *cfg = KGlobal::config();
 	if ( cfg->readEntry("showRemaining",false) )
 	{
-		showNumberRemaining->setChecked(true);
+		m_showNumberRemainingAction->setChecked(true);
 		showNumberRemainingToggled();
 	}
 }
 
-void KSameWidget::readProperties(KConfig *conf) {
+void KSameWidget::readProperties( KConfig *conf )
+{
 	Q_ASSERT(conf);
-	stone->readProperties(conf);
+	// TODO: Implement this
+	// stone->readProperties(conf);
 }
 
-void KSameWidget::saveProperties(KConfig *conf) {
+void KSameWidget::saveProperties( KConfig *conf )
+{
 	Q_ASSERT(conf);
-	stone->saveProperties(conf);
+	// TODO: Implement this
+	//stone->saveProperties(conf);
 	conf->sync();
 }
 
 void KSameWidget::showNumberRemainingToggled()
 {
-	if ( showNumberRemaining->isChecked() )
+	if ( m_showNumberRemainingAction->isChecked() )
 	{
 		setScore( m_board->score() );
 	}
-	else status->changeItem( i18n( "%1 Colors", m_board->colors() ),1 );
+	else m_statusBar->changeItem( i18n( "%1 Colors", m_board->colors() ),1 );
 	
 	KConfig *cfg = KGlobal::config();
-	cfg->writeEntry("showRemaining", showNumberRemaining->isChecked());
+	cfg->writeEntry("showRemaining", m_showNumberRemainingAction->isChecked());
 	cfg->sync();
 }
 
 void KSameWidget::newGame(unsigned int boardNumber,int colors)
 {
-	m_board->newGame(boardNumber, 12, 8, colors);
+	m_board->newGame(boardNumber, 15, 10, colors);
 	setScore(0);
 }
 
 void KSameWidget::onNewGameStarted( quint32 boardNumber, quint8 colors )
 {
 	setScore( m_board->score() );
-	status->changeItem( i18n( "%1 Colors", colors),1);
-	status->changeItem( ki18n( "Board: %1" ).subs( boardNumber, 6 ).toString(), 2);
+	m_statusBar->changeItem( i18n( "%1 Colors", colors),1);
+	m_statusBar->changeItem( ki18n( "Board: %1" ).subs( boardNumber, 6 ).toString(), \
2);  }
 
 bool KSameWidget::confirmAbort()
@@ -153,7 +153,7 @@
 	if ( not confirmAbort() )
 		return;
 
-	if ( random->isChecked() )
+	if ( m_randomBoardAction->isChecked() )
 	{
 		newGame( KRandom::random() % 1000000, default_colors );
 	}
@@ -172,7 +172,7 @@
 	}
 }
 
-void KSameWidget::m_restart()
+void KSameWidget::restartGame()
 {
 	if ( confirmAbort() )
 		newGame( m_board->boardNumber(), m_board->colors() );
@@ -193,8 +193,7 @@
 
 void KSameWidget::setMarked( int markedStones )
 {
-	status->changeItem( ki18n( "Marked: %1" ).subs( markedStones, 6 ).toString(), 3);
-	m_markedStones = markedStones;
+	m_statusBar->changeItem( ki18n( "Marked: %1" ).subs( markedStones, 6 ).toString(), \
3);  }
 
 void KSameWidget::stonesRemoved( int count )
@@ -205,7 +204,7 @@
 
 void KSameWidget::setScore( quint32 score )
 {
-	if ( showNumberRemaining->isChecked() )
+	if ( m_showNumberRemainingAction->isChecked() )
 	{
 		QStringList list;
 		for( int i = 1; i <= m_board->colors(); i++)
@@ -213,11 +212,11 @@
 			list << QString( "%1" ).arg( m_board->count( i ) );
 		}
 		QString count = QString( " (%1)" ).arg( list.join( "," ) );
-		status->changeItem( i18n( "%1 Colors%2", m_board->colors(), count ), 1 );
+		m_statusBar->changeItem( i18n( "%1 Colors%2", m_board->colors(), count ), 1 );
 	}
-	status->changeItem( ki18n( "Score: %1" ).subs( score, 6 ).toString(), 4 );
-	m_undo->setEnabled( m_board->canUndo() );
-	restart->setEnabled( m_board->changed() );
+	m_statusBar->changeItem( ki18n( "Score: %1" ).subs( score, 6 ).toString(), 4 );
+	m_undoAction->setEnabled( m_board->canUndo() );
+	m_restartAction->setEnabled( m_board->changed() );
 }
 
 void KSameWidget::gameover()
@@ -226,13 +225,13 @@
 	{
 		KNotification::event( "game won",
 		                      i18n( "You even removed the last stone, great job! "
-		                      "This gave you a score of %1 in total.", stone->score() ), \
QPixmap(), this ); +		                      "This gave you a score of %1 in total.", \
m_board->score() ), QPixmap(), this );  }
 	else
 	{
 		KNotification::event( "game over",
 		                      i18n( "There are no more removable stones. "
-		                      "You got a score of %1 in total.", stone->score() ), \
QPixmap(), this ); +		                      "You got a score of %1 in total.", \
m_board->score() ), QPixmap(), this );  }
 
 	KScoreDialog d( KScoreDialog::Name | KScoreDialog::Score, this );
--- trunk/KDE/kdegames/ksame/KSameWidget.h #604218:604219
@@ -25,57 +25,50 @@
 #include <kmainwindow.h>
 
 class KToggleAction;
-class StoneWidget;
 namespace KSame
 {
 	class Board;
 } // namespace KSame
 
-class KSameWidget: public KMainWindow {
-     Q_OBJECT
+class KSameWidget: public KMainWindow
+{
+	Q_OBJECT
 
-public:
-     KSameWidget(QWidget *parent=0);
+	public:
+		KSameWidget(QWidget *parent=0);
 
-private slots:
-     /* File Menu */
-     void newGame();
-     void onNewGameStarted( quint32 boardNumber, quint8 colors );
-     void m_restart();
-     void showHighScoreDialog();
-     void undo();
+	private slots:
+		void newGame();
+		void onNewGameStarted( quint32 boardNumber, quint8 colors );
+		void restartGame();
+		void showHighScoreDialog();
+		void undo();
 
-     void configureNotifications();
+		void configureNotifications();
 
-     void gameover();
-     void setScore(quint32 score);
-     void setMarked(int m);
-     void stonesRemoved( int count );
-     
-     void showNumberRemainingToggled();
+		void gameover();
+		void setScore(quint32 score);
+		void setMarked(int m);
+		void stonesRemoved( int count );
 
-protected:
-     void newGame(unsigned int board, int colors);
+		void showNumberRemainingToggled();
 
-     virtual void saveProperties(KConfig *conf);
-     virtual void readProperties(KConfig *conf);
+	protected:
+		void newGame(unsigned int board, int colors);
 
-     bool confirmAbort();
+		virtual void saveProperties(KConfig *conf);
+		virtual void readProperties(KConfig *conf);
 
-private:
-     // Remember how many stones were last marked, since when
-     // the stones are removed, board->marked() suddenly becomes
-     // 0 (or doesn't otherwise reflect the number of stones just removed).
-     int m_markedStones;
+		bool confirmAbort();
 
-     StoneWidget *stone;
-     KSame::Board *m_board;
-     KStatusBar *status;
-     KToggleAction *random;
-     KToggleAction *showNumberRemaining;
-     KAction *restart;
-     KAction *m_undo;
+	private:
+		KSame::Board *m_board;
+		KStatusBar   *m_statusBar;
 
+		KToggleAction *m_randomBoardAction;
+		KToggleAction *m_showNumberRemainingAction;
+		KAction       *m_restartAction;
+		KAction       *m_undoAction;
 };
 
 #endif // _KSAMEWIDGET
--- trunk/KDE/kdegames/ksame/board.h #604218:604219
@@ -80,7 +80,7 @@
 		public:
 			Board( QObject *parent = 0 );
 
-			void newGame( quint32 boardNumber = 0, quint8 width = 12, quint8 height = 8, \
quint8 colorCount = 3 ); +			void newGame( quint32 boardNumber = 0, quint8 width = \
15, quint8 height = 10, quint8 colorCount = 3 );  void resize( const QSize& size );
 
 			quint32 width()  const { return m_width;  }


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

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