+ add properties with 'hidden' mode to property editor but hide the item
This commit is contained in:
parent
843fbc49fc
commit
0ec81d2760
|
@ -132,7 +132,7 @@ void PropertyView::slotChangePropertyView(const Gui::ViewProvider&, const App::P
|
|||
void PropertyView::slotAppendDynamicProperty(const App::Property& prop)
|
||||
{
|
||||
App::PropertyContainer* parent = prop.getContainer();
|
||||
if (parent->isHidden(&prop) || prop.testStatus(App::Property::Hidden))
|
||||
if (parent->isHidden(&prop))
|
||||
return;
|
||||
|
||||
if (parent && parent->isDerivedFrom(App::DocumentObject::getClassTypeId())) {
|
||||
|
@ -158,10 +158,10 @@ void PropertyView::slotChangePropertyEditor(const App::Property& prop)
|
|||
{
|
||||
App::PropertyContainer* parent = prop.getContainer();
|
||||
if (parent && parent->isDerivedFrom(App::DocumentObject::getClassTypeId())) {
|
||||
propertyEditorData->updatetEditorMode(prop);
|
||||
propertyEditorData->updateEditorMode(prop);
|
||||
}
|
||||
else if (parent && parent->isDerivedFrom(Gui::ViewProvider::getClassTypeId())) {
|
||||
propertyEditorView->updatetEditorMode(prop);
|
||||
propertyEditorView->updateEditorMode(prop);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -220,7 +220,7 @@ void PropertyView::onSelectionChanged(const SelectionChanges& msg)
|
|||
nameType.propName = ob->getPropertyName(*pt);
|
||||
nameType.propId = (*pt)->getTypeId().getKey();
|
||||
|
||||
if (!ob->isHidden(*pt) && !(*pt)->testStatus(App::Property::Hidden)) {
|
||||
if (!ob->isHidden(*pt)) {
|
||||
std::vector<PropInfo>::iterator pi = std::find_if(propDataMap.begin(), propDataMap.end(), PropFind(nameType));
|
||||
if (pi != propDataMap.end()) {
|
||||
pi->propList.push_back(*pt);
|
||||
|
@ -240,7 +240,7 @@ void PropertyView::onSelectionChanged(const SelectionChanges& msg)
|
|||
nameType.propName = pt->first;
|
||||
nameType.propId = pt->second->getTypeId().getKey();
|
||||
|
||||
if (!vp->isHidden(pt->second) && !pt->second->testStatus(App::Property::Hidden)) {
|
||||
if (!vp->isHidden(pt->second)) {
|
||||
std::vector<PropInfo>::iterator pi = std::find_if(propViewMap.begin(), propViewMap.end(), PropFind(nameType));
|
||||
if (pi != propViewMap.end()) {
|
||||
pi->propList.push_back(pt->second);
|
||||
|
|
|
@ -131,6 +131,22 @@ void PropertyEditor::currentChanged ( const QModelIndex & current, const QModelI
|
|||
openPersistentEditor(model()->buddy(current));
|
||||
}
|
||||
|
||||
void PropertyEditor::reset()
|
||||
{
|
||||
QTreeView::reset();
|
||||
|
||||
QModelIndex index;
|
||||
int numRows = propertyModel->rowCount(index);
|
||||
if (numRows > 0)
|
||||
setEditorMode(index, 0, numRows-1);
|
||||
}
|
||||
|
||||
void PropertyEditor::rowsInserted (const QModelIndex & parent, int start, int end)
|
||||
{
|
||||
QTreeView::rowsInserted(parent, start, end);
|
||||
setEditorMode(parent, start, end);
|
||||
}
|
||||
|
||||
void PropertyEditor::drawBranches(QPainter *painter, const QRect &rect, const QModelIndex &index) const
|
||||
{
|
||||
QTreeView::drawBranches(painter, rect, index);
|
||||
|
@ -178,7 +194,19 @@ void PropertyEditor::updateProperty(const App::Property& prop)
|
|||
propertyModel->updateProperty(prop);
|
||||
}
|
||||
|
||||
void PropertyEditor::updatetEditorMode(const App::Property& prop)
|
||||
void PropertyEditor::setEditorMode(const QModelIndex & parent, int start, int end)
|
||||
{
|
||||
int column = 1;
|
||||
for (int i=start; i<=end; i++) {
|
||||
QModelIndex item = propertyModel->index(i, column, parent);
|
||||
PropertyItem* propItem = static_cast<PropertyItem*>(item.internalPointer());
|
||||
if (propItem && propItem->testStatus(App::Property::Hidden)) {
|
||||
setRowHidden (i, parent, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PropertyEditor::updateEditorMode(const App::Property& prop)
|
||||
{
|
||||
// check if the parent object is selected
|
||||
std::string editor = prop.getEditorName();
|
||||
|
|
|
@ -68,11 +68,13 @@ public:
|
|||
/** Builds up the list view with the properties. */
|
||||
void buildUp(const PropertyModel::PropertyList& props);
|
||||
void updateProperty(const App::Property&);
|
||||
void updatetEditorMode(const App::Property&);
|
||||
void updateEditorMode(const App::Property&);
|
||||
void appendProperty(const App::Property&);
|
||||
void removeProperty(const App::Property&);
|
||||
void setAutomaticDocumentUpdate(bool);
|
||||
bool isAutomaticDocumentUpdate(bool) const;
|
||||
/*! Reset the internal state of the view. */
|
||||
virtual void reset();
|
||||
|
||||
QBrush groupBackground() const;
|
||||
void setGroupBackground(const QBrush& c);
|
||||
|
@ -84,10 +86,12 @@ protected:
|
|||
virtual void commitData (QWidget * editor);
|
||||
virtual void editorDestroyed (QObject * editor);
|
||||
virtual void currentChanged (const QModelIndex & current, const QModelIndex & previous);
|
||||
virtual void rowsInserted (const QModelIndex & parent, int start, int end);
|
||||
virtual void drawBranches(QPainter *painter, const QRect &rect, const QModelIndex &index) const;
|
||||
virtual QStyleOptionViewItem viewOptions() const;
|
||||
|
||||
private:
|
||||
void setEditorMode(const QModelIndex & parent, int start, int end);
|
||||
void updateItemEditor(bool enable, int column, const QModelIndex& parent);
|
||||
|
||||
private:
|
||||
|
|
|
@ -210,6 +210,16 @@ bool PropertyItem::isReadOnly() const
|
|||
return readonly;
|
||||
}
|
||||
|
||||
bool PropertyItem::testStatus(App::Property::Status pos) const
|
||||
{
|
||||
std::vector<App::Property*>::const_iterator it;
|
||||
for (it = propertyItems.begin(); it != propertyItems.end(); ++it) {
|
||||
if ((*it)->testStatus(pos))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void PropertyItem::setDecimals(int prec)
|
||||
{
|
||||
precision = prec;
|
||||
|
|
|
@ -87,6 +87,7 @@ public:
|
|||
|
||||
void setReadOnly(bool);
|
||||
bool isReadOnly() const;
|
||||
bool testStatus(App::Property::Status pos) const;
|
||||
void setDecimals(int);
|
||||
int decimals() const;
|
||||
|
||||
|
|
|
@ -262,7 +262,6 @@ void PropertyModel::buildUp(const PropertyModel::PropertyList& props)
|
|||
}
|
||||
|
||||
endResetModel();
|
||||
// reset();
|
||||
}
|
||||
|
||||
void PropertyModel::updateProperty(const App::Property& prop)
|
||||
|
|
Loading…
Reference in New Issue
Block a user