• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

parley

  • sources
  • kde-4.14
  • kdeedu
  • parley
  • src
parleydocument.cpp
Go to the documentation of this file.
1 /***************************************************************************
2 
3  Copyright 2007-2008 Frederik Gladhorn <frederik.gladhorn@kdemail.net>
4 
5  ***************************************************************************/
6 
7 /***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 
16 #include "parleydocument.h"
17 
18 #include "../config-parley.h"
19 #include "parleymainwindow.h"
20 #include "editor/editor.h"
21 #include "version.h"
22 #include "prefs.h"
23 
24 #include "vocabularyview.h"
25 #include "settings/documentproperties.h"
26 #include "dashboard/dashboard.h"
27 
28 #include <keduvoclesson.h>
29 #include <keduvocleitnerbox.h>
30 #include <keduvocexpression.h>
31 #include <keduvocwordtype.h>
32 
33 #include <KFileDialog>
34 #include <KRecentFilesAction>
35 #include <KStandardDirs>
36 #include <knewstuff3/downloaddialog.h>
37 #include <knewstuff3/uploaddialog.h>
38 #include <KEMailSettings>
39 #include <KMessageBox>
40 #include <KProcess>
41 #include <KTempDir>
42 
43 #include <QTimer>
44 #include <QtGui/QPrinter>
45 #include <QtGui/QPrintDialog>
46 
47 #ifdef HAVE_LIBXSLT
48 #include "exportdialog.h"
49 #include <libxml/parser.h>
50 #include <libxml/tree.h>
51 #include <libxslt/xslt.h>
52 #include <libxslt/xsltInternals.h>
53 #include <libxslt/transform.h>
54 #include <libxslt/xsltutils.h>
55 #endif
56 
57 #include "settings/languageproperties.h"
58 #include "settings/documentproperties.h"
59 
60 namespace DocumentHelper
61 {
62 void fetchGrammar(KEduVocDocument* doc, int languageIndex)
63 {
64  QString locale = doc->identifier(languageIndex).locale();
65 
66  KUrl location(QString("http://edu.kde.org/parley/locale/") + locale + QString(".kvtml"));
67 
68  KEduVocDocument grammarDoc;
69  if (grammarDoc.open(location) == KEduVocDocument::NoError) {
70  doc->identifier(languageIndex).setArticle(grammarDoc.identifier(0).article());
71  doc->identifier(languageIndex).setPersonalPronouns(grammarDoc.identifier(0).personalPronouns());
72  // @todo m_doc->identifier(index).setDeclension(grammarDoc.identifier(0).declension());
73  doc->identifier(languageIndex).setTenseList(grammarDoc.identifier(0).tenseList());
74  } else {
75  kDebug() << "Download of " << location.url() << " failed.";
76  }
77 }
78 } // namespace DocumentHelper
79 
80 ParleyDocument::ParleyDocument(ParleyMainWindow* parleyMainWindow)
81  : QObject(parleyMainWindow)
82  , m_parleyApp(parleyMainWindow)
83  , m_backupTimer(0)
84  , m_doc(new KEduVocDocument(this))
85 {
86 }
87 
88 ParleyDocument::~ParleyDocument()
89 {
90  close();
91  delete m_backupTimer;
92  m_doc->deleteLater();
93  emit documentChanged(0);
94 }
95 
96 
97 KEduVocDocument *ParleyDocument::document()
98 {
99  // If there is no present vocabulary document, create an empty one.
100  if (!m_doc) {
101  m_doc = new KEduVocDocument();
102  }
103 
104  return m_doc;
105 }
106 
107 void ParleyDocument::setTitle(const QString& title)
108 {
109  m_doc->setTitle(title);
110 }
111 
112 void ParleyDocument::slotFileNew()
113 {
114  if (queryClose()) {
115  newDocument(true);
116  }
117 }
118 
119 void ParleyDocument::newDocument(bool wizard)
120 {
121  KEduVocDocument *newDoc = new KEduVocDocument();
122 
123  initializeDefaultGrammar(newDoc);
124  setDefaultDocumentProperties(newDoc);
125  bool showGrammarDialog = false;
126  bool fetchGrammarOnline = false;
127  if (wizard) {
128  DocumentProperties* titleAuthorWidget = new DocumentProperties(newDoc, true, m_parleyApp);
129  KDialog* titleAuthorDialog;
130  titleAuthorDialog = new KDialog(m_parleyApp);
131  titleAuthorDialog->setMainWidget(titleAuthorWidget);
132  titleAuthorDialog->setCaption(i18nc("@title:window document properties", "Properties for %1", newDoc->url().url()));
133  connect(titleAuthorDialog, SIGNAL(accepted()), titleAuthorWidget, SLOT(accept()));
134  if (titleAuthorDialog->exec()) {
135  showGrammarDialog = titleAuthorWidget->grammarCheckBox->isChecked();
136  fetchGrammarOnline = titleAuthorWidget->downloadGrammarCheckBox->isChecked();
137  delete titleAuthorDialog;
138  } else {
139  delete titleAuthorDialog;
140  delete newDoc;
141  return;
142  }
143  }
144 
145  close();
146  if (m_doc) {
147  m_doc->deleteLater();
148  }
149  m_doc = newDoc;
150  emit documentChanged(m_doc);
151  enableAutoBackup(Prefs::autoBackup());
152 
153  if (fetchGrammarOnline) {
154  DocumentHelper::fetchGrammar(m_doc, 0);
155  DocumentHelper::fetchGrammar(m_doc, 1);
156  }
157  if (showGrammarDialog) {
158  languageProperties();
159  }
160 
161  m_parleyApp->showEditor();
162 }
163 
164 void ParleyDocument::slotFileOpen()
165 {
166  if ( queryClose() ) {
167  QCheckBox *practiceCheckBox = new QCheckBox(i18n("Open in practice &mode"));
168  practiceCheckBox->setChecked(m_parleyApp->currentComponent() != ParleyMainWindow::EditorComponent);
169  KFileDialog dialog(QString(), KEduVocDocument::pattern(KEduVocDocument::Reading), m_parleyApp, practiceCheckBox);
170  dialog.setCaption(i18n("Open Vocabulary Collection"));
171  if (dialog.exec()
172  && !dialog.selectedUrl().isEmpty()
173  && open(dialog.selectedUrl())
174  ) {
175  if (practiceCheckBox->isChecked()) {
176  m_parleyApp->showPracticeConfiguration();
177  } else {
178  m_parleyApp->showEditor();
179  }
180  }
181  }
182 }
183 
184 void ParleyDocument::slotFileOpenRecent(const KUrl& url)
185 {
186  if ( queryClose() && open(url)) {
187  m_parleyApp->showEditor();
188  }
189 }
190 
191 bool ParleyDocument::open(const KUrl & url)
192 {
193  if (url.path().isEmpty()) {
194  return false;
195  }
196 
197  close();
198 
199  if (m_doc) {
200  m_doc->deleteLater();
201  }
202  m_doc = new KEduVocDocument(this);
203  emit documentChanged(m_doc);
204  m_doc->setCsvDelimiter(Prefs::separator());
205 
206  bool isSuccess = false, isError = false;
207 
208  KEduVocDocument::ErrorCode ret = m_doc->open(url, KEduVocDocument::FileDefaultHandling);
209  switch ( ret ) {
210  case KEduVocDocument::NoError :
211  isSuccess = true;
212  break;
213  case KEduVocDocument::FileLocked :
214  {
215  int exit = KMessageBox::warningYesNo(
216  m_parleyApp, i18n("The vocabulary collection is locked by another process. You can open the file if you take over the lock, but you will lose any changes from the other process.\n\nDo you want to take over the lock?\n"), i18n( "Take Over Lock" ) ) ;
217  if ( exit == KMessageBox::Yes ) { //attempt to steal lock
218 
219  ret = m_doc->open(url, KEduVocDocument::FileIgnoreLock);
220  if ( ret == KEduVocDocument::NoError ) {
221  kDebug() << "Lock stolen";
222  isSuccess = true;
223  } else {
224  isError = true;
225  }
226  } else { //Don't Steal continue work without saving !!!
227  }
228 
229  break;
230  }
231  default:
232  isError = true;
233  }
234 
235  if ( isSuccess ) {
236  m_parleyApp->addRecentFile(url, m_doc->title());
237 
238  enableAutoBackup(Prefs::autoBackup());
239 
240  } else {
241  if ( isError ) {
242  KMessageBox::error(
243  m_parleyApp, i18n("Opening collection \"%1\" resulted in an error: %2", m_doc->url().url(),
244  m_doc->errorDescription(ret)), i18nc("@title:window", "Open Collection"));
245  }
246  m_doc->deleteLater();
247  emit documentChanged(0);
248  m_doc = 0;
249  }
250 
251  return isSuccess;
252 }
253 
254 void ParleyDocument::close()
255 {
256  enableAutoBackup(false);
257  if (m_doc) {
258  emit documentChanged(0);
259  m_doc->deleteLater();
260  m_doc = 0;
261  }
262 }
263 
264 bool ParleyDocument::queryClose()
265 {
266  if ( (m_doc == NULL ) || !m_doc->isModified()) {
267  return true;
268  }
269 
270  Prefs::self()->writeConfig();
271 
272  bool canSave = Prefs::autoSave(); //save without asking
273 
274  if (!canSave) {
275  int exit = KMessageBox::warningYesNoCancel(
276  m_parleyApp, i18n("Vocabulary is modified.\n\nSave file before exit?\n"),
277  "", KStandardGuiItem::save(), KStandardGuiItem::discard());
278  switch ( exit ) {
279  case KMessageBox::Yes :
280  canSave = true; // save and exit
281  break;
282  case KMessageBox::No :
283  canSave = false; // don't save but exit
284  break;
285  case KMessageBox::Continue :
286  default:
287  return false; // continue work without saving !!!
288  }
289  }
290 
291  if (canSave) {
292  save(); // save and exit
293  }
294 
295  close();
296  return true;
297 }
298 
299 
300 void ParleyDocument::openGHNS()
301 {
302  if (m_parleyApp->queryClose()) {
303  QString downloadDir = KStandardDirs::locateLocal("data", "kvtml/");
304  KUrl url = KFileDialog::getOpenUrl(
305  downloadDir,
306  KEduVocDocument::pattern(KEduVocDocument::Reading),
307  m_parleyApp,
308  i18n("Open Downloaded Vocabulary Collection"));
309  if (open(url)) {
310  m_parleyApp->showPracticeConfiguration();
311  }
312  }
313 }
314 
315 void ParleyDocument::save()
316 {
317  if (m_doc->url().fileName() == i18n("Untitled")) {
318  saveAs();
319  return;
320  }
321 
322  // remove previous backup
323  QFile::remove(m_doc->url().toLocalFile() + '~');
324  QFile::copy(QFile::encodeName(m_doc->url().toLocalFile()), QFile::encodeName(m_doc->url().toLocalFile() + '~'));
325 
326  m_doc->setCsvDelimiter(Prefs::separator());
327 
328  emit statesNeedSaving();
329 
330  QString newgenerator = QString::fromLatin1("Parley ") + PARLEY_VERSION_STRING ;
331  m_doc->setGenerator(newgenerator);
332 
333  bool isSuccess = false, isError = false ;
334 
335  KEduVocDocument::ErrorCode ret = m_doc->saveAs(
336  m_doc->url() , KEduVocDocument::Automatic, KEduVocDocument::FileIgnoreLock);
337 
338  switch ( ret ) {
339  case KEduVocDocument::NoError :
340  isSuccess = true;
341  break;
342  case KEduVocDocument::FileLocked :
343  {
344  int exit = KMessageBox::warningYesNo(
345  m_parleyApp, i18n("File \"%1\" is locked by another process. You can save to the file if you take over the lock, but you will lose any changes from the other process.\n\nDo you want to take over the lock?\n"
346  , m_doc->url().url()), "");
347  if ( exit == KMessageBox::Yes ) {
348  m_doc->setGenerator(newgenerator );
349  ret = m_doc->saveAs(m_doc->url() , KEduVocDocument::Automatic, KEduVocDocument::FileIgnoreLock);
350 
351  if ( ret == KEduVocDocument::NoError ) {
352  isSuccess = true;
353  kDebug() << "Lock stolen";
354  } else {
355  isError = true;
356  }
357  } else {
358  //Intentionally empty else. Try to saveAs another filename
359  }
360  break;
361  }
362  default:
363  isError = true;
364  }
365 
366  if ( isSuccess ) {
367  m_parleyApp->addRecentFile(m_doc->url(), m_doc->title());
368  enableAutoBackup(Prefs::autoBackup());
369  } else {
370  if ( isError ) {
371  KMessageBox::error(
372  m_parleyApp, i18n("Writing file \"%1\" resulted in an error: %2", m_doc->url().url(),
373  m_doc->errorDescription(ret)), i18nc("@title:window", "Save File"));
374  }
375  kDebug() << "Save failed trying save as for "<< m_doc->url().url();
376  saveAs();
377  }
378 
379 }
380 
381 void ParleyDocument::saveAs(KUrl url)
382 {
383  if (!m_doc) {
384  return;
385  }
386 
387  if (url.isEmpty()) {
388  url = KFileDialog::getSaveUrl(QString(),
389  KEduVocDocument::pattern(KEduVocDocument::Writing),
390  m_parleyApp->parentWidget(),
391  i18n("Save Vocabulary As"));
392  if (url.isEmpty()) {
393  return;
394  }
395  }
396 
397  QFileInfo fileinfo(url.toLocalFile());
398  if (fileinfo.exists()) {
399  if (KMessageBox::warningContinueCancel(
400  0, i18n("<qt>The file<p><b>%1</b></p>already exists. Do you want to overwrite it?</qt>",
401  url.toLocalFile()), QString(), KStandardGuiItem::overwrite()) == KMessageBox::Cancel) {
402  return;
403  }
404  }
405 
406  QString msg = i18nc("@info:status saving a file", "Saving %1", url.toLocalFile());
407 
408  QFile::remove(url.toLocalFile() + '~'); // remove previous backup
409  QFile::copy(QFile::encodeName(url.toLocalFile()), QFile::encodeName(QString(url.toLocalFile() + '~')));
410 
411  m_doc->setCsvDelimiter(Prefs::separator());
412 
413  if (!url.fileName().contains('.')) {
414  url.setFileName(url.fileName() + QString::fromLatin1(".kvtml"));
415  }
416 
417  bool isSuccess = false, isError = false;
418  int ret = m_doc->saveAs(url, KEduVocDocument::Automatic, "Parley");
419  switch ( ret ) {
420  case KEduVocDocument::NoError :
421  isSuccess = true;
422  break;
423  case KEduVocDocument::FileLocked :
424  {
425  int exit = KMessageBox::warningYesNo(
426  m_parleyApp, i18n("File \"%1\" is locked by another process. You can save to the file if you take over the lock, but you will lose any changes from the other process.\n\nDo you want to take over the lock?\n"
427  , m_doc->url().url()), "");
428  if ( exit == KMessageBox::Yes ) { //attempt lock steal
429  m_doc->setGenerator(QString::fromLatin1("Parley ") + PARLEY_VERSION_STRING );
430  ret = m_doc->saveAs(
431  m_doc->url() , KEduVocDocument::Automatic, KEduVocDocument::FileIgnoreLock);
432 
433  if ( ret == KEduVocDocument::NoError ) {
434  isSuccess = true;
435  kDebug() << "Lock stolen";
436  } else {
437  isError = true;
438  }
439  break;
440  } else { //don't steal the lock
441  }
442 
443  break;
444  }
445  default:
446  isError = true;
447  break;
448  }
449 
450  if ( isSuccess ) {
451  kDebug() << "SaveAs success.";
452  m_parleyApp->addRecentFile(m_doc->url(), m_doc->title());
453  emit statesNeedSaving();
454 
455  } else {
456  kDebug() << "SaveAs failed for "<< m_doc->url().url()<<" \nwhy "<< m_doc->errorDescription(ret);
457  if ( isError ) {
458  KMessageBox::error(
459  m_parleyApp, i18n("Writing file \"%1\" resulted in an error: %2",
460  m_doc->url().url(), m_doc->errorDescription(ret)), i18nc("@title:window", "Save File"));
461 
462  }
463  }
464 
465 }
466 
467 void ParleyDocument::initializeDefaultGrammar(KEduVocDocument *doc)
468 {
469  KEduVocWordType *root = doc->wordTypeContainer();
470  KEduVocWordType *noun = new KEduVocWordType(i18n("Noun"), root);
471  noun->setWordType(KEduVocWordFlag::Noun);
472  root->appendChildContainer(noun);
473 
474  KEduVocWordType *nounChild = new KEduVocWordType(i18n("Masculine"), noun);
475  nounChild->setWordType(KEduVocWordFlag::Noun | KEduVocWordFlag::Masculine);
476  noun->appendChildContainer(nounChild);
477  nounChild = new KEduVocWordType(i18n("Feminine"), noun);
478  nounChild->setWordType(KEduVocWordFlag::Noun | KEduVocWordFlag::Feminine);
479  noun->appendChildContainer(nounChild);
480  nounChild = new KEduVocWordType(i18n("Neuter"), noun);
481  nounChild->setWordType(KEduVocWordFlag::Noun | KEduVocWordFlag::Neuter);
482  noun->appendChildContainer(nounChild);
483 
484  KEduVocWordType *verb = new KEduVocWordType(i18n("Verb"), root);
485  verb->setWordType(KEduVocWordFlag::Verb);
486  root->appendChildContainer(verb);
487 
488  KEduVocWordType *adjective = new KEduVocWordType(i18n("Adjective"), root);
489  adjective->setWordType(KEduVocWordFlag::Adjective);
490  root->appendChildContainer(adjective);
491 
492  KEduVocWordType *adverb = new KEduVocWordType(i18n("Adverb"), root);
493  adverb->setWordType(KEduVocWordFlag::Adverb);
494  root->appendChildContainer(adverb);
495 
496  KEduVocWordType *conjunction = new KEduVocWordType(i18n("Conjunction"), root);
497  conjunction->setWordType(KEduVocWordFlag::Conjunction);
498  root->appendChildContainer(conjunction);
499 }
500 
501 
502 void ParleyDocument::setDefaultDocumentProperties(KEduVocDocument *doc)
503 {
504  KEMailSettings emailSettings;
505  emailSettings.setProfile(emailSettings.defaultProfileName());
506  doc->setAuthor(emailSettings.getSetting(KEMailSettings::RealName));
507  doc->setAuthorContact(emailSettings.getSetting(KEMailSettings::EmailAddress));
508 
509  doc->setLicense(i18n("Public Domain"));
510  doc->setCategory(i18n("Languages"));
511 
512  QString locale = KGlobal::locale()->language();
513 
514  doc->appendIdentifier();
515  doc->appendIdentifier();
516  doc->identifier(0).setName(KGlobal::locale()->languageCodeToName(locale));
517  doc->identifier(0).setLocale(locale);
518  doc->identifier(1).setName(i18n("A Second Language"));
519  doc->identifier(1).setLocale(locale);
520 
521  KEduVocLesson* lesson = new KEduVocLesson(i18n("Lesson 1"), doc->lesson());
522  doc->lesson()->appendChildContainer(lesson);
523 
524  // add some entries
525  for (int i = 0; i < 15 ; i++) {
526  lesson->appendEntry(new KEduVocExpression());
527  }
528 
529  doc->setModified(false);
530 }
531 
532 void ParleyDocument::slotGHNS()
533 {
534  QString fileName;
535  KNS3::DownloadDialog newStuffDialog(ParleyMainWindow::instance());
536  newStuffDialog.exec();
537  KNS3::Entry::List entries = newStuffDialog.installedEntries();
538  int numberInstalled = entries.size();
539  foreach (const KNS3::Entry & entry, entries) {
540  // check mime type and if kvtml, open it
541  foreach (const QString & file, entry.installedFiles()) {
542  KMimeType::Ptr mimeType = KMimeType::findByPath(file);
543  kDebug() << "KNS2 file of mime type:" << KMimeType::findByPath(file)->name();
544  if (mimeType->is("application/x-kvtml")) {
545  ParleyMainWindow::instance()->addRecentFile(file, QString());
546  fileName = file;
547  }
548  }
549  }
550 
551  // to enable the display in the dashboard
552  Prefs::self()->writeConfig();
553  m_parleyApp->updateRecentFilesModel();
554  if (numberInstalled > 1) {
555  openGHNS();
556  } else if (numberInstalled == 1) {
557  if (open(KUrl(fileName)))
558  m_parleyApp->showPracticeConfiguration();
559  else
560  KMessageBox::error(m_parleyApp, i18n("Could not open vocabulary collection \"%1\"", entries.first().name()));
561  }
562 }
563 
564 void ParleyDocument::documentProperties()
565 {
566  DocumentProperties* titleAuthorWidget = new DocumentProperties(m_doc, false, m_parleyApp);
567  KDialog* titleAuthorDialog;
568  titleAuthorDialog = new KDialog(m_parleyApp);
569  titleAuthorDialog->setMainWidget(titleAuthorWidget);
570 
571  // the language options are only shown, when this is used to create a new document.
572  titleAuthorWidget->languageGroupBox->setVisible(false);
573  titleAuthorDialog->setCaption(i18nc("@title:window document properties", "Properties for %1", m_doc->url().url()));
574  connect(titleAuthorDialog, SIGNAL(accepted()), titleAuthorWidget, SLOT(accept()));
575  titleAuthorDialog->exec();
576  delete titleAuthorDialog;
577  emit documentChanged(m_doc);
578 }
579 
580 void ParleyDocument::languageProperties()
581 {
582  LanguageProperties properties(m_doc, m_parleyApp);
583  if (properties.exec() == KDialog::Accepted) {
584  emit languagesChanged();
585  }
586 }
587 
588 void ParleyDocument::uploadFile()
589 {
590  // save file to temp location
591  KTempDir dir;
592  KUrl url(dir.name() + m_doc->url().fileName());
593  kDebug() << "save in " << url.url();
594  if ( m_doc->saveAs(url, KEduVocDocument::Automatic, "Parley") != KEduVocDocument::NoError ) {
595  KMessageBox::error(m_parleyApp, i18n("Could not save vocabulary collection \"%1\"", url.fileName() ));
596  return;
597  }
598 
599  KEduVocDocument tempDoc(this);
600  if ( tempDoc.open(url) != KEduVocDocument::NoError ) {
601  KMessageBox::error(m_parleyApp, i18n("Could not open vocabulary collection \"%1\"", url.fileName() ));
602  return;
603  }
604 
605  // remove grades
606  tempDoc.lesson()->resetGrades(-1, KEduVocContainer::Recursive);
607  if ( tempDoc.saveAs(url, KEduVocDocument::Automatic, "Parley") != KEduVocDocument::NoError ) {
608  KMessageBox::error(m_parleyApp, i18n("Could not save vocabulary collection \"%1\"", url.fileName() ));
609  return;
610  }
611 
612  // upload
613  KNS3::UploadDialog dialog(ParleyMainWindow::instance());
614  dialog.setUploadFile(url);
615  dialog.exec();
616 }
617 
618 
619 void ParleyDocument::exportDialog()
620 {
621 #ifdef HAVE_LIBXSLT
622  ExportDialog dialog(this, m_parleyApp);
623  dialog.exec();
624 #endif
625 }
626 
627 void ParleyDocument::slotFileMerge()
628 {
630 // KUrl url = KFileDialog::getOpenUrl(QString(), KEduVocDocument::pattern(KEduVocDocument::Reading), parentWidget(), i18n("Merge Vocabulary File"));
631  //
632 // if (!url.isEmpty()) {
633 // QString msg = i18n("Loading %1", url.path());
634 // slotStatusMsg(msg);
635  //
636 // KEduVocDocument *new_doc = new KEduVocDocument(this);
637 // new_doc->setCsvDelimiter(Prefs::separator());
638 // new_doc->open(url);
639  //
640 // m_doc->merge(new_doc, true);
641  //
642 // KEduVocWordFlag::setTenseNames(m_doc->tenseDescriptions());
643 // KVTUsage::setUsageNames(m_doc->usageDescriptions());
644  //
645 // delete(new_doc);
646 // m_recentFilesAction->addUrl(url);
647 // m_tableModel->reset();
648 // m_lessonModel->setDocument(m_doc);
649 // m_tableView->adjustContent();
650 // }
651 }
652 
653 void ParleyDocument::enableAutoBackup(bool enable)
654 {
655  if (!enable) {
656  if (m_backupTimer) {
657  m_backupTimer->stop();
658  }
659  } else {
660  if (!m_backupTimer) {
661  m_backupTimer = new QTimer(this);
662  connect(m_backupTimer, SIGNAL(timeout()), this, SLOT(save()));
663  }
664  m_backupTimer->start(Prefs::backupTime() * 60 * 1000);
665  }
666 }
667 
668 #include "parleydocument.moc"
ParleyDocument::ParleyDocument
ParleyDocument(ParleyMainWindow *parleyMainWindow)
Definition: parleydocument.cpp:80
ParleyMainWindow::currentComponent
Component currentComponent()
Definition: parleymainwindow.cpp:418
ParleyDocument::documentChanged
void documentChanged(KEduVocDocument *newDocument)
Emitted when the document pointer is changed.
PARLEY_VERSION_STRING
#define PARLEY_VERSION_STRING
Definition: version.h:3
ParleyDocument::statesNeedSaving
void statesNeedSaving()
ParleyDocument::languageProperties
void languageProperties()
Definition: parleydocument.cpp:580
ParleyDocument::setTitle
void setTitle(const QString &title)
Definition: parleydocument.cpp:107
Prefs::autoSave
static bool autoSave()
Get If true, vocabularies are automatically saved on close and exit.
Definition: prefs.h:165
ParleyMainWindow::showEditor
void showEditor()
Definition: parleymainwindow.cpp:267
ParleyMainWindow::queryClose
bool queryClose()
When quitting, ask for confirmation if the doc has not been saved.
Definition: parleymainwindow.cpp:209
ParleyDocument::documentProperties
void documentProperties()
General doc properties like title, author etc.
Definition: parleydocument.cpp:564
QFile::remove
bool remove()
ParleyDocument::slotFileMerge
void slotFileMerge()
merge a document
Definition: parleydocument.cpp:627
ParleyDocument::exportDialog
void exportDialog()
Definition: parleydocument.cpp:619
ParleyMainWindow
Definition: parleymainwindow.h:41
DocumentHelper::fetchGrammar
void fetchGrammar(KEduVocDocument *doc, int languageIndex)
Definition: parleydocument.cpp:62
ParleyDocument::slotFileOpenRecent
void slotFileOpenRecent(const KUrl &url)
opens a file from the recent files menu
Definition: parleydocument.cpp:184
QWidget::setVisible
virtual void setVisible(bool visible)
ParleyDocument::document
KEduVocDocument * document()
Definition: parleydocument.cpp:97
KDialog
prefs.h
ParleyDocument::queryClose
bool queryClose()
When quitting, ask for confirmation if the doc has not been saved.
Definition: parleydocument.cpp:264
ParleyDocument::slotFileOpen
void slotFileOpen()
open a document
Definition: parleydocument.cpp:164
QFile::copy
bool copy(const QString &newName)
editor.h
Prefs::self
static Prefs * self()
Definition: prefs.cpp:17
ParleyDocument::save
void save()
save a document
Definition: parleydocument.cpp:315
ParleyMainWindow::EditorComponent
Definition: parleymainwindow.h:54
parleydocument.h
ParleyDocument::newDocument
void newDocument(bool wizard)
Definition: parleydocument.cpp:119
exportdialog.h
ParleyMainWindow::instance
static ParleyMainWindow * instance()
Definition: parleymainwindow.cpp:55
QTimer
ParleyMainWindow::showPracticeConfiguration
void showPracticeConfiguration()
Definition: parleymainwindow.cpp:272
QObject
QCheckBox
LanguageProperties
Definition: languageproperties.h:22
ExportDialog
Definition: exportdialog.h:24
QString
ParleyDocument::enableAutoBackup
void enableAutoBackup(bool enable)
Enable/disable the timed auto backup.
Definition: parleydocument.cpp:653
documentproperties.h
languageproperties.h
QFileInfo
ParleyDocument::openGHNS
void openGHNS()
open a downloaded (knewstuff/get hot new stuff) document
Definition: parleydocument.cpp:300
QTimer::stop
void stop()
version.h
ParleyDocument::~ParleyDocument
~ParleyDocument()
Definition: parleydocument.cpp:88
QAbstractButton::setChecked
void setChecked(bool)
ParleyDocument::uploadFile
void uploadFile()
upload the current file
Definition: parleydocument.cpp:588
parleymainwindow.h
Prefs::backupTime
static int backupTime()
Get Time interval between two automatic backups.
Definition: prefs.h:222
ParleyDocument::slotGHNS
void slotGHNS()
download new vocabularies
Definition: parleydocument.cpp:532
ParleyMainWindow::updateRecentFilesModel
void updateRecentFilesModel()
update the list of recent files in the dashboard
Definition: parleymainwindow.cpp:141
DocumentProperties
Definition: documentproperties.h:33
Prefs::autoBackup
static bool autoBackup()
Get If true, a backup is saved every BackupTime minutes.
Definition: prefs.h:203
QString::fromLatin1
QString fromLatin1(const char *str, int size)
QTimer::start
void start(int msec)
ParleyMainWindow::addRecentFile
void addRecentFile(const KUrl &url, const QString &name)
add a new entry to the list of recent files
Definition: parleymainwindow.cpp:118
ParleyDocument::open
bool open(const KUrl &)
Opens the given url, displays an error message and returns false on failure.
Definition: parleydocument.cpp:191
QObject::connect
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
ParleyDocument::close
void close()
close the document
Definition: parleydocument.cpp:254
dashboard.h
ParleyDocument::saveAs
void saveAs(KUrl file=KUrl())
Definition: parleydocument.cpp:381
ParleyDocument::slotFileNew
void slotFileNew()
open a new application window
Definition: parleydocument.cpp:112
QFile::encodeName
QByteArray encodeName(const QString &fileName)
vocabularyview.h
Prefs::separator
static QString separator()
Get This sets the separator used when copying/pasting text, default is Tab.
Definition: prefs.h:108
ParleyDocument::languagesChanged
void languagesChanged()
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:15:56 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

parley

Skip menu "parley"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal