summaryrefslogtreecommitdiff
path: root/src/dic-options/FieldsListModel.h
blob: 1cc4534944111f24f5e4735bf53059ae8a32068b (plain)
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
42
43
44
45
46
47
48
49
#ifndef FIELDSLISTMODEL_H
#define FIELDSLISTMODEL_H

#include <QAbstractTableModel>

#include "DictionaryOptionsDialog.h"
#include "../dictionary/Dictionary.h"

class FieldsListModel : public QAbstractTableModel
{
    Q_OBJECT

public:
    enum
        {
        EStyleRole = Qt::UserRole
        };

    FieldsListModel( DictionaryOptionsDialog* aParent ):
        QAbstractTableModel( aParent ), m_parent( aParent )
        {}

    int rowCount( const QModelIndex& /*parent*/ = QModelIndex() ) const
        { return m_parent->m_dict.fieldsNum(); }
    int columnCount( const QModelIndex& /*parent*/ = QModelIndex() ) const
        { return 2; }
    QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const;
    Qt::ItemFlags flags(const QModelIndex &index) const;
    bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
    bool insertRows(int position, int rows, const QModelIndex &/*parent*/);
    bool removeRows(int position, int rows, const QModelIndex &/*parent*/);
    void insertField(int aPos, Field *aField);
    void removeField( int aPos );
    Qt::DropActions supportedDropActions() const;
    QStringList mimeTypes() const;
    QMimeData* mimeData(const QModelIndexList &indexes) const;
    bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column,
                      const QModelIndex &parent);
    QVariant headerData(int section, Qt::Orientation orientation, int role) const;
    void moveIndexesUpDown(QModelIndexList aIndexes, int aDirection);

signals:
    void indexesDropped(QList<QPersistentModelIndex> aIndexes);

private:
    DictionaryOptionsDialog* m_parent;
};

#endif // FIELDSLISTMODEL_H