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 RowDelegate : public QItemDelegate
60 RowDelegate(QObject *parent = 0);
63 void commitAndCloseEditor();
69 class CellDelegate : public QItemDelegate
74 CellDelegate(QObject *parent = 0);
75 QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &,
76 const QModelIndex &index) const;
77 void setEditorData(QWidget *editor, const QModelIndex &index) const;
78 void setModelData(QWidget *editor, QAbstractItemModel *model,
79 const QModelIndex &index) const;
83 void nextCell(QObject *);
86 void commitAndCloseEditor();
92 #endif // CELLDELEGATE_H