def __recalculate_delegates(self):
        # reset all the item delegates to make sure all items are properly displayed
        source_model = self.model()
        if source_model is None:
            return

        # figure out the model behind any proxies
        proxy_models = []
        while hasattr(source_model, "sourceModel"):
            proxy_models.append(source_model)
            source_model = source_model.sourceModel()

        # go through each top level row to assign an appropriate delegate
        invalidIndex = QtCore.QModelIndex()
        for row in xrange(0, self.model().rowCount()):
            # map the row back to source model
            source_index = self.model().index(row, 0, invalidIndex)
            for proxy in proxy_models:
                source_index = proxy.mapToSource(source_index)

            # assign header, footer, or group specific delegates
            if source_model.is_header(source_index):
                self.setItemDelegateForRow(row, self.__header_delegate)
            if source_model.is_footer(source_index):
                self.setItemDelegateForRow(row, self.__footer_delegate)
            if source_model.is_content(source_index):
                group_key = source_model.get_item_group_key(source_index)
                self.setItemDelegateForRow(row, self.__group_delegates.get(group_key))