From 4ed3b5aace9bebf72b6c9d5a4be832dd1f2599b4 Mon Sep 17 00:00:00 2001 From: Martin Pfeiffer Date: Mon, 11 Jul 2005 17:18:31 +0000 Subject: [PATCH] more bugs fixed+cleanup svn path=/branches/work/kwordquiz/src/leitnersystem.cpp; revision=433743 --- kwordquiz/leitnersystem.cpp | 42 ++++++++++++++++++++++++++++++----- kwordquiz/leitnersystemview.h | 1 - 2 files changed, 37 insertions(+), 6 deletions(-) diff --git a/kwordquiz/leitnersystem.cpp b/kwordquiz/leitnersystem.cpp index 178b8b9..b903b8f 100644 --- a/kwordquiz/leitnersystem.cpp +++ b/kwordquiz/leitnersystem.cpp @@ -104,12 +104,21 @@ int LeitnerSystem::getCorrectBoxNumber( int box ) void LeitnerSystem::deleteBox( int box ) { - m_boxes.remove( m_boxes.at( box ) ); + deleteBox( &(*m_boxes.at( box )) ); } void LeitnerSystem::deleteBox( LeitnerBox* box ) { - m_boxes.remove( *box ); + for( int i = 0; i < m_boxes.count(); i++ ) + { + if( m_boxes[i].getCorrectWordBox() == box ) + m_boxes[i].setCorrectWordBox( 0 ); + + if( m_boxes[i].getWrongWordBox() == box ) + m_boxes[i].setWrongWordBox( 0 ); + } + + m_boxes.remove( *box ); } bool LeitnerSystem::insertBox( const QString& name, int correctWordBox, int wrongWordBox ) @@ -133,8 +142,9 @@ void LeitnerSystem::setSystemName( const QString& name ) int LeitnerSystem::getNumber( LeitnerBox* box ) { - if( m_boxes.findIndex( *box ) == -1 ) - kdDebug() << "muhaha" << endl; + if( box == 0 ) + return -1; + return m_boxes.findIndex( *box ); } @@ -169,7 +179,6 @@ bool LeitnerSystem::insertBox( const QString& name ) LeitnerBox tmpBox; tmpBox.setBoxName( name ); - //tmpBox.setVocabCount( count ); m_boxes.append( tmpBox ); return true; @@ -189,3 +198,26 @@ const QString& LeitnerSystem::getBox( int i ) { return getBoxWithNumber( i )->getBoxName(); } + +void LeitnerSystem::setBoxVocabCount( QString& box, int vocabCount ) +{ + getBoxWithName( box )->setVocabCount( vocabCount ); +} + +int LeitnerSystem::getBoxVocabCount( QString& box ) +{ + return getBoxWithName( box )->getVocabCount(); +} + +void LeitnerSystem::incrementBoxVocabCount( QString& box ) +{ + int tmp = getBoxWithName( box )->getVocabCount(); + getBoxWithName( box )->setVocabCount( tmp++ ); +} + +void LeitnerSystem::decrementBoxVocabCount( QString& box ) +{ + int tmp = getBoxWithName( box )->getVocabCount(); + getBoxWithName( box )->setVocabCount( tmp-- ); +} + diff --git a/kwordquiz/leitnersystemview.h b/kwordquiz/leitnersystemview.h index be52bc0..8639463 100644 --- a/kwordquiz/leitnersystemview.h +++ b/kwordquiz/leitnersystemview.h @@ -48,7 +48,6 @@ private: void drawConnections(QPainter*); //paints the arrows between the boxes void calculateSize(); - //QRect m_viewArea; int m_imageY; //high border of the images int m_distPixmap; int m_highlightedBox; //the box which is currently highlighted -- 2.47.3