Mercurial > hg > Feedworm
changeset 226:016c89dfd488
use our generic PyQtLib instead of custom Qt models in this project
author | Dirk Olmes <dirk@xanthippe.ping.de> |
---|---|
date | Thu, 22 May 2014 06:10:05 +0200 |
parents | f6dcc85cd8ca |
children | 6ce0e081094a |
files | DisplayModel.py MainWindow.py |
diffstat | 2 files changed, 2 insertions(+), 28 deletions(-) [+] |
line wrap: on
line diff
--- a/DisplayModel.py Thu May 22 05:49:46 2014 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,26 +0,0 @@ -# -*- coding: utf-8 -*- -from PyQt4.QtCore import QAbstractListModel, QModelIndex, Qt - -class DisplayModel(QAbstractListModel): - def __init__(self, parent=None, list=None, displayAttribute=None, **args): - super(DisplayModel, self).__init__(parent, *args) - self.list = list - self.displayAttribute = displayAttribute - - def rowCount(self, parent=QModelIndex()): - return len(self.list) - - def data(self, index, role): - if index.isValid() and role == Qt.DisplayRole: - row = index.row() - item = self.list[row] - displayString = self._stringToDisplay(item) - return displayString - else: - return None - - def _stringToDisplay(self, item): - if hasattr(item, self.displayAttribute): - return getattr(item, self.displayAttribute) - else: - return "invalid display attribute: " + self.displayAttribute
--- a/MainWindow.py Thu May 22 05:49:46 2014 +0200 +++ b/MainWindow.py Thu May 22 06:10:05 2014 +0200 @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- import subprocess from AddFeed import AddFeed -from DisplayModel import DisplayModel +from PyQtLib.GenericListModel import GenericListModel from FeedEntryItemDelegate import FeedEntryItemDelegate from FeedEntryTableModel import FeedEntryTableModel from FeedSettings import FeedSettings @@ -24,7 +24,7 @@ def updateFeedList(self): allFeeds = self.backend.getFeeds() - feedModel = DisplayModel(self, allFeeds, "title") + feedModel = GenericListModel(self, allFeeds, 'title') self.ui.feedList.setModel(feedModel) self.ui.feedList.update()