Hello community,

here is the log from the commit of package libkdeedu4 for openSUSE:Factory 
checked in at 2014-07-16 16:19:13
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/libkdeedu4 (Old)
 and      /work/SRC/openSUSE:Factory/.libkdeedu4.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "libkdeedu4"

Changes:
--------
--- /work/SRC/openSUSE:Factory/libkdeedu4/libkdeedu4.changes    2014-06-19 
13:16:00.000000000 +0200
+++ /work/SRC/openSUSE:Factory/.libkdeedu4.new/libkdeedu4.changes       
2014-07-16 16:20:15.000000000 +0200
@@ -1,0 +2,7 @@
+Thu Jul 10 22:20:30 UTC 2014 - [email protected]
+
+- Update to 4.13.80
+   * KDE 4.14 Beta 1 release
+   * See http://www.kde.org/announcements/announce-4.14-beta1.php
+
+-------------------------------------------------------------------

Old:
----
  libkdeedu-4.13.2.tar.xz

New:
----
  libkdeedu-4.13.80.tar.xz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ libkdeedu4.spec ++++++
--- /var/tmp/diff_new_pack.iTzi39/_old  2014-07-16 16:20:16.000000000 +0200
+++ /var/tmp/diff_new_pack.iTzi39/_new  2014-07-16 16:20:16.000000000 +0200
@@ -17,7 +17,7 @@
 
 
 Name:           libkdeedu4
-Version:        4.13.2
+Version:        4.13.80
 Release:        0
 Summary:        Library for KDE Education Applications
 License:        GPL-2.0+

++++++ libkdeedu-4.13.2.tar.xz -> libkdeedu-4.13.80.tar.xz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/libkdeedu-4.13.2/keduvocdocument/keduvoccontainer.cpp 
new/libkdeedu-4.13.80/keduvocdocument/keduvoccontainer.cpp
--- old/libkdeedu-4.13.2/keduvocdocument/keduvoccontainer.cpp   2013-06-13 
01:49:19.000000000 +0200
+++ new/libkdeedu-4.13.80/keduvocdocument/keduvoccontainer.cpp  2014-06-26 
09:32:42.000000000 +0200
@@ -249,13 +249,19 @@
 
 double KEduVocContainer::averageGrade(int translation, EnumEntriesRecursive 
recursive)
 {
-    // grades range from 0..7 right now
-    int sum = 0;
+    int sum = 0,  presum = 0,  count = 0;
     foreach (KEduVocExpression *entry, entries(recursive)) {
-        sum += entry->translation(translation)->grade();
+        KEduVocTranslation & trans( *entry->translation(translation) );
+        if ( !trans.isEmpty() ) {
+            ++count;
+            sum += trans.grade();
+            presum += trans.preGrade();
+        }
     }
     // make that a percentage
-    return (sum * 100.0/7.0)/entryCount(recursive);
+    // There are KV_MAX_GRADE grades from 0 -> 100 %
+    // There are KV_MAX_GRADE preGrades within the first grade.
+    return ((sum * 100.0 / KV_MAX_GRADE) + (presum * 100.0 / (KV_MAX_GRADE * 
KV_MAX_GRADE))) / count;
 }
 
 int KEduVocContainer::expressionsOfGrade(int translation, grade_t grade, 
EnumEntriesRecursive recursive)
@@ -275,4 +281,3 @@
         entry->resetGrades(translation);
     }
 }
-
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libkdeedu-4.13.2/keduvocdocument/keduvocdocument.cpp 
new/libkdeedu-4.13.80/keduvocdocument/keduvocdocument.cpp
--- old/libkdeedu-4.13.2/keduvocdocument/keduvocdocument.cpp    2013-06-13 
01:49:19.000000000 +0200
+++ new/libkdeedu-4.13.80/keduvocdocument/keduvocdocument.cpp   2014-06-26 
09:32:42.000000000 +0200
@@ -28,6 +28,7 @@
 #include <kio/netaccess.h>
 #include <krandomsequence.h>
 #include <kfilterdev.h>
+#include <kautosavefile.h>
 
 #include "keduvocexpression.h"
 #include "keduvoclesson.h"
@@ -59,6 +60,7 @@
         m_lessonContainer = 0;
         m_wordTypeContainer = 0;
         m_leitnerContainer = 0;
+        m_autosave = new KAutoSaveFile;
         init();
     }
 
@@ -68,8 +70,13 @@
 
     KEduVocDocument* q;
 
+    /** autosave file used to provide locking access to the underlying file
+     * Note: It is a pointer to allow locking a new file, saving results and
+     * then transfering the lock to m_autosave without risking loss of lock.
+     * See saveAs for clarification*/
+    KAutoSaveFile            *m_autosave;
+
     bool                      m_dirty;
-    KUrl                      m_url;
 
     // save these to document
     QList<KEduVocIdentifier>  m_identifiers;
@@ -100,6 +107,14 @@
     KEduVocLesson * m_lessonContainer;
     KEduVocWordType * m_wordTypeContainer;
     KEduVocLeitnerBox * m_leitnerContainer;
+
+    /** Creates an autosave file for fpath in order to lock the file
+     *   @param autosave a reference to an allocated KAutosave
+     *   @param fpath File path to the file to be locked
+     *   @param flags Describes how to deal with locked file etc.
+     *   @return ErrorCode where NoError is success
+     *   */
+    KEduVocDocument::ErrorCode initializeKAutoSave(KAutoSaveFile &autosave,  
QString const &fpath,  FileHandlingFlags flags) const;
 };
 
 KEduVocDocument::KEduVocDocumentPrivate::~KEduVocDocumentPrivate()
@@ -107,6 +122,9 @@
     delete m_lessonContainer;
     delete m_wordTypeContainer;
     delete m_leitnerContainer;
+
+    m_autosave->releaseLock();
+    delete m_autosave;
 }
 
 void KEduVocDocument::KEduVocDocumentPrivate::init()
@@ -127,7 +145,7 @@
     m_dirty = false;
     m_queryorg = "";
     m_querytrans = "";
-    m_url.setFileName( i18n( "Untitled" ) );
+    m_autosave->setManagedFile( i18n( "Untitled" ) );
     m_author = "";
     m_title = "";
     m_comment = "";
@@ -140,10 +158,35 @@
 }
 
 
+KEduVocDocument::ErrorCode 
KEduVocDocument::KEduVocDocumentPrivate::initializeKAutoSave(KAutoSaveFile 
&autosave,  QString const & fpath,  FileHandlingFlags flags) const {
+
+    QList<KAutoSaveFile *> staleFiles = KAutoSaveFile::staleFiles( fpath );
+    if ( !staleFiles.isEmpty()) {
+        if ( flags & FileIgnoreLock ) {
+            foreach( KAutoSaveFile *f,  staleFiles ) {
+                f->open( QIODevice::ReadWrite );
+                f->remove();
+                delete f;
+            }
+        } else {
+            kError() << i18n( "Cannot lock file %1", fpath );
+            return FileLocked;
+        }
+    }
+
+    autosave.setManagedFile( fpath );
+    if ( !autosave.open( QIODevice::ReadWrite ) ) {
+        kError() << i18n( "Cannot lock file %1", autosave.fileName() );
+        return FileCannotLock;
+    }
+
+    return NoError;
+}
+
+
 KEduVocDocument::KEduVocDocument( QObject *parent )
         : QObject( parent ), d( new KEduVocDocumentPrivate( this ) )
 {
-    kDebug() << "constructor done";
 }
 
 
@@ -236,14 +279,19 @@
 }
 
 
-int KEduVocDocument::open( const KUrl& url )
+/// @todo When the API major version number increments remove this function
+int KEduVocDocument::open( const KUrl& url ) {
+    return open( url, FileDefaultHandling );
+}
+
+KEduVocDocument::ErrorCode KEduVocDocument::open( const KUrl& url,  
FileHandlingFlags flags)
 {
     // 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;
+        setUrl( url );
     }
     d->m_csvDelimiter = csv;
 
