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

parley

parley.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002 
00003                       main part of parley
00004 
00005     -----------------------------------------------------------------------
00006 
00007     begin         : Thu Mar 11 20:50:53 MET 1999
00008 
00009     copyright     : (C) 1999-2001 Ewald Arnold <kvoctrain@ewald-arnold.de>
00010                     (C) 2004-2007 Peter Hedlund <peter.hedlund@kdemail.net>
00011                     (C) 2007-2008 Frederik Gladhorn <frederik.gladhorn@kdemail.net>
00012     -----------------------------------------------------------------------
00013 
00014  ***************************************************************************/
00015 
00016 /***************************************************************************
00017  *                                                                         *
00018  *   This program is free software; you can redistribute it and/or modify  *
00019  *   it under the terms of the GNU General Public License as published by  *
00020  *   the Free Software Foundation; either version 2 of the License, or     *
00021  *   (at your option) any later version.                                   *
00022  *                                                                         *
00023  ***************************************************************************/
00024 
00025 #include "parley.h"
00026 
00027 #include "../config-parley.h"
00028 
00029 #include "practiceold/testentrymanager.h"
00030 #include "practice/parleypracticemainwindow.h"
00031 
00032 #include "vocabulary/vocabularymodel.h"
00033 #include "vocabulary/vocabularyview.h"
00034 #include "vocabulary/vocabularyfilter.h"
00035 #include "vocabulary/containerview.h"
00036 #include "vocabulary/lessonview.h"
00037 #include "vocabulary/wordtypeview.h"
00038 #include "vocabulary/containermodel.h"
00039 #include "vocabulary/lessonmodel.h"
00040 #include "vocabulary/wordtypemodel.h"
00041 #include "vocabulary/leitnerview.h"
00042 #include "vocabulary/leitnermodel.h"
00043 
00044 #include "entry-dialogs/multiplechoicewidget.h"
00045 #include "entry-dialogs/comparisonwidget.h"
00046 #include "entry-dialogs/conjugationwidget.h"
00047 #include "entry-dialogs/declensionwidget.h"
00048 #include "entry-dialogs/imagechooserwidget.h"
00049 #include "entry-dialogs/audiowidget.h"
00050 #include "entry-dialogs/browserwidget.h"
00051 #include "entry-dialogs/synonymwidget.h"
00052 #include "entry-dialogs/summarywordwidget.h"
00053 
00054 #include "statistics-dialogs/StatisticsDialog.h"
00055 #include "settings/parleyprefs.h"
00056 #include "settings/TitlePage.h"
00057 #include "settings/languageproperties.h"
00058 #include "configure-practice/configurepracticedialog.h"
00059 #include "prefs.h"
00060 
00061 #include "scripts/scriptdialog.h"
00062 #include "scripts/scripting/parley.h"
00063 #include "scripts/scripting/expression.h"
00064 #include "scripts/translator.h"
00065 
00066 #include "welcomescreen/welcomescreen.h"
00067 
00068 #include <keduvoclesson.h>
00069 #include <keduvocexpression.h>
00070 
00071 #include <KLineEdit>
00072 #include <KStatusBar>
00073 
00074 #include <KActionCollection>
00075 #include <KRecentFilesAction>
00076 #include <KToggleAction>
00077 #include <KActionMenu>
00078 #include <KMenuBar>
00079 #include <KMessageBox>
00080 #include <KTipDialog>
00081 #include <KCharSelect>
00082 #include <knewstuff2/ui/knewstuffaction.h>
00083 
00084 #include <QtCore/QTimer>
00085 #include <QtGui/QDockWidget>
00086 #include <QtGui/QHeaderView>
00087 #include <QtGui/QStackedWidget>
00088 
00089 #include "modeltest/modeltest.h"
00090 
00091 
00092 ParleyApp::ParleyApp(const QString& appName, const KUrl & filename) : KXmlGuiWindow(0)
00093 {
00094     m_appName = appName;
00095     m_document = new ParleyDocument(this);
00096     m_searchLine = 0;
00097     m_searchWidget = 0;
00098     m_pronunciationStatusBarLabel = 0;
00099     m_remarkStatusBarLabel = 0;
00100     m_typeStatusBarLabel = 0;
00101     m_conjugationWidget = 0;
00102 
00103     m_entryDlg = 0;
00104 
00105     initStatusBar();
00106 
00107     setCorner(Qt::TopLeftCorner, Qt::LeftDockWidgetArea);
00108     setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea);
00109     setCorner(Qt::TopRightCorner, Qt::RightDockWidgetArea);
00110     setCorner(Qt::BottomRightCorner, Qt::RightDockWidgetArea);
00111 
00112     initView();
00113     initModel();
00114 
00115     initWelcomeScreen();
00116 
00117     initDockWidgets();
00118 
00119     initActions();
00120 
00121     // these connects need the model to exist
00122 //     QAction * actionRestoreNativeOrder = actionCollection()->action("restore_native_order");
00123 //     m_tableView->horizontalHeader()->addAction(actionRestoreNativeOrder);
00124 //     connect(actionRestoreNativeOrder, SIGNAL(triggered()), m_sortFilterModel, SLOT(restoreNativeOrder()));
00125     
00126     bool showWelcomeScreen = false;
00127     
00128     if ( !filename.url().isEmpty() ) {
00129         kDebug() << "open doc" << filename.url();
00130         m_document->open(filename);
00131         kDebug() << "open done";
00132     } else {
00133         bool openLastFile = Prefs::autoOpenLast();
00134         if (openLastFile && m_recentFilesAction->actions().count() > 0
00135             && m_recentFilesAction->action(m_recentFilesAction->actions().count()-1)->isEnabled() ) {
00136             m_recentFilesAction->action(m_recentFilesAction->actions().count()-1)->trigger();
00137         } else {
00138             kDebug() << "new doc";
00139             m_document->newDocument();
00140             updateDocument();
00141             if (!openLastFile) {
00142                 showWelcomeScreen = true;
00143             }
00144         }
00145     }
00146 
00147     if (!initialGeometrySet()) {
00148         resize(QSize(800, 600).expandedTo(minimumSizeHint()));
00149     }
00150     setupGUI(ToolBar | Keys | StatusBar | Create);
00151 
00152     // save position of dock windows etc
00153     setAutoSaveSettings();
00154 
00155     initScripts();
00156     
00157     if (showWelcomeScreen) {
00158         setShowWelcomeScreen(true);
00159     }
00160 
00161     // finally show tip-of-day ( if the user wants it :) )
00162     QTimer::singleShot( 0, this, SLOT( startupTipOfDay() ) );
00163 }
00164 
00165 void ParleyApp::saveOptions()
00166 {
00167     m_recentFilesAction->saveEntries(KGlobal::config()->group("Recent Files"));
00168     m_downloadedFilesAction->saveEntries(KGlobal::config()->group("Downloaded Files"));
00169 
00171 //     if (m_tableView) {
00172 //         // map to original entry numbers:
00173 //         QModelIndex sourceIndex = m_sortFilterModel->mapToSource(m_tableView->currentIndex());
00174 //         Prefs::setCurrentRow(sourceIndex.row());
00175 //         Prefs::setCurrentCol(sourceIndex.column());
00176 //     }
00177     Prefs::self()->writeConfig();
00178 }
00179 
00180 void ParleyApp::slotUpdateWindowCaption()
00181 {
00182     setCaption(m_document->document()->title(), m_document->document()->isModified());
00183 //     slotStatusMsg(IDS_DEFAULT);
00184 }
00185 
00186 void ParleyApp::slotShowStatistics()
00187 {
00188     StatisticsDialog statisticsDialog(m_document->document(), this);
00189     statisticsDialog.exec();
00190 }
00191 
00192 void ParleyApp::slotGeneralOptions()
00193 {
00194     ParleyPrefs* dialog = new ParleyPrefs(m_document->document(), this, "settings",  Prefs::self());
00195     connect(dialog, SIGNAL(settingsChanged(const QString &)), this, SLOT(slotApplyPreferences()));
00196     dialog->show();
00197 }
00198 
00199 
00200 void ParleyApp::slotApplyPreferences()
00201 {
00202     m_document->enableAutoBackup(Prefs::autoBackup());
00203 
00204     if (m_pronunciationStatusBarLabel) {
00205         m_pronunciationStatusBarLabel->setFont(Prefs::iPAFont());
00206     }
00207 
00208     m_vocabularyView->setFont(Prefs::tableFont());
00209     m_vocabularyView->reset();
00210 }
00211 
00212 void ParleyApp::slotCloseDocument()
00213 {
00214     if (!queryClose()) {
00215         return;
00216     }
00217     m_document->newDocument();
00218     updateDocument();
00219     setShowWelcomeScreen(true);
00220 }
00221 
00222 
00223 // void ParleyApp::slotStatusHelpMsg(const QString &text)
00224 // {
00225 //     ///////////////////////////////////////////////////////////////////
00226 //     // change status message of whole statusbar temporary (text, msec)
00227 //     if (pbar == 0 || !pbar->isVisible()) {
00228 //         statusBar()->showMessage(text, 3000);
00229 //     }
00230 // }
00231 
00232 
00233 
00234 
00235 void ParleyApp::slotConfigShowSearch()
00236 {
00237     if (m_searchWidget) {
00238         m_searchWidget->setVisible(m_searchWidget->isHidden());
00239         Prefs::setShowSearch(m_searchWidget->isVisible());
00240     }
00241 }
00242 
00243 void ParleyApp::slotDocumentProperties()
00244 {
00245     TitlePage* titleAuthorWidget = new TitlePage(m_document->document(), this);
00246     KDialog* titleAuthorDialog;
00247     titleAuthorDialog = new KDialog(this);
00248     titleAuthorDialog->setMainWidget( titleAuthorWidget );
00249     titleAuthorDialog->setCaption(i18nc("@title:window document properties", "Properties for %1", m_document->document()->url().url()));
00250     if ( titleAuthorDialog->exec() == KDialog::Accepted ) {
00251         titleAuthorWidget->commitData();
00252     }
00253     slotUpdateWindowCaption();
00254     delete titleAuthorDialog;
00255 }
00256 
00257 void ParleyApp::configurePractice()
00258 {
00259     ConfigurePracticeDialog* configurePracticeDialog;
00260     configurePracticeDialog = new ConfigurePracticeDialog(m_document->document(), this, "practice settings",  Prefs::self());
00261 
00262     if ( configurePracticeDialog->exec() == ConfigurePracticeDialog::StartPractice ) {
00263         startPractice();
00264     }
00265 }
00266 
00267 void ParleyApp::startPractice()
00268 {
00269     if (Prefs::oldPractice()) {
00270         hide();
00271         TestEntryManager testManager(m_document->document(), this);
00272         testManager.startPractice();
00273         show();
00274     } else {
00275         hide();
00276         ParleyPracticeMainWindow* window = new ParleyPracticeMainWindow(m_document->document(), this);
00277         connect(window, SIGNAL(signalPracticeFinished()), this, SLOT(show()));
00278         window->show();
00279     }
00280 }
00281 
00282 
00283 void ParleyApp::slotConfigOldPractice(bool old)
00284 {
00285 kDebug() << "slot config old practice";
00286     Prefs::setOldPractice(old);
00287 }
00288 
00289 void ParleyApp::closeEvent(QCloseEvent *event)
00290 {
00291     // hide the welcome screen to prevent the dock widgets to be hidden when saving the window state
00292     setShowWelcomeScreen(false);
00293     KXmlGuiWindow::closeEvent(event);
00294 }
00295 
00296 bool ParleyApp::queryClose()
00297 {
00298     bool erg = queryExit();
00299     if (erg)
00300         m_document->document()->setModified(false);  // avoid double query on exit via system menu
00301     return erg;
00302 }
00303 
00304 
00305 bool ParleyApp::queryExit()
00306 {
00307     saveOptions();
00308     if (!m_document->document()->isModified()) {
00309         return true;
00310     }
00311 
00312     bool save = Prefs::autoSave(); //save without asking
00313 
00314     if (!save) {
00315         int exit = KMessageBox::warningYesNoCancel(this, i18n("Vocabulary is modified.\n\nSave file before exit?\n"),
00316                 "", KStandardGuiItem::save(), KStandardGuiItem::discard());
00317         if (exit == KMessageBox::Yes) {
00318             save = true;   // save and exit
00319         } else if (exit == KMessageBox::No) {
00320             save = false;  // don't save but exit
00321         } else {
00322             return false;  // continue work
00323         }
00324     }
00325 
00326     if (save) {
00327         m_document->save();       // save and exit
00328     }
00329     return true;
00330 }
00331 
00332 
00333 void ParleyApp::updateDocument()
00334 {
00336     m_vocabularyModel->setDocument(m_document->document());
00337 
00338     m_lessonModel->setDocument(m_document->document());
00339     m_wordTypeModel->setDocument(m_document->document());
00340     m_leitnerModel->setDocument(m_document->document());
00341 
00342     // expand the root items
00343     m_lessonView->expandToDepth(0);
00344     m_wordTypeView->expandToDepth(0);
00345 
00346     // the top level container of this model only holds the others
00347     m_leitnerView->setRootIndex(m_leitnerModel->index(0,0));
00348 
00349     connect(m_document->document(), SIGNAL(docModified(bool)), this, SLOT(slotUpdateWindowCaption()));
00350     connect(m_document->document(), SIGNAL(docModified(bool)), m_document, SLOT(slotDocumentChanged(bool)));
00351     connect(m_vocabularyModel, SIGNAL(documentChanged(KEduVocDocument*)),
00352             m_summaryWordWidget, SLOT(slotDocumentChanged(KEduVocDocument *)));
00353     connect(m_vocabularyView->selectionModel(), 
00354                 SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)),
00355             m_summaryWordWidget, SLOT(slotSelectionChanged(const QItemSelection &, const QItemSelection &)));
00356     connect(m_vocabularyModel, SIGNAL(documentChanged(KEduVocDocument*)), m_vocabularyView, SLOT(slotRestoreColumnVisibility(KEduVocDocument*)));
00357 
00358     setCaption(m_document->document()->url().fileName(), false);
00359 
00361 // at the moment creates a new test every time a model is created. this is good because we get the basic sanity check then.
00362 // temporarily disabled because somehow with the welcome screen this crashes Parley when using open recent
00363 //     new ModelTest(m_vocabularyModel, this);
00364 }
00365 
00366 
00367 void ParleyApp::initDockWidgets()
00368 {
00369 // Lesson dock
00370     QDockWidget *lessonDockWidget = new QDockWidget(i18n("Lessons"), this);
00371     lessonDockWidget->setObjectName("LessonDock");
00372     m_lessonView = new LessonView(this);
00373     lessonDockWidget->setWidget(m_lessonView);
00374     addDockWidget(Qt::LeftDockWidgetArea, lessonDockWidget);
00375     m_dockWidgets.append(lessonDockWidget);
00376     actionCollection()->addAction("show_lesson_dock", lessonDockWidget->toggleViewAction());
00377 
00378     m_lessonModel = new LessonModel(this);
00380     new ModelTest(m_lessonModel, this);
00381 
00382     m_lessonView->setModel(m_lessonModel);
00383     m_lessonView->setToolTip(i18n("Right click to add, delete, or rename lessons. \n"
00384             "With the checkboxes you can select which lessons you want to practice. \n"
00385             "Only checked lessons [x] will be asked in the tests!"));
00386 
00387     connect(m_lessonView, SIGNAL(selectedLessonChanged(KEduVocLesson*)),
00388         m_vocabularyModel, SLOT(setLesson(KEduVocLesson*)));
00389 
00390     connect(m_lessonView, SIGNAL(signalShowContainer(KEduVocContainer*)),
00391         m_vocabularyModel, SLOT(showContainer(KEduVocContainer*)));
00392 
00393     connect(m_vocabularyView, SIGNAL(translationChanged(KEduVocExpression*, int)),
00394         m_lessonView, SLOT(setTranslation(KEduVocExpression*, int)));
00395 
00396 
00397 // Word types dock
00398     QDockWidget* wordTypeDockWidget = new QDockWidget(i18n("Word Types"), this);
00399     wordTypeDockWidget->setObjectName( "WordTypeDock" );
00400     m_wordTypeView = new WordTypeView(this);
00401     wordTypeDockWidget->setWidget(m_wordTypeView);
00402     addDockWidget( Qt::LeftDockWidgetArea, wordTypeDockWidget );
00403     m_dockWidgets.append(wordTypeDockWidget);
00404 
00405     m_wordTypeModel = new WordTypeModel(this);
00406     wordTypeDockWidget->setVisible(false);
00407     actionCollection()->addAction("show_wordtype_dock", wordTypeDockWidget->toggleViewAction());
00408 
00411 //     new ModelTest(m_wordTypeModel, this);
00412 
00413     m_wordTypeView->setModel(m_wordTypeModel);
00414 
00415     connect(m_wordTypeView, SIGNAL(selectedWordTypeChanged(KEduVocWordType*)),
00416         m_vocabularyModel, SLOT(setWordType(KEduVocWordType*)));
00417 
00418     connect(m_wordTypeView, SIGNAL(signalShowContainer(KEduVocContainer*)),
00419         m_vocabularyModel, SLOT(showContainer(KEduVocContainer*)));
00420 
00421     connect(m_vocabularyView, SIGNAL(translationChanged(KEduVocExpression*, int)),
00422         m_wordTypeView, SLOT(setTranslation(KEduVocExpression*, int)));
00423 
00424 // Leitner boxes dock
00425     QDockWidget* leitnerDockWidget = new QDockWidget(i18n("Grade Boxes"), this);
00426     leitnerDockWidget->setObjectName( "LeitnerDock" );
00427     m_leitnerView = new LeitnerView(this);
00428     leitnerDockWidget->setWidget(m_leitnerView);
00429     addDockWidget( Qt::LeftDockWidgetArea, leitnerDockWidget );
00430     m_dockWidgets.append(leitnerDockWidget);
00431 
00432     m_leitnerModel = new LeitnerModel(this);
00433     leitnerDockWidget->setVisible(false);
00434     actionCollection()->addAction("show_leitner_dock", leitnerDockWidget->toggleViewAction());
00435 
00436     m_leitnerView->setModel(m_leitnerModel);
00437 
00438     connect(m_leitnerView, SIGNAL(selectedLeitnerBoxChanged(KEduVocLeitnerBox*)),
00439         m_vocabularyModel, SLOT(setLeitnerBox(KEduVocLeitnerBox*)));
00440 
00441     connect(m_leitnerView, SIGNAL(signalShowContainer(KEduVocContainer*)),
00442         m_vocabularyModel, SLOT(showContainer(KEduVocContainer*)));
00443 
00444     connect(m_vocabularyView, SIGNAL(translationChanged(KEduVocExpression*, int)),
00445         m_leitnerView, SLOT(setTranslation(KEduVocExpression*, int)));
00446 
00447 // Conjugations
00448     QDockWidget *conjugationDock = new QDockWidget(i18n("Conjugation"), this);
00449     conjugationDock->setObjectName("ConjugationDock");
00450     m_conjugationWidget = new ConjugationWidget(this);
00451     conjugationDock->setWidget(m_conjugationWidget);
00452     addDockWidget(Qt::RightDockWidgetArea, conjugationDock);
00453     m_dockWidgets.append(conjugationDock);
00454     conjugationDock->setVisible(false);
00455     actionCollection()->addAction("show_conjugation_dock", conjugationDock->toggleViewAction());
00456     connect(m_document, SIGNAL(documentChanged(KEduVocDocument*)),
00457         m_conjugationWidget, SLOT(setDocument(KEduVocDocument*)));
00458     connect(m_vocabularyView, SIGNAL(translationChanged(KEduVocExpression*, int)),
00459         m_conjugationWidget, SLOT(setTranslation(KEduVocExpression*, int)));
00460 
00461 // Declensions
00462     QDockWidget *declensionDock = new QDockWidget(i18n("Declension"), this);
00463     declensionDock->setObjectName("DeclensionDock");
00464     DeclensionWidget *declensionWidget = new DeclensionWidget(this);
00465     declensionDock->setWidget(declensionWidget);
00466     addDockWidget(Qt::RightDockWidgetArea, declensionDock);
00467     m_dockWidgets.append(declensionDock);
00468     actionCollection()->addAction("show_declension_dock", declensionDock->toggleViewAction());
00469     declensionDock->setVisible(false);
00470     connect(m_document, SIGNAL(documentChanged(KEduVocDocument*)),
00471             declensionWidget, SLOT(setDocument(KEduVocDocument*)));
00472     connect(m_vocabularyView, SIGNAL(translationChanged(KEduVocExpression*, int)),
00473             declensionWidget, SLOT(setTranslation(KEduVocExpression*, int)));
00474 
00475 
00476 // Comparison forms
00477     QDockWidget *comparisonDock = new QDockWidget(i18n("Comparison forms"), this);
00478     comparisonDock->setObjectName("ComparisonDock");
00479     ComparisonWidget *comparisonWidget = new ComparisonWidget(this);
00480     comparisonDock->setWidget(comparisonWidget);
00481     addDockWidget(Qt::RightDockWidgetArea, comparisonDock);
00482     m_dockWidgets.append(comparisonDock);
00483     actionCollection()->addAction("show_comparison_dock", comparisonDock->toggleViewAction());
00484     comparisonDock->setVisible(false);
00485     connect(m_vocabularyView, SIGNAL(translationChanged(KEduVocExpression*, int)),
00486         comparisonWidget, SLOT(setTranslation(KEduVocExpression*, int)));
00487     connect(m_document, SIGNAL(documentChanged(KEduVocDocument*)), comparisonWidget, SLOT(setDocument(KEduVocDocument*)));
00488 
00489 
00490 // Multiple choice
00491     QDockWidget *multipleChoiceDock = new QDockWidget(i18n("Multiple Choice"), this);
00492     multipleChoiceDock->setObjectName("MultipleChoiceDock");
00493     MultipleChoiceWidget *multipleChoiceWidget = new MultipleChoiceWidget(this);
00494     multipleChoiceDock->setWidget(multipleChoiceWidget);
00495     addDockWidget(Qt::RightDockWidgetArea, multipleChoiceDock);
00496     m_dockWidgets.append(multipleChoiceDock);
00497     actionCollection()->addAction("show_multiplechoice_dock", multipleChoiceDock->toggleViewAction());
00498     multipleChoiceDock->setVisible(false);
00499     connect(m_vocabularyView, SIGNAL(translationChanged(KEduVocExpression*, int)),
00500         multipleChoiceWidget, SLOT(setTranslation(KEduVocExpression*, int)));
00501 
00502 // Synonym (and the same for antonym and false friends)
00503     QDockWidget *synonymDock = new QDockWidget(i18n("Synonyms"), this);
00504     synonymDock->setObjectName("SynonymDock");
00505     SynonymWidget *synonymWidget = new SynonymWidget(SynonymWidget::Synonym, this);
00506     synonymDock->setWidget(synonymWidget);
00507     addDockWidget(Qt::RightDockWidgetArea, synonymDock);
00508     m_dockWidgets.append(synonymDock);
00509     actionCollection()->addAction("show_synonym_dock", synonymDock->toggleViewAction());
00510     synonymDock->setVisible(false);
00511     connect(m_vocabularyView, SIGNAL(translationChanged(KEduVocExpression*, int)),
00512             synonymWidget, SLOT(setTranslation(KEduVocExpression*, int)));
00513 
00514     QDockWidget *antonymDock = new QDockWidget(i18n("Antonyms"), this);
00515     antonymDock->setObjectName("AntonymDock");
00516     SynonymWidget *antonymWidget = new SynonymWidget(SynonymWidget::Antonym, this);
00517     antonymDock->setWidget(antonymWidget);
00518     addDockWidget(Qt::RightDockWidgetArea, antonymDock);
00519     m_dockWidgets.append(antonymDock);
00520     actionCollection()->addAction("show_antonym_dock", antonymDock->toggleViewAction());
00521     antonymDock->setVisible(false);
00522     connect(m_vocabularyView, SIGNAL(translationChanged(KEduVocExpression*, int)),
00523             antonymWidget, SLOT(setTranslation(KEduVocExpression*, int)));
00524 
00525     QDockWidget *falseFriendDock = new QDockWidget(i18n("False Friends"), this);
00526     falseFriendDock->setObjectName("FalseFriendDock");
00527     SynonymWidget *falseFriendWidget = new SynonymWidget(SynonymWidget::FalseFriend, this);
00528     falseFriendDock->setWidget(falseFriendWidget);
00529     addDockWidget(Qt::RightDockWidgetArea, falseFriendDock);
00530     m_dockWidgets.append(falseFriendDock);
00531     actionCollection()->addAction("show_falsefriend_dock", falseFriendDock->toggleViewAction());
00532     falseFriendDock->setVisible(false);
00533     connect(m_vocabularyView, SIGNAL(translationChanged(KEduVocExpression*, int)),
00534             falseFriendWidget, SLOT(setTranslation(KEduVocExpression*, int)));
00535 
00536 // Pronunciation symbols - Use KCharSelect
00537     QDockWidget *charSelectDock = new QDockWidget(i18n("Phonetic Symbols"), this);
00538     charSelectDock->setObjectName("IPADock");
00539     KCharSelect *charSelectWidget = new KCharSelect(this,  KCharSelect::SearchLine | KCharSelect::BlockCombos | KCharSelect::CharacterTable);
00540     charSelectWidget->setCurrentChar(0x0250);
00541     charSelectDock->setWidget(charSelectWidget);
00542     addDockWidget(Qt::BottomDockWidgetArea, charSelectDock);
00543     m_dockWidgets.append(charSelectDock);
00544     actionCollection()->addAction("show_pronunciation_dock", charSelectDock->toggleViewAction());
00545     charSelectDock->setVisible(false);
00546     connect(charSelectWidget, SIGNAL(charSelected(const QChar &)), m_vocabularyView, SLOT(appendChar(const QChar &)));
00547 
00548 // Image
00549     QDockWidget *imageDock = new QDockWidget(i18n("Image"), this);
00550     imageDock->setObjectName("ImageDock");
00551     ImageChooserWidget *imageChooserWidget = new ImageChooserWidget(this);
00552     imageDock->setWidget(imageChooserWidget);
00553     addDockWidget(Qt::RightDockWidgetArea, imageDock);
00554     m_dockWidgets.append(imageDock);
00555     actionCollection()->addAction("show_image_dock", imageDock->toggleViewAction());
00556     imageDock->setVisible(false);
00557     connect(m_vocabularyView, SIGNAL(translationChanged(KEduVocExpression*, int)),
00558         imageChooserWidget, SLOT(setTranslation(KEduVocExpression*, int)));
00559 
00560 // Summary word
00561     QDockWidget *summaryDock = new QDockWidget(i18n("Summary"), this);
00562     summaryDock->setObjectName("SummaryDock");
00563     m_summaryWordWidget = new SummaryWordWidget(m_vocabularyModel, m_document->document(), this);
00564     summaryDock->setWidget(m_summaryWordWidget);
00565     addDockWidget(Qt::RightDockWidgetArea, summaryDock);
00566     actionCollection()->addAction("show_summary_dock", summaryDock->toggleViewAction());
00567     summaryDock->setVisible(false);
00568     m_dockWidgets.append(summaryDock);
00569     connect(m_document, SIGNAL(documentChanged(KEduVocDocument *)),
00570             m_summaryWordWidget, SLOT(slotDocumentChanged(KEduVocDocument *)));
00571     connect(m_vocabularyView, SIGNAL(translationChanged(KEduVocExpression*, int)),
00572             m_summaryWordWidget, SLOT(setTranslation(KEduVocExpression*, int)));
00573 
00574 // Sound
00575     QDockWidget *audioDock = new QDockWidget(i18n("Sound"), this);
00576     audioDock->setObjectName("AudioDock");
00577     AudioWidget *audioWidget = new AudioWidget(this);
00578     audioDock->setWidget(audioWidget);
00579     addDockWidget(Qt::RightDockWidgetArea, audioDock);
00580     m_dockWidgets.append(audioDock);
00581     actionCollection()->addAction("show_audio_dock", audioDock->toggleViewAction());
00582     audioDock->setVisible(false);
00583     connect(m_vocabularyView, SIGNAL(translationChanged(KEduVocExpression*, int)),
00584         audioWidget, SLOT(setTranslation(KEduVocExpression*, int)));
00585 
00586 // browser
00587     QDockWidget *browserDock = new QDockWidget(i18n("Internet"), this);
00588     browserDock->setObjectName("BrowserDock");
00589     //TinyWebBrowser *browserWidget = new TinyWebBrowser(this);
00590     BrowserWidget *htmlPart = new BrowserWidget(browserDock);
00591     browserDock->setWidget(htmlPart);
00592     addDockWidget(Qt::RightDockWidgetArea, browserDock);
00593     m_dockWidgets.append(browserDock);
00594     actionCollection()->addAction("show_browser_dock", browserDock->toggleViewAction());
00595     browserDock->setVisible(false);
00596     connect(m_vocabularyView, SIGNAL(translationChanged(KEduVocExpression*, int)),
00597             htmlPart, SLOT(setTranslation(KEduVocExpression*, int)));
00598 
00599 // Marble
00600 //     QDockWidget *marbleDock = new QDockWidget(i18n("Marble"), this);
00601 //     marbleDock->setObjectName("MarbleDock");
00602 //     MarbleWidget *marbleWidget = new MarbleWidget(this);
00603 //     marbleDock->setWidget(marbleWidget);
00604 //     addDockWidget(Qt::RightDockWidgetArea, marbleDock);
00605 
00606 
00607 // Grades
00608 //     QDockWidget *gradeDock = new QDockWidget(i18n("Grade"), this);
00609 //     gradeDock->setObjectName("gradeDock");
00610 //     QLabel *gradeWidget = new QLabel("grade placeholder", this);
00611 //     gradeDock->setWidget(gradeWidget);
00612 //     addDockWidget(Qt::RightDockWidgetArea, gradeDock);
00613 //     connect(this, SIGNAL(signalSetData(KEduVocTranslation*)), m_declensionWidget, SLOT(setTranslation(KEduVocTranslation*)));
00614 
00615 // actionCollection()->addAction("show_leitner_dock", ->toggleViewAction());
00616 }
00617 
00618 void ParleyApp::tipOfDay() {
00619   KTipDialog::showTip(this, "parley/tips", true);
00620 }
00621 
00622 void ParleyApp::startupTipOfDay() {
00623   KTipDialog::showTip(this, "parley/tips");
00624 }
00625 
00626 
00627 void ParleyApp::initActions()
00628 {
00629 // -- FILE --------------------------------------------------
00630     KAction* fileNew = KStandardAction::openNew(m_document, SLOT(slotFileNew()), actionCollection());
00631     fileNew->setWhatsThis(i18n("Creates a new blank vocabulary document"));
00632     fileNew->setToolTip(fileNew->whatsThis());
00633     fileNew->setStatusTip(fileNew->whatsThis());
00634 
00635     KAction* fileOpen = KStandardAction::open(m_document, SLOT(slotFileOpen()), actionCollection());
00636     fileOpen->setWhatsThis(i18n("Opens an existing vocabulary document"));
00637     fileOpen->setToolTip(fileOpen->whatsThis());
00638     fileOpen->setStatusTip(fileOpen->whatsThis());
00639 
00640     KAction* fileOpenExample = new KAction(this);
00641     actionCollection()->addAction("file_open_example", fileOpenExample);
00642     fileOpenExample->setIcon(KIcon("document-open"));
00643     fileOpenExample->setText(i18n("Open &Example..."));
00644     connect(fileOpenExample, SIGNAL(triggered(bool)), m_document, SLOT(openExample()));
00645     fileOpenExample->setWhatsThis(i18n("Open an example vocabulary document"));
00646     fileOpenExample->setToolTip(fileOpenExample->whatsThis());
00647     fileOpenExample->setStatusTip(fileOpenExample->whatsThis());
00648 
00649     KAction* fileGHNS = KNS::standardAction(i18n("Download New Vocabularies..."), m_document, SLOT(slotGHNS()), actionCollection(), "file_ghns");
00650     fileGHNS->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_G));
00651     fileGHNS->setWhatsThis(i18n("Downloads new vocabularies"));
00652     fileGHNS->setToolTip(fileGHNS->whatsThis());
00653     fileGHNS->setStatusTip(fileGHNS->whatsThis());
00654 
00655     m_recentFilesAction = KStandardAction::openRecent(m_document, SLOT(slotFileOpenRecent(const KUrl&)), actionCollection());
00656     m_recentFilesAction->loadEntries(KGlobal::config()->group("Recent Files"));
00657 
00658     m_downloadedFilesAction = new KRecentFilesAction(KIcon("get-hot-new-stuff"), "file_open_downloaded", this);
00659     actionCollection()->addAction("file_open_downloaded", m_downloadedFilesAction);
00660     m_downloadedFilesAction->setText(i18n("Open Downloaded Vocabularies"));
00661     m_downloadedFilesAction->loadEntries(KGlobal::config()->group("Downloaded Files"));
00662     connect(m_downloadedFilesAction, SIGNAL(urlSelected(const KUrl &)), m_document, SLOT(open(const KUrl&)));
00663     m_downloadedFilesAction->loadEntries(KGlobal::config()->group("Downloaded Files"));
00664     m_downloadedFilesAction->setMaxItems(30);
00665 
00666     /*
00667     KAction* fileMerge = new KAction(this);
00668     actionCollection()->addAction("file_merge", fileMerge);
00669     fileMerge->setText(i18n("&Merge..."));
00670     connect(fileMerge, SIGNAL(triggered(bool)), m_document, SLOT(slotFileMerge()));
00671     fileMerge->setWhatsThis(i18n("Merge an existing vocabulary document with the current one"));
00672     fileMerge->setToolTip(fileMerge->whatsThis());
00673     fileMerge->setStatusTip(fileMerge->whatsThis());
00674     fileMerge->setEnabled(false); ///@todo merging files is horribly broken
00675     */
00676 
00677     KAction* fileSave = KStandardAction::save(m_document, SLOT(save()), actionCollection());
00678     fileSave->setWhatsThis(i18n("Save the active vocabulary document"));
00679     fileSave->setToolTip(fileSave->whatsThis());
00680     fileSave->setStatusTip(fileSave->whatsThis());
00681 
00682     KAction* fileSaveAs = KStandardAction::saveAs(m_document, SLOT(saveAs()), actionCollection());
00683     fileSaveAs->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_S));
00684     fileSaveAs->setWhatsThis(i18n("Save the active vocabulary document with a different name"));
00685     fileSaveAs->setToolTip(fileSaveAs->whatsThis());
00686     fileSaveAs->setStatusTip(fileSaveAs->whatsThis());
00687 
00688 #ifdef HAVE_LIBXSLT
00689 
00690 // Printing would be nice, but for now html export has to suffice
00691 //     KAction* filePrint = KStandardAction::print(m_document, SLOT(print()), actionCollection());
00692 //     filePrint->setWhatsThis(i18n("Print the active vocabulary document"));
00693 //     filePrint->setToolTip(filePrint->whatsThis());
00694 //     filePrint->setStatusTip(filePrint->whatsThis());
00695 
00696     KAction* fileExport = new KAction(this);
00697     actionCollection()->addAction("file_export", fileExport);
00698     fileExport->setText(i18n("&Export..."));
00699     connect(fileExport, SIGNAL(triggered(bool)), m_document, SLOT(exportHtmlDialog()));
00700     fileExport->setIcon(KIcon("document-export"));
00701     fileExport->setWhatsThis(i18n("Export to HTML"));
00702     fileExport->setToolTip(fileExport->whatsThis());
00703     fileExport->setStatusTip(fileExport->whatsThis());
00704 #endif
00705 
00706     KAction* fileProperties = new KAction(this);
00707     actionCollection()->addAction("file_properties", fileProperties);
00708     fileProperties->setText(i18n("&Properties..."));
00709     connect(fileProperties, SIGNAL(triggered(bool)), SLOT(slotDocumentProperties()));
00710     fileProperties->setIcon(KIcon("document-properties"));
00711     fileProperties->setWhatsThis(i18n("Edit document properties"));
00712     fileProperties->setToolTip(fileProperties->whatsThis());
00713     fileProperties->setStatusTip(fileProperties->whatsThis());
00714 
00715     KAction* fileClose = KStandardAction::close(this, SLOT(slotCloseDocument()), actionCollection());
00716     fileClose->setWhatsThis(i18n("Close the current collection"));
00717     fileClose->setToolTip(fileClose->whatsThis());
00718     fileClose->setStatusTip(fileClose->whatsThis());
00719 
00720     KAction* fileQuit = KStandardAction::quit(this, SLOT(close()), actionCollection());
00721     fileQuit->setWhatsThis(i18n("Quit Parley"));
00722     fileQuit->setToolTip(fileQuit->whatsThis());
00723     fileQuit->setStatusTip(fileQuit->whatsThis());
00724 
00725 
00726     KAction* editLanguages =new KAction(this);
00727     actionCollection()->addAction("edit_languages", editLanguages);
00728     editLanguages->setIcon(KIcon("set-language"));
00729     editLanguages->setText(i18n("&Languages..."));
00730     editLanguages->setWhatsThis(i18n("Edit which languages are in the collection and their grammar properties."));
00731     editLanguages->setToolTip(editLanguages->whatsThis());
00732     editLanguages->setStatusTip(editLanguages->whatsThis());
00733     connect(editLanguages, SIGNAL(triggered()),  this, SLOT(slotLanguageProperties()));
00735 
00736     KAction *checkSpelling = KStandardAction::spelling(m_vocabularyView, SLOT(checkSpelling()), actionCollection());
00737 
00738     KAction *showSublessonentries = actionCollection()->add<KToggleAction>("lesson_showsublessonentries");
00739     showSublessonentries->setText(i18n("Show Entries from Child Lessons"));
00740     connect(showSublessonentries, SIGNAL(triggered(bool)), m_vocabularyModel, SLOT(showEntriesOfSubcontainers(bool)));
00741     showSublessonentries->setWhatsThis(i18n("Enable to also see the entries of child lessons in each lesson."));
00742     showSublessonentries->setToolTip(showSublessonentries->whatsThis());
00743     showSublessonentries->setStatusTip(showSublessonentries->whatsThis());
00744     showSublessonentries->setChecked(Prefs::showSublessonentries());
00745 
00746     KAction *automaticTranslation = actionCollection()->add<KToggleAction>("lesson_automatictranslation");
00747     automaticTranslation->setText(i18n("Automatic Translation"));
00748     connect(automaticTranslation, SIGNAL(triggered(bool)), m_vocabularyModel, SLOT(automaticTranslation(bool)));
00749     automaticTranslation->setWhatsThis(i18n("Enable for automatic translation of the lesson entries."));
00750     automaticTranslation->setToolTip(automaticTranslation->whatsThis());
00751     automaticTranslation->setStatusTip(automaticTranslation->whatsThis());
00752     automaticTranslation->setChecked(Prefs::automaticTranslation());
00753 
00754     KAction* removeGrades = new KAction(this);
00755     actionCollection()->addAction("vocab_remove_grades", removeGrades);
00756     removeGrades->setIcon(KIcon("edit-clear"));
00757     removeGrades->setText(i18n("Remove Grades"));
00758     connect(removeGrades, SIGNAL(triggered(bool)), this, SLOT(removeGrades()));
00759     removeGrades->setWhatsThis(i18n("Remove all grades from the current document"));
00760     removeGrades->setToolTip(removeGrades->whatsThis());
00761     removeGrades->setStatusTip(removeGrades->whatsThis());
00762 
00763 // -- PRACTICE --------------------------------------------------
00764 
00765     KAction* configurePractice = new KAction(this);
00766     configurePractice->setText(i18n("Configure Practice..."));
00767     configurePractice->setIcon(KIcon("practice-setup"));
00768     configurePractice->setWhatsThis(i18n("Set up and start a test"));
00769     configurePractice->setToolTip(configurePractice->whatsThis());
00770     configurePractice->setStatusTip(configurePractice->whatsThis());
00771     actionCollection()->addAction("practice_configure", configurePractice);
00772     connect(configurePractice, SIGNAL(triggered(bool)), SLOT(configurePractice()));
00773 
00774     KAction* startPractice = new KAction(this);
00775     startPractice->setText(i18n("Start Practice..."));
00776     startPractice->setIcon(KIcon("practice-start"));
00777     startPractice->setWhatsThis(i18n("Start a test with the last settings"));
00778     startPractice->setToolTip(startPractice->whatsThis());
00779     startPractice->setStatusTip(startPractice->whatsThis());
00780     actionCollection()->addAction("practice_start", startPractice);
00781     connect(startPractice, SIGNAL(triggered(bool)), SLOT(startPractice()));
00782 
00783     KAction* showStatistics = new KAction(this);
00784     actionCollection()->addAction("show_statistics", showStatistics);
00785     showStatistics->setIcon(KIcon("statistics"));
00786     showStatistics->setText(i18n("&Statistics..."));
00787     connect(showStatistics, SIGNAL(triggered(bool)), this, SLOT(slotShowStatistics()));
00788     showStatistics->setWhatsThis(i18n("Show and reset statistics for the current vocabulary"));
00789     showStatistics->setToolTip(showStatistics->whatsThis());
00790     showStatistics->setStatusTip(showStatistics->whatsThis());
00791 
00792 
00793 // -- SETTINGS --------------------------------------------------
00794     KAction* configApp = KStandardAction::preferences(this, SLOT(slotGeneralOptions()), actionCollection());
00795     configApp->setWhatsThis(i18n("Show the configuration dialog"));
00796     configApp->setToolTip(configApp->whatsThis());
00797     configApp->setStatusTip(configApp->whatsThis());
00798 
00799     m_vocabShowSearchBarAction = actionCollection()->add<KToggleAction>("config_show_search");
00800     m_vocabShowSearchBarAction->setText(i18n("Show Se&arch"));
00801     connect(m_vocabShowSearchBarAction, SIGNAL(triggered(bool)), this, SLOT(slotConfigShowSearch()));
00802     m_vocabShowSearchBarAction->setWhatsThis(i18n("Toggle display of the search bar"));
00803     m_vocabShowSearchBarAction->setToolTip(m_vocabShowSearchBarAction->whatsThis());
00804     m_vocabShowSearchBarAction->setStatusTip(m_vocabShowSearchBarAction->whatsThis());
00805     m_vocabShowSearchBarAction->setChecked(Prefs::showSearch());
00806 
00807     actionCollection()->addAction("show_vocabulary_columns_menu", m_vocabularyColumnsActionMenu);
00808     m_vocabularyColumnsActionMenu->setText(i18n("Vocabulary Columns"));
00809     m_vocabularyColumnsActionMenu->setWhatsThis(i18n("Toggle display of individual vocabulary columns"));
00810     m_vocabularyColumnsActionMenu->setToolTip(m_vocabularyColumnsActionMenu->whatsThis());
00811     m_vocabularyColumnsActionMenu->setStatusTip(m_vocabularyColumnsActionMenu->whatsThis());
00812     m_vocabularyView->horizontalHeader()->addAction(m_vocabularyColumnsActionMenu);
00813 
00814     actionCollection()->addAction(KStandardAction::TipofDay,  "help_tipofday", this, SLOT( tipOfDay() ));
00815 
00816 // -- ONLY ON RIGHT CLICK - HEADER SO FAR -------------------------------------
00818     KAction *actionRestoreNativeOrder = new KAction(this);
00819     actionCollection()->addAction("restore_native_order", actionRestoreNativeOrder);
00820     actionRestoreNativeOrder->setText(i18n("Restore Native Order"));
00821 
00822 
00823     KAction* findVocabulary = KStandardAction::find(m_searchLine, SLOT(setFocus()), actionCollection());
00824 
00825 // SCRIPTS MENU
00826 //     QMenu * scriptsMenu = menuBar()->addMenu(i18n("Scriptss"));
00827 //     scriptsMenu->addAction(i18n("Test"));
00828     
00829     //Script Manager Menu Action
00830     KAction* menu_scriptManager =new KAction(this);
00831     actionCollection()->addAction("show_script_manager", menu_scriptManager);
00832     menu_scriptManager->setIcon(KIcon("set-language"));
00833     menu_scriptManager->setText(i18n("&Script Manager"));
00834     connect(menu_scriptManager, SIGNAL(triggered()),  this, SLOT(slotShowScriptManager()));
00835 
00836     KToggleAction *oldPractice = actionCollection()->add<KToggleAction>("config_oldPractice");
00837     oldPractice->setText(i18n("Old Practice Dialogs"));
00838     connect(oldPractice, SIGNAL(triggered(bool)), this, SLOT(slotConfigOldPractice(bool)));
00839     m_vocabShowSearchBarAction->setChecked(Prefs::oldPractice());
00840 }
00841 
00842 
00843 void ParleyApp::initStatusBar()
00844 {
00845     m_typeStatusBarLabel = new QLabel(statusBar());
00846     m_typeStatusBarLabel->setFrameStyle(QFrame::NoFrame);
00847     statusBar()->addWidget(m_typeStatusBarLabel, 150);
00848 
00849     m_pronunciationStatusBarLabel = new QLabel(statusBar());
00850     m_pronunciationStatusBarLabel->setFrameStyle(QFrame::NoFrame);
00851     m_pronunciationStatusBarLabel->setFont(Prefs::iPAFont());
00852     statusBar()->addWidget(m_pronunciationStatusBarLabel, 200);
00853 
00854     m_remarkStatusBarLabel = new QLabel(statusBar());
00855     m_remarkStatusBarLabel->setFrameStyle(QFrame::NoFrame);
00856     statusBar()->addWidget(m_remarkStatusBarLabel, 150);
00857 }
00858 
00859 void ParleyApp::initModel()
00860 {
00861     m_vocabularyModel = new VocabularyModel(this);
00862 
00863     m_vocabularyFilter = new VocabularyFilter(this);
00864     m_vocabularyFilter->setSourceModel(m_vocabularyModel);
00865     m_vocabularyView->setModel(m_vocabularyFilter);
00866 
00867     connect(m_document, SIGNAL(documentChanged(KEduVocDocument*)), m_vocabularyModel, SLOT(setDocument(KEduVocDocument*)));
00868     connect(m_document, SIGNAL(documentChanged(KEduVocDocument*)), m_vocabularyView, SLOT(setDocument(KEduVocDocument*)));
00869 
00870     connect(m_searchLine, SIGNAL(textChanged(const QString&)), m_vocabularyFilter, SLOT(setSearchString(const QString&)));
00871 }
00872 
00876 void ParleyApp::initView()
00877 {
00878     // Parent of all
00879     QStackedWidget *stackedWidget = new QStackedWidget(this);
00880     setCentralWidget(stackedWidget);
00881     
00882     QWidget *mainWidget = new QWidget(this);
00883     stackedWidget->addWidget(mainWidget);
00884     QVBoxLayout *topLayout = new QVBoxLayout(mainWidget);
00885     topLayout->setMargin(KDialog::marginHint());
00886     topLayout->setSpacing(KDialog::spacingHint());
00887 
00888     m_searchLine = new KLineEdit(this);
00889     m_searchLine->show();
00890     m_searchLine->setFocusPolicy(Qt::ClickFocus);
00891     m_searchLine->setClearButtonShown(true);
00892     m_searchLine->setClickMessage(i18n("Enter search terms here"));
00893 
00894 //     m_searchLine->setToolTip(i18n("Search your vocabuary"));
00895 
00896     QLabel *label = new QLabel(i18n("S&earch:"), this);
00897     label->setBuddy(m_searchLine);
00898     label->show();
00899 
00900     m_searchWidget = new QWidget(this);
00901     QHBoxLayout* layout = new QHBoxLayout(m_searchWidget);
00902     layout->setSpacing(KDialog::spacingHint());
00903     layout->setMargin(0);
00904     layout->addWidget(label);
00905     layout->addWidget(m_searchLine);
00906 
00908     QVBoxLayout * rightLayout = new QVBoxLayout(mainWidget);
00909     rightLayout->setSpacing(KDialog::spacingHint());
00910     rightLayout->setMargin(0);
00911     rightLayout->addWidget(m_searchWidget);
00912     m_searchWidget->setVisible(Prefs::showSearch());
00913 
00914     m_vocabularyView = new VocabularyView(this);
00915     m_vocabularyColumnsActionMenu = m_vocabularyView->columnsActionMenu();
00916     rightLayout->addWidget(m_vocabularyView, 1, 0);
00917 
00918     topLayout->addLayout(rightLayout);
00919 }
00920 
00921 void ParleyApp::initWelcomeScreen()
00922 {
00923     WelcomeScreen* welcomeScreen = new WelcomeScreen(this);
00924     qobject_cast<QStackedWidget*>(centralWidget())->addWidget(welcomeScreen);
00925     
00926     connect(m_document, SIGNAL(documentChanged(KEduVocDocument*)), this, SLOT(hideWelcomeScreen()));
00927 }
00928 
00929 void ParleyApp::slotShowScriptManager() {
00930 //      kDebug() << QString("here!!");
00931     ScriptDialog * dialog = new ScriptDialog(m_scriptManager);
00932     dialog->show();
00933 }
00934 
00935 void ParleyApp::removeGrades()
00936 {
00937     m_document->document()->lesson()->resetGrades(-1, KEduVocContainer::Recursive);
00938 }
00939 
00940 
00941 void ParleyApp::initScripts()
00942 {
00943     m_scriptManager = new ScriptManager(this);
00944 
00945     m_vocabularyView->setTranslator(m_scriptManager->translator());
00946 
00947     //Load scripts
00948     m_scriptManager->loadScripts();
00949 }
00950 
00951 
00952 void ParleyApp::setShowWelcomeScreen(bool show)
00953 {
00954     QStackedWidget* central = qobject_cast<QStackedWidget*>(centralWidget());
00955     int index = int(show);
00956     if (central->currentIndex() != index) {
00957         central->setCurrentIndex(int(show));
00958     } else {
00959         return;
00960     }
00961 
00962     if (show) {
00963         // hide dock widgets
00964         m_dockWidgetVisibility.clear();
00965         foreach(QDockWidget* dock, m_dockWidgets) {
00966             m_dockWidgetVisibility.append(!dock->isHidden());
00967             dock->close();
00968         }
00969     } else {
00970         // restore dock widgets
00971         if(m_dockWidgets.count() != m_dockWidgetVisibility.count()) {
00972             return;
00973         }
00974         int i = 0;
00975         foreach(QDockWidget* dock, m_dockWidgets) {
00976             if (m_dockWidgetVisibility[i]) {
00977                 dock->show();
00978             }
00979             i++;
00980         }
00981     }
00982 }
00983 
00984 void ParleyApp::hideWelcomeScreen()
00985 {
00986     setShowWelcomeScreen(false);
00987 }
00988 
00989 ParleyDocument* ParleyApp::parleyDocument()
00990 {
00991     return m_document;
00992 }
00993 
00994 void ParleyApp::slotLanguageProperties()
00995 {
00996     LanguageProperties properties(m_document->document(), this);
00997     if ( properties.exec() == KDialog::Accepted ) {
00998          m_vocabularyModel->resetLanguages();
00999     }
01000 }
01001 
01002 #include "parley.moc"
01003