File indexing completed on 2024-05-05 17:04:26

0001 /* This file is part of the KDE project
0002  * Copyright (C) 2012 Arjen Hiemstra <ahiemstra@heimr.nl>
0003  *
0004  *  This program is free software; you can redistribute it and/or modify
0005  *  it under the terms of the GNU General Public License as published by
0006  *  the Free Software Foundation; either version 2 of the License, or
0007  *  (at your option) any later version.
0008  *
0009  *  This program is distributed in the hope that it will be useful,
0010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
0011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0012  *  GNU General Public License for more details.
0013  *
0014  *  You should have received a copy of the GNU General Public License
0015  *  along with this program; if not, write to the Free Software
0016  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
0017  */
0018 
0019 #ifndef KEYBOARDMODEL_H
0020 #define KEYBOARDMODEL_H
0021 
0022 #include <QAbstractListModel>
0023 #include <QQmlParserStatus>
0024 
0025 class KeyboardModel : public QAbstractListModel, public QQmlParserStatus
0026 {
0027     Q_OBJECT
0028     Q_INTERFACES(QQmlParserStatus)
0029     Q_PROPERTY(KeyboardMode mode READ keyboardMode WRITE setKeyboardMode NOTIFY keyboardModeChanged)
0030     Q_PROPERTY(bool useBuiltIn READ useBuiltIn NOTIFY useBuiltInChanged)
0031 
0032 public:
0033     enum Roles {
0034         TextRole = Qt::UserRole + 1,
0035         TypeRole,
0036         WidthRole
0037     };
0038 
0039     enum KeyboardMode {
0040         NormalMode,
0041         CapitalMode,
0042         NumericMode
0043     };
0044     Q_ENUMS(KeyboardMode)
0045 
0046     enum KeyType {
0047         NormalKey,
0048         SpacerKey,
0049         ShiftKey,
0050         EnterKey,
0051         BackspaceKey,
0052         NumericModeKey,
0053         CloseKey,
0054         LeftArrowKey,
0055         RightArrowKey
0056     };
0057     Q_ENUMS(KeyType)
0058 
0059     explicit KeyboardModel(QObject* parent = 0);
0060     ~KeyboardModel() override;
0061 
0062     void classBegin() override;
0063     void componentComplete() override;
0064 
0065     QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
0066     int rowCount(const QModelIndex& parent = QModelIndex()) const override;
0067 
0068     KeyboardMode keyboardMode() const;
0069     void setKeyboardMode(KeyboardModel::KeyboardMode mode);
0070 
0071     bool useBuiltIn() const;
0072 
0073 Q_SIGNALS:
0074     void keyboardModeChanged();
0075     bool useBuiltInChanged();
0076 
0077 private:
0078     class Private;
0079     Private * const d;
0080 };
0081 
0082 #endif // KEYBOARDMODEL_H