38 int row =
index.row();
44 foreach(QStringList pre,
rule->preconditions())
49 if (pre[0] !=
"token" && pre[0] !=
"npctoken")
52 QStringList acceptable = pre;
53 acceptable.removeFirst();
54 acceptable.removeFirst();
64 foreach(QStringList post,
check->postconditions())
68 if ((post[0] !=
"settoken" && post[0] !=
"setnpctoken") || post[1] != pre[1] || !acceptable.contains(post[2]))
79 foreach(QStringList post,
rule->postconditions())
84 if (post[0] !=
"settoken" && post[0] !=
"setnpctoken")
95 foreach(QStringList pre,
check->preconditions())
99 if ((pre[0] !=
"token" && pre[0] !=
"npctoken") || pre[1] != post[1])
102 QStringList acceptable = pre;
103 acceptable.removeFirst();
104 acceptable.removeFirst();
105 if (!acceptable.contains(post[2]))
119 emit dataChanged(createIndex(
b, 0), createIndex(
b, 6));
125 emit dataChanged(createIndex(
r, 0), createIndex(
r, 6));
130 for (
int old : red + blue)
132 emit dataChanged(createIndex(old, 0), createIndex(old, 6));
146 return QModelIndex();
147 return createIndex(row, column);
152 return QModelIndex();
168 return data.join(
"\n");
176 if (role == Qt::BackgroundColorRole)
179 return QVariant::fromValue(QBrush(Qt::blue));
181 return QVariant::fromValue(QBrush(Qt::red));
185 if (role != Qt::DisplayRole && role != Qt::EditRole)
191 switch(
index.column())
194 return role == Qt::DisplayRole ? QVariant::fromValue(
rule->match().join(
"\n")) : QVariant::fromValue(
rule->match());
196 return role == Qt::DisplayRole ? QVariant::fromValue(
toDisplay(
rule->preconditions())) : QVariant::fromValue(
rule->preconditions());
198 return role == Qt::DisplayRole ? QVariant::fromValue(
toDisplay(
rule->replies())) : QVariant::fromValue(
rule->replies());
200 return role == Qt::DisplayRole ? QVariant::fromValue(
rule->messages().join(
"\n")) : QVariant::fromValue(
rule->messages());
202 return role == Qt::DisplayRole ? QVariant::fromValue(
toDisplay(
rule->postconditions())) : QVariant::fromValue(
rule->postconditions());
204 return role == Qt::DisplayRole ? QVariant::fromValue(
rule->include().join(
"\n")) : QVariant::fromValue(
rule->include());
212 if (orientation != Qt::Horizontal || role != Qt::DisplayRole)
220 return tr(
"pre-conditions");
222 return tr(
"player suggested replies");
224 return tr(
"NPC messages");
226 return tr(
"post-conditions");
228 return tr(
"includes");
236 if (!
index.isValid())
238 return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable;
245 if (role != Qt::EditRole)
250 switch (
index.column())
253 rule->setMatch(
value.value<QStringList>());
256 rule->setPreconditions(
value.value<QList<QStringList>>());
259 rule->setReplies(
value.value<QList<QStringList>>());
262 rule->setMessages(
value.value<QStringList>());
265 rule->setPostconditions(
value.value<QList<QStringList>>());
268 rule->setInclude(
value.value<QStringList>());
305 while (
count > 0 && row < myMessage->rules().size())
321 const int shift = up ? -1 : 1;
329 emit dataChanged(createIndex(up ? row - 1 : row, 0), createIndex(up ? row : row + 1, 6));
338 beginInsertRows(QModelIndex(), row + 1, row + 1);