Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vmj-qt
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
vmj-qt
Commits
b089bcc2
Commit
b089bcc2
authored
May 31, 2013
by
Dan Pascu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move contact when its name changes to keep contacts sorted
parent
ffb0f317
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
1 deletion
+25
-1
contacts.py
blink/contacts.py
+25
-1
No files found.
blink/contacts.py
View file @
b089bcc2
...
...
@@ -1750,7 +1750,15 @@ class ContactModel(QAbstractListModel):
icon_manager
.
remove
(
contact
.
settings
.
id
)
def
_NH_BlinkContactDidChange
(
self
,
notification
):
index
=
self
.
index
(
self
.
items
.
index
(
notification
.
sender
))
contact
=
notification
.
sender
position
=
self
.
items
.
index
(
contact
)
move_point
=
self
.
_find_contact_move_point
(
contact
)
if
move_point
is
not
None
:
self
.
beginMoveRows
(
QModelIndex
(),
position
,
position
,
QModelIndex
(),
move_point
)
del
self
.
items
[
position
]
self
.
items
.
insert
(
self
.
_find_contact_insertion_point
(
contact
),
contact
)
self
.
endMoveRows
()
index
=
self
.
index
(
self
.
items
.
index
(
contact
))
self
.
dataChanged
.
emit
(
index
,
index
)
def
_NH_SIPAccountManagerDidStart
(
self
,
notification
):
...
...
@@ -1821,6 +1829,22 @@ class ContactModel(QAbstractListModel):
[
item
.
save
()
for
item
in
save
]
[
item
.
delete
()
for
item
in
delete
]
def
_find_contact_move_point
(
self
,
contact
):
position
=
self
.
items
.
index
(
contact
)
prev_item
=
self
.
items
[
position
-
1
]
if
position
>
0
else
None
next_item
=
self
.
items
[
position
+
1
]
if
position
+
1
<
len
(
self
.
items
)
else
None
prev_ok
=
prev_item
is
None
or
isinstance
(
prev_item
,
Group
)
or
prev_item
.
name
<=
contact
.
name
next_ok
=
next_item
is
None
or
isinstance
(
next_item
,
Group
)
or
next_item
.
name
>=
contact
.
name
if
prev_ok
and
next_ok
:
return
None
for
position
in
xrange
(
self
.
items
.
index
(
contact
.
group
)
+
1
,
len
(
self
.
items
)):
item
=
self
.
items
[
position
]
if
isinstance
(
item
,
Group
)
or
item
.
name
>
contact
.
name
:
break
else
:
position
=
len
(
self
.
items
)
return
position
def
_find_contact_insertion_point
(
self
,
contact
):
for
position
in
xrange
(
self
.
items
.
index
(
contact
.
group
)
+
1
,
len
(
self
.
items
)):
item
=
self
.
items
[
position
]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment