File indexing completed on 2022-11-29 18:12:55

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;
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
0045                          , RadicalButton::ButtonStatus newStatus );
0046     /**
0047      * Reset all buttons to the up and uncolored state
0048      */
0049     void clearSelections();
0050 
0051     void setSortByFrequency( bool enable );
0052 
0053   private:
0054     void buildRadicalButtons();
0055     void updateButtons();
0056 
0057     static const unsigned int number_of_radical_columns = 11;
0058     static const unsigned int maximumStrokeValue = 50;
0059 
0060     enum
0061     {
0062       Selection,
0063       Relational
0064     } CurrentMode;
0065 
0066     QString        m_relationalRadical;
0067     QSet<QString>  m_selectedRadicals;
0068     RadicalFile   *m_radicalInfo;
0069     bool           m_sortByFrequency;
0070 
0071     //Radical -> Button Mapping
0072     QHash<QString, RadicalButton*> m_buttons;
0073 };
0074 
0075 #endif