File: dictmodel.h

package info (click to toggle)
fcitx5-skk 5.1.8-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 388 kB
  • sloc: cpp: 1,400; makefile: 3; sh: 1
file content (41 lines) | stat: -rw-r--r-- 1,028 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/*
 * SPDX-FileCopyrightText: 2013~2020 CSSlayer <wengxt@gmail.com>
 *
 * SPDX-License-Identifier: GPL-3.0-or-later
 *
 */

#ifndef DICTMODEL_H
#define DICTMODEL_H
#include <QAbstractItemModel>
#include <QFile>
#include <QSet>

namespace fcitx {

class SkkDictModel : public QAbstractListModel {
    Q_OBJECT
public:
    explicit SkkDictModel(QObject *parent = 0);
    int rowCount(const QModelIndex &parent = QModelIndex()) const override;
    QVariant data(const QModelIndex &index,
                  int role = Qt::DisplayRole) const override;
    bool removeRows(int row, int count,
                    const QModelIndex &parent = QModelIndex()) override;

    void load();
    void load(QFile &file);
    void defaults();
    bool save();
    void add(const QMap<QString, QString> &dict);
    bool moveDown(const QModelIndex &currentIndex);
    bool moveUp(const QModelIndex &currentIndex);

private:
    QSet<QString> m_knownKeys;
    QList<QMap<QString, QString>> m_dicts;
};

} // namespace fcitx

#endif // DICTMODEL_H