diff --git a/apps/opencs/CMakeLists.txt b/apps/opencs/CMakeLists.txt index 83a20ecaa1..88edf7bb1c 100644 --- a/apps/opencs/CMakeLists.txt +++ b/apps/opencs/CMakeLists.txt @@ -70,7 +70,7 @@ opencs_units (view/world opencs_units_noqt (view/world subviews enumdelegate vartypedelegate recordstatusdelegate idtypedelegate datadisplaydelegate scripthighlighter idvalidator dialoguecreator physicssystem idcompletiondelegate - colorpickerdelegate + colordelegate ) opencs_units (view/widget diff --git a/apps/opencs/view/doc/viewmanager.cpp b/apps/opencs/view/doc/viewmanager.cpp index e5bb7fe811..9699148512 100644 --- a/apps/opencs/view/doc/viewmanager.cpp +++ b/apps/opencs/view/doc/viewmanager.cpp @@ -19,7 +19,7 @@ #include "../world/recordstatusdelegate.hpp" #include "../world/idtypedelegate.hpp" #include "../world/idcompletiondelegate.hpp" -#include "../world/colorpickerdelegate.hpp" +#include "../world/colordelegate.hpp" #include "../../model/settings/usersettings.hpp" @@ -65,7 +65,7 @@ CSVDoc::ViewManager::ViewManager (CSMDoc::DocumentManager& documentManager) new CSVWorld::IdTypeDelegateFactory()); mDelegateFactories->add (CSMWorld::ColumnBase::Display_Colour, - new CSVWorld::ColorPickerDelegateFactory()); + new CSVWorld::ColorDelegateFactory()); std::vector idCompletionColumns = CSMWorld::IdCompletionManager::getDisplayTypes(); for (std::vector::const_iterator current = idCompletionColumns.begin(); diff --git a/apps/opencs/view/world/colordelegate.cpp b/apps/opencs/view/world/colordelegate.cpp new file mode 100644 index 0000000000..ae71f965a7 --- /dev/null +++ b/apps/opencs/view/world/colordelegate.cpp @@ -0,0 +1,36 @@ +#include "colordelegate.hpp" + +#include +#include + +#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()); + 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); +} + + diff --git a/apps/opencs/view/world/colorpickerdelegate.hpp b/apps/opencs/view/world/colordelegate.hpp similarity index 64% rename from apps/opencs/view/world/colorpickerdelegate.hpp rename to apps/opencs/view/world/colordelegate.hpp index a8e6d87fca..87051e86d8 100644 --- a/apps/opencs/view/world/colorpickerdelegate.hpp +++ b/apps/opencs/view/world/colordelegate.hpp @@ -1,5 +1,5 @@ -#ifndef CSV_WORLD_COLORPICKERDELEGATE_HPP -#define CSV_WORLD_COLORPICKERDELEGATE_HPP +#ifndef CSV_WORLD_COLORDELEGATE_HPP +#define CSV_WORLD_COLORDELEGATE_HPP #include "util.hpp" @@ -12,19 +12,19 @@ namespace CSVWidget namespace CSVWorld { - class ColorPickerDelegate : public CommandDelegate + class ColorDelegate : public CommandDelegate { public: - ColorPickerDelegate(CSMWorld::CommandDispatcher *dispatcher, - CSMDoc::Document& document, - QObject *parent); + ColorDelegate(CSMWorld::CommandDispatcher *dispatcher, + CSMDoc::Document& document, + QObject *parent); virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const; }; - class ColorPickerDelegateFactory : public CommandDelegateFactory + class ColorDelegateFactory : public CommandDelegateFactory { public: virtual CommandDelegate *makeDelegate(CSMWorld::CommandDispatcher *dispatcher, diff --git a/apps/opencs/view/world/colorpickerdelegate.cpp b/apps/opencs/view/world/colorpickerdelegate.cpp deleted file mode 100644 index 4feaa170e3..0000000000 --- a/apps/opencs/view/world/colorpickerdelegate.cpp +++ /dev/null @@ -1,36 +0,0 @@ -#include "colorpickerdelegate.hpp" - -#include -#include - -#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()); - 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); -} - -