38 #include <QTableWidget>
42 : QItemDelegate(parent)
48 const QModelIndex &index)
const
51 QComboBox *editor =
new QComboBox(parent);
57 QSpinBox *editor =
new QSpinBox(parent);
58 connect(editor, &QAbstractSpinBox::editingFinished,
this,
59 &NotifyItemDelegate::commitAndCloseEditor);
62 if (
eTurnOn == index.column()) {
63 QCheckBox *editor =
new QCheckBox(parent);
72 QLineEdit *editor =
new QLineEdit(parent);
76 void NotifyItemDelegate::commitAndCloseEditor()
78 QLineEdit *editor = qobject_cast<QLineEdit *>(sender());
80 emit commitData(editor);
81 emit closeEditor(editor);
83 QComboBox *editor = qobject_cast<QComboBox *>(sender());
85 emit commitData(editor);
86 emit closeEditor(editor);
88 QSpinBox *editor = qobject_cast<QSpinBox *>(sender());
90 emit commitData(editor);
91 emit closeEditor(editor);
93 QCheckBox *editor = qobject_cast<QCheckBox *>(sender());
95 emit commitData(editor);
96 emit closeEditor(editor);
105 QLineEdit *edit = qobject_cast<QLineEdit *>(editor);
107 edit->setText(index.model()->data(index, Qt::EditRole).toString());
109 QComboBox *repeatEditor = qobject_cast<QComboBox *>(editor);
111 repeatEditor->setCurrentIndex(
112 repeatEditor->findText(index.model()->data(index, Qt::EditRole).toString()));
114 QSpinBox *expireEditor = qobject_cast<QSpinBox *>(editor);
116 expireEditor->setValue(index.model()->data(index, Qt::EditRole).toInt());
118 QCheckBox *enablePlayEditor = qobject_cast<QCheckBox *>(editor);
119 if (enablePlayEditor)
120 enablePlayEditor->setChecked(index.model()->data(index, Qt::EditRole).toBool());
127 const QModelIndex &index)
const
129 QLineEdit *edit = qobject_cast<QLineEdit *>(editor);
131 model->setData(index, edit->text());
133 QComboBox *repeatEditor = qobject_cast<QComboBox *>(editor);
135 model->setData(index, repeatEditor->currentText());
137 QSpinBox *expireEditor = qobject_cast<QSpinBox *>(editor);
139 model->setData(index, expireEditor->value(), Qt::EditRole);
141 QCheckBox *enablePlayEditor = qobject_cast<QCheckBox *>(editor);
142 if (enablePlayEditor) {
143 model->setData(index, enablePlayEditor->isChecked(), Qt::EditRole);
150 void NotifyItemDelegate::selectRow(
const QString &text)
154 QComboBox *combo = qobject_cast<QComboBox *>(sender());
155 QTableWidget *table =
new QTableWidget;
156 table =
dynamic_cast<QTableWidget *
>(combo->parent());
164 const QModelIndex &index)
const
166 QSize
s = QItemDelegate::sizeHint(option, index);
Uses to logging only inside notify plugin, can be convinient turned on/off.
NotifyItemDelegate(QObject *parent=nullptr)
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
QWidget * createEditor(QWidget *parent, const QStyleOptionViewItem &, const QModelIndex &index) const
static QStringList retryValues
void setEditorData(QWidget *editor, const QModelIndex &index) const
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const