return m_correctWordBox;
}
+const LeitnerBox* LeitnerBox::correctWordBox() const
+{
+ return m_correctWordBox;
+}
+
LeitnerBox* LeitnerBox::wrongWordBox()
{
return m_wrongWordBox;
}
+const LeitnerBox* LeitnerBox::wrongWordBox() const
+{
+ return m_wrongWordBox;
+}
+
void LeitnerBox::setBoxName( const QString& name )
{
m_name = name;
*/
LeitnerBox* correctWordBox();
+ const LeitnerBox* correctWordBox() const;
+
/**
* Returns a pointer to the LeitnerBox wrong cards of this LeitnerBox here are assigned to
* @return a pointer to a LeitnerBox
*/
LeitnerBox* wrongWordBox();
+ const LeitnerBox* wrongWordBox() const;
+
bool operator == ( const LeitnerBox& a ) const;
private:
return &m_boxes[ number ];
}
+const LeitnerBox* LeitnerSystem::boxWithNumber( int number ) const
+{
+ return &m_boxes.at( number );
+}
+
LeitnerBox* LeitnerSystem::boxWithName( const QString& name )
{
QList<LeitnerBox>::iterator it, it2;
return 0;
}
-QString& LeitnerSystem::systemName()
+const LeitnerBox* LeitnerSystem::boxWithName( const QString& name ) const
+{
+ QList<LeitnerBox>::const_iterator it, it2;
+ it = m_boxes.begin();
+ it2 = m_boxes.end();
+ for ( ; it != it2; ++it)
+ {
+ if ( (*it).boxName() == name )
+ return &(*it);
+ }
+
+ return 0;
+}
+
+QString LeitnerSystem::systemName() const
{
return m_systemName;
}
-QString LeitnerSystem::nextBox( QString& previousBox )
+QString LeitnerSystem::nextBox( const QString& previousBox )
{
for( int i = 0; i < m_boxes.count(); i++ )
{
return QString();
}
-const QString& LeitnerSystem::correctBox( int box )
+QString LeitnerSystem::correctBox( int box ) const
{
return m_boxes[ box ].correctWordBox()->boxName();
}
-const QString& LeitnerSystem::wrongBox( int box )
+QString LeitnerSystem::wrongBox( int box ) const
{
return m_boxes[ box ].wrongWordBox()->boxName();
}
-const QString& LeitnerSystem::correctBox( QString& box )
+QString LeitnerSystem::correctBox( const QString& box ) const
{
return boxWithName( box )->correctWordBox()->boxName();
}
-const QString& LeitnerSystem::wrongBox( QString& box )
+QString LeitnerSystem::wrongBox( const QString& box ) const
{
return boxWithName( box )->wrongWordBox()->boxName();
}
-int LeitnerSystem::wrongBoxNumber( int box )
+int LeitnerSystem::wrongBoxNumber( int box ) const
{
return number( m_boxes[ box ].wrongWordBox() );
}
-int LeitnerSystem::correctBoxNumber( int box )
+int LeitnerSystem::correctBoxNumber( int box ) const
{
return number( m_boxes[ box ].correctWordBox() );
}
m_systemName = name;
}
-int LeitnerSystem::number( LeitnerBox* box ) const
+int LeitnerSystem::number( const LeitnerBox* box ) const
{
if( box == 0 )
return -1;
boxWithName( box )->setWrongWordBox( boxWithName( wrongWordBox ) );
}
-const QString& LeitnerSystem::box( int i ) const
+QString LeitnerSystem::box( int i ) const
{
- return m_boxes[ i ].boxName();
+ return m_boxes.at( i ).boxName();
}
void LeitnerSystem::setBoxVocabCount( QString& box, int vocabCount )
return boxWithName( box )->vocabCount();
}
-void LeitnerSystem::incrementBoxVocabCount( QString& box )
+void LeitnerSystem::incrementBoxVocabCount( const QString& box )
{
int tmp = boxWithName( box )->vocabCount();
boxWithName( box )->setVocabCount( tmp++ );
}
-void LeitnerSystem::decrementBoxVocabCount( QString& box )
+void LeitnerSystem::decrementBoxVocabCount( const QString& box )
{
int tmp = boxWithName( box )->vocabCount();
boxWithName( box )->setVocabCount( tmp-- );
{
public:
/**Constructor without arguments*/
- LeitnerSystem();
+ explicit LeitnerSystem();
/**Constructor with arguments
* @param boxes reference to a QList of LeitnerBox
/**Returns the LeitnerSystem's name
* @return the LeitnerSystem's name as reference to QString
*/
- QString& systemName();
+ QString systemName() const;
/**Sets the LeitnerSystem's name
*
*/
LeitnerBox* boxWithNumber( int number );
+ const LeitnerBox* boxWithNumber( int number ) const;
+
/**Returns a LeitnerBox by name
* @param name the name of the LeitnerBox to be returned
* @return a pointer to the LeitnerBox with the name,
*/
LeitnerBox* boxWithName( const QString& name );
+ const LeitnerBox* boxWithName( const QString& name ) const;
+
/**Returns the number of the given LeitnerBox
* @param box a pointer to the LeitnerBox
* @return the number of the given LeitnerBox
*/
- int number( LeitnerBox* box ) const;
+ int number( const LeitnerBox* box ) const;
/**Returns the name of the LeitnerBox with number @p i
* @param i the LeitnerBox's number
* @return the name of the LeitnerBox with number @p i
*/
- const QString& box( int i ) const;
+ QString box( int i ) const;
/**Returns the LeitnerBox following @p previousBox
* @param previousBox the name of the LeitnerBox
* @return the name of the LeitnerBox following previousBox
*/
- QString nextBox( QString& previousBox );
+ QString nextBox( const QString& previousBox );
- 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 );
+ /**Returns the correct word box of "int box"
+ */
+ QString correctBox( int box ) const;
+ /**Returns the wrong word box of "int box"
+ */
+ QString wrongBox( int box ) const;
+ QString correctBox( const QString& box ) const;
+ QString wrongBox( const QString& box ) const;
- int wrongBoxNumber( int box );
- int correctBoxNumber( int box );
+ int wrongBoxNumber( int box ) const;
+ int correctBoxNumber( int box ) const;
void setCorrectBox( const QString& box, const QString& correctWordBox );
void setWrongBox( const QString& box, const QString& wrongWordBox );
void setBoxVocabCount( QString& box, int vocabCount );
int boxVocabCount( QString& box );
- void incrementBoxVocabCount( QString& box );
- void decrementBoxVocabCount( QString& box );
+ void incrementBoxVocabCount( const QString& box );
+ void decrementBoxVocabCount( const QString& box );
//inserts a box with number, name, correct and wrong word box
bool insertBox( const QString& name, int correctWordBox, int wrongWordBox );