mirror of
https://github.com/OpenMW/openmw.git
synced 2025-06-19 19:11:32 +00:00
Fix region colors
This commit is contained in:
parent
7021d354c6
commit
b14404e9cc
2 changed files with 13 additions and 19 deletions
|
@ -692,32 +692,23 @@ namespace CSMWorld
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// \todo QColor is a GUI class and should not be in model. Need to think of an alternative
|
|
||||||
/// solution.
|
|
||||||
template<typename ESXRecordT>
|
template<typename ESXRecordT>
|
||||||
struct MapColourColumn : public Column<ESXRecordT>
|
struct MapColourColumn : public Column<ESXRecordT>
|
||||||
{
|
{
|
||||||
/// \todo Replace Display_Integer with something that displays the colour value more directly.
|
|
||||||
MapColourColumn()
|
MapColourColumn()
|
||||||
: Column<ESXRecordT> (Columns::ColumnId_MapColour, ColumnBase::Display_Colour)
|
: Column<ESXRecordT> (Columns::ColumnId_MapColour, ColumnBase::Display_Colour)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
virtual QVariant get (const Record<ESXRecordT>& record) const
|
virtual QVariant get (const Record<ESXRecordT>& record) const
|
||||||
{
|
{
|
||||||
int colour = record.get().mMapColor;
|
return record.get().mMapColor;
|
||||||
|
|
||||||
return QColor (colour & 0xff, (colour>>8) & 0xff, (colour>>16) & 0xff);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void set (Record<ESXRecordT>& record, const QVariant& data)
|
virtual void set (Record<ESXRecordT>& record, const QVariant& data)
|
||||||
{
|
{
|
||||||
ESXRecordT record2 = record.get();
|
ESXRecordT copy = record.get();
|
||||||
|
copy.mMapColor = data.toInt();
|
||||||
QColor colour = data.value<QColor>();
|
record.setModified (copy);
|
||||||
|
|
||||||
record2.mMapColor = (colour.blue() << 16) | (colour.green() << 8) | colour.red();
|
|
||||||
|
|
||||||
record.setModified (record2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool isEditable() const
|
virtual bool isEditable() const
|
||||||
|
|
|
@ -15,12 +15,15 @@ void CSVWorld::ColorDelegate::paint(QPainter *painter,
|
||||||
const QStyleOptionViewItem &option,
|
const QStyleOptionViewItem &option,
|
||||||
const QModelIndex &index) const
|
const QModelIndex &index) const
|
||||||
{
|
{
|
||||||
|
int colorInt = index.data().toInt();
|
||||||
|
QColor color(colorInt & 0xff, (colorInt >> 8) & 0xff, (colorInt >> 16) & 0xff);
|
||||||
|
|
||||||
QRect coloredRect(option.rect.x() + qRound(option.rect.width() / 4.0),
|
QRect coloredRect(option.rect.x() + qRound(option.rect.width() / 4.0),
|
||||||
option.rect.y() + qRound(option.rect.height() / 4.0),
|
option.rect.y() + qRound(option.rect.height() / 4.0),
|
||||||
option.rect.width() / 2,
|
option.rect.width() / 2,
|
||||||
option.rect.height() / 2);
|
option.rect.height() / 2);
|
||||||
painter->save();
|
painter->save();
|
||||||
painter->fillRect(coloredRect, index.data().value<QColor>());
|
painter->fillRect(coloredRect, color);
|
||||||
painter->setPen(Qt::black);
|
painter->setPen(Qt::black);
|
||||||
painter->drawRect(coloredRect);
|
painter->drawRect(coloredRect);
|
||||||
painter->restore();
|
painter->restore();
|
||||||
|
|
Loading…
Reference in a new issue