from util import qtpie
from util import misc as misc_utils
+import session
+
_moduleLogger = logging.getLogger(__name__)
class Dialpad(object):
- def __init__(self, app):
+ def __init__(self, app, session):
self._app = app
+ self._session = session
self._plus = self._generate_key_button("+", "")
self._entry = QtGui.QLineEdit()
def _on_sms_clicked(self, checked = False):
number = str(self._entry.text())
self._entry.clear()
- print "sms", number
+ self._session.draft.add_contact(number, [])
@misc_utils.log_exception(_moduleLogger)
def _on_call_clicked(self, checked = False):
number = str(self._entry.text())
self._entry.clear()
- print "call", number
+ self._session.draft.add_contact(number, [])
+ self._session.call()
class History(object):
HISTORY_COLUMNS = ["When", "What", "Number", "From"]
assert len(HISTORY_COLUMNS) == MAX_IDX
- def __init__(self, app):
+ def __init__(self, app, session):
self._selectedFilter = self.HISTORY_ITEM_TYPES[0]
self._app = app
+ self._session = session
+ self._session.historyUpdated.connect(self._on_history_updated)
self._typeSelection = QtGui.QComboBox()
self._typeSelection.addItems(self.HISTORY_ITEM_TYPES)
self._widget = QtGui.QWidget()
self._widget.setLayout(self._layout)
+ self._populate_items()
+
@property
def toplevel(self):
return self._widget
def refresh(self):
pass
+ def _populate_items(self):
+ pass
+
@misc_utils.log_exception(_moduleLogger)
def _on_filter_changed(self, newItem):
self._selectedFilter = str(newItem)
@misc_utils.log_exception(_moduleLogger)
+ def _on_history_updated(self):
+ self._populate_items()
+
+ @misc_utils.log_exception(_moduleLogger)
def _on_row_activated(self, index):
rowIndex = index.row()
+ #self._session.draft.add_contact(number, details)
class Messages(object):
ALL_STATUS = "Any"
MESSAGE_STATUSES = [UNREAD_STATUS, UNARCHIVED_STATUS, ALL_STATUS]
- def __init__(self, app):
+ def __init__(self, app, session):
self._selectedTypeFilter = self.ALL_TYPES
self._selectedStatusFilter = self.ALL_STATUS
self._app = app
+ self._session = session
+ self._session.messagesUpdated.connect(self._on_messages_updated)
self._typeSelection = QtGui.QComboBox()
self._typeSelection.addItems(self.MESSAGE_TYPES)
self._widget = QtGui.QWidget()
self._widget.setLayout(self._layout)
+ self._populate_items()
+
@property
def toplevel(self):
return self._widget
def refresh(self):
pass
+ def _populate_items(self):
+ pass
+
@misc_utils.log_exception(_moduleLogger)
def _on_type_filter_changed(self, newItem):
self._selectedTypeFilter = str(newItem)
self._selectedStatusFilter = str(newItem)
@misc_utils.log_exception(_moduleLogger)
+ def _on_messages_updated(self):
+ self._populate_items()
+
+ @misc_utils.log_exception(_moduleLogger)
def _on_row_activated(self, index):
rowIndex = index.row()
+ #self._session.draft.add_contact(number, details)
class Contacts(object):
- def __init__(self, app):
+ def __init__(self, app, session):
self._selectedFilter = ""
self._app = app
+ self._session = session
+ self._session.contactsUpdated.connect(self._on_contacts_updated)
self._listSelection = QtGui.QComboBox()
self._listSelection.addItems([])
self._widget = QtGui.QWidget()
self._widget.setLayout(self._layout)
+ self._populate_items()
+
@property
def toplevel(self):
return self._widget
def refresh(self):
pass
+ def _populate_items(self):
+ pass
+
@misc_utils.log_exception(_moduleLogger)
def _on_filter_changed(self, newItem):
self._selectedFilter = str(newItem)
@misc_utils.log_exception(_moduleLogger)
+ def _on_contacts_updated(self):
+ self._populate_items()
+
+ @misc_utils.log_exception(_moduleLogger)
def _on_row_activated(self, index):
rowIndex = index.row()
+ #self._session.draft.add_contact(number, details)
class MainWindow(object):
def __init__(self, parent, app):
self._fsContactsPath = os.path.join(constants._data_path_, "contacts")
self._app = app
+ self._session = session.Session()
self._errorDisplay = QErrorDisplay()
DelayedWidget(self._app)
for i in xrange(self.MAX_TABS)
]
+ for tab in self._tabsContents:
+ tab.disable()
self._tabWidget = QtGui.QTabWidget()
if maeqt.screen_orientation() == QtCore.Qt.Vertical:
def _initialize_tab(self, index):
assert index < self.MAX_TABS
if not self._tabsContents[index].has_child():
- self._tabsContents[index].set_child(self._TAB_CLASS[index](self._app))
+ self._tabsContents[index].set_child(
+ self._TAB_CLASS[index](self._app, self._session)
+ )
@misc_utils.log_exception(_moduleLogger)
def _on_login(self, checked = True):
recipientsChanged = QtCore.pyqtSignal()
def __init__(self):
- self._contacts = []
+ self._contacts = {}
def send(self, text):
assert 0 < len(self._contacts)
# self.clear()
def call(self):
- assert 0 < len(self._contacts)
+ assert len(self._contacts) == 1
self.calling.emit()
self.error.emit("Not Implemented")
# self.clear()
self.cancelling.emit()
self.error.emit("Not Implemented")
- def add_contact(self, contact):
+ def add_contact(self, contact, details):
assert contact not in self._contacts
- self._contacts.append(contact)
+ self._contacts[contact] = details
self.recipientsChanged.emit()
def remove_contact(self, contact):
assert contact not in self._contacts
- self._contacts.remove(contact)
+ del self._contacts[contact]
self.recipientsChanged.emit()
def get_contacts(self, contact):
return self._contacts
def clear(self):
- self._contacts = []
+ self._contacts = {}
self.recipientsChanged.emit()