Warning, file /education/kiten/kanjibrowser/kanjibrowserview.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /*
0002     This file is part of Kiten, a KDE Japanese Reference Tool
0003     SPDX-FileCopyrightText: 2011 Daniel E. Moctezuma <democtezuma@gmail.com>
0004 
0005     SPDX-License-Identifier: LGPL-2.0-or-later
0006 */
0007 
0008 #ifndef KANJIBROWSERVIEW_H
0009 #define KANJIBROWSERVIEW_H
0010 
0011 #include "ui_kanjibrowserview.h"
0012 
0013 class EntryKanjidic;
0014 class QAction;
0015 class KanjiBrowser;
0016 class QListWidgetItem;
0017 
0018 class KanjiBrowserView : public QWidget, private Ui::KanjiBrowserView
0019 {
0020     Q_OBJECT
0021 
0022 public:
0023     /**
0024      * Constructor.
0025      *
0026      * @param parent parent QWidget
0027      */
0028     explicit KanjiBrowserView(QWidget *parent);
0029     ~KanjiBrowserView() override;
0030 
0031     /**
0032      * Initial setup.
0033      *
0034      * @param parent      parent to which we are going to add some QActions
0035      * @param kanji       hash containing kanji with its grades and number of strokes
0036      * @param kanjiGrades sorted list of grades found in KANJIDIC
0037      * @param strokeCount sorted list of strokes found in KANJIDIC
0038      */
0039     void setupView(KanjiBrowser *parent, const QHash<QString, QPair<int, int>> &kanji, QList<int> &kanjiGrades, QList<int> &strokeCount);
0040 
0041 Q_SIGNALS:
0042     /**
0043      * Emitted when the status bar changed.
0044      *
0045      * @param text new text to put in the status bar
0046      */
0047     void statusBarChanged(const QString &text);
0048 
0049 public Q_SLOTS:
0050     /**
0051      * Load the font settings.
0052      */
0053     void loadSettings();
0054 
0055 private Q_SLOTS:
0056     /**
0057      * Called when the user changed the grade
0058      * of a kanji to be shown in the ComboBox.
0059      *
0060      * @param grade kanji grade to filter
0061      */
0062     void changeGrade(const int grade);
0063     /**
0064      * Change StackedWidget to "Kanji Information" page.
0065      */
0066     void changeToInfoPage();
0067     /**
0068      * Change StackedWidget to "Kanji List" page.
0069      */
0070     void changeToListPage();
0071     /**
0072      * Called when the user changed the strokes
0073      * of a kanji to be shown in the ComboBox.
0074      *
0075      * @param strokes number of strokes of a kanji to filter
0076      */
0077     void changeStrokeCount(const int strokes);
0078     /**
0079      * Search for an item (kanji) in KANJIDIC.
0080      *
0081      * @param item item to search in the dictionary
0082      */
0083     void searchKanji(QListWidgetItem *item);
0084 
0085 private:
0086     /**
0087      * QFont to CSS font style conversion.
0088      *
0089      * @param font font to be convert
0090      */
0091     QString convertToCSS(const QFont &font);
0092     /**
0093      * Reload the KListWidget items.
0094      */
0095     void reloadKanjiList();
0096     /**
0097      * Shows the information of a kanji as HTML in a QTextBrowser.
0098      *
0099      * @param kanji kanji that will be displayed as HTML
0100      */
0101     void showKanjiInformation(const EntryKanjidic *kanji);
0102 
0103     /**
0104      * Copies last selected kanji to clipboard
0105      */
0106     void toClipboard();
0107 
0108     /**
0109      * Enumerations of our possible states in QStackedWidget.
0110      */
0111     enum Page { List, Info };
0112 
0113     enum Grade { AllJouyouGrades = 0, Grade7 = 7, Jinmeiyou = 9 };
0114 
0115     enum StrokesCount { NoStrokeLimit };
0116 
0117     /**
0118      * We need this as we are going to add some QActions to it.
0119      */
0120     KanjiBrowser *_parent;
0121     /**
0122      * We need to update this action's text from different functions.
0123      */
0124     QAction *_goToKanjiInfo;
0125     /**
0126      * We need to update this action's text from different functions.
0127      */
0128     QAction *_copyToClipboard;
0129     /**
0130      * Keep track of the current kanji being displayed in the Kanji Information page.
0131      */
0132     EntryKanjidic *_currentKanji;
0133     /**
0134      * A hash containing all the kanji (found in KANJIDIC) we need to filter.
0135      */
0136     QHash<QString, QPair<int, int>> _kanji;
0137     /**
0138      * A list containing all the kanji grades found in KANJIDIC.
0139      */
0140     QList<int> _gradeList;
0141     /**
0142      * A list containing all the number of strokes found in KANJIDIC.
0143      */
0144     QList<int> _strokesList;
0145     /**
0146      * Current kanji grades selected by the user to be filtered.
0147      */
0148     QList<int> _currentGradeList;
0149     /**
0150      * Current number of strokes selected by the user to be filtered.
0151      */
0152     QList<int> _currentStrokesList;
0153     /**
0154      * Font size of the kanji displayed in the Kanji Information page.
0155      */
0156     QVariant _kanjiSize;
0157     /**
0158      * Font used in kana (onyomi and kunyomi pronunciations of a kanji).
0159      */
0160     QFont _kanaFont;
0161     /**
0162      * Font used in information labels of a kanji (Grades, Strokes, etc.).
0163      */
0164     QFont _labelFont;
0165 };
0166 
0167 #endif