]> Git trees. - libqmvoc.git/commitdiff
more bugs fixed+cleanup
authorMartin Pfeiffer <hubipete@gmx.net>
Mon, 11 Jul 2005 17:18:31 +0000 (17:18 +0000)
committerMartin Pfeiffer <hubipete@gmx.net>
Mon, 11 Jul 2005 17:18:31 +0000 (17:18 +0000)
svn path=/branches/work/kwordquiz/src/leitnersystem.cpp; revision=433743

kwordquiz/leitnersystem.cpp
kwordquiz/leitnersystemview.h

index 178b8b9e6aa1c8c24b7bbff0c4804877a3b41ca8..b903b8f498a2321b10dabf931405ac923c8a7fcf 100644 (file)
@@ -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-- );
+}
+
index be52bc0b8578a9d593e7237e4f5d6e6935744df2..86394630db965020a2cce0aa6df99940ebb8d8bf 100644 (file)
@@ -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