File indexing completed on 2022-11-29 13:00:35

0001 /*
0002     SPDX-FileCopyrightText: 1999-2001 Ewald Arnold <kvoctrain@ewald-arnold.de>
0003     SPDX-FileCopyrightText: 2004-2007 Peter Hedlund <peter.hedlund@kdemail.net>
0004     SPDX-FileCopyrightText: 2007-2009 Frederik Gladhorn <gladhorn@kde.org>
0005     SPDX-FileCopyrightText: 2008 Daniel Laidig <d.laidig@gmx.de>
0006     SPDX-License-Identifier: GPL-2.0-or-later
0007 */
0008 
0009 #include "editor.h"
0010 
0011 #include <config-parley.h>
0012 
0013 // Qt models on top of the KEduVocDocument
0014 #include "containermodel.h"
0015 #include "lessonmodel.h"
0016 #include "vocabularyfilter.h"
0017 #include "vocabularymodel.h"
0018 #include "wordclassmodel.h"
0019 
0020 // Views
0021 #include "containerview.h"
0022 #include "lessonview.h"
0023 #include "vocabularyview.h"
0024 #include "wordtypeview.h"
0025 
0026 #include "audiowidget.h"
0027 #include "browserwidget.h"
0028 #include "comparisonwidget.h"
0029 #include "imagechooserwidget.h"
0030 #include "inflectionwidget.h"
0031 #include "latexwidget.h"
0032 #include "multiplechoicewidget.h"
0033 #include "parleyactions.h"
0034 #include "parleyadaptor.h"
0035 #include "parleymainwindow.h"
0036 #include "prefs.h"
0037 #include "settings/parleyprefs.h"
0038 #include "summarywordwidget.h"
0039 #include "synonymwidget.h"
0040 
0041 #include <KActionCollection>
0042 #include <KActionMenu>
0043 #include <KCharSelect>
0044 #include <KToggleAction>
0045 
0046 #include <QDockWidget>
0047 #include <QHeaderView>
0048 #include <QMenu>
0049 #include <QScrollArea>
0050 #include <QStackedWidget>
0051 #include <QTimer>
0052 
0053 using namespace Editor;
0054 
0055 EditorWindow::EditorWindow(ParleyMainWindow *parent)
0056     : KXmlGuiWindow(parent)
0057     , m_mainWindow(parent)
0058 {
0059     // KXmlGui
0060     setXMLFile(QStringLiteral("editorui.rc"));
0061     setObjectName(QStringLiteral("Editor"));
0062 
0063     setCorner(Qt::TopLeftCorner, Qt::LeftDockWidgetArea);
0064     setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea);
0065     setCorner(Qt::TopRightCorner, Qt::RightDockWidgetArea);
0066     setCorner(Qt::BottomRightCorner, Qt::RightDockWidgetArea);
0067 
0068     initView();
0069     initModel();
0070 
0071     initDockWidgets();
0072     initActions();
0073 
0074     KConfigGroup cfg(KSharedConfig::openConfig(QStringLiteral("parleyrc")), objectName());
0075     applyMainWindowSettings(cfg);
0076 
0077     connect(parent->parleyDocument(), &ParleyDocument::documentChanged, this, &EditorWindow::updateDocument);
0078     connect(parent->parleyDocument(), &ParleyDocument::languagesChanged, this, &EditorWindow::slotLanguagesChanged);
0079     connect(parent->parleyDocument(), SIGNAL(statesNeedSaving()), this, SLOT(saveState()));
0080     connect(parent, &ParleyMainWindow::preferencesChanged, this, &EditorWindow::applyPrefs);
0081 }
0082 
0083 EditorWindow::~EditorWindow()
0084 {
0085     saveState();
0086     KConfigGroup cfg(KSharedConfig::openConfig(QStringLiteral("parleyrc")), objectName());
0087     saveMainWindowSettings(cfg);
0088 }
0089 
0090 void EditorWindow::updateDocument(const std::shared_ptr<KEduVocDocument> &doc)
0091 {
0092     m_vocabularyView->setDocument(doc);
0093     m_vocabularyModel->setDocument(doc.get());
0094 
0095     m_lessonModel->setDocument(doc);
0096     m_wordTypeModel->setDocument(doc);
0097 
0098     m_summaryWordWidget->slotDocumentChanged(doc);
0099     m_inflectionWidget->setDocument(doc);
0100     m_comparisonWidget->setDocument(doc.get());
0101     m_synonymWidget->setDocument(doc.get());
0102     m_antonymWidget->setDocument(doc.get());
0103     m_falseFriendWidget->setDocument(doc.get());
0104     m_audioWidget->setDocument(doc.get());
0105 
0106     if (!m_mainWindow->parleyDocument()->document()) {
0107         return;
0108     }
0109 
0110     if (!doc) {
0111         return;
0112     }
0113 
0114     // expand the root items
0115     m_lessonView->expandToDepth(0);
0116     m_wordTypeView->expandToDepth(0);
0117 
0118     connect(m_vocabularyView->selectionModel(), &QItemSelectionModel::selectionChanged, m_summaryWordWidget, &SummaryWordWidget::slotSelectionChanged);
0119     connect(m_vocabularyView->selectionModel(), &QItemSelectionModel::selectionChanged, m_latexWidget, &LatexWidget::slotSelectionChanged);
0120 
0121     m_spellCheckMenu->menu()->clear();
0122     for (int i = 0; i < doc->identifierCount(); ++i) {
0123         QAction *languageSpellCheck = new QAction(doc->identifier(i).name(), m_spellCheckMenu->menu());
0124         m_spellCheckMenu->menu()->addAction(languageSpellCheck);
0125         connect(languageSpellCheck, &QAction::triggered, this, [=] {
0126             m_vocabularyView->checkSpelling(i);
0127         });
0128     }
0129 }
0130 
0131 void EditorWindow::initDockWidgets()
0132 {
0133     // Lesson dockwidget
0134     QDockWidget *lessonDockWidget = new QDockWidget(i18n("Units"), this);
0135     lessonDockWidget->setObjectName(QStringLiteral("LessonDock"));
0136     m_lessonView = new LessonView(this);
0137     lessonDockWidget->setWidget(m_lessonView);
0138     addDockWidget(Qt::LeftDockWidgetArea, lessonDockWidget);
0139     m_dockWidgets.append(lessonDockWidget);
0140     actionCollection()->addAction(QStringLiteral("show_units_dock"), lessonDockWidget->toggleViewAction());
0141 
0142     m_lessonModel = new LessonModel(this);
0143     m_lessonView->setModel(m_lessonModel);
0144     m_lessonView->setToolTip(
0145         i18n("Right click to add, delete, or rename units. \n"
0146              "With the checkboxes you can select which units you want to practice. \n"
0147              "Only checked units [x] will be asked in the practice!"));
0148 
0149     connect(m_lessonView, &LessonView::selectedLessonChanged, m_vocabularyModel, &VocabularyModel::setLesson);
0150 
0151     connect(m_lessonView, &LessonView::signalShowContainer, m_vocabularyModel, &VocabularyModel::showContainer);
0152 
0153     connect(m_vocabularyView, &VocabularyView::translationChanged, m_lessonView, &LessonView::setTranslation);
0154 
0155     // Word classes dock widget
0156     QDockWidget *wordTypeDockWidget = new QDockWidget(i18n("Word Types"), this);
0157     wordTypeDockWidget->setObjectName(QStringLiteral("WordTypeDock"));
0158     m_wordTypeView = new WordTypeView(this);
0159     wordTypeDockWidget->setWidget(m_wordTypeView);
0160     addDockWidget(Qt::LeftDockWidgetArea, wordTypeDockWidget);
0161     m_dockWidgets.append(wordTypeDockWidget);
0162 
0163     m_wordTypeModel = new WordClassModel(this);
0164     wordTypeDockWidget->setVisible(false);
0165     actionCollection()->addAction(QStringLiteral("show_wordtype_dock"), wordTypeDockWidget->toggleViewAction());
0166 
0167     ///@todo test, should be fixed with the lesson one though
0168     ///@todo remove before release
0169     //     new ModelTest(m_wordTypeModel, this);
0170 
0171     m_wordTypeView->setModel(m_wordTypeModel);
0172 
0173     connect(m_vocabularyView, &VocabularyView::translationChanged, m_wordTypeView, &WordTypeView::setTranslation);
0174 
0175     // Inflections
0176     QDockWidget *inflectionDock = new QDockWidget(i18n("Inflection (verbs, adjectives, nouns)"), this);
0177     inflectionDock->setObjectName(QStringLiteral("InflectionDock"));
0178     m_inflectionWidget = new InflectionWidget(this);
0179     QScrollArea *inflectionScrollArea = new QScrollArea(this);
0180     inflectionScrollArea->setWidgetResizable(true);
0181     inflectionScrollArea->setWidget(m_inflectionWidget);
0182     inflectionDock->setWidget(inflectionScrollArea);
0183     addDockWidget(Qt::RightDockWidgetArea, inflectionDock);
0184     m_dockWidgets.append(inflectionDock);
0185     actionCollection()->addAction(QStringLiteral("show_inflection_dock"), inflectionDock->toggleViewAction());
0186     connect(m_mainWindow->parleyDocument(), &ParleyDocument::documentChanged, m_inflectionWidget, &InflectionWidget::setDocument);
0187     connect(m_vocabularyView, &VocabularyView::translationChanged, m_inflectionWidget, &InflectionWidget::setTranslation);
0188 
0189     // Comparison forms
0190     QDockWidget *comparisonDock = new QDockWidget(i18n("Comparison Forms"), this);
0191     comparisonDock->setObjectName(QStringLiteral("ComparisonDock"));
0192     m_comparisonWidget = new ComparisonWidget(this);
0193     QScrollArea *comparisonScrollArea = new QScrollArea(this);
0194     comparisonScrollArea->setWidgetResizable(true);
0195     comparisonScrollArea->setWidget(m_comparisonWidget);
0196     comparisonDock->setWidget(comparisonScrollArea);
0197     addDockWidget(Qt::RightDockWidgetArea, comparisonDock);
0198     m_dockWidgets.append(comparisonDock);
0199     actionCollection()->addAction(QStringLiteral("show_comparison_dock"), comparisonDock->toggleViewAction());
0200     comparisonDock->setVisible(false);
0201     connect(m_vocabularyView, &VocabularyView::translationChanged, m_comparisonWidget, &ComparisonWidget::setTranslation);
0202     tabifyDockWidget(comparisonDock, inflectionDock);
0203 
0204     // Multiple choice
0205     QDockWidget *multipleChoiceDock = new QDockWidget(i18n("Multiple Choice"), this);
0206     multipleChoiceDock->setObjectName(QStringLiteral("MultipleChoiceDock"));
0207     MultipleChoiceWidget *multipleChoiceWidget = new MultipleChoiceWidget(this);
0208     QScrollArea *multipleChoiceScrollArea = new QScrollArea(this);
0209     multipleChoiceScrollArea->setWidgetResizable(true);
0210     multipleChoiceScrollArea->setWidget(multipleChoiceWidget);
0211     multipleChoiceDock->setWidget(multipleChoiceScrollArea);
0212     addDockWidget(Qt::RightDockWidgetArea, multipleChoiceDock);
0213     m_dockWidgets.append(multipleChoiceDock);
0214     actionCollection()->addAction(QStringLiteral("show_multiplechoice_dock"), multipleChoiceDock->toggleViewAction());
0215     multipleChoiceDock->setVisible(false);
0216     connect(m_vocabularyView, &VocabularyView::translationChanged, multipleChoiceWidget, &MultipleChoiceWidget::setTranslation);
0217 
0218     // Synonym (and the same for antonym and false friends)
0219     QDockWidget *synonymDock = new QDockWidget(i18n("Synonyms"), this);
0220     synonymDock->setObjectName(QStringLiteral("SynonymDock"));
0221     m_synonymWidget = new SynonymWidget(SynonymWidget::Synonym, this);
0222     QScrollArea *synonymScrollArea = new QScrollArea(this);
0223     synonymScrollArea->setWidgetResizable(true);
0224     synonymScrollArea->setWidget(m_synonymWidget);
0225     synonymDock->setWidget(synonymScrollArea);
0226     addDockWidget(Qt::RightDockWidgetArea, synonymDock);
0227     m_dockWidgets.append(synonymDock);
0228     actionCollection()->addAction(QStringLiteral("show_synonym_dock"), synonymDock->toggleViewAction());
0229     synonymDock->setVisible(false);
0230     connect(m_vocabularyView, &VocabularyView::translationChanged, m_synonymWidget, &SynonymWidget::setTranslation);
0231 
0232     QDockWidget *antonymDock = new QDockWidget(i18n("Antonyms"), this);
0233     antonymDock->setObjectName(QStringLiteral("AntonymDock"));
0234     m_antonymWidget = new SynonymWidget(SynonymWidget::Antonym, this);
0235     QScrollArea *antonymScrollArea = new QScrollArea(this);
0236     antonymScrollArea->setWidgetResizable(true);
0237     antonymScrollArea->setWidget(m_antonymWidget);
0238     antonymDock->setWidget(antonymScrollArea);
0239     addDockWidget(Qt::RightDockWidgetArea, antonymDock);
0240     m_dockWidgets.append(antonymDock);
0241     actionCollection()->addAction(QStringLiteral("show_antonym_dock"), antonymDock->toggleViewAction());
0242     antonymDock->setVisible(false);
0243     connect(m_vocabularyView, &VocabularyView::translationChanged, m_antonymWidget, &SynonymWidget::setTranslation);
0244     tabifyDockWidget(synonymDock, antonymDock);
0245 
0246     QDockWidget *falseFriendDock = new QDockWidget(i18n("False Friends"), this);
0247     falseFriendDock->setObjectName(QStringLiteral("FalseFriendDock"));
0248     m_falseFriendWidget = new SynonymWidget(SynonymWidget::FalseFriend, this);
0249     QScrollArea *falseFriendScrollArea = new QScrollArea(this);
0250     falseFriendScrollArea->setWidgetResizable(true);
0251     falseFriendScrollArea->setWidget(m_falseFriendWidget);
0252     falseFriendDock->setWidget(falseFriendScrollArea);
0253     addDockWidget(Qt::RightDockWidgetArea, falseFriendDock);
0254     m_dockWidgets.append(falseFriendDock);
0255     actionCollection()->addAction(QStringLiteral("show_falsefriend_dock"), falseFriendDock->toggleViewAction());
0256     falseFriendDock->setVisible(false);
0257     connect(m_vocabularyView, &VocabularyView::translationChanged, m_falseFriendWidget, &SynonymWidget::setTranslation);
0258     tabifyDockWidget(antonymDock, falseFriendDock);
0259 
0260     // Pronunciation symbols - Use KCharSelect
0261     QDockWidget *charSelectDock = new QDockWidget(i18n("Phonetic Symbols"), this);
0262     charSelectDock->setObjectName(QStringLiteral("IPADock"));
0263     KCharSelect *charSelectWidget = new KCharSelect(this, 0, KCharSelect::SearchLine | KCharSelect::BlockCombos | KCharSelect::CharacterTable);
0264     charSelectWidget->setCurrentChar(0x0250);
0265     QScrollArea *charSelectScrollArea = new QScrollArea(this);
0266     charSelectScrollArea->setWidgetResizable(true);
0267     charSelectScrollArea->setWidget(charSelectWidget);
0268     charSelectDock->setWidget(charSelectScrollArea);
0269     addDockWidget(Qt::BottomDockWidgetArea, charSelectDock);
0270     m_dockWidgets.append(charSelectDock);
0271     actionCollection()->addAction(QStringLiteral("show_pronunciation_dock"), charSelectDock->toggleViewAction());
0272     charSelectDock->setVisible(false);
0273     connect(charSelectWidget, &KCharSelect::charSelected, m_vocabularyView, &VocabularyView::appendChar);
0274 
0275     // Image
0276     QDockWidget *imageDock = new QDockWidget(i18n("Image"), this);
0277     imageDock->setObjectName(QStringLiteral("ImageDock"));
0278     ImageChooserWidget *imageChooserWidget = new ImageChooserWidget(this);
0279     QScrollArea *imageScrollArea = new QScrollArea(this);
0280     imageScrollArea->setWidgetResizable(true);
0281     imageScrollArea->setWidget(imageChooserWidget);
0282     imageDock->setWidget(imageScrollArea);
0283     addDockWidget(Qt::RightDockWidgetArea, imageDock);
0284     m_dockWidgets.append(imageDock);
0285     actionCollection()->addAction(QStringLiteral("show_image_dock"), imageDock->toggleViewAction());
0286     imageDock->setVisible(false);
0287     connect(m_vocabularyView, &VocabularyView::translationChanged, imageChooserWidget, &ImageChooserWidget::setTranslation);
0288     tabifyDockWidget(multipleChoiceDock, imageDock);
0289 
0290     // Summary word
0291     QDockWidget *summaryDock = new QDockWidget(i18n("Summary"), this);
0292     summaryDock->setObjectName(QStringLiteral("SummaryDock"));
0293     m_summaryWordWidget = new SummaryWordWidget(m_vocabularyFilter, m_mainWindow->parleyDocument()->document(), this);
0294     QScrollArea *summaryScrollArea = new QScrollArea(this);
0295     summaryScrollArea->setWidgetResizable(true);
0296     summaryScrollArea->setWidget(m_summaryWordWidget);
0297     summaryDock->setWidget(summaryScrollArea);
0298     addDockWidget(Qt::BottomDockWidgetArea, summaryDock);
0299     actionCollection()->addAction(QStringLiteral("show_summary_dock"), summaryDock->toggleViewAction());
0300     summaryDock->setVisible(false);
0301     m_dockWidgets.append(summaryDock);
0302     connect(m_vocabularyView, &VocabularyView::translationChanged, m_summaryWordWidget, &SummaryWordWidget::setTranslation);
0303 
0304     // Sound
0305     QDockWidget *audioDock = new QDockWidget(i18n("Sound"), this);
0306     audioDock->setObjectName(QStringLiteral("AudioDock"));
0307     m_audioWidget = new AudioWidget(this);
0308     QScrollArea *audioScrollArea = new QScrollArea(this);
0309     audioScrollArea->setWidgetResizable(true);
0310     audioScrollArea->setWidget(m_audioWidget);
0311     audioDock->setWidget(audioScrollArea);
0312     addDockWidget(Qt::RightDockWidgetArea, audioDock);
0313     m_dockWidgets.append(audioDock);
0314     actionCollection()->addAction(QStringLiteral("show_audio_dock"), audioDock->toggleViewAction());
0315     audioDock->setVisible(false);
0316     connect(m_vocabularyView, &VocabularyView::translationChanged, m_audioWidget, &AudioWidget::setTranslation);
0317     tabifyDockWidget(imageDock, audioDock);
0318 
0319     // browser
0320     QDockWidget *browserDock = new QDockWidget(i18n("Internet"), this);
0321     browserDock->setObjectName(QStringLiteral("BrowserDock"));
0322     BrowserWidget *htmlPart = new BrowserWidget(browserDock);
0323     QScrollArea *browserScrollArea = new QScrollArea(this);
0324     browserScrollArea->setWidgetResizable(true);
0325     browserScrollArea->setWidget(htmlPart);
0326     browserDock->setWidget(browserScrollArea);
0327     addDockWidget(Qt::BottomDockWidgetArea, browserDock);
0328     m_dockWidgets.append(browserDock);
0329     actionCollection()->addAction(QStringLiteral("show_browser_dock"), browserDock->toggleViewAction());
0330     browserDock->setVisible(false);
0331     connect(m_vocabularyView, &VocabularyView::translationChanged, htmlPart, &BrowserWidget::setTranslation);
0332     tabifyDockWidget(summaryDock, browserDock);
0333 
0334     // LaTeX
0335     QDockWidget *latexDock = new QDockWidget(i18n("LaTeX"), this);
0336     latexDock->setObjectName(QStringLiteral("LatexDock"));
0337     m_latexWidget = new LatexWidget(m_vocabularyFilter, m_mainWindow->parleyDocument()->document().get(), this);
0338     QScrollArea *latexScrollArea = new QScrollArea(this);
0339     latexScrollArea->setWidgetResizable(true);
0340     latexScrollArea->setWidget(m_latexWidget);
0341     latexDock->setWidget(latexScrollArea);
0342     addDockWidget(Qt::RightDockWidgetArea, latexDock);
0343     actionCollection()->addAction(QStringLiteral("show_latex_dock"), latexDock->toggleViewAction());
0344     latexDock->setVisible(false);
0345     m_dockWidgets.append(latexDock);
0346     connect(m_vocabularyView, &VocabularyView::translationChanged, m_latexWidget, &LatexWidget::setTranslation);
0347     tabifyDockWidget(audioDock, latexDock);
0348 
0349     // Grades
0350     //     QDockWidget *gradeDock = new QDockWidget(i18n("Grade"), this);
0351     //     gradeDock->setObjectName("gradeDock");
0352     //     QLabel *gradeWidget = new QLabel("grade placeholder", this);
0353     //     gradeDock->setWidget(gradeWidget);
0354     //     addDockWidget(Qt::RightDockWidgetArea, gradeDock);
0355     //     connect(this, SIGNAL(signalSetData(KEduVocTranslation*)), m_declensionWidget, SLOT(setTranslation(KEduVocTranslation*)));
0356 }
0357 
0358 void EditorWindow::initActions()
0359 {
0360     ParleyActions::create(ParleyActions::RemoveGrades, this, SLOT(removeGrades()), actionCollection());
0361     m_spellCheckMenu = ParleyActions::create(ParleyActions::CheckSpelling, 0, "", actionCollection());
0362     m_spellCheckMenu->setMenu(new QMenu(this));
0363 
0364     ParleyActions::create(ParleyActions::ToggleShowSublessons, m_vocabularyModel, SLOT(showEntriesOfSubcontainers(bool)), actionCollection());
0365     ParleyActions::create(ParleyActions::AutomaticTranslation, m_vocabularyModel, SLOT(automaticTranslation(bool)), actionCollection());
0366     ParleyActions::create(ParleyActions::StartPractice, m_mainWindow, SLOT(showPracticeConfiguration()), actionCollection());
0367     actionCollection()->action(QStringLiteral("practice_start"))->setText(i18n("Practice"));
0368     actionCollection()->action(QStringLiteral("practice_start"))->setToolTip(i18n("Practice"));
0369     ParleyActions::create(ParleyActions::ConfigurePractice, m_mainWindow, SLOT(configurePractice()), actionCollection());
0370     ParleyActions::create(ParleyActions::ToggleSearchBar, this, SLOT(slotConfigShowSearch()), actionCollection());
0371     ParleyActions::create(ParleyActions::SearchVocabulary, this, SLOT(startSearch()), actionCollection());
0372     ParleyActions::create(ParleyActions::LanguagesProperties, m_mainWindow->parleyDocument(), SLOT(languageProperties()), actionCollection());
0373 
0374     new EditorWindowAdaptor(this);
0375 
0376     QDBusConnection dbus = QDBusConnection::sessionBus();
0377     dbus.registerObject(QStringLiteral("/AddWithTranslation"), this);
0378 }
0379 
0380 void EditorWindow::addWordWithTranslation(const QStringList &w)
0381 {
0382     KEduVocExpression *kexpr = new KEduVocExpression(w);
0383 
0384     m_vocabularyModel->appendEntry(kexpr);
0385 }
0386 
0387 void EditorWindow::initModel()
0388 {
0389     m_vocabularyModel = new VocabularyModel(this);
0390     m_vocabularyFilter = new VocabularyFilter(this);
0391     m_vocabularyFilter->setSourceModel(m_vocabularyModel);
0392     m_vocabularyView->setFilter(m_vocabularyFilter);
0393 
0394     //    connect(m_mainWindow->parleyDocument(), SIGNAL(documentChanged(KEduVocDocument*)), m_vocabularyModel, SLOT(setDocument(KEduVocDocument*)));
0395     //    connect(m_mainWindow->parleyDocument(), SIGNAL(documentChanged(KEduVocDocument*)), m_vocabularyView, SLOT(setDocument(KEduVocDocument*)));
0396     connect(m_searchLine, &QLineEdit::textChanged, m_vocabularyFilter, &VocabularyFilter::setSearchString);
0397 }
0398 
0399 /**
0400  * This initializes the main widgets and table.
0401  */
0402 void EditorWindow::initView()
0403 {
0404     QWidget *mainWidget = new QWidget(this);
0405     setCentralWidget(mainWidget);
0406     QVBoxLayout *topLayout = new QVBoxLayout(mainWidget);
0407 
0408     m_searchLine = new QLineEdit(this);
0409     m_searchLine->show();
0410     m_searchLine->setFocusPolicy(Qt::ClickFocus);
0411     m_searchLine->setClearButtonEnabled(true);
0412     m_searchLine->setPlaceholderText(i18n("Enter search terms here"));
0413     m_searchLine->setToolTip(i18n("Search your vocabulary"));
0414 
0415     QLabel *label = new QLabel(i18n("S&earch:"), this);
0416     label->setBuddy(m_searchLine);
0417     label->show();
0418 
0419     m_searchWidget = new QWidget(this);
0420     QHBoxLayout *layout = new QHBoxLayout(m_searchWidget);
0421     layout->setContentsMargins(0, 0, 0, 0);
0422     layout->addWidget(label);
0423     layout->addWidget(m_searchLine);
0424 
0425     ///@todo     centralWidget()-> delete layout
0426     QVBoxLayout *rightLayout = new QVBoxLayout();
0427     rightLayout->setContentsMargins(0, 0, 0, 0);
0428     rightLayout->addWidget(m_searchWidget);
0429     m_searchWidget->setVisible(Prefs::showSearch());
0430 
0431     m_vocabularyView = new VocabularyView(this);
0432     rightLayout->addWidget(m_vocabularyView, 1);
0433 
0434     topLayout->addLayout(rightLayout);
0435 }
0436 
0437 void EditorWindow::slotConfigShowSearch()
0438 {
0439     m_searchWidget->setVisible(m_searchWidget->isHidden());
0440     Prefs::setShowSearch(m_searchWidget->isVisible());
0441 }
0442 
0443 void EditorWindow::startSearch()
0444 {
0445     m_searchWidget->setVisible(true);
0446     m_searchLine->setFocus();
0447 }
0448 
0449 void EditorWindow::applyPrefs()
0450 {
0451     m_vocabularyView->reset();
0452 }
0453 
0454 void EditorWindow::removeGrades()
0455 {
0456     m_mainWindow->parleyDocument()->document()->lesson()->resetGrades(-1, KEduVocContainer::Recursive);
0457 }
0458 
0459 void EditorWindow::saveState()
0460 {
0461     m_vocabularyView->saveColumnVisibility();
0462 }
0463 
0464 void EditorWindow::slotLanguagesChanged()
0465 {
0466     m_vocabularyModel->resetLanguages();
0467 }