ij-16.png   inspectorJ -- JavaTM Profiler
sf project site browse source checkout source
SourceForge.net Logo



src/inspectorj/model/treeitem.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   inspectorJ - java profiler                                            *
00003  *   Copyright (C) 2007 by James May
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015  *   You should have received a copy of the GNU General Public License     *
00016  *   along with this program; if not, write to the                         *
00017  *   Free Software Foundation, Inc.,                                       *
00018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00019  ***************************************************************************/
00020 
00027 #include <QStringList>
00028 #include "inspectorj/model/treeitem.h"
00029 
00030 namespace inspectorj {
00031 namespace model {
00032 
00033 TreeItem::TreeItem(const QList<QVariant> &data, TreeItem *parent)
00034     : parentItem(parent), itemData(data)
00035 {
00036 }
00037 
00038 TreeItem::~TreeItem()
00039 {
00040     qDeleteAll(childItems);
00041 }
00042 
00043 void TreeItem::appendChild(TreeItem *item)
00044 {
00045     childItems.append(item);
00046 }
00047 
00048 TreeItem *TreeItem::child(int row)
00049 {
00050     return childItems.value(row);
00051 }
00052 
00053 int TreeItem::childCount() const
00054 {
00055     return childItems.count();
00056 }
00057 
00058 int TreeItem::columnCount() const
00059 {
00060     return itemData.count();
00061 }
00062 
00063 QVariant TreeItem::data(int column) const
00064 {
00065     return itemData.value(column);
00066 }
00067 
00068 TreeItem *TreeItem::parent()
00069 {
00070     return parentItem;
00071 }
00072 
00073 int TreeItem::row() const
00074 {
00075     if (parentItem) {
00076         return parentItem->childItems.indexOf(const_cast<TreeItem*>(this));
00077     }
00078     return 0;
00079 }
00080 
00081 } // end namespace model
00082 } // end namespace inspectorj

Generated on Sun Aug 19 17:07:54 2007 for inspectorJ by  doxygen 1.5.1