Back to index

salome-gui  6.5.0
TreeItem.hxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // This library is free software; you can redistribute it and/or
00004 // modify it under the terms of the GNU Lesser General Public
00005 // License as published by the Free Software Foundation; either
00006 // version 2.1 of the License.
00007 //
00008 // This library is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 // Lesser General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU Lesser General Public
00014 // License along with this library; if not, write to the Free Software
00015 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00016 //
00017 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00018 //
00019 
00020 // Author: Guillaume Boulant (EDF/R&D)
00021 
00022 #ifndef TREEITEM_H
00023 #define TREEITEM_H
00024 
00025 #include "TreeData.hxx"
00026 
00027 #include <QList>
00028 #include <QVariant>
00029 #include <QVector>
00030 #include <QModelIndex>
00031 
00032 #include "DataObject.hxx"
00033 #include "TreeModel.hxx"
00034 
00035 class TREEDATA_EXPORT TreeItem
00036 {
00037  public:
00038   TreeItem(const QString &nameId, const QVector<QVariant> &columnValues, TreeItem *parent = 0);
00039   ~TreeItem();
00040 
00041   QString nameId();
00042   void associateToModel(TreeModel * model);
00043   TreeModel * associatedModel();
00044   QModelIndex modelIndex(int column=0);
00045   TreeItem *parent();
00046 
00047   void appendChild(TreeItem * child);
00048   void appendChild(DataObject * dataObject,
00049                    const QStringList &relativePath=QStringList());
00050   void appendChild(const QString &nameId,
00051                    const QVector<QVariant> &columnValues,
00052                    const QStringList &relativePath=QStringList());
00053 
00054   
00055   
00056   TreeItem *child(int row);
00057   TreeItem *childById(const QString &nameId);
00058   TreeItem *childByLabel(const QString &label);
00059   int childCount() const;
00060   int columnCount() const;
00061   int rowIndex() const;
00062   QVariant data(int column) const;
00063   bool setData(int column, const QVariant &value);
00064 
00065 
00066  private:
00067   void initialize(const QString &nameId,
00068                   const QVector<QVariant> &columnValues,
00069                   TreeItem *parent);
00070 
00071   QList<TreeItem*> _childItems;
00072   QMap <QString, TreeItem *> _childItemsMapById;
00073   QMap <QString, TreeItem *> _childItemsMapByLabel;
00074 
00075   QString _itemNameId;
00076   QVector<QVariant> _itemData;
00077   TreeItem  * _parentItem;
00078   TreeModel * _associatedModel;
00079 
00080 };
00081 
00082 #endif