#include <QtGui>#include "datdelegate.h"datDelegate::datDelegate(QObject *parent) : QItemDelegate(parent){}QWidget *datDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &/* option */, const QModelIndex &/* index */) const{ QDateEdit *editor = new QDateEdit(parent); editor->setDisplayFormat("dd.MM.yy"); return editor;}void datDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const{ QDate value = index.model()->data(index, Qt::EditRole).toDate(); QDateEdit *dateEdit = static_cast<QDateEdit*>(editor); dateEdit->setDate(value);}void datDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const{ QDateEdit *dateEdit = static_cast<QDateEdit*>(editor); QDate value = dateEdit->date(); model->setData(index, value, Qt::EditRole);}void datDelegate::updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &/* index */) const{ editor->setGeometry(option.rect);}QString datDelegate::displayText(const QVariant &value, const QLocale &locale) const{ return locale.toString(value.toDate(), "dd:MM:yy");}
QString datDelegate::displayText(const QVariant &value, const QLocale &locale) const{ return locale.toString(value.toDate(), "dd:MM:yy");}