]> Git trees. - libqmvoc.git/commitdiff
some bugs fixed
authorMartin Pfeiffer <hubipete@gmx.net>
Mon, 11 Jul 2005 17:14:39 +0000 (17:14 +0000)
committerMartin Pfeiffer <hubipete@gmx.net>
Mon, 11 Jul 2005 17:14:39 +0000 (17:14 +0000)
svn path=/branches/work/kwordquiz/src/leitnersystemview.cpp; revision=433742

kwordquiz/leitnersystem.h
kwordquiz/leitnersystemview.cpp
kwordquiz/prefleitner.cpp

index 87e583d9fc6e591dccd9dda729f986ab005f20d0..50b9f2ddd6050a4675c7f18938960e22e6dfb34b 100644 (file)
@@ -45,13 +45,22 @@ public:
        
        const QString& getCorrectBox( int box );        //returns the correct word box of "int box"
        const QString& getWrongBox( int box );          //returns the wrong word box of "int box"
+
        int getWrongBoxNumber( int box );
        int getCorrectBoxNumber( int box );
+
        void setCorrectBox( const QString& box, const QString& correctWordBox );
        void setWrongBox( const QString& box, const QString& wrongWordBox );
+
        bool setBoxName( int box, const QString& name );
        bool setBoxName( LeitnerBox* box, const QString& name );
        
+       void setBoxVocabCount( QString& box, int vocabCount );
+       int getBoxVocabCount( QString& box );
+
+       void incrementBoxVocabCount( QString& box );
+       void decrementBoxVocabCount( QString& box );
+
        //inserts a box with number, name, correct and wrong word box
        bool insertBox( const QString& name, int correctWordBox, int wrongWordBox );
        bool insertBox( const QString& name );
index 3dcd5b0b41ed7d4ada66c388a150335f0439c3f3..a7ddaf26ed83c8c618989910a6aa6614e8d260e5 100644 (file)
@@ -33,11 +33,6 @@ LeitnerSystemView::~LeitnerSystemView()
 
 void LeitnerSystemView::drawSystem(QPainter* p)
 {
-       kdDebug() << "drawSystem( )" << endl;
-       
-
-       //einarbeiten von m_selectedBox... aus prefLeitner
-       
        m_imageY = height() / 2 - 32;
 
        //draw the boxes' icons
@@ -69,23 +64,25 @@ void LeitnerSystemView::drawConnections(QPainter* p)
        //paint the connections for the correct word boxes, above the boxes 
        for(int i = 0; i < numberOfBoxes; i++)
        {
-               dist = m_leitnerSystem->getCorrectBoxNumber( i ) - i;
-                               
-               if(dist <= 0)
+               if( m_leitnerSystem->getCorrectBoxNumber( i ) != -1 )
                {
-                       // (dist*(-1) -1)*64 == for each box in between take 64
-                       // dist*(-1)*10 == the gaps in between
-                       // 2*22; 2*21 == the distances of the endings on the picture 
-                       width = (dist*(-1) -1)*64 + dist*(-1)*10 + 2*22 + 2*21; 
+                       dist = m_leitnerSystem->getCorrectBoxNumber( i ) - i;
+                               
+                       if(dist <= 0)
+                       {
+                               // (dist*(-1) -1)*64 == for each box in between take 64
+                               // dist*(-1)*10 == the gaps in between
+                               // 2*22; 2*21 == the distances of the endings on the picture 
+                               width = (dist*(-1) -1)*64 + dist*(-1)*10 + 2*22 + 2*21; 
                         
-                       p->drawArc( 12 + (dist+i)*74 + 21, m_imageY-(width/3), width, /*(height()/2 - 12-32) *2*/ width/3*2, 0, 180*16);
-               }
-               else
-               {
-                       width = (dist-1)*64 + dist*10 + 2*21;
-                       p->drawArc(12 + i*74 + 21+22 ,m_imageY-(width/3) , width, /*(height()/2 - 12-32) *2*/width/3*2, 0, 180*16);
-               }
-               
+                               p->drawArc( 12 + (dist+i)*74 + 21, m_imageY-(width/3), width, /*(height()/2 - 12-32) *2*/ width/3*2, 0, 180*16);
+                       }
+                       else
+                       {
+                               width = (dist-1)*64 + dist*10 + 2*21;
+                               p->drawArc(12 + i*74 + 21+22 ,m_imageY-(width/3) , width, /*(height()/2 - 12-32) *2*/width/3*2, 0, 180*16);
+                       }
+               }       
        }
        
        //paint the connections for the wrong word boxes, below the boxes
