47 #include "DataControlPlugin.hh" 54 emit setSlotDescription(
"getSourceObjects(DataType)",tr(
"Returns the IdList of all source objects with given DataType."),
55 QStringList(tr(
"Datatype")), QStringList(tr(
"Datatype of the objects")));
57 emit setSlotDescription(
"getTargetObjects(DataType)",tr(
"Returns the IdList of all target objects with given DataType."),
58 QStringList(tr(
"Datatype")), QStringList(tr(
"Datatype of the objects")));
60 emit setSlotDescription(
"getObject(QString)",tr(
"Returns the id of an object with given name."),
61 QStringList(tr(
"Name")), QStringList(tr(
"Name of an object")));
63 emit setSlotDescription(
"getObjectName(int)",tr(
"Returns the name of an object with given id."),
64 QStringList(tr(
"objectId")), QStringList(tr(
"ID of an object")));
66 emit setSlotDescription(
"dataType(int)",tr(
"Returns the DataType of the object with the given id."),
67 QStringList(tr(
"objectId")), QStringList(tr(
"ID of an object")));
69 emit setSlotDescription(
"hideObject(int)",tr(
"Hide object with the given id."),
70 QStringList(tr(
"objectId")), QStringList(tr(
"ID of an object")));
72 emit setSlotDescription(
"showObject(int)",tr(
"Show object with the given id."),
73 QStringList(tr(
"objectId")), QStringList(tr(
"ID of an object")));
75 emit setSlotDescription(
"setTarget(int,bool)",tr(
"Set given object as target."),
76 QString(tr(
"ObjectId,Target")).split(
","),
77 QString(tr(
"id of the object, set object as target?")).split(
","));
79 emit setSlotDescription(
"setSource(int,bool)",tr(
"Set given object as source."),
80 QString(tr(
"ObjectId,Source")).split(
","),
81 QString(tr(
"id of the object, set object as source?")).split(
","));
83 emit setSlotDescription(
"setObjectName(int,QString)",tr(
"Set name of given object."),
84 QString(tr(
"ObjectId,name")).split(
","),
85 QString(tr(
"id of the object, the new name")).split(
","));
87 emit setSlotDescription(
"addEmptyGroup(QString)", tr(
"Create new empty group."),
88 QStringList(tr(
"GroupName")),
89 QStringList(tr(
"Name of the new group.")));
91 emit setSlotDescription(
"addEmptyGroup(QString,int)", tr(
"Create new empty group."),
92 QString(tr(
"GroupName,Parent")).split(
","),
93 QString(tr(
"Name of the new group., Parent of the new group, or -1, if there is no parent.")).split(
","));
95 emit setSlotDescription(
"groupObjects(IdList,QString)",tr(
"Group given Objects together."),
96 QString(tr(
"objectIds,groupName")).split(
","),
97 QString(tr(
"List of objects that should be grouped., Name of the group.")).split(
","));
99 emit setSlotDescription(
"groupObjects(IdList)",tr(
"Group given Objects together."),
100 QStringList(tr(
"objectIds")), QStringList(tr(
"List of objects that should be grouped.")));
102 emit setSlotDescription(
"groupCount()",tr(
"Returns the number of group objects."),
103 QStringList(tr(
"")), QStringList(tr(
"")));
105 emit setSlotDescription(
"unGroupObject(int)",tr(
"Remove the given object from its group and append to root node."),
106 QStringList(tr(
"ObjectId")), QStringList(tr(
"Object to be removed from group.")));
108 emit setSlotDescription(
"objectDelete(int)",tr(
"Delete an object"),
109 QStringList(tr(
"objectId")), QStringList(tr(
"Delete the given object.")));
111 emit setSlotDescription(
"getGroupElements(int)",tr(
"Get elements of a group"),
112 QStringList(tr(
"groupId")), QStringList(tr(
"Id of the group.")));
114 emit setSlotDescription(
"copyObject(int)",tr(
"Create a copy of an object"),
115 QStringList(tr(
"objectId")), QStringList(tr(
"Object to copy.")));
117 emit setSlotDescription(
"setAllTarget()",tr(
"Set All objects as targets"),
118 QStringList(), QStringList());
120 emit setSlotDescription(
"setAllSource()",tr(
"Set All objects as source"),
121 QStringList(), QStringList());
123 emit setSlotDescription(
"clearAllTarget()",tr(
"Clear targets"),
124 QStringList(), QStringList());
126 emit setSlotDescription(
"clearAllSource()",tr(
"Clear sources"),
127 QStringList(), QStringList());
129 emit setSlotDescription(
"showAll()",tr(
"Show all objects"),
130 QStringList(), QStringList());
132 emit setSlotDescription(
"hideAll()",tr(
"Hide all objects"),
133 QStringList(), QStringList());
135 emit setSlotDescription(
"availableDataTypeNames()",tr(
"Returns a QStringList of all available DataType names."),
136 QStringList(tr(
"")), QStringList(tr(
"")));
138 emit setSlotDescription(
"printObjectInfoToLog()",tr(
"Print info about all objects to log"),
139 QStringList(), QStringList());
141 emit setSlotDescription(
"addObjectToGroup(int,int)",tr(
"Add an Object to an existing group"),
142 QStringList(tr(
"objectId,groupId").split(
",")),
143 QStringList(tr(
"ID of an object.,ID of an group where the object has to be added.").split(
",")));
173 int DataControlPlugin::copyObject(
int objectId ) {
177 emit copyObject( objectId, newObject );
194 emit log(
LOGERR,tr(
"getObjectName : unable to get object") );
195 return QString(tr(
"Unknown Object"));
197 return object->name() ;
209 return object->dataType();
223 if ( ! OpenFlipper::Options::gui())
245 object->
target( _target );
261 object->
source( _source );
298 emit deleteObject(objectId);
310 if ( ! OpenFlipper::Options::gui())
334 parentGroupObject = parent;
336 emit log(
LOGWARN, tr(
"Parent object %1 is not a group, creating a new toplevel group").arg(_parentGroupId));
338 }
else if (_parentGroupId != 0 ) {
339 emit log(
LOGWARN, tr(
"Cannot get parent object %1, creating a new toplevel group").arg(_parentGroupId));
344 if (_groupName ==
"") {
345 groupObject->
setName(tr(
"New group ") + QString::number(groupObject->
id()));
347 groupObject->
setName(_groupName);
350 emit emptyObjectAdded(groupObject->
id());
352 return groupObject->
id();
363 QVector< BaseObject* > objs;
366 for (uint i=0; i < _objectIDs.size(); i++){
373 if (objs.size() == 0){
374 emit log(tr(
"No objects to group."));
381 for (
int i = 1 ; i < objs.size() ; ++i){
382 if ( parent != (objs[i])->
parent() ){
383 emit log(tr(
"Cannot group Objects with different parents"));
400 for (
int i = 0 ; i < objs.size() ; ++i)
402 (objs[i])->setParent(groupItem);
403 ids.push_back((objs[i])->
id());
406 emit objectsGrouped(ids);
419 if ( group && group->
isGroup())
422 for (
int i=group->
childCount()-1; i >= 0; --i){
429 emit deleteObject( group->
id() );
434 emit log(
LOGERR, tr(
"Cannot Ungroup. Object with id %1 is not a group").arg(_id));
436 emit log(
LOGERR, tr(
"Unable to get Object with id %1 for ungrouping").arg(_id) );
452 QAction* action =
dynamic_cast< QAction*
> ( sender() );
454 if ( action != 0 && action->data().isValid() )
455 type = (
DataType) action->data().toUInt();
474 QAction* action =
dynamic_cast< QAction*
> ( sender() );
476 if ( action != 0 && action->data().isValid() )
477 type = (
DataType) action->data().toUInt();
496 QAction* action =
dynamic_cast< QAction*
> ( sender() );
498 if ( action != 0 && action->data().isValid() )
499 type = (
DataType) action->data().toUInt();
518 QAction* action =
dynamic_cast< QAction*
> ( sender() );
520 if ( action != 0 && action->data().isValid() )
521 type = (
DataType) action->data().toUInt();
537 if ( ! OpenFlipper::Options::gui())
543 QAction* action =
dynamic_cast< QAction*
> ( sender() );
545 if ( action != 0 && action->data().isValid() )
546 type = (
DataType) action->data().toUInt();
563 if ( ! OpenFlipper::Options::gui())
569 QAction* action =
dynamic_cast< QAction*
> ( sender() );
571 if ( action != 0 && action->data().isValid() )
572 type = (
DataType) action->data().toUInt();
590 list.push_back( o_it->id() );
605 list.push_back( o_it->id() );
618 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()));
630 unsigned int count = 0;
678 emit log(
LOGERR, tr(
" Object with id %1 is not a group").arg(_groupId));
681 emit log(
LOGERR, tr(
"Unable to get Object with id %1").arg(_objectId) );
683 emit log(
LOGERR, tr(
"Unable to get Group with id %1").arg(_groupId) );
703 result.push_back(group->
child(i)->
id());
DLLEXPORT std::vector< TypeInfo >::const_iterator typesEnd()
Get iterator pointing to the last element in the types list.
void hideAll()
Hides all objects.
IdList getSourceObjects(DataType _type)
Get all source objects of given type.
void hideObject(int objectId)
Hide the given Object.
void showAll()
Shows all objects.
BaseObject * child(int row)
return a child
virtual void show()
Sets the whole Scenegraph subtree of this node to visible.
int groupObjects(IdList _objectIDs, QString _groupName="")
Group given Objects together.
void setSource(int objectId, bool _source)
set the given Object as source
bool addObjectToGroup(int _objectId, int _groupId)
add an object to an existing group
void setTarget(int objectId, bool _target)
set the given Object as target
virtual void setName(QString _name) override
path to the file from which the object is loaded ( defaults to "." )
int childCount() const
get the number of children
const UpdateType UPDATE_ALL(UpdateTypeSet(1))
Identifier for all updates.
QString name() const
Return the name of this type as text.
bool getObject(const int _identifier, BaseObject *&_object)
Get the object which has the given identifier.
bool unGroupObject(int _id)
BaseObject *& objectRoot()
Get the root of the object structure.
IdList getTargetObjects(DataType _type)
Get all target objects of given type.
void clearAllTarget()
Unselect all objects.
const QStringList SOURCE_OBJECTS("source")
Iterable object range.
const QStringList ALL_OBJECTS
Iterable object range.
const DataType DATA_GROUP(1)
Items used for Grouping.
void setAllTarget()
Makes all available objects target.
BaseObject * childExists(int _objectId)
Check if the element exists in the subtree of this element.
std::vector< int > IdList
Standard Type for id Lists used for scripting.
DLLEXPORT ObjectIterator objectsEnd()
Return Iterator to Object End.
BaseObject * parent()
Get the parent item ( 0 if rootitem )
void setParent(BaseObject *_parent)
Set the parent pointer.
virtual void setName(QString _name)
path to the file from which the object is loaded ( defaults to "." )
QString getObjectName(int objectId)
Get the Objects name from the id.
void setAllSource()
Makes all available objects source.
Core Data Iterator used to iterate over all objects (Including groups)
unsigned int groupCount() const
Returns the number of groups.
DataType dataType(int objectId)
Get the DataType of a given object.
IdList getGroupElements(int _groupId)
Get all elements of the given group.
virtual void hide()
Sets the whole Scenegraph subtree of this node to invisible.
const QStringList TARGET_OBJECTS("target")
Iterable object range.
bool isGroup() const
Check if object is a group.
void printObjectInfoToLog()
Print information about all open objects to the console.
void objectDelete(int objectId)
Delete the given object.
int getObject(QString _name)
Get the id of an object by its name.
void clearAllSource()
remove source selection from all objects
DLLEXPORT std::vector< TypeInfo >::const_iterator typesBegin()
Get iterator pointing to the first element in the types list.
const DataType DATA_UNKNOWN(0)
None of the other Objects.
void setObjectName(int objectId, QString _name)
set the name of the given object
const DataType DATA_ALL(UINT_MAX)
Identifier for all available objects.
int addEmptyGroup(QString _groupName="", int _parentGroupId=0)
Create new empty group.
QString availableDataTypeNames() const
Returns a list of all available DataTypes.
void showObject(int objectId)
Show the given Object.