@@ -251,8 +299,12 @@
     QString errorMessage = i18n( "<qt>Cannot open file<br /><b>%1</b></qt>", 
url.path() );
     QString temporaryFile;
     if ( KIO::NetAccess::download( url, temporaryFile, 0 ) ) {
-        QIODevice * f = KFilterDev::deviceForFile( temporaryFile );
+        ErrorCode autosaveError = d->initializeKAutoSave( *d->m_autosave,  
temporaryFile, flags );
+        if ( autosaveError != NoError) {
+            return autosaveError;
+        }
 
+        QIODevice * f = KFilterDev::deviceForFile( temporaryFile );
         if ( !f->open( QIODevice::ReadOnly ) ) {
             kError() << errorMessage;
             delete f;
@@ -275,7 +327,7 @@
             case Wql: {
                 kDebug(1100) << "Reading WordQuiz (WQL) document...";
                 KEduVocWqlReader wqlReader( f );
-                d->m_url.setFileName( i18n( "Untitled" ) );
+                d->m_autosave->setManagedFile( i18n( "Untitled" ) );
                 read = wqlReader.readDoc( this );
                 if ( !read ) {
                     errorMessage = wqlReader.errorMessage();
@@ -286,7 +338,7 @@
             case Pauker: {
                 kDebug(1100) << "Reading Pauker document...";
                 KEduVocPaukerReader paukerReader( this );
-                d->m_url.setFileName( i18n( "Untitled" ) );
+                d->m_autosave->setManagedFile( 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() );
@@ -297,7 +349,7 @@
             case Vokabeln: {
                 kDebug(1100) << "Reading Vokabeln document...";
                 KEduVocVokabelnReader vokabelnReader( f );
-                d->m_url.setFileName( i18n( "Untitled" ) );
+                d->m_autosave->setManagedFile( i18n( "Untitled" ) );
                 read = vokabelnReader.readDoc( this );
                 if ( !read ) {
                     errorMessage = vokabelnReader.errorMessage();
@@ -306,7 +358,7 @@
             break;
 
             case Csv: {
-                kDebug(1100) << "Reading CVS document...";
+                kDebug(1100) << "Reading CSV document...";
                 KEduVocCsvReader csvReader( f );
                 read = csvReader.readDoc( this );
                 if ( !read ) {
@@ -318,7 +370,7 @@
             case Xdxf: {
                 kDebug(1100) << "Reading XDXF document...";
                 KEduVocXdxfReader xdxfReader( this );
-                d->m_url.setFileName( i18n( "Untitled" ) );
+                d->m_autosave->setManagedFile( 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() );
@@ -339,7 +391,7 @@
         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
+            ///@todo make the readers return ErrorCode, pass on the error 
message properly
             delete f;
             return FileReaderFailed;
         }
@@ -354,12 +406,29 @@
     }
 
     setModified(false);
-    return 0;
+    return NoError;
 }
 
+void KEduVocDocument::close() {
+    d->m_autosave->releaseLock();
+}
 
+/// @todo When the API major version number increments remove this function
 int KEduVocDocument::saveAs( const KUrl & url, FileType ft, const QString & 
generator )
 {
+    const QString oldgenerator( d->m_generator );
+    d->m_generator = generator;
+
+    ErrorCode err = saveAs( url,  ft,  FileDefaultHandling );
+
+    d->m_generator = oldgenerator;
+
+    return err;
+}
+
+KEduVocDocument::ErrorCode KEduVocDocument::saveAs( const KUrl & url, FileType 
ft, FileHandlingFlags flags)
+{
+
     KUrl tmp( url );
 
     if ( ft == Automatic ) {
@@ -372,34 +441,57 @@
         }
     }
 
-    QFile f( tmp.path() );
+    QString errorMessage = i18n( "Cannot write to file %1", tmp.path() );
+
+    KAutoSaveFile *autosave;
 
+    //If we don't care about the lock always create a new one
+    //If we are changing files create a new lock
+    if ( ( flags & FileIgnoreLock )
+        || ( d->m_autosave->managedFile() != tmp.path() ) ) {
+
+        autosave = new KAutoSaveFile;
+        ErrorCode autosaveError = d->initializeKAutoSave( *autosave,  
tmp.path(), flags );
+        if ( autosaveError != NoError) {
+            delete autosave;
+            return autosaveError;
+        }
+    }
+
+    //We care about the lock and we think we still have it.
+    else {
+         autosave = d->m_autosave;
+        //Is the lock still good?
+        if ( !autosave->exists( ) ) {
+            return FileCannotLock;
+        }
+    }
+
+    QFile f( tmp.path() );
     if ( !f.open( QIODevice::WriteOnly ) ) {
-        kError() << i18n( "Cannot write to file %1", tmp.path() );
+        kError() << errorMessage;
         return FileCannotWrite;
     }
 
-    KUrl oldUrl = d->m_url;
     bool saved = false;
-    d->m_url = tmp;
 
     switch ( ft ) {
         case Kvtml: {
             // write version 2 file
             KEduVocKvtml2Writer kvtmlWriter( &f );
-            saved = kvtmlWriter.writeDoc( this, generator );
+            saved = kvtmlWriter.writeDoc( this, d->m_generator );
         }
         break;
         ///@todo port me
 //         case Kvtml1: {
 //             // write old version 1 file
 //             KEduVocKvtmlWriter kvtmlWriter( &f );
-//             saved = kvtmlWriter.writeDoc( this, generator );
+//             saved = kvtmlWriter.writeDoc( this, d->m_generator );
 //         }
 //         break;
         case Csv: {
             KEduVocCsvWriter csvWriter( &f );
-            saved = csvWriter.writeDoc( this, generator );
+            saved = csvWriter.writeDoc( this, d->m_generator );
         }
         break;
         default: {
@@ -411,13 +503,22 @@
     f.close();
 
     if ( !saved ) {
+        if ( autosave != d->m_autosave ) {
+            delete autosave;
+        }
         kError() << "Error Saving File" << tmp.path();
-        d->m_url = oldUrl;
         return FileWriterFailed;
     }
 
+    if ( autosave != d->m_autosave ) {
+        //The order is important: release old lock, delete old locker and then 
claim new locker.
+        d->m_autosave->releaseLock();
+        delete d->m_autosave;
+        d->m_autosave = autosave;
+    }
+
     setModified( false );
-    return 0;
+    return NoError;
 }
 
 QByteArray KEduVocDocument::toByteArray(const QString &generator)
@@ -730,18 +831,18 @@
 
 KUrl KEduVocDocument::url() const
 {
-    return d->m_url;
+    return d->m_autosave->managedFile();
 }
 
 void KEduVocDocument::setUrl( const KUrl& url )
 {
-    d->m_url = url;
+    d->m_autosave->setManagedFile(url);
 }
 
 QString KEduVocDocument::title() const
 {
     if ( d->m_title.isEmpty() )
-        return d->m_url.fileName();
+        return d->m_autosave->managedFile().fileName();
     else
         return d->m_title;
 }
@@ -909,6 +1010,10 @@
         return i18n("The file reader failed.");
     case FileDoesNotExist:
         return i18n("The file does not exist.");
+    case FileLocked:
+        return i18n("The file is locked by another process.");
+    case FileCannotLock:
+        return i18n("The lock file can't be created.");
     case Unknown:
     default:
         return i18n("Unknown error.");
@@ -916,4 +1021,3 @@
 }
 
 #include "keduvocdocument.moc"
-
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libkdeedu-4.13.2/keduvocdocument/keduvocdocument.h 
new/libkdeedu-4.13.80/keduvocdocument/keduvocdocument.h
--- old/libkdeedu-4.13.2/keduvocdocument/keduvocdocument.h      2013-06-13 
01:49:19.000000000 +0200
+++ new/libkdeedu-4.13.80/keduvocdocument/keduvocdocument.h     2014-06-26 
09:32:42.000000000 +0200
@@ -69,7 +69,16 @@
         FileWriterFailed,
         FileCannotRead,
         FileReaderFailed,
-        FileDoesNotExist
+        FileDoesNotExist,
+        FileLocked,       //*< An autosave file exists for this document
+        FileCannotLock  //*< Can't create an autosave file for this document
+    };
+
+    /// indicates file open/save status locking or readonly
+    enum FileHandlingFlags
+    {
+        FileDefaultHandling = 0x0, //*< Default status
+        FileIgnoreLock = 0x1       //*< Ignore the file lock
     };
 
     /// used as parameter for pattern
@@ -101,7 +110,7 @@
     // *** whole document methods ***
 
     /**
-     * Open a document file
+     * Opens and locks a document file
      *
      * @param url      url to file to open
      * @returns        ErrorCode
@@ -109,8 +118,28 @@
     int open( const KUrl& url );
 
     /**
+     * Opens and locks a document file
+     *
+     * Note: This is intended to be preserve binary compatible with int 
open(const KUrl&)
+     *       When the API increments the major version number, then merge them
+     *
+     * @param url      url to file to open
+     * @param flags How to handle expected unusual conditions (i.e. locking)
+     * @returns        ErrorCode
+     */
+    ErrorCode open( const KUrl& url,  FileHandlingFlags flags /*= 
FileDefaultHandling*/);
+
+    /**
+     * Close a document file and release the lock on the file
+     *
+     */
+    void close();
+
+    /**
      * Saves the data under the given name
      *
+     * This does not set the generator of the document, just writes it to file.
+     *
      * @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
@@ -118,6 +147,23 @@
      */
     int saveAs( const KUrl & url, FileType ft, const QString & generator );
 
+    /**
+     * Saves the data under the given name
+     *
+     * @pre generator is set.
+     *
+     * Note: This is intended to be preserve binary compatible with
+     *       int saveAs(const KUrl&, FileType ft, const QString & generator );
+     *       When the API increments the major version number, then merge them
+     *
+     * @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
+     * @param flags How to handle expected unusual conditions (i.e. locking)
+     * @returns          ErrorCode
+     */
+    ErrorCode saveAs( const KUrl & url, FileType ft,  FileHandlingFlags flags  
/*= FileDefaultHandling*/);
+
     QByteArray toByteArray(const QString &generator);
 
     /**
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libkdeedu-4.13.2/keduvocdocument/keduvoctext.cpp 
new/libkdeedu-4.13.80/keduvocdocument/keduvoctext.cpp
--- old/libkdeedu-4.13.2/keduvocdocument/keduvoctext.cpp        2013-06-13 
01:49:19.000000000 +0200
+++ new/libkdeedu-4.13.80/keduvocdocument/keduvoctext.cpp       2014-06-26 
09:32:42.000000000 +0200
@@ -24,10 +24,12 @@
     /// This is the word itself. The vocabulary. This is what it is all about.
     QString m_text;
 
+    grade_t m_preGrade;         // Before it gets to grade 1.
     grade_t m_grade;
     count_t m_totalPracticeCount;
     count_t m_badCount;
     QDateTime m_practiceDate;
+    quint32 m_interval;         // Interval in seconds until next training is 
due.
 };
 
 KEduVocText::KEduVocText(const QString& text)
@@ -38,13 +40,15 @@
 }
 
 KEduVocText::KEduVocText( const KEduVocText &other )
-        :d( new KEduVocTextPrivate )
+    : d( new KEduVocTextPrivate )
 {
     d->m_text = other.d->m_text;
+    setPreGrade( other.preGrade() );
     setGrade( other.grade() );
     setPracticeCount( other.practiceCount() );
     setBadCount( other.badCount() );
     setPracticeDate( other.practiceDate() );
+    setInterval( other.interval() );
 }
 
 KEduVocText::~KEduVocText()
@@ -64,6 +68,7 @@
 
 void KEduVocText::resetGrades()
 {
+    d->m_preGrade = KV_NORM_GRADE;
     d->m_grade = KV_NORM_GRADE;
     d->m_totalPracticeCount = 0;
     d->m_badCount = 0;
@@ -71,6 +76,22 @@
     QDateTime dt;
     dt.setTime_t( 0 );
     d->m_practiceDate = dt;
+    d->m_interval = 0;
+}
+
+
+grade_t KEduVocText::preGrade() const
+{
+    return d->m_preGrade;
+}
+
+
+void KEduVocText::setPreGrade( grade_t grade )
+{
+    if ( grade > KV_MAX_GRADE ) {
+        grade = KV_MAX_GRADE;
+    }
+    d->m_preGrade = grade;
 }
 
 
@@ -151,6 +172,18 @@
     d->m_practiceDate = date;
 }
 
+quint32 KEduVocText::interval() const
+{
+    return d->m_interval;
+}
+
+
+void KEduVocText::setInterval( quint32 interval )
+{
+    d->m_interval = interval;
+}
+
+
 KEduVocText & KEduVocText::operator =(const KEduVocText & other)
 {
     d->m_text = other.d->m_text;
@@ -186,6 +219,9 @@
     if ( d->m_totalPracticeCount > 0 ) {
         QDomElement gradeElement = domDoc.createElement( KVTML_GRADE );
 
+            //<pregrade>2</pregrade>
+        KEduVocKvtml2Writer::appendTextElement( gradeElement, KVTML_PREGRADE, 
QString::number( preGrade() ) );
+
             //<currentgrade>2</currentgrade>
         KEduVocKvtml2Writer::appendTextElement( gradeElement, 
KVTML_CURRENTGRADE, QString::number( grade() ) );
 
@@ -198,6 +234,10 @@
             //<date>949757271</date>
         KEduVocKvtml2Writer::appendTextElement( gradeElement, KVTML_DATE,  
practiceDate().toString( Qt::ISODate ) );
 
+            //<interval>300</interval>
+        KEduVocKvtml2Writer::appendTextElement( gradeElement, KVTML_INTERVAL,  
QString::number(interval()) );
+
+
         parent.appendChild( gradeElement );
     }
 }
@@ -210,6 +250,7 @@
     const QDomElement& gradeElement = parent.firstChildElement( KVTML_GRADE );
     if ( !gradeElement.isNull() ) {
 
+        setPreGrade( 
gradeElement.firstChildElement(KVTML_PREGRADE).text().toInt() );
         setGrade( 
gradeElement.firstChildElement(KVTML_CURRENTGRADE).text().toInt() );
 
         setPracticeCount( 
gradeElement.firstChildElement(KVTML_COUNT).text().toInt() );
@@ -221,6 +262,7 @@
             QDateTime value = QDateTime::fromString( dateString, Qt::ISODate );
             setPracticeDate( value );
         }
+        setInterval( 
gradeElement.firstChildElement(KVTML_INTERVAL).text().toInt() );
     }
 }
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libkdeedu-4.13.2/keduvocdocument/keduvoctext.h 
new/libkdeedu-4.13.80/keduvocdocument/keduvoctext.h
--- old/libkdeedu-4.13.2/keduvocdocument/keduvoctext.h  2013-06-13 
01:49:19.000000000 +0200
+++ new/libkdeedu-4.13.80/keduvocdocument/keduvoctext.h 2014-06-26 
09:32:42.000000000 +0200
@@ -128,6 +128,15 @@
      */
     void resetGrades();
 
+    /** sets the pregrade
+    * @param grade number of knowlegde: 0=known, x=numbers not knows
+    */
+    void setPreGrade( grade_t grade );
+
+    /** returns pregrade
+    */
+    grade_t preGrade() const;
+
     /** sets the grade
     * @param grade number of knowlegde: 0=known, x=numbers not knows
     */
@@ -153,6 +162,15 @@
     */
     void setPracticeDate( const QDateTime & date );
 
+    /** returns interval until next practice is due
+    */
+    quint32 interval() const;
+
+    /** Set interval until next practice is due.
+    * @param interval   the new interval
+    */
+    void setInterval( quint32 interval );
+
     /**
      * If the string inside is empty this returns true.
      * @return 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libkdeedu-4.13.2/keduvocdocument/kvtml2defs.h 
new/libkdeedu-4.13.80/keduvocdocument/kvtml2defs.h
--- old/libkdeedu-4.13.2/keduvocdocument/kvtml2defs.h   2013-06-13 
01:49:19.000000000 +0200
+++ new/libkdeedu-4.13.80/keduvocdocument/kvtml2defs.h  2014-06-26 
09:32:42.000000000 +0200
@@ -151,10 +151,12 @@
 
 #define KVTML_GRADE             "grade"
 #define KVTML_FROMID            "fromid"
+#define KVTML_PREGRADE          "pregrade"
 #define KVTML_CURRENTGRADE      "currentgrade"
 #define KVTML_COUNT             "count"
 #define KVTML_ERRORCOUNT        "errorcount"
 #define KVTML_DATE              "date"
+#define KVTML_INTERVAL          "interval"
 
 #define KVTML_TRUE              "true"
 #define KVTML_FALSE             "false"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/libkdeedu-4.13.2/keduvocdocument/tests/CMakeLists.txt 
new/libkdeedu-4.13.80/keduvocdocument/tests/CMakeLists.txt
--- old/libkdeedu-4.13.2/keduvocdocument/tests/CMakeLists.txt   2013-06-13 
01:49:19.000000000 +0200
+++ new/libkdeedu-4.13.80/keduvocdocument/tests/CMakeLists.txt  2014-06-26 
09:32:42.000000000 +0200
@@ -3,7 +3,11 @@
 
 kde4_add_unit_test(keduvocdocumentvalidatortest 
keduvocdocumentvalidatortest.cpp)
 target_link_libraries(keduvocdocumentvalidatortest keduvocdocument
-    ${KDE4_KDECORE_LIBS} ${QT_QTGUI_LIBRARY} ${QT_QTTEST_LIBRARY} 
${QT_QTXML_LIBRARY})
+  ${KDE4_KDECORE_LIBS} ${QT_QTGUI_LIBRARY} ${QT_QTTEST_LIBRARY} 
${QT_QTXML_LIBRARY})
+
+kde4_add_unit_test( keduvocdocumentfilelockingtest 
keduvocdocumentfilelockingtest.cpp )
+target_link_libraries( keduvocdocumentfilelockingtest keduvocdocument
+  ${KDE4_KDECORE_LIBS} ${QT_QTGUI_LIBRARY} ${QT_QTTEST_LIBRARY} 
${QT_QTXML_LIBRARY})
 
 
 # CONVERTER:
@@ -21,8 +25,3 @@
 kde4_add_executable(converter ${converter_SRCS})
 
 target_link_libraries(converter keduvocdocument ${KDE4_KDECORE_LIBS})
-
-
-
-
-
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libkdeedu-4.13.2/keduvocdocument/tests/converter.cpp 
new/libkdeedu-4.13.80/keduvocdocument/tests/converter.cpp
--- old/libkdeedu-4.13.2/keduvocdocument/tests/converter.cpp    2013-06-13 
01:49:19.000000000 +0200
+++ new/libkdeedu-4.13.80/keduvocdocument/tests/converter.cpp   2014-06-26 
09:32:42.000000000 +0200
@@ -1,5 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2007 by Jeremy Whiting <[email protected]>            *
+ *   Copyright (C) 2007 by Jeremy Whiting <[email protected]>              *
  *                                                                         *
  *   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  *
@@ -21,7 +21,7 @@
  * \brief kvtml document reader/writer
  * partly to test the document class, partly to convert
  * old kvtml files to the new format
- * @author Jeremy Whiting <[email protected]>
+ * @author Jeremy Whiting <[email protected]>
  */
 
 #include "keduvocdocument.h"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/libkdeedu-4.13.2/keduvocdocument/tests/keduvocdocumentfilelockingtest.cpp 
new/libkdeedu-4.13.80/keduvocdocument/tests/keduvocdocumentfilelockingtest.cpp
--- 
old/libkdeedu-4.13.2/keduvocdocument/tests/keduvocdocumentfilelockingtest.cpp   
    1970-01-01 01:00:00.000000000 +0100
+++ 
new/libkdeedu-4.13.80/keduvocdocument/tests/keduvocdocumentfilelockingtest.cpp  
    2014-06-26 09:32:42.000000000 +0200
@@ -0,0 +1,294 @@
+/*
+ Copyright 2014-2014 Andreas Xavier <andxav at zoho dot com>
+
+ 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 <KTemporaryFile>
+
+#include <qtest_kde.h>
+
+#include <qobject.h>
+#include <qvalidator.h>
+#include <QtXml/QDomDocument>
+
+/** Unit tests to verify that 2 kvocdocs can't access a single file at the 
same time.*/
+class KEduVocDocumentFileLockingTest
+  : public QObject
+{
+    Q_OBJECT
+
+private slots:
+    /**  Checks that the lock is released in the destructor*/
+    void testVocFileLockReleaseOnDestruction();
+    /**  Checks that the lock is released on close()*/
+    void testVocFileLockReleaseOnClose();
+    /**  Checks that the lock is released if another url is opened.*/
+    void testVocFileLockReleaseOnSecondOpen();
+    /** Checks that the lock is released when it saves as another filename*/
+    void testVocFileLockReleaseOnSaveAs();
+
+    /**  Checks that the kvocdoc doesn't lock itself out with a second open*/
+    void testVocFileLockOpenOpenCycle();
+    /**  Checks that the kvoc doc doesn't lock itself out with a second save*/
+    void testVocFileLockOpenSaveSaveCycle();
+
+    /**  Checks that the kvoc doc can steal the lock with an open function*/
+    void testVocFileLockOpenStealWOpen();
+    /**  Checks that the kvoc doc can steal the lock with a saveAs function*/
+    void testVocFileLockOpenStealWSaveAs();
+
+private :
+
+    /** Class to manage creation/destruction of a kvtml temp doc*/
+    class TemporaryVocDoc : public KTemporaryFile
+    {
+    public :
+        /** Create the file, fix the suffix and instantiate it.*/
+        TemporaryVocDoc() {
+            this->setSuffix(".kvtml");
+            this->open();
+            this->close();
+        }
+        /** Destructor*/
+        ~TemporaryVocDoc() {}
+    };
+
+    /** Creates a minimal doc that will save and load error free.*/
+    class MinimalTempVocDoc : public TemporaryVocDoc
+    {
+    public :
+        /** The minimal doc has generator, author, lang and local */
+        MinimalTempVocDoc() {
+            const QString generator = QString::fromLatin1( "File Locking Unit 
Tests" );
+            const QString author = QString::fromLatin1( "File Locking Test" );
+            const QString lang = QString::fromLatin1( "File Locking Language 
Name" );
+            const QString locale = QString::fromLatin1( "en" ) ;
+
+            KEduVocIdentifier lang0;
+            lang0.setName( lang );
+            lang0.setLocale( locale);
+
+            KEduVocDocument *doc = new KEduVocDocument();
+            doc->setAuthor( author );
+            doc->appendIdentifier( lang0 );
+            KUrl filename = this->fileName();
+            doc->saveAs(filename, KEduVocDocument::Kvtml, generator);
+            delete doc;
+        }
+        /** Destructor*/
+        ~MinimalTempVocDoc() {}
+    };
+};
+
+
+void KEduVocDocumentFileLockingTest::testVocFileLockReleaseOnDestruction()
+{
+    MinimalTempVocDoc tempfile;
+
+    KEduVocDocument *doc1 = new KEduVocDocument();
+    int docError = doc1->open(tempfile.fileName());
+    QCOMPARE( docError, int( KEduVocDocument::NoError ) );
+
+    const QString generator = QString::fromLatin1( "File Locking Unit Tests" );
+    QCOMPARE( doc1->generator(), generator );
+
+    KEduVocDocument *doc2 = new KEduVocDocument();
+    docError = doc2->open(tempfile.fileName());
+    QCOMPARE( docError, int( KEduVocDocument::FileLocked ) );
+    delete doc2;
+
+    delete doc1;
+    KEduVocDocument *doc3 = new KEduVocDocument();
+    docError = doc3->open(tempfile.fileName());
+    QCOMPARE( docError, int( KEduVocDocument::NoError ) );
+    QCOMPARE( doc3->generator(), generator );
+    delete doc3;
+
+}
+
+void KEduVocDocumentFileLockingTest::testVocFileLockReleaseOnClose()
+{
+    MinimalTempVocDoc tempfile;
+
+    KEduVocDocument *doc1 = new KEduVocDocument();
+    int docError = doc1->open(tempfile.fileName());
+    QCOMPARE( docError, int( KEduVocDocument::NoError ) );
+
+    KEduVocDocument *doc2 = new KEduVocDocument();
+    docError = doc2->open(tempfile.fileName());
+    QCOMPARE( docError, int( KEduVocDocument::FileLocked ) );
+    delete doc2;
+
+    doc1->close();
+    KEduVocDocument *doc3 = new KEduVocDocument();
+    docError = doc3->open(tempfile.fileName());
+    QCOMPARE( docError, int( KEduVocDocument::NoError ) );
+
+    delete doc3;
+    delete doc1;
+
+}
+
+void KEduVocDocumentFileLockingTest::testVocFileLockReleaseOnSecondOpen()
+{
+    MinimalTempVocDoc tempfile,  tempfile2;
+
+    KEduVocDocument *doc1 = new KEduVocDocument();
+    int docError = doc1->open(tempfile.fileName());
+    QCOMPARE( docError, int( KEduVocDocument::NoError ) );
+
+    KEduVocDocument *doc2 = new KEduVocDocument();
+    docError = doc2->open(tempfile.fileName());
+    QCOMPARE( docError, int( KEduVocDocument::FileLocked ) );
+    delete doc2;
+
+    doc1->open( tempfile2.fileName() );
+    KEduVocDocument *doc3 = new KEduVocDocument();
+    docError = doc3->open(tempfile.fileName());
+    QCOMPARE( docError, int( KEduVocDocument::NoError ) );
+
+    delete doc1;
+    delete doc3;
+}
+
+void KEduVocDocumentFileLockingTest::testVocFileLockReleaseOnSaveAs()
+{
+    MinimalTempVocDoc tempfile;
+    TemporaryVocDoc tempfile2;
+
+    KEduVocDocument *doc1 = new KEduVocDocument();
+    int docError = doc1->open(tempfile.fileName());
+    QCOMPARE( docError, int( KEduVocDocument::NoError ) );
+
+    KEduVocDocument *doc2 = new KEduVocDocument();
+    docError = doc2->open(tempfile.fileName());
+    QCOMPARE( docError, int( KEduVocDocument::FileLocked ) );
+    delete doc2;
+
+    const QString generator = QString::fromLatin1( "File Locking Unit Tests" );
+    docError = doc1->saveAs( tempfile2.fileName() ,KEduVocDocument::Kvtml, 
generator);
+    QCOMPARE( docError, int( KEduVocDocument::NoError ) );
+
+    KEduVocDocument *doc3 = new KEduVocDocument();
+    docError = doc3->open(tempfile.fileName());
+    QCOMPARE( docError, int( KEduVocDocument::NoError ) );
+
+    delete doc1;
+    delete doc3;
+}
+
+void KEduVocDocumentFileLockingTest::testVocFileLockOpenOpenCycle()
+{
+    MinimalTempVocDoc tempfile;
+    const QString generator = QString::fromLatin1( "File Locking Unit Tests" );
+
+    KEduVocDocument *doc = new KEduVocDocument();
+    int docError = doc->open(tempfile.fileName());
+    docError = doc->open(tempfile.fileName());
+    QCOMPARE( docError, int( KEduVocDocument::NoError ) );
+
+    delete doc;
+}
+
+void KEduVocDocumentFileLockingTest::testVocFileLockOpenSaveSaveCycle()
+{
+    MinimalTempVocDoc tempfile;
+    const QString generator = QString::fromLatin1( "File Locking Unit Tests" );
+
+    KEduVocDocument *doc = new KEduVocDocument();
+    int docError = doc->open(tempfile.fileName());
+
+    doc->setAuthor( QString::fromLatin1( "Author1" ) );
+    docError = doc->saveAs( tempfile.fileName() ,KEduVocDocument::Kvtml, 
generator);
+    QCOMPARE( docError, int( KEduVocDocument::NoError ) );
+
+    const QString author2 = QString::fromLatin1( "Author2" );
+    doc->setAuthor( author2 );
+    docError = doc->saveAs( tempfile.fileName() ,KEduVocDocument::Kvtml, 
generator);
+    QCOMPARE( docError, int( KEduVocDocument::NoError ) );
+
+    delete doc;
+
+    KEduVocDocument docRead;
+    docRead.open(tempfile.fileName());
+    QCOMPARE( docRead.author(), author2 );
+
+}
+
+void KEduVocDocumentFileLockingTest::testVocFileLockOpenStealWOpen()
+{
+    MinimalTempVocDoc tempfile;
+    const QString generator = QString::fromLatin1( "File Locking Unit Tests" );
+
+    KEduVocDocument *doc1 = new KEduVocDocument();
+    int docError = doc1->open(tempfile.fileName());
+    QCOMPARE( docError, int( KEduVocDocument::NoError ) );
+
+    KEduVocDocument *doc2 = new KEduVocDocument();
+    docError = doc2->open(tempfile.fileName());
+    QCOMPARE( docError, int( KEduVocDocument::FileLocked ) );
+
+    docError = doc2->open(tempfile.fileName(),  
KEduVocDocument::FileIgnoreLock);
+    QCOMPARE( docError, int( KEduVocDocument::NoError ) );
+
+    docError = doc1->saveAs(tempfile.fileName(), KEduVocDocument::Kvtml, 
generator );
+    QCOMPARE( docError, int( KEduVocDocument::FileCannotLock ) );
+
+    delete doc2;
+    delete doc1;
+}
+
+void KEduVocDocumentFileLockingTest::testVocFileLockOpenStealWSaveAs()
+{
+    MinimalTempVocDoc tempfile,  tempfile2;
+    const QString generator = QString::fromLatin1( "File Locking Unit Tests 
Save w Stolen Lock" );
+
+    KEduVocDocument *doc1 = new KEduVocDocument();
+    int docError = doc1->open(tempfile.fileName());
+    QCOMPARE( docError, int( KEduVocDocument::NoError ) );
+
+    KEduVocDocument *doc2 = new KEduVocDocument();
+    docError = doc2->open(tempfile2.fileName());
+    QCOMPARE( docError, int( KEduVocDocument::NoError ) );
+
+    docError = doc2->saveAs(tempfile.fileName(), KEduVocDocument::Kvtml, 
generator );
+    QCOMPARE( docError, int( KEduVocDocument::FileLocked ) );
+
+    docError = doc2->saveAs(tempfile.fileName(), KEduVocDocument::Kvtml, 
KEduVocDocument::FileIgnoreLock );
+    QCOMPARE( docError, int( KEduVocDocument::NoError ) );
+
+    docError = doc1->saveAs(tempfile.fileName(), KEduVocDocument::Kvtml, 
generator );
+    QCOMPARE( docError, int( KEduVocDocument::FileCannotLock ) );
+
+    delete doc2;
+    delete doc1;
+}
+
+
+
+QTEST_KDEMAIN_CORE( KEduVocDocumentFileLockingTest )
+
+#include "keduvocdocumentfilelockingtest.moc"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/libkdeedu-4.13.2/keduvocdocument/tests/keduvocdocumentvalidatortest.cpp 
new/libkdeedu-4.13.80/keduvocdocument/tests/keduvocdocumentvalidatortest.cpp
--- old/libkdeedu-4.13.2/keduvocdocument/tests/keduvocdocumentvalidatortest.cpp 
2013-06-13 01:49:19.000000000 +0200
+++ 
new/libkdeedu-4.13.80/keduvocdocument/tests/keduvocdocumentvalidatortest.cpp    
    2014-06-26 09:32:42.000000000 +0200
@@ -73,6 +73,7 @@
     doc.setTitle( title );
 
     doc.saveAs(fileName, KEduVocDocument::Kvtml, generator);
+    doc.close();
 
     KEduVocDocument docRead;
     docRead.open(fileName);

-- 
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to