4 #include <QItemDelegate>
10 class CellFilter : public QObject
15 CellFilter(QObject *parent=0) : QObject(parent)
21 void nextCell(QObject *);
24 bool eventFilter(QObject *dist, QEvent *event)
26 if (event->type() == QEvent::KeyPress) {
27 QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
28 static QString digits = QString("123456789");
29 if (digits.indexOf(keyEvent->text()) != -1) {
30 qDebug() << "Key press number";
31 int rc = QObject::eventFilter(dist, event);
32 emit nextCell(m_parent);
37 qDebug() << "Key press invalid";
47 class CellDelegate : public QItemDelegate
52 CellDelegate(QObject *parent = 0);
53 QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &,
54 const QModelIndex &index) const;
55 void setEditorData(QWidget *editor, const QModelIndex &index) const;
56 void setModelData(QWidget *editor, QAbstractItemModel *model,
57 const QModelIndex &index) const;
61 void nextCell(QObject *);
64 void commitAndCloseEditor();
70 #endif // CELLDELEGATE_H