21 #include <KEMailSettings>
26 #include <keduvoclesson.h>
27 #include <keduvocleitnerbox.h>
28 #include <keduvocexpression.h>
29 #include <keduvocwordtype.h>
32 #include "../config-parley.h"
43 QString locale = doc->identifier(languageIndex).locale();
45 KUrl location(
QString(
"http://edu.kde.org/parley/locale/") + locale +
QString(
".kvtml"));
47 KEduVocDocument grammarDoc;
48 if (grammarDoc.open(location) == KEduVocDocument::NoError) {
49 doc->identifier(languageIndex).setArticle(grammarDoc.identifier(0).article());
50 doc->identifier(languageIndex).setPersonalPronouns(grammarDoc.identifier(0).personalPronouns());
52 doc->identifier(languageIndex).setTenseList(grammarDoc.identifier(0).tenseList());
54 kDebug() <<
"Download of " << location.url() <<
" failed.";
67 , m_doc(new KEduVocDocument(this))
72 m_doc->open(*url, KEduVocDocument::FileOpenReadOnly);
95 m_doc =
new KEduVocDocument();
103 m_doc->setTitle(title);
112 m_backupTimer->
stop();
115 if (!m_backupTimer) {
116 m_backupTimer =
new QTimer(
this);
117 connect(m_backupTimer, SIGNAL(timeout()),
this, SLOT(save()));
126 if (m_allTestEntries.
isEmpty()) {
128 m_allTestEntries = filter.
entries(
false);
133 foreach (
const TestEntry *entry, m_allTestEntries) {
135 KEduVocExpression *exp = entry->
entry();
137 int grade = exp->translation(languageTo)->grade();
138 int pregrade = exp->translation(languageTo)->preGrade();
139 if (exp->translation(languageTo)->text().isEmpty()) {
142 else if (pregrade > 0) {
171 void Collection::setDefaultDocumentProperties(KEduVocDocument *doc)
173 KEMailSettings emailSettings;
174 emailSettings.setProfile(emailSettings.defaultProfileName());
175 doc->setAuthor(emailSettings.getSetting(KEMailSettings::RealName));
176 doc->setAuthorContact(emailSettings.getSetting(KEMailSettings::EmailAddress));
178 doc->setLicense(i18n(
"Public Domain"));
179 doc->setCategory(i18n(
"Languages"));
181 QString locale = KGlobal::locale()->language();
183 doc->appendIdentifier();
184 doc->appendIdentifier();
185 doc->identifier(0).setName(KGlobal::locale()->languageCodeToName(locale));
186 doc->identifier(0).setLocale(locale);
187 doc->identifier(1).setName(i18n(
"A Second Language"));
188 doc->identifier(1).setLocale(locale);
190 KEduVocLesson* lesson =
new KEduVocLesson(i18n(
"Lesson 1"), doc->lesson());
191 doc->lesson()->appendChildContainer(lesson);
194 for (
int i = 0; i < 15 ; i++) {
195 lesson->appendEntry(
new KEduVocExpression());
198 doc->setModified(
false);
201 void Collection::initializeDefaultGrammar(KEduVocDocument *doc)
203 KEduVocWordType *root = doc->wordTypeContainer();
204 KEduVocWordType *noun =
new KEduVocWordType(i18n(
"Noun"), root);
205 noun->setWordType(KEduVocWordFlag::Noun);
206 root->appendChildContainer(noun);
208 KEduVocWordType *nounChild =
new KEduVocWordType(i18n(
"Masculine"), noun);
209 nounChild->setWordType(KEduVocWordFlag::Noun | KEduVocWordFlag::Masculine);
210 noun->appendChildContainer(nounChild);
211 nounChild =
new KEduVocWordType(i18n(
"Feminine"), noun);
212 nounChild->setWordType(KEduVocWordFlag::Noun | KEduVocWordFlag::Feminine);
213 noun->appendChildContainer(nounChild);
214 nounChild =
new KEduVocWordType(i18n(
"Neuter"), noun);
215 nounChild->setWordType(KEduVocWordFlag::Noun | KEduVocWordFlag::Neuter);
216 noun->appendChildContainer(nounChild);
218 KEduVocWordType *verb =
new KEduVocWordType(i18n(
"Verb"), root);
219 verb->setWordType(KEduVocWordFlag::Verb);
220 root->appendChildContainer(verb);
222 KEduVocWordType *adjective =
new KEduVocWordType(i18n(
"Adjective"), root);
223 adjective->setWordType(KEduVocWordFlag::Adjective);
224 root->appendChildContainer(adjective);
226 KEduVocWordType *adverb =
new KEduVocWordType(i18n(
"Adverb"), root);
227 adverb->setWordType(KEduVocWordFlag::Adverb);
228 root->appendChildContainer(adverb);
230 KEduVocWordType *conjunction =
new KEduVocWordType(i18n(
"Conjunction"), root);
231 conjunction->setWordType(KEduVocWordFlag::Conjunction);
232 root->appendChildContainer(conjunction);
KEduVocExpression * entry() const
void enableAutoBackup(bool enable)
Enable/disable the timed auto backup.
Collection(KEduVocDocument *doc, QObject *parent=0)
void documentChanged(KEduVocDocument *newDocument)
Emitted when the document pointer is changed.
void fetchGrammar(KEduVocDocument *doc, int languageIndex)
KEduVocDocument * eduVocDocument()
int count(const T &value) const
void close()
close the document
void setTitle(const QString &title)
int pregrades[KV_MAX_GRADE+1]
static int backupTime()
Get Time interval between two automatic backups.
void numDueWords(WordCount &wc)
int grades[KV_MAX_GRADE+1]
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QList< TestEntry * > entries(bool showDialog=true)
Returns the list of test entries after filtering out invalid entries according to the settings...