2 * Copyright (C) 2009 Sakari Poussa
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, version 2.
10 #define CELLDELEGATE_H
12 #include <QItemDelegate>
18 class CellFilter : public QObject
23 CellFilter(QObject *parent=0) : QObject(parent)
29 void nextCell(QObject *);
32 bool eventFilter(QObject *dist, QEvent *event)
34 if (event->type() == QEvent::KeyPress) {
35 QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
36 static QString digits = QString("123456789");
37 if (digits.indexOf(keyEvent->text()) != -1) {
38 qDebug() << "Key press number";
39 int rc = QObject::eventFilter(dist, event);
40 emit nextCell(m_parent);
45 qDebug() << "Key press invalid";
55 class CellDelegate : public QItemDelegate
60 CellDelegate(QObject *parent = 0);
61 QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &,
62 const QModelIndex &index) const;
63 void setEditorData(QWidget *editor, const QModelIndex &index) const;
64 void setModelData(QWidget *editor, QAbstractItemModel *model,
65 const QModelIndex &index) const;
69 void nextCell(QObject *);
72 void commitAndCloseEditor();
78 #endif // CELLDELEGATE_H