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

parley

editor.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002     Copyright 1999-2001 Ewald Arnold <kvoctrain@ewald-arnold.de>
00003     Copyright 2004-2007 Peter Hedlund <peter.hedlund@kdemail.net>
00004     Copyright 2007-2009 Frederik Gladhorn <gladhorn@kde.org>
00005     Copyright 2008 Daniel Laidig <d.laidig@gmx.de>
00006 ***************************************************************************/
00007 
00008 /***************************************************************************
00009  *                                                                         *
00010  *   This program is free software; you can redistribute it and/or modify  *
00011  *   it under the terms of the GNU General Public License as published by  *
00012  *   the Free Software Foundation; either version 2 of the License, or     *
00013  *   (at your option) any later version.                                   *
00014  *                                                                         *
00015  ***************************************************************************/
00016 
00017 #include "editor.h"
00018 
00019 #include "../config-parley.h"
00020 
00021 #include "vocabulary/vocabularymodel.h"
00022 #include "vocabulary/vocabularyview.h"
00023 #include "vocabulary/vocabularyfilter.h"
00024 #include "vocabulary/containerview.h"
00025 #include "vocabulary/lessonview.h"
00026 #include "vocabulary/wordtypeview.h"
00027 #include "vocabulary/containermodel.h"
00028 #include "vocabulary/lessonmodel.h"
00029 #include "vocabulary/wordtypemodel.h"
00030 #include "vocabulary/leitnerview.h"
00031 #include "vocabulary/leitnermodel.h"
00032 
00033 #include "entry-dialogs/multiplechoicewidget.h"
00034 #include "entry-dialogs/comparisonwidget.h"
00035 #include "entry-dialogs/conjugationwidget.h"
00036 #include "entry-dialogs/declensionwidget.h"
00037 #include "entry-dialogs/imagechooserwidget.h"
00038 #include "entry-dialogs/audiowidget.h"
00039 #include "entry-dialogs/browserwidget.h"
00040 #include "entry-dialogs/synonymwidget.h"
00041 #include "entry-dialogs/summarywordwidget.h"
00042 
00043 #include "settings/parleyprefs.h"
00044 #include "settings/languageproperties.h"
00045 #include "settings/documentproperties.h"
00046 #include "prefs.h"
00047 
00048 #include "scripts/scriptdialog.h"
00049 #include "scripts/translator.h"
00050 
00051 #include <KActionCollection>
00052 #include <KToggleAction>
00053 #include <KActionMenu>
00054 #include <KCharSelect>
00055 
00056 #include <QtGui/QDockWidget>
00057 #include <QtGui/QHeaderView>
00058 #include <QtGui/QStackedWidget>
00059 
00060 #include "modeltest/modeltest.h"
00061 
00062 Editor::Editor(ParleyMainWindow* parent) : KXmlGuiWindow(parent), m_mainWindow(parent)
00063 {
00064     // KXmlGui
00065     setXMLFile("editorui.rc");
00066     setObjectName("Editor");
00067 
00068     setCorner(Qt::TopLeftCorner, Qt::LeftDockWidgetArea);
00069     setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea);
00070     setCorner(Qt::TopRightCorner, Qt::RightDockWidgetArea);
00071     setCorner(Qt::BottomRightCorner, Qt::RightDockWidgetArea);
00072 
00073     initView();
00074     initModel();
00075 
00076     initDockWidgets();
00077     initActions();
00078     initScripts();
00079 
00080     KConfigGroup cfg(KSharedConfig::openConfig("parleyrc"), objectName());
00081     applyMainWindowSettings(cfg);
00082 
00083     connect(parent, SIGNAL(documentChanged()), this, SLOT(updateDocument()));
00084 }
00085 
00086 Editor::~Editor()
00087 {
00088     KConfigGroup cfg(KSharedConfig::openConfig("parleyrc"), objectName());
00089     saveMainWindowSettings(cfg);
00090 }
00091 
00092 void Editor::updateDocument()
00093 {
00095     m_vocabularyView->setDocument(m_mainWindow->parleyDocument()->document());
00096     m_vocabularyModel->setDocument(m_mainWindow->parleyDocument()->document());
00097 
00098     m_lessonModel->setDocument(m_mainWindow->parleyDocument()->document());
00099     m_wordTypeModel->setDocument(m_mainWindow->parleyDocument()->document());
00100     m_leitnerModel->setDocument(m_mainWindow->parleyDocument()->document());
00101 
00102     if (!m_mainWindow->parleyDocument()->document()) {
00103         return;
00104     }
00105 
00106     // expand the root items
00107     m_lessonView->expandToDepth(0);
00108     m_wordTypeView->expandToDepth(0);
00109 
00110     // the top level container of this model only holds the others
00111     m_leitnerView->setRootIndex(m_leitnerModel->index(0,0));
00112 
00113     connect(m_mainWindow->parleyDocument()->document(), SIGNAL(docModified(bool)), m_mainWindow, SLOT(slotUpdateWindowCaption()));
00114     connect(m_vocabularyModel, SIGNAL(documentChanged(KEduVocDocument*)),
00115             m_summaryWordWidget, SLOT(slotDocumentChanged(KEduVocDocument *)));
00116     connect(m_vocabularyView->selectionModel(), 
00117                 SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)),
00118             m_summaryWordWidget, SLOT(slotSelectionChanged(const QItemSelection &, const QItemSelection &)));
00119 
00120     setCaption(m_mainWindow->parleyDocument()->document()->url().fileName(), false);
00121 
00122     m_mainWindow->slotUpdateWindowCaption();
00123 
00125 // at the moment creates a new test every time a model is created. this is good because we get the basic sanity check then.
00126 // temporarily disabled because somehow with the welcome screen this crashes Parley when using open recent
00127 //     new ModelTest(m_vocabularyModel, this);
00128 }
00129 
00130 
00131 void Editor::initDockWidgets()
00132 {
00133 // Lesson dock
00134     QDockWidget *lessonDockWidget = new QDockWidget(i18n("Lessons"), this);
00135     lessonDockWidget->setObjectName("LessonDock");
00136     m_lessonView = new LessonView(this);
00137     lessonDockWidget->setWidget(m_lessonView);
00138     addDockWidget(Qt::LeftDockWidgetArea, lessonDockWidget);
00139     m_dockWidgets.append(lessonDockWidget);
00140     actionCollection()->addAction("show_lesson_dock", lessonDockWidget->toggleViewAction());
00141 
00142     m_lessonModel = new LessonModel(this);
00144     new ModelTest(m_lessonModel, this);
00145 
00146     m_lessonView->setModel(m_lessonModel);
00147     m_lessonView->setToolTip(i18n("Right click to add, delete, or rename lessons. \n"
00148             "With the checkboxes you can select which lessons you want to practice. \n"
00149             "Only checked lessons [x] will be asked in the tests!"));
00150 
00151     connect(m_lessonView, SIGNAL(selectedLessonChanged(KEduVocLesson*)),
00152         m_vocabularyModel, SLOT(setLesson(KEduVocLesson*)));
00153 
00154     connect(m_lessonView, SIGNAL(signalShowContainer(KEduVocContainer*)),
00155         m_vocabularyModel, SLOT(showContainer(KEduVocContainer*)));
00156 
00157     connect(m_vocabularyView, SIGNAL(translationChanged(KEduVocExpression*, int)),
00158         m_lessonView, SLOT(setTranslation(KEduVocExpression*, int)));
00159 
00160 
00161 // Word types dock
00162     QDockWidget* wordTypeDockWidget = new QDockWidget(i18n("Word Types"), this);
00163     wordTypeDockWidget->setObjectName( "WordTypeDock" );
00164     m_wordTypeView = new WordTypeView(this);
00165     wordTypeDockWidget->setWidget(m_wordTypeView);
00166     addDockWidget( Qt::LeftDockWidgetArea, wordTypeDockWidget );
00167     m_dockWidgets.append(wordTypeDockWidget);
00168 
00169     m_wordTypeModel = new WordTypeModel(this);
00170     wordTypeDockWidget->setVisible(false);
00171     actionCollection()->addAction("show_wordtype_dock", wordTypeDockWidget->toggleViewAction());
00172 
00175 //     new ModelTest(m_wordTypeModel, this);
00176 
00177     m_wordTypeView->setModel(m_wordTypeModel);
00178 
00179     connect(m_wordTypeView, SIGNAL(selectedWordTypeChanged(KEduVocWordType*)),
00180         m_vocabularyModel, SLOT(setWordType(KEduVocWordType*)));
00181 
00182     connect(m_wordTypeView, SIGNAL(signalShowContainer(KEduVocContainer*)),
00183         m_vocabularyModel, SLOT(showContainer(KEduVocContainer*)));
00184 
00185     connect(m_vocabularyView, SIGNAL(translationChanged(KEduVocExpression*, int)),
00186         m_wordTypeView, SLOT(setTranslation(KEduVocExpression*, int)));
00187 
00188 // Leitner boxes dock
00189     QDockWidget* leitnerDockWidget = new QDockWidget(i18n("Grade Boxes"), this);
00190     leitnerDockWidget->setObjectName( "LeitnerDock" );
00191     m_leitnerView = new LeitnerView(this);
00192     leitnerDockWidget->setWidget(m_leitnerView);
00193     addDockWidget( Qt::LeftDockWidgetArea, leitnerDockWidget );
00194     m_dockWidgets.append(leitnerDockWidget);
00195 
00196     m_leitnerModel = new LeitnerModel(this);
00197     leitnerDockWidget->setVisible(false);
00198     actionCollection()->addAction("show_leitner_dock", leitnerDockWidget->toggleViewAction());
00199 
00200     m_leitnerView->setModel(m_leitnerModel);
00201 
00202     connect(m_leitnerView, SIGNAL(selectedLeitnerBoxChanged(KEduVocLeitnerBox*)),
00203         m_vocabularyModel, SLOT(setLeitnerBox(KEduVocLeitnerBox*)));
00204 
00205     connect(m_leitnerView, SIGNAL(signalShowContainer(KEduVocContainer*)),
00206         m_vocabularyModel, SLOT(showContainer(KEduVocContainer*)));
00207 
00208     connect(m_vocabularyView, SIGNAL(translationChanged(KEduVocExpression*, int)),
00209         m_leitnerView, SLOT(setTranslation(KEduVocExpression*, int)));
00210 
00211 // Conjugations
00212     QDockWidget *conjugationDock = new QDockWidget(i18n("Conjugation"), this);
00213     conjugationDock->setObjectName("ConjugationDock");
00214     m_conjugationWidget = new ConjugationWidget(this);
00215     conjugationDock->setWidget(m_conjugationWidget);
00216     addDockWidget(Qt::RightDockWidgetArea, conjugationDock);
00217     m_dockWidgets.append(conjugationDock);
00218     conjugationDock->setVisible(false);
00219     actionCollection()->addAction("show_conjugation_dock", conjugationDock->toggleViewAction());
00220     connect(m_mainWindow->parleyDocument(), SIGNAL(documentChanged(KEduVocDocument*)),
00221         m_conjugationWidget, SLOT(setDocument(KEduVocDocument*)));
00222     connect(m_vocabularyView, SIGNAL(translationChanged(KEduVocExpression*, int)),
00223         m_conjugationWidget, SLOT(setTranslation(KEduVocExpression*, int)));
00224 
00225 // Declensions
00226 //     QDockWidget *declensionDock = new QDockWidget(i18n("Declension"), this);
00227 //     declensionDock->setObjectName("DeclensionDock");
00228 //     DeclensionWidget *declensionWidget = new DeclensionWidget(this);
00229 //     declensionDock->setWidget(declensionWidget);
00230 //     addDockWidget(Qt::RightDockWidgetArea, declensionDock);
00231 //     m_dockWidgets.append(declensionDock);
00232 //     actionCollection()->addAction("show_declension_dock", declensionDock->toggleViewAction());
00233 //     declensionDock->setVisible(false);
00234 //     connect(m_mainWindow->parleyDocument(), SIGNAL(documentChanged(KEduVocDocument*)),
00235 //             declensionWidget, SLOT(setDocument(KEduVocDocument*)));
00236 //     connect(m_vocabularyView, SIGNAL(translationChanged(KEduVocExpression*, int)),
00237 //             declensionWidget, SLOT(setTranslation(KEduVocExpression*, int)));
00238 
00239 // Comparison forms
00240     QDockWidget *comparisonDock = new QDockWidget(i18n("Comparison forms"), this);
00241     comparisonDock->setObjectName("ComparisonDock");
00242     ComparisonWidget *comparisonWidget = new ComparisonWidget(this);
00243     comparisonDock->setWidget(comparisonWidget);
00244     addDockWidget(Qt::RightDockWidgetArea, comparisonDock);
00245     m_dockWidgets.append(comparisonDock);
00246     actionCollection()->addAction("show_comparison_dock", comparisonDock->toggleViewAction());
00247     comparisonDock->setVisible(false);
00248     connect(m_vocabularyView, SIGNAL(translationChanged(KEduVocExpression*, int)),
00249         comparisonWidget, SLOT(setTranslation(KEduVocExpression*, int)));
00250     connect(m_mainWindow->parleyDocument(), SIGNAL(documentChanged(KEduVocDocument*)), comparisonWidget, SLOT(setDocument(KEduVocDocument*)));
00251 
00252 // Multiple choice
00253     QDockWidget *multipleChoiceDock = new QDockWidget(i18n("Multiple Choice"), this);
00254     multipleChoiceDock->setObjectName("MultipleChoiceDock");
00255     MultipleChoiceWidget *multipleChoiceWidget = new MultipleChoiceWidget(this);
00256     multipleChoiceDock->setWidget(multipleChoiceWidget);
00257     addDockWidget(Qt::RightDockWidgetArea, multipleChoiceDock);
00258     m_dockWidgets.append(multipleChoiceDock);
00259     actionCollection()->addAction("show_multiplechoice_dock", multipleChoiceDock->toggleViewAction());
00260     multipleChoiceDock->setVisible(false);
00261     connect(m_vocabularyView, SIGNAL(translationChanged(KEduVocExpression*, int)),
00262         multipleChoiceWidget, SLOT(setTranslation(KEduVocExpression*, int)));
00263 
00264 // Synonym (and the same for antonym and false friends)
00265     QDockWidget *synonymDock = new QDockWidget(i18n("Synonyms"), this);
00266     synonymDock->setObjectName("SynonymDock");
00267     SynonymWidget *synonymWidget = new SynonymWidget(SynonymWidget::Synonym, this);
00268     synonymDock->setWidget(synonymWidget);
00269     addDockWidget(Qt::RightDockWidgetArea, synonymDock);
00270     m_dockWidgets.append(synonymDock);
00271     actionCollection()->addAction("show_synonym_dock", synonymDock->toggleViewAction());
00272     synonymDock->setVisible(false);
00273     connect(m_vocabularyView, SIGNAL(translationChanged(KEduVocExpression*, int)),
00274             synonymWidget, SLOT(setTranslation(KEduVocExpression*, int)));
00275 
00276     QDockWidget *antonymDock = new QDockWidget(i18n("Antonyms"), this);
00277     antonymDock->setObjectName("AntonymDock");
00278     SynonymWidget *antonymWidget = new SynonymWidget(SynonymWidget::Antonym, this);
00279     antonymDock->setWidget(antonymWidget);
00280     addDockWidget(Qt::RightDockWidgetArea, antonymDock);
00281     m_dockWidgets.append(antonymDock);
00282     actionCollection()->addAction("show_antonym_dock", antonymDock->toggleViewAction());
00283     antonymDock->setVisible(false);
00284     connect(m_vocabularyView, SIGNAL(translationChanged(KEduVocExpression*, int)),
00285             antonymWidget, SLOT(setTranslation(KEduVocExpression*, int)));
00286 
00287     QDockWidget *falseFriendDock = new QDockWidget(i18n("False Friends"), this);
00288     falseFriendDock->setObjectName("FalseFriendDock");
00289     SynonymWidget *falseFriendWidget = new SynonymWidget(SynonymWidget::FalseFriend, this);
00290     falseFriendDock->setWidget(falseFriendWidget);
00291     addDockWidget(Qt::RightDockWidgetArea, falseFriendDock);
00292     m_dockWidgets.append(falseFriendDock);
00293     actionCollection()->addAction("show_falsefriend_dock", falseFriendDock->toggleViewAction());
00294     falseFriendDock->setVisible(false);
00295     connect(m_vocabularyView, SIGNAL(translationChanged(KEduVocExpression*, int)),
00296             falseFriendWidget, SLOT(setTranslation(KEduVocExpression*, int)));
00297 
00298 // Pronunciation symbols - Use KCharSelect
00299     QDockWidget *charSelectDock = new QDockWidget(i18n("Phonetic Symbols"), this);
00300     charSelectDock->setObjectName("IPADock");
00301     KCharSelect *charSelectWidget = new KCharSelect(this,  KCharSelect::SearchLine | KCharSelect::BlockCombos | KCharSelect::CharacterTable);
00302     charSelectWidget->setCurrentChar(0x0250);
00303     charSelectDock->setWidget(charSelectWidget);
00304     addDockWidget(Qt::BottomDockWidgetArea, charSelectDock);
00305     m_dockWidgets.append(charSelectDock);
00306     actionCollection()->addAction("show_pronunciation_dock", charSelectDock->toggleViewAction());
00307     charSelectDock->setVisible(false);
00308     connect(charSelectWidget, SIGNAL(charSelected(const QChar &)), m_vocabularyView, SLOT(appendChar(const QChar &)));
00309 
00310 // Image
00311     QDockWidget *imageDock = new QDockWidget(i18n("Image"), this);
00312     imageDock->setObjectName("ImageDock");
00313     ImageChooserWidget *imageChooserWidget = new ImageChooserWidget(this);
00314     imageDock->setWidget(imageChooserWidget);
00315     addDockWidget(Qt::RightDockWidgetArea, imageDock);
00316     m_dockWidgets.append(imageDock);
00317     actionCollection()->addAction("show_image_dock", imageDock->toggleViewAction());
00318     imageDock->setVisible(false);
00319     connect(m_vocabularyView, SIGNAL(translationChanged(KEduVocExpression*, int)),
00320         imageChooserWidget, SLOT(setTranslation(KEduVocExpression*, int)));
00321 
00322 // Summary word
00323     QDockWidget *summaryDock = new QDockWidget(i18n("Summary"), this);
00324     summaryDock->setObjectName("SummaryDock");
00325     m_summaryWordWidget = new SummaryWordWidget(m_vocabularyFilter, m_mainWindow->parleyDocument()->document(), this);
00326     summaryDock->setWidget(m_summaryWordWidget);
00327     addDockWidget(Qt::RightDockWidgetArea, summaryDock);
00328     actionCollection()->addAction("show_summary_dock", summaryDock->toggleViewAction());
00329     summaryDock->setVisible(false);
00330     m_dockWidgets.append(summaryDock);
00331     connect(m_mainWindow->parleyDocument(), SIGNAL(documentChanged(KEduVocDocument *)),
00332             m_summaryWordWidget, SLOT(slotDocumentChanged(KEduVocDocument *)));
00333     connect(m_vocabularyView, SIGNAL(translationChanged(KEduVocExpression*, int)),
00334             m_summaryWordWidget, SLOT(setTranslation(KEduVocExpression*, int)));
00335 
00336 // Sound
00337     QDockWidget *audioDock = new QDockWidget(i18n("Sound"), this);
00338     audioDock->setObjectName("AudioDock");
00339     AudioWidget *audioWidget = new AudioWidget(this);
00340     audioDock->setWidget(audioWidget);
00341     addDockWidget(Qt::RightDockWidgetArea, audioDock);
00342     m_dockWidgets.append(audioDock);
00343     actionCollection()->addAction("show_audio_dock", audioDock->toggleViewAction());
00344     audioDock->setVisible(false);
00345     connect(m_vocabularyView, SIGNAL(translationChanged(KEduVocExpression*, int)),
00346         audioWidget, SLOT(setTranslation(KEduVocExpression*, int)));
00347 
00348 // browser
00349     QDockWidget *browserDock = new QDockWidget(i18n("Internet"), this);
00350     browserDock->setObjectName("BrowserDock");
00351     //TinyWebBrowser *browserWidget = new TinyWebBrowser(this);
00352     BrowserWidget *htmlPart = new BrowserWidget(browserDock);
00353     browserDock->setWidget(htmlPart);
00354     addDockWidget(Qt::RightDockWidgetArea, browserDock);
00355     m_dockWidgets.append(browserDock);
00356     actionCollection()->addAction("show_browser_dock", browserDock->toggleViewAction());
00357     browserDock->setVisible(false);
00358     connect(m_vocabularyView, SIGNAL(translationChanged(KEduVocExpression*, int)),
00359             htmlPart, SLOT(setTranslation(KEduVocExpression*, int)));
00360 
00361 // Grades
00362 //     QDockWidget *gradeDock = new QDockWidget(i18n("Grade"), this);
00363 //     gradeDock->setObjectName("gradeDock");
00364 //     QLabel *gradeWidget = new QLabel("grade placeholder", this);
00365 //     gradeDock->setWidget(gradeWidget);
00366 //     addDockWidget(Qt::RightDockWidgetArea, gradeDock);
00367 //     connect(this, SIGNAL(signalSetData(KEduVocTranslation*)), m_declensionWidget, SLOT(setTranslation(KEduVocTranslation*)));
00368 
00369 // actionCollection()->addAction("show_leitner_dock", ->toggleViewAction());
00370 }
00371 
00372 void Editor::initActions()
00373 {
00374     KAction* editLanguages =new KAction(this);
00375     actionCollection()->addAction("edit_languages", editLanguages);
00376     editLanguages->setIcon(KIcon("set-language"));
00377     editLanguages->setText(i18n("&Languages..."));
00378     editLanguages->setWhatsThis(i18n("Edit which languages are in the collection and their grammar properties."));
00379     editLanguages->setToolTip(editLanguages->whatsThis());
00380     editLanguages->setStatusTip(editLanguages->whatsThis());
00381     connect(editLanguages, SIGNAL(triggered()),  this, SLOT(slotLanguageProperties()));
00383 
00384     KAction *removeGrades = new KAction(this);
00385     actionCollection()->addAction("vocab_remove_grades", removeGrades);
00386     removeGrades->setIcon(KIcon("edit-clear"));
00387     removeGrades->setText(i18n("Remove Grades"));
00388     connect(removeGrades, SIGNAL(triggered(bool)), this, SLOT(removeGrades()));
00389     removeGrades->setWhatsThis(i18n("Remove all grades from the current document"));
00390     removeGrades->setToolTip(removeGrades->whatsThis());
00391     removeGrades->setStatusTip(removeGrades->whatsThis());
00392 
00393     KAction *checkSpelling = KStandardAction::spelling(m_vocabularyView, SLOT(checkSpelling()), actionCollection());
00394 
00395     KAction *showSublessonentries = actionCollection()->add<KToggleAction>("lesson_showsublessonentries");
00396     showSublessonentries->setText(i18n("Show Entries from Child Lessons"));
00397     connect(showSublessonentries, SIGNAL(triggered(bool)), m_vocabularyModel, SLOT(showEntriesOfSubcontainers(bool)));
00398     showSublessonentries->setWhatsThis(i18n("Enable to also see the entries of child lessons in each lesson."));
00399     showSublessonentries->setToolTip(showSublessonentries->whatsThis());
00400     showSublessonentries->setStatusTip(showSublessonentries->whatsThis());
00401     showSublessonentries->setChecked(Prefs::showSublessonentries());
00402 
00403     KAction *automaticTranslation = actionCollection()->add<KToggleAction>("lesson_automatictranslation");
00404     automaticTranslation->setText(i18n("Automatic Translation"));
00405     connect(automaticTranslation, SIGNAL(triggered(bool)), m_vocabularyModel, SLOT(automaticTranslation(bool)));
00406     automaticTranslation->setWhatsThis(i18n("Enable automatic translation of the lesson entries."));
00407     automaticTranslation->setToolTip(automaticTranslation->whatsThis());
00408     automaticTranslation->setStatusTip(automaticTranslation->whatsThis());
00409     automaticTranslation->setChecked(Prefs::automaticTranslation());
00410 
00411     KAction* startPractice = new KAction(this);
00412     startPractice->setText(i18n("Start Practice..."));
00413     startPractice->setIcon(KIcon("practice-start"));
00414     startPractice->setWhatsThis(i18n("Start a test"));
00415     startPractice->setToolTip(startPractice->whatsThis());
00416     startPractice->setStatusTip(startPractice->whatsThis());
00417     actionCollection()->addAction("practice_start", startPractice);
00418     connect(startPractice, SIGNAL(triggered(bool)), m_mainWindow, SLOT(startPractice()));
00419 
00420 // -- PRACTICE --------------------------------------------------
00421 
00422     KAction* configurePractice = new KAction(this);
00423     configurePractice->setText(i18n("Configure Practice..."));
00424     configurePractice->setIcon(KIcon("practice-setup"));
00425     configurePractice->setWhatsThis(i18n("Change practice settings"));
00426     configurePractice->setToolTip(configurePractice->whatsThis());
00427     configurePractice->setStatusTip(configurePractice->whatsThis());
00428     actionCollection()->addAction("practice_configure", configurePractice);
00429     connect(configurePractice, SIGNAL(triggered(bool)), m_mainWindow, SLOT(configurePractice()));
00430 
00431     KAction* showStatistics = new KAction(this);
00432     actionCollection()->addAction("show_statistics", showStatistics);
00433     showStatistics->setIcon(KIcon("view-statistics"));
00434     showStatistics->setText(i18n("&Statistics..."));
00435     connect(showStatistics, SIGNAL(triggered(bool)), m_mainWindow, SLOT(slotShowStatistics()));
00436     showStatistics->setWhatsThis(i18n("Show statistics for the current collection"));
00437     showStatistics->setToolTip(showStatistics->whatsThis());
00438     showStatistics->setStatusTip(showStatistics->whatsThis());
00439 
00440 // -- SETTINGS --------------------------------------------------
00441     m_vocabShowSearchBarAction = actionCollection()->add<KToggleAction>("config_show_search");
00442     m_vocabShowSearchBarAction->setText(i18n("Show Se&arch"));
00443     connect(m_vocabShowSearchBarAction, SIGNAL(triggered(bool)), this, SLOT(slotConfigShowSearch()));
00444     m_vocabShowSearchBarAction->setWhatsThis(i18n("Toggle display of the search bar"));
00445     m_vocabShowSearchBarAction->setToolTip(m_vocabShowSearchBarAction->whatsThis());
00446     m_vocabShowSearchBarAction->setStatusTip(m_vocabShowSearchBarAction->whatsThis());
00447     m_vocabShowSearchBarAction->setChecked(Prefs::showSearch());
00448 
00450     KAction* findVocabulary = KStandardAction::find(m_searchLine, SLOT(setFocus()), actionCollection());
00451 
00452     //Script Manager Menu Action
00453     KAction* menu_scriptManager =new KAction(this);
00454     actionCollection()->addAction("show_script_manager", menu_scriptManager);
00455     menu_scriptManager->setIcon(KIcon("set-language"));
00456     menu_scriptManager->setText(i18n("&Script Manager"));
00457     connect(menu_scriptManager, SIGNAL(triggered()),  this, SLOT(slotShowScriptManager()));
00458 }
00459 
00460 void Editor::initModel()
00461 {
00462     m_vocabularyModel = new VocabularyModel(this);
00463     m_vocabularyFilter = new VocabularyFilter(this);
00464     m_vocabularyFilter->setSourceModel(m_vocabularyModel);
00465     m_vocabularyView->setModel(m_vocabularyFilter);
00466 
00467     connect(m_mainWindow->parleyDocument(), SIGNAL(documentChanged(KEduVocDocument*)), m_vocabularyModel, SLOT(setDocument(KEduVocDocument*)));
00468     connect(m_mainWindow->parleyDocument(), SIGNAL(documentChanged(KEduVocDocument*)), m_vocabularyView, SLOT(setDocument(KEduVocDocument*)));
00469     connect(m_searchLine, SIGNAL(textChanged(const QString&)), m_vocabularyFilter, SLOT(setSearchString(const QString&)));
00470 }
00471 
00475 void Editor::initView()
00476 {
00477     // Parent of all
00478     QStackedWidget *stackedWidget = new QStackedWidget(this);
00479     setCentralWidget(stackedWidget);
00480 
00481     QWidget *mainWidget = new QWidget(this);
00482     stackedWidget->addWidget(mainWidget);
00483     QVBoxLayout *topLayout = new QVBoxLayout(mainWidget);
00484     topLayout->setMargin(KDialog::marginHint());
00485     topLayout->setSpacing(KDialog::spacingHint());
00486 
00487     m_searchLine = new KLineEdit(this);
00488     m_searchLine->show();
00489     m_searchLine->setFocusPolicy(Qt::ClickFocus);
00490     m_searchLine->setClearButtonShown(true);
00491     m_searchLine->setClickMessage(i18n("Enter search terms here"));
00492 
00493 //     m_searchLine->setToolTip(i18n("Search your vocabuary"));
00494 
00495     QLabel *label = new QLabel(i18n("S&earch:"), this);
00496     label->setBuddy(m_searchLine);
00497     label->show();
00498 
00499     m_searchWidget = new QWidget(this);
00500     QHBoxLayout* layout = new QHBoxLayout(m_searchWidget);
00501     layout->setSpacing(KDialog::spacingHint());
00502     layout->setMargin(0);
00503     layout->addWidget(label);
00504     layout->addWidget(m_searchLine);
00505 
00507     QVBoxLayout * rightLayout = new QVBoxLayout(mainWidget);
00508     rightLayout->setSpacing(KDialog::spacingHint());
00509     rightLayout->setMargin(0);
00510     rightLayout->addWidget(m_searchWidget);
00511     m_searchWidget->setVisible(Prefs::showSearch());
00512 
00513     m_vocabularyView = new VocabularyView(this);
00514     rightLayout->addWidget(m_vocabularyView, 1, 0);
00515 
00516     topLayout->addLayout(rightLayout);
00517 }
00518 
00519 void Editor::slotConfigShowSearch()
00520 {
00521     m_searchWidget->setVisible(m_searchWidget->isHidden());
00522     Prefs::setShowSearch(m_searchWidget->isVisible());
00523 }
00524 
00525 void Editor::slotShowScriptManager() {
00526     ScriptDialog * dialog = new ScriptDialog(m_scriptManager);
00527     dialog->show();
00528 }
00529 
00530 void Editor::setTableFont(const QFont& font)
00531 {
00532     m_vocabularyView->setFont(font);
00533     m_vocabularyView->reset();
00534 }
00535 
00536 void Editor::removeGrades()
00537 {
00538     m_mainWindow->parleyDocument()->document()->lesson()->resetGrades(-1, KEduVocContainer::Recursive);
00539 }
00540 
00541 void Editor::initScripts()
00542 {
00543     m_scriptManager = new ScriptManager(this);
00544 
00545     m_vocabularyView->setTranslator(m_scriptManager->translator());
00546 
00547     //Load scripts
00548     m_scriptManager->loadScripts();
00549 }
00550 
00551 void Editor::saveState()
00552 {
00553     m_vocabularyView->saveColumnVisibility();
00554 }
00555 
00556 void Editor::slotLanguageProperties()
00557 {
00558     LanguageProperties properties(this);
00559     if ( properties.exec() == KDialog::Accepted ) {
00560          m_vocabularyModel->resetLanguages();
00561     }
00562 }
00563 
00564 void Editor::slotDocumentProperties()
00565 {
00566     DocumentProperties* titleAuthorWidget = new DocumentProperties(ParleyDocument::instance()->document(), false, this);
00567     KDialog* titleAuthorDialog;
00568     titleAuthorDialog = new KDialog(this);
00569     titleAuthorDialog->setMainWidget( titleAuthorWidget );
00570 
00571     // the language options are only shown, when this is used to create a new document.
00572     titleAuthorWidget->languageGroupBox->setVisible(false);
00573     titleAuthorDialog->setCaption(i18nc("@title:window document properties", "Properties for %1", ParleyDocument::instance()->document()->url().url()));
00574     connect(titleAuthorDialog, SIGNAL(accepted()), titleAuthorWidget, SLOT(accept()));
00575     titleAuthorDialog->exec();
00576     delete titleAuthorDialog;
00577 }
00578 
00579 #include "editor.moc"

parley

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

kdeedu

Skip menu "kdeedu"
  •     lib
  • kalzium
  • kanagram
  • kig
  •   lib
  • klettres
  • kstars
  • libkdeedu
  •   keduvocdocument
  • marble
  • parley
  •   stepcore
Generated for kdeedu by doxygen 1.5.9-20090814
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal