File indexing completed on 2024-04-21 03:42:01

0001 /*
0002     This file is part of Kiten, a KDE Japanese Reference Tool
0003     SPDX-FileCopyrightText: 2006 Joseph Kerian <jkerian@gmail.com>
0004 
0005     SPDX-License-Identifier: LGPL-2.0-or-later
0006 */
0007 
0008 #ifndef RADSELECTBUTTONGRID_H
0009 #define RADSELECTBUTTONGRID_H
0010 
0011 #include <QHash>
0012 #include <QList>
0013 #include <QSet>
0014 #include <QString>
0015 #include <QWidget>
0016 
0017 #include "radicalbutton.h"
0018 #include "radicalfile.h"
0019 
0020 class ButtonGrid : public QWidget
0021 {
0022     Q_OBJECT
0023 
0024 public:
0025     ButtonGrid(QWidget *parent, RadicalFile *radicalInfo);
0026     ~ButtonGrid() override = default;
0027 
0028 Q_SIGNALS:
0029     /**
0030      * Our generic message alert signal
0031      */
0032     void signalChangeStatusbar(const QString &text);
0033     /**
0034      * We Q_EMIT this whenever something changed. This gives our list of
0035      * suggested kanji
0036      */
0037     void possibleKanji(const QList<Kanji> &kanjiList);
0038     void clearButtonSelections();
0039 
0040 public Q_SLOTS:
0041     /**
0042      * Triggered by a button press
0043      */
0044     void radicalClicked(const QString &newrad, RadicalButton::ButtonStatus newStatus);
0045     /**
0046      * Reset all buttons to the up and uncolored state
0047      */
0048     void clearSelections();
0049 
0050     void setSortByFrequency(bool enable);
0051 
0052 private:
0053     void buildRadicalButtons();
0054     void updateButtons();
0055 
0056     static const unsigned int number_of_radical_columns = 11;
0057     static const unsigned int maximumStrokeValue = 50;
0058 
0059     enum { Selection, Relational } CurrentMode;
0060 
0061     QString m_relationalRadical;
0062     QSet<QString> m_selectedRadicals;
0063     RadicalFile *m_radicalInfo;
0064     bool m_sortByFrequency;
0065 
0066     // Radical -> Button Mapping
0067     QHash<QString, RadicalButton *> m_buttons;
0068 };
0069 
0070 #endif