keduvocvokabelnreader.cpp
keduvocwqlreader.cpp
keduvocxdxfreader.cpp
- leitnerbox.cpp
- leitnersystem.cpp
- leitnersystemview.cpp
- sharedkvtmlfiles.cpp
- prefleitner.cpp )
-
-
-kde4_add_ui_files(keduvocdocument_LIB_SRCS
- prefleitnerbase.ui
-)
+ sharedkvtmlfiles.cpp )
kde4_add_library(keduvocdocument SHARED ${keduvocdocument_LIB_SRCS})
keduvocmultiplechoice.h
keduvoctranslation.h
keduvocwordtype.h
- leitnerbox.h
- leitnersystem.h
- leitnersystemview.h
sharedkvtmlfiles.h
- prefleitner.h DESTINATION ${INCLUDE_INSTALL_DIR}/libkdeedu
+ DESTINATION ${INCLUDE_INSTALL_DIR}/libkdeedu
)
#include "keduvocpaukerreader.h"
#include "keduvocvokabelnreader.h"
#include "keduvocxdxfreader.h"
-#include "leitnersystem.h"
#define WQL_IDENT "WordQuiz"
QList<KEduVocLesson> m_lessons;
KEduVocWordType m_wordTypes;
-
- LeitnerSystem* m_leitnerSystem;
- bool m_activeLeitnerSystem;
};
KEduVocDocument::KEduVocDocumentPrivate::~KEduVocDocumentPrivate()
m_version = "";
m_generator = "";
m_csvDelimiter = QString( '\t' );
- m_activeLeitnerSystem = false;
- m_leitnerSystem = NULL;
}
}
-bool KEduVocDocument::leitnerSystemActive() const
-{
- return d->m_activeLeitnerSystem;
-}
-
-void KEduVocDocument::setLeitnerSystemActive( bool yes )
-{
- if ( yes ) {
- if ( d->m_leitnerSystem == 0 )
- createStandardLeitnerSystem(); //if nothing is loaded yet
-
- d->m_activeLeitnerSystem = true;
- } else if ( !yes )
- d->m_activeLeitnerSystem = false;
-}
-
-void KEduVocDocument::createStandardLeitnerSystem()
-{
- LeitnerSystem* tmpSystem = new LeitnerSystem();
- QString name = "Standard";
-
- tmpSystem->setSystemName( name );
- tmpSystem->insertBox( "Box 1" );
- tmpSystem->insertBox( "Box 2" );
- tmpSystem->insertBox( "Box 3" );
- tmpSystem->insertBox( "Box 4" );
- tmpSystem->insertBox( "Box 5" );
-
- tmpSystem->setCorrectBox( "Box 1", "Box 2" );
- tmpSystem->setWrongBox( "Box 1", "Box 1" );
-
- tmpSystem->setCorrectBox( "Box 2", "Box 3" );
- tmpSystem->setWrongBox( "Box 2", "Box 1" );
-
- tmpSystem->setCorrectBox( "Box 3", "Box 4" );
- tmpSystem->setWrongBox( "Box 3", "Box 1" );
-
- tmpSystem->setCorrectBox( "Box 4", "Box 5" );
- tmpSystem->setWrongBox( "Box 4", "Box 1" );
-
- tmpSystem->setCorrectBox( "Box 5", "Box 1" );
- tmpSystem->setWrongBox( "Box 5", "Box 1" );
-
- d->m_leitnerSystem = tmpSystem;
-}
-
-void KEduVocDocument::setLeitnerSystem( LeitnerSystem* system )
-{
- d->m_leitnerSystem = system;
-}
-
-LeitnerSystem* KEduVocDocument::leitnerSystem()
-{
- return d->m_leitnerSystem;
-}
-
-
int KEduVocDocument::entryCount() const
{
return d->m_vocabulary.count();
class QStringList;
class KEduVocExpression;
class KEduVocLesson;
-class LeitnerSystem;
class KEduVocWordType;
/**
*/
void setCsvDelimiter( const QString &delimiter );
- bool leitnerSystemActive() const;
- void setLeitnerSystemActive( bool yes );
- void createStandardLeitnerSystem();
- void setLeitnerSystem( LeitnerSystem* system );
- LeitnerSystem* leitnerSystem();
-
static FileType detectFileType( const QString &fileName );
/**
KEduVocExpression* q;
- QString m_leitnerBox;
int m_sortIndex;
int m_lesson;
bool m_active;
{
return
m_translations == p.m_translations &&
- m_leitnerBox == p.m_leitnerBox &&
m_lesson == p.m_lesson &&
m_sortIndex == p.m_sortIndex &&
m_active == p.m_active;
d->m_lesson = l;
}
-QString KEduVocExpression::leitnerBox() const
-{
- return d->m_leitnerBox;
-}
-
-
-void KEduVocExpression::setLeitnerBox( const QString& box )
-{
- d->m_leitnerBox = box;
-}
-
bool KEduVocExpression::isActive() const
{
QList<int> translationIndices() const;
- /** sets the box of the Leitner system which actually contains the expression
- *
- * @param box the box's name
- */
- void setLeitnerBox( const QString & box );
-
- /** returns the name of the Leitner system's box actually containing the expression
- *
- * @return the box's name
- */
- QString leitnerBox() const;
-
KEduVocExpression& operator= ( const KEduVocExpression &expression );
bool operator== ( const KEduVocExpression &expression ) const;
+++ /dev/null
-/***************************************************************************
- * Copyright (C) 2005 by Martin Pfeiffer <hubipete@gmx.net> *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
- ***************************************************************************/
-
-#include "leitnerbox.h"
-
-LeitnerBox::LeitnerBox()
-{}
-
-
-LeitnerBox::~LeitnerBox()
-{}
-
-int LeitnerBox::vocabCount() const
-{
- return m_vocabCount;
-}
-
-void LeitnerBox::setVocabCount( int count )
-{
- m_vocabCount = count;
-}
-
-const QString& LeitnerBox::boxName() const
-{
- return m_name;
-}
-
-LeitnerBox* LeitnerBox::correctWordBox()
-{
- 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;
-}
-
-void LeitnerBox::setCorrectWordBox( LeitnerBox* correctWordBox )
-{
- m_correctWordBox = correctWordBox;
-}
-
-void LeitnerBox::setWrongWordBox( LeitnerBox* wrongWordBox )
-{
- m_wrongWordBox = wrongWordBox;
-}
-
-bool LeitnerBox::operator == ( const LeitnerBox& a ) const
-{
- if ( a.boxName() == boxName() )
- return true;
- else
- return false;
-}
+++ /dev/null
-/***************************************************************************
- * Copyright (C) 2005 by Martin Pfeiffer <hubipete@gmx.net> *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
- ***************************************************************************/
-
-#ifndef LEITNERBOX_H
-#define LEITNERBOX_H
-
-#include "libkeduvocdocument_export.h"
-
-#include <QtCore/QString>
-
-/**
- * A box in a LeitnerSystem - a LeitnerBox
- *
- * This box has a name and a certain number of vocabulars in it. This number changes continuosly
- * as the vocab cards increase or decrease in box position. There is a determined order of LeitnerBoxes
- * in a LeitnerSystem, therefore each LeitnerBox helds pointers to the LeitnerBox for wrong and correct
- * cards of this LeitnerBox
- * @author Martin Pfeiffer <hubipete@gmx.net>
- */
-class KEDUVOCDOCUMENT_EXPORT LeitnerBox
-{
-public:
- /**
- * The constructor
- */
- explicit LeitnerBox();
-
- /**
- * The destructor
- */
- ~LeitnerBox();
-
- /**
- * Sets the LeitnerBox's pointer to the correct word LeitnerBox
- * @param correctWordBox a pointer to the LeitnerBox to be set
- */
- void setCorrectWordBox( LeitnerBox* correctWordBox );
-
- /**
- * Sets the LeitnerBox's pointer to the wrong word LeitnerBox
- * @param wrongWordBox a pointer to the LeitnerBox to be set
- */
- void setWrongWordBox( LeitnerBox* wrongWordBox );
-
-
- /**
- * Sets the LeitnerBox's name to name. The name is the unique identifier of a LeitnerBox.
- * @param name a QString with the LeitnerBox's new name
- */
- void setBoxName( const QString& name );
-
- /**
- * Returns the current name of the LeitnerBox
- * @return a const QString with the name of the LeitnerBox
- */
- const QString& boxName() const;
-
- /**
- * Sets the LeitnerBox's vocabCount to count
- * @param count the new vocabCount to be set
- */
- void setVocabCount( int count );
-
- /**
- * Returns the current vocabCount
- * @return the number of cards/ vocabs that are currently assigned to the LeitnerBox.
- */
- int vocabCount() const;
-
- /**
- * Returns a pointer to the LeitnerBox correct cards of this LeitnerBox here are assigned to
- * @return a pointer to a LeitnerBox
- */
- 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:
- QString m_name;
- int m_vocabCount;
- LeitnerBox* m_wrongWordBox;
- LeitnerBox* m_correctWordBox;
-};
-
-#endif
+++ /dev/null
-/***************************************************************************
- * Copyright (C) 2005 by Martin Pfeiffer <hubipete@gmx.net> *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
- ***************************************************************************/
-
-#include "leitnersystem.h"
-
-#include <kdebug.h>
-
-LeitnerSystem::LeitnerSystem( const QList<LeitnerBox> &boxes, const QString &name )
-{
- if ( !boxes.empty() )
- m_boxes = boxes;
-
- if ( name.isNull() )
- m_systemName = name;
-}
-
-LeitnerSystem::LeitnerSystem()
-{}
-
-LeitnerSystem::~LeitnerSystem()
-{}
-
-QStringList LeitnerSystem::getBoxNameList()
-{
- QStringList boxNameList;
-
- foreach( const LeitnerBox &box, m_boxes )
- boxNameList.append( box.boxName() );
-
- return boxNameList;
-}
-
-int LeitnerSystem::getNumberOfBoxes() const
-{
- return m_boxes.count();
-}
-
-LeitnerBox* LeitnerSystem::boxWithNumber( int number )
-{
- 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;
- it = m_boxes.begin();
- it2 = m_boxes.end();
- for ( ; it != it2; ++it ) {
- if (( *it ).boxName() == name )
- return & ( *it );
- }
-
- return 0;
-}
-
-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( const QString& previousBox )
-{
- Q_UNUSED( previousBox )
- for ( int i = 0; i < m_boxes.count(); i++ ) {
- if ( m_boxes[i].vocabCount() > 0 )
- return box( i );
- }
-
- return QString();
-}
-
-QString LeitnerSystem::correctBox( int box ) const
-{
- return m_boxes[ box ].correctWordBox()->boxName();
-}
-
-QString LeitnerSystem::wrongBox( int box ) const
-{
- return m_boxes[ box ].wrongWordBox()->boxName();
-}
-
-QString LeitnerSystem::correctBox( const QString& box ) const
-{
- return boxWithName( box )->correctWordBox()->boxName();
-}
-
-QString LeitnerSystem::wrongBox( const QString& box ) const
-{
- return boxWithName( box )->wrongWordBox()->boxName();
-}
-
-int LeitnerSystem::wrongBoxNumber( int box ) const
-{
- return number( m_boxes[ box ].wrongWordBox() );
-}
-
-int LeitnerSystem::correctBoxNumber( int box ) const
-{
- return number( m_boxes[ box ].correctWordBox() );
-}
-
-void LeitnerSystem::deleteBox( int box )
-{
- m_boxes.removeAt( box );
-}
-
-void LeitnerSystem::deleteBox( LeitnerBox* box )
-{
- for ( int i = 0; i < m_boxes.count(); i++ ) {
- if ( m_boxes[i].correctWordBox() == box )
- m_boxes[i].setCorrectWordBox( 0 );
-
- if ( m_boxes[i].wrongWordBox() == box )
- m_boxes[i].setWrongWordBox( 0 );
- }
-
- m_boxes.removeAll( *box );
-}
-
-bool LeitnerSystem::insertBox( const QString& name, int correctWordBox, int wrongWordBox )
-{
- if ( getBoxNameList().contains( name ) != 0 )
- return false;
-
- LeitnerBox tmpBox;
- tmpBox.setBoxName( name );
- tmpBox.setCorrectWordBox( boxWithNumber( correctWordBox ) );
- tmpBox.setWrongWordBox( boxWithNumber( wrongWordBox ) );
-
- m_boxes.append( tmpBox );
- return true;
-}
-
-void LeitnerSystem::setSystemName( const QString& name )
-{
- m_systemName = name;
-}
-
-int LeitnerSystem::number( const LeitnerBox* box ) const
-{
- if ( box == 0 )
- return -1;
-
- return m_boxes.indexOf( *box );
-}
-
-bool LeitnerSystem::setBoxName( int box, const QString& name )
-{
- if ( boxWithName( name ) == 0 || boxWithName( name ) == boxWithNumber( box ) ) {
- boxWithNumber( box )->setBoxName( name );
-
- return true;
- } else
- return false;
-}
-
-bool LeitnerSystem::setBoxName( LeitnerBox* box, const QString& name )
-{
- if ( boxWithName( name ) == 0 || boxWithName( name ) == box ) {
- box->setBoxName( name );
-
- return true;
- } else
- return false;
-}
-
-bool LeitnerSystem::insertBox( const QString& name )
-{
- 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 )
-{
- boxWithName( box )->setCorrectWordBox( boxWithName( correctWordBox ) );
-}
-
-void LeitnerSystem::setWrongBox( const QString& box, const QString& wrongWordBox )
-{
- boxWithName( box )->setWrongWordBox( boxWithName( wrongWordBox ) );
-}
-
-QString LeitnerSystem::box( int i ) const
-{
- return m_boxes.at( i ).boxName();
-}
-
-void LeitnerSystem::setBoxVocabCount( QString& box, int vocabCount )
-{
- boxWithName( box )->setVocabCount( vocabCount );
-}
-
-int LeitnerSystem::boxVocabCount( QString& box ) const
-{
- return boxWithName( box )->vocabCount();
-}
-
-void LeitnerSystem::incrementBoxVocabCount( const QString& box )
-{
- int tmp = boxWithName( box )->vocabCount();
- boxWithName( box )->setVocabCount( tmp++ );
-}
-
-void LeitnerSystem::decrementBoxVocabCount( const QString& box )
-{
- int tmp = boxWithName( box )->vocabCount();
- boxWithName( box )->setVocabCount( tmp-- );
-}
-
+++ /dev/null
-/***************************************************************************
- * Copyright (C) 2005 by Martin Pfeiffer <hubipete@gmx.net> *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
- ***************************************************************************/
-
-#ifndef LEITNERSYSTEM_H
-#define LEITNERSYSTEM_H
-
-#include "libkeduvocdocument_export.h"
-
-#include <QtCore/QStringList>
-
-#include "leitnerbox.h"
-
-/**
-@author Martin Pfeiffer
-*/
-
-class KEDUVOCDOCUMENT_EXPORT LeitnerSystem
-{
-public:
- /**Constructor without arguments*/
- explicit LeitnerSystem();
-
- /**Constructor with arguments
- * @param boxes reference to a QList of LeitnerBox
- * @param name the new LeitnerSystems name
- */
- LeitnerSystem( const QList<LeitnerBox> &boxes, const QString &name );
-
- /**Destructor*/
- ~LeitnerSystem();
-
- /**Returns the number of LeitnerBoxes contained by this LeitnerSystem
- * @return the number of LeitnerBoxes as integer
- */
- int getNumberOfBoxes() const;
-
- /**Returns a QStringList with all the LeitnerBoxes' names
- * @return a QStringList with all names
- */
- QStringList getBoxNameList();
-
- /**Returns the LeitnerSystem's name
- * @return the LeitnerSystem's name as reference to QString
- */
- QString systemName() const;
-
- /**Sets the LeitnerSystem's name
- *
- * @param name the new name as QString
- */
- void setSystemName( const QString& name );
-
- /**Returns a LeitnerBox by number
- * @param number the number of the LeitnerBox to be returned
- * @return a pointer to the LeitnerBox with the number
- */
- 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,
- * or 0 if no such box exists.
- */
- 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( 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
- */
- 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( const QString& previousBox );
-
- /**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 ) const;
- int correctBoxNumber( int box ) const;
-
- 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 boxVocabCount( QString& box ) const;
-
- 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 );
- bool insertBox( const QString& name );
- void deleteBox( int box );
- void deleteBox( LeitnerBox* box );
-
-private:
- QString m_systemName; //the systems name
-
- QList<LeitnerBox> m_boxes;
-};
-
-#endif
+++ /dev/null
-/***************************************************************************
- * Copyright (C) 2005 by Martin Pfeiffer <hubipete@gmx.net> *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
- ***************************************************************************/
-
-#include "leitnersystemview.h"
-
-#include "leitnersystem.h"
-
-#include <QPainter>
-#include <QMouseEvent>
-
-#include <kdebug.h>
-
-class LeitnerSystemView::LeitnerSystemViewPrivate
-{
-public:
- LeitnerSystemViewPrivate( LeitnerSystemView* qq )
- : q( qq ), m_highlightedBox( -1 )
- {}
-
- LeitnerSystemView *q;
-
- LeitnerSystem* m_leitnerSystem; //the system which is shown
-
- void drawSystem( QPainter* ); //paints the boxes
- void drawConnections( QPainter* ); //paints the arrows between the boxes
- void calculateSize();
-
- int m_imageY; //high border of the images
- int m_distPixmap;
- int m_highlightedBox; //the box which is currently highlighted
-};
-
-
-LeitnerSystemView::LeitnerSystemView( QWidget* parent )
- : QWidget( parent ), d( new LeitnerSystemViewPrivate( this ) )
-{}
-
-
-LeitnerSystemView::~LeitnerSystemView()
-{
- delete d;
-}
-
-void LeitnerSystemView::LeitnerSystemViewPrivate::drawSystem( QPainter* p )
-{
- m_imageY = q->height() / 2 - 32;
-
- //draw the boxes' icons
- for ( int i = 0; i < m_leitnerSystem->getNumberOfBoxes(); i++ ) {
- if ( i == m_highlightedBox ) {
- //p->drawPixmap(12 + i * 64 + i*10, m_imageY, KGlobal::iconLoader()->loadIcon("leitnerbox", KIconLoader::Panel));
- p->drawRect( 12 + i * 64 + i*10, m_imageY,64,64 );
- p->fillRect( 12 + i * 64 + i*10, m_imageY,64,64, QBrush( Qt::red ) );
- } else { //for each box 74 = 64(pixmap) + 10(distance between two boxes)
- //p->drawPixmap(12 + i * 74, m_imageY, KGlobal::iconLoader()->loadIcon("leitnerbox", KIconLoader::Panel));
- p->drawRect( 12 + i * 64 + i*10, m_imageY,64,64 );
- }
- }
-}
-
-void LeitnerSystemView::LeitnerSystemViewPrivate::drawConnections( QPainter* p )
-{
- //dist = number of boxes that are in between the two boxes
- //width = width of the rect for the arc
- int dist, width = 0;
- int numberOfBoxes = m_leitnerSystem->getNumberOfBoxes();
-
- p->setPen( QPen( Qt::green, 2 ) );
-
- //paint the connections for the correct word boxes, above the boxes
- for ( int i = 0; i < numberOfBoxes; i++ ) {
- if ( m_leitnerSystem->correctBoxNumber( i ) != -1 ) {
- 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;
-
- 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( Qt::red, 2 ) );
-
- for ( int i = 0; i < numberOfBoxes; i++ ) {
- if ( m_leitnerSystem->wrongBoxNumber( i ) != -1 ) {
- dist = m_leitnerSystem->wrongBoxNumber( 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 )
-{
- d->m_leitnerSystem = leitnersystem;
-
- //calculate the new sizes
- d->calculateSize();
- update();
-}
-
-void LeitnerSystemView::highlightBox( int box )
-{
- d->m_highlightedBox = box;
- update();
-}
-
-void LeitnerSystemView::paintEvent( QPaintEvent* )
-{
- QPainter p( this );
- p.eraseRect( 0, 0, width(), height() );
-
- d->drawSystem( &p );
-
- d->drawConnections( &p );
-}
-
-void LeitnerSystemView::LeitnerSystemViewPrivate::calculateSize()
-{
- //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;
- height = 0;
-
- for ( int i = 0; i < numberOfBoxes; i++ ) {
- if ( m_leitnerSystem->correctBoxNumber( i ) != -1 ) {
- dist = m_leitnerSystem->correctBoxNumber( i ) - i;
-
- if ( abs( dist ) >= abs( tmpMaxC ) )
- tmpMaxC = dist;
- }
-
- if ( m_leitnerSystem->wrongBoxNumber( i ) != -1 ) {
- dist = m_leitnerSystem->wrongBoxNumber( i ) - i;
-
- 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;
-
- if ( tmpMaxW <= 0 )
- height += (( abs( tmpMaxW ) -1 ) *64 + abs( tmpMaxW ) *10 + 2*22 + 2*21 ) /3;
- else
- height += (( tmpMaxW-1 ) *64 + tmpMaxW*10 + 2*21 ) /3;
-
- height += 24+64;
-
-// resizeContents( numberOfBoxes * 64 + (numberOfBoxes - 1)*10 + 2 * 12, height );
- q->setMinimumSize( numberOfBoxes * 64 + ( numberOfBoxes - 1 ) *10 + 2 * 12, height );
-}
-
-void LeitnerSystemView::mousePressEvent( QMouseEvent* e )
-{
- kDebug() << "mouseClick";
- //if the user has clicked into a box
- if ( e->y() > d->m_imageY && e->y() < d->m_imageY + 64 && e->x() < width() ) {
- int dd = ( e->x()-12 ) /74;
-
- if (( e->x()-12-74*dd ) <= 64 ) {
- //signal for prefLeitner to set the comboboxes to the clicked box
- emit boxClicked( dd );
- d->m_highlightedBox = dd;
-
- update();
- }
- }
-}
-
-#include "leitnersystemview.moc"
-
+++ /dev/null
-/***************************************************************************
- * Copyright (C) 2005 by Martin Pfeiffer <hubipete@gmx.net> *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
- ***************************************************************************/
-
-#ifndef LEITNERSYSTEMVIEW_H
-#define LEITNERSYSTEMVIEW_H
-
-#include "libkeduvocdocument_export.h"
-
-#include <QtGui/QWidget>
-
-class LeitnerSystem;
-
-/**
- * This class displays a given LeitnerSystem on a QWidget
- * It is used to configurate a LeitnerSystem and easily remove
- * and add boxes within a GUI.
- * @author Martin Pfeiffer
- */
-class KEDUVOCDOCUMENT_EXPORT LeitnerSystemView : public QWidget
-{
- Q_OBJECT
-
-public:
- /**
- * The public constructor
- * @param parent the QWidget that is the parent widget
- */
- explicit LeitnerSystemView( QWidget* parent = 0 );
-
- ~LeitnerSystemView();
-
- /**
- * Sets the LeitnerSystem to be displayed in the LeitnerSystemView
- * @param system the LeitnerSystem to be displayed
- */
- void setSystem( LeitnerSystem* system );
-
- /**
- * Highlight a special box to indicate that this one is selected
- * @param box the number of the box to be highlighted
- */
- void highlightBox( int box );
-
-Q_SIGNALS:
- void boxClicked( int box ); //is emitted if the user clicks on a box
-
-protected:
- virtual void paintEvent( QPaintEvent* );
-// virtual void drawContents(QPainter* p, int clipx, int clipy, int clipw, int cliph);
- virtual void mousePressEvent( QMouseEvent* e );
-
-private:
- class LeitnerSystemViewPrivate;
- LeitnerSystemViewPrivate* const d;
-
- Q_DISABLE_COPY( LeitnerSystemView )
-};
-
-#endif
+++ /dev/null
-/***************************************************************************
- * Copyright (C) 2005 by Martin Pfeiffer <hubipete@gmx.net> *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
- ***************************************************************************/
-
-#include "prefleitner.h"
-
-#include "leitnersystemview.h"
-#include "leitnersystem.h"
-#include "ui_prefleitnerbase.h"
-
-#include <QLayout>
-#include <QComboBox>
-#include <QLineEdit>
-#include <QPushButton>
-#include <QScrollArea>
-
-#include <kdebug.h>
-
-class PrefLeitner::PrefLeitnerPrivate
-{
-public:
- PrefLeitnerPrivate( PrefLeitner* qq, LeitnerSystem* system )
- : q( qq ), m_leitnerSystemView( 0 ), m_selectedSystem( system ),
- m_selectedBox( 0 )
- {
- init();
- }
-
- PrefLeitner* q;
-
- LeitnerSystemView* m_leitnerSystemView; //the LeitnerSystemView which shows the selected system
- LeitnerSystem* m_selectedSystem; //the currently selected system to be changed
- LeitnerBox* m_selectedBox; //the currently selected box
-
- Ui::PrefLeitnerBase m_ui;
-
- void init();
-
- void refreshSystemView(); //refresh the LeitnerSystemView
- void newSystem();
-
- // slots
- // catches the signal from the view if user clicks on a box
- void slotBoxClicked( int );
-};
-
-
-PrefLeitner::PrefLeitner( QWidget* parent )
- : QDialog( parent ), d( new PrefLeitnerPrivate( this, 0 ) )
-{}
-
-PrefLeitner::PrefLeitner( LeitnerSystem* system, QWidget* parent )
- : QDialog( parent ), d( new PrefLeitnerPrivate( this, system ) )
-{}
-
-PrefLeitner::~PrefLeitner()
-{
- delete d;
-}
-
-void PrefLeitner::PrefLeitnerPrivate::init()
-{
- m_ui.setupUi( q );
-
- QScrollArea *helperSV = new QScrollArea( q );
-
- m_leitnerSystemView = new LeitnerSystemView( helperSV->viewport() );
- m_leitnerSystemView->setObjectName( "LeitnerSystemView" );
-
- helperSV->setWidget( m_leitnerSystemView );
-
- connect( m_leitnerSystemView, SIGNAL( boxClicked( int ) ), q, SLOT( slotBoxClicked( int ) ) );
-
- if ( m_selectedSystem ) {
- //insert the list of box' names in the comboboxes
- m_ui.cmbWrong->addItems( m_selectedSystem->getBoxNameList() );
- m_ui.cmbCorrect->addItems( m_selectedSystem->getBoxNameList() );
-
- //show leitnersystem
- m_leitnerSystemView->setSystem( m_selectedSystem );
- }
-}
-
-void PrefLeitner::slotCorrectWord( const QString& newBox )
-{
- if ( d->m_selectedBox == 0 )
- return;
-
- //when the correct word box was changed in the combobox
- d->m_selectedBox->setCorrectWordBox( d->m_selectedSystem->boxWithName( newBox ) );
- d->refreshSystemView();
-}
-
-void PrefLeitner::slotWrongWord( const QString& newBox )
-{
- if ( d->m_selectedBox == 0 )
- return;
-
- //when the wrong word box was changed in the combobox
- d->m_selectedBox->setWrongWordBox( d->m_selectedSystem->boxWithName( newBox ) );
- d->refreshSystemView();
-}
-
-void PrefLeitner::slotBoxName( const QString& newName )
-{
- if ( d->m_selectedBox == 0 )
- return;
-
- //when the boxes name was changed
- d->m_selectedSystem->setBoxName( d->m_selectedBox, newName );
-}
-
-void PrefLeitner::PrefLeitnerPrivate::newSystem()
-{
- m_ui.cmbCorrect->addItems( m_selectedSystem->getBoxNameList() );
- m_ui.cmbWrong->addItems( m_selectedSystem->getBoxNameList() );
-
- refreshSystemView();
-}
-
-void PrefLeitner::PrefLeitnerPrivate::refreshSystemView()
-{
- m_leitnerSystemView->setSystem( m_selectedSystem );
-}
-
-void PrefLeitner::PrefLeitnerPrivate::slotBoxClicked( int box )
-{
- m_selectedBox = m_selectedSystem->boxWithNumber( box );
-
- m_ui.cmbCorrect->setCurrentIndex( m_selectedSystem->correctBoxNumber( box ) );
- m_ui.cmbWrong->setCurrentIndex( m_selectedSystem->wrongBoxNumber( box ) );
- m_ui.lndBoxName->setText( m_selectedBox->boxName() );
-}
-
-void PrefLeitner::slotAddBox()
-{
- d->m_selectedSystem->insertBox( "New Box", 1, 1 );
- d->refreshSystemView();
-}
-
-void PrefLeitner::slotDeleteBox()
-{
- d->m_selectedSystem->deleteBox( d->m_selectedBox );
- d->m_selectedBox = 0;
-
- d->refreshSystemView();
-}
-
-void PrefLeitner::slotApply()
-{
- setResult( QDialog::Accepted );
- close();
-}
-
-void PrefLeitner::slotDiscard()
-{
- setResult( QDialog::Rejected );
- close();
-}
-
-LeitnerSystem* PrefLeitner::system()
-{
- return d->m_selectedSystem;
-}
-
-#include "prefleitner.moc"
+++ /dev/null
-#ifndef PREFLEITNER_H
-#define PREFLEITNER_H
-
-/***************************************************************************
- * Copyright (C) 2005 by Martin Pfeiffer *
- * hubipete@gmx.net *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
- **************************************************************************/
-
-#include "libkeduvocdocument_export.h"
-
-#include <QtGui/QDialog>
-
-class LeitnerSystem;
-
-/**
- * This class is a dialog for configuring a LeitnerSystem
- * @author Martin Pfeiffer <hubipete@gmx.net>
- */
-class KEDUVOCDOCUMENT_EXPORT PrefLeitner : public QDialog
-{
- Q_OBJECT
-
-public:
- /**
- * The public contructor
- * @param parent the widget's parent
- */
- explicit PrefLeitner( QWidget* parent = 0 );
-
- /**
- * The public contructur which sets also the LeitnerSystem
- * @param parent is the parent widget
- * @param system a pointer to the LeitnerSystem to configure
- */
- explicit PrefLeitner( LeitnerSystem* system, QWidget* parent = 0 );
-
- /**
- * The public destructor
- */
- ~PrefLeitner();
-
- /**
- * Sets the LeitnerSystem for the dialog
- * @param system a pointer to the LeitnerSystem to configure
- */
- void setLeitnerSystem( LeitnerSystem* system );
-
- /**
- * Get the LeitnerSystem that is set to the dialog
- * @return a pointer to the actual set LeitnerSystem
- */
- LeitnerSystem* system();
-
-public Q_SLOTS:
- void slotCorrectWord( const QString& newBox );
- void slotWrongWord( const QString& newBox );
- void slotBoxName( const QString& newName );
- void slotAddBox();
- void slotDeleteBox();
- void slotDiscard();
- void slotApply();
-
-private:
- class PrefLeitnerPrivate;
- PrefLeitnerPrivate* const d;
-
- Q_DISABLE_COPY( PrefLeitner )
- Q_PRIVATE_SLOT( d, void slotBoxClicked( int ) )
-};
-
-#endif //PREFLEITNER_H
+++ /dev/null
-<ui version="4.0" >
- <author></author>
- <comment></comment>
- <exportmacro></exportmacro>
- <class>PrefLeitnerBase</class>
- <widget class="QDialog" name="PrefLeitnerBase" >
- <property name="geometry" >
- <rect>
- <x>0</x>
- <y>0</y>
- <width>770</width>
- <height>458</height>
- </rect>
- </property>
- <property name="windowTitle" >
- <string>Leitner System</string>
- </property>
- <layout class="QGridLayout" >
- <property name="margin" >
- <number>10</number>
- </property>
- <property name="spacing" >
- <number>6</number>
- </property>
- <item row="0" column="0" >
- <layout class="QGridLayout" >
- <property name="margin" >
- <number>0</number>
- </property>
- <property name="spacing" >
- <number>6</number>
- </property>
- <item row="3" column="3" >
- <widget class="QPushButton" name="btnApply" >
- <property name="text" >
- <string>Appl&y Changes</string>
- </property>
- </widget>
- </item>
- <item row="3" column="0" colspan="2" >
- <spacer>
- <property name="orientation" >
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeType" >
- <enum>QSizePolicy::Expanding</enum>
- </property>
- <property name="sizeHint" >
- <size>
- <width>421</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- <item rowspan="3" row="0" column="1" >
- <layout class="QGridLayout" >
- <property name="margin" >
- <number>0</number>
- </property>
- <property name="spacing" >
- <number>6</number>
- </property>
- <item row="1" column="0" >
- <widget class="QLineEdit" name="lndBoxName" />
- </item>
- <item row="0" column="0" >
- <widget class="QLabel" name="lblBoxName" >
- <property name="text" >
- <string>Edit box name:</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item row="3" column="2" >
- <widget class="QPushButton" name="btnDiscard" >
- <property name="text" >
- <string>Disc&ard Changes</string>
- </property>
- </widget>
- </item>
- <item row="1" column="0" >
- <widget class="QPushButton" name="btnAddBox" >
- <property name="text" >
- <string>Add a bo&x</string>
- </property>
- </widget>
- </item>
- <item row="2" column="0" >
- <widget class="QPushButton" name="btnDeleteBox" >
- <property name="text" >
- <string>Delete selected &box</string>
- </property>
- </widget>
- </item>
- <item rowspan="3" row="0" column="2" colspan="2" >
- <layout class="QGridLayout" >
- <property name="margin" >
- <number>0</number>
- </property>
- <property name="spacing" >
- <number>6</number>
- </property>
- <item row="0" column="0" >
- <widget class="QLabel" name="lblCorrect" >
- <property name="text" >
- <string>Correct words to:</string>
- </property>
- </widget>
- </item>
- <item row="0" column="1" >
- <widget class="QComboBox" name="cmbCorrect" />
- </item>
- <item row="1" column="0" >
- <widget class="QLabel" name="lblWrong" >
- <property name="text" >
- <string>Wrong words to:</string>
- </property>
- </widget>
- </item>
- <item row="1" column="1" >
- <widget class="QComboBox" name="cmbWrong" />
- </item>
- </layout>
- </item>
- <item row="0" column="0" >
- <spacer>
- <property name="orientation" >
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeType" >
- <enum>QSizePolicy::Expanding</enum>
- </property>
- <property name="sizeHint" >
- <size>
- <width>252</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
- </item>
- </layout>
- </widget>
- <layoutdefault spacing="6" margin="11" />
- <pixmapfunction>qPixmapFromMimeSource</pixmapfunction>
- <resources/>
- <connections/>
-</ui>