mirror of
https://github.com/AxioDL/PrimeWorldEditor.git
synced 2025-07-03 03:36:10 +00:00
CInstanceModel: Mark strings as translatable where applicable
This commit is contained in:
parent
6962f8e026
commit
86bca47221
@ -53,9 +53,9 @@ QVariant CInstancesModel::headerData(int Section, Qt::Orientation Orientation, i
|
|||||||
{
|
{
|
||||||
switch (Section)
|
switch (Section)
|
||||||
{
|
{
|
||||||
case 0: return "Name";
|
case 0: return tr("Name");
|
||||||
case 1: return (mModelType == EInstanceModelType::Layers ? "Type" : "Layer");
|
case 1: return (mModelType == EInstanceModelType::Layers ? tr("Type") : tr("Layer"));
|
||||||
case 2: return "Show";
|
case 2: return tr("Show");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return QVariant::Invalid;
|
return QVariant::Invalid;
|
||||||
@ -66,25 +66,25 @@ QModelIndex CInstancesModel::index(int Row, int Column, const QModelIndex& rkPar
|
|||||||
if (!hasIndex(Row, Column, rkParent))
|
if (!hasIndex(Row, Column, rkParent))
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
|
|
||||||
EIndexType Type = IndexType(rkParent);
|
const EIndexType Type = IndexType(rkParent);
|
||||||
|
|
||||||
// Parent is root - child is Node type index
|
// Parent is root - child is Node type index
|
||||||
if (Type == EIndexType::Root)
|
if (Type == EIndexType::Root)
|
||||||
{
|
{
|
||||||
if (Row < mBaseItems.count())
|
if (Row < mBaseItems.count())
|
||||||
return createIndex(Row, Column, quint64(0));
|
return createIndex(Row, Column, quint64(0));
|
||||||
else
|
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parent is node - child is Object type index
|
// Parent is node - child is Object type index
|
||||||
else if (Type == EIndexType::NodeType)
|
if (Type == EIndexType::NodeType)
|
||||||
return createIndex(Row, Column, ((Row << TYPES_ROW_INDEX_SHIFT) | (rkParent.row() << TYPES_NODE_TYPE_SHIFT) | 1));
|
return createIndex(Row, Column, ((Row << TYPES_ROW_INDEX_SHIFT) | (rkParent.row() << TYPES_NODE_TYPE_SHIFT) | 1));
|
||||||
|
|
||||||
// Parent is object - child is Instance index
|
// Parent is object - child is Instance index
|
||||||
else if (Type == EIndexType::ObjectType)
|
if (Type == EIndexType::ObjectType)
|
||||||
{
|
{
|
||||||
uint32 RootRow = rkParent.parent().row();
|
const uint32 RootRow = rkParent.parent().row();
|
||||||
|
|
||||||
// Object
|
// Object
|
||||||
if (RootRow == 0)
|
if (RootRow == 0)
|
||||||
@ -94,11 +94,11 @@ QModelIndex CInstancesModel::index(int Row, int Column, const QModelIndex& rkPar
|
|||||||
CScriptLayer *pLayer = mpArea->ScriptLayer(static_cast<size_t>(rkParent.row()));
|
CScriptLayer *pLayer = mpArea->ScriptLayer(static_cast<size_t>(rkParent.row()));
|
||||||
if (static_cast<size_t>(Row) >= pLayer->NumInstances())
|
if (static_cast<size_t>(Row) >= pLayer->NumInstances())
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
else
|
|
||||||
return createIndex(Row, Column, (*pLayer)[Row]);
|
return createIndex(Row, Column, (*pLayer)[Row]);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (mModelType == EInstanceModelType::Types)
|
if (mModelType == EInstanceModelType::Types)
|
||||||
{
|
{
|
||||||
const std::list<CScriptObject*>& list = mTemplateList[rkParent.row()]->ObjectList();
|
const std::list<CScriptObject*>& list = mTemplateList[rkParent.row()]->ObjectList();
|
||||||
if (static_cast<size_t>(Row) >= list.size())
|
if (static_cast<size_t>(Row) >= list.size())
|
||||||
@ -121,7 +121,7 @@ QModelIndex CInstancesModel::index(int Row, int Column, const QModelIndex& rkPar
|
|||||||
|
|
||||||
QModelIndex CInstancesModel::parent(const QModelIndex& rkChild) const
|
QModelIndex CInstancesModel::parent(const QModelIndex& rkChild) const
|
||||||
{
|
{
|
||||||
EIndexType Type = IndexType(rkChild);
|
const EIndexType Type = IndexType(rkChild);
|
||||||
|
|
||||||
// Root parent
|
// Root parent
|
||||||
if (Type == EIndexType::NodeType)
|
if (Type == EIndexType::NodeType)
|
||||||
@ -130,12 +130,12 @@ QModelIndex CInstancesModel::parent(const QModelIndex& rkChild) const
|
|||||||
// Node type parent
|
// Node type parent
|
||||||
if (Type == EIndexType::ObjectType)
|
if (Type == EIndexType::ObjectType)
|
||||||
{
|
{
|
||||||
uint32 NodeTypeRow = (rkChild.internalId() & TYPES_NODE_TYPE_MASK) >> TYPES_NODE_TYPE_SHIFT;
|
const uint32 NodeTypeRow = (rkChild.internalId() & TYPES_NODE_TYPE_MASK) >> TYPES_NODE_TYPE_SHIFT;
|
||||||
return createIndex(NodeTypeRow, 0, quint64(0));
|
return createIndex(NodeTypeRow, 0, quint64(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Object type parent
|
// Object type parent
|
||||||
else if (Type == EIndexType::Instance)
|
if (Type == EIndexType::Instance)
|
||||||
{
|
{
|
||||||
CScriptObject *pObj = static_cast<CScriptObject*> (rkChild.internalPointer());
|
CScriptObject *pObj = static_cast<CScriptObject*> (rkChild.internalPointer());
|
||||||
|
|
||||||
@ -149,7 +149,6 @@ QModelIndex CInstancesModel::parent(const QModelIndex& rkChild) const
|
|||||||
return createIndex(iLyr, 0, (iLyr << TYPES_ROW_INDEX_SHIFT) | 1);
|
return createIndex(iLyr, 0, (iLyr << TYPES_ROW_INDEX_SHIFT) | 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (mModelType == EInstanceModelType::Types)
|
else if (mModelType == EInstanceModelType::Types)
|
||||||
{
|
{
|
||||||
CScriptTemplate *pTemp = pObj->Template();
|
CScriptTemplate *pTemp = pObj->Template();
|
||||||
@ -210,7 +209,7 @@ int CInstancesModel::columnCount(const QModelIndex& /*rkParent*/) const
|
|||||||
|
|
||||||
QVariant CInstancesModel::data(const QModelIndex& rkIndex, int Role) const
|
QVariant CInstancesModel::data(const QModelIndex& rkIndex, int Role) const
|
||||||
{
|
{
|
||||||
EIndexType Type = IndexType(rkIndex);
|
const EIndexType Type = IndexType(rkIndex);
|
||||||
|
|
||||||
// Name/Layer
|
// Name/Layer
|
||||||
if ((Role == Qt::DisplayRole) || (Role == Qt::ToolTipRole))
|
if ((Role == Qt::DisplayRole) || (Role == Qt::ToolTipRole))
|
||||||
@ -221,12 +220,11 @@ QVariant CInstancesModel::data(const QModelIndex& rkIndex, int Role) const
|
|||||||
if (rkIndex.column() == 0)
|
if (rkIndex.column() == 0)
|
||||||
return mBaseItems[rkIndex.row()];
|
return mBaseItems[rkIndex.row()];
|
||||||
|
|
||||||
else
|
return QVariant::Invalid;
|
||||||
return QVariant::Invalid;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Object types
|
// Object types
|
||||||
else if (Type == EIndexType::ObjectType)
|
if (Type == EIndexType::ObjectType)
|
||||||
{
|
{
|
||||||
if (rkIndex.column() == 0)
|
if (rkIndex.column() == 0)
|
||||||
{
|
{
|
||||||
@ -235,40 +233,42 @@ QVariant CInstancesModel::data(const QModelIndex& rkIndex, int Role) const
|
|||||||
else
|
else
|
||||||
return TO_QSTRING(mTemplateList[rkIndex.row()]->Name());
|
return TO_QSTRING(mTemplateList[rkIndex.row()]->Name());
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo: show/hide button in column 2
|
// todo: show/hide button in column 2
|
||||||
else
|
return QVariant::Invalid;
|
||||||
return QVariant::Invalid;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Instances
|
// Instances
|
||||||
else if (Type == EIndexType::Instance)
|
if (Type == EIndexType::Instance)
|
||||||
{
|
{
|
||||||
// todo: show/hide button
|
// todo: show/hide button
|
||||||
CScriptObject *pObj = static_cast<CScriptObject*>(rkIndex.internalPointer());
|
const CScriptObject *pObj = static_cast<CScriptObject*>(rkIndex.internalPointer());
|
||||||
|
|
||||||
if (rkIndex.column() == 0)
|
if (rkIndex.column() == 0)
|
||||||
return TO_QSTRING(pObj->InstanceName());
|
return TO_QSTRING(pObj->InstanceName());
|
||||||
|
|
||||||
else if (rkIndex.column() == 1)
|
if (rkIndex.column() == 1)
|
||||||
{
|
{
|
||||||
if (mModelType == EInstanceModelType::Layers)
|
if (mModelType == EInstanceModelType::Layers)
|
||||||
return TO_QSTRING(pObj->Template()->Name());
|
return TO_QSTRING(pObj->Template()->Name());
|
||||||
else if (mModelType == EInstanceModelType::Types)
|
if (mModelType == EInstanceModelType::Types)
|
||||||
return TO_QSTRING(pObj->Layer()->Name());
|
return TO_QSTRING(pObj->Layer()->Name());
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
|
{
|
||||||
return QVariant::Invalid;
|
return QVariant::Invalid;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show/Hide Buttons
|
// Show/Hide Buttons
|
||||||
else if ((Role == Qt::DecorationRole) && (rkIndex.column() == 2))
|
else if ((Role == Qt::DecorationRole) && (rkIndex.column() == 2))
|
||||||
{
|
{
|
||||||
if (!mpScene) return QVariant::Invalid;
|
if (!mpScene)
|
||||||
|
return QVariant::Invalid;
|
||||||
|
|
||||||
static QIcon Visible(":/icons/Show.svg");
|
static const QIcon Visible(QStringLiteral(":/icons/Show.svg"));
|
||||||
static QIcon Invisible(":/icons/Hide.svg");
|
static const QIcon Invisible(QStringLiteral(":/icons/Hide.svg"));
|
||||||
|
|
||||||
// Show/Hide Node Types
|
// Show/Hide Node Types
|
||||||
if (Type == EIndexType::NodeType)
|
if (Type == EIndexType::NodeType)
|
||||||
@ -292,26 +292,28 @@ QVariant CInstancesModel::data(const QModelIndex& rkIndex, int Role) const
|
|||||||
{
|
{
|
||||||
if (mModelType == EInstanceModelType::Layers)
|
if (mModelType == EInstanceModelType::Layers)
|
||||||
{
|
{
|
||||||
CScriptLayer *pLayer = IndexLayer(rkIndex);
|
const CScriptLayer *pLayer = IndexLayer(rkIndex);
|
||||||
if (pLayer->IsVisible()) return Visible;
|
if (pLayer->IsVisible())
|
||||||
else return Invisible;
|
return Visible;
|
||||||
|
return Invisible;
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (mModelType == EInstanceModelType::Types)
|
if (mModelType == EInstanceModelType::Types)
|
||||||
{
|
{
|
||||||
CScriptTemplate *pTemp = IndexTemplate(rkIndex);
|
const CScriptTemplate *pTemp = IndexTemplate(rkIndex);
|
||||||
if (pTemp->IsVisible()) return Visible;
|
if (pTemp->IsVisible())
|
||||||
else return Invisible;
|
return Visible;
|
||||||
|
return Invisible;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show/Hide Instance
|
// Show/Hide Instance
|
||||||
else if (Type == EIndexType::Instance)
|
else if (Type == EIndexType::Instance)
|
||||||
{
|
{
|
||||||
CScriptObject *pObj = IndexObject(rkIndex);
|
CScriptObject *pObj = IndexObject(rkIndex);
|
||||||
CScriptNode *pNode = mpScene->NodeForInstance(pObj);
|
const CScriptNode *pNode = mpScene->NodeForInstance(pObj);
|
||||||
if (pNode->MarkedVisible()) return Visible;
|
if (pNode->MarkedVisible())
|
||||||
else return Invisible;
|
return Visible;
|
||||||
|
return Invisible;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -372,8 +374,9 @@ void CInstancesModel::OnActiveProjectChanged(CGameProject *pProj)
|
|||||||
void CInstancesModel::OnMapChange()
|
void CInstancesModel::OnMapChange()
|
||||||
{
|
{
|
||||||
if (mModelType == EInstanceModelType::Types)
|
if (mModelType == EInstanceModelType::Types)
|
||||||
|
{
|
||||||
GenerateList();
|
GenerateList();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
beginResetModel();
|
beginResetModel();
|
||||||
@ -481,7 +484,6 @@ void CInstancesModel::PropertyModified(IProperty *pProp, CScriptObject *pInst)
|
|||||||
QModelIndex InstIndex = index(pInst->LayerIndex(), 0, LayerIndex);
|
QModelIndex InstIndex = index(pInst->LayerIndex(), 0, LayerIndex);
|
||||||
emit dataChanged(InstIndex, InstIndex);
|
emit dataChanged(InstIndex, InstIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
uint32 Index = mTemplateList.indexOf(pInst->Template());
|
uint32 Index = mTemplateList.indexOf(pInst->Template());
|
||||||
@ -528,19 +530,25 @@ void CInstancesModel::InstancesLayerPostChange(const QList<CScriptNode*>& rkInst
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else // For layers we just need to emit layoutChanged() and done
|
||||||
// For layers we just need to emit layoutChanged() and done
|
{
|
||||||
else
|
|
||||||
emit layoutChanged();
|
emit layoutChanged();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ************ STATIC ************
|
// ************ STATIC ************
|
||||||
CInstancesModel::EIndexType CInstancesModel::IndexType(const QModelIndex& rkIndex)
|
CInstancesModel::EIndexType CInstancesModel::IndexType(const QModelIndex& rkIndex)
|
||||||
{
|
{
|
||||||
if (!rkIndex.isValid()) return EIndexType::Root;
|
if (!rkIndex.isValid())
|
||||||
else if (rkIndex.internalId() == 0) return EIndexType::NodeType;
|
return EIndexType::Root;
|
||||||
else if (((rkIndex.internalId() & TYPES_ITEM_TYPE_MASK) >> TYPES_ITEM_TYPE_SHIFT) == 1) return EIndexType::ObjectType;
|
|
||||||
else return EIndexType::Instance;
|
if (rkIndex.internalId() == 0)
|
||||||
|
return EIndexType::NodeType;
|
||||||
|
|
||||||
|
if (((rkIndex.internalId() & TYPES_ITEM_TYPE_MASK) >> TYPES_ITEM_TYPE_SHIFT) == 1)
|
||||||
|
return EIndexType::ObjectType;
|
||||||
|
|
||||||
|
return EIndexType::Instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
ENodeType CInstancesModel::IndexNodeType(const QModelIndex& rkIndex)
|
ENodeType CInstancesModel::IndexNodeType(const QModelIndex& rkIndex)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user