Пример #1
0
bool ObjectContainer::modify(QJsonObject& data)
{
	if (!verifyData(data)) return false;

	ObjectItem * item = getItem(data["id"].toInt());
	if (!item)
	{
		StaticLogger::logit("WARNING: Object not modified! The object with id '" + QString::number(data["id"].toInt()) + "' does not exist.");
		return false;
	}
	item->setData(data["name"].toString(), Qt::DisplayRole); // Modify name in gui
	item->setData(data); // Modify object data ( UserRole + 1)

	return true;
}
Пример #2
0
// Store objects with their propterties as QJsonObjects
// This way, every object can have custom properties, without creating special object classes
// The objects and its properties also may be saved to file in a human readable and modifiable format
bool ObjectContainer::add(ObjectType type, QJsonObject& data)
{
	if (!verifyData(data)) return false;

	ObjectItem* item = new ObjectItem(data["name"].toString());
	item->setData(data);
	m_model.appendRow(item);
	return true;
}
Пример #3
0
// ツリービュー ダブルクリック
void AnimationForm::slot_treeViewDoubleClicked(QModelIndex index)
{
	CObjectModel *pModel = m_pEditData->getObjectModel() ;
	if ( !pModel->isLayer(index) ) { return ; }

	ObjectItem *pItem = pModel->getItemFromIndex(index) ;
	if ( !pItem ) { return ; }

	QVariant flag = pItem->data(Qt::CheckStateRole) ;
	int f = flag.toInt() ;
	if ( f & ObjectItem::kState_Disp )	{ f &= ~ObjectItem::kState_Disp ; }
	else								{ f |= ObjectItem::kState_Disp ; }
	pItem->setData(f, Qt::CheckStateRole);
	m_pGlWidget->update();
	ui->treeView->update(index) ;
}