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