Initial commit of BudgetPro
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
#include "itemtextdelegate.h"
|
||||
|
||||
#include <QLineEdit>
|
||||
|
||||
ItemTextDelegate::ItemTextDelegate(QObject *parent) :
|
||||
QItemDelegate(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QWidget *ItemTextDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const
|
||||
{
|
||||
QLineEdit *editor = new QLineEdit(parent);
|
||||
editor->installEventFilter(const_cast<ItemTextDelegate *>(this));
|
||||
//editor->setFrame(false);
|
||||
return editor;
|
||||
}
|
||||
|
||||
void ItemTextDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const
|
||||
{
|
||||
QString value = index.model()->data(index, Qt::EditRole).toString();
|
||||
QLineEdit *dsb = static_cast<QLineEdit*>(editor);
|
||||
dsb->setText(value);
|
||||
}
|
||||
|
||||
void ItemTextDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
|
||||
const QModelIndex& index) const
|
||||
{
|
||||
QLineEdit *dsb = static_cast<QLineEdit*>(editor);
|
||||
//dsb->interpretText();
|
||||
//double value = dsb->value();
|
||||
model->setData(index, dsb->text(), Qt::EditRole);
|
||||
}
|
||||
|
||||
void ItemTextDelegate::updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option,
|
||||
const QModelIndex& /* index */) const
|
||||
{
|
||||
editor->setGeometry(option.rect);
|
||||
}
|
||||
Reference in New Issue
Block a user