573,89 → 573,3 |
void IconDelegate::setTableView(QTableView* table){ |
tblView = table; |
} |
|
|
|
|
|
|
|
|
FileDelegate::FileDelegate( QObject * parent ) : QItemDelegate(parent) |
{ |
} |
|
|
|
|
|
QWidget *FileDelegate::createEditor(QWidget *parent, |
const QStyleOptionViewItem &/* option */, |
const QModelIndex & /* index */) const |
{ |
|
FileForm *editor = new FileForm(parent); |
|
return editor; |
|
} |
|
|
|
|
void FileDelegate::setEditorData(QWidget *editor, |
const QModelIndex &index) const |
{ |
|
|
const QAbstractItemModel * model = index.model(); |
FileForm *flFrm = static_cast<FileForm*>(editor); |
QVariant currentData = model->data(index,0); |
QByteArray bytes = currentData.toByteArray(); |
if (currentData.isValid()) flFrm->setData(bytes); |
else return; |
|
} |
|
|
|
|
void FileDelegate::setModelData( |
QWidget *editor, |
QAbstractItemModel *model, |
const QModelIndex& index) const { |
FileForm *flFrm = static_cast<FileForm*>(editor); |
if (!(flFrm->dataIsChanged())) return; |
|
m_Data = flFrm->data(); |
if (!m_Data.isEmpty()) { // åñëè ìàññèâ íå ïóñòîé |
model->setData(index, QVariant (m_Data), Qt::EditRole); |
|
} |
else { // åñëè ìàññèâ ïóñòîé (ôàéë óäàëèëè) |
QVariant val_null; |
model->setData(index, val_null, Qt::EditRole); |
|
} |
|
|
|
} |
|
|
|
void FileDelegate::updateEditorGeometry( |
QWidget *editor, |
const QStyleOptionViewItem &option, |
const QModelIndex& /* index */) const { |
|
|
// QRect r(option.rect.x() + option.rect.width()/2 - 7, option.rect.y() + option.rect.height()/2 - 7, 150, 100); |
// editor->setGeometry(r); |
|
editor->setGeometry(option.rect); |
} |
|
|
|
|