29 virtual QWidget*
createEditor(QWidget* parent,
const QStyleOptionViewItem&,
const QModelIndex&)
const override
31 QComboBox* box =
new QComboBox(parent);
32 box->addItem(get_reply_text_own(rt_say), QString::number(
static_cast<int>(rt_say)));
33 box->addItem(get_reply_text_own(rt_reply), QString::number(
static_cast<int>(rt_reply)));
34 box->addItem(get_reply_text_own(rt_question), QString::number(
static_cast<int>(rt_question)));
38 virtual void setEditorData(QWidget* editor,
const QModelIndex& index)
const override
40 QComboBox* box = qobject_cast<QComboBox*>(editor);
44 box->setCurrentIndex(box->findData(index.data(Qt::UserRole).toString()));
47 virtual void setModelData(QWidget* editor, QAbstractItemModel* model,
const QModelIndex& index)
const override
49 QComboBox* box = qobject_cast<QComboBox*>(editor);
52 model->setData(index, box->currentData(Qt::UserRole).toString(), Qt::UserRole);
55 virtual void updateEditorGeometry(QWidget* editor,
const QStyleOptionViewItem& option,
const QModelIndex&)
const override
57 editor->setGeometry(option.rect);
58 QComboBox* box = qobject_cast<QComboBox*>(editor);
67 setWindowTitle(tr(
"Player suggested replies"));
71 myReplies->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
74 QPushButton* addReply =
new QPushButton(tr(
"add reply"),
this);
75 connect(addReply, SIGNAL(clicked(
bool)),
this, SLOT(
onAddCondition(
bool)));
77 QPushButton* deleteReply =
new QPushButton(tr(
"delete reply"),
this);
80 QPushButton* reset =
new QPushButton(tr(
"reset changes"),
this);
81 connect(reset, SIGNAL(clicked(
bool)),
this, SLOT(
onReset(
bool)));
83 QHBoxLayout* buttons =
new QHBoxLayout();
84 buttons->addWidget(addReply);
85 buttons->addWidget(deleteReply);
86 buttons->addWidget(reset);
88 QVBoxLayout* l =
new QVBoxLayout(
this);
90 l->addLayout(buttons);
100 int i = type.toInt();
101 if (i < 0 || i > rt_question)
103 return get_reply_text_own(
static_cast<reply_type
>(i));
106 QTableWidgetItem*
createItem(
const QString& text,
const QString& edit)
108 QTableWidgetItem* wi =
new QTableWidgetItem(text);
109 wi->setData(Qt::UserRole, edit);
110 wi->setFlags(Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable);
127 myReplies->setHorizontalHeaderLabels(QStringList() <<
"What the player should say" <<
"What the player will be displayed as saying" <<
"Message type");
128 for (QStringList item :
data)
137 QList<QStringList> value;
138 for (
int r = 0; r <
myReplies->rowCount(); r++)
141 i <<
myReplies->item(r, 0)->data(Qt::DisplayRole).toString();
142 i <<
myReplies->item(r, 1)->data(Qt::DisplayRole).toString();
143 i <<
myReplies->item(r, 2)->data(Qt::UserRole).toString();
152 item <<
"*" <<
"?" <<
"0";
167 if (QMessageBox::question(
this,
"Confirm reset",
"Reset the replies to the initial values of the message?") != QMessageBox::StandardButton::Yes)