mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-03-13 07:14:31 +00:00
generalised RefIdTypeDelegate into IdTypeDelegate
This commit is contained in:
parent
5aa8c03461
commit
1c4a4b4f26
@ -64,7 +64,7 @@ opencs_units (view/world
|
||||
|
||||
opencs_units_noqt (view/world
|
||||
dialoguesubview subviews
|
||||
enumdelegate vartypedelegate recordstatusdelegate refidtypedelegate datadisplaydelegate
|
||||
enumdelegate vartypedelegate recordstatusdelegate idtypedelegate datadisplaydelegate
|
||||
scripthighlighter idvalidator
|
||||
)
|
||||
|
||||
|
@ -14,7 +14,7 @@
|
||||
#include "../world/enumdelegate.hpp"
|
||||
#include "../world/vartypedelegate.hpp"
|
||||
#include "../world/recordstatusdelegate.hpp"
|
||||
#include "../world/refidtypedelegate.hpp"
|
||||
#include "../world/idtypedelegate.hpp"
|
||||
#include "../settings/usersettingsdialog.hpp"
|
||||
|
||||
#include "view.hpp"
|
||||
@ -56,7 +56,7 @@ CSVDoc::ViewManager::ViewManager (CSMDoc::DocumentManager& documentManager)
|
||||
new CSVWorld::RecordStatusDelegateFactory());
|
||||
|
||||
mDelegateFactories->add (CSMWorld::ColumnBase::Display_RefRecordType,
|
||||
new CSVWorld::RefIdTypeDelegateFactory());
|
||||
new CSVWorld::IdTypeDelegateFactory());
|
||||
|
||||
struct Mapping
|
||||
{
|
||||
|
45
apps/opencs/view/world/idtypedelegate.cpp
Executable file
45
apps/opencs/view/world/idtypedelegate.cpp
Executable file
@ -0,0 +1,45 @@
|
||||
#include "idtypedelegate.hpp"
|
||||
|
||||
#include "../../model/world/universalid.hpp"
|
||||
|
||||
CSVWorld::IdTypeDelegate::IdTypeDelegate
|
||||
(const ValueList &values, const IconList &icons, QUndoStack& undoStack, QObject *parent)
|
||||
: DataDisplayDelegate (values, icons, undoStack, parent)
|
||||
{}
|
||||
|
||||
bool CSVWorld::IdTypeDelegate::updateEditorSetting (const QString &settingName, const QString &settingValue)
|
||||
{
|
||||
if (settingName == "Referenceable ID Type Display")
|
||||
{
|
||||
if (settingValue == "Icon and Text")
|
||||
mDisplayMode = Mode_IconAndText;
|
||||
|
||||
else if (settingValue == "Icon Only")
|
||||
mDisplayMode = Mode_IconOnly;
|
||||
|
||||
else if (settingValue == "Text Only")
|
||||
mDisplayMode = Mode_TextOnly;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
CSVWorld::IdTypeDelegateFactory::IdTypeDelegateFactory()
|
||||
{
|
||||
for (int i=0; i<CSMWorld::UniversalId::NumberOfTypes; ++i)
|
||||
{
|
||||
CSMWorld::UniversalId id (static_cast<CSMWorld::UniversalId::Type> (i));
|
||||
|
||||
DataDisplayDelegateFactory::add (id.getType(), QString::fromUtf8 (id.getTypeName().c_str()),
|
||||
QString::fromUtf8 (id.getIcon().c_str()));
|
||||
}
|
||||
}
|
||||
|
||||
CSVWorld::CommandDelegate *CSVWorld::IdTypeDelegateFactory::makeDelegate (QUndoStack& undoStack,
|
||||
QObject *parent) const
|
||||
{
|
||||
return new IdTypeDelegate (mValues, mIcons, undoStack, parent);
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
#ifndef REFIDTYPEDELEGATE_HPP
|
||||
#define REFIDTYPEDELEGATE_HPP
|
||||
#ifndef IDTYPEDELEGATE_HPP
|
||||
#define IDTYPEDELEGATE_HPP
|
||||
|
||||
#include "enumdelegate.hpp"
|
||||
#include "util.hpp"
|
||||
@ -8,29 +8,23 @@
|
||||
|
||||
namespace CSVWorld
|
||||
{
|
||||
class RefIdTypeDelegate : public DataDisplayDelegate
|
||||
class IdTypeDelegate : public DataDisplayDelegate
|
||||
{
|
||||
public:
|
||||
RefIdTypeDelegate (const ValueList &mValues, const IconList &icons, QUndoStack& undoStack, QObject *parent);
|
||||
IdTypeDelegate (const ValueList &mValues, const IconList &icons, QUndoStack& undoStack, QObject *parent);
|
||||
|
||||
virtual bool updateEditorSetting (const QString &settingName, const QString &settingValue);
|
||||
|
||||
};
|
||||
|
||||
class RefIdTypeDelegateFactory : public DataDisplayDelegateFactory
|
||||
class IdTypeDelegateFactory : public DataDisplayDelegateFactory
|
||||
{
|
||||
|
||||
typedef std::vector < std::pair <CSMWorld::UniversalId::Type, QString> > UidTypeList;
|
||||
|
||||
public:
|
||||
RefIdTypeDelegateFactory();
|
||||
|
||||
IdTypeDelegateFactory();
|
||||
|
||||
virtual CommandDelegate *makeDelegate (QUndoStack& undoStack, QObject *parent) const;
|
||||
///< The ownership of the returned CommandDelegate is transferred to the caller.
|
||||
|
||||
private:
|
||||
UidTypeList buildUidTypeList () const;
|
||||
|
||||
};
|
||||
}
|
||||
|
@ -1,62 +0,0 @@
|
||||
#include "refidtypedelegate.hpp"
|
||||
|
||||
#include "../../model/world/universalid.hpp"
|
||||
|
||||
CSVWorld::RefIdTypeDelegate::RefIdTypeDelegate
|
||||
(const ValueList &values, const IconList &icons, QUndoStack& undoStack, QObject *parent)
|
||||
: DataDisplayDelegate (values, icons, undoStack, parent)
|
||||
{}
|
||||
|
||||
bool CSVWorld::RefIdTypeDelegate::updateEditorSetting (const QString &settingName, const QString &settingValue)
|
||||
{
|
||||
if (settingName == "Referenceable ID Type Display")
|
||||
{
|
||||
if (settingValue == "Icon and Text")
|
||||
mDisplayMode = Mode_IconAndText;
|
||||
|
||||
else if (settingValue == "Icon Only")
|
||||
mDisplayMode = Mode_IconOnly;
|
||||
|
||||
else if (settingValue == "Text Only")
|
||||
mDisplayMode = Mode_TextOnly;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
CSVWorld::RefIdTypeDelegateFactory::RefIdTypeDelegateFactory()
|
||||
{
|
||||
UidTypeList uIdList = buildUidTypeList();
|
||||
|
||||
for (UidTypeList::const_iterator it = uIdList.begin(); it != uIdList.end(); it++)
|
||||
{
|
||||
int i = it->first;
|
||||
DataDisplayDelegateFactory::add (i, QString::fromStdString(CSMWorld::UniversalId(it->first, "").getTypeName()), it->second);
|
||||
}
|
||||
}
|
||||
|
||||
CSVWorld::CommandDelegate *CSVWorld::RefIdTypeDelegateFactory::makeDelegate (QUndoStack& undoStack,
|
||||
QObject *parent) const
|
||||
{
|
||||
return new RefIdTypeDelegate (mValues, mIcons, undoStack, parent);
|
||||
}
|
||||
|
||||
CSVWorld::RefIdTypeDelegateFactory::UidTypeList CSVWorld::RefIdTypeDelegateFactory::buildUidTypeList() const
|
||||
{
|
||||
UidTypeList list;
|
||||
|
||||
std::vector<CSMWorld::UniversalId::Type> types = CSMWorld::UniversalId::listReferenceableTypes();
|
||||
|
||||
for (std::vector<CSMWorld::UniversalId::Type>::const_iterator iter (types.begin());
|
||||
iter!=types.end(); ++iter)
|
||||
{
|
||||
CSMWorld::UniversalId id (*iter, "");
|
||||
|
||||
list.push_back (std::make_pair (id.getType(), id.getIcon().c_str()));
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
@ -12,8 +12,8 @@
|
||||
#include "../../model/world/idtableproxymodel.hpp"
|
||||
#include "../../model/world/idtable.hpp"
|
||||
#include "../../model/world/record.hpp"
|
||||
|
||||
#include "recordstatusdelegate.hpp"
|
||||
#include "refidtypedelegate.hpp"
|
||||
#include "util.hpp"
|
||||
|
||||
void CSVWorld::Table::contextMenuEvent (QContextMenuEvent *event)
|
||||
|
Loading…
x
Reference in New Issue
Block a user