return;
if (idx <= numTranslations())
- translations.erase (translations.begin() + idx-1);
+ translations.remove(translations.at(idx-1));
if (idx < (int)remarks.size() )
remarks.erase (remarks.begin() + idx);
#define KV_LEV7_GRADE 7
#define KV_LEV7_TEXT I18N_NOOP("Level 7")
+#include <qstringlist.h>
+
#include <time.h>
#include <vector>
using namespace std;
// all these vectors must be deleted in removeTranslation()
vector<QString> exprtypes;
- vector<QString> translations;
+ /*vector<QString>*/ QStringList translations;
vector<QString> remarks;
vector<QString> usageLabels;
vector<QString> paraphrases;
//
// C++ Implementation: leitnerbox
//
-// Description:
+// Description:
//
//
// Author: Martin Pfeiffer <martin-pfeiffer-bensheim@web.de>, (C) 2005
{
}
-int LeitnerBox::getVocabCount()
+int LeitnerBox::vocabCount()
{
return m_vocabCount;
}
m_vocabCount = count;
}
-const QString& LeitnerBox::getBoxName() const
+const QString& LeitnerBox::boxName() const
{
return m_name;
}
-LeitnerBox* LeitnerBox::getCorrectWordBox()
+LeitnerBox* LeitnerBox::correctWordBox()
{
return m_correctWordBox;
}
-LeitnerBox* LeitnerBox::getWrongWordBox()
+LeitnerBox* LeitnerBox::wrongWordBox()
{
return m_wrongWordBox;
}
bool LeitnerBox::operator ==( const LeitnerBox& a ) const
{
- if( a.getBoxName() == getBoxName() )
+ if( a.boxName() == boxName() )
return true;
else
return false;
//
// C++ Interface: leitnerbox
//
-// Description:
+// Description:
//
//
// Author: Martin Pfeiffer <martin-pfeiffer-bensheim@web.de>, (C) 2005
void setBoxName( const QString& ); //sets the boxes name
void setVocabCount( int count );
- int getVocabCount();
-
- LeitnerBox* getCorrectWordBox();
- LeitnerBox* getWrongWordBox();
- const QString& getBoxName() const;
-
+ int vocabCount();
+
+ LeitnerBox* correctWordBox();
+ LeitnerBox* wrongWordBox();
+ const QString& boxName() const;
+
bool operator == ( const LeitnerBox& a ) const;
private:
QString m_name;
int m_vocabCount;
-
+
LeitnerBox* m_wrongWordBox;
LeitnerBox* m_correctWordBox;
};
//
// C++ Implementation: leitnersystem
//
-// Description:
+// Description:
//
//
// Author: Martin Pfeiffer <martin-pfeiffer-bensheim@web.de>, (C) 2005
QStringList LeitnerSystem::getBoxNameList()
{
QStringList boxNameList;
- QValueList<LeitnerBox>::iterator it;
+ QValueList<LeitnerBox>::iterator it;
for(it = m_boxes.begin(); it != m_boxes.end(); ++it)
{
- boxNameList.append((*it).getBoxName());
+ boxNameList.append((*it).boxName());
}
return boxNameList;
return m_boxes.count();
}
-LeitnerBox* LeitnerSystem::getBoxWithNumber( int number )
+LeitnerBox* LeitnerSystem::boxWithNumber( int number )
{
return &m_boxes[ number ];
}
-LeitnerBox* LeitnerSystem::getBoxWithName( const QString& name )
+LeitnerBox* LeitnerSystem::boxWithName( const QString& name )
{
QValueList<LeitnerBox>::iterator it;
for(it = m_boxes.begin(); it != m_boxes.end(); ++it)
{
- if((*it).getBoxName() == name)
+ if((*it).boxName() == name)
return &(*it);
}
return 0;
}
-QString& LeitnerSystem::getSystemName()
+QString& LeitnerSystem::systemName()
{
return m_systemName;
}
-const QString& LeitnerSystem::getNextBox( QString& previousBox )
+const QString& LeitnerSystem::nextBox( QString& previousBox )
{
for( int i = 0; i < m_boxes.count(); i++ )
{
- if( m_boxes[i].getVocabCount() > 0 )
- return getBox( i );
+ if( m_boxes[i].vocabCount() > 0 )
+ return box( i );
}
-
+
return QString::null;
}
-const QString& LeitnerSystem::getCorrectBox( int box )
+const QString& LeitnerSystem::correctBox( int box )
{
- return m_boxes[ box ].getCorrectWordBox()->getBoxName();
+ return m_boxes[ box ].correctWordBox()->boxName();
}
-const QString& LeitnerSystem::getWrongBox( int box )
+const QString& LeitnerSystem::wrongBox( int box )
{
- return m_boxes[ box ].getWrongWordBox()->getBoxName();
+ return m_boxes[ box ].wrongWordBox()->boxName();
}
-const QString& LeitnerSystem::getCorrectBox( QString& box )
+const QString& LeitnerSystem::correctBox( QString& box )
{
- return getBoxWithName( box )->getCorrectWordBox()->getBoxName();
+ return boxWithName( box )->correctWordBox()->boxName();
}
-const QString& LeitnerSystem::getWrongBox( QString& box )
+const QString& LeitnerSystem::wrongBox( QString& box )
{
- return getBoxWithName( box )->getWrongWordBox()->getBoxName();
+ return boxWithName( box )->wrongWordBox()->boxName();
}
-int LeitnerSystem::getWrongBoxNumber( int box )
+int LeitnerSystem::wrongBoxNumber( int box )
{
- return getNumber( m_boxes[ box ].getWrongWordBox() );
+ return number( m_boxes[ box ].wrongWordBox() );
}
-int LeitnerSystem::getCorrectBoxNumber( int box )
+int LeitnerSystem::correctBoxNumber( int box )
{
- return getNumber( m_boxes[ box ].getCorrectWordBox() );
+ return number( m_boxes[ box ].correctWordBox() );
}
void LeitnerSystem::deleteBox( int box )
{
for( int i = 0; i < m_boxes.count(); i++ )
{
- if( m_boxes[i].getCorrectWordBox() == box )
+ if( m_boxes[i].correctWordBox() == box )
m_boxes[i].setCorrectWordBox( 0 );
- if( m_boxes[i].getWrongWordBox() == box )
+ if( m_boxes[i].wrongWordBox() == box )
m_boxes[i].setWrongWordBox( 0 );
}
{
if( getBoxNameList().contains( name ) != 0 )
return false;
-
+
LeitnerBox tmpBox;
tmpBox.setBoxName( name );
- tmpBox.setCorrectWordBox( getBoxWithNumber( correctWordBox ) );
- tmpBox.setWrongWordBox( getBoxWithNumber( wrongWordBox ) );
-
+ tmpBox.setCorrectWordBox( boxWithNumber( correctWordBox ) );
+ tmpBox.setWrongWordBox( boxWithNumber( wrongWordBox ) );
+
m_boxes.append( tmpBox );
return true;
}
m_systemName = name;
}
-int LeitnerSystem::getNumber( LeitnerBox* box )
+int LeitnerSystem::number( LeitnerBox* box )
{
if( box == 0 )
return -1;
bool LeitnerSystem::setBoxName( int box, const QString& name )
{
- if( getBoxWithName( name ) == 0 || getBoxWithName( name ) == getBoxWithNumber( box ) )
+ if( boxWithName( name ) == 0 || boxWithName( name ) == boxWithNumber( box ) )
{
- getBoxWithNumber( box )->setBoxName( name );
-
+ boxWithNumber( box )->setBoxName( name );
+
return true;
}
else
bool LeitnerSystem::setBoxName( LeitnerBox* box, const QString& name )
{
- if( getBoxWithName( name ) == 0 || getBoxWithName( name ) == box )
+ if( boxWithName( name ) == 0 || boxWithName( name ) == box )
{
box->setBoxName( name );
-
+
return true;
}
else
{
if( getBoxNameList().contains( name ) != 0 )
return false;
-
+
LeitnerBox tmpBox;
tmpBox.setBoxName( name );
-
+
m_boxes.append( tmpBox );
return true;
}
void LeitnerSystem::setCorrectBox( const QString& box, const QString& correctWordBox )
{
- getBoxWithName( box )->setCorrectWordBox( getBoxWithName( correctWordBox ) );
+ boxWithName( box )->setCorrectWordBox( boxWithName( correctWordBox ) );
}
void LeitnerSystem::setWrongBox( const QString& box, const QString& wrongWordBox )
{
- getBoxWithName( box )->setWrongWordBox( getBoxWithName( wrongWordBox ) );
+ boxWithName( box )->setWrongWordBox( boxWithName( wrongWordBox ) );
}
-const QString& LeitnerSystem::getBox( int i )
+const QString& LeitnerSystem::box( int i )
{
- return getBoxWithNumber( i )->getBoxName();
+ return boxWithNumber( i )->boxName();
}
void LeitnerSystem::setBoxVocabCount( QString& box, int vocabCount )
{
- getBoxWithName( box )->setVocabCount( vocabCount );
+ boxWithName( box )->setVocabCount( vocabCount );
}
-int LeitnerSystem::getBoxVocabCount( QString& box )
+int LeitnerSystem::boxVocabCount( QString& box )
{
- return getBoxWithName( box )->getVocabCount();
+ return boxWithName( box )->vocabCount();
}
void LeitnerSystem::incrementBoxVocabCount( QString& box )
{
- int tmp = getBoxWithName( box )->getVocabCount();
- getBoxWithName( box )->setVocabCount( tmp++ );
+ int tmp = boxWithName( box )->vocabCount();
+ boxWithName( box )->setVocabCount( tmp++ );
}
void LeitnerSystem::decrementBoxVocabCount( QString& box )
{
- int tmp = getBoxWithName( box )->getVocabCount();
- getBoxWithName( box )->setVocabCount( tmp-- );
+ int tmp = boxWithName( box )->vocabCount();
+ boxWithName( box )->setVocabCount( tmp-- );
}
//
// C++ Interface: leitnersystem
//
-// Description:
+// Description:
//
//
// Author: Martin Pfeiffer <martin-pfeiffer-bensheim@web.de>, (C) 2005
int getNumberOfBoxes(); //returns the number of boxes in the system
QStringList getBoxNameList(); //returns a list with the boxes names
- QString& getSystemName(); //returns the systems name
+ QString& systemName(); //returns the systems name
void setSystemName( const QString& name ); //sets the systems name
- LeitnerBox* getBoxWithNumber( int number ); //returns box by number
- LeitnerBox* getBoxWithName( const QString& name );//returns box by name
- int getNumber( LeitnerBox* box );
- const QString& getBox( int i );
-
- const QString& getNextBox( QString& previousBox ); //returns the next box for the next question
-
- 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"
- const QString& getCorrectBox( QString& box );
- const QString& getWrongBox( QString& box );
-
- int getWrongBoxNumber( int box );
- int getCorrectBoxNumber( int box );
+ LeitnerBox* boxWithNumber( int number ); //returns box by number
+ LeitnerBox* boxWithName( const QString& name );//returns box by name
+ int number( LeitnerBox* box );
+ const QString& box( int i );
+
+ const QString& nextBox( QString& previousBox ); //returns the next box for the next question
+
+ const QString& correctBox( int box ); //returns the correct word box of "int box"
+ const QString& wrongBox( int box ); //returns the wrong word box of "int box"
+ const QString& correctBox( QString& box );
+ const QString& wrongBox( QString& box );
+
+ int wrongBoxNumber( int box );
+ int correctBoxNumber( 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 );
+ int boxVocabCount( QString& box );
void incrementBoxVocabCount( QString& box );
void decrementBoxVocabCount( QString& box );
//
// C++ Implementation: leitnersystemview
//
-// Description:
+// Description:
//
//
// Author: Martin Pfeiffer <martin-pfeiffer-bensheim@web.de>, (C) 2005
}
else
{ //for each box 74 = 64(pixmap) + 10(distance between two boxes)
- //p->drawPixmap(12 + i * 74, m_imageY, KGlobal::iconLoader()->loadIcon("leitnerbox", KIcon::Panel));
+ //p->drawPixmap(12 + i * 74, m_imageY, KGlobal::iconLoader()->loadIcon("leitnerbox", KIcon::Panel));
p->drawRect(12 + i * 64 + i*10, m_imageY,64,64);
}
}
//width = width of the rect for the arc
int dist, width = 0;
int numberOfBoxes = m_leitnerSystem->getNumberOfBoxes();
-
+
p->setPen( QPen(green, 2) );
- //paint the connections for the correct word boxes, above the boxes
+ //paint the connections for the correct word boxes, above the boxes
for(int i = 0; i < numberOfBoxes; i++)
{
- if( m_leitnerSystem->getCorrectBoxNumber( i ) != -1 )
+ if( m_leitnerSystem->correctBoxNumber( i ) != -1 )
{
- dist = m_leitnerSystem->getCorrectBoxNumber( i ) - i;
-
+ dist = m_leitnerSystem->correctBoxNumber( 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;
-
+ // 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);
}
- }
+ }
}
-
+
//paint the connections for the wrong word boxes, below the boxes
p->setPen(QPen(red, 2));
for(int i = 0; i < numberOfBoxes; i++)
{
- if( m_leitnerSystem->getWrongBoxNumber( i ) != -1 )
+ if( m_leitnerSystem->wrongBoxNumber( i ) != -1 )
{
- dist = m_leitnerSystem->getWrongBoxNumber( i ) - i;
-
+ dist = m_leitnerSystem->wrongBoxNumber( i ) - i;
+
if(dist <= 0)
{
- width = (dist*(-1) -1)*64 + dist*(-1)*10 + 2*22 + 2*21;
+ 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;
void LeitnerSystemView::setSystem(LeitnerSystem* leitnersystem)
{
m_leitnerSystem = leitnersystem;
-
+
//calculate the new sizes
calculateSize();
updateContents();
void LeitnerSystemView::drawContents(QPainter* p, int clipx, int clipy, int clipw, int cliph)
{
- p->eraseRect(0,0,width(),height());
-
+ p->eraseRect(0,0,width(),height());
+
drawSystem( p );
-
+
drawConnections( p );
}
//margin = 12
//distance between boxes = 10
//boxes = 64*64
-
+
int numberOfBoxes = m_leitnerSystem->getNumberOfBoxes();
QString x;
int height, dist, tmpMaxC, tmpMaxW;
tmpMaxC = 0;
- tmpMaxW = 0;
+ tmpMaxW = 0;
height = 0;
for(int i = 0; i < numberOfBoxes; i++)
{
- if( m_leitnerSystem->getCorrectBoxNumber( i ) != -1 )
- {
- dist = m_leitnerSystem->getCorrectBoxNumber( i ) - i;
-
+ if( m_leitnerSystem->correctBoxNumber( i ) != -1 )
+ {
+ dist = m_leitnerSystem->correctBoxNumber( i ) - i;
+
if( abs(dist) >= abs(tmpMaxC) )
tmpMaxC = dist;
}
-
- if( m_leitnerSystem->getWrongBoxNumber( i ) != -1 )
+
+ if( m_leitnerSystem->wrongBoxNumber( i ) != -1 )
{
- dist = m_leitnerSystem->getWrongBoxNumber( i ) - i;
-
+ dist = m_leitnerSystem->wrongBoxNumber( i ) - i;
+
if( abs(dist) >= abs(tmpMaxW) )
tmpMaxW = dist;
}
height += (( abs(tmpMaxC) -1)*64 + abs(tmpMaxC)*10 + 2*22 + 2*21)/3;
else
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;
else
if( e->y() > m_imageY && e->y() < m_imageY + 64 && e->x() < contentsWidth() )
{
int d = (e->x()-12)/74;
-
+
if((e->x()-12-74*d) <= 64)
{
//signal for prefLeitner to set the comboboxes to the clicked box
emit boxClicked( d );
m_highlightedBox = d;
-
+
updateContents();
}
}
m_leitnerSystemView = new LeitnerSystemView( this, 0 );
PrefLeitnerBaseLayout->addWidget( m_leitnerSystemView, 1, 0 );
PrefLeitnerBaseLayout->setOrigin( QGridLayout::BottomLeft );
-
+
connect( m_leitnerSystemView, SIGNAL( boxClicked( int ) ), this, SLOT( slotBoxClicked( int ) ) );
//insert the list of box' names in the comboboxes
cmbWrong->insertStringList( m_selectedSystem->getBoxNameList() );
cmbCorrect->insertStringList( m_selectedSystem->getBoxNameList() );
-
+
//show leitnersystem
m_leitnerSystemView->setSystem( m_selectedSystem );
}
{
if( m_selectedBox == 0 )
return;
-
+
//when the correct word box was changed in the combobox
- m_selectedBox->setCorrectWordBox( m_selectedSystem->getBoxWithName( newBox ) );
+ m_selectedBox->setCorrectWordBox( m_selectedSystem->boxWithName( newBox ) );
refreshSystemView();
}
{
if( m_selectedBox == 0 )
return;
-
+
//when the wrong word box was changed in the combobox
- m_selectedBox->setWrongWordBox( m_selectedSystem->getBoxWithName( newBox ) );
+ m_selectedBox->setWrongWordBox( m_selectedSystem->boxWithName( newBox ) );
refreshSystemView();
}
{
cmbCorrect->insertStringList( m_selectedSystem->getBoxNameList() );
cmbWrong->insertStringList( m_selectedSystem->getBoxNameList() );
-
+
refreshSystemView();
}
void PrefLeitner::slotBoxClicked( int box )
{
- m_selectedBox = m_selectedSystem->getBoxWithNumber( box );
-
- cmbCorrect->setCurrentItem( m_selectedSystem->getCorrectBoxNumber( box ) );
- cmbWrong->setCurrentItem( m_selectedSystem->getWrongBoxNumber( box ) );
- lndBoxName->setText( m_selectedBox->getBoxName() );
+ m_selectedBox = m_selectedSystem->boxWithNumber( box );
+
+ cmbCorrect->setCurrentItem( m_selectedSystem->correctBoxNumber( box ) );
+ cmbWrong->setCurrentItem( m_selectedSystem->wrongBoxNumber( box ) );
+ lndBoxName->setText( m_selectedBox->boxName() );
}
void PrefLeitner::slotAddBox()