@@ -93,20 +90,22 @@ void LeitnerSystemView::drawConnections(QPainter* p)
 
        for(int i = 0; i < numberOfBoxes; i++)
        {
-               dist = m_leitnerSystem->getWrongBoxNumber( i ) - i;
-                               
-               if(dist <= 0)
-               {
-                       width = (dist*(-1) -1)*64 + dist*(-1)*10 + 2*22 + 2*21; 
-                       p->drawArc(12+ (dist+i)*74 + 21 ,m_imageY+64-width/3 , width, width/3*2 , 180*16, 180*16);
-               }
-               else
+               if( m_leitnerSystem->getWrongBoxNumber( i ) != -1 )
                {
-                       width = (dist-1)*64 + dist*10 + 2*21;
-                       p->drawArc(12 + i*74 + 21+22 ,m_imageY+64-width/3 , width, width/3*2, 180*16, 180*16);
+                       dist = m_leitnerSystem->getWrongBoxNumber( i ) - i;
+                               
+                       if(dist <= 0)
+                       {
+                               width = (dist*(-1) -1)*64 + dist*(-1)*10 + 2*22 + 2*21; 
+                               p->drawArc(12+ (dist+i)*74 + 21 ,m_imageY+64-width/3 , width, width/3*2 , 180*16, 180*16);
+                       }       
+                       else
+                       {
+                               width = (dist-1)*64 + dist*10 + 2*21;
+                               p->drawArc(12 + i*74 + 21+22 ,m_imageY+64-width/3 , width, width/3*2, 180*16, 180*16);
+                       }
                }
        }
-
 }
 
 void LeitnerSystemView::setSystem(LeitnerSystem* leitnersystem)
@@ -116,10 +115,6 @@ void LeitnerSystemView::setSystem(LeitnerSystem* leitnersystem)
        //calculate the new sizes
        calculateSize();
        updateContents();
-       //repaint
-       //update();
-       //QPainter* p = new QPainter(this);
-       //drawContents( p, 0, 0, 0, 0 );
 }
 
 void LeitnerSystemView::highlightBox(int box)
@@ -130,7 +125,6 @@ void LeitnerSystemView::highlightBox(int box)
 
 void LeitnerSystemView::drawContents(QPainter* p, int clipx, int clipy, int clipw, int cliph)
 {
-       kdDebug() << "drawContents" << endl;
        p->eraseRect(0,0,width(),height()); 
        
        drawSystem( p );
@@ -153,21 +147,27 @@ void LeitnerSystemView::calculateSize()
 
        for(int i = 0; i < numberOfBoxes; i++)
        {
-               dist = m_leitnerSystem->getCorrectBoxNumber( i ) - i;
+               if( m_leitnerSystem->getCorrectBoxNumber( i ) != -1 )
+               {       
+                       dist = m_leitnerSystem->getCorrectBoxNumber( i ) - i;
                                
-               if( abs(dist) >= abs(tmpMaxC) )
-                       tmpMaxC = dist;
-       
-               dist = m_leitnerSystem->getWrongBoxNumber( i ) - i;
+                       if( abs(dist) >= abs(tmpMaxC) )
+                               tmpMaxC = dist;
+               }
+               
+               if( m_leitnerSystem->getWrongBoxNumber( i ) != -1 )
+               {
+                       dist = m_leitnerSystem->getWrongBoxNumber( i ) - i;
                
-               if( abs(dist) >= abs(tmpMaxW) )
-                       tmpMaxW = dist;
+                       if( abs(dist) >= abs(tmpMaxW) )
+                               tmpMaxW = dist;
+               }
        }
-       
+
        if( tmpMaxC <= 0 )
                height += (( abs(tmpMaxC) -1)*64 + abs(tmpMaxC)*10 + 2*22 + 2*21)/3;
        else
-               height += (( tmpMaxC-1)*64 + tmpMaxC*10 + 2*21)/3;
+               height += ((tmpMaxC-1)*64 + tmpMaxC*10 + 2*21)/3;
        
        if( tmpMaxW <= 0 )
                height += (( abs(tmpMaxW) -1)*64 + abs(tmpMaxW)*10 + 2*22 + 2*21)/3;
@@ -175,7 +175,7 @@ void LeitnerSystemView::calculateSize()
                height += (( tmpMaxW-1)*64 + tmpMaxW*10 + 2*21)/3;
 
        height += 24+64;
-       
+
        resizeContents( numberOfBoxes * 64 + (numberOfBoxes - 1)*10 + 2 * 12, height );
        setMinimumSize( numberOfBoxes * 64 + (numberOfBoxes - 1)*10 + 2 * 12, height );
 }
