A usage is now simply a QStringList.
Translations can contain as many usage QStrings as they want (also QStringList).
Another dtd update: A translation can contain multiple <usage>tags.
Removal of usage label management classes.
svn path=/trunk/KDE/kdeedu/libkdeedu/; revision=705421
QList<int> m_lessonsInQuery;
QStringList m_tenseDescriptions;
- QStringList m_usageDescriptions;
+ QStringList m_usages;
QString m_title;
QString m_author;
QString m_license;
}
-QString KEduVocDocument::usageName(int index) const
-{
- if (index >= d->m_usageDescriptions.size())
- return "";
- else
- return d->m_usageDescriptions[index];
-}
-
-
-void KEduVocDocument::setUsageName(int idx, QString &id)
-{
- if (idx >= d->m_usageDescriptions.size())
- for (int i = d->m_usageDescriptions.size(); i <= idx; i++)
- d->m_usageDescriptions.append ("");
-
- d->m_usageDescriptions[idx] = id;
-}
-
-
-QStringList KEduVocDocument::usageDescriptions() const
-{
- return d->m_usageDescriptions;
-}
-
-
-void KEduVocDocument::setUsageDescriptions(const QStringList &names)
-{
- d->m_usageDescriptions = names;
-}
-
-
void KEduVocDocument::setConjugation(int idx, const KEduVocConjugation &con)
{
if ( idx < 0) return;
return d->m_wordTypes;
}
+
+QStringList KEduVocDocument::usages(){
+ return d->m_usages;
+}
+
+
+/*
+void KEduVocDocument::setUsageDescriptions(const QStringList &names)
+{
+ d->m_usageDescriptions = names;
+}*/
+
+
+void KEduVocDocument::addUsage(const QString &usage){
+ d->m_usages.append(usage);
+}
+
+
+QString KEduVocDocument::renameUsage(const QString &oldName, const QString &newName){
+ d->m_usages[d->m_usages.indexOf(oldName)]=newName;
+}
+
+
+void KEduVocDocument::removeUsage(const QString &name){
+ d->m_usages.removeAt(d->m_usages.indexOf(name));
+}
+
+
+
+
#include "keduvocdocument.moc"
// *** usage methods ***
- /**
- * Sets usage string
- *
- * @param index number of usage
- * @param str name of usage
- */
- void setUsageName(int index, QString &str);
-
- /**
- * Returns usage string
- *
- * @param index number of usage
- * @returns string
- */
- QString usageName(int index) const;
-
- /**
- * Sets the descriptions of the usages
- */
- void setUsageDescriptions(const QStringList &names);
-
/**
* Gets the descriptions of the usages.
* Usages are context information in a dictionary you may find [biol.]
* [am.] and the like to hint at the context in which the word is usually used.
*/
- QStringList usageDescriptions() const;
+ QStringList usages();
+
+
+ void addUsage(const QString &usage);
+
+
+ QString renameUsage(const QString &oldName, const QString &newName);
+
+
+ void removeUsage(const QString &name);
// *** grade methods ***
expr.translation(index).setExample(currentElement.text());
}
- //<usage></usage>
+ //<usage></usage> can be as often as there are usage labels
currentElement = translationElement.firstChildElement(KVTML_USAGE);
- if (!currentElement.isNull())
+ while (!currentElement.isNull())
{
- expr.translation(index).setUsageLabel(currentElement.text());
+ expr.translation(index).usages().append(currentElement.text());
+ currentElement = currentElement.nextSiblingElement(KVTML_USAGE);
}
//<paraphrase></paraphrase>
QDomElement currentElement = usageNodes.item(i).toElement();
if (currentElement.parentNode() == usagesElement)
{
- usages.append(currentElement.text());
+ m_doc->addUsage(currentElement.text());
}
}
- m_doc->setUsageDescriptions(usages);
return true;
}
bool KEduVocKvtml2Writer::writeUsages(QDomElement &usagesElement)
{
- foreach(QString usage, m_doc->usageDescriptions())
+ foreach(QString usage, m_doc->usages())
{
- if (!(usage.isNull()))
- {
- usagesElement.appendChild(newTextElement(KVTML_USAGE, usage));
- }
+ usagesElement.appendChild(newTextElement(KVTML_USAGE, usage));
}
return true;
}
// <usage></usage>
- if (!translation.usageLabel().isEmpty())
+ foreach (QString usage, translation.usages())
{
- translationElement.appendChild(newTextElement(KVTML_USAGE, translation.usageLabel()));
+ translationElement.appendChild(newTextElement(KVTML_USAGE, usage));
}
// <paraphrase></paraphrase>
if (entryList.length() <= 0)
return false;
- descriptions.clear();
for (int i = 0; i < entryList.count(); ++i) {
currentElement = entryList.item(i).toElement();
s = currentElement.text();
if (s.isNull())
s = "";
- descriptions.append(s);
+ m_doc->addUsage(s);
}
}
- m_doc->setUsageDescriptions(descriptions);
return true;
}
if (!attribute.isNull())
example = attribute.value();
+///@todo usages
+/*
usage = "";
attribute = domElementExpressionChild.attributeNode(KV_USAGE);
if (!attribute.isNull())
m_doc->setUsageDescriptions(sl);
}
}
- }
+ }*/
paraphrase = "";
attribute = domElementExpressionChild.attributeNode(KV_PARAPHRASE);
expr.translation(i).setSynonym (synonym);
if (!example.isEmpty() )
expr.translation(i).setExample (example);
+///@todo enable reading of usages into a qstringlist
+/*
if (!usage.isEmpty() )
expr.translation(i).setUsageLabel (usage);
+*/
if (!paraphrase.isEmpty() )
expr.translation(i).setParaphrase (paraphrase);
if (!antonym.isEmpty() )
if (!entry->translation(0).example().isEmpty() )
domElementOriginal.setAttribute(KV_EXAMPLE, entry->translation(0).example());
-
+///@todo enable writing of usages into a qstringlist
+/*
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(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());
bool KEduVocKvtmlWriter::writeUsage(QDomDocument &domDoc, QDomElement &domElementParent)
{
+
+///@todo usages
+/*
if (m_doc->usageDescriptions().count() == 0)
return true;
domElementParent.appendChild(domElementUsage);
return true;
+*/
}
/// noun:male etc (language dependent)
QString m_type;
QString m_subType;
- QString m_usageLabel;
+ QStringList m_usages;
QString m_comment;
QString m_paraphrase;
QString m_synonym;
return m_translation == other.m_translation &&
m_type == other.m_type &&
m_subType == other.m_subType &&
- m_usageLabel == other.m_usageLabel &&
+ m_usages == other.m_usages &&
m_comment == other.m_comment &&
m_paraphrase == other.m_paraphrase &&
m_synonym == other.m_synonym &&
d->m_translation = other.d->m_translation;
d->m_type = other.d->m_type;
d->m_subType = other.d->m_subType;
- d->m_usageLabel = other.d->m_usageLabel;
+ d->m_usages = other.d->m_usages;
d->m_comment = other.d->m_comment;
d->m_paraphrase = other.d->m_paraphrase;
d->m_synonym = other.d->m_synonym;
}
-void KEduVocTranslation::setUsageLabel ( const QString & usage )
+void KEduVocTranslation::setUsages ( const QStringList & usages )
{
- d->m_usageLabel = usage;
+ d->m_usages = usages;
}
-QString KEduVocTranslation::usageLabel () const
+QStringList& KEduVocTranslation::usages ()
{
- return d->m_usageLabel;
+ return d->m_usages;
}
return d->m_translation == translation.d->m_translation &&
d->m_type == translation.d->m_type &&
d->m_subType == translation.d->m_subType &&
- d->m_usageLabel == translation.d->m_usageLabel &&
+ d->m_usages == translation.d->m_usages &&
d->m_comment == translation.d->m_comment &&
d->m_paraphrase == translation.d->m_paraphrase &&
d->m_synonym == translation.d->m_synonym &&
d->m_translation = translation.d->m_translation;
d->m_type = translation.d->m_type;
d->m_subType = translation.d->m_subType;
- d->m_usageLabel = translation.d->m_usageLabel;
+ d->m_usages = translation.d->m_usages;
d->m_comment = translation.d->m_comment;
d->m_paraphrase = translation.d->m_paraphrase;
d->m_synonym = translation.d->m_synonym;
*/
QString example() const;
- /** sets usage label this expression
- * @param usage usage label of this index
+
+ /** sets usages this expression
+ * @param usage usage labels of this index
*/
- void setUsageLabel( const QString & usage);
+ void setUsages( const QStringList & usage);
+
- /** returns usage label of this expression
- * @return usage or "" if no string available
+ /** returns usages of this expression
+ * @return usages
*/
- QString usageLabel() const;
+ QStringList& usages();
/** sets paraphrase of this expression
* @param expression paraphrase of this index
<!ELEMENT inactive EMPTY >
<!ELEMENT inquery EMPTY >
-<!ELEMENT translation (text, wordtype?, inquery?, comment?, pronunciation?, falsfriend?, antonym?, synonym?, example?, usage?, paraphrase?, comparison?, conjugation*) >
+<!ELEMENT translation (text, wordtype?, inquery?, comment?, pronunciation?, falsfriend?, antonym?, synonym?, example?, usage*, paraphrase?, comparison?, conjugation*) >
<!ELEMENT text (#PCDATA) >
<!ELEMENT pronunciation (#PCDATA) >
<!ELEMENT falsefriend (#PCDATA) >