annotate editor/edres.cpp @ 2294:7f6ba3b32f54

Cleanups.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 03 Jul 2019 10:28:43 +0300
parents e2ac08228a0f
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
403
d34922e6a244 Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1 #include "edres.h"
d34922e6a244 Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
2 #include "dmengine.h"
d34922e6a244 Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
3
d34922e6a244 Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
4
d34922e6a244 Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
5 QEDResourceModel::QEDResourceModel(QObject *parent)
d34922e6a244 Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
6 : QAbstractTableModel(parent)
d34922e6a244 Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
7 {
d34922e6a244 Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
8 }
d34922e6a244 Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
9
d34922e6a244 Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
10
d34922e6a244 Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
11 int QEDResourceModel::rowCount(const QModelIndex &parent) const
d34922e6a244 Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
12 {
d34922e6a244 Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
13 Q_UNUSED(parent);
d34922e6a244 Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
14 return nengineEffects;
d34922e6a244 Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
15 }
d34922e6a244 Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
16
d34922e6a244 Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
17
d34922e6a244 Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
18 int QEDResourceModel::columnCount(const QModelIndex &parent) const
d34922e6a244 Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
19 {
d34922e6a244 Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
20 Q_UNUSED(parent);
d34922e6a244 Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
21 return 2;
d34922e6a244 Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
22 }
d34922e6a244 Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
23
d34922e6a244 Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
24
d34922e6a244 Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
25 QVariant QEDResourceModel::data(const QModelIndex &index, int role) const
d34922e6a244 Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
26 {
d34922e6a244 Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
27 if (!index.isValid())
d34922e6a244 Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
28 return QVariant();
d34922e6a244 Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
29
d34922e6a244 Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
30 if (index.row() >= nengineEffects || index.row() < 0)
d34922e6a244 Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
31 return QVariant();
d34922e6a244 Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
32
d34922e6a244 Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
33 if (role == Qt::DisplayRole)
d34922e6a244 Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
34 {
d34922e6a244 Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
35 DMEffect *ef = &engineEffects[index.row()];
d34922e6a244 Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
36 switch (index.column())
d34922e6a244 Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
37 {
d34922e6a244 Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
38 case 0:
d34922e6a244 Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
39 return QString(ef->name);
d34922e6a244 Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
40
d34922e6a244 Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
41 case 1:
d34922e6a244 Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
42 return QVariant(ef->nparams);
d34922e6a244 Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
43 }
d34922e6a244 Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
44 }
d34922e6a244 Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
45 return QVariant();
d34922e6a244 Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
46 }
d34922e6a244 Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
47
d34922e6a244 Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
48
d34922e6a244 Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
49 QVariant QEDResourceModel::headerData(int section, Qt::Orientation orientation, int role) const
d34922e6a244 Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
50 {
d34922e6a244 Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
51 if (role != Qt::DisplayRole)
d34922e6a244 Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
52 return QVariant();
d34922e6a244 Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
53
d34922e6a244 Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
54 if (orientation == Qt::Horizontal)
d34922e6a244 Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
55 {
d34922e6a244 Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
56 switch (section) {
d34922e6a244 Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
57 case 0:
d34922e6a244 Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
58 return "Name";
d34922e6a244 Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
59
d34922e6a244 Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
60 case 1:
d34922e6a244 Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
61 return "# params";
d34922e6a244 Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
62 }
d34922e6a244 Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
63 }
d34922e6a244 Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
64 return QVariant();
d34922e6a244 Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
65 }
d34922e6a244 Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
66
d34922e6a244 Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
67
d34922e6a244 Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
68 Qt::ItemFlags QEDResourceModel::flags(const QModelIndex &index) const
d34922e6a244 Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
69 {
d34922e6a244 Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
70 if (!index.isValid())
d34922e6a244 Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
71 return Qt::ItemIsEnabled;
d34922e6a244 Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
72
d34922e6a244 Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
73 return QAbstractTableModel::flags(index); // | Qt::ItemIsEditable;
d34922e6a244 Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
74 }