@@ -184,7 +184,7 @@ void LeitnerSystemView::mousePressEvent(QMouseEvent* e)
 {
        kdDebug() << "mouseClick" << endl;
        //if the user has clicked into a box
-       if(e->y() > m_imageY && e->y() < m_imageY + 64 && e->x() < width()-13)
+       if( e->y() > m_imageY && e->y() < m_imageY + 64 && e->x() < contentsWidth() )
        {
                int d = (e->x()-12)/74;
                
@@ -196,20 +196,6 @@ void LeitnerSystemView::mousePressEvent(QMouseEvent* e)
                        
                        updateContents();
                }
-               else
-               {
-                       emit boxClicked( -1 );
-                       m_highlightedBox = -1;
-                       
-                       updateContents();
-               }
-       }
-       else
-       {
-               emit boxClicked( -1 );
-               m_highlightedBox = -1;
-                       
-               updateContents();
        }
 }
 
index 6efd7a93900d6852df7ce4441b1ed7c32093aa1f..de264abac4b253bc3fc9dab736daf6618c37ce9b 100644 (file)
@@ -33,15 +33,7 @@ PrefLeitner::PrefLeitner(QWidget * parent, const char* name, WFlags f, LeitnerSy
        PrefLeitnerBaseLayout->setOrigin( QGridLayout::BottomLeft );
        
        connect( m_leitnerSystemView, SIGNAL( boxClicked( int ) ), this, SLOT( slotBoxClicked( int ) ) );
-       /*
-       connect( cmbCorrect, SIGNAL( activated(const QString&) ), this, SLOT( slotCorrectWord(const QString&) ) );
-       connect( cmbWrong, SIGNAL( activated(const QString&) ), this, SLOT( slotWrongWord(const QString&) ) );
-       connect( lndBoxName, SIGNAL( textChanged(const QString&) ), this, SLOT( slotBoxName(const QString&) ) );
-       connect( btnAddBox, SIGNAL( clicked() ), this, SLOT( slotAddBox() ) );
-       connect( btnDeleteBox, SIGNAL( clicked() ), this, SLOT( slotDeleteBox() ) );*/
-//     connect( btnApply, SIGNAL( clicked() ), this, SLOT( slotApply() ) );
-//     connect( btnDiscard, SIGNAL( clicked() ), this, SLOT( slotDiscard() ) );
-       
+
        //insert the list of box' names in the comboboxes
        cmbWrong->insertStringList( m_selectedSystem->getBoxNameList() );
        cmbCorrect->insertStringList( m_selectedSystem->getBoxNameList() );
@@ -77,6 +69,9 @@ void PrefLeitner::slotWrongWord( const QString& newBox )
 
 void PrefLeitner::slotBoxName( const QString& newName )
 {
+       if( m_selectedBox == 0 )
+               return;
+
        //when the boxes name was changed
        m_selectedSystem->setBoxName( m_selectedBox, newName );
 }
@@ -96,21 +91,11 @@ void PrefLeitner::refreshSystemView()
 
 void PrefLeitner::slotBoxClicked( int box )
 {
-       if( box == -1 )
-       {
-               kdDebug() << "outside" << endl;
-               m_selectedBox = 0;
-               lndBoxName->setText( "" );
-       }
-       else
-       {
-               kdDebug() << "inside" << endl;
-               m_selectedBox = m_selectedSystem->getBoxWithNumber( box );
+       m_selectedBox = m_selectedSystem->getBoxWithNumber( box );
                
-               cmbCorrect->setCurrentItem( m_selectedSystem->getCorrectBoxNumber( box ) );
-               cmbWrong->setCurrentItem( m_selectedSystem->getWrongBoxNumber( box ) );
-               lndBoxName->setText( m_selectedBox->getBoxName() );
-       }
+       cmbCorrect->setCurrentItem( m_selectedSystem->getCorrectBoxNumber( box ) );
+       cmbWrong->setCurrentItem( m_selectedSystem->getWrongBoxNumber( box ) );
+       lndBoxName->setText( m_selectedBox->getBoxName() );
 }
 
 void PrefLeitner::slotAddBox()
@@ -122,20 +107,19 @@ void PrefLeitner::slotAddBox()
 void PrefLeitner::slotDeleteBox()
 {
        m_selectedSystem->deleteBox( m_selectedBox );
-       
+       m_selectedBox = 0;
+
        refreshSystemView();
 }
 
 void PrefLeitner::slotApply()
 {
-       kdDebug() << "apply" << endl;
        setResult( QDialog::Accepted );
        close();
 }
 
 void PrefLeitner::slotDiscard()
 {
-       kdDebug() << "discard" << endl;
        setResult( QDialog::Rejected );
        close();
 }
@@ -145,4 +129,3 @@ LeitnerSystem* PrefLeitner::getSystem()
        return m_selectedSystem;
 }
 
-//#include "prefleitner.moc"