# HG changeset patch # User Dirk Olmes # Date 1400731805 -7200 # Node ID 016c89dfd48807083af0e6ef92967da96438f182 # Parent f6dcc85cd8cad2301609b568e8f9cad06f6a9e5e use our generic PyQtLib instead of custom Qt models in this project diff -r f6dcc85cd8ca -r 016c89dfd488 DisplayModel.py --- 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 diff -r f6dcc85cd8ca -r 016c89dfd488 MainWindow.py --- 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()