~ubuntu-branches/ubuntu/trusty/fcitx/trusty-proposed

« back to all changes in this revision

Viewing changes to tools/gui/quickphrase-editor/model.h

  • Committer: Package Import Robot
  • Author(s): Aron Xu
  • Date: 2013-02-10 17:03:56 UTC
  • mfrom: (1.3.18) (33.1.3 experimental)
  • Revision ID: package-import@ubuntu.com-20130210170356-2yuv6xy3ed378kn0
Tags: 1:4.2.7-1
* New upstream release.
* New binary packages:
  - fcitx-libs-gclient: D-Bus client library for Glib
  - fcitx-libs-qt: D-Bus client library for Qt
  - fcitx-module-quickphrase-editor: Quick Phrase editor module

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
 *   Copyright (C) 2012~2012 by CSSlayer                                   *
 
3
 *   wengxt@gmail.com                                                      *
 
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
#ifndef FCITX_TOOLS_GUI_MODEL_H_
 
21
#define FCITX_TOOLS_GUI_MODEL_H_
 
22
 
 
23
#include <QAbstractTableModel>
 
24
#include <QSet>
 
25
#include <QTextStream>
 
26
#include <QFutureWatcher>
 
27
 
 
28
class QFile;
 
29
namespace fcitx {
 
30
 
 
31
class QuickPhraseModel : public QAbstractTableModel {
 
32
    Q_OBJECT
 
33
public:
 
34
    explicit QuickPhraseModel(QObject* parent = 0);
 
35
    virtual ~QuickPhraseModel();
 
36
 
 
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);
 
47
    void deleteAllItem();
 
48
    QFutureWatcher< bool >* save(const QString& file);
 
49
    void saveData(QTextStream& stream);
 
50
    bool needSave();
 
51
 
 
52
signals:
 
53
    void needSaveChanged(bool m_needSave);
 
54
 
 
55
private slots:
 
56
    void loadFinished();
 
57
    void saveFinished();
 
58
 
 
59
private:
 
60
    void parse(const QString& file);
 
61
    bool saveData(const QString& file);
 
62
    void setNeedSave(bool needSave);
 
63
    bool m_needSave;
 
64
    QList<QPair< QString, QString > >m_list;
 
65
};
 
66
 
 
67
}
 
68
 
 
69
#endif // FCITX_TOOLS_GUI_MODEL_H_