def __init__(self, parent, app, session, errorLog):
qwrappers.WindowWrapper.__init__(self, parent, app)
self._session = session
+ self._session.messagesUpdated.connect(self._on_refresh_history)
+ self._session.historyUpdated.connect(self._on_refresh_history)
self._session.draft.recipientsChanged.connect(self._on_recipients_changed)
self._session.draft.sendingMessage.connect(self._on_op_started)
_moduleLogger.exception("Oh well")
def destroy(self):
+ self._session.messagesUpdated.disconnect(self._on_refresh_history)
+ self._session.historyUpdated.disconnect(self._on_refresh_history)
self._session.draft.recipientsChanged.disconnect(self._on_recipients_changed)
self._session.draft.sendingMessage.disconnect(self._on_op_started)
self._session.draft.calling.disconnect(self._on_op_started)
else:
self._smsButton.setEnabled(True)
+ def _update_history(self, cid):
+ draftContactsCount = self._session.draft.get_num_contacts()
+ if draftContactsCount != 1:
+ self._history.setVisible(False)
+ else:
+ description = self._session.draft.get_description(cid)
+
+ self._targetList.setVisible(False)
+ if description:
+ self._history.setText(description)
+ self._history.setVisible(True)
+ else:
+ self._history.setText("")
+ self._history.setVisible(False)
+
def _update_target_fields(self):
draftContactsCount = self._session.draft.get_num_contacts()
if draftContactsCount == 0:
elif draftContactsCount == 1:
(cid, ) = self._session.draft.get_contacts()
title = self._session.draft.get_title(cid)
- description = self._session.draft.get_description(cid)
numbers = self._session.draft.get_numbers(cid)
self._targetList.setVisible(False)
- if description:
- self._history.setText(description)
- self._history.setVisible(True)
- else:
- self._history.setText("")
- self._history.setVisible(False)
+ self._update_history(cid)
self._populate_number_selector(self._singleNumberSelector, cid, 0, numbers)
self._cids = [cid]
@QtCore.pyqtSlot()
@misc_utils.log_exception(_moduleLogger)
+ def _on_refresh_history(self):
+ draftContactsCount = self._session.draft.get_num_contacts()
+ if draftContactsCount != 1:
+ # Changing contact count will automatically refresh it
+ return
+ (cid, ) = self._session.draft.get_contacts()
+ self._update_history(cid)
+
+ @QtCore.pyqtSlot()
+ @misc_utils.log_exception(_moduleLogger)
def _on_recipients_changed(self):
with qui_utils.notify_error(self._app.errorLog):
self._update_target_fields()