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 decreaseObjectCount()
Increase the number of current Object.
int row() const
get the row of this item from the parent
QMap< QString, PerObjectData * > & getPerObjectDataMap()
get reference to map of all perObject Datas
void deleteSubtree()
delete the whole subtree below this item ( The item itself is not touched )
QString path_
path to the file from which the object is loaded ( defaults to "." )
BaseObject * parent()
Get the parent item ( 0 if rootitem )
void appendChild(BaseObject *child)
add a child to this node
PerObjectData * objectData(QString _dataName)
Returns the object data pointer.
virtual QString getObjectinfo()
Get all Info for the Object as a string.
QMap< QString, PerObjectData * > dataMap_
get reference to map of all perObject Datas
QString name() const
return the name of the object. The name defaults to NONAME if unset.
const DataType DATA_UNKNOWN(0)
None of the other Objects.
QString filename() const
return the filename of the object
void deleteData()
Delete all data attached to this object ( calls delete on each object )
virtual void update(UpdateType _type=UPDATE_ALL)
This function is called to update the object.
const DataType DATA_GROUP(1)
Items used for Grouping.
QString path() const
return the path to the object ( defaults to "." if unset )
void setFileName(const QString &_filename)
set the filename for this object
void setFromFileName(const QString &_filename)
virtual bool visible()
return if object is visible
void decreaseTargetCount()
Increase the number of current Object.
bool isInGroup(int _id) const
DataType dataType() const
bool isGroup() const
Check if object is a group.
QList< BaseObject * > childItems_
Children of this node.
virtual void printObjectInfo()
Print all information about the object.
DLLEXPORT QString typeName(DataType _id)
Get the name of a type with given id.
bool dataType(DataType _type) const
void increaseTargetCount()
Decrease the number of current Object.
void addObjectToMap(int _objectId, BaseObject *_object)
Add object to internal object map.
virtual PerObjectData * copyPerObjectData()
Copy Function.
bool hasObjectData(QString _dataName)
Checks if object data with given name is available.
void setObjectData(QString _dataName, PerObjectData *_data)
void removeChild(BaseObject *_item)
Remove a child from this object.
QString filename_
path to the file from which the object is loaded ( defaults to "." )
void setParent(BaseObject *_parent)
Set the parent pointer.
void increaseObjectCount()
Decrease the number of current Object.
BaseObject * childExists(int _objectId)
Check if the element exists in the subtree of this element.
void setPath(const QString &_path)
set the path to the object.
BaseObject *& objectRoot()
Get the root of the object structure.
std::vector< int > getGroupIds()
void clearObjectData(QString _dataName)
Clear the object data pointer ( this will not delete the object!! )
QList< BaseObject * > getLeafs()
get all leafes of the tree below this object ( These will be all visible objects ) ...
void setDataType(DataType _type)
const DataType DATA_ALL(UINT_MAX)
Identifier for all available objects.
QString name_
Object/FileName ( defaults to NONAME )
BaseObject(const BaseObject &_object)
void objectSelectionChanged(int _objectId)
void setFlag(QString _flag, bool _set)
void visibilityChanged(int _objectId)
int childCount() const
get the number of children
int persistentId_
Persistent ID for this Object.
virtual BaseObject * copy()
Returns a full copy of the object.
int id_
Unique ID for this Object.
virtual void setName(QString _name)
path to the file from which the object is loaded ( defaults to "." )
BaseObject * child(int row)
return a child
void removeObjectFromMap(int _objectId)
Remove object from internal object map.
QStringList getGroupNames()
void dumpTree()
Debugging function, writing the subtree to output.
void objectPropertiesChanged(int _objectId)
BaseObject * parentItem_
Parent item or 0 if rootnode.