From b6c5ee125d8d334c3265da0cf01e55950ec349da Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Tue, 8 Jul 2014 09:24:05 +0200 Subject: [PATCH] more refactoring --- apps/opencs/view/world/util.cpp | 63 ++++++++++++++++----------------- 1 file changed, 30 insertions(+), 33 deletions(-) diff --git a/apps/opencs/view/world/util.cpp b/apps/opencs/view/world/util.cpp index 5d26b75c4f..0b06cfb362 100644 --- a/apps/opencs/view/world/util.cpp +++ b/apps/opencs/view/world/util.cpp @@ -143,50 +143,47 @@ QWidget *CSVWorld::CommandDelegate::createEditor (QWidget *parent, const QStyleO } } - if (display != CSMWorld::ColumnBase::Display_None) + switch (display) { - if (display == CSMWorld::ColumnBase::Display_Colour) - { - return new QLineEdit(parent); - } + case CSMWorld::ColumnBase::Display_Colour: - if (display == CSMWorld::ColumnBase::Display_Integer) - { - return new QSpinBox(parent); - } - if (display == CSMWorld::ColumnBase::Display_Var) - { return new QLineEdit(parent); - } - if (display == CSMWorld::ColumnBase::Display_Float) - { + + case CSMWorld::ColumnBase::Display_Integer: + + return new QSpinBox(parent); + + case CSMWorld::ColumnBase::Display_Var: + + return new QLineEdit(parent); + + case CSMWorld::ColumnBase::Display_Float: + return new QDoubleSpinBox(parent); - } - if (display == CSMWorld::ColumnBase::Display_LongString) - { + + case CSMWorld::ColumnBase::Display_LongString: + return new QTextEdit(parent); - } - if (display == CSMWorld::ColumnBase::Display_String || - display == CSMWorld::ColumnBase::Display_Skill || - display == CSMWorld::ColumnBase::Display_Script || - display == CSMWorld::ColumnBase::Display_Race || - display == CSMWorld::ColumnBase::Display_Class || - display == CSMWorld::ColumnBase::Display_Faction || - display == CSMWorld::ColumnBase::Display_Miscellaneous || - display == CSMWorld::ColumnBase::Display_Sound) - { - return new DropLineEdit(parent); - } - if (display == CSMWorld::ColumnBase::Display_Boolean) - { + + case CSMWorld::ColumnBase::Display_Boolean: + return new QCheckBox(parent); - } + + case CSMWorld::ColumnBase::Display_String: + case CSMWorld::ColumnBase::Display_Skill: + case CSMWorld::ColumnBase::Display_Script: + case CSMWorld::ColumnBase::Display_Race: + case CSMWorld::ColumnBase::Display_Class: + case CSMWorld::ColumnBase::Display_Faction: + case CSMWorld::ColumnBase::Display_Miscellaneous: + case CSMWorld::ColumnBase::Display_Sound: + + return new DropLineEdit(parent); } return QStyledItemDelegate::createEditor (parent, option, index); } - void CSVWorld::CommandDelegate::setEditLock (bool locked) { mEditLock = locked;