File indexing completed on 2023-11-26 03:55:52
0001 /* 0002 SPDX-FileCopyrightText: 2010 Daniel Laidig <laidig@kde.org> 0003 SPDX-License-Identifier: GPL-2.0-or-later 0004 */ 0005 #ifndef LATEXWIDGET_H 0006 #define LATEXWIDGET_H 0007 0008 #include "ui_latexwidget.h" 0009 0010 #include <QItemDelegate> 0011 #include <QItemSelection> 0012 #include <QWidget> 0013 0014 class QDataWidgetMapper; 0015 class KEduVocDocument; 0016 class KEduVocExpression; 0017 class KEduVocTranslation; 0018 0019 namespace Practice 0020 { 0021 class LatexRenderer; 0022 } 0023 0024 class VocabularyFilter; 0025 0026 namespace Editor 0027 { 0028 class LatexWidget : public QWidget, public Ui::LatexWidget 0029 { 0030 Q_OBJECT 0031 0032 public: 0033 LatexWidget(VocabularyFilter *model, KEduVocDocument *doc, QWidget *parent = nullptr); 0034 ~LatexWidget() override; 0035 0036 public Q_SLOTS: 0037 /** 0038 * Sets the selected word (KEduVocExpression) from the vocabularyView 0039 */ 0040 void setTranslation(KEduVocExpression *entry, int translation); 0041 0042 /** 0043 * Called when a KEduVocDocument change happened 0044 */ 0045 void slotDocumentChanged(KEduVocDocument *doc); 0046 0047 /** 0048 * Called when the selection changed in the vocabulary view 0049 */ 0050 void slotSelectionChanged(const QItemSelection &, const QItemSelection &); 0051 0052 void checkBoxToggled(); 0053 0054 void updateLatex(); 0055 0056 private: 0057 VocabularyFilter *m_model{nullptr}; 0058 KEduVocDocument *m_doc{nullptr}; 0059 QDataWidgetMapper *m_mapper{nullptr}; 0060 KEduVocTranslation *m_translation{nullptr}; 0061 QLabel m_hiddenLabel; 0062 Practice::LatexRenderer *m_renderer{nullptr}; 0063 }; 0064 0065 class LatexDelegate : public QItemDelegate 0066 { 0067 Q_OBJECT 0068 public: 0069 explicit LatexDelegate(QObject *parent = nullptr); 0070 0071 void setEditorData(QWidget *editor, const QModelIndex &index) const override; 0072 void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const override; 0073 void setMathModeCheckBox(QCheckBox *checkBox) 0074 { 0075 m_checkBox = checkBox; 0076 } 0077 0078 private: 0079 QCheckBox *m_checkBox{nullptr}; 0080 }; 0081 } 0082 0083 #endif // LATEXWIDGET_H