+ fixes #0002197: Buggy Placement dialog when using Euler angles

This commit is contained in:
wmayer 2015-09-13 15:17:44 +02:00
parent 8cee8992ab
commit 043dc1616d
8 changed files with 88 additions and 1 deletions

View File

@ -28,6 +28,8 @@
# include <QEvent>
#endif
#include <boost/bind.hpp>
/// Here the FreeCAD includes sorted by Base,App,Gui......
#include <Base/Parameter.h>
#include <App/PropertyStandard.h>
@ -90,10 +92,29 @@ PropertyView::PropertyView(QWidget *parent)
// connect after adding all tabs, so adding doesn't thrash the parameter
connect(tabs, SIGNAL(currentChanged(int)), this, SLOT(tabChanged(int)));
this->connectPropData =
App::GetApplication().signalChangedObject.connect(boost::bind
(&PropertyView::slotChangePropertyData, this, _1, _2));
this->connectPropView =
Gui::Application::Instance->signalChangedObject.connect(boost::bind
(&PropertyView::slotChangePropertyView, this, _1, _2));
}
PropertyView::~PropertyView()
{
this->connectPropData.disconnect();
this->connectPropView.disconnect();
}
void PropertyView::slotChangePropertyData(const App::DocumentObject&, const App::Property& prop)
{
propertyEditorData->updateProperty(prop);
}
void PropertyView::slotChangePropertyView(const Gui::ViewProvider&, const App::Property& prop)
{
propertyEditorView->updateProperty(prop);
}
struct PropertyView::PropInfo

View File

@ -28,12 +28,15 @@
#include "DockWindow.h"
#include "Selection.h"
#include <boost/signals.hpp>
class QPixmap;
class QTabWidget;
namespace App {
class Property;
class PropertyContainer;
class DocumentObject;
}
namespace Gui {
@ -47,7 +50,7 @@ class PropertyEditor;
} // namespace Gui
namespace Gui {
class ViewProvider;
/** The property view class.
*/
@ -71,10 +74,15 @@ protected:
private:
void onSelectionChanged(const SelectionChanges& msg);
void slotChangePropertyData(const App::DocumentObject&, const App::Property&);
void slotChangePropertyView(const Gui::ViewProvider&, const App::Property&);
private:
struct PropInfo;
struct PropFind;
typedef boost::BOOST_SIGNALS_NAMESPACE::connection Connection;
Connection connectPropData;
Connection connectPropView;
QTabWidget* tabs;
};

View File

@ -145,4 +145,11 @@ void PropertyEditor::buildUp(const PropertyModel::PropertyList& props)
}
}
void PropertyEditor::updateProperty(const App::Property& prop)
{
// forward this to the model if the property is changed from outside
//if (!committing)
propertyModel->updateProperty(prop);
}
#include "moc_PropertyEditor.cpp"

View File

@ -51,6 +51,7 @@ public:
/** Builds up the list view with the properties. */
void buildUp(const PropertyModel::PropertyList& props);
void updateProperty(const App::Property&);
void setAutomaticDocumentUpdate(bool);
bool isAutomaticDocumentUpdate(bool) const;

View File

@ -97,6 +97,15 @@ const std::vector<App::Property*>& PropertyItem::getPropertyData() const
return propertyItems;
}
bool PropertyItem::hasProperty(const App::Property* prop) const
{
std::vector<App::Property*>::const_iterator it = std::find(propertyItems.begin(), propertyItems.end(), prop);
if (it != propertyItems.end())
return true;
else
return false;
}
App::Property* PropertyItem::getFirstProperty()
{
if (propertyItems.empty())

View File

@ -61,6 +61,7 @@ public:
/** Sets the current property objects. */
void setPropertyData( const std::vector<App::Property*>& );
const std::vector<App::Property*>& getPropertyData() const;
bool hasProperty(const App::Property*) const;
App::Property* getFirstProperty();
const App::Property* getFirstProperty() const;

View File

@ -261,4 +261,40 @@ void PropertyModel::buildUp(const PropertyModel::PropertyList& props)
reset();
}
void PropertyModel::updateProperty(const App::Property& prop)
{
int column = 1;
int numChild = rootItem->childCount();
for (int row=0; row<numChild; row++) {
PropertyItem* child = rootItem->child(row);
if (child->hasProperty(&prop)) {
QModelIndex data = this->index(row, column, QModelIndex());
if (data.isValid()) {
dataChanged(data, data);
updateChildren(child, column, data);
}
break;
}
}
}
void PropertyModel::updateChildren(PropertyItem* item, int column, const QModelIndex& parent)
{
int numChild = item->childCount();
if (numChild > 0) {
QModelIndex topLeft = this->index(0, column, parent);
QModelIndex bottomRight = this->index(numChild, column, parent);
dataChanged(topLeft, bottomRight);
#if 0 // It seems we don't have to inform grand children
for (int row=0; row<numChild; row++) {
PropertyItem* child = item->child(row);
QModelIndex data = this->index(row, column, parent);
if (data.isValid()) {
updateChildren(child, column, data);
}
}
#endif
}
}
#include "moc_PropertyModel.cpp"

View File

@ -57,9 +57,13 @@ public:
QVariant headerData (int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
bool setHeaderData (int section, Qt::Orientation orientation, const QVariant & value, int role = Qt::EditRole);
void buildUp(const PropertyList& props);
void updateProperty(const App::Property&);
QStringList propertyPathFromIndex(const QModelIndex&) const;
QModelIndex propertyIndexFromPath(const QStringList&) const;
private:
void updateChildren(PropertyItem* item, int column, const QModelIndex& parent);
private:
PropertyItem *rootItem;
};