class TachogramStatisticsWidget(TableViewWidget):
    """
    a widget to display basic tachogram's statistics
    """
    def __init__(self, parent, **params):
        TableViewWidget.__init__(self, parent, **params)
        self.__dragger__ = CopyDragger(self, STATISTIC_MIME_ID, drag_only=True)
        self.setSelectionMode(QAbstractItemView.SingleSelection)
        self.setSelectionBehavior(QAbstractItemView.SelectRows)
        self.__createModel__()

    def __createModel__(self):
        model = TachogramStatisticsModel(self)
        labels = QStringList(["class_name", "Statistic", "Value"])
        model.setHorizontalHeaderLabels(labels)
        self.setModel(model)

    def setTachogramStatistics(self, _statistics):
        model = self.model()
        model.removeRows(0, model.rowCount())
        values = _statistics[0]
        descriptions = _statistics[1]
        self.class_names = sorted([name for name in values])
        for name in sorted([name for name in self.class_names]):
            model.appendRow([QStandardItem(str(name)),
                             QStandardItem(str(descriptions[name])),
                             QStandardItem(str(values[name]))])
        self.setColumnHidden(0, True)  # "class_name" is a hidden column

    def startDrag(self, dropActions):
        row = self.model().itemFromIndex(self.currentIndex()).row()
        self.__dragger__.clear()
        self.__dragger__.dragObject(STATISTIC_CLASS_NAME_ID,
                                    self.class_names[row])
        self.__dragger__.startDrag()
class TachogramStatisticsWidget(TableViewWidget):
    """
    a widget to display basic tachogram's statistics
    """
    def __init__(self, parent, **params):
        TableViewWidget.__init__(self, parent, **params)
        self.__dragger__ = CopyDragger(self, STATISTIC_MIME_ID, drag_only=True)
        self.setSelectionMode(QAbstractItemView.SingleSelection)
        self.setSelectionBehavior(QAbstractItemView.SelectRows)
        self.__createModel__()

    def __createModel__(self):
        model = TachogramStatisticsModel(self)
        labels = QStringList(["class_name", "Statistic", "Value"])
        model.setHorizontalHeaderLabels(labels)
        self.setModel(model)

    def setTachogramStatistics(self, _statistics):
        model = self.model()
        model.removeRows(0, model.rowCount())
        values = _statistics[0]
        descriptions = _statistics[1]
        self.class_names = sorted([name for name in values])
        for name in sorted([name for name in self.class_names]):
            model.appendRow([
                QStandardItem(str(name)),
                QStandardItem(str(descriptions[name])),
                QStandardItem(str(values[name]))
            ])
        self.setColumnHidden(0, True)  # "class_name" is a hidden column

    def startDrag(self, dropActions):
        row = self.model().itemFromIndex(self.currentIndex()).row()
        self.__dragger__.clear()
        self.__dragger__.dragObject(STATISTIC_CLASS_NAME_ID,
                                    self.class_names[row])
        self.__dragger__.startDrag()
 def __init__(self, parent, **params):
     TableViewWidget.__init__(self, parent, **params)
     self.__dragger__ = CopyDragger(self, STATISTIC_MIME_ID, drag_only=True)
     self.setSelectionMode(QAbstractItemView.SingleSelection)
     self.setSelectionBehavior(QAbstractItemView.SelectRows)
     self.__createModel__()
 def __init__(self, parent, **params):
     TableViewWidget.__init__(self, parent, **params)
     self.__dragger__ = CopyDragger(self, STATISTIC_MIME_ID, drag_only=True)
     self.setSelectionMode(QAbstractItemView.SingleSelection)
     self.setSelectionBehavior(QAbstractItemView.SelectRows)
     self.__createModel__()