/***************************************************************************************
|
* Copyright 2009-2011 Hikvision Digital Technology Co., Ltd.
|
* FileName : treeitem.h
|
* Description : Ê÷ÐÍÏÔʾ½ÚµãÍ·Îļþ
|
* Modification : ÎÞ
|
* Version : V1.0.0
|
* Time : 2009-10,11
|
* Author : wanggp@hikvision.com
|
**************************************************************************************/
|
|
|
#include <QStringList>
|
#include <QMessageBox>
|
#include "treeitem.h"
|
|
/************************************************************************
|
* Function : TreeItem
|
* Description : ¹¹Ô캯Êý
|
* Input : data,parent
|
* Output : ÎÞ
|
* Return : ÎÞ
|
*************************************************************************/
|
TreeItem::TreeItem(const QList<QVariant> &data, TreeItem *parent)
|
{
|
parentItem = parent;
|
itemData = data;
|
}
|
|
/************************************************************************
|
* Function : ~TreeItem
|
* Description : Îö¹¹º¯Êý
|
* Input : ÎÞ
|
* Output : ÎÞ
|
* Return : ÎÞ
|
*************************************************************************/
|
TreeItem::~TreeItem()
|
{
|
qDeleteAll(childItems);
|
}
|
|
/************************************************************************
|
* Function : appendChild
|
* Description : Ìí¼Ó½Úµã
|
* Input : item
|
* Output : ÎÞ
|
* Return : ÎÞ
|
*************************************************************************/
|
void TreeItem::appendChild(TreeItem *item)
|
{
|
childItems.append(item);
|
}
|
|
/************************************************************************
|
* Function : child
|
* Description : È¡º¢×Ó½áµã
|
* Input : row
|
* Output : ÎÞ
|
* Return : childItems
|
*************************************************************************/
|
TreeItem *TreeItem::child(int row)
|
{
|
return childItems.value(row);
|
}
|
|
/************************************************************************
|
* Function : childCount
|
* Description : ×Ó½Úµã¼ÆÊý
|
* Input : ÎÞ
|
* Output : ÎÞ
|
* Return : ÎÞ
|
*************************************************************************/
|
int TreeItem::childCount() const
|
{
|
return childItems.count();
|
}
|
|
/************************************************************************
|
* Function : columnCount
|
* Description : ÁÐÊý¼ÆÊý
|
* Input : ÎÞ
|
* Output : ÎÞ
|
* Return : ×Ó½ÚµãµÄ×ܸöÊý
|
*************************************************************************/
|
int TreeItem::columnCount() const
|
{
|
return itemData.count();
|
}
|
|
/************************************************************************
|
* Function : data
|
* Description : ijһÁÐÊý¾Ý
|
* Input : column
|
* Output : ÎÞ
|
* Return : itemData.value
|
*************************************************************************/
|
QVariant TreeItem::data(int column) const
|
{
|
QString data =itemData.value(column).toString();
|
//QMessageBox::information(this,tr("TreeItem::data"),tr("data=%1").arg(data.toLatin1().data()));
|
//printf("%s\n",data.toLatin1().data());
|
return itemData.value(column);
|
}
|
|
bool TreeItem::setData(const QVariant &value)
|
{
|
//printf("1232434534555=%s\n",value.toString().toLatin1().data());
|
//itemData.clear();
|
//itemData.append(value);
|
//printf("1232434534555=%s\n",value.toString().toLatin1().data());
|
|
return true;
|
|
// return false;
|
|
|
}
|
|
/************************************************************************
|
* Function : parent
|
* Description : È¡Æä¸¸½Úµã
|
* Input : ÎÞ
|
* Output : ÎÞ
|
* Return : parentItem
|
*************************************************************************/
|
TreeItem *TreeItem::parent()
|
{
|
return parentItem;
|
}
|
|
/************************************************************************
|
* Function : row
|
* Description : ͳ¼ÆÐÐÊý
|
* Input : ÎÞ
|
* Output : ÎÞ
|
* Return : 0
|
*************************************************************************/
|
int TreeItem::row() const
|
{
|
if (parentItem)
|
{
|
return parentItem->childItems.indexOf(const_cast<TreeItem*>(this));
|
}
|
return 0;
|
}
|
|