Commit 371288b7 authored by David Thompson's avatar David Thompson

Signal more changes to the attribute system...

... to keep resource tree and component list views up to date.
parent 68f45eec
......@@ -453,6 +453,7 @@ void qtAttributeView::onAttributeNameChanged(QTableWidgetItem* item)
{
ResourcePtr attResource = aAttribute->definition()->resource();
attResource->rename(aAttribute, item->text().toStdString());
this->attributeChanged(aAttribute);
//aAttribute->definition()->setLabel(item->text().toAscii().constData());
}
}
......@@ -671,6 +672,7 @@ void qtAttributeView::createNewAttribute(smtk::attribute::DefinitionPtr attDef)
ResourcePtr attResource = attDef->resource();
smtk::attribute::AttributePtr newAtt = attResource->createAttribute(attDef->type());
this->attributeCreated(newAtt);
QTableWidgetItem* item = this->addAttributeListItem(newAtt);
if (item)
{
......@@ -711,6 +713,7 @@ void qtAttributeView::onDeleteSelected()
attribute::DefinitionPtr attDef = selObject->definition();
ResourcePtr attResource = attDef->resource();
attResource->removeAttribute(selObject);
this->attributeRemoved(selObject);
QTableWidgetItem* selItem = this->getSelectedItem();
this->Internals->ListTable->removeRow(selItem->row());
......
......@@ -9,8 +9,13 @@
//=========================================================================
#include "smtk/extension/qt/qtBaseView.h"
#include "smtk/attribute/ComponentItem.h"
#include "smtk/attribute/Definition.h"
#include "smtk/attribute/Resource.h"
#include "smtk/attribute/operators/Signal.h"
#include "smtk/operation/Manager.h"
#include "smtk/extension/qt/qtUIManager.h"
#include "smtk/view/View.h"
......@@ -128,6 +133,43 @@ void qtBaseView::valueChanged(smtk::attribute::ItemPtr item)
this->uiManager()->onViewUIModified(this, item);
}
namespace
{
static void signalAttribute(smtk::extension::qtUIManager* uiManager,
const smtk::attribute::AttributePtr& attr, const char* itemName)
{
if (attr && uiManager && itemName && itemName[0])
{
// create a "dummy" operation that will mark the attribute resource
// as modified so that applications know when a "save" is required.
auto opManager = uiManager->operationManager();
if (opManager)
{
auto markModified = opManager->create<smtk::attribute::Signal>();
auto didAppend = markModified->parameters()->findComponent(itemName)->appendObjectValue(attr);
(void)didAppend;
markModified->operate();
}
}
}
}
void qtBaseView::attributeCreated(const smtk::attribute::AttributePtr& attr)
{
signalAttribute(this->uiManager(), attr, "created");
}
void qtBaseView::attributeChanged(const smtk::attribute::AttributePtr& attr)
{
signalAttribute(this->uiManager(), attr, "modified");
}
void qtBaseView::attributeRemoved(const smtk::attribute::AttributePtr& attr)
{
signalAttribute(this->uiManager(), attr, "expunged");
}
bool qtBaseView::setFixedLabelWidth(int w)
{
w = std::min(w, this->uiManager()->maxValueLabelLength());
......
......@@ -114,6 +114,12 @@ public slots:
}
virtual void updateModelAssociation() { ; }
virtual void valueChanged(smtk::attribute::ItemPtr);
/// Invoke the Signal dummy operation to indicate an attribute has been created.
virtual void attributeCreated(const smtk::attribute::AttributePtr&);
/// Invoke the Signal dummy operation to indicate an attribute has been changed (renamed).
virtual void attributeChanged(const smtk::attribute::AttributePtr&);
/// Invoke the Signal dummy operation to indicate an attribute has been removed.
virtual void attributeRemoved(const smtk::attribute::AttributePtr&);
virtual void childrenResized() { ; }
virtual void showAdvanceLevelOverlay(bool val) { m_advOverlayVisible = val; }
virtual void showAdvanceLevel(int i);
......
......@@ -140,6 +140,7 @@ void qtInstancedView::updateAttributeData()
else
{
att = resource->createAttribute(attName, attDef);
this->attributeCreated(att);
}
}
else
......
......@@ -507,6 +507,7 @@ void qtModelEntityAttributeView::cellChanged(int row, int column)
else if (att)
{
attRes->removeAttribute(att);
this->attributeRemoved(att);
}
// Now create a new attribute for the model entity of the correct type
......@@ -517,6 +518,8 @@ void qtModelEntityAttributeView::cellChanged(int row, int column)
{
att = attRes->createAttribute(currentDefs.at(j));
att->associate(entity);
// Notify the application of the new attribute via an "operation"
this->attributeCreated(att);
break;
}
}
......
......@@ -112,6 +112,7 @@ bool qtSelectorView::createSelector()
return false;
}
this->Internals->m_selectorAttribute = resource->createAttribute(attName, attDef);
this->attributeCreated(this->Internals->m_selectorAttribute);
}
else
{
......
......@@ -449,6 +449,7 @@ void qtSimpleExpressionView::createNewFunction(smtk::attribute::DefinitionPtr at
ResourcePtr attResource = attDef->resource();
smtk::attribute::AttributePtr newFunc = attResource->createAttribute(attDef->type());
this->attributeCreated(newFunc);
QListWidgetItem* item = this->addFunctionListItem(newFunc);
if (item)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment