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.editQueryButton, SIGNAL('clicked()'), self.editQuery)
|
||||||
self.connect(self.ui.removeQueryButton, SIGNAL('clicked()'), self.removeQuery)
|
self.connect(self.ui.removeQueryButton, SIGNAL('clicked()'), self.removeQuery)
|
||||||
self.connect(self.ui.bookmarksButton, SIGNAL('clicked()'), self.displayBookmarks)
|
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.previousButton, SIGNAL('clicked()'), self.previousClicked)
|
||||||
self.connect(self.ui.nextButton, SIGNAL('clicked()'), self.nextClicked)
|
self.connect(self.ui.nextButton, SIGNAL('clicked()'), self.nextClicked)
|
||||||
self.connect(self.ui.bookmark, SIGNAL('stateChanged(int)'), self.bookmarkChanged)
|
self.connect(self.ui.bookmark, SIGNAL('stateChanged(int)'), self.bookmarkChanged)
|
||||||
|
|
@ -66,6 +66,10 @@ class MainWindow(QtMainWindow):
|
||||||
if len(self.config.get('queries')) == 0:
|
if len(self.config.get('queries')) == 0:
|
||||||
self.addQuery()
|
self.addQuery()
|
||||||
|
|
||||||
|
def closeEvent(self, event):
|
||||||
|
self.setHousing(None)
|
||||||
|
QtMainWindow.closeEvent(self, event)
|
||||||
|
|
||||||
def backendsConfig(self):
|
def backendsConfig(self):
|
||||||
bckndcfg = BackendCfg(self.weboob, (ICapHousing,), self)
|
bckndcfg = BackendCfg(self.weboob, (ICapHousing,), self)
|
||||||
if bckndcfg.run():
|
if bckndcfg.run():
|
||||||
|
|
@ -183,6 +187,21 @@ class MainWindow(QtMainWindow):
|
||||||
self.process_bookmarks[id] = QtDo(self.weboob, self.addHousing)
|
self.process_bookmarks[id] = QtDo(self.weboob, self.addHousing)
|
||||||
self.process_bookmarks[id].do('get_housing', _id, backends=backend_name)
|
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):
|
def addHousing(self, backend, housing):
|
||||||
if not backend:
|
if not backend:
|
||||||
self.ui.queriesList.setEnabled(True)
|
self.ui.queriesList.setEnabled(True)
|
||||||
|
|
@ -191,14 +210,8 @@ class MainWindow(QtMainWindow):
|
||||||
return
|
return
|
||||||
|
|
||||||
item = QListWidgetItem()
|
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)
|
item.setData(Qt.UserRole, housing)
|
||||||
|
self.setHousingItemAttrs(item)
|
||||||
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)))
|
|
||||||
|
|
||||||
if housing.photos is NotLoaded:
|
if housing.photos is NotLoaded:
|
||||||
process = QtDo(self.weboob, lambda b, c: self.setPhoto(c, item))
|
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:
|
if housing.fullid in self.process_bookmarks:
|
||||||
self.process_bookmarks.pop(housing.fullid)
|
self.process_bookmarks.pop(housing.fullid)
|
||||||
|
|
||||||
def housingSelected(self, item):
|
def housingSelected(self, item, prev):
|
||||||
housing = item.data(Qt.UserRole).toPyObject()
|
housing = item.data(Qt.UserRole).toPyObject()
|
||||||
self.ui.queriesFrame.setEnabled(False)
|
self.ui.queriesFrame.setEnabled(False)
|
||||||
|
|
||||||
|
|
@ -228,6 +241,9 @@ class MainWindow(QtMainWindow):
|
||||||
|
|
||||||
self.setHousing(housing)
|
self.setHousing(housing)
|
||||||
|
|
||||||
|
if prev:
|
||||||
|
self.setHousingItemAttrs(prev)
|
||||||
|
|
||||||
self.process = QtDo(self.weboob, self.gotHousing)
|
self.process = QtDo(self.weboob, self.gotHousing)
|
||||||
self.process.do('fillobj', housing, backends=housing.backend)
|
self.process.do('fillobj', housing, backends=housing.backend)
|
||||||
|
|
||||||
|
|
@ -257,8 +273,15 @@ class MainWindow(QtMainWindow):
|
||||||
|
|
||||||
|
|
||||||
def setHousing(self, housing, nottext='Loading...'):
|
def setHousing(self, housing, nottext='Loading...'):
|
||||||
|
if self.housing is not None:
|
||||||
|
self.saveNotes()
|
||||||
|
|
||||||
self.housing = housing
|
self.housing = housing
|
||||||
|
|
||||||
|
if self.housing is None:
|
||||||
|
self.ui.housingFrame.hide()
|
||||||
|
return
|
||||||
|
|
||||||
self.ui.housingFrame.show()
|
self.ui.housingFrame.show()
|
||||||
|
|
||||||
self.display_photo()
|
self.display_photo()
|
||||||
|
|
@ -278,6 +301,8 @@ class MainWindow(QtMainWindow):
|
||||||
else:
|
else:
|
||||||
self.ui.descriptionEdit.setText(nottext)
|
self.ui.descriptionEdit.setText(nottext)
|
||||||
|
|
||||||
|
self.ui.notesEdit.setText(self.storage.get('notes', housing.fullid, default=''))
|
||||||
|
|
||||||
while self.ui.detailsFrame.layout().count() > 0:
|
while self.ui.detailsFrame.layout().count() > 0:
|
||||||
child = self.ui.detailsFrame.layout().takeAt(0)
|
child = self.ui.detailsFrame.layout().takeAt(0)
|
||||||
child.widget().hide()
|
child.widget().hide()
|
||||||
|
|
@ -306,6 +331,12 @@ class MainWindow(QtMainWindow):
|
||||||
self.storage.set('bookmarks', list(bookmarks))
|
self.storage.set('bookmarks', list(bookmarks))
|
||||||
self.storage.save()
|
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):
|
def previousClicked(self):
|
||||||
if not self.housing.photos or len(self.housing.photos) == 0:
|
if not self.housing.photos or len(self.housing.photos) == 0:
|
||||||
return
|
return
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ class QFlatBoob(QtApplication):
|
||||||
DESCRIPTION = 'Qt application to find housings.'
|
DESCRIPTION = 'Qt application to find housings.'
|
||||||
CAPS = ICapHousing
|
CAPS = ICapHousing
|
||||||
CONFIG = {'queries': {}}
|
CONFIG = {'queries': {}}
|
||||||
STORAGE = {'bookmarks': [], 'read': []}
|
STORAGE = {'bookmarks': [], 'read': [], 'notes': {}}
|
||||||
|
|
||||||
def main(self, argv):
|
def main(self, argv):
|
||||||
self.load_backends(ICapHousing)
|
self.load_backends(ICapHousing)
|
||||||
|
|
|
||||||
|
|
@ -70,6 +70,9 @@
|
||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="editTriggers">
|
||||||
|
<set>QAbstractItemView::NoEditTriggers</set>
|
||||||
|
</property>
|
||||||
<property name="iconSize">
|
<property name="iconSize">
|
||||||
<size>
|
<size>
|
||||||
<width>128</width>
|
<width>128</width>
|
||||||
|
|
@ -106,7 +109,7 @@
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QSplitter" name="splitter_4">
|
<widget class="QSplitter" name="splitter_5">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Vertical</enum>
|
<enum>Qt::Vertical</enum>
|
||||||
</property>
|
</property>
|
||||||
|
|
@ -406,17 +409,36 @@
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QSplitter" name="splitter_3">
|
<widget class="QSplitter" name="splitter_4">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QTextEdit" name="descriptionEdit">
|
<widget class="QSplitter" name="splitter_3">
|
||||||
<property name="sizePolicy">
|
<property name="orientation">
|
||||||
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
|
<enum>Qt::Vertical</enum>
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>50</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
</property>
|
||||||
|
<widget class="QTextEdit" name="descriptionEdit">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>50</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="readOnly">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QTextEdit" name="notesEdit">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Expanding" vsizetype="Maximum">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="acceptRichText">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QFrame" name="detailsFrame">
|
<widget class="QFrame" name="detailsFrame">
|
||||||
<property name="frameShape">
|
<property name="frameShape">
|
||||||
|
|
@ -473,6 +495,18 @@
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
|
<tabstops>
|
||||||
|
<tabstop>addQueryButton</tabstop>
|
||||||
|
<tabstop>queriesList</tabstop>
|
||||||
|
<tabstop>editQueryButton</tabstop>
|
||||||
|
<tabstop>removeQueryButton</tabstop>
|
||||||
|
<tabstop>housingsList</tabstop>
|
||||||
|
<tabstop>bookmarksButton</tabstop>
|
||||||
|
<tabstop>bookmark</tabstop>
|
||||||
|
<tabstop>previousButton</tabstop>
|
||||||
|
<tabstop>nextButton</tabstop>
|
||||||
|
<tabstop>descriptionEdit</tabstop>
|
||||||
|
</tabstops>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
</ui>
|
</ui>
|
||||||
|
|
|
||||||
|
|
@ -261,6 +261,18 @@
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
<tabstops>
|
||||||
|
<tabstop>nameEdit</tabstop>
|
||||||
|
<tabstop>cityEdit</tabstop>
|
||||||
|
<tabstop>resultsList</tabstop>
|
||||||
|
<tabstop>citiesList</tabstop>
|
||||||
|
<tabstop>nbRooms</tabstop>
|
||||||
|
<tabstop>areaMin</tabstop>
|
||||||
|
<tabstop>areaMax</tabstop>
|
||||||
|
<tabstop>costMin</tabstop>
|
||||||
|
<tabstop>costMax</tabstop>
|
||||||
|
<tabstop>buttonBox</tabstop>
|
||||||
|
</tabstops>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections>
|
<connections>
|
||||||
<connection>
|
<connection>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue