From: Frederik Gladhorn Date: Fri, 19 Oct 2007 12:50:33 +0000 (+0000) Subject: In agreement with Peter I removed the leitner system implementation from libkdeedu. X-Git-Tag: v3.95.0~6 X-Git-Url: https://git.rmz.fi/?a=commitdiff_plain;h=42fd3be5cdf0de83b1eb1fe1b9f0c242f91391d0;p=libqmvoc.git In agreement with Peter I removed the leitner system implementation from libkdeedu. - It was never completed - It was used in none of our apps, only KWQ had some unfinished functions for it This does not solve the Leitner implementation problem. My current plan: * Have a Leitner implementation in KDE 4.1 * Use the lesson class as leitner boxes - since kvtml2 entries can be in multiple lessons, no need to reinvent the wheel - have svg boxes to display the current state if possible Details are still to be decided and this is just an idea. KWordQuiz and Parley should share the implementation. CCMAIL: peter@peterandlinda.com svn path=/trunk/KDE/kdeedu/libkdeedu/; revision=727005 --- diff --git a/keduvocdocument/CMakeLists.txt b/keduvocdocument/CMakeLists.txt index f629997..e5c42a6 100644 --- a/keduvocdocument/CMakeLists.txt +++ b/keduvocdocument/CMakeLists.txt @@ -26,16 +26,7 @@ set(keduvocdocument_LIB_SRCS 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}) @@ -63,10 +54,7 @@ install(FILES 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 ) diff --git a/keduvocdocument/keduvocdocument.cpp b/keduvocdocument/keduvocdocument.cpp index 192aa12..ffd9f3f 100644 --- a/keduvocdocument/keduvocdocument.cpp +++ b/keduvocdocument/keduvocdocument.cpp @@ -41,7 +41,6 @@ #include "keduvocpaukerreader.h" #include "keduvocvokabelnreader.h" #include "keduvocxdxfreader.h" -#include "leitnersystem.h" #define WQL_IDENT "WordQuiz" @@ -98,9 +97,6 @@ public: QList m_lessons; KEduVocWordType m_wordTypes; - - LeitnerSystem* m_leitnerSystem; - bool m_activeLeitnerSystem; }; KEduVocDocument::KEduVocDocumentPrivate::~KEduVocDocumentPrivate() @@ -126,8 +122,6 @@ void KEduVocDocument::KEduVocDocumentPrivate::init() m_version = ""; m_generator = ""; m_csvDelimiter = QString( '\t' ); - m_activeLeitnerSystem = false; - m_leitnerSystem = NULL; } @@ -797,63 +791,6 @@ bool KEduVocDocument::isModified() const } -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(); diff --git a/keduvocdocument/keduvocdocument.h b/keduvocdocument/keduvocdocument.h index 126e20c..05be0ef 100644 --- a/keduvocdocument/keduvocdocument.h +++ b/keduvocdocument/keduvocdocument.h @@ -34,7 +34,6 @@ class QStringList; class KEduVocExpression; class KEduVocLesson; -class LeitnerSystem; class KEduVocWordType; /** @@ -483,12 +482,6 @@ public: */ 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 ); /** diff --git a/keduvocdocument/keduvocexpression.cpp b/keduvocdocument/keduvocexpression.cpp index b18e372..edf3bc1 100644 --- a/keduvocdocument/keduvocexpression.cpp +++ b/keduvocdocument/keduvocexpression.cpp @@ -36,7 +36,6 @@ public: KEduVocExpression* q; - QString m_leitnerBox; int m_sortIndex; int m_lesson; bool m_active; @@ -60,7 +59,6 @@ bool KEduVocExpression::KEduVocExpressionPrivate::operator== ( const KEduVocExpr { 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; @@ -124,17 +122,6 @@ void KEduVocExpression::setLesson( int l ) 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 { diff --git a/keduvocdocument/keduvocexpression.h b/keduvocdocument/keduvocexpression.h index 7f447f0..1f242c6 100644 --- a/keduvocdocument/keduvocexpression.h +++ b/keduvocdocument/keduvocexpression.h @@ -113,18 +113,6 @@ public: QList 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; diff --git a/keduvocdocument/leitnerbox.cpp b/keduvocdocument/leitnerbox.cpp deleted file mode 100644 index 5959d9c..0000000 --- a/keduvocdocument/leitnerbox.cpp +++ /dev/null @@ -1,85 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005 by Martin Pfeiffer * - * * - * 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; -} diff --git a/keduvocdocument/leitnerbox.h b/keduvocdocument/leitnerbox.h deleted file mode 100644 index e44fa57..0000000 --- a/keduvocdocument/leitnerbox.h +++ /dev/null @@ -1,111 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005 by Martin Pfeiffer * - * * - * 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 - -/** - * 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 - */ -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 diff --git a/keduvocdocument/leitnersystem.cpp b/keduvocdocument/leitnersystem.cpp deleted file mode 100644 index d5316cb..0000000 --- a/keduvocdocument/leitnersystem.cpp +++ /dev/null @@ -1,249 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005 by Martin Pfeiffer * - * * - * 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 - -LeitnerSystem::LeitnerSystem( const QList &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::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::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-- ); -} - diff --git a/keduvocdocument/leitnersystem.h b/keduvocdocument/leitnersystem.h deleted file mode 100644 index 7c63b97..0000000 --- a/keduvocdocument/leitnersystem.h +++ /dev/null @@ -1,140 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005 by Martin Pfeiffer * - * * - * 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 - -#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 &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 m_boxes; -}; - -#endif diff --git a/keduvocdocument/leitnersystemview.cpp b/keduvocdocument/leitnersystemview.cpp deleted file mode 100644 index 2dfd898..0000000 --- a/keduvocdocument/leitnersystemview.cpp +++ /dev/null @@ -1,211 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005 by Martin Pfeiffer * - * * - * 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 -#include - -#include - -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" - diff --git a/keduvocdocument/leitnersystemview.h b/keduvocdocument/leitnersystemview.h deleted file mode 100644 index 23a6479..0000000 --- a/keduvocdocument/leitnersystemview.h +++ /dev/null @@ -1,75 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005 by Martin Pfeiffer * - * * - * 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 - -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 diff --git a/keduvocdocument/prefleitner.cpp b/keduvocdocument/prefleitner.cpp deleted file mode 100644 index 67fb274..0000000 --- a/keduvocdocument/prefleitner.cpp +++ /dev/null @@ -1,181 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005 by Martin Pfeiffer * - * * - * 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 -#include -#include -#include -#include - -#include - -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" diff --git a/keduvocdocument/prefleitner.h b/keduvocdocument/prefleitner.h deleted file mode 100644 index 0be0ccd..0000000 --- a/keduvocdocument/prefleitner.h +++ /dev/null @@ -1,86 +0,0 @@ -#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 - -class LeitnerSystem; - -/** - * This class is a dialog for configuring a LeitnerSystem - * @author Martin Pfeiffer - */ -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 diff --git a/keduvocdocument/prefleitnerbase.ui b/keduvocdocument/prefleitnerbase.ui deleted file mode 100644 index 881cb1a..0000000 --- a/keduvocdocument/prefleitnerbase.ui +++ /dev/null @@ -1,151 +0,0 @@ - - - - - PrefLeitnerBase - - - - 0 - 0 - 770 - 458 - - - - Leitner System - - - - 10 - - - 6 - - - - - 0 - - - 6 - - - - - Appl&y Changes - - - - - - - Qt::Horizontal - - - QSizePolicy::Expanding - - - - 421 - 20 - - - - - - - - 0 - - - 6 - - - - - - - - Edit box name: - - - - - - - - - Disc&ard Changes - - - - - - - Add a bo&x - - - - - - - Delete selected &box - - - - - - - 0 - - - 6 - - - - - Correct words to: - - - - - - - - - - Wrong words to: - - - - - - - - - - - - Qt::Horizontal - - - QSizePolicy::Expanding - - - - 252 - 20 - - - - - - - - - - qPixmapFromMimeSource - - -