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

0001 /*
0002     SPDX-FileCopyrightText: 2007 Frederik Gladhorn <frederik.gladhorn@kdemail.net>
0003     SPDX-FileCopyrightText: 2008 Javier Goday <jgoday@gmail.com>
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 #ifndef SUMMARYWORDWIDGET_H
0007 #define SUMMARYWORDWIDGET_H
0008 
0009 #include "ui_summarywordwidget.h"
0010 
0011 #include <memory>
0012 
0013 #include <QItemDelegate>
0014 #include <QWidget>
0015 
0016 class QTreeView;
0017 class QDataWidgetMapper;
0018 class QItemSelection;
0019 class QModelIndex;
0020 class KEduVocDocument;
0021 class KEduVocExpression;
0022 
0023 class VocabularyFilter;
0024 class WordClassModel;
0025 
0026 namespace Editor
0027 {
0028 /**
0029 * Represents the overview of a KEduVocExpression
0030 * Shows the language word
0031 *       the lesson
0032         the word type
0033         pronunciation
0034         example
0035         paraphrase
0036         comment
0037 */
0038 class SummaryWordWidget : public QWidget, public Ui::SummaryWordWidget
0039 {
0040     Q_OBJECT
0041 
0042 public:
0043     SummaryWordWidget(VocabularyFilter *model, const std::shared_ptr<KEduVocDocument> &, QWidget *parent = nullptr);
0044 
0045 public Q_SLOTS:
0046     /**
0047      * Sets the selected word (KEduVocExpression) from the vocabularyView
0048      */
0049     void setTranslation(KEduVocExpression *entry, int translation);
0050 
0051     /**
0052      * Called when a KEduVocDocument change happened
0053      */
0054     void slotDocumentChanged(const std::shared_ptr<KEduVocDocument> &doc);
0055 
0056     /**
0057      * Called when the selection changed in the vocabulary view
0058      */
0059     void slotSelectionChanged(const QItemSelection &, const QItemSelection &);
0060 
0061     void wordTypeSelected(const QString &wordTypeName);
0062 
0063 private:
0064     /**
0065      * Clears the form and the comboboxes
0066      */
0067     void clear();
0068 
0069     /**
0070     * Fill the lesson combobox with the available lessons of the KEduVocDocument
0071 
0072     void populateLessonList(KEduVocExpression *entry);
0073     */
0074     /**
0075      * Fill the word types list with the available word types of the KEduVocDocument
0076      */
0077     void setCurrentWordType(KEduVocExpression *entry, int translation);
0078 
0079 private:
0080     VocabularyFilter *m_model{nullptr};
0081     std::shared_ptr<KEduVocDocument> m_doc;
0082     QDataWidgetMapper *m_mapper{nullptr};
0083     WordClassModel *m_wordTypeModel{nullptr};
0084     QTreeView *m_wordTypeView{nullptr};
0085     KEduVocExpression *m_entry{nullptr};
0086     int m_translationId{0};
0087 };
0088 
0089 class SummaryWordDelegate : public QItemDelegate
0090 {
0091     Q_OBJECT
0092 public:
0093     explicit SummaryWordDelegate(QObject *parent = nullptr);
0094 
0095     void setEditorData(QWidget *editor, const QModelIndex &index) const override;
0096 };
0097 }
0098 
0099 #endif