Commit 9d48e59f authored by Dan Pascu's avatar Dan Pascu

Set contact URI type to SIP by default for new entries

parent d050dd7f
...@@ -3579,6 +3579,8 @@ class ContactURIModel(QAbstractTableModel): ...@@ -3579,6 +3579,8 @@ class ContactURIModel(QAbstractTableModel):
TypeColumn = 1 TypeColumn = 1
DefaultColumn = 2 DefaultColumn = 2
default_uri_type = 'SIP'
def __init__(self, parent=None): def __init__(self, parent=None):
super(ContactURIModel, self).__init__(parent) super(ContactURIModel, self).__init__(parent)
self.table_view = parent.addresses_table self.table_view = parent.addresses_table
...@@ -3629,7 +3631,7 @@ class ContactURIModel(QAbstractTableModel): ...@@ -3629,7 +3631,7 @@ class ContactURIModel(QAbstractTableModel):
item.uri = value item.uri = value
if item.ghost and value: if item.ghost and value:
item.ghost = False item.ghost = False
self._add_item(ContactURIItem(None, None, None, False, ghost=True)) self._add_item(ContactURIItem(None, None, self.default_uri_type, False, ghost=True))
elif column == ContactURIModel.TypeColumn: elif column == ContactURIModel.TypeColumn:
self.items[row].type = value or None self.items[row].type = value or None
elif column == ContactURIModel.DefaultColumn: elif column == ContactURIModel.DefaultColumn:
...@@ -3648,8 +3650,8 @@ class ContactURIModel(QAbstractTableModel): ...@@ -3648,8 +3650,8 @@ class ContactURIModel(QAbstractTableModel):
return super(ContactURIModel, self).headerData(section, orientation, role) return super(ContactURIModel, self).headerData(section, orientation, role)
def init_with_address(self, address=None): def init_with_address(self, address=None):
items = [ContactURIItem(None, address, None, False)] if address else [] items = [ContactURIItem(None, address, self.default_uri_type, False)] if address else []
items.append(ContactURIItem(None, None, None, False, ghost=True)) items.append(ContactURIItem(None, None, self.default_uri_type, False, ghost=True))
self.beginResetModel() self.beginResetModel()
self.items = items self.items = items
self.uri_types = [] self.uri_types = []
...@@ -3662,7 +3664,7 @@ class ContactURIModel(QAbstractTableModel): ...@@ -3662,7 +3664,7 @@ class ContactURIModel(QAbstractTableModel):
def init_with_contact(self, contact): def init_with_contact(self, contact):
items = [ContactURIItem(uri.id, uri.uri, uri.type, default=uri is contact.uris.default) for uri in contact.uris] items = [ContactURIItem(uri.id, uri.uri, uri.type, default=uri is contact.uris.default) for uri in contact.uris]
items.append(ContactURIItem(None, None, None, False, ghost=True)) items.append(ContactURIItem(None, None, self.default_uri_type, False, ghost=True))
self.beginResetModel() self.beginResetModel()
self.items = items self.items = items
self.uri_types = [uri.type for uri in contact.uris] self.uri_types = [uri.type for uri in contact.uris]
...@@ -3684,7 +3686,7 @@ class ContactURIModel(QAbstractTableModel): ...@@ -3684,7 +3686,7 @@ class ContactURIModel(QAbstractTableModel):
default_item = None # only care for the default URI if it was a newly added one, else use the one from the contact default_item = None # only care for the default URI if it was a newly added one, else use the one from the contact
items = [ContactURIItem(uri.id, uri.uri, uri.type, default=default_item is None and uri is contact.uris.default) for uri in contact.uris] items = [ContactURIItem(uri.id, uri.uri, uri.type, default=default_item is None and uri is contact.uris.default) for uri in contact.uris]
items.extend(added_items) items.extend(added_items)
items.append(ContactURIItem(None, None, None, False, ghost=True)) items.append(ContactURIItem(None, None, self.default_uri_type, False, ghost=True))
self.beginResetModel() self.beginResetModel()
self.items = items self.items = items
self.uri_types = [item.type for item in items] self.uri_types = [item.type for item in items]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment