def data(self, index, role = Qt.DisplayRole): """ Public method to get data from the model. @param index index of history entry to get data for (QModelIndex) @param role data role (integer) @return history entry data (QVariant) """ if role in [Qt.DisplayRole, Qt.EditRole]: start = index.internalId() if start == 0: offset = self.__sourceDateRow(index.row()) if index.column() == 0: idx = self.sourceModel().index(offset, 0) date = idx.data(HistoryModel.DateRole).toDate() if date == QDate.currentDate(): return QVariant(self.trUtf8("Earlier Today")) return QVariant(date.toString("yyyy-MM-dd")) if index.column() == 1: return QVariant(self.trUtf8( "%n item(s)", "", self.rowCount(index.sibling(index.row(), 0)))) elif role == Qt.DecorationRole: if index.column() == 0 and not index.parent().isValid(): return QVariant(UI.PixmapCache.getIcon("history.png")) elif role == HistoryModel.DateRole: if index.column() == 0 and index.internalId() == 0: offset = self.__sourceDateRow(index.row()) idx = self.sourceModel().index(offset, 0) return idx.data(HistoryModel.DateRole) return QAbstractProxyModel.data(self, index, role)
def data(self, index, role = Qt.DisplayRole): """ Public method to get data from the model. @param index index of history entry to get data for (QModelIndex) @param role data role (integer) @return history entry data (QVariant) """ if role == self.FrequencyRole and index.isValid(): return QVariant(self.__filteredRows[index.row()].frequency) return QAbstractProxyModel.data(self, index, role)