added missing columns for apparati records

pull/16/head
Marc Zinnschlag 12 years ago
parent 7fd277b87a
commit 929b38ff6a

@ -36,7 +36,8 @@ namespace CSMWorld
Display_Attribute,
Display_Boolean,
Display_SpellType,
Display_Script
Display_Script,
Display_ApparatusType
};
std::string mTitle;

@ -29,4 +29,40 @@ void CSMWorld::PotionRefIdAdapter::setData (const RefIdColumn *column, RefIdData
record.get().mData.mAutoCalc = value.toInt();
else
InventoryRefIdAdapter<ESM::Potion>::setData (column, data, index, value);
}
CSMWorld::ApparatusRefIdAdapter::ApparatusRefIdAdapter (const InventoryColumns& columns,
const RefIdColumn *type, const RefIdColumn *quality)
: InventoryRefIdAdapter<ESM::Apparatus> (UniversalId::Type_Apparatus, columns),
mType (type), mQuality (quality)
{}
QVariant CSMWorld::ApparatusRefIdAdapter::getData (const RefIdColumn *column,
const RefIdData& data, int index) const
{
const Record<ESM::Apparatus>& record = static_cast<const Record<ESM::Apparatus>&> (
data.getRecord (RefIdData::LocalIndex (index, UniversalId::Type_Apparatus)));
if (column==mType)
return record.get().mData.mType;
if (column==mQuality)
return record.get().mData.mQuality;
return InventoryRefIdAdapter<ESM::Apparatus>::getData (column, data, index);
}
void CSMWorld::ApparatusRefIdAdapter::setData (const RefIdColumn *column, RefIdData& data, int index,
const QVariant& value) const
{
Record<ESM::Apparatus>& record = static_cast<Record<ESM::Apparatus>&> (
data.getRecord (RefIdData::LocalIndex (index, UniversalId::Type_Apparatus)));
if (column==mType)
record.get().mData.mType = value.toInt();
else if (column==mQuality)
record.get().mData.mQuality = value.toFloat();
else
InventoryRefIdAdapter<ESM::Apparatus>::setData (column, data, index, value);
}

@ -4,6 +4,7 @@
#include <QVariant>
#include <components/esm/loadalch.hpp>
#include <components/esm/loadappa.hpp>
#include "record.hpp"
#include "refiddata.hpp"
@ -297,6 +298,24 @@ namespace CSMWorld
const QVariant& value) const;
///< If the data type does not match an exception is thrown.
};
class ApparatusRefIdAdapter : public InventoryRefIdAdapter<ESM::Apparatus>
{
const RefIdColumn *mType;
const RefIdColumn *mQuality;
public:
ApparatusRefIdAdapter (const InventoryColumns& columns, const RefIdColumn *type,
const RefIdColumn *quality);
virtual QVariant getData (const RefIdColumn *column, const RefIdData& data, int index)
const;
virtual void setData (const RefIdColumn *column, RefIdData& data, int index,
const QVariant& value) const;
///< If the data type does not match an exception is thrown.
};
}
#endif

@ -70,12 +70,18 @@ CSMWorld::RefIdCollection::RefIdCollection()
mColumns.push_back (RefIdColumn ("Auto Calc", ColumnBase::Display_Boolean));
const RefIdColumn *autoCalc = &mColumns.back();
mColumns.push_back (RefIdColumn ("Apparatus Type", ColumnBase::Display_ApparatusType));
const RefIdColumn *apparatusType = &mColumns.back();
mColumns.push_back (RefIdColumn ("Quality", ColumnBase::Display_Float));
const RefIdColumn *quality = &mColumns.back();
mAdapters.insert (std::make_pair (UniversalId::Type_Activator,
new NameRefIdAdapter<ESM::Activator> (UniversalId::Type_Activator, nameColumns)));
mAdapters.insert (std::make_pair (UniversalId::Type_Potion,
new PotionRefIdAdapter (inventoryColumns, autoCalc)));
mAdapters.insert (std::make_pair (UniversalId::Type_Apparatus,
new InventoryRefIdAdapter<ESM::Apparatus> (UniversalId::Type_Apparatus, inventoryColumns)));
new ApparatusRefIdAdapter (inventoryColumns, apparatusType, quality)));
mAdapters.insert (std::make_pair (UniversalId::Type_Armor,
new InventoryRefIdAdapter<ESM::Armor> (UniversalId::Type_Armor, inventoryColumns)));
mAdapters.insert (std::make_pair (UniversalId::Type_Book,

@ -54,6 +54,11 @@ CSVDoc::ViewManager::ViewManager (CSMDoc::DocumentManager& documentManager)
"Spell", "Ability", "Blight", "Disease", "Curse", "Power", 0
};
static const char *sApparatusTypes[] =
{
"Mortar & Pestle", "Albemic", "Calcinator", "Retort", 0
};
mDelegateFactories = new CSVWorld::CommandDelegateFactoryCollection;
mDelegateFactories->add (CSMWorld::ColumnBase::Display_GmstVarType,
@ -70,6 +75,9 @@ CSVDoc::ViewManager::ViewManager (CSMDoc::DocumentManager& documentManager)
mDelegateFactories->add (CSMWorld::ColumnBase::Display_SpellType,
new CSVWorld::EnumDelegateFactory (sSpellTypes));
mDelegateFactories->add (CSMWorld::ColumnBase::Display_ApparatusType,
new CSVWorld::EnumDelegateFactory (sApparatusTypes));
}
CSVDoc::ViewManager::~ViewManager()

@ -44,6 +44,9 @@ CSVWorld::EnumDelegate::EnumDelegate (const std::vector<std::pair<int, QString>
QWidget *CSVWorld::EnumDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem& option,
const QModelIndex& index) const
{
if (!index.data().isValid())
return 0;
QComboBox *comboBox = new QComboBox (parent);
for (std::vector<std::pair<int, QString> >::const_iterator iter (mValues.begin());
@ -73,20 +76,23 @@ void CSVWorld::EnumDelegate::setEditorData (QWidget *editor, const QModelIndex&
void CSVWorld::EnumDelegate::paint (QPainter *painter, const QStyleOptionViewItem& option,
const QModelIndex& index) const
{
QStyleOptionViewItemV4 option2 (option);
if (index.data().isValid())
{
QStyleOptionViewItemV4 option2 (option);
int value = index.data().toInt();
int value = index.data().toInt();
for (std::vector<std::pair<int, QString> >::const_iterator iter (mValues.begin());
iter!=mValues.end(); ++iter)
if (iter->first==value)
{
option2.text = iter->second;
for (std::vector<std::pair<int, QString> >::const_iterator iter (mValues.begin());
iter!=mValues.end(); ++iter)
if (iter->first==value)
{
option2.text = iter->second;
QApplication::style()->drawControl (QStyle::CE_ItemViewItem, &option2, painter);
QApplication::style()->drawControl (QStyle::CE_ItemViewItem, &option2, painter);
break;
}
break;
}
}
}

Loading…
Cancel
Save