29 virtual QWidget*
createEditor(QWidget* parent,
const QStyleOptionViewItem&,
const QModelIndex&)
const override
31 QComboBox*
box =
new QComboBox(parent);
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);
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);
77 QPushButton* deleteReply =
new QPushButton(tr(
"delete reply"),
this);
80 QPushButton* reset =
new QPushButton(tr(
"reset changes"),
this);
83 QHBoxLayout* buttons =
new QHBoxLayout();
85 buttons->addWidget(deleteReply);
86 buttons->addWidget(reset);
88 QVBoxLayout*
l =
new QVBoxLayout(
this);
90 l->addLayout(buttons);
100 int i =
type.toInt();
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");
137 QList<QStringList>
value;
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)