XML Mill  1.0.0
A GUI based XML editor with a memory.
gctreewidgetitem.h
00001 /* Copyright (c) 2012 - 2013 by William Hallatt.
00002  *
00003  * This file forms part of "XML Mill".
00004  *
00005  * The official website for this project is <http://www.goblincoding.com> and,
00006  * although not compulsory, it would be appreciated if all works of whatever
00007  * nature using this source code (in whole or in part) include a reference to
00008  * this site.
00009  *
00010  * Should you wish to contact me for whatever reason, please do so via:
00011  *
00012  *                 <http://www.goblincoding.com/contact>
00013  *
00014  * This program is free software: you can redistribute it and/or modify it under
00015  * the terms of the GNU General Public License as published by the Free Software
00016  * Foundation, either version 3 of the License, or (at your option) any later
00017  * version.
00018  *
00019  * This program is distributed in the hope that it will be useful, but WITHOUT
00020  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00021  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
00022  *
00023  * You should have received a copy of the GNU General Public License along with
00024  * this program (GNUGPL.txt).  If not, see
00025  *
00026  *                    <http://www.gnu.org/licenses/>
00027  */
00028 
00029 #ifndef GCTREEWIDGETITEM_H
00030 #define GCTREEWIDGETITEM_H
00031 
00032 #include <QTreeWidgetItem>
00033 #include <QStringList>
00034 #include <QString>
00035 #include <QDomElement>
00036 
00038 
00051 class GCTreeWidgetItem : public QTreeWidgetItem
00052 {
00053 public:
00055   explicit GCTreeWidgetItem( QDomElement element );
00056 
00060   explicit GCTreeWidgetItem( QDomElement element, int index );
00061 
00063   GCTreeWidgetItem* gcParent() const;
00064 
00066   GCTreeWidgetItem* gcChild( int index ) const;
00067 
00069   QDomElement element() const;
00070 
00074   void setExcludeElement( bool exclude );
00075 
00079   bool elementExcluded() const;
00080 
00084   void excludeAttribute( const QString& attribute );
00085 
00089   void includeAttribute( const QString& attribute, const QString& value );
00090 
00094   bool attributeIncluded( const QString& attribute ) const;
00095 
00104   void setIncrementAttribute( const QString& attribute, bool increment );
00105 
00112   bool incrementAttribute( const QString& attribute ) const;
00113 
00120   void fixAttributeValues();
00121 
00127   QString fixedValue( const QString& attribute ) const;
00128 
00134   void revertToFixedValues();
00135 
00138   QString toString() const;
00139 
00142   void setIndex( int index );
00143 
00147   int index() const;
00148 
00150   void rename( const QString& newName );
00151 
00153   QString name() const;
00154 
00158   void setVerbose( bool verbose );
00159 
00162   void insertGcChild( int index, GCTreeWidgetItem* item );
00163 
00164 private:
00166   void init( QDomElement element, int index );
00167 
00170   void setDisplayText();
00171 
00172   QDomElement m_element;
00173   bool m_elementExcluded;
00174   bool m_verbose;
00175   int m_index;
00176 
00177   QStringList m_includedAttributes;
00178   QStringList m_incrementedAttributes;
00179   QHash< QString/*attr*/, QString /*val*/ > m_fixedValues;
00180 };
00181 
00182 #endif // GCTREEWIDGETITEM_H