From: Kashyap Ramesh Puranik Date: Sat, 27 Jun 2009 17:31:11 +0000 (+0000) Subject: adding libscience to my branch X-Git-Tag: v4.3.80~1^2~4 X-Git-Url: https://git.rmz.fi/?a=commitdiff_plain;h=d5a91a9e99893285851aac561acfd20d6c9868c2;p=libqmvoc.git adding libscience to my branch svn path=/branches/kalzium/gsoc2009/kalzium/libscience/; revision=988289 --- diff --git a/AUTHORS b/AUTHORS deleted file mode 100644 index ac809ea..0000000 --- a/AUTHORS +++ /dev/null @@ -1,3 +0,0 @@ -Developers: -* Scott Wheeler - Original author and current maintainer diff --git a/CMakeLists.txt b/CMakeLists.txt deleted file mode 100644 index 1d296a7..0000000 --- a/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -project(libkdeedu) - -#add_definitions( -Wall -fprofile-arcs -ftest-coverage ) - -add_subdirectory(keduvocdocument) -add_subdirectory(kdeeduui) -add_subdirectory(libscience) -#add_subdirectory(widgets) diff --git a/Mainpage.dox b/Mainpage.dox deleted file mode 100644 index 4c70094..0000000 --- a/Mainpage.dox +++ /dev/null @@ -1,15 +0,0 @@ -/** @mainpage libkdeedu - -libkdeedu is a set of shared libraries used by the KDE Education Project applications. - -It consists of several parts: - -User interface parts: Glossary - -ExtDate for KStars - -libscience for Kalzium containing chemical classes - -KEduVocDocument is a library for reading and writing vocabulary files used by KVocTrain, KAnagram, KHangman and KWordQuiz. - -*/ diff --git a/Messages.sh b/Messages.sh deleted file mode 100644 index 2360fd9..0000000 --- a/Messages.sh +++ /dev/null @@ -1,17 +0,0 @@ -#! /bin/sh -find kdeeduui -maxdepth 1 -name \*.cpp >>list_libkdeedu -find keduvocdocument -maxdepth 1 -name \*.cpp -o -name \*.h >>list_libkdeedu -find libscience -maxdepth 1 -name \*.cpp >>list_libkdeedu - -# extracting a reduced version of the elements.xml, with only the data we want -echo "" >element_tiny.xml -cat libscience/data/elements.xml | grep 'bo:name' >>element_tiny.xml -echo "" >>element_tiny.xml -$EXTRACTATTR --attr=label,value element_tiny.xml >>rc.cpp -$EXTRACTRC --tag-group=none --tag=scalar element_tiny.xml >>rc.cpp -echo 'rc.cpp' >>list_libkdeedu - -$XGETTEXT --files-from=list_libkdeedu --from-code=UTF-8 -o $podir/libkdeedu.pot -rm -f element_tiny.xml -rm -f list_libkdeedu -rm -f rc.cpp diff --git a/README b/README deleted file mode 100644 index 2ab20b7..0000000 --- a/README +++ /dev/null @@ -1,27 +0,0 @@ -Contents of libkdeedu as of Feb 2006, and brief description of each module: - -extdate: -Contains a reimplementation of QDate named ExtDate which eliminates the -limitation on the year (1752-8000) imposed by QDate. Also contains -related reimplemented classes such as ExtDateTime, ExtDatePicker, -ExtDateTimeEdit, and ExtCalendarSystem. -Currently used by: kstars - -kdeeducore: -Contains KEduVocDocument and its related class for reading from/writing to the -KVTML format (and others too). -Currently used by: kanagram, khangman, klatin, kvoctrain, kwordquiz - -kdeeduui: -Contains: -- Glossary, GlossaryItem and GlossaryDialog, which can be useful to embed a - small glossary in an application -Currently used by: kalzium, kstars - -libscience: -Contains some classes related to scientific data, like chemical Element's, -spectra, temperature units and Isotope's. -Currently used by: kalzium - -ideas: stub directory, contains generic README and TODO files. - diff --git a/kdeeduui/CMakeLists.txt b/kdeeduui/CMakeLists.txt deleted file mode 100644 index 3cffd82..0000000 --- a/kdeeduui/CMakeLists.txt +++ /dev/null @@ -1,25 +0,0 @@ - -#add_subdirectory(tests) - -########### next target ############### - -set(kdeeduui_LIB_SRCS - kdeeduglossary.cpp - kedufontutils.cpp -) - - -kde4_add_library(kdeeduui SHARED ${kdeeduui_LIB_SRCS}) - -target_link_libraries(kdeeduui ${KDE4_KHTML_LIBS} ${QT_QTXML_LIBRARY}) - -set_target_properties(kdeeduui PROPERTIES VERSION ${GENERIC_LIB_VERSION} SOVERSION ${GENERIC_LIB_SOVERSION} ) -install(TARGETS kdeeduui ${INSTALL_TARGETS_DEFAULT_ARGS}) - - -########### install files ############### - -install(FILES - libkdeedu_ui_export.h - kdeeduglossary.h kedufontutils.h DESTINATION ${INCLUDE_INSTALL_DIR}/libkdeedu COMPONENT Devel -) diff --git a/kdeeduui/kdeeduglossary.cpp b/kdeeduui/kdeeduglossary.cpp deleted file mode 100644 index c6ed902..0000000 --- a/kdeeduui/kdeeduglossary.cpp +++ /dev/null @@ -1,552 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005, 2006 by Carsten Niehaus * - * Copyright (C) 2005 - 2007 by Pino Toscano * - * * - * 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 "kdeeduglossary.h" - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -static const int FirstLetterRole = 0x00b00a00; - -static const int GlossaryTreeItemType = QTreeWidgetItem::UserType + 1; - -class GlossaryTreeItem : public QTreeWidgetItem -{ - public: - GlossaryTreeItem( Glossary * g, GlossaryItem * gi ) - : QTreeWidgetItem( GlossaryTreeItemType ), m_g( g ), m_gi( gi ) - { - setText( 0, m_gi->name() ); - } - - Glossary *glossary() const - { - return m_g; - } - - GlossaryItem *glossaryItem() const - { - return m_gi; - } - - private: - Glossary *m_g; - GlossaryItem *m_gi; -}; - - -struct GlossaryInfo -{ - GlossaryInfo( Glossary* g ) - : glossary( g ), folded( true ) - { - } - - Glossary *glossary; - bool folded; -}; - - -class GlossaryDialog::Private -{ - public: - Private( GlossaryDialog *qq ) - : q( qq ) - { - } - - ~Private() - { - QList< GlossaryInfo >::ConstIterator it = m_glossaries.constBegin(), itEnd = m_glossaries.constEnd(); - for ( ; it != itEnd; ++it ) - { - delete (*it).glossary; - } - } - - void rebuildTree(); - QTreeWidgetItem* createItem( const GlossaryInfo& gi ) const; - QTreeWidgetItem* findTreeWithLetter( const QChar& l, QTreeWidgetItem* item ) const; - - // slots - void itemActivated( QTreeWidgetItem * item, int column ); - // The user clicked on a href. Find and display the right item - void displayItem( const KUrl &url, const KParts::OpenUrlArguments& arguments, const KParts::BrowserArguments &browserArguments ); - - GlossaryDialog *q; - - QList< GlossaryInfo > m_glossaries; - - KHTMLPart *m_htmlpart; - QTreeWidget *m_glosstree; - KTreeWidgetSearchLine *m_search; - QString m_htmlbasestring; - - KActionCollection* m_actionCollection; -}; - - -Glossary::Glossary( const KUrl& url, const QString& path ) -{ - init( url, path ); -} - -Glossary::Glossary() -{ - init( KUrl(), QString() ); -} - -Glossary::~Glossary() -{ - qDeleteAll(m_itemlist); -} - -void Glossary::init( const KUrl& url, const QString& path ) -{ - // setting a generic name for a new glossary - m_name = i18n( "Glossary" ); - - setPicturePath( path ); - - if ( !url.isEmpty() ) - { - - QDomDocument doc( "document" ); - - if ( loadLayout( doc, url ) ) - { - setItemlist( readItems( doc ) ); - if ( !m_picturepath.isEmpty() ) - fixImagePath(); - } - } -} - -bool Glossary::loadLayout( QDomDocument &Document, const KUrl& url ) -{ - QFile layoutFile( url.path() ); - - if ( !layoutFile.exists() ) - { - kDebug() << "no such file: " << layoutFile.fileName(); - return false; - } - - if ( !layoutFile.open( QIODevice::ReadOnly ) ) - return false; - - // check if document is well-formed - if ( !Document.setContent( &layoutFile ) ) - { - kDebug() << "wrong xml of " << layoutFile.fileName(); - layoutFile.close(); - return false; - } - layoutFile.close(); - - return true; -} - -bool Glossary::isEmpty() const -{ - return m_itemlist.count() == 0; -} - -void Glossary::setName( const QString& name ) -{ - if ( name.isEmpty()) - return; - m_name = name; -} - -void Glossary::setPicturePath( const QString& path ) -{ - if ( path.isEmpty()) - return; - m_picturepath = path; -} - -void Glossary::setBackgroundPicture( const QString& filename ) -{ - if ( filename.isEmpty()) - return; - m_backgroundpicture = filename; -} - -void Glossary::fixImagePath() -{ - QString imgtag = ""; - QRegExp exp( "\\[img\\]([^[]+)\\[/img\\]" ); - - foreach (GlossaryItem * item, m_itemlist) { - QString tmp = item->desc(); - while ( exp.indexIn( tmp ) > -1 ) - { - tmp = tmp.replace( exp, imgtag ); - } - item->setDesc( tmp ); - } -} - -QList Glossary::readItems( QDomDocument &itemDocument ) -{ - QList list; - - QDomNodeList itemList; - QDomNodeList refNodeList; - QDomElement itemElement; - QStringList reflist; - - itemList = itemDocument.elementsByTagName( "item" ); - - const uint num = itemList.count(); - for ( uint i = 0; i < num; ++i ) - { - reflist.clear(); - GlossaryItem *item = new GlossaryItem(); - - itemElement = ( const QDomElement& ) itemList.item( i ).toElement(); - - QDomNode nameNode = itemElement.namedItem( "name" ); - QDomNode descNode = itemElement.namedItem( "desc" ); - - QString picName = itemElement.namedItem( "picture" ).toElement().text(); - QDomElement refNode = ( const QDomElement& ) itemElement.namedItem( "references" ).toElement(); - - QString desc = i18n( descNode.toElement().text().toUtf8() ); - if ( !picName.isEmpty() ) - desc.prepend("[img]"+picName +"[/img][brclear][br]" ); - - item->setName( i18n( nameNode.toElement( ).text().toUtf8() ) ); - - desc = desc.replace("[b]", "" ); - desc = desc.replace("[/b]", "" ); - desc = desc.replace("[i]", "" ); - desc = desc.replace("[/i]", "" ); - desc = desc.replace("[sub]", "" ); - desc = desc.replace("[/sub]", "" ); - desc = desc.replace("[sup]", "" ); - desc = desc.replace("[/sup]", "" ); - desc = desc.replace("[br]", "
" ); - desc = desc.replace("[brclear]", "
" ); - item->setDesc( desc ); - - refNodeList = refNode.elementsByTagName( "refitem" ); - for ( int it = 0; it < refNodeList.count(); it++ ) - { - reflist << i18n( refNodeList.item( it ).toElement().text().toUtf8() ); - } - item->setRef( reflist ); - - list.append( item ); - } - - return list; -} - -void Glossary::addItem( GlossaryItem* item ) -{ - m_itemlist.append( item ); -} - -QList Glossary::itemlist()const -{ - return m_itemlist; -} - -void Glossary::clear() -{ - m_itemlist.clear(); -} - -QString Glossary::name()const -{ - return m_name; -} - -void Glossary::setItemlist( QList list ) -{ - m_itemlist = list; -} - -QString Glossary::picturePath()const -{ - return m_picturepath; -} - -QString Glossary::backgroundPicture()const -{ - return m_backgroundpicture; -} - -GlossaryDialog::GlossaryDialog( QWidget *parent ) - : KDialog( parent ), d( new Private( this ) ) -{ - setCaption( i18n( "Glossary" ) ); - setButtons( Close ); - setDefaultButton( Close ); - - //this string will be used for all items. If a backgroundpicture should - //be used call Glossary::setBackgroundPicture(). - d->m_htmlbasestring = "" ; - - QWidget *main = new QWidget( this ); - setMainWidget( main ); - QVBoxLayout *vbox = new QVBoxLayout( main ); - vbox->setMargin( 0 ); - - QHBoxLayout *hbox = new QHBoxLayout(); - - QLabel *lbl = new QLabel( main ); - lbl->setText( i18n( "&Search:" ) ); - hbox->addWidget( lbl ); - - d->m_search = new KTreeWidgetSearchLine( main ); - d->m_search->setObjectName( "search-line" ); - lbl->setBuddy( lbl ); - hbox->addWidget( d->m_search ); - vbox->addLayout( hbox ); - setFocusProxy(d->m_search); - - QSplitter *vs = new QSplitter( main ); - vbox->addWidget( vs ); - - d->m_glosstree = new QTreeWidget( vs ); - d->m_glosstree->setObjectName( "treeview" ); - d->m_glosstree->setHeaderLabel( "entries" ); - d->m_glosstree->header()->hide(); - d->m_glosstree->setRootIsDecorated( true ); - - d->m_search->addTreeWidget( d->m_glosstree ); - - d->m_htmlpart = new KHTMLPart( vs ); - - connect( d->m_htmlpart->browserExtension(), SIGNAL( openUrlRequestDelayed( const KUrl &, const KParts::OpenUrlArguments &, const KParts::BrowserArguments & ) ), - this, SLOT( displayItem( const KUrl &, const KParts::OpenUrlArguments &, const KParts::BrowserArguments & ) ) ); - connect( d->m_glosstree, SIGNAL( itemActivated( QTreeWidgetItem * , int ) ), this, SLOT( itemActivated( QTreeWidgetItem * , int ) ) ); - - resize( 600, 400 ); -} - -GlossaryDialog::~GlossaryDialog() -{ - delete d; -} - -void GlossaryDialog::keyPressEvent(QKeyEvent* e) -{ - if (e->key() == Qt::Key_Return) { - e->ignore(); - } - KDialog::keyPressEvent(e); -} - -void GlossaryDialog::Private::displayItem( const KUrl &url, const KParts::OpenUrlArguments &, const KParts::BrowserArguments & ) -{ - // using the "path" part of a kurl as reference - QString myurl = url.path().toLower(); - - QTreeWidgetItemIterator it( m_glosstree ); - while ( *it ) - { - if ( (*it)->type() == GlossaryTreeItemType && (*it)->text( 0 ).toLower() == myurl ) - { - // force the item to be selected - m_glosstree->setCurrentItem( *it ); - // display its content - itemActivated( (*it), 0 ); - break; - } - else - ++it; - } -} - -void GlossaryDialog::Private::rebuildTree() -{ - m_glosstree->clear(); - - QList< GlossaryInfo >::ConstIterator it = m_glossaries.constBegin(), itEnd = m_glossaries.constEnd(); - for ( ; it != itEnd; ++it ) - { - m_glosstree->addTopLevelItem( createItem( *it ) ); - } -} - -QTreeWidgetItem* GlossaryDialog::Private::createItem( const GlossaryInfo& gi ) const -{ - Glossary *glossary = gi.glossary; - bool folded = gi.folded; - QTreeWidgetItem *main = new QTreeWidgetItem(); - main->setText( 0, glossary->name() ); - main->setFlags( Qt::ItemIsEnabled ); - foreach ( GlossaryItem * item, glossary->itemlist() ) - { - if ( folded ) - { - QChar thisletter = item->name().toUpper().at(0); - QTreeWidgetItem *thisletteritem = findTreeWithLetter( thisletter, main ); - if ( !thisletteritem ) - { - thisletteritem = new QTreeWidgetItem( main ); - thisletteritem->setText( 0, QString( thisletter ) ); - thisletteritem->setFlags( Qt::ItemIsEnabled ); - thisletteritem->setData( 0, FirstLetterRole, thisletter ); - } - thisletteritem->addChild( new GlossaryTreeItem( glossary, item ) ); - } - else - { - main->addChild( new GlossaryTreeItem( glossary, item ) ); - } - - } - return main; -} - -void GlossaryDialog::addGlossary( Glossary* newgloss, bool folded ) -{ - if ( !newgloss || newgloss->isEmpty() ) - return; - - GlossaryInfo gi( newgloss ); - gi.folded = folded; - d->m_glossaries.append( gi ); - - d->m_glosstree->addTopLevelItem( d->createItem( gi ) ); - d->m_glosstree->sortItems( 0, Qt::AscendingOrder ); -} - -QTreeWidgetItem* GlossaryDialog::Private::findTreeWithLetter( const QChar& l, QTreeWidgetItem* item ) const -{ - int count = item->childCount(); - for ( int i = 0; i < count; ++i ) - { - QTreeWidgetItem *itemchild = item->child( i ); - if ( itemchild->data( 0, FirstLetterRole ).toChar() == l ) - return itemchild; - } - return 0; -} - -void GlossaryDialog::Private::itemActivated( QTreeWidgetItem * item, int column ) -{ - Q_UNUSED(column) - if ( !item || item->type() != GlossaryTreeItemType ) - return; - - GlossaryTreeItem *glosstreeitem = static_cast< GlossaryTreeItem * >( item ); - GlossaryItem * glossitem = glosstreeitem->glossaryItem(); - QString html; - QString bg_picture = glosstreeitem->glossary()->backgroundPicture(); - if ( !bg_picture.isEmpty() ) - { - html = " background=\"" + bg_picture + "\""; - } - - html = m_htmlbasestring.arg( html ); - html += glossitem->toHtml() + ""; - - m_htmlpart->begin(); - m_htmlpart->write( html ); - m_htmlpart->end(); -} - -void GlossaryItem::setRef( const QStringList& s ) -{ - m_ref = s; - m_ref.sort(); -} - -QString GlossaryItem::toHtml() const -{ - QString code = "

" + m_name + "

" + m_desc + parseReferences(); - - return code; -} - -QString GlossaryItem::parseReferences() const -{ - if ( m_ref.isEmpty() ) - return QString(); - - QString htmlcode = "

" + i18n( "References" ) + "

    "; - static QString basehref = QString( "
  • %3
  • " ); - - foreach ( const QString& ref, m_ref ) - { - htmlcode += basehref.arg( KUrl::toPercentEncoding( ref ), i18n( "Go to '%1'", ref ), ref ); - } - htmlcode += "
"; - - return htmlcode; -} - -void GlossaryItem::setName( const QString& s ) -{ - m_name = s; -} - -void GlossaryItem::setDesc( const QString& s) -{ - m_desc = s; -} - -void GlossaryItem::setPictures( const QString& s ){ - m_pic = QStringList(s); -} - -QString GlossaryItem::name() const -{ - return m_name; -} - -QString GlossaryItem::desc() const -{ - return m_desc; -} - -QStringList GlossaryItem::ref() const -{ - return m_ref; -} - -QStringList GlossaryItem::pictures() const -{ - return m_pic; -} - -#include "kdeeduglossary.moc" diff --git a/kdeeduui/kdeeduglossary.h b/kdeeduui/kdeeduglossary.h deleted file mode 100644 index f5cf86d..0000000 --- a/kdeeduui/kdeeduglossary.h +++ /dev/null @@ -1,241 +0,0 @@ -#ifndef KDEEDUGLOSSARY_H -#define KDEEDUGLOSSARY_H -/*************************************************************************** - * Copyright (C) 2005, 2006 by Carsten Niehaus * - * Copyright (C) 2005 - 2007 by Pino Toscano * - * * - * 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. * - ***************************************************************************/ - -#include "libkdeedu_ui_export.h" - -#include - -class QDomDocument; -class GlossaryItem; - -/** - * @class Glossary - * @author Carsten Niehaus - * @author Pino Toscano - * - * This class stores all items to be displayed. It also - * has access-methods to the items - */ -class KDEEDUUI_EXPORT Glossary -{ - public: - /** - * Creates a new glossary and add contents from an XML file. - * Use isEmpty() to know if any items were loaded. - * - * @param url the path of the file to load - * @param path the path of the pictures - */ - explicit Glossary( const KUrl& url, const QString& path = 0 ); - - /** - * Creates a new empty glossary - */ - Glossary(); - - virtual ~Glossary(); - - /** - * add the item @p item to the glossary - */ - void addItem( GlossaryItem* item ); - - QList itemlist()const; - - /** - * clear the Glossary - */ - void clear(); - - /** - * does this glossary have items? - */ - bool isEmpty() const; - - /** - * Every glossary can have a name. It will be - * set to @p name - */ - void setName( const QString& name ); - - /** - * @returns the name of the glossary - */ - QString name()const; - - /** - * sets the internal list of items to @p list - */ - void setItemlist( QList list ); - - /** - * Every glossaryitem can show pictures. [img src="foo.png] - * will look for the file foo.png in the path defined by - * @p path - */ - void setPicturePath( const QString& path ); - - QString picturePath()const; - - /** - * defines which picture to use as the background - * of the htmlview. The dialog - * will use the file specifiec by the @p filename - */ - void setBackgroundPicture( const QString& filename ); - - /** - * @return the picuture used as the background in - * this background - */ - QString backgroundPicture()const; - - protected: - void init( const KUrl& url, const QString& path ); - - private: - /** - * This methods parses the given XML code. It will extract - * the information of the items and return them as a - * QList - */ - virtual QList readItems( QDomDocument &itemDocument ); - - QString m_backgroundpicture; - - /** - * replaces the [img]-pseudocode with valid HTML. The path where - * the pictures are stored will be used for pictures - */ - void fixImagePath(); - - /** - * the path in which pictures of the glossary will be searched - */ - QString m_picturepath; - - /** - * Load the layout from an XML file. - * - * @param doc The QDomDocument which will contain the read XML - * contents. - * @param url The path of the file to load - * - * @return a bool indicating whether the loading of the XML was - * successful or not - */ - bool loadLayout( QDomDocument& doc, const KUrl& url ); - - QList m_itemlist; - - /** - * the name of the glossary - */ - QString m_name; -}; - -/** - * @class GlossaryItem - * @author Carsten Niehaus - * - * A GlossaryItem stores the information of the content of - * the item and its name. Furthermore, every item can have - * a number of pictures or references associated to it. - * These are stored as QStringLists. - */ -class KDEEDUUI_EXPORT GlossaryItem -{ - public: - GlossaryItem(){} - ~GlossaryItem(){} - - void setName( const QString& s ); - - void setDesc( const QString& s); - - /** - * Set the references for the current GlossaryItem to - * @p s. - * There's no need to sort the list before, as they - * will be sorted automatically - */ - void setRef( const QStringList& s); - - void setPictures( const QString& s ); - - QString name() const; - - QString desc() const; - - QStringList ref() const; - - QStringList pictures() const; - - /** - * @return the formated HTML code for current item. - */ - QString toHtml() const; - - /** - * This method parses the references. - * @return the HTML code with the references as HTML links - */ - QString parseReferences() const; - - private: - QString m_name; - QString m_desc; - QStringList m_ref; - QStringList m_pic; -}; - -/** - * @class GlossaryDialog - * @author Pino Toscano - * @author Carsten Niehaus - */ -class KDEEDUUI_EXPORT GlossaryDialog : public KDialog -{ - Q_OBJECT - - public: - /** - * Creates a new dialog for a glossary. - * - * @param parent the parent of the new dialog - */ - explicit GlossaryDialog( QWidget *parent = 0 ); - - virtual ~GlossaryDialog(); - - /** - * Add a new glossary. - * - * @param newgloss the new glossary to add - * @param folded whether to fold the various items in subtrees depending on the - * first letter of every item - */ - void addGlossary( Glossary* newgloss, bool folded = true ); - - protected: - void keyPressEvent(QKeyEvent*); - - private: - class Private; - Private * const d; - - Q_PRIVATE_SLOT( d, void itemActivated( QTreeWidgetItem *, int ) ) - Q_PRIVATE_SLOT( d, void displayItem( const KUrl &, const KParts::OpenUrlArguments &, const KParts::BrowserArguments & ) ) -}; - -#endif // KDEEDUGLOSSARY_H - diff --git a/kdeeduui/kedufontutils.cpp b/kdeeduui/kedufontutils.cpp deleted file mode 100644 index b75be7d..0000000 --- a/kdeeduui/kedufontutils.cpp +++ /dev/null @@ -1,37 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005-2006 by Albert Astals Cid * - * * - * 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. * - ***************************************************************************/ - -#include "kedufontutils.h" - -#include - -int fontUtils::fontSize(QPainter &p, const QString &s1, int w, int h, Flags flags) -{ - int size; - QRect aux1; - bool done = false; - - size = 28; - - while (!done && size > 1) - { - QFont f = p.font(); - f.setPointSize(size); - p.setFont(f); - int qtFlags = Qt::AlignCenter | Qt::TextWordWrap; - if (flags & DoNotAllowWordWrap) qtFlags = qtFlags & ~Qt::TextWordWrap; - aux1 = p.boundingRect(QRect(0, 0, w, h), qtFlags, s1); - if (aux1.width() == 0 || aux1.height() == 0) return -1; - else if (aux1.width() > w || aux1.height() > h) size = qMin(w * size / aux1.width(), h * size / aux1.height()); - else done = true; - } - - return size; -} - diff --git a/kdeeduui/kedufontutils.h b/kdeeduui/kedufontutils.h deleted file mode 100644 index de8861f..0000000 --- a/kdeeduui/kedufontutils.h +++ /dev/null @@ -1,30 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005 by Albert Astals Cid * - * * - * 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. * - ***************************************************************************/ - -#ifndef FONTUTILS_H -#define FONTUTILS_H - -#include "libkdeedu_ui_export.h" - -class QPainter; -class QString; - -namespace fontUtils -{ - enum Flags - { - NoFlags = 1, - DoNotAllowWordWrap = 2 - }; - - int KDEEDUUI_EXPORT fontSize(QPainter &p, const QString &s1, int w, int h, Flags flags = NoFlags); -} - -#endif - diff --git a/kdeeduui/libkdeedu_ui_export.h b/kdeeduui/libkdeedu_ui_export.h deleted file mode 100644 index cec0149..0000000 --- a/kdeeduui/libkdeedu_ui_export.h +++ /dev/null @@ -1,40 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2007 David Faure - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#ifndef LIBKDEEDU_UI_EXPORT_H -#define LIBKDEEDU_UI_EXPORT_H - -/* needed for KDE_EXPORT and KDE_IMPORT macros */ -#include - -#ifndef KDEEDUUI_EXPORT -# if defined(MAKE_KDEEDUUI_LIB) - /* We are building this library */ -# define KDEEDUUI_EXPORT KDE_EXPORT -# else - /* We are using this library */ -# define KDEEDUUI_EXPORT KDE_IMPORT -# endif -#endif - -# ifndef KDEEDUUI_EXPORT_DEPRECATED -# define KDEEDUUI_EXPORT_DEPRECATED KDE_DEPRECATED KDEEDUUI_EXPORT -# endif - -#endif diff --git a/kdeeduui/tests/CMakeLists.txt b/kdeeduui/tests/CMakeLists.txt deleted file mode 100644 index 88b27f7..0000000 --- a/kdeeduui/tests/CMakeLists.txt +++ /dev/null @@ -1,23 +0,0 @@ - -include_directories( ${CMAKE_SOURCE_DIR}/kdeeduui ) - - -########### install files ############### - - - - - -#original Makefile.am contents follow: - -#SUBDIRS = . -#INCLUDES = -I. -I$(top_srcdir)/kdeeduui $(all_includes) -#LDADD = ../libkdeeduui.la -#LDFLAGS = $(all_libraries) -# -##check_PROGRAMS = entrydialogs -#check_PROGRAMS = -# -##all: check -# -##entrydialogs_SOURCES = entrydialogs.cpp diff --git a/keduvocdocument/CMakeLists.txt b/keduvocdocument/CMakeLists.txt deleted file mode 100644 index bcaf2df..0000000 --- a/keduvocdocument/CMakeLists.txt +++ /dev/null @@ -1,62 +0,0 @@ -add_subdirectory(tests) - -########### next target ############### - -set(keduvocdocument_LIB_SRCS -keduvocdocument.cpp - keduvocidentifier.cpp - keduvocexpression.cpp - keduvoctranslation.cpp - keduvoccontainer.cpp - keduvoclesson.cpp - keduvocleitnerbox.cpp - keduvoctext.cpp - keduvocarticle.cpp - keduvocconjugation.cpp - keduvocpersonalpronoun.cpp - keduvocdeclension.cpp - keduvocwordtype.cpp - keduvockvtmlcompability.cpp - keduvockvtmlreader.cpp - keduvockvtml2reader.cpp - #keduvockvtmlwriter.cpp - keduvockvtml2writer.cpp - keduvoccsvreader.cpp - keduvoccsvwriter.cpp - keduvocpaukerreader.cpp - keduvocvokabelnreader.cpp - keduvocwqlreader.cpp - keduvocxdxfreader.cpp - sharedkvtmlfiles.cpp - ) - -kde4_add_library(keduvocdocument SHARED ${keduvocdocument_LIB_SRCS}) - -target_link_libraries(keduvocdocument ${KDE4_KIO_LIBS} ${QT_QTXML_LIBRARY}) - -set_target_properties(keduvocdocument PROPERTIES VERSION ${GENERIC_LIB_VERSION} SOVERSION ${GENERIC_LIB_SOVERSION} ) -install(TARGETS keduvocdocument ${INSTALL_TARGETS_DEFAULT_ARGS}) - - -########### install files ############### - -install(FILES - libkeduvocdocument_export.h - keduvocdocument.h - keduvocidentifier.h - keduvocexpression.h - keduvoctext.h - keduvocarticle.h - keduvocconjugation.h - keduvoclesson.h - keduvocleitnerbox.h - keduvoccontainer.h - keduvocwordflags.h - keduvocmultiplechoice.h - keduvoctranslation.h - keduvocwordtype.h - keduvocpersonalpronoun.h - sharedkvtmlfiles.h - DESTINATION ${INCLUDE_INSTALL_DIR}/libkdeedu COMPONENT Devel -) - diff --git a/keduvocdocument/Mainpage.dox b/keduvocdocument/Mainpage.dox deleted file mode 100644 index 65424d6..0000000 --- a/keduvocdocument/Mainpage.dox +++ /dev/null @@ -1,36 +0,0 @@ -/** @mainpage KEduVocDocument - -KEduVocDocument is a library for reading and writing vocabulary files used by Parley, KAnagram, KHangman and KWordQuiz. - -At this date no binary compability is guaranteed. Please update this lib when updating the applications mentioned above. - -Important classes are: - - KEduVocExpression to hold an abstract entry. It contains translations in KEduVocTranslation. - - Lessons are organized by KEduVocLesson. - -Grammatical terms are part of KEduVocTranslation and also contained in: - - KEduVocArticle (articles of a language) - - KEduVocConjugation (conjugations and personal pronouns) - - KEduVocWordType (word type management) - -Grammar is accesed by using an instance of KEduVocDocument. - -Grades can be stored using the KEduVocGrade class (part of a KEduVocTranslation). - -KEduVocDocument supports reading and writing of different file formats. KVTML (version 2) is the default. - -Readers: - - KEduVocKvtml2Reader the current default file format since KDE4 - - KEduVocKvtmlReader for compability (pre KDE4) - - KEduVocCsvReader Comma seperated values (text files) - - KEduVocPaukerReader Pauker file format - - KEduVocVokabelnReader Vokabeln file format - - KEduVocXdxfReader XDXF file format - -Writers: - - KEduVocKvtml2Writer - - KEduVocKvtmlWriter - - KEduVocCsvWriter - - -*/ diff --git a/keduvocdocument/TODO b/keduvocdocument/TODO deleted file mode 100644 index c369fd4..0000000 --- a/keduvocdocument/TODO +++ /dev/null @@ -1,10 +0,0 @@ -Things to improve in KEduVocDocument ------------------------------------- - - * Check if all copy constructors are ok or disable copies - -Binary incompatible: - * Tenses should be per language as different languages have a different set of tenses - - - diff --git a/keduvocdocument/docs/basic_vocabulary_en2de.kvtml b/keduvocdocument/docs/basic_vocabulary_en2de.kvtml deleted file mode 100644 index 9567876..0000000 --- a/keduvocdocument/docs/basic_vocabulary_en2de.kvtml +++ /dev/null @@ -1,1352 +0,0 @@ - - - - - - Parley - basic vocabulary German-English - Markus Büchele, Norbert Behrendt - GPL - - - - English - en - - - - - - German - de - - - - - - - - Noun - noun - - Male - male - - - Female - female - - - Neutral - neutral - - - - Verb - verb - - Regular - - - Irregular - - - - Adjective - adjective - - - Adverb - adverb - - - Question - - - Name - - - Article - - Definite - - - Indefinite - - - - Pronoun - - Possessive - - - Personal - - - - Phrase - - - Numeral - - Ordinal - - - Cardinal - - - - Conjunction - - - Preposition - - - - - Past Progressive - Simple Past - will future - going to future - Present Perfect - Present Progressive - Plusquamperfekt - Simple Present - - - - false - - also - - - auch, außerdem - - - - false - - although - - - obwohl - - - - false - - and - - - und - - - - false - - because - - - weil - - - - false - - besides - - - außerdem - - - - false - - but - - - aber, sondern - - - - false - - despite - - - trotz - - - - false - - either ... or - - - entweder ... oder - - - - false - - however - - - jedoch, aber - - - - false - - if - - - wenn, ob - - - - false - - instead of - - - anstatt - - - - false - - like - - - wie - - - - false - - neither ... nor - - - weder ... noch - - - - false - - not yet - - - noch nicht - - - - false - - or - - - oder - - - - false - - such as - - - wie zum Beispiel - - - - false - - than - - - als - - - - false - - therefore - - - deshalb, daher - - - - false - - though - - - obwohl, trotzdem - - - - false - - unless - - - wenn nicht, es sei denn - - - - false - - until - - - bis - - - - false - - when - - - wann, als - - - - false - - whether - - - ob - - - - false - - black - - Adjective - - - black - blacker - the blackest - - - - schwarz - - Adjective - - - - - false - - blue - - Adjective - - - blue - bluer - the bluest - - - - blau - - Adjective - - - - - false - - brown - - Adjective - - - brown - browner - the brownest - - - - braun - - Adjective - - - - - false - - eight - - - acht - - - - false - - five - - - fünf - - - - false - - four - - - vier - - - - false - - green - - - grün - - - - false - - grey - - - grau - - - - false - - hundred - - - hundert - - - - false - - million - - - die Million - - - - false - - nine - - - neun - - - - false - - one - - - eins - - - - false - - red - - Adjective - - - red - redder - the reddest - - - - rot - - Adjective - - - - - false - - seven - - - sieben - - - - false - - six - - - sechs - - - - false - - ten - - - zehn - - - - false - - thousand - - - tausend - - - - false - - three - - - drei - - - - false - - two - - - zwei - - - - false - - white - - Adjective - - - white - whiter - the whitest - - - - weiß - - Adjective - - - - - false - - yellow - - Adjective - - - yellow - yellower - the yellowest - - - - gelb - - Adjective - - - - - false - - about - - - über, etwa - - - - false - - above - - - über, oben - - - - false - - according to - - - laut, nach - - - - false - - across - - - über, hinüber, durch - - - - false - - after - - - nach, nachdem - - - - false - - against - - - gegen - - - - false - - ago - - - vor - - - - false - - among - - - unter - - - - false - - at - - - an, bei - - - - false - - because of - - - wegen - - - - false - - behind - - - hinter, hinten - - - - false - - between - - - zwischen - - - - false - - by - - - bei, von, durch - - - - false - - close to - - - in der Nähe, nahe - - - - false - - due to - - - wegen - - - - false - - during - - - während - - - - false - - except - - - außer - - - - false - - for - - - für, seit - - - - false - - from - - - von - - - - false - - in - - - in - - - - false - - in front of - - - vor - - - - false - - into - - - in ... hinein - - - - false - - near - - - nahe - - - - false - - next to - - - neben - - - - false - - of - - - von - - - - false - - on - - - an, auf - - - - false - - on top of - - - oben auf - - - - false - - since - - - seit - - - - false - - through - - - durch - - - - false - - to - - - zu, nach - - - - false - - toward - - - auf ... zu - - - - false - - under - - - unter - - - - false - - up - - - oben, hinauf - - - - false - - up to - - - bis - - - - false - - with - - - mit - - - - false - - without - - - ohne - - - - false - - bed - - - das Bett - - - - false - - bread - - - das Brot - - - - false - - no - - - nein - - - - false - - please - - - bitte - - - - false - - sorry - - - Entschuldigung - - - - false - - thank you - - - danke - - - - false - - to be - - - sein - - - - false - - to do - - - tun, machen - - - - false - - to have - - - haben - - - - false - - water - - - das Wasser - - - - false - - yes - - - ja - - - - false - - autumn - - - der Herbst - - - - false - - century - - - das Jahrhundert - - - - false - - day - - - der Tag - - - - false - - east - - - der Osten, östlich - - - - false - - hour - - - die Stunde - - - - false - - inch - - - der Zoll (Längenmaß) - - - - false - - kilometre - - - der Kilometer - - - - false - - left - - - links - - - - false - - metre - - - der Meter - - - - false - - mile - - - die Meile - - - - false - - minute - - - die Minute - - - - false - - month - - - der Monat - - - - false - - north - - - der Norden, nördlich - - - - false - - right - - - das Recht, rechts, richtig - - - - false - - season - - - die Jahreszeit, die Saison - - - - false - - south - - - der Süden, südlich - - - - false - - spring - - - der Frühling - - - - false - - square - - - das Quadrat, der Platz - - - - false - - summer - - - der Sommer - - - - false - - triangle - - - das Dreieck - - - - false - - week - - - die Woche - - - - false - - west - - - der Westen, westlich - - - - false - - winter - - - der Winter - - - - false - - year - - - das Jahr - - - - - - time and space - 91 - 92 - 93 - 94 - 95 - 96 - 97 - 98 - 99 - 100 - 101 - 102 - 103 - 104 - 105 - 106 - 107 - 108 - 109 - 110 - 111 - 112 - 113 - 114 - - - survival training - 80 - 81 - 82 - 83 - 84 - 85 - 86 - 87 - 88 - 89 - 90 - - - numbers and colours - 23 - 24 - 25 - 26 - 27 - 28 - 29 - 30 - 31 - 32 - 33 - 34 - 35 - 36 - 37 - 38 - 39 - 40 - 41 - 42 - 43 - - - conjunctions - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - 17 - 18 - 19 - 20 - 21 - 22 - - - prepositions - true - 44 - 45 - 46 - 47 - 48 - 49 - 50 - 51 - 52 - 53 - 54 - 55 - 56 - 57 - 58 - 59 - 60 - 61 - 62 - 63 - 64 - 65 - 66 - 67 - 68 - 69 - 70 - 71 - 72 - 73 - 74 - 75 - 76 - 77 - 78 - 79 - - - diff --git a/keduvocdocument/docs/elek.lex b/keduvocdocument/docs/elek.lex deleted file mode 100644 index 46b23aa..0000000 --- a/keduvocdocument/docs/elek.lex +++ /dev/null @@ -1,191 +0,0 @@ -Vocabulary Trainer V5.0 -LEX|Deutsch|Englisch| 259 260 1 1 1 0 0 268 0 1 1 1 1 145 6 23 1999 255 1 1 653 0 0 0 0 0 0 0 0 0 0 1 1 1 0 1 13 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 1 1 0 0 | --11 700 -System -Energie- und Automatisierungstechnik. V. Manuela Lutz. Danke. -1 1 der die das|he she it| -1 1 eine einer eines einen einem|has have had is be| -1 1 er sie es|his him her its| -1 1 wir ihr euch|in to into on at too| -1 1 in an auf bei|the a an| -1 1 zu um zur zum|out by with of off| -1 1 ist sind seid|something someone some| -1 1 dies dieser dieses|under below| -1 1 || -1 1 || -der die das ein eine einer eines einen einem|the a an| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -Sachgebiete| -| -| -| -| -| -| -| -| -32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 -1 0 255 255 255 255 255 255 0 0 1 Abbildung||||mapping|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 0 255 255 255 255 255 255 0 0 1 Abblendkappe||||anti-dazzle device|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 0 255 255 255 255 255 255 0 0 1 Abdeckblech||||cover sheet|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 0 255 255 255 255 255 255 0 0 1 Abfallstoffe|products|||waste|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 0 255 255 255 255 255 255 0 0 1 Abfalltechnik||||waste engineering|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 0 255 255 255 255 255 255 0 0 1 Abfangblech||||locating plate|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 0 255 255 255 255 255 255 0 0 1 Abfrageprotokoll||||inquiry log|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 0 255 255 255 255 255 255 0 0 1 Abgabeleistung||||power output|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 0 255 255 255 255 255 255 0 0 1 Abgang||||outgoing circuit|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 0 255 255 255 255 255 255 0 0 1 Abgangsbaugruppe||||outgoing unit|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 0 255 255 255 255 255 255 0 0 1 Abgas||||exhaust gas|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 0 255 255 255 255 255 255 0 0 1 Abgasdruck||||exhaust gas pressure|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 0 255 255 255 255 255 255 0 0 1 Abgasemission||||exhaust gas emission|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 0 255 255 255 255 255 255 0 0 1 Abgasgegendruck||||exhaust gas back pressure|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 0 255 255 255 255 255 255 0 0 1 Abgaskatalysator||||exhaust gas catalytic converter|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 0 255 255 255 255 255 255 0 0 1 Abgaskomponenten||||exhaust gas components|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 0 255 255 255 255 255 255 0 0 1 Abgasmeßgerät||||exhaust gas measuring equipment|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 0 255 255 255 255 255 255 0 0 1 Abgasrückführung||||exhaust gas recycling|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 0 255 255 255 255 255 255 0 0 1 abgedeckter Druckknopf||||covered pushbutton|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 0 255 255 255 255 255 255 0 0 1 abgedichtete Kunststoffleuchte||||sealed plastic luminaire|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 0 255 255 255 255 255 255 0 0 1 abgehende Leitung||||outgoing feeder|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 0 255 255 255 255 255 255 0 0 1 abgeschirmte Drucktaste||||shrouded pushbutton|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 0 255 255 255 255 255 255 0 0 1 abgesichert||||fused|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 0 255 255 255 255 255 255 0 0 1 abgetastet||||sampled|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 0 255 255 255 255 255 255 0 0 1 abgeteilt||||segregated|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 0 255 255 255 255 255 255 0 0 1 Abgleich||||adjustment|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 0 255 255 255 255 255 255 0 0 1 abisolieren||||to strip|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 0 255 255 255 255 255 255 0 0 1 abklemmen||||disconnect|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 0 255 255 255 255 255 255 0 0 1 Ablauf||||sequence|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 0 255 255 255 255 255 255 0 0 1 Ablaufplan||||flow diagram|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 47 255 255 255 255 255 255 0 0 1 Ableiter||||surge arrester|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 0 255 255 255 255 255 255 0 0 1 Ableitung||||terminal lead|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 0 255 255 255 255 255 255 0 0 1 Ablenkung||||deflection|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 0 255 255 255 255 255 255 0 0 1 Abluft||||exhaust air|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 0 255 255 255 255 255 255 0 0 1 Abschaltautomatic bei Spannungsabfall||||automatic loss-of-voltage tripping equipment|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 0 255 255 255 255 255 255 0 0 1 Abschirmung||||screening|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 0 255 255 255 255 255 255 0 0 1 Absolutwert||||absolute value|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 0 255 255 255 255 255 255 0 0 1 Abstand||||distance|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 0 255 255 255 255 255 255 0 0 1 Abstraktionsebene||||level of abstraction|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 0 255 255 255 255 255 255 0 0 1 Abteilung||||department|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 0 255 255 255 255 255 255 0 0 1 Abwasseraufbereitung||||effluent treatment|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 0 255 255 255 255 255 255 0 0 1 Abwasserbehandlung||||waste water treatment|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 0 255 255 255 255 255 255 0 0 1 Abwassertechnik||||sewage technology|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 0 255 255 255 255 255 255 0 0 1 Abweichung||||deviation|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 0 255 255 255 255 255 255 0 0 1 abzählbar||||countable|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 0 255 255 255 255 255 255 0 0 1 Achse||||axis|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 0 255 255 255 255 255 255 0 0 1 adaptiver||||adaptive|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 0 255 255 255 255 255 255 0 0 1 Aggregate||||aggregates|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 0 255 255 255 255 255 255 0 0 1 Aktoren|Aktuatoren|||actuators|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 47 255 255 255 255 255 255 0 0 1 Akustik||||acoustics|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 0 255 255 255 255 255 255 0 0 1 Alterungsbeständig||||durability|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 0 255 255 255 255 255 255 0 0 1 Altlasten||||polluted areas|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 0 255 255 255 255 255 255 0 0 1 Analogeingabe||||analog input|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 0 255 255 255 255 255 255 0 0 1 Arbeitswissenschaften||||ergonomics|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 0 255 255 255 255 255 255 0 0 1 Aufbau- und Verbindungstechnik||||packaging of integrated circuits|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 0 255 255 255 255 255 255 0 0 1 Aufbereitung||||preparation|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 0 255 255 255 255 255 255 0 0 1 Auflösung||||resolution|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 0 255 255 255 255 255 255 0 0 1 Aufspannplatte||||mounting plate|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 0 255 255 255 255 255 255 0 0 1 Auftragsabwicklung||||order transaction|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 0 255 255 255 255 255 255 0 0 1 Auftragsbearbeitung||||order processing|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 0 255 255 255 255 255 255 0 0 1 Ausführung||||conducting|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 47 255 255 255 255 255 255 0 0 1 Beleuchtungstechnik||||illumination engineering|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 0 255 255 255 255 255 255 0 0 1 Bildcodierung||||image coding|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 0 255 255 255 255 255 255 0 0 1 Bilderkennungssystem||||image recognition system|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 0 255 255 255 255 255 255 0 0 1 Bildkommunikation||||image communication|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 0 255 255 255 255 255 255 0 0 1 Bildmenge||||image set|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 47 255 255 255 255 255 255 0 0 1 Bildschirmanzeige||||screen diplay|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 0 255 255 255 255 255 255 0 0 1 Bildverarbeitung||||image processing|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 0 255 255 255 255 255 255 0 0 1 Borhmaschine||||drilling machine|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -0 47 255 255 255 255 255 255 0 0 1 Datenübertragung||||data transmission|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 47 255 255 255 255 255 255 0 0 1 Druckluft||||compressed air|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 47 255 255 255 255 255 255 0 0 1 Druckluftanlage||||compressed-air system|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 47 255 255 255 255 255 255 0 0 1 Drucktaster||||pushbutton|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 47 255 255 255 255 255 255 0 0 1 Einbautechnik|Einbausystem|||packaging system|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 0 255 255 255 255 255 255 0 0 1 Einheit||||unit|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 47 255 255 255 255 255 255 0 0 1 elektrisch||||electrical|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 47 255 255 255 255 255 255 0 0 1 Elektrizitätszähler||||electricity meter|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 47 255 255 255 255 255 255 0 0 1 elektromechanische Bauelemente||||electromechanical components|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 47 255 255 255 255 255 255 0 0 1 Elektromotor||||electric motor|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 47 255 255 255 255 255 255 0 0 1 elektronische Steuerung||||electronic control|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 47 255 255 255 255 255 255 0 0 1 Endschalter||||limit switch|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 47 255 255 255 255 255 255 0 0 1 Fernwirktechnik||||telecontrol|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 47 255 255 255 255 255 255 0 0 1 Freiluftanlage||||outdoor installation|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 47 255 255 255 255 255 255 0 0 1 Gebäudeinstallation||||wiring practice|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 47 255 255 255 255 255 255 0 0 1 gedruckte Schaltung||||printed circuit|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 47 255 255 255 255 255 255 0 0 1 Gleichrichter||||rectifier|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 0 255 255 255 255 255 255 0 0 1 Grenzwert||||limiting value|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 47 255 255 255 255 255 255 0 0 1 Halbleiter||||semiconductor|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 47 255 255 255 255 255 255 0 0 1 Halbleiterbauelement||||semiconductor component|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 47 255 255 255 255 255 255 0 0 1 Hebezeug||||hoisting gear|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 47 255 255 255 255 255 255 0 0 1 Hilfsstromschalter||||control switch|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 47 255 255 255 255 255 255 0 0 1 Innenraumanlage||||indoor installation|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 47 255 255 255 255 255 255 0 0 1 Installationskanal||||trunking and duct system|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 47 255 255 255 255 255 255 0 0 1 Installationsmaterial||||wiring accessoires|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 47 255 255 255 255 255 255 0 0 1 Installationstechnik||||electrical installation|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 47 255 255 255 255 255 255 0 0 1 Isolation|Isolierung|||insulation|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 47 255 255 255 255 255 255 0 0 1 Klimatechnik||||air conditioning|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 47 255 255 255 255 255 255 0 0 1 Kommutator||||commutator|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 47 255 255 255 255 255 255 0 0 1 Kraftwerk||||power station|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 47 255 255 255 255 255 255 0 0 1 Kupplung||||coupling|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 47 255 255 255 255 255 255 0 0 1 Lager||||bearing|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 47 255 255 255 255 255 255 0 0 1 Leistungselektronik||||power electronic|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 47 255 255 255 255 255 255 0 0 1 Leistungsschalter|Leistungsschutzschalter|||circuit-breaker|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 47 255 255 255 255 255 255 0 0 1 Leittechnik||||control engineering|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 47 255 255 255 255 255 255 0 0 1 Lichttechnik||||lightning engineering|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 47 255 255 255 255 255 255 0 0 1 Linearmotor||||linear motor|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 47 255 255 255 255 255 255 0 0 1 magnetisch||||magnetic|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 47 255 255 255 255 255 255 0 0 1 Magnetschwebebahn||||magnetic levitation system|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 47 255 255 255 255 255 255 0 0 1 Maschine||||machine|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 47 255 255 255 255 255 255 0 0 1 mechanisch||||mechanical|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 47 255 255 255 255 255 255 0 0 1 Meßgerät||||measuring instrument|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 47 255 255 255 255 255 255 0 0 1 Näherungsschalter||||proximity switch|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 47 255 255 255 255 255 255 0 0 1 Oszilloskop||||oscilloscope|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 47 255 255 255 255 255 255 0 0 1 Positionsschalter||||position switch|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 47 255 255 255 255 255 255 0 0 1 programmierbares Meßgerät||||programmable measuring apparatus|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 47 255 255 255 255 255 255 0 0 1 programmierbares Steuergerät||||programmable controller|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 47 255 255 255 255 255 255 0 0 1 Prozeßleittechnik||||process control technology|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 47 255 255 255 255 255 255 0 0 1 Prüfung||||testing|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 47 255 255 255 255 255 255 0 0 1 Regelung||||automatic control|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 47 255 255 255 255 255 255 0 0 1 Relais||||relay|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 47 255 255 255 255 255 255 0 0 1 rotierende Maschine||||rotating machine|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 47 255 255 255 255 255 255 0 0 1 Rundsteueranlage||||ripple control system|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 47 255 255 255 255 255 255 0 0 1 Röntgenanalyse||||x-ray analysis|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 0 255 255 255 255 255 255 0 0 1 Rückkopplung||||feedback|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 47 255 255 255 255 255 255 0 0 1 Sammelschiene||||busbar|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 47 255 255 255 255 255 255 0 0 1 Schallmessung||||sound measurement|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 47 255 255 255 255 255 255 0 0 1 Schaltanlage|Schaltgerät|||switchgear|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 47 255 255 255 255 255 255 0 0 1 Schaltschrank||||switchgear|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 47 255 255 255 255 255 255 0 0 1 Schalttafel||||switchboard|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 47 255 255 255 255 255 255 0 0 1 Schieneninstallationsrohr||||buselectric wiring conduit|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 47 255 255 255 255 255 255 0 0 1 Sicherung|Schmelzsicherung|||fuse|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 47 255 255 255 255 255 255 0 0 1 Steckvorrichtung||||plug-and-socket device|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 47 255 255 255 255 255 255 0 0 1 Steuergerät||||controller|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 47 255 255 255 255 255 255 0 0 1 Stromrichter||||static converter|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 47 255 255 255 255 255 255 0 0 1 Supraleiter||||superconductor|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 47 255 255 255 255 255 255 0 0 1 Supraleitung||||superconductivity|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 47 255 255 255 255 255 255 0 0 1 Thyristor||||thyristor|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 47 255 255 255 255 255 255 0 0 1 Vakuumschalter|circuit-breaker|||vacuum swith|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 47 255 255 255 255 255 255 0 0 1 Wasserkraftgenerator||||water-wheel generator|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 47 255 255 255 255 255 255 0 0 1 Wasserkraftwerk||||hydroelectric power station|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 47 255 255 255 255 255 255 0 0 1 Werkzeug||||tool|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 47 255 255 255 255 255 255 0 0 1 Werkzeugmaschine||||machine tool|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 0 255 255 255 255 255 255 0 0 1 Wert||||value|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 47 255 255 255 255 255 255 0 0 1 Wicklung||||winding|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -1 47 255 255 255 255 255 255 0 0 1 Zugangskontrollsystem||||access control system|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| diff --git a/keduvocdocument/docs/kvtml-structure.txt b/keduvocdocument/docs/kvtml-structure.txt deleted file mode 100644 index 3a28920..0000000 --- a/keduvocdocument/docs/kvtml-structure.txt +++ /dev/null @@ -1,258 +0,0 @@ - - - - - generator="kvoctrain v0.7.0pre3" - cols="3" - lines="3" - title="Beispieldatei: Deutsch - Englisch/Französisch" - author="Ewald Arnold" - license="OpenContent" - remark="Beispieldatei mit allen Eigenschaften"> - - - Lektion eins - Lektion zwei - Lektion drei - Lektion vier - - -
- - die - eine - der - einer - das - ein - - - fd en - fi en - md en - mi en - nd en - ni en - - - la - une - le - un - -
- - - - ich - du - sie - er - es - wir - ihr - sie - sie - sie - - - I - you - he - she - it - we - you - they - - - je - tu - elle - il - nous - vous - elles - ils - - - - - - - - - Mein Typ 1 - Mein Typ 2 - Mein Typ 3 - - - - Benutzer-Konjugation 1 - - - - Benutzersprachebene 1 - - - - s="1" - t="v"> - - - l="de" - charset="ISO 8859-1" - y="laufen"> - - - - > - - gehe - gehst - geht - gehen - gehen - gehen - schwammschwammst - - gehen - - - - - width="208" - l="en" - g="1;2" - c="2;0" - b="1;0" - d="12312;123123" - ff="falscher Freund" - tf="Freund falscher"> - - - went - have gone - - go - - - l="fr" - charset="Unicode" - >aller - - - s="1" - t="aj"> - - - a="schlecht"> - - - gut - besser - am besten - - gut - - goodbetterbest - - good - - bonmeilleurle meilleur - - bon - - - u="anat" - >Knöchel - - - knucklescheville - - - - - \ No newline at end of file diff --git a/keduvocdocument/docs/kvtml-version1.dtd b/keduvocdocument/docs/kvtml-version1.dtd deleted file mode 100644 index 9a23f34..0000000 --- a/keduvocdocument/docs/kvtml-version1.dtd +++ /dev/null @@ -1,52 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/keduvocdocument/docs/kvtml_html_stylesheet.xsl b/keduvocdocument/docs/kvtml_html_stylesheet.xsl deleted file mode 100644 index 8cd2037..0000000 --- a/keduvocdocument/docs/kvtml_html_stylesheet.xsl +++ /dev/null @@ -1,103 +0,0 @@ - - - - - - - - - - - - <xsl:value-of select="kvtml/information/title"/> - - - - - - - -

- -
- - - - - -
-
- - -
- - -

Lesson:

- - - - - - - - - - -
-
- - - - - - - - - - - - - - - - - -
-
-
-
- - - - - - diff --git a/keduvocdocument/docs/lex-aufbau1.txt b/keduvocdocument/docs/lex-aufbau1.txt deleted file mode 100644 index cbdcf36..0000000 --- a/keduvocdocument/docs/lex-aufbau1.txt +++ /dev/null @@ -1,58 +0,0 @@ -From: Michael Werner - -Hallo Ewald, - -es freut mich, daß Dir mein VT zusagt. Wobei ich mir nicht ganz im Klaren -bin, ob es eher mein Programm oder die beigefügten Lexika sind. ;-) - -Du hast völlig Recht, daß ich der Opensource-Bewegung positiv gegenüber -stehe. - -Viele Grüße -Michael - - -----------kleine Format-Beschreibung (bitte mit Font Courier -"nichtproportional" ansehen)---------- - -Lexikon-Format-Beschreibung: - -Format eines minimalen Eintrags (mit zwei Dummy-Einträgen x und y) - 0 255 255 255 255 255 255 0 0 1 -x||||y|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| - | | | | | | - | |___________________| | | Lektionszugehörigkeit (1-9) - | | | | - | | beide Sprachseiten sind ungelernt - | | - | diese Nummern bitte unverändert übernehmen - | -Attribut: 0 für --NONE-- - -Format eines maximalen Eintrags - 0 255 255 255 255 255 255 0 0 1 -MAIN#0|SYNONYM#1|SYNONYM#2|SYNONYM#3|MAIN#1|SYNONYM#1|SYNONYM#2|SYNONYM#3|| -||||||||||||||||||||||||||||||||||||||||||||||||||||||| - - -Eine Konvertierung (zur Erstellung einer LEX-Datei) könnte nun -folgendermaßen aussehen: - -erster Schritt: -Formatkopf einer bestehenden Lexikon-Datei nehmen und vor die erste -Vokabelzeile kopieren. - - -zweiter Schritt: -0 255 255 255 255 255 255 0 0 1 an den Anfang jeder Vokabelzeile -(entspricht einem Vokabeleintrag) schreiben. Wortbestandteile durch | -trennen. Minimal muß ein MAIN#0 und ein MAIN#1 existieren und mindestens 1 -Vokabelzeile. - - -dritter Schritt: -neues Lexikon laden. Dadurch werden beim nächsten Abspeichern die Anzahl -der Vokabeleinträge und das Datum korrekt gesetzt. Die Vokabelliste wird -hierbei auch sortiert. - - diff --git a/keduvocdocument/docs/lex-aufbau2.txt b/keduvocdocument/docs/lex-aufbau2.txt deleted file mode 100644 index ea7f358..0000000 --- a/keduvocdocument/docs/lex-aufbau2.txt +++ /dev/null @@ -1,127 +0,0 @@ -# Format eines minimalen Eintrags (mit zwei Dummy-Einträgen x und y) -# 0 255 255 255 255 255 255 0 0 1 x||||y|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -# | | | | | | -# | |___________________| | | Lektionszugehörigkeit (1-9) - -? maximal 9 Lektionen? "Namen" der -Lektionen? -Das Lektionenmaximum ist auf 9 festgelegt. Die Lektionsbezeichnungen werden -weiter oben abgespeichert! Ausprobieren, dann siehst Du wo. - -# | | | | -# | | beide Sprachseiten sind ungelernt - -? 1..x = Note? -0..2 (0=ungelernt, 1=unsicher, 2=gelernt) - -# | | -# | diese Nummern bitte unverändert übernehmen - -? was bedeuten sie? - -# | -# Attribut: 0 für --NONE-- - -? weitere Attribute? -Alle aus der Eingabemaske "Edit Entry" ersichtlichen + 20 extra zu -definierenden Attributen - -# Format eines maximalen Eintrags -# 0 255 255 255 255 255 255 0 0 1 -MAIN#0|SYNONYM#1|SYNONYM#2|SYNONYM#3|MAIN#1|SYNONYM#1|SYNONYM#2|SYNONYM#3||||||||||||||||||||||||||||||||||||||||||||||||||||||||| - -? Das Lexikon beinhaltet immer 2 Sprachen, MAIN ist der "normale" Ausdruck -und -? es folgen bis zu 3 Synonyme jeweils für beide Sprachen. Was folgt -hierauf? -Alle Konjugationsformen die evtl. für das Konjugationstraining eingegeben -wurden. (siehe ITALIAN.LEX) -? Ich speichere jeweils das letzte Abfragedatum, die Anzahl der Abfragen -? und Fehler sowie eine Art Note. Gibt es dies bei dir ebenfalls? -Nein, wozu? Meiner Meinung nach, ist der Anwender am Lernen interessiert -und nicht an einer Statistikreiterei. - -? Hier der Anfang von elek.lex mit meinen Vermutungen: - -# Vocabulary Trainer V5.0 - -? 1. Zeile: Version - -# LEX|Deutsch|Englisch| 259 260 1 1 1 0 0 268 0 1 1 1 1 145 6 23 1999 255 1 1 653 0 0 0 0 0 0 0 0 0 0 1 1 1 0 1 13 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 1 1 0 0 | - -? 2. Zeile: Kennung, Sprachen 1+2 und viele Daten (aber welche ? ;-) -Programminterne: Abspeicherung der Trainingsoptionen und viele andere Infos -die meiner Meinung nach Lexikaspezifisch abgespeichert werden sollen. - -# -11 700 -verwendeter Zeichensatz -? 3. Zeile: nochmal 2 Daten -# System -? 4. Zeile: Beschreibung ? -Nein! Nochmals verwendeter Zeichensatz - -# Energie- und Automatisierungstechnik. V. Manuela Lutz. Danke. - -? 5. Zeile: nochmal Beschreibung/Herkunft ? -Eigentliche Lexikonbeschreibung - -? danach ein Stück Wörterbuch, allerdings ein anderer Aufbau als oben --> siehe Trainingsoptionen -# 1 1 der die das|he she it| -# 1 1 eine einer eines einen einem|has have had is be| -# 1 1 er sie es|his him her its| -# 1 1 wir ihr euch|in to into on at too| -# 1 1 in an auf bei|the a an| -# 1 1 zu um zur zum|out by with of off| -# 1 1 ist sind seid|something someone some| -# 1 1 dies dieser dieses|under below| -# 1 1 || -# 1 1 || - -? Zeile ohne Zahlen? --> siehe ebenfalls Trainingsoptionen -# der die das ein eine einer eines einen einem|the a an| - -? viele Leerzeilen ? --> eigene selbst zu definierende Attribute -# | -# | -# | -# | -# | -# | -# | -# | -# | -# | -# | -# | -# | -# | -# | -# | -# | -# | -# | -# | -# Sachgebiete| -# | -# | -# | -# | -# | -# | -# | -# | - -# 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 -? ab hier scheint das Lexikon zu starten, aber was bedeuten die 32 32 ... -Funktionstastenbelegungen - -# 1 0 255 255 255 255 255 255 0 0 1 Abbildung||||mapping||||||||||||||||||||||||||||||||||||||||||||||||||||||| -||||| -# 1 0 255 255 255 255 255 255 0 0 1 Abblendkappe||||anti-dazzle device|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| - -Mein Tip für Dich: Verwende das Lexikon ITALIAN.LEX von mir. Dort findest -Du die meisten Funktionen verwendet und vielleicht wird für Dich vieles -klarer, wenn Du Dich mehr mit der VT-Funktionalität auseinandersetzt. diff --git a/keduvocdocument/keduvocarticle.cpp b/keduvocdocument/keduvocarticle.cpp deleted file mode 100644 index 7eba2c0..0000000 --- a/keduvocdocument/keduvocarticle.cpp +++ /dev/null @@ -1,92 +0,0 @@ -/*************************************************************************** - - Copyright 1999-2001 Ewald Arnold - Copyright 2004, 2005, 2007 Peter Hedlund - Copyright 2007-2008 Frederik Gladhorn - - ***************************************************************************/ - -/*************************************************************************** - * * - * 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. * - * * - ***************************************************************************/ - -#include "keduvocarticle.h" -#include "keduvocwordflags.h" - -#include -#include - -class KEduVocArticle::Private -{ -public: - QMap m_articles; -}; - -KEduVocArticle::KEduVocArticle() - :d( new Private ) -{} - -KEduVocArticle::KEduVocArticle( const KEduVocArticle &other ) - :d( new Private ) -{ - d->m_articles = other.d->m_articles; -} - -KEduVocArticle &KEduVocArticle::operator= ( const KEduVocArticle& other ) -{ - d->m_articles = other.d->m_articles; - return *this; -} - -KEduVocArticle::KEduVocArticle( const QString &fem_def, const QString &fem_indef, const QString &mal_def, const QString &mal_indef, const QString &neu_def, const QString &neu_indef ) - :d( new Private ) -{ - setArticle( mal_def, KEduVocWordFlag::Singular | KEduVocWordFlag::Definite | KEduVocWordFlag::Masculine ); - setArticle( fem_def, KEduVocWordFlag::Singular | KEduVocWordFlag::Definite | KEduVocWordFlag::Feminine ); - setArticle( neu_def, KEduVocWordFlag::Singular | KEduVocWordFlag::Definite | KEduVocWordFlag::Neuter ); - - setArticle( mal_indef, KEduVocWordFlag::Singular | KEduVocWordFlag::Indefinite | KEduVocWordFlag::Masculine ); - setArticle( fem_indef, KEduVocWordFlag::Singular | KEduVocWordFlag::Indefinite | KEduVocWordFlag::Feminine ); - setArticle( neu_indef, KEduVocWordFlag::Singular | KEduVocWordFlag::Indefinite | KEduVocWordFlag::Neuter ); -} - -KEduVocArticle::~KEduVocArticle() -{ - delete d; -} - - -QString KEduVocArticle::article(const KEduVocWordFlags& flags) -{ - return d->m_articles.value(flags & (KEduVocWordFlag::genders | KEduVocWordFlag::numbers | KEduVocWordFlag::Definite | KEduVocWordFlag::Indefinite)); -} - -void KEduVocArticle::setArticle(const QString & article, const KEduVocWordFlags& flags) -{ - d->m_articles[flags & (KEduVocWordFlag::genders | KEduVocWordFlag::numbers | KEduVocWordFlag::Definite | KEduVocWordFlag::Indefinite)] = article; -} - - -bool KEduVocArticle::isArticle(const QString & article) const -{ - return d->m_articles.values().contains(article); -} - -bool KEduVocArticle::isEmpty() -{ - // we don't count empty strings as articles - foreach(const QString& s, d->m_articles) - { - if (!s.isEmpty()) - return false; - } - return true; -} - - - diff --git a/keduvocdocument/keduvocarticle.h b/keduvocdocument/keduvocarticle.h deleted file mode 100644 index 3774da3..0000000 --- a/keduvocdocument/keduvocarticle.h +++ /dev/null @@ -1,84 +0,0 @@ -/*************************************************************************** - - Copyright 1999-2001 Ewald Arnold - Copyright 2005, 2007 Peter Hedlund - Copyright 2007-2008 Frederik Gladhorn - - ***************************************************************************/ - -/*************************************************************************** - * * - * 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. * - * * - ***************************************************************************/ - -#ifndef KEDUVOCARTICLE_H -#define KEDUVOCARTICLE_H - -#include "libkeduvocdocument_export.h" - -#include - -#include "keduvocwordflags.h" - -class KEduVocWordType; -/** - * Class representing the articles of a language - * - * It contains all available articles of the language as QString - */ -class KEDUVOCDOCUMENT_EXPORT KEduVocArticle -{ -public: - - - - /** - * The constructor without arguments - */ - explicit KEduVocArticle(); - - /** copy constructor for d-pointer safety - * @param other article object to copy - */ - KEduVocArticle( const KEduVocArticle &other ); - - /** - * DEPRECATED The constructor with arguments, assumes singular! - * @param fem_def reference to a QString with the definite female article - * @param fem_indef reference to a QString with the indefinite female article - * @param mal_def reference to a QString with the definite male article - * @param mal_indef reference to a QString with the indefinite male article - * @param nat_def reference to a QString with the definite neutral article - * @param nat_indef reference to a QString with the indefinite neutral article - */ - KDE_DEPRECATED KEduVocArticle( const QString &fem_def, const QString &fem_indef, const QString &mal_def, const QString &mal_indef, const QString &nat_def, const QString &nat_indef ); - - /** - * default destructor, deletes the d pointer - */ - ~KEduVocArticle(); - - /** - * assignment operator for d-pointer copying - */ - KEduVocArticle &operator= ( const KEduVocArticle& other ); - - QString article(const KEduVocWordFlags&); - - void setArticle(const QString& article, const KEduVocWordFlags&); - - bool isArticle(const QString& article) const; - - bool isEmpty(); - -private: - class Private; - Private * const d; -}; - - -#endif diff --git a/keduvocdocument/keduvoccommon_p.h b/keduvocdocument/keduvoccommon_p.h deleted file mode 100644 index 84bca89..0000000 --- a/keduvocdocument/keduvoccommon_p.h +++ /dev/null @@ -1,16 +0,0 @@ -/*************************************************************************** - * Copyright 2007 Jeremy Whiting * - * Copyright 2007 Frederik Gladhorn * - * * - * 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. * - ***************************************************************************/ - -#ifndef KEDUVOCCOMMON_P_H -#define KEDUVOCCOMMON_P_H - -#define KVD_VERS_PREFIX " v" // kvoctrain v0.1.0 - -#endif diff --git a/keduvocdocument/keduvocconjugation.cpp b/keduvocdocument/keduvocconjugation.cpp deleted file mode 100644 index d1672df..0000000 --- a/keduvocdocument/keduvocconjugation.cpp +++ /dev/null @@ -1,230 +0,0 @@ -/*************************************************************************** - - C++ Implementation: keduvocconjugation - - ----------------------------------------------------------------------- - - begin : Di Aug 28 2007 - - copyright : (C) 2007 Frederik Gladhorn - - ----------------------------------------------------------------------- - - ***************************************************************************/ - -/*************************************************************************** - * * - * 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. * - * * - ***************************************************************************/ - -#include "keduvocconjugation.h" -#include "keduvoccommon_p.h" -#include "kvtml2defs.h" - -#include -#include -#include - -class KEduVocConjugation::Private -{ -public: - QMap m_conjugations; -}; - - -KEduVocConjugation::KEduVocConjugation() - : d( new Private ) -{} - - -KEduVocConjugation::KEduVocConjugation( const KEduVocConjugation& other ) - : d( new Private ) -{ - d->m_conjugations = other.d->m_conjugations; -} - - -KEduVocConjugation::~KEduVocConjugation() -{ - delete d; -} - -KEduVocConjugation& KEduVocConjugation::operator = ( const KEduVocConjugation& other ) -{ - d->m_conjugations = other.d->m_conjugations; - return *this; -} - -bool KEduVocConjugation::operator ==(const KEduVocConjugation& other) const -{ - return d->m_conjugations == other.d->m_conjugations; -} - - - -KEduVocText& KEduVocConjugation::conjugation(KEduVocWordFlags flags) const -{ - return d->m_conjugations[flags & (KEduVocWordFlag::persons | KEduVocWordFlag::numbers | KEduVocWordFlag::genders)]; -} - -void KEduVocConjugation::setConjugation(const KEduVocText& conjugation, KEduVocWordFlags flags) -{ - d->m_conjugations[flags & (KEduVocWordFlag::persons | KEduVocWordFlag::numbers | KEduVocWordFlag::genders)] = conjugation; -} - -bool KEduVocConjugation::isEmpty() -{ - return d->m_conjugations.count() == 0; -} - -QList< KEduVocWordFlags > KEduVocConjugation::keys() -{ - return d->m_conjugations.keys(); -} - - - -void KEduVocConjugation::toKVTML2(QDomElement & parent, const QString &tense) -{ - if (isEmpty()) { - return; - } - - QMap numbers; - numbers[0] = KEduVocWordFlag::Singular; - numbers[1] = KEduVocWordFlag::Dual; - numbers[2] = KEduVocWordFlag::Plural; - QMap persons; - persons[0] = KEduVocWordFlag::First; - persons[1] = KEduVocWordFlag::Second; - persons[2] = (KEduVocWordFlag::Flags)((int)KEduVocWordFlag::Third | (int)KEduVocWordFlag::Masculine); - persons[3] = (KEduVocWordFlag::Flags)((int)KEduVocWordFlag::Third | (int)KEduVocWordFlag::Feminine); - persons[4] = (KEduVocWordFlag::Flags)((int)KEduVocWordFlag::Third | (int)KEduVocWordFlag::Neuter); - - // write the tense tag - QDomDocument domDoc = parent.ownerDocument(); - QDomElement tenseElement = domDoc.createElement( KVTML_TENSE ); - tenseElement.appendChild( domDoc.createTextNode(tense) ); - parent.appendChild(tenseElement); - - for ( int num = 0; num <= 2; ++num) { - QDomElement numberElement = domDoc.createElement( KVTML_GRAMMATICAL_NUMBER[num] ); - for ( int person = 0; person < 5; ++person) { - if (!conjugation(numbers[num] | persons[person]).isEmpty()) { - QDomElement personElement = domDoc.createElement( KVTML_GRAMMATICAL_PERSON[person] ); - numberElement.appendChild(personElement); - conjugation(persons[person] | numbers[num]).toKVTML2(personElement); - } - } - if (numberElement.hasChildNodes()) { - parent.appendChild( numberElement ); - } - } -} - -/* - - QString first = conjugation.conjugation( - KEduVocConjugation::First, num ); - QString second = conjugation.conjugation( - KEduVocConjugation::Second, num ); - QString third_male = conjugation.conjugation( - KEduVocConjugation::ThirdMale, num ); - QString third_female = conjugation.conjugation( - KEduVocConjugation::ThirdFemale, num ); - QString third_neutral = conjugation.conjugation( - KEduVocConjugation::ThirdNeutralCommon, num ); - - if ( !first.isEmpty() || !second.isEmpty() || !third_female.isEmpty() || - !third_male.isEmpty() || !third_neutral.isEmpty() ) { - QDomElement number; - switch (num) { - case KEduVocConjugation::Singular: - number = m_domDoc.createElement( KVTML_SINGULAR ); - break; - case KEduVocConjugation::Dual: - number = m_domDoc.createElement( KVTML_DUAL ); - break; - case KEduVocConjugation::Plural: - number = m_domDoc.createElement( KVTML_PLURAL ); - break; - } - - number.appendChild( newTextElement( KVTML_1STPERSON, first ) ); - number.appendChild( newTextElement( KVTML_2NDPERSON, second ) ); - number.appendChild( newTextElement( KVTML_THIRD_MALE, third_male ) ); - number.appendChild( newTextElement( KVTML_THIRD_FEMALE, third_female ) ); - number.appendChild( newTextElement( KVTML_THIRD_NEUTRAL_COMMON, third_neutral ) ); - - conjugationElement.appendChild( number ); - } - }*/ - - - /* - for ( KEduVocWordFlag::DeclensionNumber num = KEduVocWordFlag::Singular; num <= KEduVocWordFlag::Plural; num = KEduVocWordFlag::DeclensionNumber(num +1) ) { - QDomElement numberElement = domDoc.createElement( KVTML_GRAMMATICAL_NUMBER[num] ); - for ( KEduVocWordFlag::DeclensionCase dcase = KEduVocWordFlag::Nominative; dcase < KEduVocWordFlag::DeclensionCaseMAX; dcase = KEduVocWordFlag::DeclensionCase(dcase +1) ) { - QDomElement caseElement = domDoc.createElement( KVTML_DECLENSION_CASE[dcase] ); - declension(num, dcase).toKVTML2(caseElement); - - if (caseElement.hasChildNodes()) { - numberElement.appendChild(caseElement); - } - } - if (numberElement.hasChildNodes()) { - declensionElement.appendChild(numberElement); - } - } - - */ - - - -KEduVocConjugation* KEduVocConjugation::fromKVTML2(QDomElement & parent) -{ - // sanity check - if (parent.isNull()) { - return 0; - } - - QMap numbers; - numbers[0] = KEduVocWordFlag::Singular; - numbers[1] = KEduVocWordFlag::Dual; - numbers[2] = KEduVocWordFlag::Plural; - QMap persons; - persons[0] = KEduVocWordFlag::First; - persons[1] = KEduVocWordFlag::Second; - persons[2] = (KEduVocWordFlag::Flags)((int)KEduVocWordFlag::Third | (int)KEduVocWordFlag::Masculine); - persons[3] = (KEduVocWordFlag::Flags)((int)KEduVocWordFlag::Third | (int)KEduVocWordFlag::Feminine); - persons[4] = (KEduVocWordFlag::Flags)((int)KEduVocWordFlag::Third | (int)KEduVocWordFlag::Neuter); - - - KEduVocConjugation* conjugation = new KEduVocConjugation; - - for ( int num = 0; num <= 2; num++ ) { - QDomElement numberElement = parent.firstChildElement( KVTML_GRAMMATICAL_NUMBER[num] ); - - if (numberElement.hasChildNodes()) { - for (int person = 0; person < 5; person++) { - QDomElement personElement = numberElement.firstChildElement( KVTML_GRAMMATICAL_PERSON[person] ); - if (!personElement.isNull()) { - KEduVocText text; - text.fromKVTML2(personElement); - if (text.text().isEmpty()) { - // compatibility for kde 4.0. There the text was directly below the person, not enabling grades per conjugation form. - text.setText(personElement.text()); - } - conjugation->setConjugation(text, persons[person] | numbers[num]); - } - } - } - } - return conjugation; -} - - diff --git a/keduvocdocument/keduvocconjugation.h b/keduvocdocument/keduvocconjugation.h deleted file mode 100644 index c384cfe..0000000 --- a/keduvocdocument/keduvocconjugation.h +++ /dev/null @@ -1,81 +0,0 @@ -/*************************************************************************** - - C++ Interface: keduvocconjugation - - ----------------------------------------------------------------------- - - begin : Di Aug 28 2007 - - copyright : (C) 2007 Frederik Gladhorn - - ----------------------------------------------------------------------- - - ***************************************************************************/ - -/*************************************************************************** - * * - * 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. * - * * - ***************************************************************************/ - - -#ifndef KEDUVOCCONJUGATION_H -#define KEDUVOCCONJUGATION_H - -#include "libkeduvocdocument_export.h" -#include "keduvoctext.h" -#include "keduvocwordflags.h" - -#include - -/** - * The conjugation of a verb - */ -class KEDUVOCDOCUMENT_EXPORT KEduVocConjugation -{ -public: - - /** - * The constructor - */ - explicit KEduVocConjugation(); - - KEduVocConjugation( const KEduVocConjugation& rhs ); - - ~KEduVocConjugation(); - - KEduVocConjugation& operator = ( const KEduVocConjugation& a ); - bool operator == ( const KEduVocConjugation& a ) const; - - KEduVocText& conjugation(KEduVocWordFlags flags) const; - void setConjugation(const KEduVocText& conjugation, KEduVocWordFlags flags); - - QList keys(); - - bool isEmpty(); - - /** - * Create xml for this declension - * @param parent - */ - void toKVTML2(QDomElement& parent, const QString &tense); - - /** - * Reads a declension from xml, returns 0 if it is empty - * @param parent - * @return - */ - static KEduVocConjugation* fromKVTML2(QDomElement& parent); - -private: - class Private; - Private* const d; -}; - - - -#endif // KEDUVOCCONJUGATION_H - diff --git a/keduvocdocument/keduvoccontainer.cpp b/keduvocdocument/keduvoccontainer.cpp deleted file mode 100644 index d26ca73..0000000 --- a/keduvocdocument/keduvoccontainer.cpp +++ /dev/null @@ -1,274 +0,0 @@ -/*************************************************************************** - - Copyright 2007 Jeremy Whiting - Copyright 2007 Frederik Gladhorn - - ***************************************************************************/ - -/*************************************************************************** - * * - * 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. * - * * - ***************************************************************************/ - -#include "keduvoccontainer.h" - -#include "keduvocexpression.h" - -#include -#include - -/** private class to store information about a lesson */ -class KEduVocContainer::Private -{ -public: - ~Private(); - - // properties for this lesson - QString m_name; - bool m_inPractice; - - // other lessons in the tree - KEduVocContainer *m_parentContainer; - QList < KEduVocContainer * > m_childContainers; - - EnumContainerType m_type; - - QList < KEduVocExpression* > m_childLessonEntries; - bool m_childLessonEntriesValid; - - /// Image url - KUrl m_imageUrl; -}; - -KEduVocContainer::Private::~ Private() -{ - qDeleteAll(m_childContainers); -} - -KEduVocContainer::KEduVocContainer(const QString& name, EnumContainerType type, KEduVocContainer *parent) - : d( new Private ) -{ - d->m_parentContainer = parent; - d->m_name = name; - d->m_inPractice = true; - d->m_type = type; - d->m_childLessonEntriesValid = false; -} - -KEduVocContainer::KEduVocContainer( const KEduVocContainer &other ) - : d( new Private ) -{ - d->m_name = other.d->m_name; - d->m_inPractice = other.d->m_inPractice; - d->m_type = other.d->m_type; - d->m_parentContainer = other.d->m_parentContainer; - d->m_childLessonEntriesValid = false; -} - -KEduVocContainer::~KEduVocContainer() -{ - delete d; -} - -void KEduVocContainer::appendChildContainer(KEduVocContainer * child) -{ - d->m_childContainers.append(child); - child->d->m_parentContainer = this; - - invalidateChildLessonEntries(); -} - -KEduVocContainer * KEduVocContainer::childContainer(int row) -{ - return d->m_childContainers.value(row); -} - - -KEduVocContainer * KEduVocContainer::childContainer(const QString & name) -{ - foreach (KEduVocContainer *container, d->m_childContainers) { - if (container->name() == name) { - return container; - } - } - return 0; -} - - -void KEduVocContainer::deleteChildContainer(int row) -{ - kDebug() << "Delete of container - check entry deletion!"; - delete d->m_childContainers.takeAt(row); - - invalidateChildLessonEntries(); -} - -void KEduVocContainer::removeChildContainer(int row) -{ - d->m_childContainers.removeAt(row); - invalidateChildLessonEntries(); -} - - -int KEduVocContainer::childContainerCount() const -{ - return d->m_childContainers.count(); -} - -int KEduVocContainer::row() const -{ - if (d->m_parentContainer) { - return d->m_parentContainer->d->m_childContainers.indexOf(const_cast(this)); - } - return 0; -} - - -KEduVocContainer& KEduVocContainer::operator= ( const KEduVocContainer &other ) -{ - d->m_name = other.d->m_name; - d->m_inPractice = other.d->m_inPractice; - return *this; -} - -bool KEduVocContainer::operator==(const KEduVocContainer &other) -{ - return d->m_name == other.d->m_name && - d->m_inPractice == other.d->m_inPractice -/// @todo make this return something useful - ; -} - -void KEduVocContainer::setName( const QString &name ) -{ - d->m_name = name; -} - -QString KEduVocContainer::name() -{ - return d->m_name; -} - -bool KEduVocContainer::inPractice() -{ - return d->m_inPractice; -} - -void KEduVocContainer::setInPractice(bool inPractice) -{ - d->m_inPractice = inPractice; -} - -void KEduVocContainer::removeTranslation(int translation) -{ - foreach(KEduVocContainer *childContainer, d->m_childContainers) { - childContainer->removeTranslation(translation); - } - - foreach(KEduVocExpression *entry, entries() ) { - entry->removeTranslation( translation ); - } -} - -QList< KEduVocExpression * > KEduVocContainer::entriesRecursive() -{ -// kDebug() << "entriesRecursive: " << name(); - if (!d->m_childLessonEntriesValid) { - updateChildLessonEntries(); - } - return d->m_childLessonEntries; -} - -QList< KEduVocContainer * > KEduVocContainer::childContainers() -{ - return d->m_childContainers; -} - -KEduVocContainer * KEduVocContainer::parent() -{ - return d->m_parentContainer; -} - -void KEduVocContainer::setContainerType(KEduVocContainer::EnumContainerType type) -{ - d->m_type = type; -} - -KEduVocContainer::EnumContainerType KEduVocContainer::containerType() -{ - return d->m_type; -} - - -KUrl KEduVocContainer::imageUrl() -{ - return d->m_imageUrl; -} - -void KEduVocContainer::setImageUrl(const KUrl &url) -{ - d->m_imageUrl = url; -} - -void KEduVocContainer::insertChildContainer(int row, KEduVocContainer * child) -{ - d->m_childContainers.insert(row, child); - child->d->m_parentContainer = this; - - invalidateChildLessonEntries(); -} - -void KEduVocContainer::updateChildLessonEntries() -{ - QList < KEduVocExpression* > entriesRecursive = entries(); - - foreach(KEduVocContainer *childContainer, d->m_childContainers) - foreach(KEduVocExpression * expr, childContainer->entries(Recursive)) - entriesRecursive.append(expr); - - d->m_childLessonEntries = entriesRecursive; - d->m_childLessonEntriesValid = true; -} - -void KEduVocContainer::invalidateChildLessonEntries() -{ - d->m_childLessonEntriesValid = false; - // propagate to parent - if (d->m_parentContainer) { - d->m_parentContainer->invalidateChildLessonEntries(); - } -} - -double KEduVocContainer::averageGrade(int translation, EnumEntriesRecursive recursive) -{ - // grades range from 0..7 right now - int sum = 0; - foreach (KEduVocExpression *entry, entries(recursive)) { - sum += entry->translation(translation)->grade(); - } - // make that a percentage - return (sum * 100.0/7.0)/entryCount(recursive); -} - -int KEduVocContainer::expressionsOfGrade(int translation, grade_t grade, EnumEntriesRecursive recursive) -{ - int sum = 0; - foreach (KEduVocExpression *entry, entries(recursive)) { - if (entry->translation(translation)->grade() == grade) { - sum++; - } - } - return sum; -} - -void KEduVocContainer::resetGrades(int translation, EnumEntriesRecursive recursive) -{ - foreach (KEduVocExpression *entry, entries(recursive)) { - entry->resetGrades(translation); - } -} - diff --git a/keduvocdocument/keduvoccontainer.h b/keduvocdocument/keduvoccontainer.h deleted file mode 100644 index 016aa18..0000000 --- a/keduvocdocument/keduvoccontainer.h +++ /dev/null @@ -1,163 +0,0 @@ -/*************************************************************************** - - Copyright 2007 Jeremy Whiting - Copyright 2007 Frederik Gladhorn - - ***************************************************************************/ - -/*************************************************************************** - * * - * 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. * - * * - ***************************************************************************/ - -#ifndef KEDUVOCCONTAINER_H -#define KEDUVOCCONTAINER_H - -#include "libkeduvocdocument_export.h" - -#include "keduvoctext.h" - -#include -#include - -class KEduVocExpression; - -/** class to store information about a container - that can be a lesson or word types */ -class KEDUVOCDOCUMENT_EXPORT KEduVocContainer -{ - // make this a template? - -public: - enum EnumContainerType{ - Container, - Lesson, - WordType, - Leitner - }; - - enum EnumEntriesRecursive{ - NotRecursive = 0, - Recursive = 1 - }; - - /** default constructor */ - explicit KEduVocContainer(const QString& name, EnumContainerType type, KEduVocContainer *parent = 0); - - void appendChildContainer(KEduVocContainer *child); - void insertChildContainer(int row, KEduVocContainer *child); - void deleteChildContainer(int row); - void removeChildContainer(int row); - KEduVocContainer *childContainer(int row); - - /** - * Retrieve a child container by its name - * Returns 0 if no container is found - * @param name container name - * @return the child container - */ - KEduVocContainer *childContainer(const QString& name); - - QList childContainers(); - - /** - * Find a child container - * @param name - * @return - */ -// KEduVocContainer *childContainer(const QString& name); - - int childContainerCount() const; - - int row() const; - virtual KEduVocContainer *parent(); - - /** copy constructor for d-pointer safe copying */ - KEduVocContainer( const KEduVocContainer &other ); - - /** destructor */ - virtual ~KEduVocContainer(); - - /** assignment operator */ - KEduVocContainer& operator= ( const KEduVocContainer& ); - - /** set the container name - * @param name text to set for the name - */ - void setName( const QString &name ); - - /** get the container name */ - QString name(); - - /** get a list of all entries in the container */ - virtual QList < KEduVocExpression* > entries(EnumEntriesRecursive recursive = NotRecursive) =0; - virtual int entryCount(EnumEntriesRecursive recursive = NotRecursive) =0; - virtual KEduVocExpression* entry(int row, EnumEntriesRecursive recursive = NotRecursive) =0; - - /** - * Removes a translation. This has to be called when a language is removed from a document. - * @param translation - */ - void removeTranslation(int translation); - - bool inPractice(); - void setInPractice( bool inPractice ); - - /** equality operator */ - bool operator==(const KEduVocContainer &other); - - /** - * The type of this container. @see EnumContainerType - * @return - */ - KEduVocContainer::EnumContainerType containerType(); - - /** - * Set the type of container. - * For convenience by default this is taken over from the parent, so no need to set. - * @param type the new type - */ - void setContainerType(KEduVocContainer::EnumContainerType type); - - - /** get the image url for this container if it exists */ - KUrl imageUrl(); - - /** set the image url for this container - * @param url url of the image - */ - void setImageUrl(const KUrl &url); - - double averageGrade(int translation, EnumEntriesRecursive recursive); - - int expressionsOfGrade(int translation, grade_t grade, EnumEntriesRecursive recursive); - - /** - * Remove grades from all entries of this lessons - * @param translation which translation to remove. -1 for all. - * @param recursive whether to include child lessons - */ - void resetGrades(int translation, EnumEntriesRecursive recursive); - -protected: - QList< KEduVocExpression * > entriesRecursive(); - - /** - * Set the child entry cache to invalid - */ - void invalidateChildLessonEntries(); - - /** - * Recreate the cache of entries in this lesson's child lessons. - */ - void updateChildLessonEntries(); - -private: - class Private; - Private * const d; -}; - -#endif diff --git a/keduvocdocument/keduvoccsvreader.cpp b/keduvocdocument/keduvoccsvreader.cpp deleted file mode 100644 index e3d471c..0000000 --- a/keduvocdocument/keduvoccsvreader.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/*************************************************************************** - - create a KEduVocDocument from a text file - - ----------------------------------------------------------------------- - - begin : Sat Sep 06 11:00:53 MET 1999 - - copyright : (C) 1999-2001 Ewald Arnold - - (C) 2005, 2007 Peter Hedlund - - ----------------------------------------------------------------------- - - ***************************************************************************/ - -/*************************************************************************** - * * - * 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. * - * * - ***************************************************************************/ - -#include "keduvoccsvreader.h" - -#include -#include - -#include - -#include "keduvocdocument.h" -#include "keduvoclesson.h" -#include "keduvocexpression.h" - -KEduVocCsvReader::KEduVocCsvReader( QIODevice *file ) -{ - // the file must be already open - m_inputFile = file; - m_errorMessage = ""; -} - - -bool KEduVocCsvReader::readDoc( KEduVocDocument *doc ) -{ - m_doc = doc; - - QString separator = m_doc->csvDelimiter(); - - QTextStream inputStream( m_inputFile ); - inputStream.setCodec( "UTF-8" ); - inputStream.setAutoDetectUnicode( true ); - inputStream.seek( 0 ); - - int languageCount = 0; - - KEduVocLesson* lesson = new KEduVocLesson( i18n("Vocabulary"), m_doc->lesson()); - m_doc->lesson()->appendChildContainer(lesson); - - while ( !inputStream.atEnd() ) { - QString s = inputStream.readLine(); - - if ( !s.simplified().isEmpty() ) { - KEduVocExpression* expression = new KEduVocExpression( s.split(separator) ); - languageCount = qMax( languageCount, - expression->translationIndices().count() ); - lesson->appendEntry( expression ); - } - } - - for ( int j = 0; j < languageCount; j++ ) - { - m_doc->appendIdentifier(); - } - - return true; -} diff --git a/keduvocdocument/keduvoccsvreader.h b/keduvocdocument/keduvoccsvreader.h deleted file mode 100644 index fc9613b..0000000 --- a/keduvocdocument/keduvoccsvreader.h +++ /dev/null @@ -1,44 +0,0 @@ -/*************************************************************************** - create a KEduVocDocument from a text file - ----------------------------------------------------------------------- - copyright : (C) 2007 Peter Hedlund - - ***************************************************************************/ - -/*************************************************************************** - * * - * 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. * - * * - ***************************************************************************/ - -#ifndef KEDUVOCCSVREADER_H -#define KEDUVOCCSVREADER_H - -#include - -class QIODevice; - -class KEduVocDocument; - -class KEduVocCsvReader -{ -public: - KEduVocCsvReader( QIODevice *file ); - - bool readDoc( KEduVocDocument *doc ); - - QString errorMessage() const - { - return m_errorMessage; - } - -private: - QIODevice *m_inputFile; - KEduVocDocument *m_doc; - QString m_errorMessage; -}; - -#endif diff --git a/keduvocdocument/keduvoccsvwriter.cpp b/keduvocdocument/keduvoccsvwriter.cpp deleted file mode 100644 index 32172e4..0000000 --- a/keduvocdocument/keduvoccsvwriter.cpp +++ /dev/null @@ -1,76 +0,0 @@ -/*************************************************************************** - export a KEduVocDocument to a delimited text file - ----------------------------------------------------------------------- - copyright : (C) 1999-2001 Ewald Arnold - - (C) 2007 Peter Hedlund - ***************************************************************************/ - -/*************************************************************************** - * * - * 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. * - * * - ***************************************************************************/ - -#include "keduvoccsvwriter.h" - -#include -#include - -#include - -#include "keduvocdocument.h" -#include "keduvoclesson.h" -#include "keduvocexpression.h" - -KEduVocCsvWriter::KEduVocCsvWriter( QFile *file ) -{ - // the file must be already open - m_outputFile = file; -} - - -bool KEduVocCsvWriter::writeDoc( KEduVocDocument *doc, const QString &generator ) -{ - Q_UNUSED( generator ); - - m_doc = doc; - - QString separator = m_doc->csvDelimiter(); - ; - - QTextStream outputStream; - outputStream.setDevice( m_outputFile ); - outputStream.setCodec( "UTF-8" ); - - outputStream << i18nc( "@item:intable the title of the document will be written here", "Title:" ) << separator << m_doc->title() << "\n"; - outputStream << i18nc( "@item:intable the author will be written here", "Author:" ) << separator << m_doc->author() << "\n"; - - KEduVocExpression *expression; - int idCount = m_doc->identifierCount(); - QString currentRow; - - for ( int e = 0; e < m_doc->lesson()->entryCount(KEduVocLesson::Recursive); e++ ) { - expression = m_doc->lesson()->entries(KEduVocLesson::Recursive).value( e ); - currentRow = ""; - bool sep = false; - - for ( int i = 0; i < idCount; i++ ) { - if ( !sep ) - sep = true; - else - currentRow += separator; - - currentRow += expression->translation( i )->text(); - } - - if ( !currentRow.isEmpty() ) - outputStream << currentRow << "\n"; - } - - return true; -} - diff --git a/keduvocdocument/keduvoccsvwriter.h b/keduvocdocument/keduvoccsvwriter.h deleted file mode 100644 index 19dd570..0000000 --- a/keduvocdocument/keduvoccsvwriter.h +++ /dev/null @@ -1,37 +0,0 @@ -/*************************************************************************** - export a KEduVocDocument to a delimited text file - ----------------------------------------------------------------------- - copyright : (C) 1999-2001 Ewald Arnold - - (C) 2007 Peter Hedlund - ***************************************************************************/ - -/*************************************************************************** - * * - * 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. * - * * - ***************************************************************************/ - -#ifndef KEDUVOCCSVWRITER_H -#define KEDUVOCCSVWRITER_H - -class QFile; -class QString; -class KEduVocDocument; - -class KEduVocCsvWriter -{ -public: - KEduVocCsvWriter( QFile *file ); - - bool writeDoc( KEduVocDocument *doc, const QString &generator ); - -private: - QFile *m_outputFile; - KEduVocDocument *m_doc; -}; - -#endif diff --git a/keduvocdocument/keduvocdeclension.cpp b/keduvocdocument/keduvocdeclension.cpp deleted file mode 100644 index 327c3ed..0000000 --- a/keduvocdocument/keduvocdeclension.cpp +++ /dev/null @@ -1,160 +0,0 @@ -/*************************************************************************** - - C++ Implementation: keduvocdeclension - - ----------------------------------------------------------------------- - - begin : Do Sep 20 2007 - - copyright : (C) 2007 Frederik Gladhorn - - ----------------------------------------------------------------------- - - ***************************************************************************/ - -/*************************************************************************** - * * - * 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. * - * * - ***************************************************************************/ - -#include "keduvocdeclension.h" - -#include "kvtml2defs.h" -#include "keduvockvtml2writer.h" -#include - -#include - -class KEduVocDeclension::Private -{ -public: - QMap m_declensions; -}; - -KEduVocDeclension::KEduVocDeclension() - :d (new Private) -{ -} - -KEduVocDeclension::KEduVocDeclension(const KEduVocDeclension & other) - :d (new Private) -{ - d->m_declensions = other.d->m_declensions; -} - -KEduVocDeclension & KEduVocDeclension::operator =(const KEduVocDeclension & other) -{ - d->m_declensions = other.d->m_declensions; - return *this; -} - -KEduVocDeclension::~KEduVocDeclension() -{ - delete d; -} - -KEduVocText& KEduVocDeclension::declension(KEduVocWordFlags flags) -{ - return d->m_declensions[flags]; -} - -void KEduVocDeclension::setDeclension(const KEduVocText & declension, KEduVocWordFlags flags) -{ - d->m_declensions[flags] = declension; -} - -bool KEduVocDeclension::isEmpty() -{ - return d->m_declensions.isEmpty(); -} - -void KEduVocDeclension::toKVTML2(QDomElement & parent) -{ - if (isEmpty()) { - return; - } - QDomDocument domDoc = parent.ownerDocument(); - QDomElement declensionElement = domDoc.createElement( KVTML_DECLENSION ); - - QMap numbers; - numbers[0] = KEduVocWordFlag::Singular; - numbers[1] = KEduVocWordFlag::Dual; - numbers[2] = KEduVocWordFlag::Plural; - - QMap cases; - cases[0] = KEduVocWordFlag::Nominative; - cases[1] = KEduVocWordFlag::Genitive; - cases[2] = KEduVocWordFlag::Dative; - cases[3] = KEduVocWordFlag::Accusative; - cases[4] = KEduVocWordFlag::Ablative; - cases[5] = KEduVocWordFlag::Locative; - cases[6] = KEduVocWordFlag::Vocative; - - - - for ( int num = 0; num <= 2; ++num) { - QDomElement numberElement = domDoc.createElement( KVTML_GRAMMATICAL_NUMBER[num] ); - for ( int dcase = 0; dcase <= 6; ++dcase ) { - QDomElement caseElement = domDoc.createElement( KVTML_DECLENSION_CASE[dcase] ); - declension(numbers[num] | cases[dcase]).toKVTML2(caseElement); - - if (caseElement.hasChildNodes()) { - numberElement.appendChild(caseElement); - } - } - if (numberElement.hasChildNodes()) { - declensionElement.appendChild(numberElement); - } - } - if (declensionElement.hasChildNodes()) { - parent.appendChild(declensionElement); - } -} - -KEduVocDeclension* KEduVocDeclension::fromKVTML2(QDomElement & parent) -{ - QDomElement declensionElement = parent.firstChildElement( KVTML_DECLENSION ); - // we don't create empty objects, if necessary, create later on demand. - if (declensionElement.isNull()) { - return 0; - } - - - QMap numbers; - numbers[0] = KEduVocWordFlag::Singular; - numbers[1] = KEduVocWordFlag::Dual; - numbers[2] = KEduVocWordFlag::Plural; - - QMap cases; - cases[0] = KEduVocWordFlag::Nominative; - cases[1] = KEduVocWordFlag::Genitive; - cases[2] = KEduVocWordFlag::Dative; - cases[3] = KEduVocWordFlag::Accusative; - cases[4] = KEduVocWordFlag::Ablative; - cases[5] = KEduVocWordFlag::Locative; - cases[6] = KEduVocWordFlag::Vocative; - - KEduVocDeclension* declension = new KEduVocDeclension; - - for ( int num = 0; num <= 2; ++num ) { - QDomElement numberElement = declensionElement.firstChildElement( KVTML_GRAMMATICAL_NUMBER[num] ); - if (!numberElement.isNull()) { - for ( int dcase = 0; dcase <= 6; ++dcase) { - QDomElement caseElement = numberElement.firstChildElement( KVTML_DECLENSION_CASE[dcase] ); - if (!caseElement.isNull()) { - KEduVocText text; - text.fromKVTML2(caseElement); - declension->setDeclension(text, numbers[num] | cases[dcase]); - } - } - } - } - return declension; -} - - - diff --git a/keduvocdocument/keduvocdeclension.h b/keduvocdocument/keduvocdeclension.h deleted file mode 100644 index 3ac3f3d..0000000 --- a/keduvocdocument/keduvocdeclension.h +++ /dev/null @@ -1,101 +0,0 @@ -/*************************************************************************** - - C++ Interface: keduvocdeclension - - ----------------------------------------------------------------------- - - begin : Do Sep 20 2007 - - copyright : (C) 2007 Frederik Gladhorn - - ----------------------------------------------------------------------- - - ***************************************************************************/ - -/*************************************************************************** - * * - * 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. * - * * - ***************************************************************************/ -#ifndef KEDUVOCDECLENSION_H -#define KEDUVOCDECLENSION_H - -#include "libkeduvocdocument_export.h" - -#include "keduvoctext.h" -#include "keduvocwordflags.h" - -/** -A declension contains all forms that a NOUN possibly can have. - - @author Frederik Gladhorn -*/ -class KEDUVOCDOCUMENT_EXPORT KEduVocDeclension{ -public: - - /** - * The constructor without arguments - */ - explicit KEduVocDeclension(); - - /** copy constructor - * @param other comparison object to copy - */ - KEduVocDeclension( const KEduVocDeclension &other ); - - ~KEduVocDeclension(); - - /** equality operator - * @param a object to compare to - * @returns true if comparisons are the same, false otherwise - */ -// will probably not be necessary -// bool operator == ( const KEduVocDeclension& a ) const; - - /** assignment operator for d-pointer copying - * @param other object to copy from - * @returns reference to this object - */ - KEduVocDeclension& operator= ( const KEduVocDeclension& other ); - - /** - * The grammatical number, there is singular and plural for english, some languages have dual for exactly two items. - * @param gender - * @param decCase - * @return - */ - KEduVocText& declension(KEduVocWordFlags flags); - - /** - * Set a declension - * @param - * @param number - * @param decCase - */ - void setDeclension(const KEduVocText& declension, KEduVocWordFlags flags); - - bool isEmpty(); - - - /** - * Create xml for this declension - * @param parent - */ - void toKVTML2(QDomElement& parent); - - /** - * Reads a declension from xml, returns 0 if it is empty - * @param parent - * @return - */ - static KEduVocDeclension* fromKVTML2(QDomElement& parent); - -private: - class Private; - Private * const d; -}; - -#endif diff --git a/keduvocdocument/keduvocdocument.cpp b/keduvocdocument/keduvocdocument.cpp deleted file mode 100644 index b59ece7..0000000 --- a/keduvocdocument/keduvocdocument.cpp +++ /dev/null @@ -1,919 +0,0 @@ -/*************************************************************************** - Vocabulary Document for KDE Edu - ----------------------------------------------------------------------- - copyright : (C) 1999-2001 Ewald Arnold - - (C) 2005-2007 Peter Hedlund - (C) 2007 Frederik Gladhorn - ***************************************************************************/ - -/*************************************************************************** - * * - * 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. * - * * - ***************************************************************************/ - -#include "keduvocdocument.h" - -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include "keduvocexpression.h" -#include "keduvoclesson.h" -#include "keduvocleitnerbox.h" -#include "keduvocwordtype.h" -#include "keduvockvtmlwriter.h" -#include "keduvockvtml2writer.h" -#include "keduvoccsvreader.h" -#include "keduvoccsvwriter.h" -#include "keduvockvtml2reader.h" -#include "keduvocwqlreader.h" -#include "keduvocpaukerreader.h" -#include "keduvocvokabelnreader.h" -#include "keduvocxdxfreader.h" - -#define WQL_IDENT "WordQuiz" - -#define KVTML_EXT "kvtml" -#define CSV_EXT "csv" -#define TXT_EXT "txt" -#define WQL_EXT "wql" - -class KEduVocDocument::KEduVocDocumentPrivate -{ -public: - KEduVocDocumentPrivate( KEduVocDocument* qq ) - : q( qq ) - { - m_lessonContainer = 0; - m_wordTypeContainer = 0; - m_leitnerContainer = 0; - init(); - } - - ~KEduVocDocumentPrivate(); - - void init(); - - KEduVocDocument* q; - - bool m_dirty; - KUrl m_url; - - // save these to document - QList m_identifiers; - - QList m_extraSizeHints; - QList m_sizeHints; - - QString m_generator; - QString m_queryorg; - QString m_querytrans; - - QStringList m_tenseDescriptions; - QSet m_usages; - - QString m_title; - QString m_author; - QString m_authorContact; - QString m_license; - QString m_comment; - QString m_version; - QString m_csvDelimiter; - - /** Categories that can later be used to sork kvtml files: - * language, music, children, anatomy - */ - QString m_category; - - KEduVocLesson * m_lessonContainer; - KEduVocWordType * m_wordTypeContainer; - KEduVocLeitnerBox * m_leitnerContainer; -}; - -KEduVocDocument::KEduVocDocumentPrivate::~KEduVocDocumentPrivate() -{ - delete m_lessonContainer; - delete m_wordTypeContainer; - delete m_leitnerContainer; -} - -void KEduVocDocument::KEduVocDocumentPrivate::init() -{ - delete m_lessonContainer; - m_lessonContainer = new KEduVocLesson(i18nc("The top level lesson which contains all other lessons of the document.", "Document Lesson")); - m_lessonContainer->setContainerType(KEduVocLesson::Lesson); - delete m_wordTypeContainer; - m_wordTypeContainer = new KEduVocWordType(i18n( "Word types" )); - - if ( m_leitnerContainer ) { - delete m_leitnerContainer; - } - m_leitnerContainer = new KEduVocLeitnerBox(i18n( "Leitner Box" )); - - m_tenseDescriptions.clear(); - m_identifiers.clear(); - m_extraSizeHints.clear(); - m_sizeHints.clear(); - m_dirty = false; - m_queryorg = ""; - m_querytrans = ""; - m_url.setFileName( i18n( "Untitled" ) ); - m_author = ""; - m_title = ""; - m_comment = ""; - m_version = ""; - m_generator = ""; - m_csvDelimiter = QString( '\t' ); - m_usages.clear(); - m_license.clear(); - m_category.clear(); -} - - -KEduVocDocument::KEduVocDocument( QObject *parent ) - : QObject( parent ), d( new KEduVocDocumentPrivate( this ) ) -{ - kDebug() << "constructor done"; -} - - -KEduVocDocument::~KEduVocDocument() -{ - delete d; -} - - -void KEduVocDocument::setModified( bool dirty ) -{ - d->m_dirty = dirty; - emit docModified( d->m_dirty ); -} - - -KEduVocDocument::FileType KEduVocDocument::detectFileType( const QString &fileName ) -{ - QIODevice * f = KFilterDev::deviceForFile( fileName ); - if ( !f->open( QIODevice::ReadOnly ) ) { - kDebug(1100) << "Warning, could not open QIODevice for file: " << fileName; - delete f; - return Csv; - } - - QTextStream ts( f ); - QString line1; - QString line2; - - line1 = ts.readLine(); - if ( !ts.atEnd() ) { - line2 = ts.readLine(); - } - - /* - * Vokabeln.de files: - The header seems to be something like this: - - "Name - Lang1 - Lang2",123,234,456 - 0 - - or something longer: - - "Name - Lang1 - Lang2 - [..] - Blah, blah, blah...",123,234,456 - 0 - */ - - QString tmp; - - if ( line1.startsWith(QChar::fromLatin1('"'))) { - ts.seek(0); - tmp = ts.readLine(); - // There shouldn't be headers longer than 10 lines. - for ( int x=0; x < 10; x++) { - if (tmp.contains( "\"," )) { - tmp = ts.readLine(); - if (tmp.endsWith('0')) { - f->close(); - delete f; - return Vokabeln; - } - } - tmp = ts.readLine(); - } - } - f->close(); - delete f; - - - if ( line1.startsWith(QString::fromLatin1(" 0 ) { - return Pauker; - } - if ( line2.indexOf( "xdxf", 0 ) > 0 ) { - return Xdxf; - } else { - return Kvtml; - } - } - - if ( line1 == WQL_IDENT ) { - return Wql; - } - - return Csv; -} - - -int KEduVocDocument::open( const KUrl& url ) -{ - // save csv delimiter to preserve it in case this is a csv document - QString csv = d->m_csvDelimiter; - // clear all other properties - d->init(); - if ( !url.isEmpty() ) { - d->m_url = url; - } - d->m_csvDelimiter = csv; - - bool read = false; - QString errorMessage = i18n( "Cannot open file
%1
", url.path() ); - QString temporaryFile; - if ( KIO::NetAccess::download( url, temporaryFile, 0 ) ) { - QIODevice * f = KFilterDev::deviceForFile( temporaryFile ); - - if ( !f->open( QIODevice::ReadOnly ) ) { - kError() << errorMessage; - delete f; - return FileCannotRead; - } - - FileType ft = detectFileType( temporaryFile ); - - switch ( ft ) { - case Kvtml: { - kDebug(1100) << "Reading KVTML document..."; - KEduVocKvtml2Reader kvtmlReader( f ); - read = kvtmlReader.readDoc( this ); - if ( !read ) { - errorMessage = kvtmlReader.errorMessage(); - } - } - break; - - case Wql: { - kDebug(1100) << "Reading WordQuiz (WQL) document..."; - KEduVocWqlReader wqlReader( f ); - d->m_url.setFileName( i18n( "Untitled" ) ); - read = wqlReader.readDoc( this ); - if ( !read ) { - errorMessage = wqlReader.errorMessage(); - } - } - break; - - case Pauker: { - kDebug(1100) << "Reading Pauker document..."; - KEduVocPaukerReader paukerReader( this ); - d->m_url.setFileName( i18n( "Untitled" ) ); - read = paukerReader.read( f ); - if ( !read ) { - errorMessage = i18n( "Parse error at line %1, column %2:\n%3", paukerReader.lineNumber(), paukerReader.columnNumber(), paukerReader.errorString() ); - } - } - break; - - case Vokabeln: { - kDebug(1100) << "Reading Vokabeln document..."; - KEduVocVokabelnReader vokabelnReader( f ); - d->m_url.setFileName( i18n( "Untitled" ) ); - read = vokabelnReader.readDoc( this ); - if ( !read ) { - errorMessage = vokabelnReader.errorMessage(); - } - } - break; - - case Csv: { - kDebug(1100) << "Reading CVS document..."; - KEduVocCsvReader csvReader( f ); - read = csvReader.readDoc( this ); - if ( !read ) { - errorMessage = csvReader.errorMessage(); - } - } - break; - - case Xdxf: { - kDebug(1100) << "Reading XDXF document..."; - KEduVocXdxfReader xdxfReader( this ); - d->m_url.setFileName( i18n( "Untitled" ) ); - read = xdxfReader.read( f ); - if ( !read ) { - errorMessage = i18n( "Parse error at line %1, column %2:\n%3", xdxfReader.lineNumber(), xdxfReader.columnNumber(), xdxfReader.errorString() ); - } - } - break; - - default: { - kDebug(1100) << "Reading KVTML document (fallback)..."; - KEduVocKvtml2Reader kvtmlReader( f ); - read = kvtmlReader.readDoc( this ); - if ( !read ) { - errorMessage = kvtmlReader.errorMessage(); - } - } - } - - if ( !read ) { - QString msg = i18n( "Could not open or properly read \"%1\"\n(Error reported: %2)", url.path(), errorMessage ); - kError() << msg << i18n( "Error Opening File" ); - ///@todo make the readers return int, pass on the error message properly - delete f; - return FileReaderFailed; - } - - f->close(); - delete f; - KIO::NetAccess::removeTempFile( temporaryFile ); - } - - if ( !read ) { - return FileReaderFailed; - } - - setModified(false); - return 0; -} - - -int KEduVocDocument::saveAs( const KUrl & url, FileType ft, const QString & generator ) -{ - KUrl tmp( url ); - - if ( ft == Automatic ) { - if ( tmp.path().right( strlen( "." KVTML_EXT ) ) == "." KVTML_EXT ) - ft = Kvtml; - else if ( tmp.path().right( strlen( "." CSV_EXT ) ) == "." CSV_EXT ) - ft = Csv; - else { - return FileTypeUnknown; - } - } - - QFile f( tmp.path() ); - - if ( !f.open( QIODevice::WriteOnly ) ) { - kError() << i18n( "Cannot write to file %1", tmp.path() ); - return FileCannotWrite; - } - - bool saved = false; - - switch ( ft ) { - case Kvtml: { - // write version 2 file - KEduVocKvtml2Writer kvtmlWriter( &f ); - saved = kvtmlWriter.writeDoc( this, generator ); - } - break; - ///@todo port me -// case Kvtml1: { -// // write old version 1 file -// KEduVocKvtmlWriter kvtmlWriter( &f ); -// saved = kvtmlWriter.writeDoc( this, generator ); -// } -// break; - case Csv: { - KEduVocCsvWriter csvWriter( &f ); - saved = csvWriter.writeDoc( this, generator ); - } - break; - default: { - kError() << "kvcotrainDoc::saveAs(): unknown filetype" << endl; - } - break; - } // switch - - f.close(); - - if ( !saved ) { - kError() << "Error Saving File" << tmp.path(); - return FileWriterFailed; - } - - d->m_url = tmp; - setModified( false ); - return 0; -} - -QByteArray KEduVocDocument::toByteArray(const QString &generator) -{ - // no file needed - KEduVocKvtml2Writer kvtmlWriter(0); - return kvtmlWriter.toByteArray( this, generator ); -} - -void KEduVocDocument::merge( KEduVocDocument *docToMerge, bool matchIdentifiers ) -{ - Q_UNUSED(docToMerge) - Q_UNUSED(matchIdentifiers) - kDebug(1100) << "Merging of docs is not implemented"; /// @todo IMPLEMENT ME - // This code was really horribly broken. - // Now with the new classes we could attempt to reactivate it. - // A rewrite might be easier. - - /* - if (docToMerge) { - - QStringList new_names = docToMerge->lessonDescriptions(); - - QStringList new_types = docToMerge->typeDescriptions(); - - QStringList new_tenses = docToMerge->tenseDescriptions(); - - QList old_in_query = lessonsInPractice(); - QList new_in_query = docToMerge->lessonsInPractice(); - - QStringList new_usages = docToMerge->usageDescriptions(); - - int lesson_offset = d->m_lessonDescriptions.count(); - for (int i = 0; i < new_names.count(); i++) { - d->m_lessonDescriptions.append(new_names[i]); - } - - for (int i = 0; i < new_in_query.count(); i++) - old_in_query.append(new_in_query[i] + lesson_offset); - setLessonsInPractice(old_in_query); - - int types_offset = d->m_typeDescriptions.count(); - for (int i = 0; i < new_types.count(); i++) { - d->m_typeDescriptions.append(new_types[i]); - } - - int tenses_offset = d->m_tenseDescriptions.count(); - for (int i = 0; i < new_tenses.count(); i++) { - d->m_tenseDescriptions.append(new_tenses[i]); - } - - int usages_offset = d->m_usageDescriptions.count(); - for (int i = 0; i < new_usages.count(); i++) { - d->m_usageDescriptions.append(new_usages[i]); - } - - bool equal = true; - if (originalIdentifier() != docToMerge->originalIdentifier()) - equal = false; - for (int i = 1; i < identifierCount(); i++) - if (identifier(i) != docToMerge->identifier(i)) - equal = false; - - if (!matchIdentifiers) - equal = true; ///@todo massive cheating, problem if docToMerge has more identifiers than this - - if (equal) { // easy way: same language codes, just append - - for (int i = 0; i < docToMerge->entryCount(); i++) { - KEduVocExpression *expr = docToMerge->entry(i); - - expr->setLesson(expr->lesson() + lesson_offset); - - for (int lang = 0; lang <= expr->translationCount(); lang++) { - QString t = expr->translation(lang).type(); - // adjust type offset - if (!t.isEmpty() && t.left(1) == QM_USER_TYPE) { - QString t2; - t.remove(0, 1); - t2.setNum(t.toInt() + types_offset); - t2.prepend(QM_USER_TYPE); - expr->translation(lang).setType (t2); - } - - t = expr->translation(lang).usageLabel(); - // adjust usage offset - QString tg; - if (!t.isEmpty()) { - QString t2; - while (t.left(strlen(":")) == UL_USER_USAGE) { - QString n; - t.remove(0, 1); - int next; - if ((next = t.indexOf(":")) >= 0) { - n = t.left(next); - t.remove(0, next + 1); - } - else { - n = t; - t = ""; - } - - t2.setNum(n.toInt() + usages_offset); - t2.prepend(UL_USER_USAGE); - if (tg.length() == 0) - tg = t2; - else - tg += ':' + t2; - } - - if (tg.length() == 0) - tg = t; - else if (t.length() != 0) - tg += ':' + t; - - expr->translation(lang).setUsageLabel (tg); - } - - KEduVocConjugation conj = expr->translation(lang).conjugation(); - bool condirty = false; - for (int ci = 0; ci < conj.entryCount(); ci++) { - t = conj.getType(ci); - if (!t.isEmpty() && t.left(1) == UL_USER_TENSE) { - t.remove(0, strlen(UL_USER_TENSE)); - QString t2; - t2.setNum(t.toInt() + tenses_offset); - t2.prepend(UL_USER_TENSE); - conj.setType(ci, t2); - condirty = true; - } - if (condirty) - expr->translation(lang).setConjugation(conj); - } - } - - appendEntry(expr); - } - setModified(); - } - else { // hard way: move entries around, most attributes get lost - QList move_matrix; - QList cs_equal; - QString s; - - for (int i = 0; i < qMax (identifierCount(), docToMerge->identifierCount()); i++) - cs_equal.append(false); - - move_matrix.append(docToMerge->indexOfIdentifier(originalIdentifier())); - for (int i = 1; i < identifierCount(); i++) - move_matrix.append(docToMerge->indexOfIdentifier(identifier(i))); - - for (int j = 0; j < docToMerge->entryCount(); j++) { - KEduVocExpression new_expr; - KEduVocExpression *expr = docToMerge->entry(j); - new_expr.setLesson(expr->lesson()+lesson_offset); - - for (int i = 0; i < move_matrix.count(); i++) { - int lpos = move_matrix[i]; - if (lpos >= 0) { - - if (lpos == 0) - s = expr->original(); - else - s = expr->translation(lpos); - - if (!cs_equal[lpos]) { - cs_equal[lpos] = true; - QString id = lpos == 0 ? originalIdentifier() : identifier(lpos); - } - - if (i == 0) - new_expr.setOriginal(s); - else - new_expr.setTranslation(i, s); - QString r = expr->remark(lpos); - new_expr.setRemark (i, r); - - QString t = expr->type(lpos); - if (!t.isEmpty() && t.left(1) == QM_USER_TYPE) { - QString t2; - t.remove(0, 1); - t2.setNum(t.toInt() + types_offset); - t2.prepend(QM_USER_TYPE); - new_expr.setType(i, t2); - } - - t = expr->usageLabel(lpos); - if (!t.isEmpty() && t.left(1) == QM_USER_TYPE) { - QString t2; - t.remove(0, 1); - t2.setNum(t.toInt() + usages_offset); - t2.prepend(QM_USER_TYPE); - new_expr.setUsageLabel(i, t2); - } - - KEduVocConjugation conj = expr->conjugation(lpos); - for (int ci = 0; ci < conj.entryCount(); ci++) { - t = conj.getType(ci); - if (!t.isEmpty() && t.left(1) == QM_USER_TYPE) { - t.remove (0, strlen(QM_USER_TYPE)); - QString t2; - t2.setNum(t.toInt() + tenses_offset); - t2.prepend(QM_USER_TYPE); - conj.setType(ci, t2); - } - } - - } - } - // only append if entries are used - bool used = !new_expr.original().isEmpty(); - for (int i = 1; i < identifierCount(); i++) - if (!new_expr.translation(i).isEmpty()) - used = true; - - if (used) { - appendEntry(&new_expr); - setModified(); - } - } - } - } - */ -} - -const KEduVocIdentifier& KEduVocDocument::identifier( int index ) const -{ - if ( index < 0 || index >= d->m_identifiers.size() ) { - kError() << " Error: Invalid identifier index: " << index; - } - return d->m_identifiers[index]; -} - -KEduVocIdentifier& KEduVocDocument::identifier( int index ) -{ - if ( index < 0 || index >= d->m_identifiers.size() ) { - kError() << " Error: Invalid identifier index: " << index; - } - return d->m_identifiers[index]; -} - -void KEduVocDocument::setIdentifier( int idx, const KEduVocIdentifier &id ) -{ - if ( idx >= 0 && idx < d->m_identifiers.size() ) { - d->m_identifiers[idx] = id; - } - setModified(true); -} - -// works if const is removed -int KEduVocDocument::indexOfIdentifier( const QString &name ) const -{ - for (int i = 0; i < identifierCount(); i++) - if (identifier(i).locale() == name) - return i; - return -1; -} - -void KEduVocDocument::removeIdentifier( int index ) -{ - if ( index < d->m_identifiers.size() && index >= 0 ) { - d->m_identifiers.removeAt( index ); - d->m_lessonContainer->removeTranslation( index ); - } -} - - -bool KEduVocDocument::isModified() const -{ - return d->m_dirty; -} - - -int KEduVocDocument::identifierCount() const -{ - return d->m_identifiers.count(); // number of translations -} - -int KEduVocDocument::appendIdentifier( const KEduVocIdentifier& id ) -{ - int i = d->m_identifiers.size(); -//kDebug(1100) << "appendIdentifier: " << i << id.name() << id.locale(); - d->m_identifiers.append( id ); - if ( id.name().isEmpty() ) { - if ( i == 0 ) { - identifier(i).setName(i18nc("The name of the first language/column of vocabulary, if we have to guess it.", "Original")); - } else { - identifier(i).setName(i18nc( "The name of the second, third ... language/column of vocabulary, if we have to guess it.", "Translation %1", i ) ); - } - } - - - return i; -} - -KEduVocLesson * KEduVocDocument::lesson() -{ - return d->m_lessonContainer; -} - -KEduVocWordType * KEduVocDocument::wordTypeContainer() -{ - return d->m_wordTypeContainer; -} - -KEduVocLeitnerBox * KEduVocDocument::leitnerContainer() -{ - return d->m_leitnerContainer; -} - -KUrl KEduVocDocument::url() const -{ - return d->m_url; -} - -void KEduVocDocument::setUrl( const KUrl& url ) -{ - d->m_url = url; -} - -QString KEduVocDocument::title() const -{ - if ( d->m_title.isEmpty() ) - return d->m_url.fileName(); - else - return d->m_title; -} - -void KEduVocDocument::setTitle( const QString & title ) -{ - d->m_title = title; - d->m_lessonContainer->setName(title); - setModified(true); -} - -QString KEduVocDocument::author() const -{ - return d->m_author; -} - -void KEduVocDocument::setAuthor( const QString & s ) -{ - d->m_author = s.simplified(); - setModified(true); -} - -QString KEduVocDocument::authorContact() const -{ - return d->m_authorContact; -} - -void KEduVocDocument::setAuthorContact( const QString & s ) -{ - d->m_authorContact = s.simplified(); - setModified(true); -} - -QString KEduVocDocument::license() const -{ - return d->m_license; -} - -QString KEduVocDocument::documentComment() const -{ - return d->m_comment; -} - -void KEduVocDocument::setCategory( const QString & category ) -{ - d->m_category = category; - setModified(true); -} - -QString KEduVocDocument::category() const -{ - return d->m_category; - ///@todo make writer/reader use this -} - -void KEduVocDocument::queryIdentifier( QString &org, QString &trans ) const -{ - org = d->m_queryorg; - trans = d->m_querytrans; -} - -void KEduVocDocument::setQueryIdentifier( const QString &org, const QString &trans ) -{ - d->m_queryorg = org; - d->m_querytrans = trans; - setModified(true); -} - -void KEduVocDocument::setLicense( const QString & s ) -{ - d->m_license = s.simplified(); - setModified(true); -} - -void KEduVocDocument::setDocumentComment( const QString & s ) -{ - d->m_comment = s.trimmed(); - setModified(true); -} - -void KEduVocDocument::setGenerator( const QString & generator ) -{ - d->m_generator = generator; - setModified(true); -} - -QString KEduVocDocument::generator() const -{ - return d->m_generator; -} - -QString KEduVocDocument::version() const -{ - return d->m_version; -} - -void KEduVocDocument::setVersion( const QString & vers ) -{ - d->m_version = vers; - setModified(true); -} - -QString KEduVocDocument::csvDelimiter() const -{ - return d->m_csvDelimiter; -} - -void KEduVocDocument::setCsvDelimiter( const QString &delimiter ) -{ - d->m_csvDelimiter = delimiter; - setModified(true); -} - - -QString KEduVocDocument::pattern( FileDialogMode mode ) -{ - static const struct SupportedFilter { - bool reading; - bool writing; - const char* extensions; - const char* description; - } - filters[] = { - { true, true, "*.kvtml", I18N_NOOP( "KDE Vocabulary Document" ) }, - { true, false, "*.wql", I18N_NOOP( "KWordQuiz Document" ) }, - { true, false, "*.xml.qz *.pau.gz", I18N_NOOP( "Pauker Lesson" ) }, - { true, false, "*.voc", I18N_NOOP( "Vokabeltrainer" ) }, - { true, false, "*.xdxf", I18N_NOOP( "XML Dictionary Exchange Format" ) }, - { true, true, "*.csv", I18N_NOOP( "Comma Separated Values (CSV)" ) }, - // last is marker for the end, do not remove it - { false, false, 0, 0 } - }; - QStringList newfilters; - QStringList allext; - for ( int i = 0; filters[i].extensions; ++i ) { - if (( mode == Reading && filters[i].reading ) || - ( mode == Writing && filters[i].writing ) ) { - newfilters.append( QLatin1String( filters[i].extensions ) + '|' + i18n( filters[i].description ) ); - allext.append( QLatin1String( filters[i].extensions ) ); - } - } - if ( mode == Reading ) { - newfilters.prepend( allext.join( " " ) + '|' + i18n( "All supported documents" ) ); - } - return newfilters.join( "\n" ); -} - -QString KEduVocDocument::errorDescription( int errorCode ) -{ - switch (errorCode) { - case NoError: - return i18n("No error found."); - - case InvalidXml: - return i18n("Invalid XML in document."); - case FileTypeUnknown: - return i18n("Unknown file type."); - case FileCannotWrite: - return i18n("File is not writeable."); - case FileWriterFailed: - return i18n("File writer failed."); - case FileCannotRead: - return i18n("File is not readable."); - case FileReaderFailed: - return i18n("The file reader failed."); - case FileDoesNotExist: - return i18n("The file does not exist."); - case Unknown: - default: - return i18n("Unknown error."); - } -} - -#include "keduvocdocument.moc" - diff --git a/keduvocdocument/keduvocdocument.h b/keduvocdocument/keduvocdocument.h deleted file mode 100644 index dcbf2d7..0000000 --- a/keduvocdocument/keduvocdocument.h +++ /dev/null @@ -1,339 +0,0 @@ -/*************************************************************************** - Vocabulary Document for KDE Edu - ----------------------------------------------------------------------- - copyright : (C) 1999-2001 Ewald Arnold - - (C) 2005, 2007 Peter Hedlund - (C) 2007 Frederik Gladhorn - ***************************************************************************/ - -/*************************************************************************** - * * - * 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. * - * * - ***************************************************************************/ - -#ifndef KEDUVOCDOCUMENT_H -#define KEDUVOCDOCUMENT_H - -#include "libkeduvocdocument_export.h" - -#include "keduvocidentifier.h" -#include "keduvocarticle.h" -#include "keduvocconjugation.h" - -#include -#include -#include - -#include - -class QStringList; -class KEduVocExpression; -class KEduVocLesson; -class KEduVocWordType; -class KEduVocLeitnerBox; - -/** - * This class contains the expressions of your vocabulary - * as well as other information about the vocabulary - */ -class KEDUVOCDOCUMENT_EXPORT KEduVocDocument : public QObject -{ - Q_OBJECT -public: - - /// known vocabulary file types - enum FileType { - KvdNone, - Automatic, - Kvtml, - Wql, - Pauker, - Vokabeln, - Xdxf, - Csv, - Kvtml1 - }; - - /// the return code when opening/saving - enum ErrorCode { - NoError = 0, - Unknown, - InvalidXml, - FileTypeUnknown, - FileCannotWrite, - FileWriterFailed, - FileCannotRead, - FileReaderFailed, - FileDoesNotExist - }; - - /// used as parameter for pattern - enum FileDialogMode - { - Reading, - Writing - }; - - /// delete only empty lessons or also if they have entries - enum LessonDeletion - { - DeleteEmptyLesson, - DeleteEntriesAndLesson - }; - - /** - * Constructor for a KdeEdu vocabulary document - * - * @param parent calling object - */ - explicit KEduVocDocument( QObject* parent = 0 ); - - /** - * Destructor - */ - ~KEduVocDocument(); - - // *** whole document methods *** - - /** - * Open a document file - * - * @param url url to file to open - * @returns ErrorCode - */ - int open( const KUrl& url ); - - /** - * Saves the data under the given name - * - * @param url if url is empty (or NULL) actual name is preserved - * @param ft the filetype to be used when saving the document - * @param generator the name of the application saving the document - * @returns ErrorCode - */ - int saveAs( const KUrl & url, FileType ft, const QString & generator ); - - QByteArray toByteArray(const QString &generator); - - /** - * Merges data from another document - * - * @param docToMerge document containing the data to be merged - * @param matchIdentifiers if true only entries having identifiers present in the - * current document will be mergedurl is empty (or NULL) actual name is preserved - */ - void merge( KEduVocDocument *docToMerge, bool matchIdentifiers ); - - /** - * Indicates if the document is modified - * - * @param dirty new state - */ - void setModified( bool dirty = true ); - - /** @returns the modification state of the doc */ - bool isModified() const; - - /** - * Sets the URL of the XML file - */ - void setUrl( const KUrl& url ); - - /** @returns the URL of the XML file */ - KUrl url() const; - - - /** set the title of the file - * @param title title to set */ - void setTitle( const QString & title ); - - /** @returns the title of the file */ - QString title() const; - - /** set the author of the file - * @param author author to set */ - void setAuthor( const QString & author ); - - /** @returns the author of the file */ - QString author() const; - - /** set the author contact info - * @param contact email/contact info to set */ - void setAuthorContact( const QString & authorContact ); - - /** @returns the author contact information */ - QString authorContact() const; - - /** set the license of the file - * @param license license to set */ - void setLicense( const QString & license ); - - /** @returns the license of the file */ - QString license() const; - - /** set the comment of the file - * @param comment comment to set */ - void setDocumentComment( const QString & comment ); - - /** @return the comment of the file */ - QString documentComment() const; - - /** set the category of the file - * @param category category to set */ - void setCategory( const QString & category ); - - /** @return the category of the file */ - QString category() const; - - /** - * Sets the generator of the file - */ - void setGenerator( const QString & generator ); - - /** @returns the generator of the file */ - QString generator() const; - - /** Sets version of the loaded file - * @param ver the new version */ - void setVersion( const QString & ver ); - - /** @returns the version of the loaded file */ - QString version() const; - - // *** identifier methods *** - - /** - * @returns the number of different identifiers (usually languages) - */ - int identifierCount() const; - - /** - * Appends a new identifier (usually a language) - * - * @param identifier the identifier to append. If empty default names are used. - * @returns the identifier number - */ - int appendIdentifier( const KEduVocIdentifier & identifier = KEduVocIdentifier()); - - /** - * Sets the identifier of translation - * - * @param index number of translation 0..x - * @param lang thr language identifier: en=english, de=german, ... - */ - void setIdentifier( int index, const KEduVocIdentifier& lang ); - - /** - * Returns the identifier of translation @p index - * - * @param index number of translation 0..x - * @returns the language identifier: en=english, de=german, ... - */ - KEduVocIdentifier& identifier( int index ); - - /** - * Const overload of identifier(int); - */ - const KEduVocIdentifier& identifier( int index ) const; - - /** - * Removes identifier and the according translations in all entries - * - * @param index number of translation 0..x - */ - void removeIdentifier( int index ); - - /** - * Determines the index of a given identifier - * - * @param lang identifier of language - * @returns index of identifier, 0 = original, 1..n = translation, -1 = not found - */ - int indexOfIdentifier( const QString &name ) const; - - // *** grade methods *** - - /** - * Retrieves the identifiers for the current query - * not written in the new version! - * - * @param org identifier for original - * @param trans identifier for translation - */ - KDE_DEPRECATED void queryIdentifier( QString &org, QString &trans ) const; - - /** - * Sets the identifiers for the current query - * not written in the new version! - * - * @param org identifier for original - * @param trans identifier for translation - */ - KDE_DEPRECATED void setQueryIdentifier( const QString &org, const QString &trans ); - - // *** lesson methods *** - - /** get the lesson root object - * @returns a pointer to the lesson object - */ - KEduVocLesson * lesson(); - - KEduVocWordType * wordTypeContainer(); - - KEduVocLeitnerBox * leitnerContainer(); - - // *** file format specific methods *** - - /** - * Returns the delimiter (separator) used for csv import and export. - * The default is a single tab character - * - * @returns the delimiter used - */ - QString csvDelimiter() const; - - /** - * Sets the delimiter (separator) used for csv import and export - * - * @param delimiter the delimiter to use - */ - void setCsvDelimiter( const QString &delimiter ); - - static FileType detectFileType( const QString &fileName ); - - /** - * Create a string with the supported document types, that can be used - * as filter in KFileDialog. It includes also an entry to match all the - * supported types. - * - * @param mode the mode for the supported document types - * @returns the filter string - */ - static QString pattern( FileDialogMode mode ); - - static QString errorDescription( int errorCode ); - -Q_SIGNALS: - void progressChanged( KEduVocDocument *, int curr_percent ); - - /** - * Emitted when the document becomes modified or saved. - * @returns state (true=modified) - */ - void docModified( bool mod ); - -private: - // The private data of this - see KEduVocDocument::Private, implemented in keduvocdocument.cpp - class KEduVocDocumentPrivate; - KEduVocDocumentPrivate* const d; - - Q_DISABLE_COPY( KEduVocDocument ) -}; - - -#endif // KEDUVOCDOCUMENT_H diff --git a/keduvocdocument/keduvocexpression.cpp b/keduvocdocument/keduvocexpression.cpp deleted file mode 100644 index 63d5ac3..0000000 --- a/keduvocdocument/keduvocexpression.cpp +++ /dev/null @@ -1,216 +0,0 @@ -/*************************************************************************** - Vocabulary Expression for KDE Edu - ----------------------------------------------------------------------- - copyright : (C) 1999-2001 Ewald Arnold - - (C) 2005-2007 Peter Hedlund - Copyright 2008 Frederik Gladhorn - ***************************************************************************/ - -/*************************************************************************** - * * - * 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. * - * * - ***************************************************************************/ - - -#include "keduvocexpression.h" - -#include - - -class KEduVocExpression::KEduVocExpressionPrivate -{ -public: - KEduVocExpressionPrivate() - { - m_active = true; - m_lesson = 0; - } - ~KEduVocExpressionPrivate(); - - KEduVocExpressionPrivate(const KEduVocExpressionPrivate &other); - KEduVocExpressionPrivate& operator= (const KEduVocExpressionPrivate &other); - - bool operator== ( const KEduVocExpressionPrivate &p ) const; - - KEduVocLesson* m_lesson; - bool m_active; - - QMap m_translations; -}; - -KEduVocExpression::KEduVocExpressionPrivate::~KEduVocExpressionPrivate() -{ - QMap translations = m_translations; - // empty the translations map, otherwise removal from word type will try to access them again when they don't exist any more - m_translations.clear(); - qDeleteAll(translations); -} - -KEduVocExpression::KEduVocExpressionPrivate::KEduVocExpressionPrivate(const KEduVocExpressionPrivate & other) -{ - m_active = other.m_active; - m_lesson = 0; -} - -KEduVocExpression::KEduVocExpressionPrivate & KEduVocExpression::KEduVocExpressionPrivate::operator =(const KEduVocExpressionPrivate & other) -{ - m_active = other.m_active; - m_lesson = 0; - - return *this; -} - -bool KEduVocExpression::KEduVocExpressionPrivate::operator== ( const KEduVocExpression::KEduVocExpressionPrivate &p ) const -{ - return - m_translations == p.m_translations && - m_lesson == p.m_lesson && - m_active == p.m_active; -} - - -KEduVocExpression::KEduVocExpression() - : d( new KEduVocExpressionPrivate ) -{} - -KEduVocExpression::KEduVocExpression( const QString & expression ) - : d( new KEduVocExpressionPrivate ) -{ - setTranslation( 0, expression.simplified() ); -} - -KEduVocExpression::KEduVocExpression( const QStringList & translations) - : d( new KEduVocExpressionPrivate ) -{ - foreach ( const QString &translation, translations ) { - setTranslation(d->m_translations.count(), translation); - } -} - - -KEduVocExpression::KEduVocExpression(const KEduVocExpression & other) - : d(new KEduVocExpressionPrivate(*other.d)) -{ - foreach (int key, other.d->m_translations.keys()) { - d->m_translations[key] = new KEduVocTranslation(*other.d->m_translations.value(key)); - d->m_translations[key]->setEntry(this); - } -} - -KEduVocExpression& KEduVocExpression::operator= ( const KEduVocExpression &other ) -{ - *d = *other.d; - foreach (int key, other.d->m_translations.keys()) { - d->m_translations[key] = new KEduVocTranslation(*other.d->m_translations.value(key)); - d->m_translations[key]->setEntry(this); - } - return *this; -} - -KEduVocExpression::~KEduVocExpression() -{ - setLesson(0); - delete d; -} - -void KEduVocExpression::removeTranslation( int index ) -{ - int count = d->m_translations.count(); - - // remove the index we delete - delete d->m_translations.take(index); - - // shift all other indexes, +1 for the deleted - for (int j = index; j < count-1; j++) { - d->m_translations[j] = d->m_translations.take(j+1); - } -} - - -void KEduVocExpression::setTranslation( int index, const QString & expr ) -{ - if ( index < 0 ) { - return; - } - - if (!d->m_translations.contains(index)) { - d->m_translations[index] = new KEduVocTranslation(this); - } - d->m_translations[index]->setText(expr.simplified()); -} - - -KEduVocLesson* KEduVocExpression::lesson() const -{ - return d->m_lesson; -} - - -bool KEduVocExpression::isActive() const -{ - return d->m_active; -} - - -void KEduVocExpression::setActive( bool flag ) -{ - d->m_active = flag; -} - - -void KEduVocExpression::resetGrades( int index ) -{ - if ( index == -1 ) { // clear grades for all languages - foreach( KEduVocTranslation* trans, d->m_translations ) { - trans->resetGrades(); - } - return; - } - - // only language index - if ( d->m_translations.contains( index ) ) { - d->m_translations[index]->resetGrades(); - } -} - -bool KEduVocExpression::operator== ( const KEduVocExpression &expression ) const -{ - return ( *d == *expression.d ); -} - -KEduVocTranslation* KEduVocExpression::translation( int index ) -{ - if(translationIndices().contains(index)) { - return d->m_translations[index]; - } - d->m_translations[index] = new KEduVocTranslation(this); - return d->m_translations[index]; -} - -KEduVocTranslation * KEduVocExpression::translation(int index) const -{ - if(d->m_translations.contains(index)) { - return 0; - } - return d->m_translations[index]; -} - -QList< int > KEduVocExpression::translationIndices() const -{ - return d->m_translations.keys(); -} - -void KEduVocExpression::setLesson(KEduVocLesson * l) -{ - if (d->m_lesson) { - d->m_lesson->removeEntry(this); - } - d->m_lesson = l; -} - - diff --git a/keduvocdocument/keduvocexpression.h b/keduvocdocument/keduvocexpression.h deleted file mode 100644 index 373033a..0000000 --- a/keduvocdocument/keduvocexpression.h +++ /dev/null @@ -1,123 +0,0 @@ -/*************************************************************************** - Vocabulary Expression for KDE Edu - ----------------------------------------------------------------------- - copyright : (C) 1999-2001 Ewald Arnold - - (C) 2005-2007 Peter Hedlund - Copyright 2008 Frederik Gladhorn - ***************************************************************************/ - -/*************************************************************************** - * * - * 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. * - * * - ***************************************************************************/ - -#ifndef KEDUVOCEXPRESSION_H -#define KEDUVOCEXPRESSION_H - -#include "libkeduvocdocument_export.h" - -#include - -#include "keduvoclesson.h" -#include "keduvocarticle.h" -#include "keduvocmultiplechoice.h" -#include "keduvoctranslation.h" - -class KEduVocLesson; - -/** - This class contains one vocabulary expression as an original with one or more - translations - */ -class KEDUVOCDOCUMENT_EXPORT KEduVocExpression -{ -public: - - /** default constructor for an empty vocabulary expression - */ - explicit KEduVocExpression(); - - /** Constructor for a vocabulary expression with one translation - * - * @param expression translation - * @param lesson lesson number - */ - explicit KEduVocExpression( const QString & expression ); - - /** Constructor for a vocabulary expression with an original and one or more translations - * - * @param expression expression - * @param separator expression will be split into an original and one or more translations using separator - * @param lesson lesson number, 0 for none - */ - explicit KEduVocExpression( const QStringList & translations ); - - KEduVocExpression(const KEduVocExpression& other); - - ~KEduVocExpression(); - - /** return the lesson - */ - KEduVocLesson * lesson() const; - - - /** reset all grades of the entry - * @param index identifier (language) - */ - void resetGrades( int index ); - - /** returns flag if entry is activated for queries - */ - bool isActive() const; - - /** set entry active (enabled for queries) - */ - void setActive( bool flag = true ); - - int sizeHint() const; - void setSizeHint( int sizeHint ); - - void setTranslation( int index, KEduVocTranslation* translation ); - /** - * Add a translation to this expression - * @param index number of translation = the identifier - * @param expression the translation - */ - void setTranslation( int index, const QString &expression ); - - /** removes a translation - * - * @param index number of translation 1..x - */ - void removeTranslation( int index ); - - /** - * Get a pointer to the translation - * @param index of the language identifier - * @return the translation - */ - KEduVocTranslation* translation( int index ); - KEduVocTranslation* translation( int index ) const; - - QList translationIndices() const; - - KEduVocExpression& operator= ( const KEduVocExpression &expression ); - bool operator== ( const KEduVocExpression &expression ) const; - -private: - class KEduVocExpressionPrivate; - KEduVocExpressionPrivate* const d; - - /** only called by lesson to add itself to the lesson list - */ - void setLesson( KEduVocLesson * l ); - - friend class KEduVocLesson; -}; - -#endif // KEduVocExpression_H diff --git a/keduvocdocument/keduvocidentifier.cpp b/keduvocdocument/keduvocidentifier.cpp deleted file mode 100644 index 06a3e3c..0000000 --- a/keduvocdocument/keduvocidentifier.cpp +++ /dev/null @@ -1,148 +0,0 @@ -/*************************************************************************** - Copyright 2007-2008 Frederik Gladhorn - ***************************************************************************/ - -/*************************************************************************** - * * - * 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. * - * * - ***************************************************************************/ -#include "keduvocidentifier.h" - -#include - -class KEduVocIdentifier::Private -{ -public: - /// the name: English, Anatomy, Fruit salad - QString m_name; - /// the locale: en, de, es, ... - QString m_locale; - - /** - * Let the user provide some additional informatioin about the language. - * This could be Traditional/Simplified for chinese to differentiate between them. - */ - QString m_comment; - - /** not sure yet: language|other|??? */ - QString m_type; - - /** I, you, he, she, it... */ - KEduVocPersonalPronoun m_personalPronouns; - - /** the for english ;) - der, die, das ... in german */ - KEduVocArticle m_articles; - - /** Future, present and past... and many more */ - QStringList m_tenses; -}; - -KEduVocIdentifier::KEduVocIdentifier() -: d( new Private ) -{ - ///@todo maybe the user locale would be more appropriate - d->m_locale = "en"; -} - -KEduVocIdentifier::~KEduVocIdentifier() -{ - delete d; -} - -KEduVocIdentifier::KEduVocIdentifier( const KEduVocIdentifier &other ) -: d( new Private( *other.d ) ) -{ -#if 0 - d->m_locale = other.d->m_locale; - d->m_name = other.d->m_name; - d->m_articles = other.d->m_articles; - d->m_personalPronouns = other.d->m_personalPronouns; - d->m_comment = other.d->m_comment; - d->m_tenses = other.d->m_tenses; - d->m_type = other.d->m_type; -#endif -} - -KEduVocIdentifier& KEduVocIdentifier::operator= ( const KEduVocIdentifier &other ) -{ - d->m_locale = other.d->m_locale; - d->m_name = other.d->m_name; - d->m_articles = other.d->m_articles; - d->m_personalPronouns = other.d->m_personalPronouns; - d->m_comment = other.d->m_comment; - d->m_tenses = other.d->m_tenses; - d->m_type = other.d->m_type; - return *this; -} - -QString KEduVocIdentifier::name() const -{ - return d->m_name; -} - -void KEduVocIdentifier::setName(const QString & name) -{ - d->m_name = name; -} - -QString KEduVocIdentifier::locale() const -{ - return d->m_locale; -} - -void KEduVocIdentifier::setLocale(const QString & locale) -{ - d->m_locale = locale; -} - -void KEduVocIdentifier::setArticle( const KEduVocArticle& articles ) -{ - d->m_articles = articles; -} - -KEduVocArticle& KEduVocIdentifier::article() const -{ - return d->m_articles; -} - -KEduVocPersonalPronoun& KEduVocIdentifier::personalPronouns() const -{ - return d->m_personalPronouns; -} - -void KEduVocIdentifier::setPersonalPronouns( const KEduVocPersonalPronoun & pronouns ) -{ - d->m_personalPronouns = pronouns; -} - -QString KEduVocIdentifier::tense(int tenseIndex) const -{ - Q_ASSERT(d->m_tenses.size() > tenseIndex); - return d->m_tenses.value(tenseIndex); -} - -void KEduVocIdentifier::setTense(int tenseIndex, const QString& tense) -{ - Q_ASSERT(d->m_tenses.size() >= tenseIndex); - if (tenseIndex == d->m_tenses.size()) { - d->m_tenses.append(tense); - } else { - d->m_tenses[tenseIndex] = tense; - } -} - -QStringList KEduVocIdentifier::tenseList() const -{ - return d->m_tenses; -} - -void KEduVocIdentifier::setTenseList(const QStringList& tenses) -{ - d->m_tenses = tenses; -} - diff --git a/keduvocdocument/keduvocidentifier.h b/keduvocdocument/keduvocidentifier.h deleted file mode 100644 index ca99950..0000000 --- a/keduvocdocument/keduvocidentifier.h +++ /dev/null @@ -1,125 +0,0 @@ -/*************************************************************************** - Copyright 2007-2008 Frederik Gladhorn - ***************************************************************************/ - -/*************************************************************************** - * * - * 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. * - * * - ***************************************************************************/ -#ifndef KEDUVOCIDENTIFIER_H -#define KEDUVOCIDENTIFIER_H - -#include "libkeduvocdocument_export.h" - -#include "keduvocpersonalpronoun.h" -#include "keduvocarticle.h" - -#include -#include -#include - - -/** -Class to store meta information about a language or any other category in the vocabulary. -*/ -class KEDUVOCDOCUMENT_EXPORT KEduVocIdentifier -{ -public: - /** - * Default ctor. - */ - explicit KEduVocIdentifier(); - - /** - * Copy ctor. - * @param other - */ - KEduVocIdentifier( const KEduVocIdentifier &other ); - - /** - * dtor - */ - ~KEduVocIdentifier(); - - /** - * assignment operator - * @param other - * @return - */ - KEduVocIdentifier& operator= ( const KEduVocIdentifier &other ); -public: - - /** - * Name of this identifier. (English, Anatomy, Fruit salad...) - * @return name - */ - QString name() const; - /** - * Set the name - * @param name - */ - void setName( const QString& name ); - - /** - * The locale of the contents: en, de, es, ... - * @return locale - */ - QString locale() const; - /** - * Set the locale - * @param name - */ - void setLocale( const QString& name ); - - /** - * Articles (a, the in English, el, la,... in Spanish) - * @returns articles - */ - KEduVocArticle& article() const; - - /** - * Sets the articles for this identifier - * @param art article block - */ - void setArticle( const KEduVocArticle& article ); - - /** - * Get the personal pronouns for this identifier - * @returns a KEduVocPersonalPronoun containing the personal pronouns - */ - KEduVocPersonalPronoun& personalPronouns() const; - - /** - * Sets personal pronouns - * @param pronouns a KEduVocConjugation containing the personal pronouns - */ - void setPersonalPronouns( const KEduVocPersonalPronoun &pronouns ); - - /** - * Returns the name of tense number @p tenseIndex - * @param tenseIndex desired tense - * @return name of the tense - */ - QString tense(int tenseIndex) const; - - /** - * Sets the name of a tense for this language - * @param tenseIndex - * @param tense - */ - void setTense(int tenseIndex, const QString& tense); - - QStringList tenseList() const; - - void setTenseList(const QStringList& tenses); - -private: - class Private; - Private * const d; -}; - -#endif diff --git a/keduvocdocument/keduvockvtml2reader.cpp b/keduvocdocument/keduvockvtml2reader.cpp deleted file mode 100644 index 30b6ce4..0000000 --- a/keduvocdocument/keduvockvtml2reader.cpp +++ /dev/null @@ -1,727 +0,0 @@ -/*************************************************************************** - read a KEduVocDocument from a KVTML file - ----------------------------------------------------------------------- - copyright : (C) 1999-2001 Ewald Arnold - - (C) 2005 Eric Pignet - (C) 2007 Peter Hedlund - Copyright 2007-2008 Frederik Gladhorn - ***************************************************************************/ - -/*************************************************************************** - * * - * 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. * - * * - ***************************************************************************/ - -#include "keduvockvtml2reader.h" - -#include -#include -#include - -#include - -#include "keduvocdocument.h" -#include "keduvoclesson.h" -#include "keduvocleitnerbox.h" -#include "keduvocwordtype.h" -#include "kvtml2defs.h" -#include "keduvockvtmlreader.h" -#include "keduvoccommon_p.h" - -#include - -KEduVocKvtml2Reader::KEduVocKvtml2Reader( QIODevice *file ) - : m_inputFile( file ) -{ - // the file must be already open - if ( !m_inputFile->isOpen() ) { - m_errorMessage = i18n( "file must be opened first" ); - } -} - - -bool KEduVocKvtml2Reader::readDoc( KEduVocDocument *doc ) -{ - m_doc = doc; - - QDomDocument domDoc( "KEduVocDocument" ); - - if ( !domDoc.setContent( m_inputFile, &m_errorMessage ) ) - return false; - - QDomElement domElementKvtml = domDoc.documentElement(); - if ( domElementKvtml.tagName() != KVTML_TAG ) { - m_errorMessage = i18n( "This is not a KDE Vocabulary document." ); - return false; - } - - if ( domElementKvtml.attribute( KVTML_VERSION ).toFloat() < 2.0 ) { - // read the file with the old format - - // first reset the file to the beginning - m_inputFile->seek( 0 ); - KEduVocKvtmlReader oldFormat( m_inputFile ); - - // get the return value - bool retval = oldFormat.readDoc( doc ); - - // pass the errormessage up - m_errorMessage = oldFormat.errorMessage(); - return retval; - } - - //------------------------------------------------------------------------- - // Information - //------------------------------------------------------------------------- - - QDomElement info = domElementKvtml.firstChildElement( KVTML_INFORMATION ); - if ( !info.isNull() ) { - if ( !readInformation( info ) ) - return false; - } - - bool result = readGroups( domElementKvtml ); // read sub-groups - - return result; -} - -bool KEduVocKvtml2Reader::readInformation( QDomElement &informationElement ) -{ - // read the generator - QDomElement currentElement = informationElement.firstChildElement( KVTML_GENERATOR ); - if ( !currentElement.isNull() ) { - m_doc->setGenerator( currentElement.text() ); - // add the version if it's there - int pos = m_doc->generator().lastIndexOf( KVD_VERS_PREFIX ); - if ( pos >= 0 ) { - m_doc->setVersion( m_doc->generator().remove( 0, pos + 2 ) ); - } - } - - // read the title - currentElement = informationElement.firstChildElement( KVTML_TITLE ); - if ( !currentElement.isNull() ) { - m_doc->setTitle( currentElement.text() ); - } - - // read the author - currentElement = informationElement.firstChildElement( KVTML_AUTHOR ); - if ( !currentElement.isNull() ) { - m_doc->setAuthor( currentElement.text() ); - } - - currentElement = informationElement.firstChildElement( KVTML_AUTHORCONTACT ); - if ( !currentElement.isNull() ) { - m_doc->setAuthorContact( currentElement.text() ); - } - - // read the license - currentElement = informationElement.firstChildElement( KVTML_LICENSE ); - if ( !currentElement.isNull() ) { - m_doc->setLicense( currentElement.text() ); - } - - // read the comment - currentElement = informationElement.firstChildElement( KVTML_COMMENT ); - if ( !currentElement.isNull() ) { - m_doc->setDocumentComment( currentElement.text() ); - } - - // read the category - currentElement = informationElement.firstChildElement( KVTML_CATEGORY ); - if ( !currentElement.isNull() ) { - m_doc->setCategory( currentElement.text() ); - } - - return true; -} - -bool KEduVocKvtml2Reader::readGroups( QDomElement &domElementParent ) -{ - bool result = false; - - QDomElement groupElement = domElementParent.firstChildElement( KVTML_IDENTIFIERS ); - - QDomElement currentElement; - - // ensure backwards compatibility - in kde 4.1 and earlier tenses were direct properties of the document class. - // now they are moved into the individual identifiers - QStringList tensesCompability; - groupElement = groupElement.firstChildElement( KVTML_TENSES ); - if ( !groupElement.isNull() ) { - tensesCompability = readTenses( groupElement ); - } - - groupElement = domElementParent.firstChildElement( KVTML_IDENTIFIERS ); - if ( !groupElement.isNull() ) { - QDomNodeList entryList = groupElement.elementsByTagName( KVTML_IDENTIFIER ); - if ( entryList.length() <= 0 ) { - m_errorMessage = i18n( "missing identifier elements from identifiers tag" ); - return false; - } - - for ( int i = 0; i < entryList.count(); ++i ) { - currentElement = entryList.item( i ).toElement(); - if ( currentElement.parentNode() == groupElement ) { - result = readIdentifier( currentElement ); - if ( !result ) { - return false; - } - if (!tensesCompability.isEmpty()) { - m_doc->identifier(i).setTenseList(tensesCompability); - } - } - } - } - - groupElement = domElementParent.firstChildElement( KVTML_ENTRIES ); - if ( !groupElement.isNull() ) { - QDomNodeList entryList = groupElement.elementsByTagName( KVTML_ENTRY ); - for ( int i = 0; i < entryList.count(); ++i ) { - currentElement = entryList.item( i ).toElement(); - if ( currentElement.parentNode() == groupElement ) { - result = readEntry( currentElement ); - if ( !result ) - return false; - } - } - } - - readSynonymsAntonymsFalseFriends( domElementParent ); - - groupElement = domElementParent.firstChildElement( KVTML_WORDTYPES ); - if ( !groupElement.isNull() ) { - readChildWordTypes( m_doc->wordTypeContainer(), groupElement ); - } - - groupElement = domElementParent.firstChildElement( KVTML_LEITNERBOXES ); - if ( !groupElement.isNull() ) { - readLeitner( m_doc->leitnerContainer(), groupElement ); - } - - groupElement = domElementParent.firstChildElement( KVTML_LESSONS ); - if ( !groupElement.isNull() ) { - readChildLessons(m_doc->lesson(), groupElement); - } - - // Additional cleanup: Put orphaned entries without a lesson into a default lesson. - KEduVocLesson *defaultLesson = new KEduVocLesson(i18n("Default Lesson"), m_doc->lesson()); - - // now make sure we don't have any orphan entries - foreach (KEduVocExpression * entry, m_allEntries) { - if (!entry->lesson()) - { - defaultLesson->appendEntry(entry); - } - } - - if (defaultLesson->entryCount() > 0) - { - m_doc->lesson()->appendChildContainer(defaultLesson); - } else { - delete defaultLesson; - } - - return true; -} - - -bool KEduVocKvtml2Reader::readIdentifier( QDomElement &identifierElement ) -{ - bool result = true; - int id = identifierElement.attribute( KVTML_ID ).toInt( &result ); - if ( !result ) { - m_errorMessage = i18n( "identifier missing id" ); - return false; - } - - // generate empty identifiers in the doc - for ( int i = m_doc->identifierCount(); i <= id; i++ ) { - m_doc->appendIdentifier( KEduVocIdentifier() ); - } - - // the first element, create the identifier, even if empty - QDomElement currentElement = identifierElement.firstChildElement( KVTML_NAME ); - m_doc->identifier(id).setName( currentElement.text() ); - - currentElement = identifierElement.firstChildElement( KVTML_LOCALE ); - m_doc->identifier(id).setLocale( currentElement.text() ); - - currentElement = identifierElement.firstChildElement( KVTML_IDENTIFIERTYPE ); - if ( !currentElement.isNull() ) { - // TODO: do something with the type - } - - // read sub-parts - currentElement = identifierElement.firstChildElement( KVTML_ARTICLE ); - if ( !currentElement.isNull() ) { - readArticle( currentElement, id ); - } - - currentElement = identifierElement.firstChildElement( KVTML_PERSONALPRONOUNS ); - if ( !currentElement.isNull() ) { - KEduVocPersonalPronoun personalPronoun; - readPersonalPronoun( currentElement, personalPronoun ); - m_doc->identifier(id).setPersonalPronouns( personalPronoun ); - } - - QStringList tenses = readTenses(identifierElement); -kDebug() << tenses; - - m_doc->identifier(id).setTenseList(tenses); - - return result; -} - -bool KEduVocKvtml2Reader::readEntry( QDomElement &entryElement ) -{ - QDomElement currentElement; - bool result = true; - - // get entry id - int id = entryElement.attribute( KVTML_ID ).toInt( &result ); - if ( !result ) { - m_errorMessage = i18n( "entry missing id" ); - return false; - } - - KEduVocExpression *expr = new KEduVocExpression; - - // read info tags: inactive, inquery, and sizehint - currentElement = entryElement.firstChildElement( KVTML_DEACTIVATED ); - if ( !currentElement.isNull() ) { - // set the active state of the expression - if ( currentElement.text() == KVTML_TRUE ) { - expr->setActive( false ); - } else { - expr->setActive( true ); - } - } - - // read translation children - QDomNodeList translationList = entryElement.elementsByTagName( KVTML_TRANSLATION ); - - for ( int i = 0; i < translationList.count(); ++i ) { - currentElement = translationList.item( i ).toElement(); - if ( currentElement.parentNode() == entryElement ) { - result = readTranslation( currentElement, expr, i ); - if ( !result ) - return false; - } - } - - if ( expr->translationIndices().size() == 0 ) { - kDebug() << "Found entry with no words in it." << id; - expr->setTranslation(0, QString()); - } - - Q_ASSERT(expr); - - // TODO: probably should insert at id position with a check to see if it exists - // may be useful for detecting corrupt documents - m_allEntries[id] = expr; - return result; -} - -bool KEduVocKvtml2Reader::readTranslation( QDomElement &translationElement, - KEduVocExpression *expr, int index ) -{ - // read the text, grade, declension and conjugation - expr->translation(index)->fromKVTML2(translationElement); - QDomElement currentElement; - - // - /// @todo false friends -// currentElement = translationElement.firstChildElement( KVTML_FALSEFRIEND ); -// if ( !currentElement.isNull() ) { -// int fromid = currentElement.attribute( KVTML_FROMID ).toInt(); -// expr->translation(index)->setFalseFriend( fromid, currentElement.text() ); -// } - - // comparisons - currentElement = translationElement.firstChildElement( KVTML_COMPARISON ); - if ( !currentElement.isNull() ) { - readComparison( currentElement, expr->translation(index) ); - } - - // multiple choice - currentElement = translationElement.firstChildElement( KVTML_MULTIPLECHOICE ); - if ( !currentElement.isNull() ) { - readMultipleChoice( currentElement, expr->translation(index) ); - } - - // image - currentElement = translationElement.firstChildElement( KVTML_IMAGE ); - if ( !currentElement.isNull() ) { - expr->translation(index)->setImageUrl( KUrl( m_doc->url(), currentElement.text() ) ); - } - - // sound - currentElement = translationElement.firstChildElement( KVTML_SOUND ); - if ( !currentElement.isNull() ) { - expr->translation(index)->setSoundUrl( KUrl( m_doc->url(), currentElement.text() ) ); - } - - return true; -} - -bool KEduVocKvtml2Reader::readChildLessons( KEduVocLesson* parentLesson, QDomElement &lessonElement ) -{ - QDomElement currentElement = lessonElement.firstChildElement( KVTML_CONTAINER ); - while ( !currentElement.isNull() ) { - readLesson(parentLesson, currentElement); - currentElement = currentElement.nextSiblingElement( KVTML_CONTAINER ); - } - return true; -} - -bool KEduVocKvtml2Reader::readLesson( KEduVocLesson* parentLesson, QDomElement &lessonElement ) -{ - //Lesson name - QDomElement currentElement = lessonElement.firstChildElement( KVTML_NAME ); - KEduVocLesson * lesson = new KEduVocLesson(currentElement.text(), parentLesson); - parentLesson->appendChildContainer( lesson ); - - readChildLessons( lesson, lessonElement ); - - //true - currentElement = lessonElement.firstChildElement( KVTML_INPRACTICE ); - lesson->setInPractice(currentElement.text() == KVTML_TRUE); - - // - currentElement = lessonElement.firstChildElement( KVTML_ENTRY ); - while ( !currentElement.isNull() ) { - bool result = false; - int entryId = currentElement.attribute( KVTML_ID ).toInt( &result ); - if(result) { - if (m_allEntries[entryId]) { - lesson->appendEntry( m_allEntries[entryId] ); - } - } - currentElement = currentElement.nextSiblingElement( KVTML_ENTRY ); - } - return true; -} - -bool KEduVocKvtml2Reader::readSynonymsAntonymsFalseFriends( QDomElement &rootElement ) -{ - QDomElement pairElement; - for(int type = KEduVocTranslation::Synonym; type <= KEduVocTranslation::FalseFriend; type++) { - switch (type) { - case KEduVocTranslation::Synonym: - pairElement= rootElement.firstChildElement( KVTML_SYNONYM ); - break; - case KEduVocTranslation::Antonym: - pairElement= rootElement.firstChildElement( KVTML_ANTONYM ); - break; - case KEduVocTranslation::FalseFriend: - pairElement= rootElement.firstChildElement( KVTML_FALSEFRIEND ); - break; - } - // pair - pairElement = pairElement.firstChildElement( KVTML_PAIR ); - while ( !pairElement.isNull() ) { - // - QDomElement entryElement = pairElement.firstChildElement( KVTML_ENTRY ); - int firstEntryId = entryElement.attribute( KVTML_ID ).toInt(); - - QDomElement translationElement = entryElement.firstChildElement( KVTML_TRANSLATION ); - int firstTranslationId = translationElement.attribute( KVTML_ID ).toInt(); - - // second entry - entryElement = entryElement.nextSiblingElement( KVTML_ENTRY ); - int secondEntryId = entryElement.attribute( KVTML_ID ).toInt(); - translationElement = entryElement.firstChildElement( KVTML_TRANSLATION ); - int secondTranslationId = translationElement.attribute( KVTML_ID ).toInt(); - - // pair them up - KEduVocTranslation *first = m_allEntries[firstEntryId]->translation(firstTranslationId); - KEduVocTranslation *second = m_allEntries[secondEntryId]->translation(secondTranslationId); - - switch (type) { - case KEduVocTranslation::Synonym: - first->addSynonym(second); - second->addSynonym(first); - break; - case KEduVocTranslation::Antonym: - first->addAntonym(second); - second->addAntonym(first); - break; - case KEduVocTranslation::FalseFriend: - first->addFalseFriend(second); - second->addFalseFriend(first); - break; - } - pairElement = pairElement.nextSiblingElement( KVTML_PAIR ); - } - } - return true; -} - -bool KEduVocKvtml2Reader::readArticle( QDomElement &articleElement, int identifierNum ) -/* -
- - - der - die - das - - - ein - eine - ein - - - - -
-*/ -{ - QMap numbers; - numbers[0] = KEduVocWordFlag::Singular; - numbers[1] = KEduVocWordFlag::Dual; - numbers[2] = KEduVocWordFlag::Plural; - QMap genders; - genders[0] = KEduVocWordFlag::Masculine; - genders[1] = KEduVocWordFlag::Feminine; - genders[2] = KEduVocWordFlag::Neuter; - QMap defs; - defs[0] = KEduVocWordFlag::Definite; - defs[1] = KEduVocWordFlag::Indefinite; - - for ( int num = 0; num <= 2; ++num) { - QDomElement numberElement = articleElement.firstChildElement( KVTML_GRAMMATICAL_NUMBER[num] ); - if (!numberElement.isNull()) { - // definite - for ( int def = 0; def <= 1; ++def ) { - QDomElement defElement = numberElement.firstChildElement( KVTML_GRAMMATICAL_DEFINITENESS[def] ); - if (!defElement.isNull()) { - // male - for ( int gen = 0; gen <= 2; ++gen ) { - QDomElement genderElement = defElement.firstChildElement( KVTML_GRAMMATICAL_GENDER[gen] ); - if (!genderElement.isNull()) { - m_doc->identifier(identifierNum).article().setArticle( genderElement.text(), numbers[num] | defs[def] | genders[gen]); - } - } - } - } - } - } - - return true; -} - - -bool KEduVocKvtml2Reader::readChildWordTypes(KEduVocWordType* parentContainer, QDomElement &lessonElement) -{ - QDomElement currentElement = lessonElement.firstChildElement( KVTML_CONTAINER ); - while ( !currentElement.isNull() ) { - readWordType(parentContainer, currentElement); - currentElement = currentElement.nextSiblingElement( KVTML_CONTAINER ); - } - return true; -} - -bool KEduVocKvtml2Reader::readLeitner( KEduVocLeitnerBox* parentContainer, QDomElement &leitnerParentElement ) -{ - QDomElement leitnerElement = leitnerParentElement.firstChildElement( KVTML_CONTAINER ); - while ( !leitnerElement.isNull() ) { - QString name = leitnerElement.firstChildElement( KVTML_NAME ).text(); - - KEduVocLeitnerBox * leitner = new KEduVocLeitnerBox(name, parentContainer); - parentContainer->appendChildContainer(leitner); - // for leitner we only allow a flat list, no sub boxes. - - // read entries - QDomElement entryElement = leitnerElement.firstChildElement( KVTML_ENTRY ); - while ( !entryElement.isNull() ) { - // read - int entryId = entryElement.attribute( KVTML_ID ).toInt(); - QDomElement translationElement = entryElement.firstChildElement( KVTML_TRANSLATION ); - while( !translationElement.isNull() ) { - // - int translationId = translationElement.attribute( KVTML_ID ).toInt(); - m_allEntries.value(entryId)->translation(translationId)->setLeitnerBox(leitner); - translationElement = translationElement.nextSiblingElement( KVTML_TRANSLATION ); - } - entryElement = entryElement.nextSiblingElement( KVTML_ENTRY ); - } - leitnerElement = leitnerElement.nextSiblingElement( KVTML_CONTAINER ); - } - return true; -} - -bool KEduVocKvtml2Reader::readWordType( KEduVocWordType* parentContainer, QDomElement &typeElement ) -{ - // set type and specialtype - QString typeName = - typeElement.firstChildElement( KVTML_NAME ).text(); - - KEduVocWordType * wordTypeContainer = new KEduVocWordType(typeName, parentContainer); - parentContainer->appendChildContainer(wordTypeContainer); - - QString specialType = typeElement.firstChildElement( KVTML_SPECIALWORDTYPE ).text(); - if ( !specialType.isEmpty() ) { - // get the localized version - if ( specialType == KVTML_SPECIALWORDTYPE_NOUN ) { - wordTypeContainer->setWordType(KEduVocWordFlag::Noun); - } - if ( specialType == KVTML_SPECIALWORDTYPE_VERB ) { - wordTypeContainer->setWordType(KEduVocWordFlag::Verb); - } - if ( specialType == KVTML_SPECIALWORDTYPE_ADVERB ) { - wordTypeContainer->setWordType(KEduVocWordFlag::Adverb); - } - if ( specialType == KVTML_SPECIALWORDTYPE_ADJECTIVE ) { - wordTypeContainer->setWordType(KEduVocWordFlag::Adjective); - } - if ( specialType == KVTML_SPECIALWORDTYPE_NOUN_MALE ) { - wordTypeContainer->setWordType(KEduVocWordFlag::Noun | KEduVocWordFlag::Masculine); - } - if ( specialType == KVTML_SPECIALWORDTYPE_NOUN_FEMALE ) { - wordTypeContainer->setWordType(KEduVocWordFlag::Noun | KEduVocWordFlag::Feminine); - } - if ( specialType == KVTML_SPECIALWORDTYPE_NOUN_NEUTRAL ) { - wordTypeContainer->setWordType(KEduVocWordFlag::Noun| KEduVocWordFlag::Neuter); - } - } // special type - - - // read entries - QDomElement entryElement = typeElement.firstChildElement( KVTML_ENTRY ); - while ( !entryElement.isNull() ) { - // read - int entryId = entryElement.attribute( KVTML_ID ).toInt(); - QDomElement translationElement = entryElement.firstChildElement( KVTML_TRANSLATION ); - while( !translationElement.isNull() ) { - // - int translationId = translationElement.attribute( KVTML_ID ).toInt(); - m_allEntries.value(entryId)->translation(translationId)->setWordType(wordTypeContainer); - translationElement = translationElement.nextSiblingElement( KVTML_TRANSLATION ); - } - entryElement = entryElement.nextSiblingElement( KVTML_ENTRY ); - } - - readChildWordTypes(wordTypeContainer, typeElement); - - return true; -} - -QStringList KEduVocKvtml2Reader::readTenses( QDomElement &tensesElement ) -{ - QStringList tenses; - - QDomNodeList tenseNodes = tensesElement.elementsByTagName( KVTML_TENSE ); - for ( int i = 0; i < tenseNodes.count(); ++i ) { - QDomElement currentElement = tenseNodes.item( i ).toElement(); - if ( currentElement.parentNode() == tensesElement ) { - tenses.append( currentElement.text() ); - } - } - - return tenses; -} - -bool KEduVocKvtml2Reader::readComparison( QDomElement &domElementParent, KEduVocTranslation* translation ) -/* - - better - best - -*/ -{ - QDomElement currentElement; - - currentElement = domElementParent.firstChildElement( KVTML_COMPARATIVE ); - if ( !currentElement.isNull() ) - { - translation->setComparative( currentElement.text() ); - } - - currentElement = domElementParent.firstChildElement( KVTML_SUPERLATIVE ); - if ( !currentElement.isNull() ) - { - translation->setSuperlative( currentElement.text() ); - } - return true; -} - - -bool KEduVocKvtml2Reader::readMultipleChoice( QDomElement &multipleChoiceElement, KEduVocTranslation* translation ) -/* - - good - better - best - best 2 - best 3 - -*/ -{ - QDomElement currentElement; - QDomNodeList choiceNodes = multipleChoiceElement.elementsByTagName( KVTML_CHOICE ); - for ( int i = 0; i < choiceNodes.count(); ++i ) - { - currentElement = choiceNodes.item( i ).toElement(); - if ( currentElement.parentNode() == multipleChoiceElement ) { - translation->multipleChoice().append( currentElement.text() ); - } - } - return true; -} - - -bool KEduVocKvtml2Reader::readPersonalPronoun(QDomElement & pronounElement, KEduVocPersonalPronoun & pronoun) -{ - pronoun.setMaleFemaleDifferent(!pronounElement.firstChildElement( - KVTML_THIRD_PERSON_MALE_FEMALE_DIFFERENT).isNull()); - pronoun.setNeutralExists( !pronounElement.firstChildElement( - KVTML_THIRD_PERSON_NEUTRAL_EXISTS).isNull() ); - pronoun.setDualExists( !pronounElement.firstChildElement( - KVTML_DUAL_EXISTS).isNull() ); - - QDomElement personElement = pronounElement.firstChildElement( KVTML_GRAMMATICAL_NUMBER[0] ); - if ( !personElement.isNull() ) { - readPersonalPronounChild( personElement, pronoun, KEduVocWordFlag::Singular ); - } - - personElement = pronounElement.firstChildElement( KVTML_GRAMMATICAL_NUMBER[1] ); - if ( !personElement.isNull() ) { - readPersonalPronounChild( personElement, pronoun, KEduVocWordFlag::Dual ); - } - - personElement = pronounElement.firstChildElement( KVTML_GRAMMATICAL_NUMBER[2] ); - if ( !personElement.isNull() ) { - readPersonalPronounChild( personElement, pronoun, KEduVocWordFlag::Plural ); - } - return true; -} - - -bool KEduVocKvtml2Reader::readPersonalPronounChild(QDomElement & personElement, KEduVocPersonalPronoun & pronoun, KEduVocWordFlags number) -{ - QMap persons; - persons[0] = KEduVocWordFlag::First; - persons[1] = KEduVocWordFlag::Second; - persons[2] = (KEduVocWordFlag::Flags)((int)KEduVocWordFlag::Third | (int)KEduVocWordFlag::Masculine); - persons[3] = (KEduVocWordFlag::Flags)((int)KEduVocWordFlag::Third | (int)KEduVocWordFlag::Feminine); - persons[4] = (KEduVocWordFlag::Flags)((int)KEduVocWordFlag::Third | (int)KEduVocWordFlag::Neuter); - - - - for (int person = 0; person < 5; person++) { - QDomElement currentElement = personElement.firstChildElement( KVTML_GRAMMATICAL_PERSON[person] ); - pronoun.setPersonalPronoun( currentElement.text(), persons[person] | number ); - } - - return true; -} - - -#include "keduvockvtml2reader.moc" diff --git a/keduvocdocument/keduvockvtml2reader.h b/keduvocdocument/keduvockvtml2reader.h deleted file mode 100644 index ec476c1..0000000 --- a/keduvocdocument/keduvockvtml2reader.h +++ /dev/null @@ -1,167 +0,0 @@ -/*************************************************************************** - read a KEduVocDocument from a KVTML2 file - ----------------------------------------------------------------------- - copyright : (C) 2007 Jeremy Whiting - Copyright 2007-2008 Frederik Gladhorn - ***************************************************************************/ - -/*************************************************************************** - * * - * 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. * - * * - ***************************************************************************/ - -#ifndef KEDUVOCKVTML2READER_H -#define KEDUVOCKVTML2READER_H - -#include -#include - -#include "keduvocexpression.h" -#include "keduvocpersonalpronoun.h" -#include "keduvocarticle.h" -#include "keduvocmultiplechoice.h" - -class QIODevice; -class KEduVocDocument; -class KEduVocWordType; - -/** -* @brief class to read kvtml2 data files into keduvocdocument -* @author Jeremy Whiting -*/ -class KEduVocKvtml2Reader : public QObject -{ - Q_OBJECT -public: - /** default constructor - * @param file file to read from - */ - KEduVocKvtml2Reader( QIODevice *file ); - - /** read the document - * @param doc document object to store the data in - */ - bool readDoc( KEduVocDocument *doc ); - - /** get the errormessage string - * @returns the errormessage string - */ - QString errorMessage() const - { - return m_errorMessage; - } - -private: - /** read information entries - * @param informationElement QDomElement information - */ - bool readInformation( QDomElement &informationElement ); - - /** read group elements: identifiers, entries, types, usages, lessons */ - bool readGroups( QDomElement &domElementParent ); - - /** read an identifier - * @param identifierElement QDomElement for the identifier to read - */ - bool readIdentifier( QDomElement &identifierElement ); - - /** read an identifiers articles - * @param articleElement QDomElement for the article group - * @param identifierNum number of the identifier this article is inside of - */ - bool readArticle( QDomElement &articleElement, int identifierNum ); - - bool readPersonalPronoun( QDomElement &conjugElement, KEduVocPersonalPronoun &pronoun ); - - bool readPersonalPronounChild(QDomElement & personElement, KEduVocPersonalPronoun &pronoun, KEduVocWordFlags flags); - - /** read the types - * @param typesElement QDomElement for the types group - */ - bool readWordType( KEduVocWordType* parentContainer, QDomElement &typesElement ); - - /** - * Read a leitner box container. - * This is a grading system where the vocabulary are kept in boxes and promoted/demoted during the learning. - * Be aware that leitner boxes are a list only and no sub boxes will ever be read or written. - * While reusing the lesson class is quite easy for this a proper subclass of KEduVocContainer would be the better solution. - * @param parentContainer the parent to append the new leitner container to - * @param leitnerElement the element in the dom - * @return success - */ - bool readLeitner( KEduVocLeitnerBox* parentContainer, QDomElement &leitnerElement ); - - /** - * Read all tags within a word type definition. - * @param parentContainer - * @param lessonElement - * @return - */ - bool readChildWordTypes( KEduVocWordType* parentContainer, QDomElement &lessonElement ); - - /** read the tenses - * @param tensesElement QDomElement for the tenses group - */ - QStringList readTenses( QDomElement &tensesElement ); - - /** read the usages - * @param usagesElement QDomElement for the usages group - */ - bool readUsages( QDomElement &usagesElement ); - - /** read an entry - * @param entryElement QDomElement for the entry to read - */ - bool readEntry( QDomElement &entryElement ); - - /** read a translation - * @param translationElement QDomElement for the translation to read - */ - bool readTranslation( QDomElement &translationElement, KEduVocExpression *expr, int index ); - - /** read a comparison - * @param comparisonElement comparison group element - * @param comp comparison object to read into - */ - bool readComparison( QDomElement &comparisonElement, KEduVocTranslation *translation ); - - /** read a multiple choice group - * @param multipleChoiceElement element to read from - * @param mc KEduVocMultipleChoice object to read to - */ - bool readMultipleChoice( QDomElement &multipleChoiceElement, KEduVocTranslation* translation ); - - /** - * Read tags. - * @param parentLesson - * @param lessonElement - * @return - */ - bool readChildLessons( KEduVocLesson* parentLesson, QDomElement &lessonElement ); - - /** read a lesson, and append it to the document - * @param lessonElement element to read from - */ - bool readLesson( KEduVocLesson* parentLesson, QDomElement &lessonElement ); - - bool readSynonymsAntonymsFalseFriends( QDomElement &rootElement ); - - /** pre-opened QIODevice to read from */ - QIODevice *m_inputFile; - - /** KEduVocDocument to read to */ - KEduVocDocument *m_doc; - - /** because we read the entries first, we store them here temporarily. - * later we read the lessons and put the entries there based on the key (their id) */ - QMap m_allEntries; - - /** error message */ - QString m_errorMessage; -}; - -#endif diff --git a/keduvocdocument/keduvockvtml2writer.cpp b/keduvocdocument/keduvockvtml2writer.cpp deleted file mode 100644 index 485cc41..0000000 --- a/keduvocdocument/keduvockvtml2writer.cpp +++ /dev/null @@ -1,674 +0,0 @@ -/*************************************************************************** - export a KEduVocDocument to a KVTML file - ----------------------------------------------------------------------- - copyright : (C) 2007 Jeremy Whiting - (C) 2007-2008 Frederik Gladhorn - ***************************************************************************/ - -/*************************************************************************** - * * - * 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. * - * * - ***************************************************************************/ - -#include "keduvockvtml2writer.h" - -#include -#include - -#include - -#include "keduvocdocument.h" -#include "keduvocexpression.h" -#include "keduvoclesson.h" -#include "keduvocleitnerbox.h" -#include "keduvocwordtype.h" -#include "kvtml2defs.h" - -KEduVocKvtml2Writer::KEduVocKvtml2Writer( QFile *file ) -{ - // the file must be already open - m_outputFile = file; -} - -bool KEduVocKvtml2Writer::writeDoc( KEduVocDocument *doc, const QString &generator ) -{ - if (createXmlDocument(doc, generator)) { - QTextStream ts( m_outputFile ); - m_domDoc.save( ts, 2 ); - return true; - } - return false; -} - -QByteArray KEduVocKvtml2Writer::toByteArray(KEduVocDocument * doc, const QString & generator) -{ - if (createXmlDocument(doc, generator)) { - return m_domDoc.toByteArray(); - } - return QByteArray(); -} - -bool KEduVocKvtml2Writer::createXmlDocument( KEduVocDocument *doc, const QString &generator ) -{ - m_doc = doc; - - m_domDoc = QDomDocument( "kvtml PUBLIC \"kvtml2.dtd\" \"http://edu.kde.org/kvtml/kvtml2.dtd\"" ); - m_domDoc.appendChild( m_domDoc.createProcessingInstruction( "xml", "version=\"1.0\" encoding=\"UTF-8\"" ) ); - QDomElement domElementKvtml = m_domDoc.createElement( "kvtml" ); - m_domDoc.appendChild( domElementKvtml ); - - domElementKvtml.setAttribute( KVTML_VERSION, ( QString ) "2.0" ); - - // information group - QDomElement currentElement = m_domDoc.createElement( KVTML_INFORMATION ); - writeInformation( currentElement, generator ); - domElementKvtml.appendChild( currentElement ); - - // identifiers - currentElement = m_domDoc.createElement( KVTML_IDENTIFIERS ); - writeIdentifiers( currentElement ); - domElementKvtml.appendChild( currentElement ); - - // entries - currentElement = m_domDoc.createElement( KVTML_ENTRIES ); - if ( !writeEntries( currentElement ) ) { - // at least one entry is required! - return false; - } - domElementKvtml.appendChild( currentElement ); - - // lessons - currentElement = m_domDoc.createElement( KVTML_LESSONS ); - writeLessons( m_doc->lesson(), currentElement ); - if ( currentElement.hasChildNodes() ) { - domElementKvtml.appendChild( currentElement ); - } - - // types - currentElement = m_domDoc.createElement( KVTML_WORDTYPES ); - writeWordTypes( currentElement, m_doc->wordTypeContainer() ); - if ( currentElement.hasChildNodes() ) { - domElementKvtml.appendChild( currentElement ); - } - - // leitner boxes - currentElement = m_domDoc.createElement( KVTML_LEITNERBOXES ); - writeLeitnerBoxes( currentElement, m_doc->leitnerContainer() ); - if ( currentElement.hasChildNodes() ) { - domElementKvtml.appendChild( currentElement ); - } - - writeSynonymAntonymFalseFriend(domElementKvtml); - - m_domDoc.appendChild( domElementKvtml ); - - return true; -} - -bool KEduVocKvtml2Writer::writeInformation( QDomElement &informationElement, const QString &generator ) -{ - QDomElement currentElement; - QDomText textNode; - - // generator - informationElement.appendChild( newTextElement( KVTML_GENERATOR, generator ) ); - - // title - if ( !m_doc->title().isEmpty() ) { - informationElement.appendChild( newTextElement( KVTML_TITLE, m_doc->title() ) ); - } - - // author - if ( !m_doc->author().isEmpty() ) { - informationElement.appendChild( newTextElement( KVTML_AUTHOR, m_doc->author() ) ); - } - - // author contact (mail/homepage) - if ( !m_doc->authorContact().isEmpty() ) { - informationElement.appendChild( newTextElement( KVTML_AUTHORCONTACT, m_doc->authorContact() ) ); - } - - // license - if ( !m_doc->license().isEmpty() ) { - informationElement.appendChild( newTextElement( KVTML_LICENSE, m_doc->license() ) ); - } - - // comment - if ( !m_doc->documentComment().isEmpty() ) { - informationElement.appendChild( newTextElement( KVTML_COMMENT, m_doc->documentComment() ) ); - } - - QDate today = QDate::currentDate(); - informationElement.appendChild( newTextElement( KVTML_DATE, today.toString(QLatin1String("yyyy-MM-dd")) ) ); - - // category - if ( !m_doc->category().isEmpty() ) { - informationElement.appendChild( newTextElement( KVTML_CATEGORY, m_doc->category() ) ); - } - - return true; -} - - -bool KEduVocKvtml2Writer::writeIdentifiers( QDomElement &identifiersElement ) -{ - for ( int i = 0; i < m_doc->identifierCount(); ++i ) { - // create the node - QDomElement identifier = m_domDoc.createElement( KVTML_IDENTIFIER ); - - // set the id - identifier.setAttribute( KVTML_ID, QString::number( i ) ); - - // record the identifier as the locale for now - // TODO: when support for more parts of the identifier is in the document class (name, type, etc.) store those here as well - identifier.appendChild( newTextElement( KVTML_NAME, m_doc->identifier( i ).name() ) ); - - identifier.appendChild( newTextElement( KVTML_LOCALE, m_doc->identifier( i ).locale() ) ); - - // record articles - QDomElement article = m_domDoc.createElement( KVTML_ARTICLE ); - writeArticle( article, i ); - if ( article.hasChildNodes() ) { - identifier.appendChild( article ); - } - - // record personalpronouns - QDomElement personalpronouns = m_domDoc.createElement( KVTML_PERSONALPRONOUNS ); - writePersonalPronoun( personalpronouns, m_doc->identifier(i).personalPronouns() ); - if ( personalpronouns.hasChildNodes() ) { - identifier.appendChild( personalpronouns ); - } - - // tenses - foreach(const QString &tense, m_doc->identifier(i).tenseList() ) { - if ( !( tense.isNull() ) ) { - identifier.appendChild( newTextElement( KVTML_TENSE, tense ) ); - } - } - // add this identifier to the group - identifiersElement.appendChild( identifier ); - } - return true; -} - -bool KEduVocKvtml2Writer::writeLessons( KEduVocLesson *parentLesson, QDomElement &lessonsElement ) -{ - // iterate over child lessons. - // the first time this is called with the root lesson which does not have a entry. - for( int i = 0; i < parentLesson->childContainerCount(); i++ ) { - KEduVocLesson *lesson = static_cast(parentLesson->childContainer(i)); - // make lesson element - QDomElement thisLessonElement = m_domDoc.createElement( KVTML_CONTAINER ); - - // add a name - thisLessonElement.appendChild( newTextElement( KVTML_NAME, lesson->name() ) ); - - // add a inquery tag - if ( lesson->inPractice() ) { - thisLessonElement.appendChild( newTextElement( KVTML_INPRACTICE, KVTML_TRUE ) ); - } - - // child lessons - writeLessons(lesson, thisLessonElement); - - // child entries - foreach(KEduVocExpression *entry, lesson->entries()) { - QDomElement entryElement = m_domDoc.createElement( KVTML_ENTRY ); - entryElement.setAttribute( KVTML_ID, QString::number(m_allEntries.indexOf(entry)) ); - thisLessonElement.appendChild(entryElement); - } - lessonsElement.appendChild( thisLessonElement ); - } - return true; -} - - - -void KEduVocKvtml2Writer::writeSynonymAntonymFalseFriend(QDomElement & parentElement) -{ - QList< KEduVocTranslation* > currentList; - QDomElement synonymElement; - // synonym, antonym, false friend - for(int type = KEduVocTranslation::Synonym; type <= KEduVocTranslation::FalseFriend; type++) { - switch (type) { - case KEduVocTranslation::Synonym: - synonymElement = m_domDoc.createElement( KVTML_SYNONYM ); - currentList = m_synonyms; - break; - case KEduVocTranslation::Antonym: - synonymElement = m_domDoc.createElement( KVTML_ANTONYM ); - currentList = m_antonyms; - break; - case KEduVocTranslation::FalseFriend: - synonymElement = m_domDoc.createElement( KVTML_FALSEFRIEND ); - currentList = m_falseFriends; - break; - } - - while (!currentList.isEmpty()) { - // after writing a translation, remove it from the list - KEduVocTranslation* translation = currentList.takeAt(0); - - // fill the entry element but only add later if it is valid - QDomElement entryElement = m_domDoc.createElement( KVTML_ENTRY ); - entryElement.setAttribute( KVTML_ID, QString::number(m_allEntries.indexOf(translation->entry())) ); - // find out which id that is... silly - foreach(int index, translation->entry()->translationIndices()) { - if (translation->entry()->translation(index) == translation) { - // create - QDomElement translationElement = m_domDoc.createElement( KVTML_TRANSLATION ); - translationElement.setAttribute( KVTML_ID, QString::number(index) ); - entryElement.appendChild(translationElement); - break; - } - } - - QDomElement relatedElement; - QList list; - switch (type) { - case KEduVocTranslation::Synonym: - list = translation->synonyms(); - break; - case KEduVocTranslation::Antonym: - list = translation->antonyms(); - break; - case KEduVocTranslation::FalseFriend: - list = translation->falseFriends(); - break; - } - foreach (KEduVocTranslation* synonym, list) { - // if it is not in the list it has already been written and we can move on - if (currentList.contains(synonym)) { - relatedElement = m_domDoc.createElement( KVTML_PAIR ); - synonymElement.appendChild(relatedElement); - relatedElement.appendChild(entryElement); - - - QDomElement partnerElement = m_domDoc.createElement( KVTML_ENTRY ); - partnerElement.setAttribute( KVTML_ID, QString::number(m_allEntries.indexOf(synonym->entry())) ); - - // find out which id that is - foreach(int index, synonym->entry()->translationIndices()) { - if (synonym->entry()->translation(index) == synonym) { - // create - QDomElement translationElement = m_domDoc.createElement( KVTML_TRANSLATION ); - translationElement.setAttribute( KVTML_ID, QString::number(index) ); - partnerElement.appendChild(translationElement); - break; - } - } - relatedElement.appendChild( partnerElement ); - } - } - if (relatedElement.hasChildNodes()) { - synonymElement.appendChild( relatedElement ); - } - } - if (synonymElement.hasChildNodes()) { - parentElement.appendChild( synonymElement ); - } - } // iterate over types -} -/* -bool KEduVocKvtml2Writer::writeRelated(QDomElement & parentElement, QList< KEduVocTranslation * > relatedList) -{ - foreach (KEduVocTranslation* synonym, translation->synonyms()) { - QDomElement entryElement = m_domDoc.createElement( KVTML_ENTRY ); - entryElement.setAttribute( KVTML_ID, QString::number(m_allEntries.indexOf(translation->entry())) ); - - // find out which id that is... silly - foreach(int index, translation->entry()->translationIndices()) { - if (translation->entry()->translation(index) == translation) { - // create - QDomElement translationElement = m_domDoc.createElement( KVTML_TRANSLATION ); - translationElement.setAttribute( KVTML_ID, QString::number(index) ); - entryElement.appendChild(translationElement); - } - } - parentElement.appendChild( entryElement ); - } -}*/ - -bool KEduVocKvtml2Writer::writeArticle( QDomElement &articleElement, int language ) -{ - ///@todo only write if not empty - QMap numbers; - numbers[0] = KEduVocWordFlag::Singular; - numbers[1] = KEduVocWordFlag::Dual; - numbers[2] = KEduVocWordFlag::Plural; - QMap genders; - genders[0] = KEduVocWordFlag::Masculine; - genders[1] = KEduVocWordFlag::Feminine; - genders[2] = KEduVocWordFlag::Neuter; - QMap defs; - defs[0] = KEduVocWordFlag::Definite; - defs[1] = KEduVocWordFlag::Indefinite; - - for (int num = 0; num <= 2; num++) - { - QDomElement numberElement = m_domDoc.createElement( KVTML_GRAMMATICAL_NUMBER[num] ); - - for (int def = 0; def <= 1; def++) { - QDomElement defElement = m_domDoc.createElement( KVTML_GRAMMATICAL_DEFINITENESS[def] ); - - for (int gen = 0; gen <= 2; gen++) - { - QString articleString = m_doc->identifier(language).article().article(numbers[num] | genders[gen] | defs[def]); - if ( !articleString.isEmpty() ) { - defElement.appendChild( newTextElement( KVTML_GRAMMATICAL_GENDER[gen], articleString ) ); - } - } - if ( defElement.hasChildNodes() ) { - numberElement.appendChild( defElement ); - } - } - if ( numberElement.hasChildNodes() ) { - articleElement.appendChild( numberElement ); - } - } - return true; -} - - -bool KEduVocKvtml2Writer::writeWordTypes( QDomElement &typesElement, KEduVocWordType* parentContainer ) -{ - foreach( KEduVocContainer* container, parentContainer->childContainers() ) { - KEduVocWordType* wordType = static_cast(container); - - QDomElement typeDefinitionElement = m_domDoc.createElement( KVTML_CONTAINER ); - typeDefinitionElement.appendChild( newTextElement( KVTML_NAME, wordType->name() ) ); - - if (wordType->wordType().testFlag(KEduVocWordFlag::Noun)) - { - if (wordType->wordType().testFlag(KEduVocWordFlag::Masculine)) - typeDefinitionElement.appendChild( newTextElement( KVTML_SPECIALWORDTYPE, KVTML_SPECIALWORDTYPE_NOUN_MALE ) ); - - else if (wordType->wordType().testFlag(KEduVocWordFlag::Feminine)) - typeDefinitionElement.appendChild( newTextElement( KVTML_SPECIALWORDTYPE, KVTML_SPECIALWORDTYPE_NOUN_FEMALE ) ); - - else if (wordType->wordType().testFlag(KEduVocWordFlag::Neuter)) - typeDefinitionElement.appendChild( newTextElement( KVTML_SPECIALWORDTYPE, KVTML_SPECIALWORDTYPE_NOUN_NEUTRAL ) ); - else - typeDefinitionElement.appendChild( newTextElement( KVTML_SPECIALWORDTYPE, KVTML_SPECIALWORDTYPE_NOUN ) ); - } - else if (wordType->wordType().testFlag(KEduVocWordFlag::Verb)) - typeDefinitionElement.appendChild( newTextElement( KVTML_SPECIALWORDTYPE, KVTML_SPECIALWORDTYPE_VERB ) ); - - else if (wordType->wordType().testFlag(KEduVocWordFlag::Adjective)) - typeDefinitionElement.appendChild( newTextElement( KVTML_SPECIALWORDTYPE, KVTML_SPECIALWORDTYPE_ADJECTIVE ) ); - - else if (wordType->wordType().testFlag(KEduVocWordFlag::Adverb)) - typeDefinitionElement.appendChild( newTextElement( KVTML_SPECIALWORDTYPE, KVTML_SPECIALWORDTYPE_ADVERB ) ); - - -// child entries - - // child entries - foreach(KEduVocExpression *entry, wordType->entries()) { - QDomElement entryElement = m_domDoc.createElement( KVTML_ENTRY ); - entryElement.setAttribute( KVTML_ID, QString::number(m_allEntries.indexOf(entry)) ); - for(int translation = 0; translationidentifierCount(); translation++) { - if (entry->translation(translation)->wordType()== wordType) { - QDomElement translationElement = m_domDoc.createElement( KVTML_TRANSLATION ); - // create - translationElement.setAttribute( KVTML_ID, QString::number(translation) ); - // append both - entryElement.appendChild(translationElement); - } - } - typeDefinitionElement.appendChild( entryElement ); - } - - writeWordTypes( typeDefinitionElement, wordType ); - - typesElement.appendChild( typeDefinitionElement ); - } - return true; -} - -bool KEduVocKvtml2Writer::writeLeitnerBoxes( QDomElement &leitnerParentElement, KEduVocLeitnerBox* parentContainer ) -{ - foreach( KEduVocContainer* container, parentContainer->childContainers() ) { - KEduVocLeitnerBox* leitnerBox = static_cast(container); - - QDomElement containerElement = m_domDoc.createElement( KVTML_CONTAINER ); - containerElement.appendChild( newTextElement( KVTML_NAME, leitnerBox->name() ) ); - - // child entries - foreach(KEduVocExpression *entry, leitnerBox->entries()) { - QDomElement entryElement = m_domDoc.createElement( KVTML_ENTRY ); - entryElement.setAttribute( KVTML_ID, QString::number(m_allEntries.indexOf(entry)) ); - for(int translation = 0; translationidentifierCount(); translation++) { - if (entry->translation(translation)->leitnerBox()== leitnerBox) { - QDomElement translationElement = m_domDoc.createElement( KVTML_TRANSLATION ); - // create - translationElement.setAttribute( KVTML_ID, QString::number(translation) ); - // append both - entryElement.appendChild(translationElement); - } - } - containerElement.appendChild( entryElement ); - } - - leitnerParentElement.appendChild( containerElement ); - } - return true; -} - -bool KEduVocKvtml2Writer::writeEntries( QDomElement &entriesElement ) -{ - m_allEntries = m_doc->lesson()->entries(KEduVocLesson::Recursive); - - // loop through entries - for ( int i = 0; i < m_allEntries.count(); ++i ) { - KEduVocExpression *thisEntry = m_allEntries.value(i); - - // write entry tag - QDomElement entryElement = m_domDoc.createElement( KVTML_ENTRY ); - - // add id - entryElement.setAttribute( KVTML_ID, QString::number( i ) ); - - // write deactivated - if(!thisEntry->isActive()) { - entryElement.appendChild( newTextElement( KVTML_DEACTIVATED, KVTML_TRUE ) ); - } - - // loop through translations - foreach( int trans, thisEntry->translationIndices() ) { - // write translations - QDomElement translation = m_domDoc.createElement( KVTML_TRANSLATION ); - translation.setAttribute( KVTML_ID, QString::number( trans ) ); - writeTranslation( translation, thisEntry->translation( trans ) ); - entryElement.appendChild( translation ); - } - // add this entry to the entriesElement - entriesElement.appendChild( entryElement ); - } - return true; -} - - -bool KEduVocKvtml2Writer::writeTranslation( QDomElement &translationElement, KEduVocTranslation* translation ) -{ - // so far only for KEduVocWord - text and grades - translation->toKVTML2(translationElement); - - // comparison - if ( !(translation->comparative().isEmpty() || translation->comparative().isEmpty())) { - QDomElement comparisonElement = m_domDoc.createElement( KVTML_COMPARISON ); - writeComparison( comparisonElement, translation ); - translationElement.appendChild( comparisonElement ); - } - - // multiplechoice - if ( !translation->multipleChoice().isEmpty() ) { - QDomElement multipleChoiceElement = m_domDoc.createElement( KVTML_MULTIPLECHOICE ); - writeMultipleChoice( multipleChoiceElement, translation ); - translationElement.appendChild( multipleChoiceElement ); - } - - // image - if ( !translation->imageUrl().isEmpty() ) { - QString urlString; - if ( translation->imageUrl().url().startsWith(m_doc->url().upUrl().url()) ) { - // try to save as relative url - urlString = KUrl::relativeUrl( m_doc->url() , translation->imageUrl() ); - } else { - urlString = translation->imageUrl().url(); - } - translationElement.appendChild( newTextElement( KVTML_IMAGE, urlString ) ); - } - - // sound - if ( !translation->soundUrl().isEmpty() ) { - QString urlString; - if ( translation->soundUrl().url().startsWith(m_doc->url().upUrl().url()) ) { - // try to save as relative url - urlString = KUrl::relativeUrl( m_doc->url() , translation->soundUrl() ); - } else { - urlString = translation->soundUrl().url(); - } - translationElement.appendChild( newTextElement( KVTML_SOUND, urlString ) ); - } - - - // synonym, antonym, false friend - // add to the list if it has any, write later since we want them separate - if (!translation->synonyms().isEmpty()) { - m_synonyms.append(translation); - } - if (!translation->antonyms().isEmpty()) { - m_antonyms.append(translation); - } - if (!translation->falseFriends().isEmpty()) { - m_falseFriends.append(translation); - } - return true; -} - - - - ///@todo write false friends - // - // loop through the identifiers -// for ( int i = 0; i < m_doc->identifierCount(); ++i ) { -// // see if this identifier has a falsefriend in this translation -// QString thisFriend = translation->falseFriend( i ); -// if ( !thisFriend.isEmpty() ) { -// // if so, create it, and set the fromid to i -// QDomElement thisFriendElement = newTextElement( KVTML_FALSEFRIEND, thisFriend ); -// thisFriendElement.setAttribute( KVTML_FROMID, QString::number( i ) ); -// translationElement.appendChild( thisFriendElement ); -// } -// } - - - - - - -bool KEduVocKvtml2Writer::writeComparison( QDomElement &comparisonElement, KEduVocTranslation* translation ) -/* - - good - better - best - -*/ -{ - comparisonElement.appendChild( newTextElement( KVTML_COMPARATIVE, translation->comparative() ) ); - comparisonElement.appendChild( newTextElement( KVTML_SUPERLATIVE, translation->superlative() ) ); - - return true; -} - - -bool KEduVocKvtml2Writer::writeMultipleChoice( QDomElement &multipleChoiceElement, KEduVocTranslation* translation ) -/* - - good - better - best - best 2 - best 3 - -*/ -{ - foreach ( const QString &choice, translation->multipleChoice() ) { - multipleChoiceElement.appendChild( newTextElement( KVTML_CHOICE, choice ) ); - } - return true; -} - -QDomElement KEduVocKvtml2Writer::newTextElement( const QString &elementName, const QString &text ) -{ - kDebug() << "append: " << elementName << text; - QDomElement retval = m_domDoc.createElement( elementName ); - QDomText textNode = m_domDoc.createTextNode( text ); - retval.appendChild( textNode ); - return retval; -} - -bool KEduVocKvtml2Writer::writePersonalPronoun(QDomElement & pronounElement, const KEduVocPersonalPronoun & pronoun) -{ - // general pronoun properties - if ( pronoun.maleFemaleDifferent() ) { - pronounElement.appendChild( m_domDoc.createElement( KVTML_THIRD_PERSON_MALE_FEMALE_DIFFERENT ) ); - } - if ( pronoun.neutralExists() ) { - pronounElement.appendChild( m_domDoc.createElement( KVTML_THIRD_PERSON_NEUTRAL_EXISTS ) ); - } - if ( pronoun.dualExists() ) { - pronounElement.appendChild( m_domDoc.createElement( KVTML_DUAL_EXISTS ) ); - } - - - QMap numbers; - numbers[0] = KEduVocWordFlag::Singular; - numbers[1] = KEduVocWordFlag::Dual; - numbers[2] = KEduVocWordFlag::Plural; - QMap persons; - persons[0] = KEduVocWordFlag::First; - persons[1] = KEduVocWordFlag::Second; - persons[2] = (KEduVocWordFlag::Flags)((int)KEduVocWordFlag::Third | (int)KEduVocWordFlag::Masculine); - persons[3] = (KEduVocWordFlag::Flags)((int)KEduVocWordFlag::Third | (int)KEduVocWordFlag::Feminine); - persons[4] = (KEduVocWordFlag::Flags)((int)KEduVocWordFlag::Third | (int)KEduVocWordFlag::Neuter); - - - - // the actual pronouns - for ( int num = 0; num < 3; num++ ) { - QDomElement numberElement = m_domDoc.createElement( KVTML_GRAMMATICAL_NUMBER[num] ); - for ( int person = 0; person < 5; person++ ) { - QString pronounString = pronoun.personalPronoun(numbers[num] | persons[person]); - if (!pronounString.isEmpty()) { - numberElement.appendChild( newTextElement( KVTML_GRAMMATICAL_PERSON[person], pronounString )); - } - } - if (numberElement.hasChildNodes()) { - pronounElement.appendChild( numberElement ); - } - } - return true; -} - -void KEduVocKvtml2Writer::appendTextElement(QDomElement & parent, const QString & elementName, const QString & text) -{ - // empty will never be written - if (text.isEmpty()) { - return; - } - - QDomDocument domDoc = parent.ownerDocument(); - QDomElement element = domDoc.createElement( elementName ); - parent.appendChild( element ); - QDomText textNode = domDoc.createTextNode( text ); - element.appendChild( textNode ); -} - - diff --git a/keduvocdocument/keduvockvtml2writer.h b/keduvocdocument/keduvockvtml2writer.h deleted file mode 100644 index 4a07293..0000000 --- a/keduvocdocument/keduvockvtml2writer.h +++ /dev/null @@ -1,145 +0,0 @@ -/*************************************************************************** - export a KEduVocDocument to a KVTML file - ----------------------------------------------------------------------- - copyright : (C) 2007 Jeremy Whiting - (C) 2007-2008 Frederik Gladhorn - ***************************************************************************/ - -/*************************************************************************** - * * - * 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. * - * * - ***************************************************************************/ - -#ifndef KEDUVOCKVTML2WRITER_H -#define KEDUVOCKVTML2WRITER_H - -#include -#include -#include - -#include "keduvocarticle.h" -#include "keduvocmultiplechoice.h" -#include "keduvoctranslation.h" -#include "keduvocpersonalpronoun.h" - -class KEduVocDocument; -class KEduVocExpression; -class KEduVocLesson; -class KEduVocLeitnerBox; - -/** -* @brief Class to write kvtml2 data files from KEduVocDocument -* @author Jeremy Whiting -*/ -class KEduVocKvtml2Writer -{ -public: - KEduVocKvtml2Writer( QFile *file ); - - bool writeDoc( KEduVocDocument *doc, const QString &generator ); - - QByteArray toByteArray( KEduVocDocument *doc, const QString &generator ); - - /** - * Helper function, appends a new element AND a text child to @p parent - * Only appends if @p text is NOT empty. - * @param parent - * @param elementName - * @param text - */ - static void appendTextElement( QDomElement &parent, const QString &elementName, const QString &text ); - -private: - - bool createXmlDocument( KEduVocDocument *doc, const QString &generator ); - - /** write information entries - * @param informationElement QDomElement information to write to - * @param generator text describing generator - */ - bool writeInformation( QDomElement &informationElement, const QString &generator ); - - /** write identifiers group - * @param identifiersElement QDomElement identifiers to write to - */ - bool writeIdentifiers( QDomElement &identifiersElement ); - - /** write article - * @param articleElement QDomElement article to write to - * @param article the article number to write - */ - bool writeArticle( QDomElement &articleElement, int article ); - - bool writePersonalPronoun( QDomElement &pronounElement, const KEduVocPersonalPronoun &pronoun); - /** write types - * @param typesElement QDomElement types to write to - */ - bool writeWordTypes( QDomElement &typesElement, KEduVocWordType* parentContainer ); - - /** - * write the leitner boxes @see KEduVocLeitnerBox - * @param leitnerParentElement parent dom element - * @param parentContainer parent of the KEduVocLeitnerBoxes to write - * @return success - */ - bool writeLeitnerBoxes( QDomElement &leitnerParentElement, KEduVocLeitnerBox* parentContainer ); - - /** write entries - * @param entriesElement QDomElement entries to write to - */ - bool writeEntries( QDomElement &entriesElement ); - - /** write a translation - * @param translationElement QDomElement translation to write to, with id pre-set - * @param translation object to write - */ - bool writeTranslation( QDomElement &translationElement, KEduVocTranslation* translation ); - - /** - * Used to write synonym, antonym and false friend lists - * @param typesElement - * @param parentContainer - * @return - */ - bool writeRelated( QDomElement &parentElement, QList relatedList ); - - /** write the lesson group - * @param parentLesson the parent lesson of the current lesson - * @param lessonsElement QDomElement lessons to write to - */ - bool writeLessons( KEduVocLesson *parentLesson, QDomElement &lessonsElement ); - - - void writeSynonymAntonymFalseFriend(QDomElement & parentElement); - - /** write a comparison - * @param comparisonElement QDomElement comparison to write to - * @param comparison object to write - * @returns success - */ - bool writeComparison( QDomElement &comparisonElement, KEduVocTranslation *translation ); - - /** write multiple choice choices - * @param multipleChoiceElement QDomElement multiplechoice to write to - * @returns success - */ - bool writeMultipleChoice( QDomElement &multipleChoiceElement, KEduVocTranslation* translation ); - - QDomElement newTextElement( const QString &elementName, const QString &text ); - - QFile *m_outputFile; - KEduVocDocument *m_doc; - - QList m_allEntries; - QList m_synonyms; - QList m_antonyms; - QList m_falseFriends; - - QDomDocument m_domDoc; -}; - -#endif diff --git a/keduvocdocument/keduvockvtmlcompability.cpp b/keduvocdocument/keduvockvtmlcompability.cpp deleted file mode 100644 index ead419f..0000000 --- a/keduvocdocument/keduvockvtmlcompability.cpp +++ /dev/null @@ -1,298 +0,0 @@ -/*************************************************************************** - - C++ Implementation: keduvockvtml1compability_p - - ----------------------------------------------------------------------- - - begin : Di Aug 28 2007 - - copyright : (C) 2007 Frederik Gladhorn - - ----------------------------------------------------------------------- - - ***************************************************************************/ - -/*************************************************************************** - * * - * 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. * - * * - ***************************************************************************/ - -#include "keduvockvtmlcompability.h" - -#include "keduvocwordtype.h" -#include - -const QString KEduVocKvtmlCompability::KVTML_1_USER_DEFINED = QString( "#" ); -const QString KEduVocKvtmlCompability::KVTML_1_SEPERATOR = QString( ":" ); - - -KEduVocKvtmlCompability::KEduVocKvtmlCompability() -{ - m_userdefinedTenseCounter = 0; - m_userdefinedTypeCounter = 0; - - initOldTypeLists(); - initOldTenses(); -} - - -////////////////// TYPES ///////////////////////////////////////// -void KEduVocKvtmlCompability::initOldTypeLists() -{ - m_oldMainTypeNames.clear(); - m_oldMainTypeNames.insert( "v", i18nc( "@item:inlistbox The grammatical type of a word", "Verb" ) ); - m_oldMainTypeNames.insert( "n", i18nc( "@item:inlistbox The grammatical type of a word", "Noun" ) ); - m_oldMainTypeNames.insert( "nm", i18nc( "@item:inlistbox The grammatical type of a word", "Name" ) ); - m_oldMainTypeNames.insert( "ar", i18nc( "@item:inlistbox The grammatical type of a word", "Article" ) ); - m_oldMainTypeNames.insert( "aj", i18nc( "@item:inlistbox The grammatical type of a word", "Adjective" ) ); - m_oldMainTypeNames.insert( "av", i18nc( "@item:inlistbox The grammatical type of a word", "Adverb" ) ); - m_oldMainTypeNames.insert( "pr", i18nc( "@item:inlistbox The grammatical type of a word", "Pronoun" ) ); - m_oldMainTypeNames.insert( "ph", i18nc( "@item:inlistbox The grammatical type of an entry", "Phrase" ) ); - m_oldMainTypeNames.insert( "num", i18nc( "@item:inlistbox The grammatical type of a word", "Numeral" ) ); - m_oldMainTypeNames.insert( "con", i18nc( "@item:inlistbox The grammatical type of a word", "Conjunction" ) ); - m_oldMainTypeNames.insert( "pre", i18nc( "@item:inlistbox The grammatical type of a word", "Preposition" ) ); - m_oldMainTypeNames.insert( "qu", i18nc( "@item:inlistbox The grammatical type of an entry", "Question" ) ); - - - m_oldSubTypeNames.clear(); - m_oldSubTypeNames.insert( "ord", i18nc( "@item:inlistbox A subtype of the grammatical word type: Numeral Ordinal (first, second, third, ...)","Ordinal" ) ); - m_oldSubTypeNames.insert( "crd", i18nc( "@item:inlistbox A subtype of the grammatical word type: Numeral Cardinal (one, two, three, ...)","Cardinal" ) ); - m_oldSubTypeNames.insert( "def", i18nc( "@item:inlistbox A subtype of the grammatical word type: Article (the)","Definite" ) ); - m_oldSubTypeNames.insert( "ind", i18nc( "@item:inlistbox A subtype of the grammatical word type: Article (a)","Indefinite" ) ); - m_oldSubTypeNames.insert( "re", i18nc( "@item:inlistbox A subtype of the grammatical word type: Verb with regular conjugation","Regular" ) ); - m_oldSubTypeNames.insert( "ir", i18nc( "@item:inlistbox A subtype of the grammatical word type: Verb with irregular conjugation","Irregular" ) ); - m_oldSubTypeNames.insert( "pos", i18nc( "@item:inlistbox A subtype of the grammatical word type: Pronoun (my, your, his, her...)", "Possessive" ) ); - m_oldSubTypeNames.insert( "per", i18nc( "@item:inlistbox A subtype of the grammatical word type: Pronoun (I, you, he...)", "Personal" ) ); - m_oldSubTypeNames.insert( "m", i18nc( "@item:inlistbox A subtype of the grammatical word type: Noun", "Male" ) ); - m_oldSubTypeNames.insert( "f", i18nc( "@item:inlistbox A subtype of the grammatical word type: Noun", "Female" ) ); - m_oldSubTypeNames.insert( "s", i18nc( "@item:inlistbox A subtype of the grammatical word type: Noun", "Neutral" ) ); -} - - -KEduVocWordType* KEduVocKvtmlCompability::typeFromOldFormat(KEduVocWordType* parent, const QString & typeSubtypeString ) const -{ - // check if it's user defined - if ( typeSubtypeString.length() >= 2 && typeSubtypeString.left( 1 ) == QM_USER_TYPE ) { - // they started counting at 1, we need to know which index we are dealing with: - int selfDefinedTypeIndex = typeSubtypeString.right( typeSubtypeString.count()-1 ).toInt() -1; - return static_cast(parent->childContainer(selfDefinedTypeIndex)); - } - - // assume the parent is set up to contain the old types correctly - QString mainType; - QString subType; - int i; - - if (( i = typeSubtypeString.indexOf( KVTML_1_SEPERATOR ) ) >= 0 ) { - mainType = typeSubtypeString.left( i ); - subType = typeSubtypeString.right( i+1 ); - } else { - mainType = typeSubtypeString; - } - - // convert from pre-0.5 versions (I guess we can just leave that in here. - // I seriously doubt that any such documents exist... - if ( mainType == "1" ) { - mainType = QM_VERB; - } else if ( mainType == "2" ) { - mainType = QM_NOUN; - } else if ( mainType == "3" ) { - mainType = QM_NAME; - } - - QString typeName = m_oldMainTypeNames.value( mainType ); - if ( typeName.isEmpty() ) { - kDebug() << "Unknown old maintype: " << typeSubtypeString; - return 0; - } - - QString subTypeName = m_oldSubTypeNames.value( subType ); - - foreach (KEduVocContainer* wordType, parent->childContainers()) { - if (wordType->name() == typeName) { - if (subType.isEmpty()) { - return static_cast(wordType); - } else { - foreach (KEduVocContainer* subWordType, wordType->childContainers()) { - if (subWordType->name() == subTypeName) { - return static_cast(subWordType); - } - } - } - } - } - - return 0; -} - - - - - - -/* -if ( type.length() >= 2 && type.left( 1 ) == QM_USER_TYPE ) { - // they started counting at 1, we need to know which index we are dealing with: - int selfDefinedTypeIndex = type.right( type.count()-1 ).toInt() -1; - - // append invented types (do we not trust our own writer?) - if ( selfDefinedTypeIndex >= m_oldSelfDefinedTypes.count() ) { - while ( selfDefinedTypeIndex >= m_oldSelfDefinedTypes.count() ) { - m_oldSelfDefinedTypes.append( i18n( "User defined word type %1", m_oldSelfDefinedTypes.count() - 1 ) ); - } - } - type = m_oldSelfDefinedTypes.value( selfDefinedTypeIndex ); - } else { - type = m_compability.mainTypeFromOldFormat( oldType ); - subType = m_compability.subTypeFromOldFormat( oldType ); - } // not user defined - preset types - - -if ( oldType.length() >= 2 && type.left( 1 ) == QM_USER_TYPE ) { - // they started counting at 1 - int selfDefinedTypeIndex = oldType.right( type.count()-1 ).toInt() -1; - // append invented types (do we not trust our own writer?) - if ( selfDefinedTypeIndex >= m_oldSelfDefinedTypes.count() ) { - while ( selfDefinedTypeIndex >= m_oldSelfDefinedTypes.count() ) { - m_oldSelfDefinedTypes.append( i18n( "User defined word type %1", m_oldSelfDefinedTypes.count() - 1 ) ); - } - } - type = m_oldSelfDefinedTypes.value( selfDefinedTypeIndex ); - } else { - type = m_compability.mainTypeFromOldFormat( oldType ); - subType = m_compability.subTypeFromOldFormat( oldType ); - } // not user defined - preset types - } -*/ - - - -void KEduVocKvtmlCompability::initOldTenses() -{ - m_oldTenses["PrSi"] = i18n( "Simple Present" ); - m_oldTenses["PrPr"] = i18n( "Present Progressive" ); - m_oldTenses["PrPe"] = i18n( "Present Perfect" ); - m_oldTenses["PaSi"] = i18n( "Simple Past" ); - m_oldTenses["PaPr"] = i18n( "Past Progressive" ); - m_oldTenses["PaPa"] = i18n( "Past Participle" ); - m_oldTenses["FuSi"] = i18n( "Future" ); -} - - -void KEduVocKvtmlCompability::addUserdefinedTense(const QString & tense) -{ - m_userdefinedTenseCounter++; - m_oldTenses[KVTML_1_USER_DEFINED + QString::number( m_userdefinedTenseCounter )] = tense; - m_tenses.insert(tense); - - kDebug() << " Add tense: " << KVTML_1_USER_DEFINED + QString::number( m_userdefinedTenseCounter ) << " - " << tense; -} - - -QString KEduVocKvtmlCompability::tenseFromKvtml1(const QString & oldTense) -{ - // in case the document got chaged, at least make up something as tense - if (!m_oldTenses.keys().contains(oldTense)) { - m_oldTenses[oldTense] = oldTense; - kDebug() << "Warning, tense " << oldTense << " not found in document!"; - } - m_tenses.insert(m_oldTenses.value(oldTense)); - return m_oldTenses.value(oldTense); -} - - -QStringList KEduVocKvtmlCompability::documentTenses() const -{ - return m_tenses.values(); -} - - -QString KEduVocKvtmlCompability::oldTense(const QString & tense) -{ -///@todo writing of the user defined tenses is probably messed up - if ( !m_oldTenses.values().contains(tense) ) { - m_userdefinedTenseCounter++; - m_oldTenses[KVTML_1_USER_DEFINED + QString::number( m_userdefinedTenseCounter )] = tense; - } - return m_oldTenses.key(tense); -} - -void KEduVocKvtmlCompability::setupWordTypes(KEduVocWordType * parent) -{ - QStringList wordTypeNames; - wordTypeNames - << i18nc( "The grammatical type of a word", "Verb" ) // 0 - << i18nc( "The grammatical type of a word", "Noun" ) // 1 - << i18nc( "The grammatical type of a word", "Name" ) - << i18nc( "The grammatical type of a word", "Article" ) // 3 - << i18nc( "The grammatical type of a word", "Adjective" ) // 4 - << i18nc( "The grammatical type of a word", "Adverb" ) // 5 - << i18nc( "The grammatical type of a word", "Pronoun" ) // 6 - << i18nc( "The grammatical type of an entry", "Phrase" ) - << i18nc( "The grammatical type of a word", "Numeral" ) // 8 - << i18nc( "The grammatical type of a word", "Conjunction" ) - << i18nc( "The grammatical type of a word", "Preposition" ) - << i18nc( "The grammatical type of an entry", "Question" ); - - foreach (const QString &typeName, wordTypeNames) { - KEduVocWordType* wordType = new KEduVocWordType(typeName, parent); - parent->appendChildContainer(wordType); - m_userdefinedTypeCounter++; - } - static_cast(parent->childContainer(4))->setWordType(KEduVocWordFlag::Adjective); - static_cast(parent->childContainer(5))->setWordType(KEduVocWordFlag::Adverb); - - KEduVocWordType* numeral = static_cast(parent->childContainer(8)); - KEduVocWordType* wordType = new KEduVocWordType( - i18nc( "@item:inlistbox A subtype of the grammatical word type: Numeral Ordinal (first, second, third, ...)","Ordinal" ), numeral); - wordType->setWordType(KEduVocWordFlag::Adjective); - numeral->appendChildContainer(wordType); - wordType = new KEduVocWordType( - i18nc( "@item:inlistbox A subtype of the grammatical word type: Numeral Cardinal (one, two, three, ...)","Cardinal" ), numeral); - - wordType->setWordType(KEduVocWordFlag::Adjective); - numeral->appendChildContainer(wordType); - - KEduVocWordType* article = static_cast(parent->childContainer(3)); - wordType = new KEduVocWordType(i18nc( "@item:inlistbox A subtype of the grammatical word type: Article (the)","Definite" ), article); - wordType->setWordType(KEduVocWordFlag::Article | KEduVocWordFlag::Definite); - article->appendChildContainer(wordType); - wordType = new KEduVocWordType(i18nc( "@item:inlistbox A subtype of the grammatical word type: Article (a)","Indefinite" ), article); - wordType->setWordType(KEduVocWordFlag::Article | KEduVocWordFlag::Indefinite); - article->appendChildContainer(wordType); - - KEduVocWordType* verb = static_cast(parent->childContainer(0)); - verb->setWordType(KEduVocWordFlag::Verb); - wordType = new KEduVocWordType(i18nc( "@item:inlistbox A subtype of the grammatical word type: Verb with regular conjugation","Regular" ), verb); - wordType->setWordType(KEduVocWordFlag::Verb | KEduVocWordFlag::Regular); - verb->appendChildContainer(wordType); - wordType = new KEduVocWordType(i18nc( "@item:inlistbox A subtype of the grammatical word type: Verb with irregular conjugation","Irregular" ), verb); - verb->appendChildContainer(wordType); - wordType->setWordType(KEduVocWordFlag::Verb | KEduVocWordFlag::Irregular); - - KEduVocWordType* noun = static_cast(parent->childContainer(1)); - noun->setWordType(KEduVocWordFlag::Noun); - wordType = new KEduVocWordType(i18nc( "@item:inlistbox A subtype of the grammatical word type: Noun", "Male" ), noun); - noun->appendChildContainer(wordType); - wordType->setWordType(KEduVocWordFlag::Noun | KEduVocWordFlag::Masculine); - wordType = new KEduVocWordType(i18nc( "@item:inlistbox A subtype of the grammatical word type: Noun", "Female" ), noun); - noun->appendChildContainer(wordType); - wordType->setWordType(KEduVocWordFlag::Noun | KEduVocWordFlag::Feminine); - wordType = new KEduVocWordType(i18nc( "@item:inlistbox A subtype of the grammatical word type: Noun", "Neutral" ), noun); - noun->appendChildContainer(wordType); - wordType->setWordType(KEduVocWordFlag::Noun | KEduVocWordFlag::Neuter); - - - KEduVocWordType* pronoun = static_cast(parent->childContainer(6)); - wordType = new KEduVocWordType(i18nc( "@item:inlistbox A subtype of the grammatical word type: Pronoun (my, your, his, her...)", "Possessive" ), pronoun); - wordType->setWordType(KEduVocWordFlag::Pronoun); - pronoun->appendChildContainer(wordType); - wordType = new KEduVocWordType(i18nc( "@item:inlistbox A subtype of the grammatical word type: Pronoun (I, you, he...)", "Personal" ), pronoun); - wordType->setWordType(KEduVocWordFlag::Pronoun); - pronoun->appendChildContainer(wordType); -} - diff --git a/keduvocdocument/keduvockvtmlcompability.h b/keduvocdocument/keduvockvtmlcompability.h deleted file mode 100644 index 4d05a44..0000000 --- a/keduvocdocument/keduvockvtmlcompability.h +++ /dev/null @@ -1,130 +0,0 @@ -/*************************************************************************** - - C++ Interface: keduvockvtml1compability_p - - ----------------------------------------------------------------------- - - begin : Di Aug 28 2007 - - copyright : (C) 2007 Frederik Gladhorn - - ----------------------------------------------------------------------- - - ***************************************************************************/ - -/*************************************************************************** - * * - * 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. * - * * - ***************************************************************************/ - -#ifndef KEDUVOCKVTMLCOMPABILITY_H -#define KEDUVOCKVTMLCOMPABILITY_H - -#include -#include -#include -#include - - -// internal types, indented are subtypes - -#define QM_VERB "v" // go -// #define QM_VERB_IRR "ir" -// #define QM_VERB_REG "re" -#define QM_NOUN "n" // table, coffee -// #define QM_NOUN_F "f" -// #define QM_NOUN_M "m" -// #define QM_NOUN_S "s" -#define QM_NAME "nm" -// #define QM_ART "ar" // article -// #define QM_ART_DEF "def" // definite a/an -// #define QM_ART_IND "ind" // indefinite the -#define QM_ADJ "aj" // adjective expensive, good -// #define QM_ADV "av" // adverb today, strongly -// #define QM_PRON "pr" // pronoun you, she -// #define QM_PRON_POS "pos" // possessive my, your -// #define QM_PRON_PER "per" // personal -// #define QM_PHRASE "ph" -// #define QM_NUM "num" // numeral -// #define QM_NUM_ORD "ord" // ordinal first, second -// #define QM_NUM_CARD "crd" // cardinal one, two -// #define QM_INFORMAL "ifm" -// #define QM_FIG "fig" -// #define QM_CON "con" // conjuncton and, but -// #define QM_PREP "pre" // preposition behind, between -// #define QM_QUEST "qu" // question who, what - -// type delimiters - -#define QM_USER_TYPE "#" // designates number of user type -#define QM_TYPE_DIV ":" // divide main from subtype - -// usage delimiters (also declared in UsageManager.h) - -#define UL_USER_USAGE "#" // designates number of user type - -class KEduVocWordType; - -/** - * @file contains defines and constants necessary for reading kvtml files prior to KDE4. kvtml version 1. - */ -class KEduVocKvtmlCompability -{ - -public: - /** - * Constructor, initialize the map. - */ - KEduVocKvtmlCompability(); - - ///// TYPES - /** - * Get the type from an old type definition - * @param typeSubtypeString the old string containing everything - * @return type - */ - KEduVocWordType* typeFromOldFormat(KEduVocWordType* parent, const QString & typeSubtypeString ) const; - - /** - * To write old docs: convert a nice new type to the ugly old style. - * @param mainType type - * @param subType subtype - * @return old type string - */ - QString oldType( const QString& mainType, const QString& subType ) const; - - - void addUserdefinedTense( const QString& tense ); - QString tenseFromKvtml1( const QString & oldTense ); - QStringList documentTenses() const; - QString oldTense( const QString& tense ); - - void setupWordTypes(KEduVocWordType* parent); - -private: - -//////////// TYPES ///////////////// - void initOldTypeLists(); - - QMap m_oldMainTypeNames; - QMap m_oldSubTypeNames; - int m_userdefinedTypeCounter; - -///////////TENSES/CONJUGATIONS/////// - void initOldTenses(); - - QMap m_oldTenses; - int m_userdefinedTenseCounter; - QSet m_tenses; - - /// # defines user defined usage/word type/tense - static const QString KVTML_1_USER_DEFINED; - /// : seperates usages/word types - static const QString KVTML_1_SEPERATOR; -}; - -#endif // KEDUVOCKVTMLCOMPABILITY_H diff --git a/keduvocdocument/keduvockvtmlreader.cpp b/keduvocdocument/keduvockvtmlreader.cpp deleted file mode 100644 index de2fd85..0000000 --- a/keduvocdocument/keduvockvtmlreader.cpp +++ /dev/null @@ -1,1095 +0,0 @@ -/*************************************************************************** - read a KEduVocDocument from a KVTML file - ----------------------------------------------------------------------- - copyright : (C) 1999-2001 Ewald Arnold - - (C) 2005 Eric Pignet - (C) 2007 Peter Hedlund - (C) 2007 Frederik Gladhorn - ***************************************************************************/ - -/*************************************************************************** - * * - * 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. * - * * - ***************************************************************************/ - -#include "keduvockvtmlreader.h" - -#include -#include -#include - -#include -#include -#include - -#include "keduvocdocument.h" -#include "keduvoclesson.h" -#include "keduvocwordtype.h" -#include "kvtmldefs.h" -#include "keduvoccommon_p.h" - -KEduVocKvtmlReader::KEduVocKvtmlReader( QIODevice *file ) -{ - // the file must be already open - m_inputFile = file; - m_errorMessage = ""; - kDebug() << "KEduVocKvtmlReader for kvtml version 1 files started."; -} - - -bool KEduVocKvtmlReader::readDoc( KEduVocDocument *doc ) -{ - m_doc = doc; - m_cols = 0; - m_lines = 0; - - QDomDocument domDoc( "KEduVocDocument" ); - - if ( !domDoc.setContent( m_inputFile, &m_errorMessage ) ) - return false; - - QDomElement domElementKvtml = domDoc.documentElement(); - if ( domElementKvtml.tagName() != KV_DOCTYPE ) { - m_errorMessage = i18n( "This is not a KDE Vocabulary document." ); - return false; - } - - //------------------------------------------------------------------------- - // Attributes - //------------------------------------------------------------------------- - - QDomAttr documentAttribute; - documentAttribute = domElementKvtml.attributeNode( KV_ENCODING ); - if ( !documentAttribute.isNull() ) { - // TODO handle old encodings - // Qt DOM API autodetects encoding, so is there anything to do ? - } - - documentAttribute = domElementKvtml.attributeNode( KV_TITLE ); - if ( !documentAttribute.isNull() ) - m_doc->setTitle( documentAttribute.value() ); - - documentAttribute = domElementKvtml.attributeNode( KV_AUTHOR ); - if ( !documentAttribute.isNull() ) - m_doc->setAuthor( documentAttribute.value() ); - - documentAttribute = domElementKvtml.attributeNode( KV_LICENSE ); - if ( !documentAttribute.isNull() ) - m_doc->setLicense( documentAttribute.value() ); - - documentAttribute = domElementKvtml.attributeNode( KV_DOC_REM ); - if ( !documentAttribute.isNull() ) - m_doc->setDocumentComment( documentAttribute.value() ); - - documentAttribute = domElementKvtml.attributeNode( KV_GENERATOR ); - if ( !documentAttribute.isNull() ) { - m_doc->setGenerator( documentAttribute.value() ); - int pos = m_doc->generator().lastIndexOf( KVD_VERS_PREFIX ); - if ( pos >= 0 ) - m_doc->setVersion( m_doc->generator().remove( 0, pos + 2 ) ); - } - - documentAttribute = domElementKvtml.attributeNode( KV_COLS ); - if ( !documentAttribute.isNull() ) - m_cols = documentAttribute.value().toInt(); ///currently not used anywhere - - documentAttribute = domElementKvtml.attributeNode( KV_LINES ); - if ( !documentAttribute.isNull() ) - m_lines = documentAttribute.value().toInt(); - - //------------------------------------------------------------------------- - // Children - //------------------------------------------------------------------------- - - bool result = readBody( domElementKvtml ); // read vocabulary - - return result; -} - - -bool KEduVocKvtmlReader::readBody( QDomElement &domElementParent ) -{ - bool result = false; - - QDomElement currentElement; - - currentElement = domElementParent.firstChildElement( KV_LESS_GRP ); - if ( !currentElement.isNull() ) { - result = readLesson( currentElement ); - if ( !result ) - return false; - } - - currentElement = domElementParent.firstChildElement( KV_ARTICLE_GRP ); - if ( !currentElement.isNull() ) { - result = readArticle( currentElement ); - if ( !result ) - return false; - } - - currentElement = domElementParent.firstChildElement( KV_CONJUG_GRP ); - if ( !currentElement.isNull() ) { - int count = 0; - - QDomElement domElementConjugChild = currentElement.firstChildElement(KV_CON_ENTRY); - while ( !domElementConjugChild.isNull() ) { - QString lang; - QDomAttr domAttrLang = domElementConjugChild.attributeNode( KV_LANG ); // "l" - // make sure, the identifier is there - if (!addLanguage(count, domAttrLang.value())) { - return false; - } - - KEduVocPersonalPronoun pronouns; - if (! readPersonalPronouns( domElementConjugChild, pronouns ) ) { - return false; - } - m_doc->identifier(count).setPersonalPronouns( pronouns ); - - count ++; - - domElementConjugChild = domElementConjugChild.nextSiblingElement( KV_CON_ENTRY ); - } - } - - // initialize the list of predefined types - m_compability.setupWordTypes(m_doc->wordTypeContainer()); - - currentElement = domElementParent.firstChildElement( KV_TYPE_GRP ); - if ( !currentElement.isNull() ) { - result = readType( currentElement ); - if ( !result ) - return false; - } - - currentElement = domElementParent.firstChildElement( KV_TENSE_GRP ); - if ( !currentElement.isNull() ) { - result = readTense( currentElement ); - if ( !result ) - return false; - } - - QDomNodeList entryList = domElementParent.elementsByTagName( KV_EXPR ); - if ( entryList.length() <= 0 ) - return false; - - for ( int i = 0; i < entryList.count(); ++i ) { - currentElement = entryList.item( i ).toElement(); - if ( currentElement.parentNode() == domElementParent ) { - result = readExpression( currentElement ); - if ( !result ) - return false; - } - } - - for(int i = 0; i < m_doc->identifierCount(); i++) { - m_doc->identifier(i).setTenseList(m_compability.documentTenses()); - } - - return true; -} - - -bool KEduVocKvtmlReader::readLesson( QDomElement &domElementParent ) -{ - QString s; - QDomAttr attribute; - QDomElement currentElement; - - - //------------------------------------------------------------------------- - // Children - //------------------------------------------------------------------------- - - QDomNodeList entryList = domElementParent.elementsByTagName( KV_LESS_DESC ); - if ( entryList.length() <= 0 ) - return false; - - for ( int i = 0; i < entryList.count(); ++i ) { - currentElement = entryList.item( i ).toElement(); - if ( currentElement.parentNode() == domElementParent ) { - int no = -1; - - attribute = currentElement.attributeNode( KV_LESS_NO ); - if ( !attribute.isNull() ) { - no = attribute.value().toInt(); - } - - bool inQuery = false; - attribute = currentElement.attributeNode( KV_LESS_QUERY ); - if ( !attribute.isNull() ) { - inQuery = (attribute.value().toInt() != 0); - } - - s = currentElement.text(); - KEduVocLesson* lesson = new KEduVocLesson(s, m_doc->lesson()); - lesson->setInPractice(inQuery); - m_doc->lesson()->appendChildContainer( lesson ); - if ( m_doc->lesson()->childContainerCount() != no-1 ) { - kDebug() << "Warning! Lesson order may be confused. Are all lessons in order in the file?"; - } - } - } - - return true; -} - - -bool KEduVocKvtmlReader::readArticle( QDomElement &domElementParent ) -/* -
- lang determines also lang order in entries !! - eine which must NOT differ - die - ein - der - ein - das - -
-*/ -{ - - QString s; - QDomAttr attribute; - QDomElement currentElement; - QDomElement article; - - QDomNodeList entryList = domElementParent.elementsByTagName( KV_ART_ENTRY ); - if ( entryList.length() <= 0 ) - return false; - - for ( int i = 0; i < entryList.count(); ++i ) { - -//kDebug() << "KEduVocKvtmlReader::readArticle() read " << entryList.count() << " articles. "; - currentElement = entryList.item( i ).toElement(); - if ( currentElement.parentNode() == domElementParent ) { - QString lang; - attribute = currentElement.attributeNode( KV_LANG ); - - if (!addLanguage(i, attribute.value())) { - return false; - } - - //--------- - // Children - - QString fem_def = ""; - QString mal_def = ""; - QString nat_def = ""; - QString fem_indef = ""; - QString mal_indef = ""; - QString nat_indef = ""; - - article = currentElement.firstChildElement( KV_ART_FD ); - if ( !article.isNull() ) { - fem_def = article.text(); - if ( fem_def.isNull() ) - fem_def = ""; - } - - article = currentElement.firstChildElement( KV_ART_FI ); - if ( !article.isNull() ) { - fem_indef = article.text(); - if ( fem_indef.isNull() ) - fem_indef = ""; - } - - article = currentElement.firstChildElement( KV_ART_MD ); - if ( !article.isNull() ) { - mal_def = article.text(); - if ( mal_def.isNull() ) - mal_def = ""; - } - - article = currentElement.firstChildElement( KV_ART_MI ); - if ( !article.isNull() ) { - mal_indef = article.text(); - if ( mal_indef.isNull() ) - mal_indef = ""; - } - - article = currentElement.firstChildElement( KV_ART_ND ); - if ( !article.isNull() ) { - nat_def = article.text(); - if ( nat_def.isNull() ) - nat_def = ""; - } - - article = currentElement.firstChildElement( KV_ART_NI ); - if ( !article.isNull() ) { - nat_indef = article.text(); - if ( nat_indef.isNull() ) - nat_indef = ""; - } - - m_doc->identifier(i).setArticle( KEduVocArticle( fem_def, fem_indef, mal_def, mal_indef, nat_def, nat_indef ) ); - } - } - - return true; -} - - -bool KEduVocKvtmlReader::readTranslationConjugations( QDomElement &domElementParent, KEduVocTranslation* translation ) -{ - QString tense; - - QDomElement domElementConjugChild = domElementParent.firstChildElement(KV_CON_TYPE); - while ( !domElementConjugChild.isNull() ) - { - // "n" == is the type is the tense - QDomAttr domAttrLang = domElementConjugChild.attributeNode( KV_CON_NAME ); - QString oldShortTense = domAttrLang.value(); - - tense = m_compability.tenseFromKvtml1( oldShortTense ); - KEduVocConjugation conjugation; - readConjugation(domElementConjugChild, conjugation); - translation->setConjugation(tense, conjugation); - - domElementConjugChild = domElementConjugChild.nextSiblingElement( KV_CON_TYPE ); - } // while -> next tense, count++ - return true; -} - -bool KEduVocKvtmlReader::readConjugation( QDomElement &domElementParent, KEduVocConjugation& conjugation ) -/* - used in header for definiton of "prefix" - lang determines also lang order in entries !! - I which must NOT differ - you<2> - he - she - it - we - you - they - they - they - - - - and in entry for definition of tenses of (irreg.) verbs - - go - go - goes - goes - goes - go - go - go - go - go - - -*/ -{ -// QString s; - bool p3_common; - bool s3_common; - QString pers1_sing; - QString pers2_sing; - QString pers3_m_sing; - QString pers3_f_sing; - QString pers3_n_sing; - QString pers1_plur; - QString pers2_plur; - QString pers3_m_plur; - QString pers3_f_plur; - QString pers3_n_plur; - - p3_common = false; - s3_common = false; - - // get the individual entries for persons... - QDomElement domElementConjugGrandChild = domElementParent.firstChild().toElement(); - while ( !domElementConjugGrandChild.isNull() ) { - if ( domElementConjugGrandChild.tagName() == KV_CON_P1S ) { - pers1_sing = domElementConjugGrandChild.text(); - } else if ( domElementConjugGrandChild.tagName() == KV_CON_P2S ) { - pers2_sing = domElementConjugGrandChild.text(); - } else if ( domElementConjugGrandChild.tagName() == KV_CON_P3SF ) { - QDomAttr domAttrCommon = domElementConjugGrandChild.attributeNode( KV_CONJ_COMMON ); - if ( !domAttrCommon.isNull() ) - s3_common = domAttrCommon.value().toInt(); // returns 0 if the conversion fails - pers3_f_sing = domElementConjugGrandChild.text(); - - } else if ( domElementConjugGrandChild.tagName() == KV_CON_P3SM ) { - pers3_m_sing = domElementConjugGrandChild.text(); - - } else if ( domElementConjugGrandChild.tagName() == KV_CON_P3SN ) { - pers3_n_sing = domElementConjugGrandChild.text(); - - } else if ( domElementConjugGrandChild.tagName() == KV_CON_P1P ) { - pers1_plur = domElementConjugGrandChild.text(); - - } else if ( domElementConjugGrandChild.tagName() == KV_CON_P2P ) { - pers2_plur = domElementConjugGrandChild.text(); - - } else if ( domElementConjugGrandChild.tagName() == KV_CON_P3PF ) { - QDomAttr domAttrCommon = domElementConjugGrandChild.attributeNode( KV_CONJ_COMMON ); - if ( !domAttrCommon.isNull() ) - p3_common = domAttrCommon.value().toInt(); // returns 0 if the conversion fails - - pers3_f_plur = domElementConjugGrandChild.text(); - - } else if ( domElementConjugGrandChild.tagName() == KV_CON_P3PM ) { - pers3_m_plur = domElementConjugGrandChild.text(); - - } else if ( domElementConjugGrandChild.tagName() == KV_CON_P3PN ) { - pers3_n_plur = domElementConjugGrandChild.text(); - - } else { - return false; - } - - domElementConjugGrandChild = domElementConjugGrandChild.nextSibling().toElement(); - } // while - probably to be sure, because the persons could be in any order. - // I guess this goes over only one set, such as: - // traigotraestrae - // traemostraéistraen - // until no elements are left in that soup. - - // now set the data: [count] - number of conjug? - // type - the tense? - // finally the person - - const KEduVocWordFlags numS = KEduVocWordFlag::Singular; - const KEduVocWordFlags numP = KEduVocWordFlag::Plural; - - conjugation.setConjugation( pers1_sing, KEduVocWordFlag::First | numS); - conjugation.setConjugation( pers2_sing, KEduVocWordFlag::Second | numS); - conjugation.setConjugation( pers1_plur, KEduVocWordFlag::First | numP); - conjugation.setConjugation( pers2_plur, KEduVocWordFlag::Second | numP); - - if ( s3_common ) { - conjugation.setConjugation( pers3_f_sing, KEduVocWordFlag::Third | KEduVocWordFlag::Neuter | KEduVocWordFlag::Singular ); - } else { - conjugation.setConjugation( pers3_m_sing, - KEduVocWordFlag::Third | KEduVocWordFlag::Masculine | KEduVocWordFlag::Singular ); - conjugation.setConjugation( pers3_f_sing, - KEduVocWordFlag::Third | KEduVocWordFlag::Feminine | KEduVocWordFlag::Singular ); - conjugation.setConjugation( pers3_n_sing, - KEduVocWordFlag::Third | KEduVocWordFlag::Neuter | KEduVocWordFlag::Singular ); - } - - if ( p3_common ) { - conjugation.setConjugation( pers3_f_plur, KEduVocWordFlag::Third | KEduVocWordFlag::Neuter | KEduVocWordFlag::Plural ); - } else { - conjugation.setConjugation( pers3_m_plur, - KEduVocWordFlag::Third | KEduVocWordFlag::Masculine | KEduVocWordFlag::Plural ); - conjugation.setConjugation( pers3_f_plur, - KEduVocWordFlag::Third | KEduVocWordFlag::Feminine | KEduVocWordFlag::Plural ); - conjugation.setConjugation( pers3_n_plur, - KEduVocWordFlag::Third | KEduVocWordFlag::Neuter | KEduVocWordFlag::Plural ); - } - - return true; -} - - - - -bool KEduVocKvtmlReader::readPersonalPronouns( QDomElement &domElementParent, KEduVocPersonalPronoun& pronouns ) -{ -// QString s; - bool p3_common; - bool s3_common; - QString pers1_sing; - QString pers2_sing; - QString pers3_m_sing; - QString pers3_f_sing; - QString pers3_n_sing; - QString pers1_plur; - QString pers2_plur; - QString pers3_m_plur; - QString pers3_f_plur; - QString pers3_n_plur; - - p3_common = false; - s3_common = false; - - // get the individual entries for persons... - QDomElement domElementConjugGrandChild = domElementParent.firstChild().toElement(); - while ( !domElementConjugGrandChild.isNull() ) { - if ( domElementConjugGrandChild.tagName() == KV_CON_P1S ) { - pers1_sing = domElementConjugGrandChild.text(); - } else if ( domElementConjugGrandChild.tagName() == KV_CON_P2S ) { - pers2_sing = domElementConjugGrandChild.text(); - } else if ( domElementConjugGrandChild.tagName() == KV_CON_P3SF ) { - QDomAttr domAttrCommon = domElementConjugGrandChild.attributeNode( KV_CONJ_COMMON ); - if ( !domAttrCommon.isNull() ) - s3_common = domAttrCommon.value().toInt(); // returns 0 if the conversion fails - pers3_f_sing = domElementConjugGrandChild.text(); - - } else if ( domElementConjugGrandChild.tagName() == KV_CON_P3SM ) { - pers3_m_sing = domElementConjugGrandChild.text(); - - } else if ( domElementConjugGrandChild.tagName() == KV_CON_P3SN ) { - pers3_n_sing = domElementConjugGrandChild.text(); - - } else if ( domElementConjugGrandChild.tagName() == KV_CON_P1P ) { - pers1_plur = domElementConjugGrandChild.text(); - - } else if ( domElementConjugGrandChild.tagName() == KV_CON_P2P ) { - pers2_plur = domElementConjugGrandChild.text(); - - } else if ( domElementConjugGrandChild.tagName() == KV_CON_P3PF ) { - QDomAttr domAttrCommon = domElementConjugGrandChild.attributeNode( KV_CONJ_COMMON ); - if ( !domAttrCommon.isNull() ) - p3_common = domAttrCommon.value().toInt(); // returns 0 if the conversion fails - - pers3_f_plur = domElementConjugGrandChild.text(); - - } else if ( domElementConjugGrandChild.tagName() == KV_CON_P3PM ) { - pers3_m_plur = domElementConjugGrandChild.text(); - - } else if ( domElementConjugGrandChild.tagName() == KV_CON_P3PN ) { - pers3_n_plur = domElementConjugGrandChild.text(); - - } else { - return false; - } - - domElementConjugGrandChild = domElementConjugGrandChild.nextSibling().toElement(); - } // while - probably to be sure, because the persons could be in any order. - // I guess this goes over only one set, such as: - // traigotraestrae - // traemostraéistraen - // until no elements are left in that soup. - - // now set the data: [count] - number of conjug? - // type - the tense? - // finally the person - - KEduVocWordFlags numS = KEduVocWordFlag::Singular; - pronouns.setMaleFemaleDifferent(false); - pronouns.setPersonalPronoun( pers1_sing, KEduVocWordFlag::First | numS ); - pronouns.setPersonalPronoun( pers2_sing, KEduVocWordFlag::Second | numS ); - - // used to have common in female - if ( s3_common ) { - pronouns.setPersonalPronoun( pers3_f_sing, KEduVocWordFlag::Third | KEduVocWordFlag::Neuter | numS ); - } else { - pronouns.setPersonalPronoun( pers3_m_sing, - KEduVocWordFlag::Third | KEduVocWordFlag::Masculine | numS ); - pronouns.setPersonalPronoun( pers3_f_sing, - KEduVocWordFlag::Third | KEduVocWordFlag::Feminine | numS ); - pronouns.setPersonalPronoun( pers3_n_sing, - KEduVocWordFlag::Third | KEduVocWordFlag::Neuter | numS ); - pronouns.setMaleFemaleDifferent(true); - } - - KEduVocWordFlags numP = KEduVocWordFlag::Plural; - - pronouns.setPersonalPronoun( pers1_plur, KEduVocWordFlag::First | numP ); - pronouns.setPersonalPronoun( pers2_plur, KEduVocWordFlag::Second | numP ); - if ( p3_common ) { - pronouns.setPersonalPronoun( pers3_f_plur, KEduVocWordFlag::Third | KEduVocWordFlag::Neuter | numP ); - } else { - pronouns.setPersonalPronoun( pers3_m_plur, - KEduVocWordFlag::Third | KEduVocWordFlag::Masculine | numP ); - pronouns.setPersonalPronoun( pers3_f_plur, - KEduVocWordFlag::Third | KEduVocWordFlag::Feminine | numP ); - pronouns.setPersonalPronoun( pers3_n_plur, - KEduVocWordFlag::Third | KEduVocWordFlag::Neuter | numP ); - pronouns.setMaleFemaleDifferent(true); - } - - return true; -} - - -bool KEduVocKvtmlReader::readType( QDomElement &domElementParent ) -{ - QString s; - QDomElement currentElement; - - QDomNodeList entryList = domElementParent.elementsByTagName( KV_TYPE_DESC ); - if ( entryList.length() <= 0 ) - return false; - - for ( int i = 0; i < entryList.count(); ++i ) { - currentElement = entryList.item( i ).toElement(); - if ( currentElement.parentNode() == domElementParent ) { - // We need to even add empty elements since the old system relied on - // the order. So "type1" "" "type2" should be just like that. - - kDebug() << "Adding old self defined type: " << currentElement.text(); - // add the type to the list of available types - KEduVocWordType* type = new KEduVocWordType(currentElement.text(), m_doc->wordTypeContainer()); - m_doc->wordTypeContainer()->appendChildContainer( type ); - - // from this the #1 are transformed to something sensible again - m_oldSelfDefinedTypes.append( currentElement.text() ); - } - } - - return true; -} - - -bool KEduVocKvtmlReader::readTense( QDomElement &domElementParent ) -{ - QDomElement currentElement; - - currentElement = domElementParent.firstChildElement( KV_TENSE_DESC ); - while ( !currentElement.isNull() ) { - kDebug() << "Reading user defined tense description: " << currentElement.text(); - m_compability.addUserdefinedTense( currentElement.text() ); - currentElement = currentElement.nextSiblingElement( KV_TENSE_DESC ); - } - return true; -} - - -bool KEduVocKvtmlReader::readComparison( QDomElement &domElementParent, KEduVocTranslation * translation ) -/* - - good --- this one is dead as it always has to be the word itself - better - best - -*/ -{ - QDomElement currentElement; - - currentElement = domElementParent.firstChildElement( KV_COMP_L2 ); - translation->setComparative(currentElement.text()); - - currentElement = domElementParent.firstChildElement( KV_COMP_L3 ); - translation->setSuperlative(currentElement.text()); - - return true; -} - - -bool KEduVocKvtmlReader::readMultipleChoice( QDomElement &domElementParent, KEduVocTranslation* translation ) -/* - - good - better - best - best 2 - best 3 - -*/ - -{ - QDomElement currentElement; - - currentElement = domElementParent.firstChildElement( KV_MC_1 ); - if ( !currentElement.isNull() ) { - translation->multipleChoice().append( currentElement.text() ); - } - - currentElement = domElementParent.firstChildElement( KV_MC_2 ); - if ( !currentElement.isNull() ) { - translation->multipleChoice().append( currentElement.text() ); - } - - currentElement = domElementParent.firstChildElement( KV_MC_3 ); - if ( !currentElement.isNull() ) { - translation->multipleChoice().append( currentElement.text() ); - } - - currentElement = domElementParent.firstChildElement( KV_MC_4 ); - if ( !currentElement.isNull() ) { - translation->multipleChoice().append( currentElement.text() ); - } - - currentElement = domElementParent.firstChildElement( KV_MC_5 ); - if ( !currentElement.isNull() ) { - translation->multipleChoice().append( currentElement.text() ); - } - - return true; -} - - -bool KEduVocKvtmlReader::readExpressionChildAttributes( QDomElement &domElementExpressionChild, - QString &lang, - grade_t &grade, grade_t &rev_grade, - int &count, int &rev_count, - QDateTime &date, QDateTime &rev_date, - QString &remark, - int &bcount, int &rev_bcount, - QString &query_id, - QString &pronunciation, - int &width, - QString &type, - QString &faux_ami_f, - QString &faux_ami_t, - QString &synonym, - QString &example, - QString &antonym, - QSet &usages, - QString ¶phrase ) -{ - int pos; - QDomAttr attribute; - - lang = ""; - attribute = domElementExpressionChild.attributeNode( KV_LANG ); - if ( !attribute.isNull() ) - lang = attribute.value(); - - width = -1; - attribute = domElementExpressionChild.attributeNode( KV_SIZEHINT ); - if ( !attribute.isNull() ) - width = attribute.value().toInt(); - - grade = KV_NORM_GRADE; - rev_grade = KV_NORM_GRADE; - attribute = domElementExpressionChild.attributeNode( KV_GRADE ); - if ( !attribute.isNull() ) { - QString s = attribute.value(); - if (( pos = s.indexOf( ';' ) ) >= 1 ) { - grade = s.left( pos ).toInt(); - rev_grade = s.mid( pos + 1, s.length() ).toInt(); - } else - grade = s.toInt(); - } - - count = 0; - rev_count = 0; - attribute = domElementExpressionChild.attributeNode( KV_COUNT ); - if ( !attribute.isNull() ) { - QString s = attribute.value(); - if (( pos = s.indexOf( ';' ) ) >= 1 ) { - count = s.left( pos ).toInt(); - rev_count = s.mid( pos + 1, s.length() ).toInt(); - } else - count = s.toInt(); - } - - bcount = 0; - rev_bcount = 0; - attribute = domElementExpressionChild.attributeNode( KV_BAD ); - if ( !attribute.isNull() ) { - QString s = attribute.value(); - if (( pos = s.indexOf( ';' ) ) >= 1 ) { - bcount = s.left( pos ).toInt(); - rev_bcount = s.mid( pos + 1, s.length() ).toInt(); - } else - bcount = s.toInt(); - } - - date.setTime_t( 0 ); - rev_date.setTime_t( 0 ); - attribute = domElementExpressionChild.attributeNode( KV_DATE ); - if ( !attribute.isNull() ) { - QString s = attribute.value(); - if (( pos = s.indexOf( ';' ) ) >= 1 ) { - date.setTime_t( s.left( pos ).toInt() ); - rev_date.setTime_t( s.mid( pos + 1, s.length() ).toInt() ); - } else - date.setTime_t( s.toInt() ); - } - - attribute = domElementExpressionChild.attributeNode( KV_DATE2 ); - if ( !attribute.isNull() ) { - //this format is deprecated and ignored. - } - - remark = ""; - attribute = domElementExpressionChild.attributeNode( KV_REMARK ); - if ( !attribute.isNull() ) - remark = attribute.value(); - - faux_ami_f = ""; - attribute = domElementExpressionChild.attributeNode( KV_FAUX_AMI_F ); - if ( !attribute.isNull() ) - faux_ami_f = attribute.value(); - - faux_ami_t = ""; - attribute = domElementExpressionChild.attributeNode( KV_FAUX_AMI_T ); - if ( !attribute.isNull() ) - faux_ami_t = attribute.value(); - - synonym = ""; - attribute = domElementExpressionChild.attributeNode( KV_SYNONYM ); - if ( !attribute.isNull() ) - synonym = attribute.value(); - - example = ""; - attribute = domElementExpressionChild.attributeNode( KV_EXAMPLE ); - if ( !attribute.isNull() ) - example = attribute.value(); - - paraphrase = ""; - attribute = domElementExpressionChild.attributeNode( KV_PARAPHRASE ); - if ( !attribute.isNull() ) - paraphrase = attribute.value(); - - antonym = ""; - attribute = domElementExpressionChild.attributeNode( KV_ANTONYM ); - if ( !attribute.isNull() ) - antonym = attribute.value(); - - // this is all done by reference - so we have to care about "type" :( - attribute = domElementExpressionChild.attributeNode( KV_EXPRTYPE ); - if ( !attribute.isNull() ) { - type = attribute.value(); - } - - pronunciation = ""; - attribute = domElementExpressionChild.attributeNode( KV_PRONUNCE ); - if ( !attribute.isNull() ) - pronunciation = attribute.value(); - - query_id = ""; - attribute = domElementExpressionChild.attributeNode( KV_QUERY ); - if ( !attribute.isNull() ) - query_id = attribute.value(); - - return true; -} - - -bool KEduVocKvtmlReader::readExpression( QDomElement &domElementParent ) -{ - grade_t grade; - grade_t r_grade; - int qcount; - int r_qcount; - int bcount; - int r_bcount; - QString remark; - QString pronunciation; - QDateTime qdate; - QDateTime r_qdate; - bool inquery; - bool active; - QString lang; - QString textstr; - QString q_org; - QString q_trans; - QString query_id; - int width; - QString type; - QString faux_ami_f; - QString faux_ami_t; - QString synonym; - QString example; - QString antonym; - QSet usage; - QString paraphrase; - - QDomAttr attribute; - QDomElement currentElement; - QDomElement currentChild; - - int lessonNumber = -1; - - //------------------------------------------------------------------------- - // Attributes - //------------------------------------------------------------------------- - - attribute = domElementParent.attributeNode( KV_LESS_MEMBER ); - if ( !attribute.isNull() ) { - // we start conting from 0 in new documents - lessonNumber = attribute.value().toInt() - 1; - if ( lessonNumber > m_doc->lesson()->childContainerCount() ) { - ///@todo can this happen? does it need a while loop? - // it's from a lesson that hasn't been added yet - // so make sure this lesson is in the document - kDebug() << "Warning: lesson > m_doc->lessonCount() in readExpression."; - - KEduVocLesson* lesson = new KEduVocLesson(i18nc("A generic name for a new lesson and its number.", "Lesson %1", lessonNumber ), m_doc->lesson()); - m_doc->lesson()->appendChildContainer(lesson); - } - } - - attribute = domElementParent.attributeNode( KV_SELECTED ); - if ( !attribute.isNull() ) - inquery = attribute.value() == "1" ? true : false; - else - inquery = false; - - attribute = domElementParent.attributeNode( KV_INACTIVE ); - if ( !attribute.isNull() ) - active = attribute.value() == "1" ? false : true; - else - active = true; - - // this is all done by reference - so we have to care about "type" :( - attribute = domElementParent.attributeNode( KV_EXPRTYPE ); - if ( !attribute.isNull() ) { - type = attribute.value(); - } - - - - - - - //------------------------------------------------------------------------- - // Children 'Translation' - //------------------------------------------------------------------------- - - //QDomNodeList translationList = domElementParent.elementsByTagName(KV_TRANS); - - // count which translation we are on - int i=0; - - // kvtml 1: we always have an original element (required) - currentElement = domElementParent.firstChildElement( KV_ORG ); - if ( currentElement.isNull() ) { // sanity check - m_errorMessage = i18n( "Data for original language missing" ); - return false; - } - - KEduVocExpression* entry; - - while ( !currentElement.isNull() ) { - - //----------- - // Attributes - //----------- - - // read attributes - the order of the query grades is interchanged! - if ( i == 0 && !readExpressionChildAttributes( currentElement, lang, grade, r_grade, qcount, r_qcount, qdate, r_qdate, remark, bcount, r_bcount, query_id, - pronunciation, width, type, faux_ami_t, faux_ami_f, synonym, example, antonym, usage, paraphrase ) ) { - return false; - } - - if ( i != 0 && !readExpressionChildAttributes( currentElement, lang, grade, r_grade, qcount, r_qcount, qdate, r_qdate, remark, bcount, r_bcount, query_id, - pronunciation, width, type, faux_ami_f, faux_ami_t, synonym, example, antonym, usage, paraphrase ) ) { - return false; - } - - - //--------- - // Children - - textstr = currentElement.lastChild().toText().data(); - - if ( i == 0 ) { - entry = new KEduVocExpression( textstr ); - entry->setActive( active ); - if ( lessonNumber != -1 ) { - static_cast(m_doc->lesson()->childContainer(lessonNumber))->appendEntry(entry); - } else { - m_doc->lesson()->appendEntry(entry); - } - } else { - entry->setTranslation( i, textstr ); - } - - if ( m_doc->lesson()->entries(KEduVocLesson::Recursive).count() == 1 ) { // this is because in kvtml the languages are saved in the FIRST ENTRY ONLY. - // new translation - if (!addLanguage(i, lang)) { - return false; - } - } - - // better make sure, translation(i) already exists... - currentChild = currentElement.firstChildElement( KV_CONJUG_GRP ); - if ( !currentChild.isNull() ) { - if ( !readTranslationConjugations( currentChild, entry->translation(i) ) ) { - return false; - } - } - - currentChild = currentElement.firstChildElement( KV_MULTIPLECHOICE_GRP ); - if ( !currentChild.isNull() ) { - if ( !readMultipleChoice( currentChild, entry->translation(i) ) ) { - return false; - } - } - - currentChild = currentElement.firstChildElement( KV_COMPARISON_GRP ); - if ( !currentChild.isNull() ) { - if ( !readComparison( currentChild, entry->translation(i) ) ) { - return false; - } - } - - if ( !type.isEmpty() ) { - KEduVocWordType* wordType = m_compability.typeFromOldFormat(m_doc->wordTypeContainer(), type); - entry->translation(i)->setWordType(wordType); - } - - if ( !remark.isEmpty() ) - entry->translation( i )->setComment( remark ); - if ( !pronunciation.isEmpty() ) - entry->translation( i )->setPronunciation( pronunciation ); - - ///@todo include false friends from kvtml-1 again? -// if ( !faux_ami_f.isEmpty() ) -// entry->translation( i )->setFalseFriend( 0, faux_ami_f ); -// if ( !faux_ami_t.isEmpty() ) -// entry->translation( 0 )->setFalseFriend( i, faux_ami_t ); - ///@todo include synonyms from kvtml-1 again? -// if ( !synonym.isEmpty() ) -// entry->translation( i )->setSynonym( synonym ); -// if ( !antonym.isEmpty() ) -// entry->translation( i )->setAntonym( antonym ); - - if ( !example.isEmpty() ) - entry->translation( i )->setExample( example ); - if ( !paraphrase.isEmpty() ) - entry->translation( i )->setParaphrase( paraphrase ); - - if ( i != 0 ) { - entry->translation( i )->setGrade( grade ); - entry->translation( 0 )->setGrade( r_grade ); - entry->translation( i )->setPracticeCount( qcount ); - entry->translation( 0 )->setPracticeCount( r_qcount ); - entry->translation( i )->setBadCount( bcount ); - entry->translation( 0 )->setBadCount( r_bcount ); - entry->translation( i )->setPracticeDate( qdate ); - entry->translation( 0 )->setPracticeDate( r_qdate ); - } - - // Next translation - currentElement = currentElement.nextSiblingElement( KV_TRANS ); - i++; - } - - return true; -} - - -bool KEduVocKvtmlReader::addLanguage( int languageId, const QString& locale) -{ - if ( m_doc->identifierCount() <= languageId ) { - m_doc->appendIdentifier(); - // first entry - if ( !locale.isEmpty() ) { // no definition in first entry - m_doc->identifier(languageId).setLocale(locale); - - QString languageName; - if (KGlobal::locale()) { - // when using from qt-only apps this would crash (converter) - languageName = KGlobal::locale()->languageCodeToName(locale); - } - if ( languageName.isEmpty() ) { - languageName = locale; - } - - m_doc->identifier(languageId).setName(languageName); - kDebug() << "addLanguage( " << languageId << ", " << locale << "): " << languageName; - - } - } else { - if ( !locale.isEmpty() ) { - if ( locale != m_doc->identifier(languageId).locale() ) { - // different originals ? - m_errorMessage = i18n( "Ambiguous definition of language code" ); - return false; - } - } - } - return true; -} - - -#include "keduvockvtmlreader.moc" diff --git a/keduvocdocument/keduvockvtmlreader.h b/keduvocdocument/keduvockvtmlreader.h deleted file mode 100644 index 85717c1..0000000 --- a/keduvocdocument/keduvockvtmlreader.h +++ /dev/null @@ -1,103 +0,0 @@ -/*************************************************************************** - read a KEduVocDocument from a KVTML file - ----------------------------------------------------------------------- - copyright : (C) 1999-2001 Ewald Arnold - - (C) 2005 Eric Pignet - (C) 2007 Peter Hedlund - (C) 2007 Frederik Gladhorn - ***************************************************************************/ - -/*************************************************************************** - * * - * 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. * - * * - ***************************************************************************/ - -#ifndef KEDUVOCKVTMLREADER_H -#define KEDUVOCKVTMLREADER_H - -#include -#include - - -#include "keduvocexpression.h" -#include "keduvocarticle.h" -#include "keduvocmultiplechoice.h" -#include "keduvockvtmlcompability.h" -#include "keduvocpersonalpronoun.h" - -class QIODevice; -class KEduVocDocument; - -/** -@author Eric Pignet -*/ -class KEduVocKvtmlReader : public QObject -{ - Q_OBJECT -public: - KEduVocKvtmlReader( QIODevice *file ); - - bool readDoc( KEduVocDocument *doc ); - - /** - * Attempt to add a language/locale. Language/locale are set to the same value. - * No error if already there with the same value. - * @param languageId idenifier number - * @param language name - * @return true if successful - */ - bool addLanguage( int languageId, const QString& language); - - bool readLesson( QDomElement &domElementParent ); - bool readArticle( QDomElement &domElementParent ); - bool readPersonalPronouns( QDomElement &domElementParent, KEduVocPersonalPronoun& pronouns ); - bool readConjugation( QDomElement &domElementParent, KEduVocConjugation &conjugation ); - bool readTranslationConjugations( QDomElement &domElementParent, KEduVocTranslation* translation ); - bool readType( QDomElement &domElementParent ); - bool readTense( QDomElement &domElementParent ); - bool readUsage( QDomElement &domElementParent ); - bool readComparison( QDomElement &domElementParent, KEduVocTranslation* translation ); - bool readMultipleChoice( QDomElement &domElementParent, KEduVocTranslation* translation ); - bool readExpressionChildAttributes( QDomElement &domElementExpressionChild, - QString &lang, - grade_t &grade, grade_t &rev_grade, - int &count, int &rev_count, - QDateTime &date, QDateTime &rev_date, - QString &remark, - int &bcount, int &rev_bcount, - QString &query_id, - QString &pronunciation, - int &width, - QString &type, - QString &faux_ami_f, - QString &faux_ami_t, - QString &synonym, - QString &example, - QString &antonym, - QSet &usage, - QString ¶phrase ); - bool readExpression( QDomElement &domElementParent ); - bool readBody( QDomElement &domElementParent ); - - QString errorMessage() const - { - return m_errorMessage; - } - -private: - QIODevice *m_inputFile; - KEduVocDocument *m_doc; - QString m_errorMessage; - int m_cols; - int m_lines; - QStringList m_oldSelfDefinedTypes; - - KEduVocKvtmlCompability m_compability; -}; - -#endif diff --git a/keduvocdocument/keduvockvtmlwriter.cpp b/keduvocdocument/keduvockvtmlwriter.cpp deleted file mode 100644 index bb4aa78..0000000 --- a/keduvocdocument/keduvockvtmlwriter.cpp +++ /dev/null @@ -1,934 +0,0 @@ -/*************************************************************************** - export a KEduVocDocument to a KVTML file - ----------------------------------------------------------------------- - copyright : (C) 1999-2001 Ewald Arnold - - (C) 2005 Eric Pignet - (C) 2007 Peter Hedlund - (C) 2007 Frederik Gladhorn - ***************************************************************************/ - -/*************************************************************************** - * * - * 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. * - * * - ***************************************************************************/ - -#include "keduvockvtmlwriter.h" - -#include -#include -#include - -#include - -#include "keduvocdocument.h" -#include "keduvocgrade.h" -#include "keduvoclesson.h" -#include "keduvocexpression.h" -#include "kvtmldefs.h" -#include "keduvoccommon_p.h" - -KEduVocKvtmlWriter::KEduVocKvtmlWriter( QFile *file ) -{ - // the file must be already open - m_outputFile = file; -} - - -bool KEduVocKvtmlWriter::writeDoc( KEduVocDocument *doc, const QString &generator ) -{ - bool first_expr = true; - - m_doc = doc; - - m_domDoc = QDomDocument( "kvtml SYSTEM \"kvoctrain.dtd\"" ); - m_domDoc.appendChild( m_domDoc.createProcessingInstruction( "xml", "version=\"1.0\" encoding=\"UTF-8\"" ) ); - QDomElement domElementKvtml = m_domDoc.createElement( "kvtml" ); - m_domDoc.appendChild( domElementKvtml ); - - domElementKvtml.setAttribute( KV_ENCODING, ( QString ) "UTF-8" ); - domElementKvtml.setAttribute( KV_GENERATOR, generator ); - domElementKvtml.setAttribute( KV_COLS, m_doc->identifierCount() ); - domElementKvtml.setAttribute( KV_LINES, m_doc->entryCount() ); - - if ( !m_doc->title().isEmpty() ) - domElementKvtml.setAttribute( KV_TITLE, m_doc->title() ); - - if ( !m_doc->author().isEmpty() ) - domElementKvtml.setAttribute( KV_AUTHOR, m_doc->author() ); - - if ( !m_doc->license().isEmpty() ) - domElementKvtml.setAttribute( KV_LICENSE, m_doc->license() ); - - if ( !m_doc->documentComment().isEmpty() ) - domElementKvtml.setAttribute( KV_DOC_REM, m_doc->documentComment() ); - - if ( !writeLesson( domElementKvtml ) ) - return false; - - if ( !writeArticle( domElementKvtml ) ) - return false; - - QList pronouns; - for ( int i = 0; i < m_doc->identifierCount(); i++ ) - pronouns.append( m_doc->identifier(i).personalPronouns() ); - if ( pronouns.count() > 0 ) { - if ( !writePersonalPronouns(domElementKvtml, pronouns ) ) - return false; - } - - if ( !writeType( domElementKvtml ) ) - return false; - - if ( !writeTense( domElementKvtml ) ) - return false; - - if ( !writeUsage( domElementKvtml ) ) - return false; - - QString q_org, q_trans; - m_doc->queryIdentifier( q_org, q_trans ); - - int entryCount = m_doc->entryCount(); - - for ( int i = 0; i < entryCount; i++ ) { - KEduVocExpression *entry = m_doc->entry( i ); - QDomElement domElementExpression = m_domDoc.createElement( KV_EXPR ); - - if ( entry->lesson() != 0 ) { - int lm = entry->lesson(); - if ( lm > m_doc->lessonCount() ) { - // should not be - kError() << "index of lesson member too high: " << lm << endl; - lm = 0; - } - domElementExpression.setAttribute( KV_LESS_MEMBER, lm ); - } - -// Sorry, but we don't support this any more. -// if ( entry->isInQuery() ) -// domElementExpression.setAttribute( KV_SELECTED, 1 ); - - if ( !entry->isActive() ) - domElementExpression.setAttribute( KV_INACTIVE, 1 ); - - QDomElement domElementOriginal = m_domDoc.createElement( KV_ORG ); - if ( first_expr ) { - // save space, only tell language in first entry - QString s; - domElementOriginal.setAttribute( KV_SIZEHINT, m_doc->sizeHint( 0 ) ); - - s = m_doc->identifier( 0 ).name().simplified(); - if ( s.isEmpty() ) - s = "original"; - domElementOriginal.setAttribute( KV_LANG, s ); - if ( s == q_org ) - domElementOriginal.setAttribute( KV_QUERY, ( QString ) KV_O ); - else if ( s == q_trans ) - domElementOriginal.setAttribute( KV_QUERY, ( QString ) KV_T ); - } - - if ( !entry->translation( 0 ).comment().isEmpty() ) - domElementOriginal.setAttribute( KV_REMARK, entry->translation( 0 ).comment() ); - - if ( !entry->translation( 0 ).synonym().isEmpty() ) - domElementOriginal.setAttribute( KV_SYNONYM, entry->translation( 0 ).synonym() ); - - if ( !entry->translation( 0 ).example().isEmpty() ) - domElementOriginal.setAttribute( KV_EXAMPLE, entry->translation( 0 ).example() ); -///@todo enable writing of usages in old format - /* - if (!entry->translation(0).usageLabel().isEmpty() ) - domElementOriginal.setAttribute(KV_USAGE, entry->translation(0).usageLabel()); - */ - if ( !entry->translation( 0 ).paraphrase().isEmpty() ) - domElementOriginal.setAttribute( KV_PARAPHRASE, entry->translation( 0 ).paraphrase() ); - - if ( !entry->translation( 0 ).antonym().isEmpty() ) - domElementOriginal.setAttribute( KV_ANTONYM, entry->translation( 0 ).antonym() ); - - if ( !entry->translation( 0 ).pronunciation().isEmpty() ) - domElementOriginal.setAttribute( KV_PRONUNCE, entry->translation( 0 ).pronunciation() ); - - if ( !entry->translation( 0 ).type().isEmpty() ) - domElementOriginal.setAttribute( KV_EXPRTYPE, m_compability.oldType( entry->translation( 0 ).type(), entry->translation( 0 ).subType() ) ); - - if ( !writeMultipleChoice(domElementOriginal, entry->translation( 0 ).multipleChoice() ) ) - return false; - - QString s; - QString entype = s = entry->translation( 0 ).type(); - int pos = s.indexOf( QM_TYPE_DIV ); - if ( pos >= 0 ) - entype = s.left( pos ); - else - entype = s; - - if ( entype == QM_VERB ) { - // conjugation - if ( !writeConjugEntry(domElementOriginal, entry->translation( 0 )) ) { - return false; - } - - - } else if ( entype == QM_ADJ && !entry->translation( 0 ).comparison().isEmpty() ) { - KEduVocComparison comp = entry->translation( 0 ).comparison(); - if ( !writeComparison(domElementOriginal, comp ) ) - return false; - } - - QDomText domTextOriginal = m_domDoc.createTextNode( entry->translation( 0 ).text() ); - domElementOriginal.appendChild( domTextOriginal ); - domElementExpression.appendChild( domElementOriginal ); - - int trans = 1; - while ( trans < m_doc->identifierCount() ) { - QDomElement domElementTranslation = m_domDoc.createElement( KV_TRANS ); - if ( first_expr ) { - // save space, only tell language in first entry - QString s; - domElementTranslation.setAttribute( KV_SIZEHINT, m_doc->sizeHint( trans ) ); - - s = m_doc->identifier( trans ).name().simplified(); - if ( s.isEmpty() ) { - s.setNum( trans ); - s.prepend( QLatin1String("translation ") ); - } - domElementTranslation.setAttribute( KV_LANG, s ); - if ( s == q_org ) - domElementTranslation.setAttribute( KV_QUERY, ( QString ) KV_O ); - else if ( s == q_trans ) - domElementTranslation.setAttribute( KV_QUERY, ( QString ) KV_T ); - } - - if ( entry->translation( trans ).gradeFrom( 0 ).grade() != 0 || entry->translation( 0 ).gradeFrom( trans ).grade() != 0 ) - domElementTranslation.setAttribute( KV_GRADE, QString::number( entry->translation( trans ).gradeFrom( 0 ).grade() ) + ';' + QString::number( entry->translation( 0 ).gradeFrom( trans ).grade() ) ); - - if ( entry->translation( trans ).gradeFrom( 0 ).practiceCount() != 0 || entry->translation( 0 ).gradeFrom( trans ).practiceCount() != 0 ) - domElementTranslation.setAttribute( KV_COUNT, QString::number( entry->translation( trans ).gradeFrom( 0 ).practiceCount() ) + ';' + QString::number( entry->translation( 0 ).gradeFrom( trans ).practiceCount() ) ); - - if ( entry->translation( trans ).gradeFrom( 0 ).badCount() != 0 || entry->translation( 0 ).gradeFrom( trans ).badCount() != 0 ) - domElementTranslation.setAttribute( KV_BAD, QString::number( entry->translation( trans ).gradeFrom( 0 ).badCount() ) + ';' + QString::number( entry->translation( 0 ).gradeFrom( trans ).badCount() ) ); - - if ( entry->translation( trans ).gradeFrom( 0 ).practiceDate().toTime_t() != 0 || entry->translation( 0 ).gradeFrom( trans ).practiceDate().toTime_t() != 0 ) - domElementTranslation.setAttribute( KV_DATE, QString::number( entry->translation( trans ).gradeFrom( 0 ).practiceDate().toTime_t() ) + ';' + QString::number( entry->translation( 0 ).gradeFrom( trans ).practiceDate().toTime_t() ) ); - - if ( !entry->translation( trans ).comment().isEmpty() ) - domElementTranslation.setAttribute( KV_REMARK, entry->translation( trans ).comment() ); - - if ( !entry->translation( trans ).falseFriend( 0 ).isEmpty() ) - domElementTranslation.setAttribute( KV_FAUX_AMI_F, entry->translation( trans ).falseFriend( 0 ) ); - - if ( !entry->translation( 0 ).falseFriend( trans ).isEmpty() ) - domElementTranslation.setAttribute( KV_FAUX_AMI_T, entry->translation( 0 ).falseFriend( trans ) ); - - if ( !entry->translation( trans ).synonym().isEmpty() ) - domElementTranslation.setAttribute( KV_SYNONYM, entry->translation( trans ).synonym() ); - - if ( !entry->translation( trans ).example().isEmpty() ) - domElementTranslation.setAttribute( KV_EXAMPLE, entry->translation( trans ).example() ); - -///@todo enable writing of usages in old format - /* - if (!entry->translation(trans).usageLabel().isEmpty() ) - domElementTranslation.setAttribute(KV_USAGE, entry->translation(trans).usageLabel()); - */ - if ( !entry->translation( trans ).paraphrase().isEmpty() ) - domElementTranslation.setAttribute( KV_PARAPHRASE, entry->translation( trans ).paraphrase() ); - - if ( !entry->translation( trans ).antonym().isEmpty() ) - domElementTranslation.setAttribute( KV_ANTONYM, entry->translation( trans ).antonym() ); - - if ( !entry->translation( trans ).pronunciation().isEmpty() ) - domElementTranslation.setAttribute( KV_PRONUNCE, entry->translation( trans ).pronunciation() ); - - if ( !entry->translation( trans ).type().isEmpty() ) - domElementTranslation.setAttribute( KV_EXPRTYPE, m_compability.oldType( entry->translation( trans ).type(), entry->translation( trans ).subType() ) ); - - if ( !writeMultipleChoice(domElementTranslation, entry->translation( trans ).multipleChoice() ) ) - return false; - - QString s; - QString entype = s = entry->translation( 0 ).type(); - int pos = s.indexOf( QM_TYPE_DIV ); - if ( pos >= 0 ) - entype = s.left( pos ); - else - entype = s; - - if ( entype == QM_VERB ) { - if ( !writeConjugEntry(domElementTranslation, entry->translation( trans ) ) ) { - return false; - } - } - - if ( entype == QM_ADJ && !entry->translation( trans ).comparison().isEmpty() ) { - KEduVocComparison comp = entry->translation( trans ).comparison(); - if ( !writeComparison(domElementTranslation, comp ) ) - return false; - } - - QDomText domTextTranslation = m_domDoc.createTextNode( entry->translation( trans ).text() ); - domElementTranslation.appendChild( domTextTranslation ); - domElementExpression.appendChild( domElementTranslation ); - - trans++; - } - - domElementKvtml.appendChild( domElementExpression ); - - first_expr = false; - } - - m_domDoc.appendChild( domElementKvtml ); - - QTextStream ts( m_outputFile ); - m_domDoc.save( ts, 2 ); - - return true; -} - - -bool KEduVocKvtmlWriter::writeLesson( QDomElement &domElementParent ) -{ - if ( m_doc->lessonCount() == 0 ) - return true; - - QDomElement domElementLesson = m_domDoc.createElement( KV_LESS_GRP ); - domElementLesson.setAttribute( KV_SIZEHINT, m_doc->sizeHint( -1 ) ); - - for ( int i = 0; i < m_doc->lessonCount(); ++i ) { - QDomElement domElementDesc = m_domDoc.createElement( KV_LESS_DESC ); - QDomText domTextDesc = m_domDoc.createTextNode( m_doc->lesson(i).name() ); - - domElementDesc.setAttribute( KV_LESS_NO, i ); - if ( m_doc->currentLesson() == i ) { - domElementDesc.setAttribute( KV_LESS_CURR, 1 ); - } - if ( m_doc->lesson(i).inPractice() ) { - domElementDesc.setAttribute( KV_LESS_QUERY, 1 ); - } - domElementDesc.appendChild( domTextDesc ); - domElementLesson.appendChild( domElementDesc ); - } - - domElementParent.appendChild( domElementLesson ); - return true; -} - - -bool KEduVocKvtmlWriter::writeArticle( QDomElement &domElementParent ) -/* -
- lang determines also lang order in entries !! - eine which must NOT differ - die - ein - der - ein - das - -
-*/ -{ - QDomElement domElementArticle = m_domDoc.createElement( KV_ARTICLE_GRP ); - QString def; - QString indef; - QString s; - - for ( int i = 0; i < m_doc->identifierCount(); i++ ) - { - QDomElement domElementEntry = m_domDoc.createElement( KV_ART_ENTRY ); - s = m_doc->identifier(i).name().simplified(); - domElementEntry.setAttribute( KV_LANG, s ); - - QString articleString; - // female - articleString = m_doc->identifier(i).article().article( KEduVocWordFlag::Singular | KEduVocWordFlag::Definite | KEduVocWordFlag::Feminine ); - if ( !articleString.isEmpty() ) { - QDomElement domElementFD = m_domDoc.createElement( KV_ART_FD ); - QDomText domTextFD = m_domDoc.createTextNode( articleString ); - - domElementFD.appendChild( domTextFD ); - domElementEntry.appendChild( domElementFD ); - } - articleString = m_doc->identifier(i).article().article( KEduVocWordFlag::Singular | KEduVocWordFlag::Indefinite | KEduVocWordFlag::Feminine ); - if ( !articleString.isEmpty() ) { - QDomElement domElementFI = m_domDoc.createElement( KV_ART_FI ); - QDomText domTextFI = m_domDoc.createTextNode( articleString ); - - domElementFI.appendChild( domTextFI ); - domElementEntry.appendChild( domElementFI ); - } - - - // male - articleString = m_doc->identifier(i).article().article( KEduVocWordFlag::Singular | KEduVocWordFlag::Definite | KEduVocWordFlag::Masculine ); - if ( !articleString.isEmpty() ) { - QDomElement domElementMD = m_domDoc.createElement( KV_ART_MD ); - QDomText domTextMD = m_domDoc.createTextNode( articleString ); - - domElementMD.appendChild( domTextMD ); - domElementEntry.appendChild( domElementMD ); - } - articleString = m_doc->identifier(i).article().article( KEduVocWordFlag::Singular | KEduVocWordFlag::Indefinite | KEduVocWordFlag::Masculine ); - if ( !articleString.isEmpty() ) { - QDomElement domElementMI = m_domDoc.createElement( KV_ART_MI ); - QDomText domTextMI = m_domDoc.createTextNode( articleString ); - - domElementMI.appendChild( domTextMI ); - domElementEntry.appendChild( domElementMI ); - } - - // neutral - articleString = m_doc->identifier(i).article().article( KEduVocWordFlag::Singular | KEduVocWordFlag::Definite | KEduVocWordFlag::Neutral ); - if ( !articleString.isEmpty() ) { - QDomElement domElementND = m_domDoc.createElement( KV_ART_ND ); - QDomText domTextND = m_domDoc.createTextNode( articleString ); - - domElementND.appendChild( domTextND ); - domElementEntry.appendChild( domElementND ); - } - articleString = m_doc->identifier(i).article().article( KEduVocWordFlag::Singular | KEduVocWordFlag::Indefinite | KEduVocWordFlag::Neutral ); - if ( !articleString.isEmpty() ) { - QDomElement domElementNI = m_domDoc.createElement( KV_ART_NI ); - QDomText domTextNI = m_domDoc.createTextNode( articleString ); - - domElementNI.appendChild( domTextNI ); - domElementEntry.appendChild( domElementNI ); - } - - domElementArticle.appendChild( domElementEntry ); - } - - domElementParent.appendChild( domElementArticle ); - return true; -} - - -bool KEduVocKvtmlWriter::writeType( QDomElement &domElementParent ) -{ - /** @todo port to new type handling */ - /* - if (m_doc->typeDescriptions().count() == 0) - return true; - - QDomElement domElementType = m_domDoc.createElement(KV_TYPE_GRP); - int count = 1; - - foreach(const QString &type, m_doc->typeDescriptions()) - { - if (!(type.isNull()) ) - { - QDomElement domElementDesc = m_domDoc.createElement(KV_TYPE_DESC); - QDomText domTextDesc = m_domDoc.createTextNode(type); - - domElementDesc.setAttribute(KV_TYPE_NO, count); - domElementDesc.appendChild(domTextDesc); - domElementType.appendChild(domElementDesc); - count++; - } - } - - domElementParent.appendChild(domElementType); - */ - return true; -} - -/* -bool KEduVocKvtmlWriter::writeTense( QDomElement &domElementParent ) -{ - if ( m_doc->tenseDescriptions().count() == 0 ) - return true; - - QDomElement domElementTense = m_domDoc.createElement( KV_TENSE_GRP ); - int count = 1; - - foreach( const QString &tense, m_doc->tenseDescriptions() ) { - if ( !( tense.isNull() ) ) { - QDomElement domElementDesc = m_domDoc.createElement( KV_TENSE_DESC ); - QDomText domTextDesc = m_domDoc.createTextNode( tense ); - - domElementDesc.setAttribute( KV_TENSE_NO, count ); - domElementDesc.appendChild( domTextDesc ); - domElementTense.appendChild( domElementDesc ); - count++; - } - } - - domElementParent.appendChild( domElementTense ); - return true; -} -*/ - -bool KEduVocKvtmlWriter::writeUsage( QDomElement &domElementParent ) -{ - -///@todo usages - /* - if (m_doc->usageDescriptions().count() == 0) - return true; - - QDomElement domElementUsage = m_domDoc.createElement(KV_USAGE_GRP); - int count = 1; - - foreach(const QString &usage, m_doc->usageDescriptions()) - { - if (!(usage.isNull())) - { - QDomElement domElementDesc = m_domDoc.createElement(KV_USAGE_DESC); - QDomText domTextDesc = m_domDoc.createTextNode(usage); - - domElementDesc.setAttribute(KV_USAGE_NO, count); - domElementDesc.appendChild(domTextDesc); - domElementUsage.appendChild(domElementDesc); - count++; - } - } - - domElementParent.appendChild(domElementUsage); - */ - return true; -} - - -bool KEduVocKvtmlWriter::writeComparison( QDomElement &domElementParent, const KEduVocTranslation* translation ) -/* - - good - better - best - -*/ -{ - if ( translation.comparison().isEmpty() && translation.superlative().isEmpty() ) { - return true; - } - - QDomElement domElementComparison = m_domDoc.createElement( KV_COMPARISON_GRP ); - - if ( !comp.l1().isEmpty() ) { - QDomElement domElementL1 = m_domDoc.createElement( KV_COMP_L1 ); - QDomText domTextL1 = m_domDoc.createTextNode( comp.l1() ); - - domElementL1.appendChild( domTextL1 ); - domElementComparison.appendChild( domElementL1 ); - } - - if ( !comp.l2().isEmpty() ) { - QDomElement domElementL2 = m_domDoc.createElement( KV_COMP_L2 ); - QDomText domTextL2 = m_domDoc.createTextNode( comp.l2() ); - - domElementL2.appendChild( domTextL2 ); - domElementComparison.appendChild( domElementL2 ); - } - - if ( !comp.l3().isEmpty() ) { - QDomElement domElementL3 = m_domDoc.createElement( KV_COMP_L3 ); - QDomText domTextL3 = m_domDoc.createTextNode( comp.l3() ); - - domElementL3.appendChild( domTextL3 ); - domElementComparison.appendChild( domElementL3 ); - } - - domElementParent.appendChild( domElementComparison ); - return true; -} - - -bool KEduVocKvtmlWriter::writeMultipleChoice( QDomElement &domElementParent, const KEduVocMultipleChoice &mc ) -/* - - good - better - best - best 2 - best 3 - -*/ -{ - if ( mc.isEmpty() ) - return true; - - QDomElement domElementMC = m_domDoc.createElement( KV_MULTIPLECHOICE_GRP ); - - if ( !mc.choice( 1 ).isEmpty() ) { - QDomElement domElementMC1 = m_domDoc.createElement( KV_MC_1 ); - QDomText domTextMC1 = m_domDoc.createTextNode( mc.choice( 1 ) ); - - domElementMC1.appendChild( domTextMC1 ); - domElementMC.appendChild( domElementMC1 ); - } - - if ( !mc.choice( 2 ).isEmpty() ) { - QDomElement domElementMC2 = m_domDoc.createElement( KV_MC_2 ); - QDomText domTextMC2 = m_domDoc.createTextNode( mc.choice( 2 ) ); - - domElementMC2.appendChild( domTextMC2 ); - domElementMC.appendChild( domElementMC2 ); - } - - if ( !mc.choice( 3 ).isEmpty() ) { - QDomElement domElementMC3 = m_domDoc.createElement( KV_MC_3 ); - QDomText domTextMC3 = m_domDoc.createTextNode( mc.choice( 3 ) ); - - domElementMC3.appendChild( domTextMC3 ); - domElementMC.appendChild( domElementMC3 ); - } - - if ( !mc.choice( 4 ).isEmpty() ) { - QDomElement domElementMC4 = m_domDoc.createElement( KV_MC_4 ); - QDomText domTextMC4 = m_domDoc.createTextNode( mc.choice( 4 ) ); - - domElementMC4.appendChild( domTextMC4 ); - domElementMC.appendChild( domElementMC4 ); - } - - if ( !mc.choice( 5 ).isEmpty() ) { - QDomElement domElementMC5 = m_domDoc.createElement( KV_MC_5 ); - QDomText domTextMC5 = m_domDoc.createTextNode( mc.choice( 5 ) ); - - domElementMC5.appendChild( domTextMC5 ); - domElementMC.appendChild( domElementMC5 ); - } - - domElementParent.appendChild( domElementMC ); - return true; -} - - -bool KEduVocKvtmlWriter::writeConjugHeader( QDomElement &domElementParent, QList &curr_conjug ) -{ - /* - used in header for definiton of "prefix" - lang determines also lang order in entries !! - I which must NOT differ - you<2> - he - she - it - we - you - they - they - they - - - - */ - if ( curr_conjug.size() == 0 ) - return true; - - QDomElement domElementConjug = m_domDoc.createElement( KV_CONJUG_GRP ); - QString s; - - for ( int ent = 0; ent < qMin( curr_conjug.count(), m_doc->identifierCount() ); ent++ ) { - QDomElement domElementEntry = m_domDoc.createElement( KV_CON_ENTRY ); - - s = m_doc->identifier( ent ).name().simplified(); - if ( s.isEmpty() ) { - s.setNum( ent ); - s.prepend( QLatin1String("translation ") ); - } - - domElementEntry.setAttribute( KV_LANG, s ); - if ( !writeConjug(domElementEntry, curr_conjug[ent], "--" ) ) - return false; - - domElementConjug.appendChild( domElementEntry ); - } - - domElementParent.appendChild( domElementConjug ); - return true; -} - - -bool KEduVocKvtmlWriter::writeConjugEntry( QDomElement &domElementParent, KEduVocTranslation &translation ) -/* - in entry for definition of tenses of (irreg.) verbs - - go - go - goes - goes - goes - go - go - go - go - go - - -*/ -{ - -// curr_conjug.cleanUp(); - QDomElement domElementConjug = m_domDoc.createElement( KV_CONJUG_GRP ); - - foreach ( const QString &tense, translation.conjugationTenses() ) { - QDomElement domElementType = m_domDoc.createElement( KV_CON_TYPE ); - - domElementType.setAttribute( KV_CON_NAME, m_compability.oldTense(tense) ); - - if ( !writeConjug(domElementType, translation.conjugation(tense), m_compability.oldTense(tense) ) ) - return false; - - domElementConjug.appendChild( domElementType ); - } - - domElementParent.appendChild( domElementConjug ); - return true; -} - - -bool KEduVocKvtmlWriter::writeConjug( QDomElement &domElementParent, const KEduVocConjugation &curr_conjug, const QString &type ) -{ -///@todo if we are to enable the writer: port this! -/* - if ( !curr_conjug.pers1Singular().isEmpty() ) { - QDomElement domElementP1s = m_domDoc.createElement( KV_CON_P1S ); - QDomText domTextP1s = m_domDoc.createTextNode( curr_conjug.pers1Singular() ); - - domElementP1s.appendChild( domTextP1s ); - domElementParent.appendChild( domElementP1s ); - } - - if ( !curr_conjug.pers2Singular().isEmpty() ) { - QDomElement domElementP2s = m_domDoc.createElement( KV_CON_P2S ); - QDomText domTextP2s = m_domDoc.createTextNode( curr_conjug.pers2Singular() ); - - domElementP2s.appendChild( domTextP2s ); - domElementParent.appendChild( domElementP2s ); - } - - if ( !curr_conjug.pers3FemaleSingular().isEmpty() || curr_conjug.pers3SingularCommon() ) { - QDomElement domElementP3sf = m_domDoc.createElement( KV_CON_P3SF ); - QDomText domTextP3sf = m_domDoc.createTextNode( curr_conjug.pers3FemaleSingular() ); - - if ( curr_conjug.pers3SingularCommon() ) - domElementP3sf.setAttribute( KV_CONJ_COMMON, 1 ); - - domElementP3sf.appendChild( domTextP3sf ); - domElementParent.appendChild( domElementP3sf ); - } - - if ( !curr_conjug.pers3MaleSingular().isEmpty() ) { - QDomElement domElementP3sm = m_domDoc.createElement( KV_CON_P3SM ); - QDomText domTextP3sm = m_domDoc.createTextNode( curr_conjug.pers3MaleSingular() ); - - domElementP3sm.appendChild( domTextP3sm ); - domElementParent.appendChild( domElementP3sm ); - } - - if ( !curr_conjug.pers3NaturalSingular().isEmpty() ) { - QDomElement domElementP3sn = m_domDoc.createElement( KV_CON_P3SN ); - QDomText domTextP3sn = m_domDoc.createTextNode( curr_conjug.pers3NaturalSingular() ); - - domElementP3sn.appendChild( domTextP3sn ); - domElementParent.appendChild( domElementP3sn ); - } - - if ( !curr_conjug.pers1Plural().isEmpty() ) { - QDomElement domElementP1p = m_domDoc.createElement( KV_CON_P1P ); - QDomText domTextP1p = m_domDoc.createTextNode( curr_conjug.pers1Plural() ); - - domElementP1p.appendChild( domTextP1p ); - domElementParent.appendChild( domElementP1p ); - } - - if ( !curr_conjug.pers2Plural().isEmpty() ) { - QDomElement domElementP2p = m_domDoc.createElement( KV_CON_P2P ); - QDomText domTextP2p = m_domDoc.createTextNode( curr_conjug.pers2Plural() ); - - domElementP2p.appendChild( domTextP2p ); - domElementParent.appendChild( domElementP2p ); - } - - if ( !curr_conjug.pers3FemalePlural().isEmpty() || curr_conjug.pers3PluralCommon() ) { - QDomElement domElementP3pf = m_domDoc.createElement( KV_CON_P3PF ); - QDomText domTextP3pf = m_domDoc.createTextNode( curr_conjug.pers3FemalePlural() ); - - if ( curr_conjug.pers3PluralCommon() ) - domElementP3pf.setAttribute( KV_CONJ_COMMON, 1 ); - - domElementP3pf.appendChild( domTextP3pf ); - domElementParent.appendChild( domElementP3pf ); - } - - if ( !curr_conjug.pers3MalePlural().isEmpty() ) { - QDomElement domElementP3pm = m_domDoc.createElement( KV_CON_P3PM ); - QDomText domTextP3pm = m_domDoc.createTextNode( curr_conjug.pers3MalePlural() ); - - domElementP3pm.appendChild( domTextP3pm ); - domElementParent.appendChild( domElementP3pm ); - } - - if ( !curr_conjug.pers3NaturalPlural().isEmpty() ) { - QDomElement domElementP3pn = m_domDoc.createElement( KV_CON_P3PN ); - QDomText domTextP3pn = m_domDoc.createTextNode( curr_conjug.pers3NaturalPlural() ); - - domElementP3pn.appendChild( domTextP3pn ); - domElementParent.appendChild( domElementP3pn ); - } - - return true; */ - kDebug() << "Implement me!"; - return false; -} - -bool KEduVocKvtmlWriter::writePersonalPronouns( QDomElement &domElementParent, QList &curr_conjug ) -{ - /* - used in header for definiton of "prefix" - lang determines also lang order in entries !! - I which must NOT differ - you<2> - he - she - it - we - you - they - they - they - - - */ - const QString type = QString::fromLatin1("--"); - - if ( curr_conjug.size() == 0 ) - return true; - - QDomElement domElementConjug = m_domDoc.createElement( KV_CONJUG_GRP ); - QString s; - - for ( int ent = 0; ent < qMin( curr_conjug.count(), m_doc->identifierCount() ); ent++ ) { - QDomElement domElementEntry = m_domDoc.createElement( KV_CON_ENTRY ); - - s = m_doc->identifier( ent ).name().simplified(); - if ( s.isEmpty() ) { - s.setNum( ent ); - s.prepend( QLatin1String("translation ") ); - } - - domElementEntry.setAttribute( KV_LANG, s ); - if ( !writePersonalPronounChild(domElementEntry, curr_conjug[ent] ) ) - return false; - - domElementConjug.appendChild( domElementEntry ); - } - - domElementParent.appendChild( domElementConjug ); - return true; -} - - -bool KEduVocKvtmlWriter::writePersonalPronounChild( QDomElement &domElementParent, const KEduVocPersonalPronoun &curr_conjug ) -{ - // the old stuff only has singular - const KEduVocWordFlag::ConjugationNumber num = KEduVocWordFlag::Singular; - - if ( !curr_conjug.personalPronoun( KEduVocWordFlag::First, num ).isEmpty() ) { - domElementParent.appendChild( newTextElement( KV_CON_P1S, curr_conjug.personalPronoun( KEduVocWordFlag::First, num ) ) ); - } - - if ( !curr_conjug.personalPronoun( KEduVocWordFlag::Second, num ).isEmpty() ) { - domElementParent.appendChild( newTextElement( KV_CON_P2S, curr_conjug.personalPronoun( KEduVocWordFlag::Second, num ) ) ); - } - - ///@todo if the writer ever becomes enabled, write the other pronouns -/* - if ( !curr_conjug.pers2Singular().isEmpty() ) { - QDomElement domElementP2s = m_domDoc.createElement( KV_CON_P2S ); - QDomText domTextP2s = m_domDoc.createTextNode( curr_conjug.pers2Singular() ); - - domElementP2s.appendChild( domTextP2s ); - domElementParent.appendChild( domElementP2s ); - } - - if ( !curr_conjug.pers3FemaleSingular().isEmpty() || curr_conjug.pers3SingularCommon() ) { - QDomElement domElementP3sf = m_domDoc.createElement( KV_CON_P3SF ); - QDomText domTextP3sf = m_domDoc.createTextNode( curr_conjug.pers3FemaleSingular() ); - - if ( curr_conjug.pers3SingularCommon() ) - domElementP3sf.setAttribute( KV_CONJ_COMMON, 1 ); - - domElementP3sf.appendChild( domTextP3sf ); - domElementParent.appendChild( domElementP3sf ); - } - - if ( !curr_conjug.pers3MaleSingular().isEmpty() ) { - QDomElement domElementP3sm = m_domDoc.createElement( KV_CON_P3SM ); - QDomText domTextP3sm = m_domDoc.createTextNode( curr_conjug.pers3MaleSingular() ); - - domElementP3sm.appendChild( domTextP3sm ); - domElementParent.appendChild( domElementP3sm ); - } - - if ( !curr_conjug.pers3NaturalSingular().isEmpty() ) { - QDomElement domElementP3sn = m_domDoc.createElement( KV_CON_P3SN ); - QDomText domTextP3sn = m_domDoc.createTextNode( curr_conjug.pers3NaturalSingular() ); - - domElementP3sn.appendChild( domTextP3sn ); - domElementParent.appendChild( domElementP3sn ); - } - - if ( !curr_conjug.pers1Plural().isEmpty() ) { - QDomElement domElementP1p = m_domDoc.createElement( KV_CON_P1P ); - QDomText domTextP1p = m_domDoc.createTextNode( curr_conjug.pers1Plural() ); - - domElementP1p.appendChild( domTextP1p ); - domElementParent.appendChild( domElementP1p ); - } - - if ( !curr_conjug.pers2Plural().isEmpty() ) { - QDomElement domElementP2p = m_domDoc.createElement( KV_CON_P2P ); - QDomText domTextP2p = m_domDoc.createTextNode( curr_conjug.pers2Plural() ); - - domElementP2p.appendChild( domTextP2p ); - domElementParent.appendChild( domElementP2p ); - } - - if ( !curr_conjug.pers3FemalePlural().isEmpty() || curr_conjug.pers3PluralCommon() ) { - QDomElement domElementP3pf = m_domDoc.createElement( KV_CON_P3PF ); - QDomText domTextP3pf = m_domDoc.createTextNode( curr_conjug.pers3FemalePlural() ); - - if ( curr_conjug.pers3PluralCommon() ) - domElementP3pf.setAttribute( KV_CONJ_COMMON, 1 ); - - domElementP3pf.appendChild( domTextP3pf ); - domElementParent.appendChild( domElementP3pf ); - } - - if ( !curr_conjug.pers3MalePlural().isEmpty() ) { - QDomElement domElementP3pm = m_domDoc.createElement( KV_CON_P3PM ); - QDomText domTextP3pm = m_domDoc.createTextNode( curr_conjug.pers3MalePlural() ); - - domElementP3pm.appendChild( domTextP3pm ); - domElementParent.appendChild( domElementP3pm ); - } - - if ( !curr_conjug.pers3NaturalPlural().isEmpty() ) { - QDomElement domElementP3pn = m_domDoc.createElement( KV_CON_P3PN ); - QDomText domTextP3pn = m_domDoc.createTextNode( curr_conjug.pers3NaturalPlural() ); - - domElementP3pn.appendChild( domTextP3pn ); - domElementParent.appendChild( domElementP3pn ); - }*/ - - return true; -} - -QDomElement KEduVocKvtmlWriter::newTextElement( const QString &elementName, const QString &text ) -{ - QDomElement retval = m_domDoc.createElement( elementName ); - QDomText textNode = m_domDoc.createTextNode( text ); - retval.appendChild( textNode ); - return retval; -} - - diff --git a/keduvocdocument/keduvockvtmlwriter.h b/keduvocdocument/keduvockvtmlwriter.h deleted file mode 100644 index dfe2789..0000000 --- a/keduvocdocument/keduvockvtmlwriter.h +++ /dev/null @@ -1,73 +0,0 @@ -/*************************************************************************** - export a KEduVocDocument to a KVTML file - ----------------------------------------------------------------------- - copyright : (C) 1999-2001 Ewald Arnold - - (C) 2005 Eric Pignet - (C) 2007 Peter Hedlund - (C) 2007 Frederik Gladhorn - ***************************************************************************/ - -/*************************************************************************** - * * - * 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. * - * * - ***************************************************************************/ - -#ifndef KEDUVOCKVTMLWRITER_H -#define KEDUVOCKVTMLWRITER_H - -#include -#include -#include - -#include "keduvocarticle.h" -#include "keduvocpersonalpronoun.h" -#include "keduvocconjugation.h" -#include "keduvocmultiplechoice.h" -#include "keduvockvtmlcompability.h" -#include "keduvoctranslation.h" - -class KEduVocDocument; - -/** -@author Eric Pignet -*/ -class KEduVocKvtmlWriter -{ -public: - KEduVocKvtmlWriter( QFile *file ); - - bool writeDoc( KEduVocDocument *doc, const QString &generator ); - -private: - bool writeLesson( QDomElement &domElementParent ); - bool writeType( QDomElement &domElementParent ); - bool writeTense( QDomElement &domElementParent ); - bool writeUsage( QDomElement &domElementParent ); - bool writeOption( QDomElement &domElementParent ); - bool writeArticle( QDomElement &domElementParent ); - - bool writePersonalPronouns( QDomElement &domElementParent, QList &curr_conjug ); - bool writePersonalPronounChild( QDomElement &domElementParent, const KEduVocPersonalPronoun &curr_conjug ); - - bool writeConjugHeader( QDomElement &domElementParent, QList &curr_conjug ); - bool writeConjug( QDomElement &domElementParent, const KEduVocConjugation &curr_conjug, const QString &type ); - bool writeConjugEntry( QDomElement &domElementParent, KEduVocTranslation &translation ); - bool writeComparison( QDomElement &domElementParent, KEduVocTranslation* translation ); - bool writeMultipleChoice( QDomElement &domElementParent, const KEduVocMultipleChoice &mc ); - - QDomElement newTextElement( const QString &elementName, const QString &text ); - - QFile *m_outputFile; - KEduVocDocument *m_doc; - - QDomDocument m_domDoc; - - KEduVocKvtmlCompability m_compability; -}; - -#endif diff --git a/keduvocdocument/keduvocleitnerbox.cpp b/keduvocdocument/keduvocleitnerbox.cpp deleted file mode 100644 index c9d81e1..0000000 --- a/keduvocdocument/keduvocleitnerbox.cpp +++ /dev/null @@ -1,113 +0,0 @@ -/*************************************************************************** - Copyright 2008 Frederik Gladhorn - ***************************************************************************/ - -/*************************************************************************** - * * - * 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. * - * * - ***************************************************************************/ - -#include "keduvocleitnerbox.h" - -#include "keduvocexpression.h" - -#include - -#include - -class KEduVocLeitnerBox::Private -{ -public: - // cache the entries - QList m_expressions; - // list of translations - QList m_translations; -}; - -KEduVocLeitnerBox::KEduVocLeitnerBox(const QString& name, KEduVocLeitnerBox *parent) - : KEduVocContainer(name, Leitner, parent), d( new Private ) -{ - // only one top level and children, this is only a list - Q_ASSERT(!parent || !parent->parent()); -} - -KEduVocLeitnerBox::~KEduVocLeitnerBox() -{ - foreach(KEduVocTranslation* translation, d->m_translations) { - translation->setLeitnerBox(0); - } - delete d; -} - -QList KEduVocLeitnerBox::entries(EnumEntriesRecursive recursive) -{ - Q_UNUSED(recursive) - return d->m_expressions; -} - -int KEduVocLeitnerBox::entryCount(EnumEntriesRecursive recursive) -{ - Q_UNUSED(recursive) - return d->m_expressions.count(); -} - -void KEduVocLeitnerBox::addTranslation(KEduVocTranslation* translation) -{ - // add to expression - if not already there because another translation of the same word is there. - bool found = false; - foreach(int i, translation->entry()->translationIndices()) { - if (translation->entry()->translation(i)->leitnerBox() == this) { - found = true; - break; - } - } - if (!found) { - d->m_expressions.append(translation->entry()); - } - d->m_translations.append( translation ); - invalidateChildLessonEntries(); -} - -void KEduVocLeitnerBox::removeTranslation(KEduVocTranslation* translation) -{ - int index = d->m_translations.indexOf(translation); - d->m_translations.removeAt(index); - - // no lesson found - this entry is being deleted. remove all its siblings. - if (!translation->entry()->lesson()) { - int index = d->m_expressions.indexOf(translation->entry()); - if (index != -1) { - d->m_expressions.removeAt(index); - } - } - - // remove from cache - bool found = false; - foreach(int i, translation->entry()->translationIndices()) { - if (translation->entry()->translation(i)->leitnerBox() == this) { - found = true; - break; - } - } - if (!found) { - d->m_expressions.removeAt(d->m_expressions.indexOf(translation->entry())); - } - - invalidateChildLessonEntries(); -} - -KEduVocTranslation * KEduVocLeitnerBox::translation(int row) -{ - return d->m_translations.value(row); -} - -KEduVocExpression * KEduVocLeitnerBox::entry(int row, EnumEntriesRecursive recursive) -{ - Q_UNUSED(recursive) - return entries().value(row); -} - diff --git a/keduvocdocument/keduvocleitnerbox.h b/keduvocdocument/keduvocleitnerbox.h deleted file mode 100644 index 37bd780..0000000 --- a/keduvocdocument/keduvocleitnerbox.h +++ /dev/null @@ -1,75 +0,0 @@ -/*************************************************************************** - Copyright 2008 Frederik Gladhorn - ***************************************************************************/ - -/*************************************************************************** - * * - * 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. * - * * - ***************************************************************************/ - -#ifndef KEDUVOCLEITNERBOX_H -#define KEDUVOCLEITNERBOX_H - -#include "libkeduvocdocument_export.h" - -#include "keduvoccontainer.h" - -#include -#include - -class KEduVocExpression; -class KEduVocTranslation; - -/** - * Leitner Boxes are an alternative grading system. - * Classically flash cards are kept in boxes and moved corresponding to the users knowledge level. - */ -class KEDUVOCDOCUMENT_EXPORT KEduVocLeitnerBox :public KEduVocContainer -{ -public: - /** default constructor */ - explicit KEduVocLeitnerBox(const QString& name, KEduVocLeitnerBox *parent = 0); - - /** destructor */ - ~KEduVocLeitnerBox(); - - /** - * The leitner box class keeps track of individual translations, because for one entry, the translations can have different grades. - * @param row - * @return - */ - KEduVocTranslation * translation(int row); - - /** - * get a list of all entries in the box - * @return - */ - QList < KEduVocExpression* > entries(EnumEntriesRecursive recursive = NotRecursive); - - KEduVocExpression* entry(int row, EnumEntriesRecursive recursive = NotRecursive); - - /** get the number of entries in the lesson */ - int entryCount(EnumEntriesRecursive recursive = NotRecursive); - -private: - class Private; - Private * const d; - - /** add an entry to the lesson - * @param entryid id of the entry to add - */ - void addTranslation(KEduVocTranslation* translation); - - /** remove an entry from the lesson - * @param entryid id of the entry to remove - */ - void removeTranslation(KEduVocTranslation* translation); - - friend class KEduVocTranslation; -}; - -#endif diff --git a/keduvocdocument/keduvoclesson.cpp b/keduvocdocument/keduvoclesson.cpp deleted file mode 100644 index 2e525c1..0000000 --- a/keduvocdocument/keduvoclesson.cpp +++ /dev/null @@ -1,101 +0,0 @@ -/*************************************************************************** - - Copyright 2007 Jeremy Whiting - Copyright 2007 Frederik Gladhorn - - ***************************************************************************/ - -/*************************************************************************** - * * - * 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. * - * * - ***************************************************************************/ - -#include "keduvoclesson.h" - -#include "keduvocexpression.h" - -#include -#include -#include - -/** private class to store information about a lesson */ -class KEduVocLesson::Private -{ -public: - // entries - QList m_entries; -}; - - -KEduVocLesson::KEduVocLesson(const QString& name, KEduVocContainer *parent) - : KEduVocContainer(name, Lesson, parent), d( new Private ) -{ -} - - -KEduVocLesson::KEduVocLesson( const KEduVocLesson &other ) - : KEduVocContainer(other), d( new Private ) -{ - d->m_entries = other.d->m_entries; -} - - -KEduVocLesson::~KEduVocLesson() -{ - qDeleteAll(d->m_entries); - delete d; -} - -QList KEduVocLesson::entries(EnumEntriesRecursive recursive) -{ - if (recursive == Recursive) { - return entriesRecursive(); - } - return d->m_entries; -} - -int KEduVocLesson::entryCount(EnumEntriesRecursive recursive) -{ - if (recursive == Recursive) { - return entriesRecursive().count(); - } - return d->m_entries.count(); -} - -void KEduVocLesson::appendEntry(KEduVocExpression* entry) -{ - insertEntry(d->m_entries.size(), entry); -} - -void KEduVocLesson::insertEntry(int index, KEduVocExpression * entry) -{ - Q_ASSERT(entry); - d->m_entries.insert( index, entry ); - entry->setLesson(this); - invalidateChildLessonEntries(); -} - -void KEduVocLesson::removeEntry(KEduVocExpression* entry) -{ - Q_ASSERT(entry); - if (d->m_entries.indexOf(entry) == -1) { - kDebug() << "attempting to remove entry from lesson that does not contain it!"; - return; - } - d->m_entries.removeAt( d->m_entries.indexOf(entry) ); - invalidateChildLessonEntries(); -} - -KEduVocExpression * KEduVocLesson::entry(int row, EnumEntriesRecursive recursive) -{ - if (recursive == Recursive) { - return entriesRecursive().value(row); - } - return d->m_entries.value(row); -} - - diff --git a/keduvocdocument/keduvoclesson.h b/keduvocdocument/keduvoclesson.h deleted file mode 100644 index 060c4aa..0000000 --- a/keduvocdocument/keduvoclesson.h +++ /dev/null @@ -1,82 +0,0 @@ -/*************************************************************************** - - Copyright 2007 Jeremy Whiting - Copyright 2007 Frederik Gladhorn - - ***************************************************************************/ - -/*************************************************************************** - * * - * 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. * - * * - ***************************************************************************/ - -#ifndef KEDUVOCLESSON_H -#define KEDUVOCLESSON_H - -#include "libkeduvocdocument_export.h" - -#include "keduvoccontainer.h" - -class KEduVocExpression; - -/** class to store information about a lesson */ -class KEDUVOCDOCUMENT_EXPORT KEduVocLesson :public KEduVocContainer -{ -public: - /** default constructor */ - explicit KEduVocLesson(const QString& name, KEduVocContainer *parent = 0); - -// void appendChildLesson(KEduVocLesson *child); - -// QList childLessons(); -// KEduVocLesson *childLesson(int row); - -// int childLessonCount() const; - -// int row() const; -// KEduVocLesson *parent(); - - /** copy constructor for d-pointer safe copying */ - KEduVocLesson( const KEduVocLesson &other ); - - /** destructor */ - ~KEduVocLesson(); - - /** assignment operator */ - KEduVocLesson& operator= ( const KEduVocLesson& ); - - KEduVocExpression* entry(int row, EnumEntriesRecursive recursive = NotRecursive); - - /** get a list of all entries in the lesson */ - QList < KEduVocExpression* > entries(EnumEntriesRecursive recursive = NotRecursive); - - /** get the number of entries in the lesson */ - int entryCount(EnumEntriesRecursive recursive = NotRecursive); - - /** append an entry to the lesson - * @param entryid id of the entry to add - */ - void appendEntry(KEduVocExpression* entry); - - /** - * insert an entry at a specific position - * @param index - * @param entry - */ - void insertEntry(int index, KEduVocExpression* entry); - - /** remove an entry from the lesson - * @param entryid id of the entry to remove - */ - void removeEntry(KEduVocExpression* entry); - -private: - class Private; - Private * const d; -}; - -#endif diff --git a/keduvocdocument/keduvocmultiplechoice.cpp b/keduvocdocument/keduvocmultiplechoice.cpp deleted file mode 100644 index 45d93d0..0000000 --- a/keduvocdocument/keduvocmultiplechoice.cpp +++ /dev/null @@ -1,107 +0,0 @@ -/*************************************************************************** - - manage multiple choice suggestions for queries - - ----------------------------------------------------------------------- - - begin : Mon Oct 29 18:09:29 1999 - - copyright : (C) 1999-2001 Ewald Arnold - - (C) 2005 Peter Hedlund - - ----------------------------------------------------------------------- - - ***************************************************************************/ - -/*************************************************************************** - * * - * 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. * - * * - ***************************************************************************/ - -#include "keduvocmultiplechoice.h" -#include "kdebug.h" - -class KEduVocMultipleChoice::KEduVocMultipleChoicePrivate -{ -public: - QStringList m_choices; -}; - -KEduVocMultipleChoice::KEduVocMultipleChoice() - : d( new KEduVocMultipleChoicePrivate ) -{} - -KEduVocMultipleChoice::KEduVocMultipleChoice( const KEduVocMultipleChoice &other ) - : d( new KEduVocMultipleChoicePrivate ) -{ - d->m_choices = other.choices(); -} - -KEduVocMultipleChoice::KEduVocMultipleChoice( const QStringList &choices ) - : d( new KEduVocMultipleChoicePrivate ) -{ - foreach ( const QString &choice, choices ) { - // use appendChoice to check for empty entries - appendChoice(choice); - } -} - -KEduVocMultipleChoice::~KEduVocMultipleChoice() -{ - delete d; -} - -KEduVocMultipleChoice &KEduVocMultipleChoice::operator= ( const KEduVocMultipleChoice &other ) -{ - d->m_choices = other.choices(); - return *this; -} - -QStringList KEduVocMultipleChoice::choices() const -{ - return d->m_choices; -} - -bool KEduVocMultipleChoice::isEmpty() const -{ - return d->m_choices.isEmpty(); -} - - -void KEduVocMultipleChoice::clear() -{ - d->m_choices.clear(); -} - - -QString KEduVocMultipleChoice::choice( int index ) const -{ - QString choice; - if ( d->m_choices.size() > index ) { - choice = d->m_choices[index]; - } - return choice; -} - -unsigned KEduVocMultipleChoice::size() const -{ - return d->m_choices.size(); -} - -bool KEduVocMultipleChoice::operator== ( const KEduVocMultipleChoice &choice ) const -{ - return d->m_choices == choice.choices(); -} - -void KEduVocMultipleChoice::appendChoice( const QString &s ) -{ - if ( !s.isEmpty() ) { - kDebug() << s; - d->m_choices.append( s ); - } -} diff --git a/keduvocdocument/keduvocmultiplechoice.h b/keduvocdocument/keduvocmultiplechoice.h deleted file mode 100644 index 6a9d8e6..0000000 --- a/keduvocdocument/keduvocmultiplechoice.h +++ /dev/null @@ -1,62 +0,0 @@ -/*************************************************************************** - - manage multiple choice suggestions for queries - - ----------------------------------------------------------------------- - - begin : Mon Oct 29 18:09:29 1999 - - copyright : (C) 1999-2001 Ewald Arnold - - (C) 2005 Peter Hedlund - - ----------------------------------------------------------------------- - - ***************************************************************************/ - -/*************************************************************************** - * * - * 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. * - * * - ***************************************************************************/ - - -#ifndef KEDUVOCMULTIPLECHOICE_H -#define KEDUVOCMULTIPLECHOICE_H - -#include "libkeduvocdocument_export.h" - -#include - -class KEDUVOCDOCUMENT_EXPORT KEduVocMultipleChoice -{ -public: - KEduVocMultipleChoice(); - KEduVocMultipleChoice( const KEduVocMultipleChoice &other ); - KEduVocMultipleChoice( const QStringList &choices ); - - ~KEduVocMultipleChoice(); - - QStringList choices() const; - void appendChoice( const QString &s ); - - QString choice( int index ) const; - - bool isEmpty() const; - void clear(); - unsigned size() const; - - bool operator== ( const KEduVocMultipleChoice &choice ) const; - - KEduVocMultipleChoice &operator= ( const KEduVocMultipleChoice &other ); - -private: - class KEduVocMultipleChoicePrivate; - KEduVocMultipleChoicePrivate * const d; -}; - - -#endif // MultipleChoice_included diff --git a/keduvocdocument/keduvocpaukerreader.cpp b/keduvocdocument/keduvocpaukerreader.cpp deleted file mode 100644 index 4ded3e4..0000000 --- a/keduvocdocument/keduvocpaukerreader.cpp +++ /dev/null @@ -1,156 +0,0 @@ -/*************************************************************************** - create a KEduVocDocument from a Pauker file - ----------------------------------------------------------------------- - copyright : (C) 2004, 2007 Peter Hedlund - - ***************************************************************************/ - -/*************************************************************************** - * * - * 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. * - * * - ***************************************************************************/ - -#include "keduvocpaukerreader.h" - -#include - -#include - -#include "keduvocexpression.h" -#include "keduvoclesson.h" -#include "keduvocdocument.h" - -KEduVocPaukerReader::KEduVocPaukerReader( KEduVocDocument * doc ) -{ - m_doc = doc; -} - - -bool KEduVocPaukerReader::read( QIODevice * device ) -{ - setDevice( device ); - - while ( !atEnd() ) { - readNext(); - - if ( isStartElement() ) { - if ( name() == "Lesson" ) - readPauker(); - else - raiseError( i18n( "This is not a Pauker document" ) ); - } - } - - return !error(); -} - - -void KEduVocPaukerReader::readUnknownElement() -{ - while ( !atEnd() ) { - readNext(); - - if ( isEndElement() ) - break; - - if ( isStartElement() ) - readUnknownElement(); - } -} - - -void KEduVocPaukerReader::readPauker() -{ - m_doc->setAuthor( "http://pauker.sf.net" ); - ///Pauker does not provide any column titles - m_doc->appendIdentifier(); - m_doc->appendIdentifier(); - - while ( !atEnd() ) { - readNext(); - - if ( isEndElement() ) - break; - - if ( isStartElement() ) { - if ( name() == "Description" ) - m_doc->setDocumentComment( readElementText() ); - else if ( name() == "Batch" ) - readBatch(); - else - readUnknownElement(); - } - } -} - - -void KEduVocPaukerReader::readBatch() -{ - while ( !atEnd() ) { - readNext(); - - if ( isEndElement() ) - break; - - if ( isStartElement() ) { - if ( name() == "Card" ) - readCard(); - else - readUnknownElement(); - } - } -} - - -void KEduVocPaukerReader::readCard() -{ - QString front; - QString back; - - while ( !atEnd() ) { - readNext(); - - if ( isEndElement() ) - break; - - if ( isStartElement() ) { - if ( name() == "FrontSide" ) - front = readText(); - else if ( name() == "ReverseSide" ) - back = readText(); - else - readUnknownElement(); - } - } - - KEduVocLesson* lesson = new KEduVocLesson(i18n("Vocabulary"), m_doc->lesson()); - m_doc->lesson()->appendChildContainer(lesson); - - KEduVocExpression* expr = new KEduVocExpression( QStringList() << front << back); - lesson->appendEntry( expr ); -} - - -QString KEduVocPaukerReader::readText() -{ - QString result; - - while ( !atEnd() ) { - readNext(); - - if ( isEndElement() ) - break; - - if ( isStartElement() ) { - if ( name() == "Text" ) - result = readElementText(); - else - readUnknownElement(); - } - } - return result; -} diff --git a/keduvocdocument/keduvocpaukerreader.h b/keduvocdocument/keduvocpaukerreader.h deleted file mode 100644 index c675859..0000000 --- a/keduvocdocument/keduvocpaukerreader.h +++ /dev/null @@ -1,42 +0,0 @@ -/*************************************************************************** - create a KEduVocDocument from a Pauker file - ----------------------------------------------------------------------- - copyright : (C) 2004, 2007 Peter Hedlund - - ***************************************************************************/ - -/*************************************************************************** - * * - * 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. * - * * - ***************************************************************************/ - -#ifndef KEDUVOCPAUKERREADER_H -#define KEDUVOCPAUKERREADER_H - -#include - -class QIODevice; -class KEduVocDocument; - -class KEduVocPaukerReader : public QXmlStreamReader -{ -public: - KEduVocPaukerReader( KEduVocDocument *doc ); - - bool read( QIODevice *device ); - -private: - void readUnknownElement(); - void readPauker(); - void readBatch(); - void readCard(); - QString readText(); - - KEduVocDocument *m_doc; -}; - -#endif diff --git a/keduvocdocument/keduvocpersonalpronoun.cpp b/keduvocdocument/keduvocpersonalpronoun.cpp deleted file mode 100644 index cc77d53..0000000 --- a/keduvocdocument/keduvocpersonalpronoun.cpp +++ /dev/null @@ -1,125 +0,0 @@ -/*************************************************************************** - Copyright 2007 Frederik Gladhorn - ***************************************************************************/ - -/*************************************************************************** - * * - * 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. * - * * - ***************************************************************************/ - -#include "keduvocpersonalpronoun.h" -#include "keduvoccommon_p.h" -#include -#include - -class KEduVocPersonalPronoun::Private -{ -public: - Private(); - - bool m_maleFemaleDifferent; - bool m_neutralExists; - bool m_dualExists; - QMap m_personalpronouns; -}; - - -KEduVocPersonalPronoun::Private::Private() -{ - m_maleFemaleDifferent = false; - m_neutralExists = false; - m_dualExists = false; -} - -KEduVocPersonalPronoun::KEduVocPersonalPronoun() - : d( new Private ) -{} - - -KEduVocPersonalPronoun::KEduVocPersonalPronoun( const KEduVocPersonalPronoun& other ) - : d( new Private ) -{ - d->m_maleFemaleDifferent = other.d->m_maleFemaleDifferent; - d->m_neutralExists = other.d->m_neutralExists; - d->m_personalpronouns = other.d->m_personalpronouns; - d->m_dualExists = other.d->m_dualExists; -} - - -KEduVocPersonalPronoun::~KEduVocPersonalPronoun() -{ - delete d; -} - - -KEduVocPersonalPronoun& KEduVocPersonalPronoun::operator = ( const KEduVocPersonalPronoun& other ) -{ - d->m_maleFemaleDifferent = other.d->m_maleFemaleDifferent; - d->m_neutralExists = other.d->m_neutralExists; - d->m_personalpronouns = other.d->m_personalpronouns; - d->m_dualExists = other.d->m_dualExists; - return *this; -} - - -bool KEduVocPersonalPronoun::operator ==(const KEduVocPersonalPronoun& other) const -{ - return d->m_personalpronouns == other.d->m_personalpronouns && - d->m_maleFemaleDifferent == other.d->m_maleFemaleDifferent && - d->m_neutralExists == other.d->m_neutralExists && - d->m_dualExists == other.d->m_dualExists; -} - - -QString KEduVocPersonalPronoun::personalPronoun(KEduVocWordFlags flags) const -{ - QString p = d->m_personalpronouns.value(flags & (KEduVocWordFlag::persons | KEduVocWordFlag::numbers| KEduVocWordFlag::genders)); - if (p.isEmpty() && !(flags & KEduVocWordFlag::genders) && d->m_maleFemaleDifferent && d->m_neutralExists) - { - kDebug() << "initial flag lookup failed, added neuter gender flag"; - flags |= KEduVocWordFlag::Neuter; - p = d->m_personalpronouns.value(flags & (KEduVocWordFlag::persons | KEduVocWordFlag::numbers| KEduVocWordFlag::genders)); - } - return p; -} - -void KEduVocPersonalPronoun::setPersonalPronoun(const QString & personalpronoun, KEduVocWordFlags flags) -{ - d->m_personalpronouns[flags & (KEduVocWordFlag::persons | KEduVocWordFlag::numbers| KEduVocWordFlag::genders)] = personalpronoun; -} - - -bool KEduVocPersonalPronoun::maleFemaleDifferent() const -{ - return d->m_maleFemaleDifferent; -} - -void KEduVocPersonalPronoun::setMaleFemaleDifferent(bool different) -{ - d->m_maleFemaleDifferent = different; -} - -bool KEduVocPersonalPronoun::neutralExists() const -{ - return d->m_neutralExists; -} - -void KEduVocPersonalPronoun::setNeutralExists(bool exists) -{ - d->m_neutralExists = exists; -} - -bool KEduVocPersonalPronoun::dualExists() const -{ - return d->m_dualExists; -} - -void KEduVocPersonalPronoun::setDualExists(bool exists) -{ - d->m_dualExists = exists; -} - diff --git a/keduvocdocument/keduvocpersonalpronoun.h b/keduvocdocument/keduvocpersonalpronoun.h deleted file mode 100644 index 94b50cd..0000000 --- a/keduvocdocument/keduvocpersonalpronoun.h +++ /dev/null @@ -1,61 +0,0 @@ -/*************************************************************************** - Copyright 2007 Frederik Gladhorn - ***************************************************************************/ - -/*************************************************************************** - * * - * 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. * - * * - ***************************************************************************/ - - -#ifndef KEDUVOCPERSONALPRONOUN_H -#define KEDUVOCPERSONALPRONOUN_H - -#include "libkeduvocdocument_export.h" -#include "keduvocconjugation.h" -#include - -/** - * The conjugation of a verb - */ -class KEDUVOCDOCUMENT_EXPORT KEduVocPersonalPronoun -{ -public: - - /** - * The constructor - */ - explicit KEduVocPersonalPronoun(); - - KEduVocPersonalPronoun( const KEduVocPersonalPronoun& rhs ); - - ~KEduVocPersonalPronoun(); - - KEduVocPersonalPronoun& operator = ( const KEduVocPersonalPronoun& a ); - bool operator == ( const KEduVocPersonalPronoun& a ) const; - - QString personalPronoun(KEduVocWordFlags flags) const; - void setPersonalPronoun(const QString& conjugation, KEduVocWordFlags flags); - - bool maleFemaleDifferent() const; - void setMaleFemaleDifferent(bool different); - - bool neutralExists() const; - void setNeutralExists(bool exists); - - bool dualExists() const; - void setDualExists(bool exists); -private: - class Private; - Private* const d; - -}; - - - -#endif // KEDUVOCCONJUGATION_H - diff --git a/keduvocdocument/keduvoctext.cpp b/keduvocdocument/keduvoctext.cpp deleted file mode 100644 index 02403c0..0000000 --- a/keduvocdocument/keduvoctext.cpp +++ /dev/null @@ -1,230 +0,0 @@ -/*************************************************************************** - Copyright 2007-2008 Frederik Gladhorn - ***************************************************************************/ - -/*************************************************************************** - * * - * 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. * - * * - ***************************************************************************/ - -#include "keduvoctext.h" -#include "kvtml2defs.h" -#include "keduvockvtml2writer.h" - -#include -#include - -class KEduVocText::KEduVocTextPrivate -{ -public: - /// This is the word itself. The vocabulary. This is what it is all about. - QString m_text; - - grade_t m_grade; - count_t m_totalPracticeCount; - count_t m_badCount; - QDateTime m_practiceDate; -}; - -KEduVocText::KEduVocText(const QString& text) - :d( new KEduVocTextPrivate ) -{ - d->m_text = text; - resetGrades(); -} - -KEduVocText::KEduVocText( const KEduVocText &other ) - :d( new KEduVocTextPrivate ) -{ - d->m_text = other.d->m_text; - setGrade( other.grade() ); - setPracticeCount( other.practiceCount() ); - setBadCount( other.badCount() ); - setPracticeDate( other.practiceDate() ); -} - -KEduVocText::~KEduVocText() -{ - delete d; -} - -QString KEduVocText::text() const -{ - return d->m_text; -} - -void KEduVocText::setText( const QString & expr ) -{ - d->m_text = expr.simplified(); -} - -void KEduVocText::resetGrades() -{ - d->m_grade = KV_NORM_GRADE; - d->m_totalPracticeCount = 0; - d->m_badCount = 0; - - QDateTime dt; - dt.setTime_t( 0 ); - d->m_practiceDate = dt; -} - - -grade_t KEduVocText::grade() const -{ - return d->m_grade; -} - - -void KEduVocText::setGrade( grade_t grade ) -{ - if ( grade > KV_MAX_GRADE ) { - grade = KV_MAX_GRADE; - } - d->m_grade = grade; -} - - -void KEduVocText::incGrade() -{ - setGrade( grade() + 1 ); -} - - -void KEduVocText::decGrade() -{ - if ( grade() == KV_MIN_GRADE ) { - return; - } - setGrade( grade() - 1 ); -} - - -count_t KEduVocText::practiceCount() const -{ - return d->m_totalPracticeCount; -} - - -void KEduVocText::incPracticeCount() -{ - setPracticeCount( practiceCount() + 1 ); -} - - -void KEduVocText::incBadCount() -{ - setBadCount( badCount() + 1 ); -} - - -void KEduVocText::setPracticeCount( count_t count ) -{ - d->m_totalPracticeCount = count; -} - - -count_t KEduVocText::badCount() const -{ - return d->m_badCount; -} - - -void KEduVocText::setBadCount( count_t count ) -{ - d->m_badCount = count; -} - - -QDateTime KEduVocText::practiceDate() const -{ - return d->m_practiceDate; -} - - -void KEduVocText::setPracticeDate( const QDateTime & date ) -{ - d->m_practiceDate = date; -} - -KEduVocText & KEduVocText::operator =(const KEduVocText & other) -{ - d->m_text = other.d->m_text; - d->m_grade = other.d->m_grade; - d->m_totalPracticeCount = other.d->m_totalPracticeCount; - d->m_badCount = other.d->m_badCount; - d->m_practiceDate = other.d->m_practiceDate; - - return *this; -} - -bool KEduVocText::operator ==(const KEduVocText & other) const -{ - return - d->m_text == other.d->m_text && - d->m_grade == other.d->m_grade && - d->m_totalPracticeCount == other.d->m_totalPracticeCount && - d->m_badCount == other.d->m_badCount && - d->m_practiceDate == other.d->m_practiceDate; -} - -void KEduVocText::toKVTML2(QDomElement& parent) -{ - QDomDocument domDoc = parent.ownerDocument(); - if (text().isEmpty()) { - return; - } - - // the text - KEduVocKvtml2Writer::appendTextElement( parent, KVTML_TEXT, text() ); - - // grades - if ( practiceCount() > 0 ) { - QDomElement gradeElement = domDoc.createElement( KVTML_GRADE ); - - //2 - KEduVocKvtml2Writer::appendTextElement( gradeElement, KVTML_CURRENTGRADE, QString::number( grade() ) ); - - //6 - KEduVocKvtml2Writer::appendTextElement( gradeElement, KVTML_COUNT, QString::number( practiceCount() ) ); - - //1 - KEduVocKvtml2Writer::appendTextElement( gradeElement, KVTML_ERRORCOUNT, QString::number( badCount() ) ); - - //949757271 - KEduVocKvtml2Writer::appendTextElement( gradeElement, KVTML_DATE, practiceDate().toString( Qt::ISODate ) ); - - parent.appendChild( gradeElement ); - } -} - -void KEduVocText::fromKVTML2(QDomElement & parent) -{ - setText( parent.firstChildElement( KVTML_TEXT ).text() ); - - // grade element - const QDomElement& gradeElement = parent.firstChildElement( KVTML_GRADE ); - if ( !gradeElement.isNull() ) { - - setGrade( gradeElement.firstChildElement(KVTML_CURRENTGRADE).text().toInt() ); - - setPracticeCount( gradeElement.firstChildElement(KVTML_COUNT).text().toInt() ); - - setBadCount( gradeElement.firstChildElement(KVTML_ERRORCOUNT).text().toInt() ); - - QString dateString = gradeElement.firstChildElement(KVTML_DATE).text(); - if ( !dateString.isEmpty() ) { - QDateTime value = QDateTime::fromString( dateString, Qt::ISODate ); - setPracticeDate( value ); - } - } -} - -bool KEduVocText::isEmpty() -{ - return d->m_text.isEmpty(); -} diff --git a/keduvocdocument/keduvoctext.h b/keduvocdocument/keduvoctext.h deleted file mode 100644 index 1d196c2..0000000 --- a/keduvocdocument/keduvoctext.h +++ /dev/null @@ -1,170 +0,0 @@ -/*************************************************************************** - Copyright 2007-2008 Frederik Gladhorn - ***************************************************************************/ - -/*************************************************************************** - * * - * 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. * - * * - ***************************************************************************/ - -#ifndef KEDUVOCTEXT_H -#define KEDUVOCTEXT_H - -#include "libkeduvocdocument_export.h" -#include - - -#define KV_MAX_GRADE 7 -#define KV_MIN_GRADE 0 - -#define KV_NORM_GRADE 0 // not practiced yet -#define KV_NORM_TEXT I18N_NOOP("Not Practiced Yet") - -#define KV_LEV1_GRADE 1 -#define KV_LEV1_TEXT I18N_NOOP("Level 1") - -#define KV_LEV2_GRADE 2 -#define KV_LEV2_TEXT I18N_NOOP("Level 2") - -#define KV_LEV3_GRADE 3 -#define KV_LEV3_TEXT I18N_NOOP("Level 3") - -#define KV_LEV4_GRADE 4 -#define KV_LEV4_TEXT I18N_NOOP("Level 4") - -#define KV_LEV5_GRADE 5 -#define KV_LEV5_TEXT I18N_NOOP("Level 5") - -#define KV_LEV6_GRADE 6 -#define KV_LEV6_TEXT I18N_NOOP("Level 6") - -#define KV_LEV7_GRADE 7 -#define KV_LEV7_TEXT I18N_NOOP("Level 7") - - -typedef unsigned short grade_t; -typedef unsigned short count_t; - -class QDomElement; - -/** - * A text in vocabulary documents. Associated with it are grade and date information. - * This should be used instead of strings for all things that can be tested and thus get a grade. - @author Frederik Gladhorn -*/ -class KEDUVOCDOCUMENT_EXPORT KEduVocText -{ -public: - /** default constructor */ - KEduVocText(const QString& text = QString()); - - /** copy constructor - * provides safe copy of d pointer - * @param other object to copy from - */ - KEduVocText( const KEduVocText &other ); - - /** default destructor */ - ~KEduVocText(); - - /** - * The translation as string (the word itself) - * @return the translation - */ - QString text() const; - - /** - * Sets the translation - * @param expr - */ - void setText( const QString & expr ); - - /** - * Equal operator to copy grades. - * @param other grades copied - * @return reference to the new grades - */ - KEduVocText& operator= ( const KEduVocText &other ); - /** - * Compare two sets of grades. - * @param other - * @return true if equal - */ - bool operator== ( const KEduVocText &other ) const; - - - /** returns how often this entry has been practiced as int - * @returns total count - */ - count_t practiceCount() const; - - /** set how often this entry has been practiced as int - * @param count the new count - */ - void setPracticeCount( count_t count ); - - /** returns bad query count as int - * @returns bad query count - */ - count_t badCount() const; - - /** set bad query count as int - * @param count the new count - */ - void setBadCount( count_t count ); - - /** increment bad query count of given translation by 1 */ - void incBadCount(); - - /** increment query count of given translation by 1 */ - void incPracticeCount(); - - /** - * Clears grading and date information. - */ - void resetGrades(); - - /** sets the grade - * @param grade number of knowlegde: 0=known, x=numbers not knows - */ - void setGrade( grade_t grade ); - - /** returns grade as int - * @returns number of knowlegde: 0=known, x=numbers not knows - */ - grade_t grade() const; - - /** increments grade */ - void incGrade(); - - /** decrements grade */ - void decGrade(); - - /** returns last practice date as int - */ - QDateTime practiceDate() const; - - /** Set last query date - * @param date the new date - */ - void setPracticeDate( const QDateTime & date ); - - /** - * If the string inside is empty this returns true. - * @return - */ - bool isEmpty(); - - void fromKVTML2(QDomElement& parent); - void toKVTML2(QDomElement& parent); - -private: - class KEduVocTextPrivate; - KEduVocTextPrivate * const d; -}; - -#endif diff --git a/keduvocdocument/keduvoctranslation.cpp b/keduvocdocument/keduvoctranslation.cpp deleted file mode 100644 index 167a76e..0000000 --- a/keduvocdocument/keduvoctranslation.cpp +++ /dev/null @@ -1,491 +0,0 @@ -/*************************************************************************** - Vocabulary Expression Translation for KDE Edu - ----------------------------------------------------------------------- - - Copyright 2007-2008 Frederik Gladhorn - ***************************************************************************/ - -/*************************************************************************** - * * - * 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. * - * * - ***************************************************************************/ - - -#include "keduvoctranslation.h" - -#include "keduvocdeclension.h" -#include "keduvocwordtype.h" -#include "keduvocleitnerbox.h" -#include "kvtml2defs.h" -#include "keduvockvtml2writer.h" -#include -#include - -class KEduVocTranslation::KEduVocTranslationPrivate -{ -public: - KEduVocTranslationPrivate(KEduVocExpression* parent); - - ~KEduVocTranslationPrivate(); - - KEduVocExpression* m_entry; - - /// Type of a word noun, verb, adjective etc - KEduVocWordType* m_wordType; - - /// Leitner box of the translation. - KEduVocLeitnerBox* m_leitnerBox; - - /// A comment giving additional information. - QString m_comment; - /// A hint, to make guessing the word easier. - QString m_hint; - /// Paraphrase - QString m_paraphrase; - /// An example - QString m_example; - /// Pronunciation - QString m_pronunciation; - /// Image url - KUrl m_imageUrl; - /// Sound url - KUrl m_soundUrl; - - /// When creating multiple choice tests, these are possible answers. (otherwise other words are added randomly) - QStringList m_multipleChoice; - - /// Conjugations of a word (I go, you go, he goes... boring in english) - QMap m_conjugations; - - /// The comparison forms of adjectives and adverbs: (fast), faster, fastest - QString m_comparative; - QString m_superlative; - - KEduVocDeclension* m_declension; - - // connections to other translations - /// Synonyms for a word: sick and ill, student and pupil - QList< KEduVocTranslation* > m_synonyms; - /// An antonym - the opposite: hot - cold - QList< KEduVocTranslation* > m_antonyms; - /// List of false friends - QList< KEduVocTranslation* > m_falseFriends; -}; - -KEduVocTranslation::KEduVocTranslationPrivate::KEduVocTranslationPrivate(KEduVocExpression* parent) -{ - m_entry = parent; - m_wordType = 0; - m_leitnerBox = 0; - m_declension = 0; -} - - -KEduVocTranslation::KEduVocTranslationPrivate::~KEduVocTranslationPrivate() -{ - delete m_declension; -} - -KEduVocTranslation::KEduVocTranslation(KEduVocExpression* entry) : d( new KEduVocTranslationPrivate(entry) ) -{ -} - - -KEduVocTranslation::KEduVocTranslation(KEduVocExpression* entry, const QString &translation ) : d( new KEduVocTranslationPrivate(entry) ) -{ - setText(translation.simplified()); -} - -KEduVocTranslation::KEduVocTranslation( const KEduVocTranslation &other ) - : KEduVocText(other), - // set the entry to 0, the translation will be put into a copied entry by the expression copy constructor - d( new KEduVocTranslationPrivate(0) ) -{ - // beter no word type copy as this is pointer copying - // will not work as this is not added to the word type container! -// d->m_wordType = other.d->m_wordType; -// d->m_leitnerBox = translation.d->m_leitnerBox; - d->m_comment = other.d->m_comment; - d->m_paraphrase = other.d->m_paraphrase; - d->m_example = other.d->m_example; - d->m_pronunciation = other.d->m_pronunciation; - d->m_conjugations = other.d->m_conjugations; - d->m_comparative = other.d->m_comparative; - d->m_superlative = other.d->m_superlative; - d->m_multipleChoice = other.d->m_multipleChoice; - d->m_imageUrl = other.d->m_imageUrl; - d->m_soundUrl = other.d->m_soundUrl; -// no copies of the following for now. we don't know enough to also add this as synonym/etc -// d->m_synonyms = other.d->m_synonyms; -// d->m_antonyms = other.d->m_antonyms; -// d->m_falseFriends = other.d->m_falseFriends; - if (other.d->m_declension) { - d->m_declension = new KEduVocDeclension(*other.d->m_declension); - } -} - -KEduVocTranslation::~KEduVocTranslation() -{ - setWordType(0); - setLeitnerBox(0); - foreach (KEduVocTranslation *synonym, d->m_synonyms) { - synonym->removeSynonym(this); - } - foreach (KEduVocTranslation *antonym, d->m_antonyms) { - antonym->removeAntonym(this); - } - foreach (KEduVocTranslation *falseFriend, d->m_falseFriends) { - falseFriend->removeFalseFriend(this); - } - delete d; -} - -bool KEduVocTranslation::operator == ( const KEduVocTranslation & translation ) const -{ - return KEduVocText::operator==(translation) && - d->m_wordType == translation.d->m_wordType && - d->m_leitnerBox == translation.d->m_leitnerBox && - d->m_comment == translation.d->m_comment && - d->m_paraphrase == translation.d->m_paraphrase && - d->m_example == translation.d->m_example && - d->m_pronunciation == translation.d->m_pronunciation && - d->m_imageUrl == translation.d->m_imageUrl && - d->m_soundUrl == translation.d->m_soundUrl && - d->m_comparative == translation.d->m_comparative && - d->m_superlative == translation.d->m_superlative && - d->m_multipleChoice == translation.d->m_multipleChoice && - d->m_synonyms == translation.d->m_synonyms && - d->m_antonyms == translation.d->m_antonyms && - d->m_falseFriends == translation.d->m_falseFriends && - d->m_conjugations == translation.d->m_conjugations; - /// @todo check and include declensions d->m_declension == translation.d->m_declension; -} - -KEduVocTranslation & KEduVocTranslation::operator = ( const KEduVocTranslation & translation ) -{ - KEduVocText::operator=(translation); - d->m_entry = translation.d->m_entry; -// d->m_wordType = translation.d->m_wordType; -// d->m_leitnerBox = translation.d->m_leitnerBox; - d->m_comment = translation.d->m_comment; - d->m_paraphrase = translation.d->m_paraphrase; - d->m_example = translation.d->m_example; - d->m_pronunciation = translation.d->m_pronunciation; - d->m_imageUrl = translation.d->m_imageUrl; - d->m_soundUrl = translation.d->m_soundUrl; - d->m_comparative = translation.d->m_comparative; - d->m_superlative = translation.d->m_superlative; - d->m_multipleChoice = translation.d->m_multipleChoice; - d->m_falseFriends = translation.d->m_falseFriends; - d->m_synonyms = translation.d->m_synonyms; - d->m_antonyms = translation.d->m_antonyms; - d->m_conjugations = translation.d->m_conjugations; - if (translation.d->m_declension) { - d->m_declension = new KEduVocDeclension(*translation.d->m_declension); - } - - return *this; -} - - -QString KEduVocTranslation::comment() const -{ - return d->m_comment; -} - - -void KEduVocTranslation::setComment( const QString & expr ) -{ - d->m_comment = expr.simplified(); -} - - -void KEduVocTranslation::addFalseFriend( KEduVocTranslation* falseFriend ) -{ - d->m_falseFriends.append(falseFriend); -} - -void KEduVocTranslation::removeFalseFriend(KEduVocTranslation * falseFriend) -{ - d->m_falseFriends.removeAt(d->m_falseFriends.indexOf(falseFriend)); -} - -QList< KEduVocTranslation* > KEduVocTranslation::falseFriends() const -{ - return d->m_falseFriends; -} - - -void KEduVocTranslation::addSynonym( KEduVocTranslation* synonym ) -{ - d->m_synonyms.append(synonym); -} - -void KEduVocTranslation::removeSynonym(KEduVocTranslation * synonym) -{ - d->m_synonyms.removeAt(d->m_synonyms.indexOf(synonym)); -} - -QList KEduVocTranslation::synonyms() const -{ - return d->m_synonyms; -} - -void KEduVocTranslation::addAntonym( KEduVocTranslation* antonym ) -{ - d->m_antonyms.append(antonym); -} - -QList KEduVocTranslation::antonyms() const -{ - return d->m_antonyms; -} - -void KEduVocTranslation::removeAntonym(KEduVocTranslation * antonym) -{ - d->m_antonyms.removeAt(d->m_antonyms.indexOf(antonym)); -} - -void KEduVocTranslation::setExample( const QString & expr ) -{ - d->m_example = expr.simplified(); -} - - -QString KEduVocTranslation::example() const -{ - return d->m_example; -} - - -void KEduVocTranslation::setParaphrase( const QString & expr ) -{ - d->m_paraphrase = expr.simplified(); -} - - -QString KEduVocTranslation::paraphrase() const -{ - return d->m_paraphrase; -} - - -void KEduVocTranslation::setConjugation( const QString& tense, const KEduVocConjugation& con ) -{ - d->m_conjugations[tense] = con; -} - - -KEduVocConjugation& KEduVocTranslation::conjugation( const QString& tense ) -{ - return d->m_conjugations[tense]; -} - - -QStringList & KEduVocTranslation::multipleChoice() -{ - return d->m_multipleChoice; -} - - -QString KEduVocTranslation::pronunciation() const -{ - return d->m_pronunciation; -} - - -void KEduVocTranslation::setPronunciation( const QString & expr ) -{ - d->m_pronunciation = expr.simplified(); -} - -QStringList KEduVocTranslation::conjugationTenses() const -{ - return d->m_conjugations.keys(); -} - -QMap< QString, KEduVocConjugation > KEduVocTranslation::conjugations() const -{ - return d->m_conjugations; -} - -void KEduVocTranslation::setConjugations(const QMap< QString, KEduVocConjugation > & conjugations) -{ - d->m_conjugations = conjugations; -} - -/** get the sound url for this translation if it exists */ -KUrl KEduVocTranslation::soundUrl() -{ - return d->m_soundUrl; -} - -/** set the sound url for this translation - * @param url url of the sound file */ -void KEduVocTranslation::setSoundUrl(const KUrl &url) -{ - d->m_soundUrl = url; -} - -/** get the image url for this translation if it exists */ -KUrl KEduVocTranslation::imageUrl() -{ - return d->m_imageUrl; -} - -/** set the image url for this translation - * @param url url of the image - */ -void KEduVocTranslation::setImageUrl(const KUrl &url) -{ - d->m_imageUrl = url; -} - -KEduVocWordType * KEduVocTranslation::wordType() const -{ - if (d) { - return d->m_wordType; - } else { - return 0; - } -} - -void KEduVocTranslation::setWordType(KEduVocWordType * wordType) -{ - if ( d->m_wordType ) { - d->m_wordType->removeTranslation(this); - } - if ( wordType ) { - wordType->addTranslation(this); - } - d->m_wordType = wordType; -} - -KEduVocLeitnerBox * KEduVocTranslation::leitnerBox() const -{ - return d->m_leitnerBox; -} - -void KEduVocTranslation::setLeitnerBox(KEduVocLeitnerBox * leitnerBox) -{ - if ( d->m_leitnerBox ) { - d->m_leitnerBox->removeTranslation(this); - } - if ( leitnerBox ) { - leitnerBox->addTranslation(this); - } - d->m_leitnerBox = leitnerBox; -} - -KEduVocExpression * KEduVocTranslation::entry() -{ - return d->m_entry; -} - -QString KEduVocTranslation::comparative() const -{ - return d->m_comparative; -} - -void KEduVocTranslation::setComparative(const QString & comparative) -{ - d->m_comparative = comparative; -} - -QString KEduVocTranslation::superlative() const -{ - return d->m_superlative; -} - -void KEduVocTranslation::setSuperlative(const QString & superlative) -{ - d->m_superlative = superlative; -} - -KEduVocDeclension * KEduVocTranslation::declension() -{ - return d->m_declension; -} - -void KEduVocTranslation::setDeclension(KEduVocDeclension * declension) -{ - // remove the old declension object - delete d->m_declension; - d->m_declension = declension; -} - -void KEduVocTranslation::toKVTML2(QDomElement & parent) -{ - // text and grade - KEduVocText::toKVTML2(parent); - - // declension - if (d->m_declension) { - d->m_declension->toKVTML2(parent); - } - - // conjugation - foreach ( const QString &tense, conjugationTenses() ) { - QDomElement conjugationElement = parent.ownerDocument().createElement( KVTML_CONJUGATION ); - conjugation(tense).toKVTML2(conjugationElement, tense); - parent.appendChild( conjugationElement ); - } - - // - KEduVocKvtml2Writer::appendTextElement( parent, KVTML_COMMENT, comment() ); - - // - KEduVocKvtml2Writer::appendTextElement( parent, KVTML_PRONUNCIATION, pronunciation() ); - - // - KEduVocKvtml2Writer::appendTextElement( parent, KVTML_EXAMPLE, example() ); - - // - KEduVocKvtml2Writer::appendTextElement( parent, KVTML_PARAPHRASE, paraphrase() ); - - ///@todo synonyms, antonyms - ///@todo false friends -} - -void KEduVocTranslation::fromKVTML2(QDomElement & parent) -{ - KEduVocText::fromKVTML2(parent); - - setDeclension(KEduVocDeclension::fromKVTML2(parent)); - - setComment( parent.firstChildElement( KVTML_COMMENT ).text() ); - - setPronunciation( parent.firstChildElement( KVTML_PRONUNCIATION ).text() ); - - // - setExample( parent.firstChildElement( KVTML_EXAMPLE ).text() ); - - // - setParaphrase( parent.firstChildElement( KVTML_PARAPHRASE ).text() ); - - // conjugations - QDomElement conjugationElement = parent.firstChildElement( KVTML_CONJUGATION ); - while ( !conjugationElement.isNull() ) { - QDomElement tenseElement = conjugationElement.firstChildElement( KVTML_TENSE ); - QString tense = tenseElement.text(); - KEduVocConjugation *conjugation = KEduVocConjugation::fromKVTML2(conjugationElement); - setConjugation(tense, *conjugation); - delete conjugation; - conjugationElement = conjugationElement.nextSiblingElement( KVTML_CONJUGATION ); - } - - ///@todo synonyms, antonym - ///@todo false friends -} - -void KEduVocTranslation::setEntry(KEduVocExpression * entry) -{ - d->m_entry = entry; -} - - - diff --git a/keduvocdocument/keduvoctranslation.h b/keduvocdocument/keduvoctranslation.h deleted file mode 100644 index 0d43188..0000000 --- a/keduvocdocument/keduvoctranslation.h +++ /dev/null @@ -1,302 +0,0 @@ -/*************************************************************************** - Vocabulary Expression Translation for KDE Edu - ----------------------------------------------------------------------- - Copyright 2007-2008 Frederik Gladhorn - ***************************************************************************/ - -/*************************************************************************** - * * - * 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. * - * * - ***************************************************************************/ - - -#ifndef KEDUVOCTRANSLATION_H -#define KEDUVOCTRANSLATION_H - -#include "libkeduvocdocument_export.h" -#include "keduvocarticle.h" -#include "keduvocconjugation.h" -#include "keduvoctext.h" -#include -#include - -class KEduVocExpression; -class KEduVocString; -class KEduVocWordType; -class KEduVocLeitnerBox; -class KEduVocDeclension; - -/** - @author Frederik Gladhorn -*/ -class KEDUVOCDOCUMENT_EXPORT KEduVocTranslation - :public KEduVocText -{ -public: - enum Related { - Synonym, - Antonym, - FalseFriend - }; - - /** - * Default constructor for an empty translation. - */ - KEduVocTranslation(KEduVocExpression* entry); - - /** - * Constructor - * @param translation is used as translation - */ - KEduVocTranslation(KEduVocExpression* entry, const QString &translation ); - - /** copy constructor for d-pointer safety */ - KEduVocTranslation( const KEduVocTranslation &other ); - - /** - * Destructor - */ - ~KEduVocTranslation(); - - KEduVocExpression* entry(); - - /** sets the pronunciation of this expression - * @param expression pronunciation of this index - */ - void setPronunciation( const QString & expression ); - - /** returns the pronunciation of this expression - * @return pronunciation or "" if none available - */ - QString pronunciation() const; - - /** returns comments of this expression - * @return comment or "" if no comment available - */ - QString comment() const; - - /** sets comment of this expression - * @param expr comment of this index - */ - void setComment( const QString & expr ); - - /** sets example this expression - * @param expression example of this index - */ - void setExample( const QString & expression ); - - /** returns example of this expression - * @return example or "" if no string available - */ - QString example() const; - - /** sets paraphrase of this expression - * @param expression paraphrase of this index - */ - void setParaphrase( const QString & expression ); - - /** returns paraphrase of this expression - * @return paraphrase or "" if no string available - */ - QString paraphrase() const; - - /** sets antonym this expression - * @param expression antonym of this index - */ - void setAntonym( const QString & expression ); - - /** returns antonym of this expression - * @return antonym or "" if no string available - */ - QString antonym() const; - - /** - * Set a irregular plural form. - * @param plural plural of the word - */ - void setIrregularPlural( const QString& plural ); - - /** - * Get a irregular plural form. - * @return plural of the word - */ - QString irregularPlural() const; - - /** returns the word type of this expression, you will get a 0 pointer - * if wordtype isn't set for the translation - * - * @return type or "" if no type available - */ - KEduVocWordType* wordType() const; - - /** sets the word type of this expression - * @param type type of this expression ("" = none) - */ - void setWordType( KEduVocWordType* wordType ); - - /** returns the leitner box of this translation - * @return the box - */ - KEduVocLeitnerBox* leitnerBox() const; - - /** sets the leitner box of this translation - * @param leitnerBox the box - */ - void setLeitnerBox( KEduVocLeitnerBox* leitnerBox ); - - /** - * returns a conjugation if available - * @param tense tense of the requested conjugation - * @return the conjugation - */ - KEduVocConjugation& conjugation( const QString& tense ); - - /** adds conjugations or replaces them, if they exist. - * @param conjugation conjugation - */ - void setConjugation( const QString& tense, const KEduVocConjugation & conjugation ); - - /** - * Returns a pointer to the declension object of this translation. - * Returns 0 if no declension object exists! - * @return the declension - */ - KEduVocDeclension* declension(); - - /** - * Set a new declension for a translation - * @param declension - */ - void setDeclension(KEduVocDeclension* declension); - - /** - * Bad, only used for tense entry page, will be deleted later. Deprecated. - * @param conjugation - */ - void setConjugations( const QMap& conjugations ); - - QStringList conjugationTenses() const; - - /** - * Bad, only compatibility. Deprecated. - * @return - */ - QMap conjugations() const; - - /** - * Comparison forms of adjectives/adverbs. - */ - QString comparative() const; - void setComparative(const QString& comparative); - QString superlative() const; - void setSuperlative(const QString& superlative); - - /** returns multiple choice if available - */ - QStringList & multipleChoice(); - - /** sets multiple choice - * @param mc multiple choice block - */ -// void setMultipleChoice( const QStringList &mc ); - - /** get the sound url for this translation if it exists */ - KUrl soundUrl(); - - /** set the sound url for this translation - * @param url url of the sound file */ - void setSoundUrl(const KUrl &url); - - /** get the image url for this translation if it exists */ - KUrl imageUrl(); - - /** set the image url for this translation - * @param url url of the image - */ - void setImageUrl(const KUrl &url); - - /** - * add a false friend - * @param falseFriend false friend of this index - */ - void addFalseFriend( KEduVocTranslation* falseFriend ); - - /** - * remove a false friend - * @param falseFriend false friend of this index - */ - void removeFalseFriend( KEduVocTranslation* falseFriend ); - - /** - * returns false friends of this expression - * @return list of false friends - */ - QList falseFriends() const; - - /** - * add a synonym - * @param synonym - */ - void addSynonym( KEduVocTranslation* synonym ); - - /** - * remove a synonym - * @param synonym - */ - void removeSynonym( KEduVocTranslation* synonym ); - - /** - * returns synonyms of this expression - * @return synonyms - */ - QList synonyms() const; - - /** - * add a antonym - * @param antonym - */ - void addAntonym( KEduVocTranslation* antonym ); - - /** - * remove a antonym - * @param antonym - */ - void removeAntonym( KEduVocTranslation* antonym ); - - /** - * returns antonyms of this expression - * @return antonyms - */ - QList antonyms() const; - - /** - * Equal operator to assing a translation to another one. - * @param translation translation to be copied - * @return reference to the new translation - */ - KEduVocTranslation& operator= ( const KEduVocTranslation &translation ); - - /** - * Compare two translations, including word type etc. - * @param translation - * @return true if equal - */ - bool operator== ( const KEduVocTranslation &translation ) const; - - void fromKVTML2(QDomElement& parent); - void toKVTML2(QDomElement& parent); - -private: - class KEduVocTranslationPrivate; - KEduVocTranslationPrivate* const d; - - // for the copy constructor - void setEntry(KEduVocExpression* entry); - friend class KEduVocExpression; -}; - -#endif diff --git a/keduvocdocument/keduvocvokabelnreader.cpp b/keduvocdocument/keduvocvokabelnreader.cpp deleted file mode 100644 index 7172e5b..0000000 --- a/keduvocdocument/keduvocvokabelnreader.cpp +++ /dev/null @@ -1,184 +0,0 @@ -/*************************************************************************** - - create a KEduVocDocument from a Vokabeln file - - ----------------------------------------------------------------------- - - begin : Wed Jun 15 19:32:00 PDT 2005 - - copyright : (C) 2005, 2007 Peter Hedlund - (C) 2007 Frederik Gladhorn - - ----------------------------------------------------------------------- - - ***************************************************************************/ - -/*************************************************************************** - * * - * 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. * - * * - ***************************************************************************/ - -#include "keduvocvokabelnreader.h" - -#include - -#include -#include - -#include "keduvocdocument.h" -#include "keduvocexpression.h" - -KEduVocVokabelnReader::KEduVocVokabelnReader( QIODevice *file ) -{ - // the file must be already open - m_inputFile = file; - m_errorMessage = ""; -} - - -bool KEduVocVokabelnReader::readDoc( KEduVocDocument *doc ) -{ - kDebug() << "Reading vokabeln.de document..."; - m_doc = doc; - - m_doc->setAuthor( "http://www.vokabeln.de" ); - - QTextStream inputStream( m_inputFile ); - inputStream.setCodec( "ISO-8859-1" ); - inputStream.setAutoDetectUnicode( false ); - inputStream.seek( 0 ); - - QString title; - QString lang1; - QString lang2; - QString expression; - QString original; - QString translation; - QString temp; - QString comment; - - int i; - int wordCount; - int lessonNumber; - - int lines = 10000; - - QStringList titles; - QStringList languages; - QStringList words; - - temp = inputStream.readLine(); - - if ( temp.startsWith ( QChar::fromLatin1 ( '"' ) ) ) { - while ( temp != QChar::fromLatin1('0') ) { - if ( title.isEmpty() ) { - title = temp; - } else { - comment.append( temp.append('\n') ); - } - temp = inputStream.readLine(); - } - } - - // 1 line header - if (comment.isEmpty()) { - titles = title.split( "\"," ); - m_doc->setTitle(titles[0].mid(1)); - } - // longer header - else { - titles = comment.split( "\"," ); - m_doc->setDocumentComment(titles[0]); - m_doc->setTitle(title.mid(1)); - } - - wordCount = titles[1].section( ',', 0, 0 ).toInt(); - - inputStream.readLine(); - - lang1 = inputStream.readLine(); - languages = lang1.split( "\"," ); - - m_doc->appendIdentifier(); - QString language = languages[0].mid( 1 ); - m_doc->identifier(0).setLocale(language); - m_doc->identifier(0).setName(language); - kDebug() << "First language: " << language; - - m_doc->appendIdentifier(); - language = languages[1].mid( 1 ); - m_doc->identifier(1).setLocale(language); - m_doc->identifier(1).setName(language); - kDebug() << "Second language: " << language; - - while ( !temp.contains("8. Lernhilfe") ) { - temp = inputStream.readLine(); //DO NOT translate - } - - for ( i = 0; i <= 14; ++i ) { - inputStream.readLine(); - } - - - for ( i = 0; i < wordCount - 1; ++i ) { - int c = 0; - expression.clear(); - - while ( c < 2 ) { - temp = inputStream.readLine(); - c+= temp.count( "\",", Qt::CaseSensitive ); - expression.append( temp ); - if ( c < 2 ) { - expression.append( ' ' ); - } - } - - words = expression.split( "\"," ); - original = words[0].mid( 1 ); - translation = words[1].mid( 1 ); - lessonNumber = words[2].toInt() - 1; - - kDebug() << "Reading entry: " << original << " - " << translation << " Lesson: " << lessonNumber; - - // fallback if it's not read correctly - if (lessonNumber < 0) { - kDebug() << "Warning, invalid lesson found!"; - lessonNumber = 0; - } - - while(m_doc->lesson()->childContainerCount() <= lessonNumber) { - KEduVocLesson* lesson = new KEduVocLesson(i18n("Lesson %1", lessonNumber), m_doc->lesson()); - m_doc->lesson()->appendChildContainer(lesson); - kDebug() << "Created lesson " << lessonNumber; - } - - KEduVocExpression* kve = new KEduVocExpression; - kve->setTranslation( 0, original ); - kve->setTranslation( 1, translation ); - - static_cast(m_doc->lesson()->childContainer(lessonNumber))->appendEntry(kve); - - inputStream.readLine(); - inputStream.readLine(); - } - - inputStream.readLine(); - inputStream.readLine(); - inputStream.readLine(); - - for ( int i = 0; !inputStream.atEnd() && i < lines; i++ ) { - QString lessonDescr = inputStream.readLine(); - lessonDescr = lessonDescr.mid( 1, lessonDescr.length() - 2 ); - m_doc->lesson()->childContainer(i)->setName(lessonDescr); - if ( lessonDescr.isEmpty() ) { - break; - } - inputStream.readLine(); - } - - return true; -} diff --git a/keduvocdocument/keduvocvokabelnreader.h b/keduvocdocument/keduvocvokabelnreader.h deleted file mode 100644 index 00907ca..0000000 --- a/keduvocdocument/keduvocvokabelnreader.h +++ /dev/null @@ -1,44 +0,0 @@ -/*************************************************************************** - create a KEduVocDocument from a Vokabeln file - ----------------------------------------------------------------------- - copyright : (C) 2007 Peter Hedlund - - - ***************************************************************************/ - -/*************************************************************************** - * * - * 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. * - * * - ***************************************************************************/ - -#ifndef KEDUVOCVOKABELNREADER_H -#define KEDUVOCVOKABELNREADER_H - -#include - -class QIODevice; -class KEduVocDocument; - -class KEduVocVokabelnReader -{ -public: - KEduVocVokabelnReader( QIODevice *file ); - - bool readDoc( KEduVocDocument *doc ); - - QString errorMessage() const - { - return m_errorMessage; - } - -private: - QIODevice *m_inputFile; - KEduVocDocument *m_doc; - QString m_errorMessage; -}; - -#endif diff --git a/keduvocdocument/keduvocwordflags.h b/keduvocdocument/keduvocwordflags.h deleted file mode 100644 index e6bb939..0000000 --- a/keduvocdocument/keduvocwordflags.h +++ /dev/null @@ -1,78 +0,0 @@ -/*************************************************************************** - Copyright 2008 David Capel - ***************************************************************************/ - -/*************************************************************************** - * * - * 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. * - * * - ***************************************************************************/ - -#ifndef KEDUVOCWORDFLAGS_H -#define KEDUVOCWORDFLAGS_H - -#include - -class KEduVocWordFlag -{ -public: - enum Flags - { - // This is used for both empty flags and to denote no flags of the correct type were set. - NoInformation = 0x0, - - // Gender - Masculine = 0x1, - Feminine = 0x2, - Neuter = 0x4, - - // Plurality - Singular = 0x10, - Dual = 0x20, - Plural = 0x40, - - // Part of Speech - Verb = 0x100, - Noun = 0x200, - Pronoun = 0x400, - Adjective = 0x800, - Adverb = 0x1000, - Article = 0x2000, - Conjunction = 0x4000, - - // Person - First = 0x10000, - Second = 0x20000, - Third = 0x40000, - - // Declension Case - Nominative = 0x80000, - Genitive = 0x100000, - Dative = 0x200000, - Accusative = 0x400000, - Ablative = 0x800000, - Locative = 0x1000000, - Vocative = 0x2000000, - - // Other assorted flags - Definite = 0x4000000, // The article is definite - Indefinite = 0x8000000, // The article is indefinite - Regular = 0x10000000, - Irregular = 0x20000000 - }; - - static const Flags genders = (Flags)(Masculine | Feminine | Neuter); - static const Flags partsOfSpeech =(Flags)(Noun | Verb | Article | Pronoun | Adjective | Adverb | Conjunction); - static const Flags numbers = (Flags)(Singular | Plural | Dual); - static const Flags cases = (Flags)(Nominative|Genitive|Dative|Accusative|Ablative|Locative|Vocative); - static const Flags persons = (Flags)(First | Second | Third); -}; - -Q_DECLARE_FLAGS(KEduVocWordFlags, KEduVocWordFlag::Flags) -Q_DECLARE_OPERATORS_FOR_FLAGS(KEduVocWordFlags) - - -#endif diff --git a/keduvocdocument/keduvocwordtype.cpp b/keduvocdocument/keduvocwordtype.cpp deleted file mode 100644 index 65b0638..0000000 --- a/keduvocdocument/keduvocwordtype.cpp +++ /dev/null @@ -1,146 +0,0 @@ -/*************************************************************************** - - Copyright 2007 Jeremy Whiting - Copyright 2007 Frederik Gladhorn - - ***************************************************************************/ - -/*************************************************************************** - * * - * 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. * - * * - ***************************************************************************/ - -#include "keduvocwordtype.h" - -#include "keduvocexpression.h" - -#include - -#include -#include - -class KEduVocWordType::Private -{ -public: - // bitvector of word type flags - KEduVocWordFlags m_flags; - QList m_expressions; - // list of translations - QList m_translations; -}; - -KEduVocWordType::KEduVocWordType(const QString& name, KEduVocWordType *parent) - : KEduVocContainer(name, WordType, parent), d( new Private ) -{} - -KEduVocWordType::~KEduVocWordType() -{ - foreach(KEduVocTranslation* translation, d->m_translations) { - translation->setWordType(0); - } - delete d; -} - -QList KEduVocWordType::entries(EnumEntriesRecursive recursive) -{ - if (recursive == Recursive) { - return entriesRecursive(); - } - - return d->m_expressions; -} - -int KEduVocWordType::entryCount(EnumEntriesRecursive recursive) -{ - if (recursive == Recursive) { - return entriesRecursive().count(); - } - return d->m_expressions.count(); -} - -void KEduVocWordType::addTranslation(KEduVocTranslation* translation) -{ - // add to expression - if not already there because another translation of the same word is there. - bool found = false; - foreach(int i, translation->entry()->translationIndices()) { - if (translation->entry()->translation(i)->wordType() == this) { - found = true; - break; - } - } - if (!found) { - d->m_expressions.append(translation->entry()); - } - d->m_translations.append( translation ); - invalidateChildLessonEntries(); -} - -void KEduVocWordType::removeTranslation(KEduVocTranslation* translation) -{ - d->m_translations.removeAt( d->m_translations.indexOf(translation) ); - - // no lesson found - this entry is being deleted. remove all its siblings. - if (!translation->entry()->lesson()) { - int index = d->m_expressions.indexOf(translation->entry()); - if (index != -1) { - d->m_expressions.removeAt(index); - } - } - - // remove from cache - bool found = false; - foreach(int i, translation->entry()->translationIndices()) { - if (translation->entry()->translation(i)->wordType() && translation->entry()->translation(i)->wordType() == this) { - found = true; - break; - } - } - if (!found) { - d->m_expressions.removeAt(d->m_expressions.indexOf(translation->entry())); - } - - invalidateChildLessonEntries(); -} - -KEduVocTranslation * KEduVocWordType::translation(int row) -{ - - return d->m_translations.value(row); -} - -KEduVocExpression * KEduVocWordType::entry(int row, EnumEntriesRecursive recursive) -{ - if (recursive == Recursive) { - return entriesRecursive().value(row); - } - return entries().value(row); -} - -KEduVocWordFlags KEduVocWordType::wordType() const -{ - return d->m_flags; -} - -void KEduVocWordType::setWordType(KEduVocWordFlags flags) -{ - d->m_flags = flags; -} - -KEduVocWordType* KEduVocWordType::childOfType(const KEduVocWordFlags& flags) -{ - if(d->m_flags == flags) { - return this; - } - foreach(KEduVocContainer* child, childContainers()) { - KEduVocWordType* result = static_cast(child)->childOfType(flags); - if(result) { - return result; - } - } - return 0; -} - diff --git a/keduvocdocument/keduvocwordtype.h b/keduvocdocument/keduvocwordtype.h deleted file mode 100644 index 736fd5a..0000000 --- a/keduvocdocument/keduvocwordtype.h +++ /dev/null @@ -1,102 +0,0 @@ -/*************************************************************************** - - Copyright 2007 Jeremy Whiting - Copyright 2007 Frederik Gladhorn - - ***************************************************************************/ - -/*************************************************************************** - * * - * 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. * - * * - ***************************************************************************/ - -#ifndef KEDUVOCWORDTYPE_H -#define KEDUVOCWORDTYPE_H - -#include "libkeduvocdocument_export.h" - -#include "keduvoccontainer.h" - -#include "keduvocwordflags.h" - -#include -#include - -class KEduVocExpression; -class KEduVocTranslation; - -/** class to store translation word types */ -class KEDUVOCDOCUMENT_EXPORT KEduVocWordType :public KEduVocContainer -{ -public: - - - /** default constructor */ - explicit KEduVocWordType(const QString& name, KEduVocWordType *parent = 0); - - /** destructor */ - ~KEduVocWordType(); - - /** assignment operator */ -// KEduVocWordType& operator= ( const KEduVocWordType& ); - - /** - * Internally (different from the name) the class can have one of the preset word types. These are used to determine special properties (verbs have conjugations available for example). - * @param type - */ - void setWordType(KEduVocWordFlags flags); - - /** - * Return the raw WordTypeFlags. Returns NoInformation if no flags are set. - * @return WordTypeFlags - */ - KEduVocWordFlags wordType() const; - - /** - * Return a child class (or this class) that is of the specified type. Returns 0 if no class of that type is found. - * @param type - * @return - */ - KEduVocWordType* childOfType(const KEduVocWordFlags& flags); - - /** - * The word type class does keep track of individual translations, because for one entry, the translations can have different word types (eg. genders of nouns tend to be different in different langues). - * @param row - * @return - */ - KEduVocTranslation * translation(int row); - - /** - * get a list of all entries in the lesson - * @param recursive include entries in sublessons - * @return - */ - QList < KEduVocExpression* > entries(EnumEntriesRecursive recursive = NotRecursive); - - KEduVocExpression* entry(int row, EnumEntriesRecursive recursive = NotRecursive); - - /** get the number of entries in the lesson */ - int entryCount(EnumEntriesRecursive recursive = NotRecursive); - -private: - class Private; - Private * const d; - - /** add an entry to the lesson - * @param entryid id of the entry to add - */ - void addTranslation(KEduVocTranslation* translation); - - /** remove an entry from the lesson - * @param entryid id of the entry to remove - */ - void removeTranslation(KEduVocTranslation* translation); - - friend class KEduVocTranslation; -}; - -#endif diff --git a/keduvocdocument/keduvocwqlreader.cpp b/keduvocdocument/keduvocwqlreader.cpp deleted file mode 100644 index 0841b10..0000000 --- a/keduvocdocument/keduvocwqlreader.cpp +++ /dev/null @@ -1,172 +0,0 @@ -/*************************************************************************** - read a KEduVocDocument from a WQL file - ----------------------------------------------------------------------- - copyright : (C) 2004, 2007, 2008 Peter Hedlund - (C) 2005 Eric Pignet - (C) 2007 Frederik Gladhorn - - ***************************************************************************/ - -/*************************************************************************** - * * - * 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. * - * * - ***************************************************************************/ - -#include "keduvocwqlreader.h" - -#include -#include -#include - -#include - -#include "keduvocdocument.h" -#include "keduvocexpression.h" - -KEduVocWqlReader::KEduVocWqlReader( QIODevice *file ) -{ - // the file must be already open - m_inputFile = file; - m_errorMessage = ""; -} - - -bool KEduVocWqlReader::readDoc( KEduVocDocument *doc ) -{ - m_doc = doc; - - QTextStream inputStream( m_inputFile ); - inputStream.setCodec( "Windows-1252" ); //("ISO-8851-1"); - inputStream.setAutoDetectUnicode( false ); - inputStream.seek( 0 ); - - QString s = ""; - s=inputStream.readLine(); - if ( s != "WordQuiz" ) { - m_errorMessage = i18n( "This does not appear to be a (K)WordQuiz file" ); - return false; - } - s = inputStream.readLine(); - s = s.left( 1 ); - int iFV = s.toInt( 0 ); - if ( iFV != 5 ) { - m_errorMessage = i18n( "Only files created by WordQuiz 5.x or later can be opened" ); - return false; - } - - m_errorMessage = i18n( "Error while reading file" ); - - while ( !inputStream.atEnd() && inputStream.readLine() != "[Font Info]" ) ; - if ( inputStream.atEnd() ) - return false; - s = inputStream.readLine(); - int p = s.indexOf( "=", 0 ); - QString fam = s.right( s.length() - ( p + 1 ) ); - fam = fam.mid( 1, fam.length() - 2 ); - - s = inputStream.readLine(); - p = s.indexOf( "=", 0 ); - s = s.right( s.length() - ( p + 1 ) ); - //int ps = s.toInt(0); - - s = inputStream.readLine(); - p = s.indexOf( "=", 0 ); - s = s.right( s.length() - ( p + 1 ) ); - int b = 0; - if ( s == "1" ) { - b = QFont::Bold; - } - - s = inputStream.readLine(); - p = s.indexOf( "=", 0 ); - s = s.right( s.length() - ( p + 1 ) ); - //bool it = (s == "1"); - - //m_doc->setFont(new QFont(fam, ps, b, it)); - - /* TODO - while (inputStream.readLine() != "[Character Info]"); - s = inputStream.readLine(); - p = s.find("=", 0); - m_specialCharacters = s.right(s.length() - (p + 1)); - */ - while ( !inputStream.atEnd() && inputStream.readLine() != "[Grid Info]" ) ; - if ( inputStream.atEnd() ) - return false; - inputStream.readLine(); //skip value for width of row headers - - s = inputStream.readLine(); - p = s.indexOf( "=", 0 ); - s = s.right( s.length() - ( p + 1 ) ); -// m_doc->setSizeHint( 0, s.toInt() ); - - s = inputStream.readLine(); - p = s.indexOf( "=", 0 ); - s = s.right( s.length() - ( p + 1 ) ); -// m_doc->setSizeHint( 1, s.toInt() ); - - /* TODO - s = inputStream.readLine(); - p = s.find("=", 0); - s = s.right(s.length() - (p + 1)); - m_numRows = (s.toInt() - 1); //We need to reduce by one since the header is not included - // Selection - s = inputStream.readLine(); - p = s.find("=", 0); - s = s.right(s.length() - (p + 1)); - m_topLeft =s.toInt(0, 10) - 1; - - s = inputStream.readLine(); - p = s.find("=", 0); - s = s.right(s.length() - (p + 1)); - m_topRight =s.toInt(0, 10) - 1; - - s = inputStream.readLine(); - p = s.find("=", 0); - s = s.right(s.length() - (p + 1)); - m_bottomLeft =s.toInt(0, 10) - 1; - - s = inputStream.readLine(); - p = s.find("=", 0); - s = s.right(s.length() - (p + 1)); - m_bottomRight =s.toInt(0, 10) - 1 ; - */ - while ( !inputStream.atEnd() && inputStream.readLine() != "[Vocabulary]" ) ; - if ( inputStream.atEnd() ) - return false; - - KEduVocLesson* lesson = new KEduVocLesson( i18n("Vocabulary"), m_doc->lesson()); - m_doc->lesson()->appendChildContainer(lesson); - - s = inputStream.readLine(); - p = s.indexOf( " [", 0 ); - s = s.left( p ); - s = s.simplified(); - m_doc->appendIdentifier(); - m_doc->identifier(0).setLocale( s ); - m_doc->identifier(0).setName( s ); - s = inputStream.readLine(); - m_doc->appendIdentifier(); - m_doc->identifier(1).setLocale( s ); - m_doc->identifier(1).setName( s ); - - while ( !s.isNull() ) { - s = inputStream.readLine(); - p = s.indexOf( "[", 0 ); - //QString r = s.mid(p + 1, 10); - //int h = r.toInt(); - s = s.left( p ); - s = s.simplified(); - QString b; - b = inputStream.readLine(); - - KEduVocExpression * expr = new KEduVocExpression( s ); - expr->setTranslation( 1, b ); - lesson->appendEntry( expr ); - } - return true; -} diff --git a/keduvocdocument/keduvocwqlreader.h b/keduvocdocument/keduvocwqlreader.h deleted file mode 100644 index 4b08a98..0000000 --- a/keduvocdocument/keduvocwqlreader.h +++ /dev/null @@ -1,44 +0,0 @@ -/*************************************************************************** - read a KEduVocDocument from a WQL file - ----------------------------------------------------------------------- - copyright : (C) 2004, 2007 Peter Hedlund - : (c) 2005 Eric Pignet - - ***************************************************************************/ - -/*************************************************************************** - * * - * 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. * - * * - ***************************************************************************/ - -#ifndef KEDUVOCWQLREADER_H -#define KEDUVOCWQLREADER_H - -#include - -class QIODevice; -class KEduVocDocument; - -class KEduVocWqlReader -{ -public: - KEduVocWqlReader( QIODevice *file ); - - bool readDoc( KEduVocDocument *doc ); - - QString errorMessage() const - { - return m_errorMessage; - } - -private: - QIODevice *m_inputFile; - KEduVocDocument *m_doc; - QString m_errorMessage; -}; - -#endif diff --git a/keduvocdocument/keduvocxdxfreader.cpp b/keduvocdocument/keduvocxdxfreader.cpp deleted file mode 100644 index 4317f6f..0000000 --- a/keduvocdocument/keduvocxdxfreader.cpp +++ /dev/null @@ -1,119 +0,0 @@ -/*************************************************************************** - create a KEduVocDocument from a XDXF file - ----------------------------------------------------------------------- - copyright : (C) 2007 Peter Hedlund - - ***************************************************************************/ - -/*************************************************************************** - * * - * 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. * - * * - ***************************************************************************/ - -#include "keduvocxdxfreader.h" - -#include - -#include - -#include "keduvocexpression.h" -#include "keduvocdocument.h" - -KEduVocXdxfReader::KEduVocXdxfReader( KEduVocDocument *doc ) -{ - m_doc = doc; -} - - -bool KEduVocXdxfReader::read( QIODevice *device ) -{ - setDevice( device ); - - while ( !atEnd() ) { - readNext(); - - if ( isStartElement() ) { - if ( name() == "xdxf" ) - readXdxf(); - else - raiseError( i18n( "This is not a XDXF document" ) ); - } - } - - return !error(); -} - - -void KEduVocXdxfReader::readUnknownElement() -{ - while ( !atEnd() ) { - readNext(); - - if ( isEndElement() ) - break; - - if ( isStartElement() ) - readUnknownElement(); - } -} - - -void KEduVocXdxfReader::readXdxf() -{ - ///The language attributes are required and should be ISO 639-2 codes, but you never know... - QStringRef id1 = attributes().value( "lang_from" ); - m_doc->appendIdentifier(); - if ( !id1.isNull() ) { - m_doc->identifier(0).setLocale( id1.toString().toLower() ); - m_doc->identifier(0).setName( id1.toString().toLower() ); - } - QStringRef id2 = attributes().value( "lang_to" ); - m_doc->appendIdentifier(); - if ( !id2.isNull() ) { - m_doc->identifier(1).setLocale( id2.toString().toLower() ); - m_doc->identifier(1).setName( id2.toString().toLower() ); - } - - while ( !atEnd() ) { - readNext(); - - if ( isEndElement() ) - break; - - if ( isStartElement() ) { - if ( name() == "description" ) - m_doc->setDocumentComment( readElementText() ); - else if ( name() == "full_name" ) - m_doc->setTitle( readElementText() ); - else if ( name() == "ar" ) - readEntry(); - else - readUnknownElement(); - } - } - - m_doc->setAuthor( "http://xdxf.sf.net" ); -} - - -void KEduVocXdxfReader::readEntry() -{ - QString front; - QString back; - - while ( !( isEndElement() && name() == "ar" ) ) { - readNext(); - if ( isStartElement() && name() == "k" ) - front = readElementText(); - else if ( isCharacters() || isEntityReference() ) - back.append( text().toString() ); - } - - KEduVocExpression expr = KEduVocExpression( front ); - expr.setTranslation( 1, back ); - m_doc->lesson()->appendEntry( &expr ); -} diff --git a/keduvocdocument/keduvocxdxfreader.h b/keduvocdocument/keduvocxdxfreader.h deleted file mode 100644 index 61a45d8..0000000 --- a/keduvocdocument/keduvocxdxfreader.h +++ /dev/null @@ -1,40 +0,0 @@ -/*************************************************************************** - create a KEduVocDocument from a XDXF file - ----------------------------------------------------------------------- - copyright : (C) 2007 Peter Hedlund - - ***************************************************************************/ - -/*************************************************************************** - * * - * 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. * - * * - ***************************************************************************/ - -#ifndef KEDUVOCXDXFREADER_H -#define KEDUVOCXDXFREADER_H - -#include - -class QIODevice; -class KEduVocDocument; - -class KEduVocXdxfReader : public QXmlStreamReader -{ -public: - KEduVocXdxfReader( KEduVocDocument *doc ); - - bool read( QIODevice *device ); - -private: - void readUnknownElement(); - void readXdxf(); - void readEntry(); - - KEduVocDocument *m_doc; -}; - -#endif diff --git a/keduvocdocument/kvtml2.dtd b/keduvocdocument/kvtml2.dtd deleted file mode 100644 index 5436302..0000000 --- a/keduvocdocument/kvtml2.dtd +++ /dev/null @@ -1,89 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/keduvocdocument/kvtml2.xsd b/keduvocdocument/kvtml2.xsd deleted file mode 100644 index 303d47b..0000000 --- a/keduvocdocument/kvtml2.xsd +++ /dev/null @@ -1,236 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/keduvocdocument/kvtml2defs.h b/keduvocdocument/kvtml2defs.h deleted file mode 100644 index 8bf2733..0000000 --- a/keduvocdocument/kvtml2defs.h +++ /dev/null @@ -1,162 +0,0 @@ -/*************************************************************************** - Vocabulary Document for KDE Edu KVTML version 2 - ----------------------------------------------------------------------- - copyright : (C) 2007 Jeremy Whiting - (C) 2007 Frederik Gladhorn - ***************************************************************************/ - -/*************************************************************************** - * * - * 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. * - * * - ***************************************************************************/ - -#ifndef KVTML2DEFS_H -#define KVTML2DEFS_H - -#define KVTML_TAG "kvtml" -#define KVTML_VERSION "version" -#define KVTML_ID "id" - -#define KVTML_INFORMATION "information" - -#define KVTML_GENERATOR "generator" -#define KVTML_TITLE "title" -#define KVTML_AUTHOR "author" -#define KVTML_AUTHORCONTACT "contact" -#define KVTML_LICENSE "license" -#define KVTML_COMMENT "comment" -#define KVTML_CATEGORY "category" - -#define KVTML_IDENTIFIERS "identifiers" -#define KVTML_IDENTIFIER "identifier" -#define KVTML_IDENTIFIERTYPE "identifiertype" -#define KVTML_LOCALE "locale" -#define KVTML_NAME "name" -#define KVTML_SIZEHINT "sizehint" - -// articles -#define KVTML_ARTICLE "article" - -// conjugation, declension and personal pronouns -#define KVTML_CONJUGATION "conjugation" -#define KVTML_CONJUGATIONTYPE "conjugationtype" -#define KVTML_PERSONALPRONOUNS "personalpronouns" -#define KVTML_DECLENSION "declension" - -static const QString KVTML_DECLENSION_CASE[] = { - "nominative", - "genitive", - "dative", - "accusative", - "ablative", - "locative", - "vocative" -}; - -static const QString KVTML_GRAMMATICAL_NUMBER[] = { - "singular", - "dual", // dual is the case where there's a special form for exactly two - "plural" -}; - -static const QString KVTML_GRAMMATICAL_GENDER[] = { - "male", - "female", - "neutral" -}; - -static const QString KVTML_GRAMMATICAL_PERSON[] = { - "firstperson", - "secondperson", - "thirdpersonmale", - "thirdpersonfemale", - "thirdpersonneutralcommon" -}; - -static const QString KVTML_GRAMMATICAL_DEFINITENESS[] = { - "definite", - "indefinite" -}; - - -// for the personal pronuns: -// if this tag exists, in a conjugation male/female are different -#define KVTML_THIRD_PERSON_MALE_FEMALE_DIFFERENT "malefemaledifferent" -// if this tag exists conjugations even have a neutral form for the third person -#define KVTML_THIRD_PERSON_NEUTRAL_EXISTS "neutralexists" -#define KVTML_DUAL_EXISTS "dualexists" - -// word types, lessons and leitner boxes are vocabulary containers. -// each is allowed to have as many child containers as desired. -// for KDE 4.0 Parley will only allow a depth of wordtype cildren of two, -// leitner is not implemented at all. -// it is assumed that one container only has children of the same type. -// containers may have an image associated to represent them visually. -#define KVTML_WORDTYPES "wordtypes" -#define KVTML_LESSONS "lessons" -#define KVTML_LEITNERBOXES "leitnerboxes" -#define KVTML_CONTAINER "container" -#define KVTML_INPRACTICE "inpractice" - -// these are necessary to enable practices based on word types. users can give types arbitrary names, but these few are hardcoded. special container types -#define KVTML_SPECIALWORDTYPE "specialwordtype" -#define KVTML_SPECIALWORDTYPE_NOUN "noun" -#define KVTML_SPECIALWORDTYPE_NOUN_MALE "noun/male" -#define KVTML_SPECIALWORDTYPE_NOUN_FEMALE "noun/female" -#define KVTML_SPECIALWORDTYPE_NOUN_NEUTRAL "noun/neutral" -#define KVTML_SPECIALWORDTYPE_VERB "verb" -#define KVTML_SPECIALWORDTYPE_ADJECTIVE "adjective" -#define KVTML_SPECIALWORDTYPE_ADVERB "adverb" - - -#define KVTML_TENSES "tenses" -#define KVTML_TENSE "tense" - -#define KVTML_USAGES "usages" -#define KVTML_USAGE "usage" - -#define KVTML_CURRENT "current" - -#define KVTML_ENTRIES "entries" -#define KVTML_ENTRY "entry" -#define KVTML_DEACTIVATED "deactivated" - -#define KVTML_TRANSLATION "translation" -#define KVTML_TEXT "text" -#define KVTML_PRONUNCIATION "pronunciation" - -#define KVTML_PAIR "pair" -#define KVTML_FALSEFRIEND "falsefriend" -#define KVTML_ANTONYM "antonym" -#define KVTML_SYNONYM "synonym" - -#define KVTML_EXAMPLE "example" -#define KVTML_PARAPHRASE "paraphrase" - -#define KVTML_COMPARISON "comparison" -#define KVTML_ABSOLUTE "absolute" -#define KVTML_COMPARATIVE "comparative" -#define KVTML_SUPERLATIVE "superlative" - -#define KVTML_MULTIPLECHOICE "multiplechoice" -#define KVTML_CHOICE "choice" - -#define KVTML_IMAGE "image" -#define KVTML_SOUND "sound" - -#define KVTML_GRADE "grade" -#define KVTML_FROMID "fromid" -#define KVTML_CURRENTGRADE "currentgrade" -#define KVTML_COUNT "count" -#define KVTML_ERRORCOUNT "errorcount" -#define KVTML_DATE "date" - -#define KVTML_TRUE "true" -#define KVTML_FALSE "false" - -#endif - diff --git a/keduvocdocument/kvtml2todo b/keduvocdocument/kvtml2todo deleted file mode 100644 index 990b3aa..0000000 --- a/keduvocdocument/kvtml2todo +++ /dev/null @@ -1,8 +0,0 @@ -todo for kvtml2 - -reader: - store identifier name, sizehint and type? (need a place to store it first) - -extra classes: - lesson class - diff --git a/keduvocdocument/kvtml_empty_sample.kvtml b/keduvocdocument/kvtml_empty_sample.kvtml deleted file mode 100644 index 2267d7c..0000000 --- a/keduvocdocument/kvtml_empty_sample.kvtml +++ /dev/null @@ -1,142 +0,0 @@ - - - - - - - - - - - - - - language - en - - - 250 - -
- - der - die - das - - - ein - eine - ein - -
- - - ich - du - - er - sie - es - - - - wir - ihr - - sie - - - -
-
- - - - grammar type a - grammer type b - - - Special tense - - - - slang usage - professional usage - - - - - true to deactivate an entry (won't be queried) - true - 25 - - Kniebeugen - - - - - - - - - - - 1 - regular - - ich - du - - er - sie - es - - - - wir - ihr - - sie - - - - - gut - besser - am besten - - - - - - - - - - 1 - 1 - 1 - 949757271 - - - - genuflect - - 0.8 - 6 - 1 - 949757271 - - - - - - - Lesson with grades example - true - true - 0 - - -
- diff --git a/keduvocdocument/kvtmldefs.h b/keduvocdocument/kvtmldefs.h deleted file mode 100644 index 0b2237f..0000000 --- a/keduvocdocument/kvtmldefs.h +++ /dev/null @@ -1,221 +0,0 @@ -/*************************************************************************** - Vocabulary Document for KDE Edu - ----------------------------------------------------------------------- - copyright : (C) 1999-2001 Ewald Arnold - - (C) 2005, 2007 Peter Hedlund - (C) 2007 Frederik Gladhorn - ***************************************************************************/ - -/*************************************************************************** - * * - * 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. * - * * - ***************************************************************************/ - -#ifndef KVTMLDEFS_H -#define KVTMLDEFS_H - - - -/** XML tags and attribute names */ - -static const QLatin1String KV_DOCTYPE( "kvtml" ); // doctype -#define KV_TITLE "title" // doc title -#define KV_AUTHOR "author" // doc author -#define KV_LICENSE "license" // doc license -#define KV_DOC_REM "remark" // doc remark -#define KV_LINES "lines" // entries -#define KV_GENERATOR "generator" // who generated the doc -#define KV_COLS "cols" // columns -#define KV_ENCODING "encoding" // document encoding (obsolete!) - -#define KV_EXPR "e" // entry for one expression -static const QLatin1String KV_ORG( "o" ); // original expression in specified language -static const QLatin1String KV_TRANS( "t" ); // translated expression in specified language -#define KV_LANG "l" // language: en, de, it, fr ... -#define KV_QUERY "q" // query: org or translation -#define KV_O "o" // org -#define KV_T "t" // translation -#define KV_GRADE "g" // grade of knowledge: 0=well known, x=not known for x times -#define KV_LESS_MEMBER "m" // member of lesson 1 .. x -#define KV_COUNT "c" // number of times queried -#define KV_SIZEHINT "width" // recommended column width -#define KV_CHARSET "charset" // recommended charset (obsolete!) -#define KV_BAD "b" // number of times failed -#define KV_DATE "d" // last query date -#define KV_DATE2 "w" // last query date, compressed format, deprecated, currently ignored -#define KV_REMARK "r" // remark for this entry -#define KV_FAUX_AMI_F "ff" // false friend of this entry from org -#define KV_FAUX_AMI_T "tf" // false friend of this entry to org -#define KV_SYNONYM "y" // synonym (same meaning) of expr -#define KV_ANTONYM "a" // antonym (oppositite) of expr -#define KV_PRONUNCE "p" // how to pronounce this expression -#define KV_SELECTED "s" // entry selected for queries -#define KV_INACTIVE "i" // entry inactive (for queries) -#define KV_EXPRTYPE "t" // type of expression -#define KV_EXAMPLE "x" // example string with word -#define KV_USAGE "u" // usage label -#define KV_PARAPHRASE "h" // paraphrase for expression - -/* - - My type 1 - My type 2 - -*/ - -#define KV_TYPE_GRP "type" // type descriptor group -#define KV_TYPE_DESC "desc" // type descriptor -#define KV_TYPE_NO "no" // type descriptor number - -/* - - My usage 1 - My usage 2 - -*/ - -#define KV_USAGE_GRP "usage" // usage descriptor group -#define KV_USAGE_DESC "desc" // usage descriptor -#define KV_USAGE_NO "no" // usage descriptor number - -/* - - Lesson #1 - Lesson #2 - -*/ - -#define KV_LESS_GRP "lesson" // lesson descriptor group -#define KV_LESS_CURR "current" // is current lesson -#define KV_LESS_DESC "desc" // lesson descriptor -#define KV_LESS_QUERY "query" // lesson contained in query -#define KV_LESS_NO "no" // lesson descriptor number - -/* - - user tense #1 - user tense #2 - -*/ - -#define KV_TENSE_GRP "tense" // tense descriptor group -#define KV_TENSE_DESC "desc" // tense descriptor -#define KV_TENSE_NO "no" // tense descriptor number - -/* - - - -*/ - -#define KV_OPTION_GRP "options" // internal options group -#define KV_OPT_SORT "sort" // allow sorting -#define KV_BOOL_FLAG "on" // general boolean flag - -/* -
- lang determines also lang order in entries !! - eine which must NOT differ - die - ein - der - ein - das - -
-*/ - -#define KV_ARTICLE_GRP "article" // article descriptor group -static const QLatin1String KV_ART_ENTRY( "e" ); // article entry -#define KV_ART_FD "fd" // female definite -#define KV_ART_MD "md" // male definite -#define KV_ART_ND "nd" // natural definite -#define KV_ART_FI "fi" // female indefinite -#define KV_ART_MI "mi" // male indefinite -#define KV_ART_NI "ni" // natural indefinite - -/* - - good - better - best - -*/ - -#define KV_COMPARISON_GRP "comparison" // comparison descriptor group -#define KV_COMP_L1 "l1" // base form -#define KV_COMP_L2 "l2" // next form -#define KV_COMP_L3 "l3" // last form - -/* - - good - better - best - best 2 - best 3 - -*/ - -#define KV_MULTIPLECHOICE_GRP "multiplechoice" // multiple choice descriptor group -#define KV_MC_1 "mc1" // choice 1 -#define KV_MC_2 "mc2" // choice 2 -#define KV_MC_3 "mc3" // choice 3 -#define KV_MC_4 "mc4" // choice 4 -#define KV_MC_5 "mc5" // choice 5 - -/* - used in header for definiton of "prefix" - lang determines also lang order in entries !! - I which must NOT differ in subsequent -tags - you<2> - he - she - it - we - you - they - they - they - - - - and in entry for definition of tenses of (irreg.) verbs - - go - go - goes - goes - goes - go - go - go - go - go - - -*/ - -#define KV_CONJUG_GRP "conjugation" // conjugation descriptor group -#define KV_CON_ENTRY "e" // conjugation entry (header) -#define KV_CON_TYPE "t" // conjugation type (voc entries) -#define KV_CON_NAME "n" // conjugation type name (voc entries) -#define KV_CON_P1S "s1" // 1. person singular -#define KV_CON_P2S "s2" // 2. person singular -#define KV_CON_P3SF "s3f" // 3. person singular female -#define KV_CON_P3SM "s3m" // 3. person singular male -#define KV_CON_P3SN "s3n" // 3. person singular natural -#define KV_CON_P1P "p1" // 1. person plural -#define KV_CON_P2P "p2" // 2. person plural -#define KV_CON_P3PF "p3f" // 3. person plural female -#define KV_CON_P3PM "p3m" // 3. person plural male -#define KV_CON_P3PN "p3n" // 3. person plural natural -#define KV_CONJ_COMMON "common" // female contains common for all three - - -#endif // KVTMLDEFS_H diff --git a/keduvocdocument/libkeduvocdocument_export.h b/keduvocdocument/libkeduvocdocument_export.h deleted file mode 100644 index c5675d8..0000000 --- a/keduvocdocument/libkeduvocdocument_export.h +++ /dev/null @@ -1,40 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2007 David Faure - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#ifndef LIBKEDUVOCDOCUMENT_EXPORT_H -#define LIBKEDUVOCDOCUMENT_EXPORT_H - -/* needed for KDE_EXPORT and KDE_IMPORT macros */ -#include - -#ifndef KEDUVOCDOCUMENT_EXPORT -# if defined(MAKE_KEDUVOCDOCUMENT_LIB) -/* We are building this library */ -# define KEDUVOCDOCUMENT_EXPORT KDE_EXPORT -# else -/* We are using this library */ -# define KEDUVOCDOCUMENT_EXPORT KDE_IMPORT -# endif -#endif - -# ifndef KEDUVOCDOCUMENT_EXPORT_DEPRECATED -# define KEDUVOCDOCUMENT_EXPORT_DEPRECATED KDE_DEPRECATED KEDUVOCDOCUMENT_EXPORT -# endif - -#endif diff --git a/keduvocdocument/sharedkvtmlfiles.cpp b/keduvocdocument/sharedkvtmlfiles.cpp deleted file mode 100644 index 2a2dfd6..0000000 --- a/keduvocdocument/sharedkvtmlfiles.cpp +++ /dev/null @@ -1,199 +0,0 @@ -/*************************************************************************** - scan a group of KVTML documents to get information from them - ----------------------------------------------------------------------- - copyright : (C) 2007 Jeremy Whiting - ***************************************************************************/ - -/*************************************************************************** - * * - * 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. * - * * - ***************************************************************************/ - -#include "sharedkvtmlfiles.h" - -#include "keduvocdocument.h" - -#include -#include -#include -#include - -#include -#include -#include - -#include - -class SharedKvtmlFilesPrivate -{ -public: - /** default constructor calls rescan*/ - SharedKvtmlFilesPrivate() - { - rescan(); - } - - /** default destructor */ - ~SharedKvtmlFilesPrivate() - {} - - /** scan the folder for documents, and record what is found */ - void rescan(); - - /** list of all files found */ - QStringList m_fileList; - - /** list of all files titles found */ - QStringList m_titleList; - - /** list of file comments */ - QStringList m_commentList; - - /** map of files by language key */ - QMap m_filesByLang; -}; - -K_GLOBAL_STATIC( SharedKvtmlFilesPrivate, sharedKvtmlFilesPrivate ) - -void SharedKvtmlFilesPrivate::rescan() -{ - this->m_titleList.clear(); - this->m_commentList.clear(); - this->m_filesByLang.clear(); - this->m_fileList.clear(); - - QStringList locales; - - QStringList dataPaths = KGlobal::dirs()->findDirs( "data", "kvtml/" ); - for ( int i = 0; i < dataPaths.size(); ++i ) { - locales += QDir( dataPaths[i] ).entryList( QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name ); - } - - // remove duplicates - locales = locales.toSet().toList(); - - for ( int i = 0; i < locales.size(); ++i ) { - // get all files for this language - QStringList thisLangFiles = KGlobal::dirs()->findAllResources( "data", - QString( "kvtml/%1/*.kvtml" ).arg( QDir( locales[i] ).dirName() ) ); - // add them to the big list - this->m_fileList << thisLangFiles; - - // then add them to their respective language maps - for ( int j = 0; j < thisLangFiles.size(); ++j ) { - this->m_filesByLang[locales[i]].append( thisLangFiles[j] ); - } - } - - KEduVocDocument *doc = new KEduVocDocument(); - for ( int i = 0; i < this->m_fileList.size(); ++i ) { - - // open the file - doc->open( KUrl::fromPath( this->m_fileList[i] ) ); - - // add it's title to the title list - this->m_titleList.append( doc->title() ); - - // add it's comment to the comment list - this->m_commentList.append( doc->documentComment() ); - } - delete doc; -} - -void SharedKvtmlFiles::rescan() -{ - sharedKvtmlFilesPrivate->rescan(); -} - -QStringList SharedKvtmlFiles::languages() -{ - return sharedKvtmlFilesPrivate->m_filesByLang.keys(); -} - -QStringList SharedKvtmlFiles::fileNames( const QString &language ) -{ - // return files by language for given language if it's not empty - // otherwise return all filenames - return language.isEmpty() ? sharedKvtmlFilesPrivate->m_fileList : sharedKvtmlFilesPrivate->m_filesByLang.value( language ); -} - -QStringList SharedKvtmlFiles::titles( const QString &language ) -{ - QStringList retlist; - - if ( language.isEmpty() ) { - retlist = sharedKvtmlFilesPrivate->m_titleList; - } else { - QStringList filenames = sharedKvtmlFilesPrivate->m_filesByLang.value( language ); - for ( int i = 0; i < filenames.size(); ++i ) { - retlist.append( sharedKvtmlFilesPrivate->m_titleList[sharedKvtmlFilesPrivate->m_fileList.indexOf( filenames[i] )] ); - } - } - - return retlist; -} - -QStringList SharedKvtmlFiles::comments( const QString &language ) -{ - QStringList retlist; - - if ( language.isEmpty() ) { - retlist = sharedKvtmlFilesPrivate->m_commentList; - } else { - QStringList filenames = sharedKvtmlFilesPrivate->m_filesByLang.value( language ); - for ( int i = 0; i < filenames.size(); ++i ) { - retlist.append( sharedKvtmlFilesPrivate->m_commentList[sharedKvtmlFilesPrivate->m_fileList.indexOf( filenames[i] )] ); - } - } - - return retlist; -} - -void SharedKvtmlFiles::sortDownloadedFiles() -{ - QStringList unsortedFiles = KGlobal::dirs()->findAllResources( "data", - QString( "kvtml/*.kvtml" ) ); - - KEduVocDocument doc; - - while ( !unsortedFiles.isEmpty() ) { - KUrl fileUrl( KUrl::fromPath( unsortedFiles.first() ) ); - // find the file's locale - // open the file - doc.open( fileUrl ); - - if (doc.identifierCount() == 1) { - QString locale = doc.identifier( 0 ).locale(); - - // make sure the locale sub-folder exists - KUrl pathUrl( fileUrl ); - pathUrl.setFileName( QString() ); - pathUrl.addPath( locale ); - KIO::mkdir( pathUrl ); - - // move the file into the locale sub-folder - KIO::move( fileUrl, pathUrl ); - } - - // take off the one we just did - unsortedFiles.removeFirst(); - } - - QStringList khangmanFiles = KGlobal::dirs()->findAllResources( "data", - QString( "kvtml/*.txt" ) ); - - // move khangman files into - while ( !khangmanFiles.isEmpty() ) { - KUrl fileUrl( KUrl::fromPath( khangmanFiles.first() ) ); - KUrl destDir = KUrl::fromPath(KStandardDirs::locateLocal("appdata", "khangman/data/")); - // do this better with KStandardDirs stuff - KIO::move( fileUrl, destDir); - khangmanFiles.removeFirst(); - } - - rescan(); -} diff --git a/keduvocdocument/sharedkvtmlfiles.h b/keduvocdocument/sharedkvtmlfiles.h deleted file mode 100644 index 2acc6ba..0000000 --- a/keduvocdocument/sharedkvtmlfiles.h +++ /dev/null @@ -1,60 +0,0 @@ -/*************************************************************************** - scan a group of KVTML documents to get information from them - ----------------------------------------------------------------------- - copyright : (C) 2007 Jeremy Whiting - ***************************************************************************/ - -/*************************************************************************** - * * - * 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. * - * * - ***************************************************************************/ - -#ifndef SHAREDKVTMLFILES_H -#define SHAREDKVTMLFILES_H - -#include "libkeduvocdocument_export.h" - -#include - -/** - *namespace and singleton class to scan groups of kvtml files - *from shared kvtml location, and give information - *about files found there - *@author Jeremy Whiting - */ -namespace SharedKvtmlFiles -{ - /** get list of all languages found in any files */ - KEDUVOCDOCUMENT_EXPORT QStringList languages(); - - /** get list of filenames found of given language - *@param language language requested QString() for all languages - *@return a list of filenames with words in language - */ - KEDUVOCDOCUMENT_EXPORT QStringList fileNames( const QString &language = QString() ); - - /** get the list of document titles found of a given language - *@param language requested language QString() for all titles - *@return a list of document titles with words in language - */ - KEDUVOCDOCUMENT_EXPORT QStringList titles( const QString &language = QString() ); - - /** get the list of document remarts found of a given language - *@param language requested language QString() for all comments - *@return a list of document remarks with words in language - */ - KEDUVOCDOCUMENT_EXPORT QStringList comments( const QString &language = QString() ); - - /** rescan the shared kvtml locations */ - KEDUVOCDOCUMENT_EXPORT void rescan(); - - /** sort files downloaded to kvtml top-level dir into locale sub-folders */ - KEDUVOCDOCUMENT_EXPORT void sortDownloadedFiles(); -} - -#endif - diff --git a/keduvocdocument/tests/CMakeLists.txt b/keduvocdocument/tests/CMakeLists.txt deleted file mode 100644 index da4064f..0000000 --- a/keduvocdocument/tests/CMakeLists.txt +++ /dev/null @@ -1,28 +0,0 @@ -set( EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR} ) - - -kde4_add_unit_test(keduvocdocumentvalidatortest keduvocdocumentvalidatortest.cpp) -target_link_libraries(keduvocdocumentvalidatortest keduvocdocument - ${KDE4_KDECORE_LIBS} ${QT_QTGUI_LIBRARY} ${QT_QTTEST_LIBRARY} ${QT_QTXML_LIBRARY}) - - -# CONVERTER: - - -include_directories( ${CMAKE_SOURCE_DIR}/libkdeedu/keduvocdocument/ ) - - -########### next target ############### - -set(converter_SRCS - converter.cpp ) - - -kde4_add_executable(converter ${converter_SRCS}) - -target_link_libraries(converter keduvocdocument ${KDE4_KDECORE_LIBS}) - - - - - diff --git a/keduvocdocument/tests/converter.cpp b/keduvocdocument/tests/converter.cpp deleted file mode 100644 index d7730fd..0000000 --- a/keduvocdocument/tests/converter.cpp +++ /dev/null @@ -1,81 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2007 by Jeremy Whiting * - * * - * 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. * - ***************************************************************************/ - -/** @file - * \brief kvtml document reader/writer - * partly to test the document class, partly to convert - * old kvtml files to the new format - * @author Jeremy Whiting - */ - -#include "keduvocdocument.h" - -#include - -#include -#include -#include -#include -#include - -int main( int argc, char ** argv ) -{ - KAboutData about( "kvtml-converter", 0, ki18n( "Kvtml-Converter" ), "0.1", ki18n( "kvtml file converter" ), KAboutData::License_GPL, ki18n( "© 2007 Jeremy Whiting" ) ); - KCmdLineOptions options; - options.add( "f ", ki18n("file format to write out (kvtml1, kvtml2, or csv)")); - options.add( "+infile", ki18n( "file to read in" ) ); - options.add( "+outfile", ki18n( "file to write to" ) ); - - KCmdLineArgs::init( argc, argv, &about ); - KCmdLineArgs::addCmdLineOptions( options ); - QCoreApplication app( KCmdLineArgs::qtArgc(), KCmdLineArgs::qtArgv() ); - - KCmdLineArgs * arguments = KCmdLineArgs::parsedArgs(); - if ( arguments != NULL && arguments->count() > 0 ) { - KUrl infile( arguments->url( 0 ) ); - if ( arguments->count() > 1 ) { - KUrl outfile( arguments->url( 1 ) ); - - KEduVocDocument document; - kDebug() << "Reading " << infile; - document.open( infile ); - kDebug() << "Writing to " << outfile; - if (arguments->getOption("f") == "kvtml1") - { - document.saveAs( outfile, KEduVocDocument::Kvtml1, "converter" ); - } - else if (arguments->getOption("f") == "csv") - { - document.saveAs( outfile, KEduVocDocument::Csv, "converter" ); - } - else - { - document.saveAs( outfile, KEduVocDocument::Kvtml, "converter" ); - } - } - } - else - { - arguments->usage(); - } - - arguments->clear(); - - return 0; -} diff --git a/keduvocdocument/tests/keduvocdocumentvalidatortest.cpp b/keduvocdocument/tests/keduvocdocumentvalidatortest.cpp deleted file mode 100644 index acf3f78..0000000 --- a/keduvocdocument/tests/keduvocdocumentvalidatortest.cpp +++ /dev/null @@ -1,252 +0,0 @@ -/* - Copyright 2007-2008 Frederik Gladhorn - - 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 "keduvocdocument.h" -#include "keduvoclesson.h" -#include "keduvocexpression.h" -#include "keduvoctranslation.h" -#include "keduvocconjugation.h" -#include "keduvocdeclension.h" -#include "keduvocwordtype.h" - - -#include - -#include - -#include -#include -#include - -class KEduVocDocumentValidatorTest - : public QObject -{ - Q_OBJECT - -private slots: - void testDocumentAboutInfo(); - void testLessons(); - void testWordTypes(); - void testTranslations(); - void testConjugations(); - void testDeclensions(); - void testAddRemoveLanguage(); - -}; - -void KEduVocDocumentValidatorTest::testDocumentAboutInfo() -{ - KTemporaryFile temp; - temp.setSuffix(".kvtml"); - temp.open(); - KUrl fileName = KUrl(temp.fileName()); - temp.close(); - - const QString generator = QString::fromLatin1( "Validator Unit Tests" ); - const QString author = QString::fromLatin1( "Validator Test" ); - const QString license = QString::fromLatin1( "test license" ); - const QString comment = QString::fromLatin1( "comment" ); - const QString category = QString::fromLatin1( "test document" ); - const QString title = QString::fromLatin1( "Validator Test Title" ); - - KEduVocDocument doc; - doc.setAuthor( author ); - doc.setLicense( license ); - doc.setDocumentComment( comment ); - doc.setCategory( category ); - doc.setTitle( title ); - - doc.saveAs(fileName, KEduVocDocument::Kvtml, generator); - - KEduVocDocument docRead; - docRead.open(fileName); - - QCOMPARE( docRead.generator(), generator ); - QCOMPARE( docRead.author(), author ); - QCOMPARE( docRead.license(), license ); - QCOMPARE( docRead.documentComment(), comment ); - QCOMPARE( docRead.category(), category ); - QCOMPARE( docRead.title(), title ); -} - -void KEduVocDocumentValidatorTest::testLessons() -{ - QString lesson1 = QString::fromLatin1( "Lesson 1" ); - QString lesson1child1 = QString::fromLatin1( "Lesson 1.1" ); - QString lesson1child2 = QString::fromLatin1( "Lesson 1.2" ); - QString lesson2 = QString::fromLatin1( "Lesson 2" ); - QString lesson3 = QString::fromLatin1( "Lesson 3" ); - - KEduVocDocument doc; - doc.lesson()->appendChildContainer(new KEduVocLesson(lesson1, doc.lesson())); - QCOMPARE(doc.lesson()->childContainerCount(), 1); - QCOMPARE(doc.lesson()->childContainer(0)->containerType(), KEduVocContainer::Lesson); - QCOMPARE(doc.lesson()->childContainer(0)->parent(), doc.lesson()); - QCOMPARE(doc.lesson()->childContainer(0)->name(), lesson1); - - doc.lesson()->appendChildContainer(new KEduVocLesson(lesson2, doc.lesson())); - doc.lesson()->appendChildContainer(new KEduVocLesson(lesson3, doc.lesson())); - QCOMPARE(doc.lesson()->childContainerCount(), 3); - - doc.lesson()->childContainer(0)->appendChildContainer(new KEduVocLesson(lesson1child1, doc.lesson()->childContainer(0))); - doc.lesson()->childContainer(0)->appendChildContainer(new KEduVocLesson(lesson1child2, doc.lesson()->childContainer(0))); - QCOMPARE(doc.lesson()->childContainer(0)->childContainerCount(), 2); - - -} - - -void KEduVocDocumentValidatorTest::testWordTypes() -{ - KEduVocDocument doc; - // create doc - has no word types yet - QCOMPARE(doc.wordTypeContainer()->childContainerCount(), 0); - - KEduVocWordType *noun; - KEduVocWordType *nounMale; - KEduVocWordType *nounFemale; - KEduVocWordType *verb; - - noun = new KEduVocWordType("Noun", doc.wordTypeContainer()); - doc.wordTypeContainer()->appendChildContainer(noun); - QCOMPARE(doc.wordTypeContainer()->childContainerCount(), 1); - nounMale = new KEduVocWordType("Male", noun); - noun->appendChildContainer(nounMale); - nounFemale = new KEduVocWordType("Female", noun); - noun->appendChildContainer(nounFemale); - verb = new KEduVocWordType("Verb", doc.wordTypeContainer()); - doc.wordTypeContainer()->appendChildContainer(verb); - QCOMPARE(doc.wordTypeContainer()->childContainerCount(), 2); - QCOMPARE(doc.wordTypeContainer()->childContainer(0)->childContainerCount(), 2); - - // create some entries - for(int i = 0; i < 20; i++) { - KEduVocExpression *e = - new KEduVocExpression(QStringList() << QString("lang1 %1").arg(i) << QString("lang2 %1").arg(i)); - doc.lesson()->appendEntry(e); - e->translation(0)->setWordType(noun); - e->translation(1)->setWordType(noun); - } - QCOMPARE(doc.lesson()->entryCount(), 20); - QCOMPARE(noun->entryCount(), 20); - doc.lesson()->entry(0)->translation(0)->setWordType(verb); - // translation 1 is still noun, so it needs to be in both now - QCOMPARE(noun->entryCount(), 20); - QCOMPARE(verb->entryCount(), 1); - doc.lesson()->entry(0)->translation(1)->setWordType(verb); - QCOMPARE(noun->entryCount(), 19); - QCOMPARE(verb->entryCount(), 1); - - // delete word type - doc.wordTypeContainer()->deleteChildContainer(1); - // the word type is set to 0 when removed - QVERIFY(doc.lesson()->entry(0)->translation(0)->wordType() == 0); - QVERIFY(doc.lesson()->entry(0)->translation(1)->wordType() == 0); - QCOMPARE(doc.wordTypeContainer()->childContainerCount(), 1); -} - -void KEduVocDocumentValidatorTest::testTranslations() -{ - KEduVocTranslation *trans1 = new KEduVocTranslation(0, QString("My word")); - QCOMPARE(trans1->text(), QString("My word")); - - // copy ctor - KEduVocTranslation *trans2 = new KEduVocTranslation(*trans1); - QCOMPARE(trans2->text(), QString("My word")); - - // operator = - KEduVocTranslation *trans3 = new KEduVocTranslation(0); - trans3 = new KEduVocTranslation(*trans1); - QCOMPARE(trans3->text(), QString("My word")); - - QCOMPARE((int)trans1->grade(), 0); - trans1->incGrade(); - QCOMPARE((int)trans1->grade(), 1); - QCOMPARE((int)trans3->grade(), 0); -} - -void KEduVocDocumentValidatorTest::testDeclensions() -{ - KEduVocTranslation translation(0); - QVERIFY(translation.declension() == 0); - KEduVocDeclension* declension = new KEduVocDeclension; - translation.setDeclension(declension); - QCOMPARE(translation.declension(), declension); -} - -void KEduVocDocumentValidatorTest::testConjugations() -{ - KEduVocConjugation conjugation; - conjugation.setConjugation(KEduVocText("first-singular"), KEduVocWordFlag::First | KEduVocWordFlag::Singular); - QCOMPARE(conjugation.conjugation(KEduVocWordFlag::First | KEduVocWordFlag::Singular).text(), QString("first-singular")); - - QDomDocument doc = QDomDocument("test doc"); - QDomElement root = doc.createElement( "kvtml" ); - doc.appendChild(root); - conjugation.toKVTML2(root, "tense"); - - qDebug() << root.text(); - - KEduVocConjugation *con2 = KEduVocConjugation::fromKVTML2(root); - - QCOMPARE(conjugation.conjugation(KEduVocWordFlag::First | KEduVocWordFlag::Singular).text(), con2->conjugation(KEduVocWordFlag::First | KEduVocWordFlag::Singular).text()); - delete con2; -} - -void KEduVocDocumentValidatorTest::testAddRemoveLanguage() -{ - KEduVocDocument doc; - // create some initial languages - doc.appendIdentifier(); - doc.appendIdentifier(); - doc.appendIdentifier(); - doc.appendIdentifier(); - doc.identifier(0).setName("0"); - doc.identifier(1).setName("1"); - doc.identifier(2).setName("2"); - doc.identifier(3).setName("3"); - - QCOMPARE(doc.identifierCount(), 4); - KEduVocLesson* lesson = new KEduVocLesson("lesson", doc.lesson()); - doc.lesson()->appendChildContainer(lesson); - lesson->appendEntry(new KEduVocExpression); - lesson->entry(0)->setTranslation(0, "0"); - lesson->entry(0)->setTranslation(1, "1"); - lesson->entry(0)->setTranslation(2, "2"); - lesson->entry(0)->setTranslation(3, "3"); - QCOMPARE(lesson->entry(0)->translationIndices().size(), 4); - - // throw away the second language - doc.removeIdentifier(1); - - QCOMPARE(doc.identifierCount(), 3); - QCOMPARE(doc.identifier(0).name(), QString("0")); - QCOMPARE(doc.identifier(1).name(), QString("2")); - QCOMPARE(doc.identifier(2).name(), QString("3")); - - QCOMPARE(lesson->entry(0)->translationIndices().size(), 3); - QCOMPARE(lesson->entry(0)->translation(0)->text(), QString("0")); - QCOMPARE(lesson->entry(0)->translation(1)->text(), QString("2")); - QCOMPARE(lesson->entry(0)->translation(2)->text(), QString("3")); -} - - -QTEST_KDEMAIN_CORE( KEduVocDocumentValidatorTest ) - -#include "keduvocdocumentvalidatortest.moc" diff --git a/keduvocdocument/tests/loader.cpp b/keduvocdocument/tests/loader.cpp deleted file mode 100644 index 4f18664..0000000 --- a/keduvocdocument/tests/loader.cpp +++ /dev/null @@ -1,18 +0,0 @@ -/*************************************************************************** - Copyright 2002 Ewald Arnold - Copyright 2007 Frederik Gladhorn - ***************************************************************************/ - -/*************************************************************************** - * * - * 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. * - * * - ***************************************************************************/ - -int main( void ) -{ - return 0; -} diff --git a/libscience/CMakeLists.txt b/libscience/CMakeLists.txt old mode 100644 new mode 100755 diff --git a/libscience/chemicaldataobject.cpp b/libscience/chemicaldataobject.cpp old mode 100644 new mode 100755 diff --git a/libscience/chemicaldataobject.h b/libscience/chemicaldataobject.h old mode 100644 new mode 100755 diff --git a/libscience/data/CMakeLists.txt b/libscience/data/CMakeLists.txt old mode 100644 new mode 100755 index 1714bd3..f2ae647 --- a/libscience/data/CMakeLists.txt +++ b/libscience/data/CMakeLists.txt @@ -2,6 +2,7 @@ install(FILES elements.xml isotopes.xml + symbols.csv spectra.xml DESTINATION ${DATA_INSTALL_DIR}/libkdeedu/data/ ) diff --git a/libscience/data/isotopes.xml b/libscience/data/isotopes.xml old mode 100644 new mode 100755 diff --git a/libscience/data/spectra.xml b/libscience/data/spectra.xml old mode 100644 new mode 100755 diff --git a/libscience/data/symbols.csv b/libscience/data/symbols.csv new file mode 100644 index 0000000..3afa27d --- /dev/null +++ b/libscience/data/symbols.csv @@ -0,0 +1,2 @@ +"Et","C2H5" +"Me","CH3" diff --git a/libscience/element.cpp b/libscience/element.cpp old mode 100644 new mode 100755 diff --git a/libscience/element.h b/libscience/element.h old mode 100644 new mode 100755 diff --git a/libscience/elementparser.cpp b/libscience/elementparser.cpp old mode 100644 new mode 100755 diff --git a/libscience/elementparser.h b/libscience/elementparser.h old mode 100644 new mode 100755 diff --git a/libscience/isotope.cpp b/libscience/isotope.cpp old mode 100644 new mode 100755 diff --git a/libscience/isotope.h b/libscience/isotope.h old mode 100644 new mode 100755 diff --git a/libscience/isotopeparser.cpp b/libscience/isotopeparser.cpp old mode 100644 new mode 100755 diff --git a/libscience/isotopeparser.h b/libscience/isotopeparser.h old mode 100644 new mode 100755 diff --git a/libscience/libkdeedu_science_export.h b/libscience/libkdeedu_science_export.h old mode 100644 new mode 100755 diff --git a/libscience/moleculeparser.cpp b/libscience/moleculeparser.cpp index 9057be2..9f29814 100644 --- a/libscience/moleculeparser.cpp +++ b/libscience/moleculeparser.cpp @@ -15,7 +15,9 @@ #include +#include #include +#include // ================================================================ // class ElementCountMap @@ -122,18 +124,25 @@ MoleculeParser::~MoleculeParser() // This method also acts as the main loop. bool -MoleculeParser::weight(const QString& _moleculeString, +MoleculeParser::weight(const QString& _shortMoleculeString, double *_resultMass, ElementCountMap *_resultMap) { - if ( _moleculeString.isEmpty() ) + if ( _shortMoleculeString.isEmpty() ) return false; - + QString _moleculeString; // Clear the result variables and set m_error to false _resultMap->clear(); m_error = false; *_resultMass = 0.0; - + + // Expand the molecule string + // Example : MeOH -> (CH3)OH + kDebug() << _shortMoleculeString << "is going to be expanded"; + _moleculeString = expandFormula(_shortMoleculeString); + kDebug() << _moleculeString << "is the expanded string"; + + // Now set the expanded string // Initialize the parsing process, and parse te molecule. start(_moleculeString); parseSubmolecule(_resultMass, _resultMap); @@ -143,7 +152,7 @@ MoleculeParser::weight(const QString& _moleculeString, if ( m_error )//there was an error in the input... return false; - + return true; } @@ -243,7 +252,7 @@ MoleculeParser::parseTerm(double *_resultMass, int MoleculeParser::getNextToken() { - QString elementName; + QString name; #if 0 kDebug() << "getNextToken(): Next character = " @@ -252,25 +261,25 @@ MoleculeParser::getNextToken() // Check if the token is an element name. if ('A' <= nextChar() && nextChar() <= 'Z') { - elementName = char(nextChar()); - getNextChar(); + name = char(nextChar()); + getNextChar(); - if ('a' <= nextChar() && nextChar() <= 'z') { - elementName.append(char(nextChar())); - getNextChar(); - } + if ('a' <= nextChar() && nextChar() <= 'z') { + name.append(char(nextChar())); + getNextChar(); + } - // Look up the element from the name.. - m_elementVal = lookupElement(elementName); - if (m_elementVal) - { - m_nextToken = ELEMENT_TOKEN; - } - else - m_nextToken = -1; + // Look up the element from the name.. + m_elementVal = lookupElement(name); + if (m_elementVal) + { + m_nextToken = ELEMENT_TOKEN; + } + else + m_nextToken = -1; } else - return Parser::getNextToken(); + return Parser::getNextToken(); return m_nextToken; } @@ -295,7 +304,143 @@ MoleculeParser::lookupElement( const QString& _name ) //if there is an error make m_error true. m_error = true; - kDebug() << "no such element, parsing error!: " << _name; + kDebug() << "no such element!: " << _name; return NULL; } + +QString +MoleculeParser::expandFormula( const QString& _shortString) +{ + QString _fullString = ""; // The expanded string that will be returned + QString::iterator i; // iterator + QString temp; // A temporary string that will contain a single element/group + QString expandedTerm; // expansion of a particular term. + + // Go through all letters in the string. + for(i = (const QString::iterator) _shortString.begin(); + i != _shortString.end(); ) + { + temp = ""; + + // If a character was found + if((*i).category() == QChar::Letter_Uppercase) { + temp += (*i); + i++; + + // A small letter following a capital letter + if(i != _shortString.end() && (*i).category() == QChar::Letter_Lowercase) { + temp += (*i); + i++; + } + + // If element is found, return it immediately. + if (lookupElement(temp)) { + _fullString += temp; + } + + // If an expansion was made, return the expansion + else if ((expandedTerm = expandTerm(temp)) != "") { + kDebug() << "expanded" << temp << "to" << expandedTerm; + _fullString += "("+expandedTerm+")"; + } + // invalid term, return it. + else { + _fullString += temp; + } + + } + + // Return parenthesis as and when found + else if (*i == '(') { + _fullString += '('; + i++; + } + else if (*i == ')') { + _fullString += ')'; + i++; + } + // If number was found, return it + else if ((*i).category() == QChar::Number_DecimalDigit) { + _fullString += *i; + i++; + } + else { // invalid character, return it, validation is done again later + _fullString += *i; + } + } + + // Reset all "element not found" errors. + m_error = false; + return _fullString; +} + +QString +MoleculeParser::expandTerm (const QString& _group) +{ + + QString shortForm, fullForm; // short form (symbol) and full form (expansion) + QString temp; // A temporary QString used in Regular expressions + + // Search in User defined aliases. + QString fileName = KStandardDirs::locate( "data", "libkdeedu/data/symbols.csv"); + QFile file(fileName); + + // Check file validity + if (!(!file.open(QIODevice::ReadOnly | QIODevice::Text))) + { + kDebug() << fileName << " opened"; + QTextStream in(&file); + + // Get all shortForms and fullForms in the file. + while (!in.atEnd()) { + QString line = in.readLine(); + shortForm = line.section(',', 0, 0); + shortForm.remove(QChar('\"')); + fullForm = line.section(',', 1, 1); + fullForm.remove(QChar('\"')); + + // If short term is found, return fullForm + if (shortForm == _group) + return (fullForm); + } + } + + // Find the system defined aliases + // Open the file + QString fileName = KStandardDirs::locate( "data", "libkdeedu/data/symbols.csv"); + QFile file(fileName); + + // Check file validity + if (!(!file.open(QIODevice::ReadOnly | QIODevice::Text))) + { + kDebug() << fileName << " opened"; + QTextStream in(&file); + + // Get all shortForms and fullForms in the file. + while (!in.atEnd()) { + QString line = in.readLine(); + shortForm = line.section(',', 0, 0); + shortForm.remove(QChar('\"')); + fullForm = line.section(',', 1, 1); + fullForm.remove(QChar('\"')); + + if (shortForm == _group) + return (fullForm); + } + } + else + { + kDebug() << fileName << " could not be opened"; + } + + // Sample expansions, work even when file is not found, testing purposes + if (_group == "Me") + return ("CH3"); + else if (_group == "Et") + return ("C2H5"); + + // If not found return an empty string. + else + return (""); +} diff --git a/libscience/moleculeparser.h b/libscience/moleculeparser.h index 829e7ee..2e02964 100644 --- a/libscience/moleculeparser.h +++ b/libscience/moleculeparser.h @@ -164,7 +164,21 @@ class SCIENCE_EXPORT ElementCountMap * cout << "Parse error\n"; * @endcode * + * If a short form of a compound is specified, it will be expanded. + * Example :- EtOH -> (C2H5OH) + * @code + * MoleculeParser parser; + * QString chemical_formula = "EtOH"; + * double weight; + * + * if (parser.weight(chemical_formula, &weight)) + * cout << "Weight of " << chemical_formula << " = " << weight << ".\n"; + * else + * cout << "Parse error\n"; + * @endcode + * * @author Inge Wallin + * @author Kashyap R Puranik */ class SCIENCE_EXPORT MoleculeParser : public Parser { @@ -207,7 +221,13 @@ public: ElementCountMap *_resultMap); bool parseTerm(double *_resultMass, ElementCountMap *_resultMap); - + // This function expands the molecule string + // eg expandFormula(EtOH) returns (C2H5)OH + QString expandFormula(const QString& _shortMolecularMass); + // This function expands a term + // eg expandTerm(Et) returns (C2H5) + QString expandTerm(const QString& _group); + QList m_elementList; static const int ELEMENT_TOKEN = 300; diff --git a/libscience/parser.cpp b/libscience/parser.cpp old mode 100644 new mode 100755 diff --git a/libscience/parser.h b/libscience/parser.h old mode 100644 new mode 100755 diff --git a/libscience/spectrum.cpp b/libscience/spectrum.cpp old mode 100644 new mode 100755 diff --git a/libscience/spectrum.h b/libscience/spectrum.h old mode 100644 new mode 100755 diff --git a/libscience/spectrumparser.cpp b/libscience/spectrumparser.cpp old mode 100644 new mode 100755 diff --git a/libscience/spectrumparser.h b/libscience/spectrumparser.h old mode 100644 new mode 100755 diff --git a/libscience/tempunit.cpp b/libscience/tempunit.cpp old mode 100644 new mode 100755 diff --git a/libscience/tempunit.h b/libscience/tempunit.h old mode 100644 new mode 100755 diff --git a/libscience/tests/CMakeLists.txt b/libscience/tests/CMakeLists.txt old mode 100644 new mode 100755 diff --git a/libscience/tests/isotopereadingtest.cpp b/libscience/tests/isotopereadingtest.cpp old mode 100644 new mode 100755 diff --git a/libscience/tests/spectrumreadingtests.cpp b/libscience/tests/spectrumreadingtests.cpp old mode 100644 new mode 100755 diff --git a/widgets/CMakeLists.txt b/widgets/CMakeLists.txt deleted file mode 100644 index 464ce93..0000000 --- a/widgets/CMakeLists.txt +++ /dev/null @@ -1,18 +0,0 @@ - - -########### next target ############### - -set(kdeeduwidgets_PART_SRCS - ${CMAKE_CURRENT_BINARY_DIR}/kdeeduwidgets.cpp -) - -KDE4_ADD_WIDGET_FILES(${kdeeduwidgets_PART_SRCS} kdeedu.widgets) - -kde4_add_plugin(kdeeduwidgets ${kdeeduwidgets_PART_SRCS}) - - - -target_link_libraries(kdeeduwidgets ${KDE4_KDEUI_LIBS}) - -install(TARGETS kdeeduwidgets DESTINATION ${PLUGIN_INSTALL_DIR}/plugins/designer ) - diff --git a/widgets/kdeedu.widgets b/widgets/kdeedu.widgets deleted file mode 100644 index 2d3b6ce..0000000 --- a/widgets/kdeedu.widgets +++ /dev/null @@ -1,4 +0,0 @@ -[Global] -PluginName=KDEEduWidgets -Includes=kcomponentdata.h -Init=new KComponentData("kdeeduwidgets");