本文整理汇总了C++中ObjectItem::data方法的典型用法代码示例。如果您正苦于以下问题:C++ ObjectItem::data方法的具体用法?C++ ObjectItem::data怎么用?C++ ObjectItem::data使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObjectItem
的用法示例。
在下文中一共展示了ObjectItem::data方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getData
QJsonObject ObjectContainer::getData(int id)
{
ObjectItem* item = getItem(id);
if (!item)
{
StaticLogger::logit("WARNING: Object not found! The object with id '" + QString::number(id) + "' does not exist.");
return QJsonObject();
}
return item->data().toJsonObject();
}
示例2: data
QVariant TreeModel::data(const QModelIndex &index, int role) const
{
if (!index.isValid())
return QVariant();
if (role != Qt::DisplayRole)
return QVariant();
ObjectItem *item = static_cast<ObjectItem*>(index.internalPointer());
return item->data(index.column());
}
示例3: modifyCmd
void ObjectContainer::modifyCmd(const QJsonObject& data, Modifications mod)
{
ObjectItem* item = getItem(data["id"].toInt());
if (!item)
return;
QJsonObject oldData = item->data().toJsonObject();
if (oldData != data)
{
QUndoCommand* cmd = new ModifyObjectCmd(oldData, data, item, mod);
g_undoStack.push(cmd);
}
}
示例4: remove
bool ObjectContainer::remove(int id)
{
ObjectItem* item = getItem(id);
if (!item)
{
StaticLogger::logit("WARNING: Object not removed! The object with id '" + QString::number(id) + "' does not exist.");
return false;
}
QJsonObject json = item->data().toJsonObject();
m_model.removeRow(item->row());
m_ids.erase(json["id"].toInt());
return true;
}
示例5: rendererModification
void ObjectContainer::rendererModification(std::vector<QJsonObject> data)
{
QUndoCommand * transformation = new QUndoCommand();
transformation->setText("Modify via 3D view");
for (const auto& json : data)
{
ObjectItem* item = getItem(json["id"].toInt());
if (!item)
continue;
new ModifyObjectCmd(item->data().toJsonObject(), json, item, Position | Scaling | Rotation, transformation); // Add command to command group
}
g_undoStack.push(transformation);
}
示例6: slot_treeViewDoubleClicked
// ツリービュー ダブルクリック
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) ;
}
示例7: getItem
ObjectItem* ObjectContainer::getItem(int id)
{
// count may be 0 or 1 for sets
if (!m_ids.count(id))
{
OutputDebugStringA(("ID:" + std::to_string(id) + " not found in id list!").c_str());
return nullptr;
}
//Iterate all items in list
int rc = m_model.rowCount();
for (int i = 0; i < rc; ++i)
{
ObjectItem* item = static_cast<ObjectItem*>(m_model.item(i));
if (id == item->data().toJsonObject()["id"].toInt()) // Given id equals the id of the current object
{
return item;
}
}
return nullptr;
}
示例8: data
QVariant CObjectModel::data(const QModelIndex &index, int role) const
{
ObjectItem *p = getItemFromIndex(index) ;
return p->data(role) ;
}