| 1 |
/*************************************************************************** |
| 2 |
* Copyright (C) 2012~2012 by CSSlayer * |
| 3 |
* [email protected] * |
| 4 |
* * |
| 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. * |
| 9 |
* * |
| 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. * |
| 14 |
* * |
| 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/>. * |
| 17 |
* * |
| 18 |
***************************************************************************/ |
| 19 |
|
| 20 |
#include <QAbstractItemModel> |
| 21 |
#include <QSet> |
| 22 |
#include "mactab.h" |
| 23 |
|
| 24 |
namespace fcitx_unikey { |
| 25 |
class MacroModel : public QAbstractTableModel { |
| 26 |
Q_OBJECT |
| 27 |
public: |
| 28 |
explicit MacroModel(QObject* parent = 0); |
| 29 |
virtual ~MacroModel(); |
| 30 |
|
| 31 |
virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; |
| 32 |
virtual int rowCount(const QModelIndex& parent = QModelIndex()) const; |
| 33 |
virtual int columnCount(const QModelIndex& parent = QModelIndex()) const; |
| 34 |
virtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const; |
| 35 |
void load(CMacroTable* table); |
| 36 |
void addItem(const QString& macro, const QString& word); |
| 37 |
void deleteItem(int row); |
| 38 |
void deleteAllItem(); |
| 39 |
void save(CMacroTable* m_table); |
| 40 |
bool needSave(); |
| 41 |
|
| 42 |
signals: |
| 43 |
void needSaveChanged(bool m_needSave); |
| 44 |
|
| 45 |
private: |
| 46 |
void setNeedSave(bool needSave); |
| 47 |
bool m_needSave; |
| 48 |
QSet<QString> m_keyset; |
| 49 |
QList<QPair< QString, QString > >m_list; |
| 50 |
}; |
| 51 |
|
| 52 |
} |