# Path: reid/utils/data_tree_node.py
# class DataTreeNode(object):
#     """Node of data in tree model (DataTreeNode)
# 
#     The instance of DataTreeNode class is the node in tree model. A node has a
#     parent and some children nodes. The node iteself contains several columns
#     of data.
#     """
# 
#     def __init__(self, data, parent=None):
#         """Initialize the DataTreeNode
# 
#         Args:
#             data: A list of QVariant variables
#             parent: The parent DataTreeNode
# 
#         """
# 
#         self._data = data
#         self._parent = parent
#         self._children = []
# 
#     def add_child(self, node):
#         """Add a child node
# 
#         Args:
#             node: The child DataTreeNode to be appended
#         """
# 
#         self._children.append(node)
# 
#     def get_child(self, index):
#         """Get a child node
# 
#         Args:
#             index: An integer index number
# 
#         Returns:
#             The corresponding child DataTreeNode
#         """
# 
#         return self._children[index]
# 
#     def get_child_index(self, child):
#         """Get the index of a particular child node
# 
#         Args:
#             child: Queried child DataTreeNode
# 
#         Returns:
#             An integer indicates the index of the corresponding node
#         """
# 
#         return self._children.index(child)
# 
#     def n_children(self):
#         """Get the number of children"""
# 
#         return len(self._children)
# 
#     def get_data(self, column):
#         """Get the data of a column
# 
#         Args:
#             column: Queried column index
# 
#         Returns:
#             The data stored in the column
#         """
# 
#         return self._data[column]
# 
#     def n_columns(self):
#         """Get the number of data columns"""
# 
#         return len(self._data)
# 
#     def get_parent(self):
#         """Get the parent node"""
# 
#         return self._parent


from PySide import QtCore
from PySide.QtCore import QModelIndex, Qt
from reid.utils.data_tree_node import DataTreeNode
#!/usr/bin/python2
# -*- coding: utf-8 -*-




class DataTreeModel(QtCore.QAbstractItemModel):
    """The tree model of data (DataTreeModel)

    The DataTreeModel class is the model of tree view widget in data viewer.
    """

    def __init__(self, data_loader, parent=None):
        super(DataTreeModel, self).__init__(parent)

        # Setup model data
        self._root = DataTreeNode(["Name", "Size"])

        for gid in xrange(data_loader.get_n_groups()):
            # Get the pedestrian matrix
            P = data_loader.get_pedes(gid)

            # Group node
            gdata = ["Group {0}".format(gid),
                     "{0}×{1}".format(P.shape[0], P.shape[1])]

# Path: reid/utils/data_tree_node.py
# class DataTreeNode(object):
#     """Node of data in tree model (DataTreeNode)
# 
#     The instance of DataTreeNode class is the node in tree model. A node has a
#     parent and some children nodes. The node iteself contains several columns
#     of data.
#     """
# 
#     def __init__(self, data, parent=None):
#         """Initialize the DataTreeNode
# 
#         Args:
#             data: A list of QVariant variables
#             parent: The parent DataTreeNode
# 
#         """
# 
#         self._data = data
#         self._parent = parent
#         self._children = []
# 
#     def add_child(self, node):
#         """Add a child node
# 
#         Args:
#             node: The child DataTreeNode to be appended
#         """
# 
#         self._children.append(node)
# 
#     def get_child(self, index):
#         """Get a child node
# 
#         Args:
#             index: An integer index number
# 
#         Returns:
#             The corresponding child DataTreeNode
#         """
# 
#         return self._children[index]
# 
#     def get_child_index(self, child):
#         """Get the index of a particular child node
# 
#         Args:
#             child: Queried child DataTreeNode
# 
#         Returns:
#             An integer indicates the index of the corresponding node
#         """
# 
#         return self._children.index(child)
# 
#     def n_children(self):
#         """Get the number of children"""
# 
#         return len(self._children)
# 
#     def get_data(self, column):
#         """Get the data of a column
# 
#         Args:
#             column: Queried column index
# 
#         Returns:
#             The data stored in the column
#         """
# 
#         return self._data[column]
# 
#     def n_columns(self):
#         """Get the number of data columns"""
# 
#         return len(self._data)
# 
#     def get_parent(self):
#         """Get the parent node"""
# 
#         return self._parent


# Path: reid/utils/data_tree_model.py
from PySide import QtCore
from PySide.QtCore import QModelIndex, Qt
from reid.utils.data_tree_node import DataTreeNode

#!/usr/bin/python2
# -*- coding: utf-8 -*-




class DataTreeModel(QtCore.QAbstractItemModel):
    """The tree model of data (DataTreeModel)

    The DataTreeModel class is the model of tree view widget in data viewer.
    """

    def __init__(self, data_loader, parent=None):
        super(DataTreeModel, self).__init__(parent)

        # Setup model data
        self._root = DataTreeNode(["Name", "Size"])

        for gid in xrange(data_loader.get_n_groups()):
            # Get the pedestrian matrix
            P = data_loader.get_pedes(gid)

            # Group node
            gdata = ["Group {0}".format(gid),
                     "{0}×{1}".format(P.shape[0], P.shape[1])]

            gnode = DataTreeNode(gdata, self._root)