*/
QString m_category;
- QList<KEduVocArticle> m_articles;
QList<KEduVocConjugation> m_conjugations;
// make this a map so removals don't require renumbering :)
void KEduVocDocument::KEduVocDocumentPrivate::init()
{
m_lessons.clear();
- m_articles.clear();
m_tenseDescriptions.clear();
m_identifiers.clear();
m_sortIdentifier.clear();
}
-void KEduVocDocument::setArticle( int idx, const KEduVocArticle &art )
-{
- if ( idx < 0 ) return;
-
- // extend conjugation with empty elements
- if ( d->m_articles.size() <= idx )
- for ( int i = d->m_articles.size(); i < idx+1; i++ )
- d->m_articles.append( KEduVocArticle() );
-
- d->m_articles[idx] = art;
-}
-
-
-KEduVocArticle KEduVocDocument::article( int idx ) const
-{
- if ( idx >= d->m_articles.size() || idx < 0 ) {
- return KEduVocArticle();
- } else {
- return d->m_articles[idx];
- }
-}
-
-
-int KEduVocDocument::articleCount() const
-{
- return d->m_articles.count();
-}
-
-
int KEduVocDocument::sizeHint( int idx ) const
{
if ( idx < 0 ) {
int KEduVocDocument::appendIdentifier( const KEduVocIdentifier& id )
{
int i = d->m_identifiers.size();
+kDebug() << "appendIdentifier: " << i << id.name() << id.locale();
d->m_identifiers.append( id );
if ( id.name().isEmpty() ) {
if ( i == 0 ) {
*/
int conjugationCount() const;
-
-
-///@todo move into identifier!
- // *** article methods ***
-
- /**
- * @param index index of translation
- * @returns a pointer to articles if available
- */
- KEduVocArticle article( int index ) const;
-
- /**
- * Sets the articles
- *
- * @param index index of translation
- * @param art article block
- */
- void setArticle( int index, const KEduVocArticle &art );
-
- /**
- * @returns the number of articles
- */
- int articleCount() const;
-
// *** file format specific methods ***
/**
KEduVocIdentifier::KEduVocIdentifier()
: d( new Private )
{
- d->m_name = i18nc("A default title for a single column of vocabulary. Will hardly be used. Should be very generic.", "Title");
///@todo maybe the user locale would be more appropriate
d->m_locale = "en";
}
d->m_locale = locale;
}
+
+void KEduVocIdentifier::setArticle( const KEduVocArticle& articles )
+{
+ d->m_articles = articles;
+}
+
+
+KEduVocArticle KEduVocIdentifier::article() const
+{
+ return d->m_articles;
+}
+
*/
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 );
+
+
private:
class Private;
Private * const d;
nat_indef = subElement.text();
}
}
- m_doc->setArticle( identifierNum, KEduVocArticle( fem_def, fem_indef, mal_def, mal_indef, nat_def, nat_indef ) );
+ m_doc->identifier(identifierNum).setArticle( KEduVocArticle( fem_def, fem_indef, mal_def, mal_indef, nat_def, nat_indef ) );
return true;
}
QString indef;
// male
- m_doc->article( article ).getMale( &def, &indef );
+ m_doc->identifier(article).article().getMale( &def, &indef );
if ( !def.isEmpty() ) {
definite.appendChild( newTextElement( KVTML_MALE, def ) );
}
}
// female
- m_doc->article( article ).getFemale( &def, &indef );
+ m_doc->identifier(article).article().getFemale( &def, &indef );
if ( !def.isEmpty() ) {
definite.appendChild( newTextElement( KVTML_FEMALE, def ) );
}
}
// neutral
- m_doc->article( article ).getNatural( &def, &indef );
+ m_doc->identifier(article).article().getNatural( &def, &indef );
if ( !def.isEmpty() ) {
definite.appendChild( newTextElement( KVTML_NEUTRAL, def ) );
}
return false;
}
-
// initialize the list of predefined types
m_doc->wordTypes()->createDefaultWordTypes();
currentElement = domElementParent.firstChildElement( KV_TYPE_GRP );
nat_indef = "";
}
- m_doc->setArticle( i, KEduVocArticle( fem_def, fem_indef, mal_def, mal_indef, nat_def, nat_indef ) );
+ m_doc->identifier(i).setArticle( KEduVocArticle( fem_def, fem_indef, mal_def, mal_indef, nat_def, nat_indef ) );
}
}
bool KEduVocKvtmlReader::addLanguage( int languageId, const QString& language)
{
+
+kDebug() << "addLanguage( " << languageId << ", " << language << ")";
if ( m_doc->identifierCount() <= languageId ) {
m_doc->appendIdentifier();
// first entry
}
} else {
if ( !language.isEmpty() ) {
- if ( language != m_doc->identifier( languageId ).locale() ) {
+ if ( language != m_doc->identifier(languageId).locale() ) {
// different originals ?
m_errorMessage = i18n( "Ambiguous definition of language code" );
return false;
}
}
}
+ return true;
}
</article>
*/
{
- if ( m_doc->articleCount() == 0 )
- return true;
-
QDomElement domElementArticle = domDoc.createElement( KV_ARTICLE_GRP );
QString def;
QString indef;
QString s;
- for ( int i = 0; i < qMin( m_doc->articleCount(), m_doc->identifierCount() ); i++ )
+ for ( int i = 0; i < m_doc->identifierCount(); i++ )
{
QDomElement domElementEntry = domDoc.createElement( KV_ART_ENTRY );
- if ( i == 0 ) {
- s = m_doc->identifier( 0 ).name().simplified();
- if ( s.isEmpty() )
- s = "original";
- } else {
- s = m_doc->identifier( i ).name().simplified();
- if ( s.isEmpty() ) {
- s.setNum( i );
- s.prepend( "translation " );
- }
- }
+ s = m_doc->identifier(i).name().simplified();
domElementEntry.setAttribute( KV_LANG, s );
- m_doc->article( i ).getFemale( &def, &indef );
+ m_doc->identifier(i).article().getFemale( &def, &indef );
if ( !def.isEmpty() ) {
QDomElement domElementFD = domDoc.createElement( KV_ART_FD );
QDomText domTextFD = domDoc.createTextNode( def );
domElementEntry.appendChild( domElementFI );
}
- m_doc->article( i ).getMale( &def, &indef );
+ m_doc->identifier(i).article().getMale( &def, &indef );
if ( !def.isEmpty() ) {
QDomElement domElementMD = domDoc.createElement( KV_ART_MD );
QDomText domTextMD = domDoc.createTextNode( def );
domElementEntry.appendChild( domElementMI );
}
- m_doc->article( i ).getNatural( &def, &indef );
+ m_doc->identifier(i).article().getNatural( &def, &indef );
if ( !def.isEmpty() ) {
QDomElement domElementND = domDoc.createElement( KV_ART_ND );
QDomText domTextND = domDoc.createTextNode( def );