mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/RRJServer.git
synced 2026-03-27 19:45:43 +03:00
42 lines
1.2 KiB
C++
42 lines
1.2 KiB
C++
#include "customdelegate.h"
|
|
|
|
CustomDelegate::CustomDelegate(QObject *parent):
|
|
QItemDelegate(parent)
|
|
{
|
|
|
|
}
|
|
|
|
void CustomDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
|
|
{
|
|
bool mergeCell = index.data(UserRole_MergeCell).toBool();
|
|
|
|
if (mergeCell && index.column() == 0)
|
|
{
|
|
QModelIndex nextColumnIndex = index.siblingAtColumn(index.column() + 1);
|
|
if (!nextColumnIndex.isValid())
|
|
{
|
|
QItemDelegate::paint(painter, option, index);
|
|
return;
|
|
}
|
|
|
|
QRect mergedRect(option.rect.x(),
|
|
option.rect.y(),
|
|
option.rect.width() * 2,
|
|
option.rect.height());
|
|
|
|
painter->save();
|
|
painter->setClipRect(mergedRect);
|
|
drawBackground(painter, option, index);
|
|
drawDisplay(painter, option, mergedRect, index.data(Qt::DisplayRole).toString());
|
|
|
|
painter->restore();
|
|
} else {
|
|
QItemDelegate::paint(painter, option, index);
|
|
}
|
|
}
|
|
|
|
QSize CustomDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
|
|
{
|
|
return QItemDelegate::sizeHint(option, index);
|
|
}
|