Commit ec82e26a authored by Jan Möbius's avatar Jan Möbius
Browse files

Use ranges for Object Iteration to simplify code

parent 1a6970ce
...@@ -863,7 +863,7 @@ void DataControlPlugin::propagateDownwards(BaseObject* _obj, int _column ){ ...@@ -863,7 +863,7 @@ void DataControlPlugin::propagateDownwards(BaseObject* _obj, int _column ){
*/ */
void DataControlPlugin::slotBoundingBoxChange( ) void DataControlPlugin::slotBoundingBoxChange( )
{ {
for (PluginFunctions::ObjectIterator o_it; o_it != PluginFunctions::objectsEnd(); ++o_it) { for (auto* o_it : PluginFunctions::objects()) {
updateBoundingBox (o_it); updateBoundingBox (o_it);
} }
......
...@@ -454,8 +454,7 @@ void DataControlPlugin::setAllTarget() { ...@@ -454,8 +454,7 @@ void DataControlPlugin::setAllTarget() {
if ( action != 0 && action->data().isValid() ) if ( action != 0 && action->data().isValid() )
type = (DataType) action->data().toUInt(); type = (DataType) action->data().toUInt();
for ( PluginFunctions::ObjectIterator o_it(PluginFunctions::ALL_OBJECTS, type) ; for (auto* o_it : PluginFunctions::objects(PluginFunctions::ALL_OBJECTS, type) ) {
o_it != PluginFunctions::objectsEnd(); ++o_it){
o_it->target(true); o_it->target(true);
} }
} }
...@@ -476,8 +475,7 @@ void DataControlPlugin::setAllSource() { ...@@ -476,8 +475,7 @@ void DataControlPlugin::setAllSource() {
if ( action != 0 && action->data().isValid() ) if ( action != 0 && action->data().isValid() )
type = (DataType) action->data().toUInt(); type = (DataType) action->data().toUInt();
for ( PluginFunctions::ObjectIterator o_it(PluginFunctions::ALL_OBJECTS, type) ; for (auto* o_it : PluginFunctions::objects(PluginFunctions::ALL_OBJECTS, type) ) {
o_it != PluginFunctions::objectsEnd(); ++o_it){
o_it->source(true); o_it->source(true);
} }
} }
...@@ -498,8 +496,7 @@ void DataControlPlugin::clearAllTarget() { ...@@ -498,8 +496,7 @@ void DataControlPlugin::clearAllTarget() {
if ( action != 0 && action->data().isValid() ) if ( action != 0 && action->data().isValid() )
type = (DataType) action->data().toUInt(); type = (DataType) action->data().toUInt();
for ( PluginFunctions::ObjectIterator o_it(PluginFunctions::ALL_OBJECTS, type) ; for (auto* o_it : PluginFunctions::objects(PluginFunctions::ALL_OBJECTS, type) ) {
o_it != PluginFunctions::objectsEnd(); ++o_it){
o_it->target(false); o_it->target(false);
} }
} }
...@@ -520,8 +517,7 @@ void DataControlPlugin::clearAllSource() { ...@@ -520,8 +517,7 @@ void DataControlPlugin::clearAllSource() {
if ( action != 0 && action->data().isValid() ) if ( action != 0 && action->data().isValid() )
type = (DataType) action->data().toUInt(); type = (DataType) action->data().toUInt();
for ( PluginFunctions::ObjectIterator o_it(PluginFunctions::ALL_OBJECTS, type) ; for (auto* o_it : PluginFunctions::objects(PluginFunctions::ALL_OBJECTS, type) ) {
o_it != PluginFunctions::objectsEnd(); ++o_it){
o_it->source(false); o_it->source(false);
} }
} }
...@@ -545,8 +541,7 @@ void DataControlPlugin::hideAll() { ...@@ -545,8 +541,7 @@ void DataControlPlugin::hideAll() {
if ( action != 0 && action->data().isValid() ) if ( action != 0 && action->data().isValid() )
type = (DataType) action->data().toUInt(); type = (DataType) action->data().toUInt();
for ( PluginFunctions::ObjectIterator o_it(PluginFunctions::ALL_OBJECTS,type) ; for (auto* o_it : PluginFunctions::objects(PluginFunctions::ALL_OBJECTS, type) ) {
o_it != PluginFunctions::objectsEnd(); ++o_it){
o_it->hide(); o_it->hide();
} }
...@@ -571,7 +566,7 @@ void DataControlPlugin::showAll() { ...@@ -571,7 +566,7 @@ void DataControlPlugin::showAll() {
if ( action != 0 && action->data().isValid() ) if ( action != 0 && action->data().isValid() )
type = (DataType) action->data().toUInt(); type = (DataType) action->data().toUInt();
for ( PluginFunctions::ObjectIterator o_it(PluginFunctions::ALL_OBJECTS, type); o_it != PluginFunctions::objectsEnd(); ++o_it){ for (auto* o_it : PluginFunctions::objects(PluginFunctions::ALL_OBJECTS, type) ) {
o_it->show(); o_it->show();
} }
...@@ -586,8 +581,9 @@ IdList DataControlPlugin::getTargetObjects(DataType _type) { ...@@ -586,8 +581,9 @@ IdList DataControlPlugin::getTargetObjects(DataType _type) {
IdList list; IdList list;
for ( PluginFunctions::ObjectIterator o_it(PluginFunctions::TARGET_OBJECTS, _type); o_it != PluginFunctions::objectsEnd(); ++o_it) for (auto* o_it : PluginFunctions::objects(PluginFunctions::TARGET_OBJECTS, _type) ) {
list.push_back( o_it->id() ); list.push_back( o_it->id() );
}
return list; return list;
} }
...@@ -601,8 +597,9 @@ IdList DataControlPlugin::getSourceObjects(DataType _type) { ...@@ -601,8 +597,9 @@ IdList DataControlPlugin::getSourceObjects(DataType _type) {
IdList list; IdList list;
for ( PluginFunctions::ObjectIterator o_it(PluginFunctions::SOURCE_OBJECTS, _type); o_it != PluginFunctions::objectsEnd(); ++o_it) for (auto* o_it : PluginFunctions::objects(PluginFunctions::SOURCE_OBJECTS, _type) ) {
list.push_back( o_it->id() ); list.push_back( o_it->id() );
}
return list; return list;
} }
...@@ -614,8 +611,9 @@ IdList DataControlPlugin::getSourceObjects(DataType _type) { ...@@ -614,8 +611,9 @@ IdList DataControlPlugin::getSourceObjects(DataType _type) {
*/ */
void DataControlPlugin::printObjectInfoToLog() { void DataControlPlugin::printObjectInfoToLog() {
for ( PluginFunctions::ObjectIterator o_it(PluginFunctions::ALL_OBJECTS); o_it != PluginFunctions::objectsEnd(); ++o_it) for (auto* o_it : PluginFunctions::objects(PluginFunctions::ALL_OBJECTS) ) {
emit log(LOGINFO, tr("Object \"%1\" with ID %2 of type %3 ").arg(o_it->name()).arg(o_it->id()).arg(o_it->dataType().name())); emit log(LOGINFO, tr("Object \"%1\" with ID %2 of type %3 ").arg(o_it->name()).arg(o_it->id()).arg(o_it->dataType().name()));
}
} }
//****************************************************************************** //******************************************************************************
...@@ -628,8 +626,8 @@ void DataControlPlugin::printObjectInfoToLog() { ...@@ -628,8 +626,8 @@ void DataControlPlugin::printObjectInfoToLog() {
*/ */
unsigned int DataControlPlugin::groupCount() const { unsigned int DataControlPlugin::groupCount() const {
unsigned int count = 0; unsigned int count = 0;
for ( PluginFunctions::BaseObjectIterator o_it(PluginFunctions::ALL_OBJECTS,DATA_GROUP); o_it != PluginFunctions::objectsEnd(); ++o_it) for (auto* o_it : PluginFunctions::objects(PluginFunctions::ALL_OBJECTS, DATA_GROUP) )
++count; ++count;
return count; return count;
} }
......
...@@ -321,8 +321,7 @@ void DataControlPlugin::slotHeaderCustomContextMenuRequested ( const QPoint & _p ...@@ -321,8 +321,7 @@ void DataControlPlugin::slotHeaderCustomContextMenuRequested ( const QPoint & _p
//get all used types //get all used types
QVector<DataType> types; QVector<DataType> types;
for ( PluginFunctions::ObjectIterator o_it(PluginFunctions::ALL_OBJECTS) ; for (auto* o_it : PluginFunctions::objects(PluginFunctions::ALL_OBJECTS) )
o_it != PluginFunctions::objectsEnd(); ++o_it)
if ( !types.contains( o_it->dataType() ) ) if ( !types.contains( o_it->dataType() ) )
types.push_back( o_it->dataType() ); types.push_back( o_it->dataType() );
...@@ -478,8 +477,7 @@ void DataControlPlugin::slotCopyMaterialToTargeted() { ...@@ -478,8 +477,7 @@ void DataControlPlugin::slotCopyMaterialToTargeted() {
BaseObjectData* itemData = dynamic_cast< BaseObjectData* > (item); BaseObjectData* itemData = dynamic_cast< BaseObjectData* > (item);
const ACG::SceneGraph::Material &sourceMaterial = itemData->materialNode()->material(); const ACG::SceneGraph::Material &sourceMaterial = itemData->materialNode()->material();
for (PluginFunctions::ObjectIterator o_it(PluginFunctions::TARGET_OBJECTS); for (auto* o_it : PluginFunctions::objects(PluginFunctions::TARGET_OBJECTS) ) {
o_it != PluginFunctions::objectsEnd(); ++o_it) {
MaterialNode * const materialNode = o_it->materialNode(); MaterialNode * const materialNode = o_it->materialNode();
if (materialNode) { if (materialNode) {
......
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