1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-26 18:35:20 +00:00

Rename ColorPickerDelegate to ColorDelegate

This commit is contained in:
Stanislav Bas 2015-06-12 23:09:31 +03:00
parent e516d37cbf
commit f19d07b404
5 changed files with 46 additions and 46 deletions

View File

@ -70,7 +70,7 @@ opencs_units (view/world
opencs_units_noqt (view/world opencs_units_noqt (view/world
subviews enumdelegate vartypedelegate recordstatusdelegate idtypedelegate datadisplaydelegate subviews enumdelegate vartypedelegate recordstatusdelegate idtypedelegate datadisplaydelegate
scripthighlighter idvalidator dialoguecreator physicssystem idcompletiondelegate scripthighlighter idvalidator dialoguecreator physicssystem idcompletiondelegate
colorpickerdelegate colordelegate
) )
opencs_units (view/widget opencs_units (view/widget

View File

@ -19,7 +19,7 @@
#include "../world/recordstatusdelegate.hpp" #include "../world/recordstatusdelegate.hpp"
#include "../world/idtypedelegate.hpp" #include "../world/idtypedelegate.hpp"
#include "../world/idcompletiondelegate.hpp" #include "../world/idcompletiondelegate.hpp"
#include "../world/colorpickerdelegate.hpp" #include "../world/colordelegate.hpp"
#include "../../model/settings/usersettings.hpp" #include "../../model/settings/usersettings.hpp"
@ -65,7 +65,7 @@ CSVDoc::ViewManager::ViewManager (CSMDoc::DocumentManager& documentManager)
new CSVWorld::IdTypeDelegateFactory()); new CSVWorld::IdTypeDelegateFactory());
mDelegateFactories->add (CSMWorld::ColumnBase::Display_Colour, mDelegateFactories->add (CSMWorld::ColumnBase::Display_Colour,
new CSVWorld::ColorPickerDelegateFactory()); new CSVWorld::ColorDelegateFactory());
std::vector<CSMWorld::ColumnBase::Display> idCompletionColumns = CSMWorld::IdCompletionManager::getDisplayTypes(); std::vector<CSMWorld::ColumnBase::Display> idCompletionColumns = CSMWorld::IdCompletionManager::getDisplayTypes();
for (std::vector<CSMWorld::ColumnBase::Display>::const_iterator current = idCompletionColumns.begin(); for (std::vector<CSMWorld::ColumnBase::Display>::const_iterator current = idCompletionColumns.begin();

View File

@ -0,0 +1,36 @@
#include "colordelegate.hpp"
#include <QPainter>
#include <QPushButton>
#include "../widget/coloreditor.hpp"
CSVWorld::ColorDelegate::ColorDelegate(CSMWorld::CommandDispatcher *dispatcher,
CSMDoc::Document& document,
QObject *parent)
: CommandDelegate(dispatcher, document, parent)
{}
void CSVWorld::ColorDelegate::paint(QPainter *painter,
const QStyleOptionViewItem &option,
const QModelIndex &index) const
{
QRect coloredRect(qRound(option.rect.x() + option.rect.width() / 4.0),
qRound(option.rect.y() + option.rect.height() / 4.0),
qRound(option.rect.width() / 2.0),
qRound(option.rect.height() / 2.0));
painter->save();
painter->fillRect(coloredRect, index.data().value<QColor>());
painter->setPen(Qt::black);
painter->drawRect(coloredRect);
painter->restore();
}
CSVWorld::CommandDelegate *CSVWorld::ColorDelegateFactory::makeDelegate(CSMWorld::CommandDispatcher *dispatcher,
CSMDoc::Document &document,
QObject *parent) const
{
return new ColorDelegate(dispatcher, document, parent);
}

View File

@ -1,5 +1,5 @@
#ifndef CSV_WORLD_COLORPICKERDELEGATE_HPP #ifndef CSV_WORLD_COLORDELEGATE_HPP
#define CSV_WORLD_COLORPICKERDELEGATE_HPP #define CSV_WORLD_COLORDELEGATE_HPP
#include "util.hpp" #include "util.hpp"
@ -12,19 +12,19 @@ namespace CSVWidget
namespace CSVWorld namespace CSVWorld
{ {
class ColorPickerDelegate : public CommandDelegate class ColorDelegate : public CommandDelegate
{ {
public: public:
ColorPickerDelegate(CSMWorld::CommandDispatcher *dispatcher, ColorDelegate(CSMWorld::CommandDispatcher *dispatcher,
CSMDoc::Document& document, CSMDoc::Document& document,
QObject *parent); QObject *parent);
virtual void paint(QPainter *painter, virtual void paint(QPainter *painter,
const QStyleOptionViewItem &option, const QStyleOptionViewItem &option,
const QModelIndex &index) const; const QModelIndex &index) const;
}; };
class ColorPickerDelegateFactory : public CommandDelegateFactory class ColorDelegateFactory : public CommandDelegateFactory
{ {
public: public:
virtual CommandDelegate *makeDelegate(CSMWorld::CommandDispatcher *dispatcher, virtual CommandDelegate *makeDelegate(CSMWorld::CommandDispatcher *dispatcher,

View File

@ -1,36 +0,0 @@
#include "colorpickerdelegate.hpp"
#include <QPainter>
#include <QPushButton>
#include "../widget/coloreditor.hpp"
CSVWorld::ColorPickerDelegate::ColorPickerDelegate(CSMWorld::CommandDispatcher *dispatcher,
CSMDoc::Document& document,
QObject *parent)
: CommandDelegate(dispatcher, document, parent)
{}
void CSVWorld::ColorPickerDelegate::paint(QPainter *painter,
const QStyleOptionViewItem &option,
const QModelIndex &index) const
{
QRect coloredRect(qRound(option.rect.x() + option.rect.width() / 4.0),
qRound(option.rect.y() + option.rect.height() / 4.0),
qRound(option.rect.width() / 2.0),
qRound(option.rect.height() / 2.0));
painter->save();
painter->fillRect(coloredRect, index.data().value<QColor>());
painter->setPen(Qt::black);
painter->drawRect(coloredRect);
painter->restore();
}
CSVWorld::CommandDelegate *CSVWorld::ColorPickerDelegateFactory::makeDelegate(CSMWorld::CommandDispatcher *dispatcher,
CSMDoc::Document &document,
QObject *parent) const
{
return new ColorPickerDelegate(dispatcher, document, parent);
}