can write notes on housings, display them in list
This commit is contained in:
parent
1d23f42ffa
commit
09d113b1be
4 changed files with 95 additions and 18 deletions
|
|
@ -52,7 +52,7 @@ class MainWindow(QtMainWindow):
|
|||
self.connect(self.ui.editQueryButton, SIGNAL('clicked()'), self.editQuery)
|
||||
self.connect(self.ui.removeQueryButton, SIGNAL('clicked()'), self.removeQuery)
|
||||
self.connect(self.ui.bookmarksButton, SIGNAL('clicked()'), self.displayBookmarks)
|
||||
self.connect(self.ui.housingsList, SIGNAL('itemClicked(QListWidgetItem*)'), self.housingSelected)
|
||||
self.connect(self.ui.housingsList, SIGNAL('currentItemChanged(QListWidgetItem*, QListWidgetItem*)'), self.housingSelected)
|
||||
self.connect(self.ui.previousButton, SIGNAL('clicked()'), self.previousClicked)
|
||||
self.connect(self.ui.nextButton, SIGNAL('clicked()'), self.nextClicked)
|
||||
self.connect(self.ui.bookmark, SIGNAL('stateChanged(int)'), self.bookmarkChanged)
|
||||
|
|
@ -66,6 +66,10 @@ class MainWindow(QtMainWindow):
|
|||
if len(self.config.get('queries')) == 0:
|
||||
self.addQuery()
|
||||
|
||||
def closeEvent(self, event):
|
||||
self.setHousing(None)
|
||||
QtMainWindow.closeEvent(self, event)
|
||||
|
||||
def backendsConfig(self):
|
||||
bckndcfg = BackendCfg(self.weboob, (ICapHousing,), self)
|
||||
if bckndcfg.run():
|
||||
|
|
@ -183,6 +187,21 @@ class MainWindow(QtMainWindow):
|
|||
self.process_bookmarks[id] = QtDo(self.weboob, self.addHousing)
|
||||
self.process_bookmarks[id].do('get_housing', _id, backends=backend_name)
|
||||
|
||||
def setHousingItemAttrs(self, item):
|
||||
housing = item.data(Qt.UserRole).toPyObject()
|
||||
|
||||
text = u'<h2>%s</h2>' % housing.title
|
||||
text += u'<i>%s — %sm² — %s%s (%s)</i>' % (housing.date.strftime('%Y-%m-%d') if housing.date else 'Unknown',
|
||||
housing.area, housing.cost, housing.currency, housing.backend)
|
||||
text += u'<br />%s' % housing.text
|
||||
text += u'<br /><font color="#008800">%s</font>' % self.storage.get('notes', housing.fullid, default='')
|
||||
item.setText(text)
|
||||
|
||||
if housing.fullid in self.storage.get('bookmarks'):
|
||||
item.setBackground(QBrush(QColor(255, 224, 219)))
|
||||
elif not housing.fullid in self.storage.get('read'):
|
||||
item.setBackground(QBrush(QColor(219, 224, 255)))
|
||||
|
||||
def addHousing(self, backend, housing):
|
||||
if not backend:
|
||||
self.ui.queriesList.setEnabled(True)
|
||||
|
|
@ -191,14 +210,8 @@ class MainWindow(QtMainWindow):
|
|||
return
|
||||
|
||||
item = QListWidgetItem()
|
||||
item.setText(u'<h2>%s</h2><i>%s — %sm² — %s%s (%s)</i><br />%s' % (housing.title, housing.date.strftime('%Y-%m-%d') if housing.date else 'Unknown',
|
||||
housing.area, housing.cost, housing.currency, housing.backend, housing.text))
|
||||
item.setData(Qt.UserRole, housing)
|
||||
|
||||
if housing.fullid in self.storage.get('bookmarks'):
|
||||
item.setBackground(QBrush(QColor(255, 224, 219)))
|
||||
elif not housing.fullid in self.storage.get('read'):
|
||||
item.setBackground(QBrush(QColor(219, 224, 255)))
|
||||
self.setHousingItemAttrs(item)
|
||||
|
||||
if housing.photos is NotLoaded:
|
||||
process = QtDo(self.weboob, lambda b, c: self.setPhoto(c, item))
|
||||
|
|
@ -216,7 +229,7 @@ class MainWindow(QtMainWindow):
|
|||
if housing.fullid in self.process_bookmarks:
|
||||
self.process_bookmarks.pop(housing.fullid)
|
||||
|
||||
def housingSelected(self, item):
|
||||
def housingSelected(self, item, prev):
|
||||
housing = item.data(Qt.UserRole).toPyObject()
|
||||
self.ui.queriesFrame.setEnabled(False)
|
||||
|
||||
|
|
@ -228,6 +241,9 @@ class MainWindow(QtMainWindow):
|
|||
|
||||
self.setHousing(housing)
|
||||
|
||||
if prev:
|
||||
self.setHousingItemAttrs(prev)
|
||||
|
||||
self.process = QtDo(self.weboob, self.gotHousing)
|
||||
self.process.do('fillobj', housing, backends=housing.backend)
|
||||
|
||||
|
|
@ -257,8 +273,15 @@ class MainWindow(QtMainWindow):
|
|||
|
||||
|
||||
def setHousing(self, housing, nottext='Loading...'):
|
||||
if self.housing is not None:
|
||||
self.saveNotes()
|
||||
|
||||
self.housing = housing
|
||||
|
||||
if self.housing is None:
|
||||
self.ui.housingFrame.hide()
|
||||
return
|
||||
|
||||
self.ui.housingFrame.show()
|
||||
|
||||
self.display_photo()
|
||||
|
|
@ -278,6 +301,8 @@ class MainWindow(QtMainWindow):
|
|||
else:
|
||||
self.ui.descriptionEdit.setText(nottext)
|
||||
|
||||
self.ui.notesEdit.setText(self.storage.get('notes', housing.fullid, default=''))
|
||||
|
||||
while self.ui.detailsFrame.layout().count() > 0:
|
||||
child = self.ui.detailsFrame.layout().takeAt(0)
|
||||
child.widget().hide()
|
||||
|
|
@ -306,6 +331,12 @@ class MainWindow(QtMainWindow):
|
|||
self.storage.set('bookmarks', list(bookmarks))
|
||||
self.storage.save()
|
||||
|
||||
def saveNotes(self):
|
||||
if not self.housing:
|
||||
return
|
||||
self.storage.set('notes', self.housing.fullid, unicode(self.ui.notesEdit.toPlainText()))
|
||||
self.storage.save()
|
||||
|
||||
def previousClicked(self):
|
||||
if not self.housing.photos or len(self.housing.photos) == 0:
|
||||
return
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue