summaryrefslogtreecommitdiffstats
path: root/mappingtreewidget.h
blob: f23daa1f8371c02caba5d94f13934ec2c1d7b1ae (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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
/*
  This program is free software; you can redistribute it and/or
  modify it under the terms of the GNU General Public License
  as published by the Free Software Foundation; either version
  2 of the License, or (at your option) any later version.
*/

#ifndef MAPPINGTREEWIDGET_H
#define MAPPINGTREEWIDGET_H

#include <QDialog>
#include <QSortFilterProxyModel>

#include "smtreeview.h"

class MappingTreeView;
class MappingTreeModel;
class QComboBox;
class QCheckBox;
class QStringListModel;
class MappingTreeResultModel;
class QLineEdit;
class MappingTreeProxy;

// defined in mappingtreemodel.h
struct MappingData;

class MappingTreeWidget : public QWidget {
    Q_OBJECT
    public:
        explicit MappingTreeWidget(QWidget *parent = 0);
        MappingData selectedItem() const;
        MappingTreeView *mappingTreeView() const { return mTree; }

    public slots:
        void addChild();
        void addActor();
        void addType();
        void deleteChild();
        void deleteType();

    protected:
        virtual void hideEvent(QHideEvent *event);

    private slots:
        void typeChanged(QString type);
        void editChild();
        void selectionChanged();
        void filter();
        void clearFilter();

    signals:
        void mappingChanged(int);

    private:
        const QModelIndex selected() const;
        MappingTreeView *mTree;
        MappingTreeModel *mModel;
        MappingTreeProxy *mProxy;
        QStringListModel *mTypesModel;
        QComboBox *mTypeBox;
        QLineEdit *mFilter;
        QPushButton *mDoFilter;
        QPushButton *mClearFilter;
        QPushButton *mAddType;
        QPushButton *mDeleteType;
        QPushButton *mRefresh;
        QAction *mAddChildA;
        QAction *mAddActorA;
        QAction *mDeleteChildA;
        QAction *mEditChildA;
};

class MappingTreeView : public SmTreeView {
    Q_OBJECT
    public:
        MappingTreeView(QWidget *parent = 0);

    signals:
        void addMapping();
        void removeMapping();
        void clearMappings();
        void shiftFocus();
        void acceptPics();

    protected:
        virtual void contextMenuEvent(QContextMenuEvent *e);
        virtual void keyPressEvent(QKeyEvent *e);
};

class MappingTreeResultView : public SmTreeView {
    Q_OBJECT
    public:
        explicit MappingTreeResultView(QWidget *parent = 0);

    signals:
        void shiftFocus();
        void removeMapping();

    protected:
        virtual void keyPressEvent(QKeyEvent *e);
};

class MappingEditWidget : public QWidget {
    Q_OBJECT
    public:
        explicit MappingEditWidget(QWidget *parent = 0);
        MappingTreeResultModel *model() const { return mResultModel; }
        MappingTreeWidget *treeWidget() const { return mMappingTree; }

    public slots:
        void addMapping();
        void removeMapping();
        void clearMapping();
        void setMappings(const QList<MappingData> &mappings);
        void expandAllResults();
        void shiftFocusResult();
        void shiftFocusMappings();

    private:
        MappingTreeWidget *mMappingTree;
        MappingTreeResultView *mMappingResult;
        MappingTreeResultModel *mResultModel;
        QPushButton *mAddMapping;
        QPushButton *mRemoveMapping;
        QPushButton *mClearMapping;
};

class MappingInputDialog : public QDialog {
    Q_OBJECT
    public:
        explicit MappingInputDialog(QWidget *parent, Qt::WindowFlags f = 0);
        QString mappingName() const;
        bool createRoot() const;

    private:
        QPushButton *mOk;
        QPushButton *mCancel;
        QLineEdit *mEditor;
        QCheckBox *mIsRoot;

};

class MappingEditDialog : public QDialog {
    Q_OBJECT
    public:
        explicit MappingEditDialog(QWidget *parent, Qt::WindowFlags f = 0);
        MappingEditWidget *editWidget() const { return mEditWidget; }

    private:
        MappingEditWidget *mEditWidget;
        QPushButton *mOk;
        QPushButton *mCancel;
};

class MappingTreeProxy : public QSortFilterProxyModel {
    Q_OBJECT
    public:
        explicit MappingTreeProxy(QObject *parent = 0);

    public slots:
        void setFilter(const QString &filter);

    protected:
        virtual bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const;

    private:
        QRegExp mFilter;
};

#endif // MAPPINGTREEWIDGET_H