00001 /*************************************************************************** 00002 ** 00003 ** This file is part of GeopsyCore. 00004 ** 00005 ** This library is free software; you can redistribute it and/or 00006 ** modify it under the terms of the GNU Lesser General Public 00007 ** License as published by the Free Software Foundation; either 00008 ** version 2.1 of the License, or (at your option) any later version. 00009 ** 00010 ** This file is distributed in the hope that it will be useful, but WITHOUT 00011 ** ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00012 ** FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 00013 ** License for more details. 00014 ** 00015 ** You should have received a copy of the GNU Lesser General Public 00016 ** License along with this library; if not, write to the Free Software 00017 ** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00018 ** 00019 ** See http://www.geopsy.org for more information. 00020 ** 00021 ** Created: 2011-05-16 00022 ** Authors: 00023 ** Marc Wathelet (ISTerre, Grenoble, France) 00024 ** 00025 ***************************************************************************/ 00026 00027 #ifndef ABSTRACTSIGNALGROUP_H 00028 #define ABSTRACTSIGNALGROUP_H 00029 00030 #include <QGpCoreTools.h> 00031 00032 #include "GeopsyCoreDLLExport.h" 00033 00034 class QIcon; 00035 00036 namespace GeopsyCore { 00037 00038 class Signal; 00039 class SignalDB; 00040 class SubSignalPool; 00041 00042 class GEOPSYCORE_EXPORT AbstractSignalGroup: public TreeContainer 00043 { 00044 public: 00045 AbstractSignalGroup(AbstractSignalGroup * parent=0); 00046 virtual ~AbstractSignalGroup() {} 00047 00048 virtual void setParent(AbstractSignalGroup * p); 00049 00050 virtual QString name() const {return _name;} 00051 virtual void setName(const QString& n); 00052 QString pathName() const; 00053 00054 QString comments() const {return _comments;} 00055 void setComments(const QString& c); 00056 00057 bool isModified() const; 00058 void setModified(bool m); 00059 00060 AbstractSignalGroup * find(QString name) const; 00061 QList<AbstractSignalGroup *> find(const Signal * sig) const; 00062 00063 virtual bool readOnly() const {return false;} 00064 virtual bool readOnlyChildren() const {return false;} 00065 virtual bool stored() const {return true;} 00066 virtual int signalCount() const; 00067 virtual bool hasOwnSignal() const {return false;} 00068 bool contains(const Signal * sig) const; 00069 virtual bool directlyContains(const Signal * sig) const; 00070 virtual SubSignalPool subPool() const; 00071 00072 virtual bool convertIds(const QHash<int, Signal *>& ids); 00073 00074 virtual void removeSignal(Signal * sig); 00075 00076 virtual const QIcon * icon() const; 00077 void printList(QString prefix); 00078 00079 static inline bool lessThan(AbstractSignalGroup * g1, AbstractSignalGroup * g2); 00080 00081 AbstractSignalGroup * parent() {return static_cast<AbstractSignalGroup *>(TreeContainer::parent());} 00082 const AbstractSignalGroup * parent() const {return static_cast<const AbstractSignalGroup *>(TreeContainer::parent());} 00083 AbstractSignalGroup * childAt(int index) {return static_cast<AbstractSignalGroup *>(TreeContainer::childAt(index));} 00084 protected: 00085 virtual void xml_writeProperties(XML_WRITEPROPERTIES_ARGS) const; 00086 void xml_writeChildren(XML_WRITECHILDREN_ARGS) const; 00087 virtual XMLMember xml_member(XML_MEMBER_ARGS); 00088 virtual bool xml_setProperty(XML_SETPROPERTY_ARGS); 00089 virtual void xml_polishChild(XML_POLISHCHILD_ARGS); 00090 00091 virtual void reportParentAboutToBeChanged(AbstractSignalGroup * g, AbstractSignalGroup * newParent) const; 00092 virtual void reportParentChanged(AbstractSignalGroup * g, AbstractSignalGroup * oldParent) const; 00093 virtual void reportDataChanged(AbstractSignalGroup * g) const; 00094 private: 00095 QString pathNameHelper() const; 00096 bool isSameMaster(AbstractSignalGroup * g1, AbstractSignalGroup * g2); 00097 void resetModified(); 00098 void find(QList<AbstractSignalGroup *>& groups, const Signal * sig) const; 00099 00100 QString _name; 00101 QString _comments; 00102 bool _modified; 00103 }; 00104 00105 inline bool AbstractSignalGroup::lessThan(AbstractSignalGroup * g1, AbstractSignalGroup * g2) 00106 { 00107 TRACE; 00108 return g1->name()<g2->name(); 00109 } 00110 00111 } // namespace GeopsyCore 00112 00113 #endif // ABSTRACTSIGNALGROUP_H