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 );
void LeitnerSystemView::drawSystem(QPainter* p)
{
- kdDebug() << "drawSystem( )" << endl;
-
-
- //einarbeiten von m_selectedBox... aus prefLeitner
-
m_imageY = height() / 2 - 32;
//draw the boxes' icons
//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
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)
//calculate the new sizes
calculateSize();
updateContents();
- //repaint
- //update();
- //QPainter* p = new QPainter(this);
- //drawContents( p, 0, 0, 0, 0 );
}
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 );
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;
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 );
}
{
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;
updateContents();
}
- else
- {
- emit boxClicked( -1 );
- m_highlightedBox = -1;
-
- updateContents();
- }
- }
- else
- {
- emit boxClicked( -1 );
- m_highlightedBox = -1;
-
- updateContents();
}
}
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() );
void PrefLeitner::slotBoxName( const QString& newName )
{
+ if( m_selectedBox == 0 )
+ return;
+
//when the boxes name was changed
m_selectedSystem->setBoxName( m_selectedBox, newName );
}
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()
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();
}
return m_selectedSystem;
}
-//#include "prefleitner.moc"