66 #include <OpenFlipper/BasePlugin/PluginFunctionsCore.hh>
81 static int idGenerator = 1;
91 persistentId_(_object.persistentId_),
92 objectType_(_object.objectType_),
93 flags_(_object.flags_),
94 visible_(_object.visible_),
98 commentsByKey_(_object.commentsByKey_)
111 QMap< QString, PerObjectData* >::const_iterator mapIter = _object.
dataMap_.begin();
112 while ( mapIter != _object.
dataMap_.end() ) {
117 dataMap_.insert(mapIter.key(),copiedData);
119 std::cerr <<
"Failed to copy per Object Data: " << mapIter.key().toStdString() << std::endl;
144 objectManager_.objectCreated(
id());
154 parentItem_(_parent),
179 objectManager_.objectCreated(
id());
183 BaseObject::~BaseObject() {
192 objectManager_.objectDeleted(
id());
246 std::cerr <<
"BaseObect : overwriting data type" << std::endl;
258 output +=
"Info for Object with id " + QString::number(
id()) +
"\n";
259 output +=
"Object is : ";
266 output +=
" visible";
268 output +=
" invisible";
285 return flag(
"target");
290 if (
target() != _target ) {
303 return flag(
"source");
312 return flags_.contains(_flag);
317 bool emitted =
false;
319 if (
flags_.contains(_flag))
407 std::cerr <<
"Last not implemented yet! " << std::endl;
428 while ( parentPointer ) {
431 int nextIndex = ( thisPointer->
row() + 1);
432 if ( parentPointer->
childCount() > nextIndex ) {
437 thisPointer = parentPointer;
457 while ( current->
parent() != 0 ) {
459 current = current->
parent();
514 std::cerr <<
"Warning! Trying to append a child twice! Remove the append calls from your File plugin!" << std::endl;
530 if (
id_ == _objectId )
546 if (
name() == _name )
562 QList<BaseObject*>::iterator i;
571 std::cerr <<
"Illegal remove request" << std::endl;
580 QList< BaseObject* > items;
588 items.push_back(
this);
626 return (
parent()->
id() );
643 if ( current->
id() == _id )
647 current = current->
parent();
648 }
while ( current != 0 );
664 current = current->
parent();
666 }
while ( current != 0 );
672 std::vector< int > groups;
682 if ( current->
parent() != 0 )
683 groups.push_back( current->
id() );
686 current = current->
parent();
687 }
while ( current != 0 );
703 if ( current->
parent() != 0 )
704 groups.push_back( current->
name() );
707 current = current->
parent();
708 }
while ( current != 0 );
728 QFileInfo file_info(_filename);
730 QString
filename = file_info.fileName();
762 for (
int i = 0 ; i <
level() ; ++i )
765 std::cerr <<
"Node ";
766 std::cerr << std::string(
name().toLatin1());
768 std::cerr <<
" with id : ";
772 std::cerr <<
" and type " <<
typeName(
dataType()).toStdString() << std::endl;
781 std::cerr <<
"Copy not supported by this Object" << std::endl;
793 dataMap_.insert( _dataName, _data );
808 return dataMap_.contains(_dataName);
825 QMapIterator<QString, PerObjectData* > i(
dataMap_);
826 while (i.hasNext()) {
840 ObjectManager::ObjectManager() {
843 ObjectManager::~ObjectManager() {
847 void ObjectManager::objectCreated(
int _objectId)
849 emit newObject(_objectId);
852 void ObjectManager::objectDeleted(
int _objectId)
857 emit deletedObject(_objectId);
862 return &objectManager_;
void removeObjectFromMap(int _objectId)
Remove object from internal object map.
QString name() const
return the name of the object. The name defaults to NONAME if unset.
void deleteData()
Delete all data attached to this object ( calls delete on each object )
const DataType DATA_UNKNOWN(0)
None of the other Objects.
int row() const
get the row of this item from the parent
PerObjectData * objectData(QString _dataName)
Returns the object data pointer.
bool dataType(DataType _type) const
void dumpTree()
Debugging function, writing the subtree to output.
QString path_
path to the file from which the object is loaded ( defaults to "." )
virtual void setName(QString _name)
path to the file from which the object is loaded ( defaults to "." )
virtual bool visible()
return if object is visible
int childCount() const
get the number of children
virtual BaseObject * copy()
Returns a full copy of the object.
BaseObject * childExists(int _objectId)
Check if the element exists in the subtree of this element.
virtual QString getObjectinfo()
Get all Info for the Object as a string.
void setFileName(const QString &_filename)
set the filename for this object
BaseObject * parentItem_
Parent item or 0 if rootnode.
void setFromFileName(const QString &_filename)
virtual void update(UpdateType _type=UPDATE_ALL)
This function is called to update the object.
void decreaseObjectCount()
Increase the number of current Object.
QString name_
Object/FileName ( defaults to NONAME )
QList< BaseObject * > childItems_
Children of this node.
void deleteSubtree()
delete the whole subtree below this item ( The item itself is not touched )
bool hasObjectData(QString _dataName)
Checks if object data with given name is available.
QList< BaseObject * > getLeafs()
get all leafes of the tree below this object ( These will be all visible objects ) ...
void setObjectData(QString _dataName, PerObjectData *_data)
QString path() const
return the path to the object ( defaults to "." if unset )
void setPath(const QString &_path)
set the path to the object.
void increaseObjectCount()
Decrease the number of current Object.
void objectSelectionChanged(int _objectId)
QMap< QString, PerObjectData * > dataMap_
get reference to map of all perObject Datas
BaseObject * parent()
Get the parent item ( 0 if rootitem )
const DataType DATA_ALL(UINT_MAX)
Identifier for all available objects.
BaseObject * child(int row)
return a child
QString filename() const
return the filename of the object
void clearObjectData(QString _dataName)
Clear the object data pointer ( this will not delete the object!! )
bool isInGroup(int _id) const
DataType dataType() const
void setParent(BaseObject *_parent)
Set the parent pointer.
virtual void printObjectInfo()
Print all information about the object.
DLLEXPORT QString typeName(DataType _id)
Get the name of a type with given id.
void setFlag(QString _flag, bool _set)
QString filename_
path to the file from which the object is loaded ( defaults to "." )
BaseObject(const BaseObject &_object)
std::vector< int > getGroupIds()
void addObjectToMap(int _objectId, BaseObject *_object)
Add object to internal object map.
void setDataType(DataType _type)
void removeChild(BaseObject *_item)
Remove a child from this object.
const DataType DATA_GROUP(1)
Items used for Grouping.
virtual PerObjectData * copyPerObjectData()
Copy Function.
void visibilityChanged(int _objectId)
void appendChild(BaseObject *child)
add a child to this node
void decreaseTargetCount()
Increase the number of current Object.
BaseObject *& objectRoot()
Get the root of the object structure.
QMap< QString, PerObjectData * > & getPerObjectDataMap()
get reference to map of all perObject Datas
int persistentId_
Persistent ID for this Object.
bool isGroup() const
Check if object is a group.
void increaseTargetCount()
Decrease the number of current Object.
QStringList getGroupNames()
int id_
Unique ID for this Object.
void objectPropertiesChanged(int _objectId)