1
/***************************************************************************
2
* Copyright (C) 2012~2012 by CSSlayer *
5
* This program is free software: you can redistribute it and/or modify *
6
* it under the terms of the GNU General Public License as published by *
7
* the Free Software Foundation, either version 3 of the License, or *
8
* (at your option) any later version. *
10
* This program is distributed in the hope that it will be useful, *
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13
* GNU General Public License for more details. *
15
* You should have received a copy of the GNU General Public License *
16
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
18
***************************************************************************/
20
#ifndef FCITX_TOOLS_GUI_MODEL_H_
21
#define FCITX_TOOLS_GUI_MODEL_H_
23
#include <QAbstractTableModel>
25
#include <QTextStream>
26
#include <QFutureWatcher>
31
class QuickPhraseModel : public QAbstractTableModel {
34
explicit QuickPhraseModel(QObject* parent = 0);
35
virtual ~QuickPhraseModel();
37
virtual Qt::ItemFlags flags(const QModelIndex& index) const;
38
virtual bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole);
39
virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
40
virtual int rowCount(const QModelIndex& parent = QModelIndex()) const;
41
virtual int columnCount(const QModelIndex& parent = QModelIndex()) const;
42
virtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
43
void load(const QString& file, bool append);
44
void loadData(QTextStream& stream);
45
void addItem(const QString& macro, const QString& word);
46
void deleteItem(int row);
48
QFutureWatcher< bool >* save(const QString& file);
49
void saveData(QTextStream& stream);
53
void needSaveChanged(bool m_needSave);
60
void parse(const QString& file);
61
bool saveData(const QString& file);
62
void setNeedSave(bool needSave);
64
QList<QPair< QString, QString > >m_list;
69
#endif // FCITX_TOOLS_GUI_MODEL_H_