new housings on top

This commit is contained in:
Romain Bignon 2012-02-19 10:57:27 +01:00
commit d8d9eaef60

View file

@ -32,10 +32,11 @@ class HousingListWidgetItem(QListWidgetItem):
def __init__(self, housing, *args, **kwargs): def __init__(self, housing, *args, **kwargs):
QListWidgetItem.__init__(self, *args, **kwargs) QListWidgetItem.__init__(self, *args, **kwargs)
self.housing = housing self.housing = housing
self.read = False
def __lt__(self, other): def __lt__(self, other):
return (float(self.housing.cost) / float(self.housing.area)) < \ return '%s%s' % (self.read, float(self.housing.cost) / float(self.housing.area)) < \
(float(other.housing.cost) / float(other.housing.area)) '%s%s' % (other.read, float(other.housing.cost) / float(other.housing.area))
def setAttrs(self, storage): def setAttrs(self, storage):
text = u'<h2>%s</h2>' % self.housing.title text = u'<h2>%s</h2>' % self.housing.title
@ -45,10 +46,13 @@ class HousingListWidgetItem(QListWidgetItem):
text += u'<br /><font color="#008800">%s</font>' % storage.get('notes', self.housing.fullid, default='') text += u'<br /><font color="#008800">%s</font>' % storage.get('notes', self.housing.fullid, default='')
self.setText(text) self.setText(text)
if self.housing.fullid in storage.get('bookmarks'): if not self.housing.fullid in storage.get('read'):
self.setBackground(QBrush(QColor(255, 224, 219)))
elif not self.housing.fullid in storage.get('read'):
self.setBackground(QBrush(QColor(219, 224, 255))) self.setBackground(QBrush(QColor(219, 224, 255)))
self.read = False
else:
self.read = True
if self.housing.fullid in storage.get('bookmarks'):
self.setBackground(QBrush(QColor(255, 224, 219)))
class MainWindow(QtMainWindow): class MainWindow(QtMainWindow):
def __init__(self, config, storage, weboob, parent=None): def __init__(self, config, storage, weboob, parent=None):