Front-end support for partial history updates
authorEd Page <eopage@byu.net>
Fri, 18 Mar 2011 00:40:48 +0000 (19:40 -0500)
committerEd Page <eopage@byu.net>
Tue, 19 Apr 2011 23:49:27 +0000 (18:49 -0500)
src/gv_views.py
src/session.py

index 18251df..f57995c 100644 (file)
@@ -260,7 +260,12 @@ class History(object):
        FROM_IDX = 1
        MAX_IDX = 2
 
-       HISTORY_ITEM_TYPES = ["Received", "Missed", "Placed", "All"]
+       HISTORY_RECEIVED = "Received"
+       HISTORY_MISSED = "Missed"
+       HISTORY_PLACED = "Placed"
+       HISTORY_ALL = "All"
+
+       HISTORY_ITEM_TYPES = [HISTORY_RECEIVED, HISTORY_MISSED, HISTORY_PLACED, HISTORY_ALL]
        HISTORY_COLUMNS = ["Details", "From"]
        assert len(HISTORY_COLUMNS) == MAX_IDX
 
@@ -343,7 +348,18 @@ class History(object):
 
        def refresh(self, force=True):
                self._itemView.setFocus(QtCore.Qt.OtherFocusReason)
-               self._session.update_history(force)
+
+               if self._selectedFilter == self.HISTORY_RECEIVED:
+                       self._session.update_history(self._session.HISTORY_RECEIVED, force)
+               elif self._selectedFilter == self.HISTORY_MISSED:
+                       self._session.update_history(self._session.HISTORY_MISSED, force)
+               elif self._selectedFilter == self.HISTORY_PLACED:
+                       self._session.update_history(self._session.HISTORY_PLACED, force)
+               elif self._selectedFilter == self.HISTORY_ALL:
+                       self._session.update_history(self._session.HISTORY_ALL, force)
+               else:
+                       assert False, "How did we get here?"
+
                if self._app.notifyOnMissed and self._app.alarmHandler.alarmType == self._app.alarmHandler.ALARM_BACKGROUND:
                        self._app.ledHandler.off()
 
index 7061f09..6bf5888 100644 (file)
@@ -220,6 +220,11 @@ class Session(QtCore.QObject):
        MESSAGE_VOICEMAILS = "Voicemail"
        MESSAGE_ALL = "All"
 
+       HISTORY_RECEIVED = "Received"
+       HISTORY_MISSED = "Missed"
+       HISTORY_PLACED = "Placed"
+       HISTORY_ALL = "All"
+
        _OLDEST_COMPATIBLE_FORMAT_VERSION = misc_utils.parse_version("1.3.0")
 
        _LOGGEDOUT_TIME = -1
@@ -335,10 +340,10 @@ class Session(QtCore.QObject):
        def get_when_messages_updated(self):
                return self._messageUpdateTime
 
-       def update_history(self, force = True):
+       def update_history(self, historyType, force = True):
                if not force and self._history:
                        return
-               le = concurrent.AsyncLinearExecution(self._pool, self._update_history), (), {}
+               le = concurrent.AsyncLinearExecution(self._pool, self._update_history), (historyType, ), {}
                self._perform_op_while_loggedin(le)
 
        def get_history(self):
@@ -689,13 +694,13 @@ class Session(QtCore.QObject):
                self.messagesUpdated.emit()
                self._alert_on_messages(self._messages)
 
-       def _update_history(self):
+       def _update_history(self, historyType):
                try:
                        assert self.state == self.LOGGEDIN_STATE, "History requires being logged in (currently %s" % self.state
                        with qui_utils.notify_busy(self._errorLog, "Updating History"):
                                self._history = yield (
                                        self._backend[0].get_call_history,
-                                       (self._backend[0].HISTORY_ALL, ),
+                                       (historyType, ),
                                        {},
                                )
                except Exception, e: