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
ea0c1df8
Commit
ea0c1df8
authored
Jun 18, 2013
by
Dan Pascu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed session model to use UserRole instead of DisplayRole for items
parent
f0baaccf
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
18 deletions
+26
-18
mainwindow.py
blink/mainwindow.py
+3
-3
sessions.py
blink/sessions.py
+23
-15
No files found.
blink/mainwindow.py
View file @
ea0c1df8
...
@@ -420,7 +420,7 @@ class MainWindow(base_class, ui_class):
...
@@ -420,7 +420,7 @@ class MainWindow(base_class, ui_class):
session_manager
.
start_call
(
name
,
address
,
contact
=
contact
,
account
=
BonjourAccount
()
if
isinstance
(
contact
.
settings
,
BonjourNeighbour
)
else
None
)
session_manager
.
start_call
(
name
,
address
,
contact
=
contact
,
account
=
BonjourAccount
()
if
isinstance
(
contact
.
settings
,
BonjourNeighbour
)
else
None
)
def
_SH_BreakConference
(
self
):
def
_SH_BreakConference
(
self
):
active_session
=
self
.
session_list
.
selectionModel
()
.
selectedIndexes
()[
0
]
.
data
()
active_session
=
self
.
session_list
.
selectionModel
()
.
selectedIndexes
()[
0
]
.
data
(
Qt
.
UserRole
)
self
.
session_model
.
breakConference
(
active_session
.
conference
)
self
.
session_model
.
breakConference
(
active_session
.
conference
)
def
_SH_ContactListSelectionChanged
(
self
,
selected
,
deselected
):
def
_SH_ContactListSelectionChanged
(
self
,
selected
,
deselected
):
...
@@ -521,7 +521,7 @@ class MainWindow(base_class, ui_class):
...
@@ -521,7 +521,7 @@ class MainWindow(base_class, ui_class):
def
_SH_SessionListSelectionChanged
(
self
,
selected
,
deselected
):
def
_SH_SessionListSelectionChanged
(
self
,
selected
,
deselected
):
selected_indexes
=
selected
.
indexes
()
selected_indexes
=
selected
.
indexes
()
active_session
=
selected_indexes
[
0
]
.
data
()
if
selected_indexes
else
Null
active_session
=
selected_indexes
[
0
]
.
data
(
Qt
.
UserRole
)
if
selected_indexes
else
Null
if
active_session
.
conference
:
if
active_session
.
conference
:
self
.
conference_button
.
setEnabled
(
True
)
self
.
conference_button
.
setEnabled
(
True
)
self
.
conference_button
.
setChecked
(
True
)
self
.
conference_button
.
setChecked
(
True
)
...
@@ -539,7 +539,7 @@ class MainWindow(base_class, ui_class):
...
@@ -539,7 +539,7 @@ class MainWindow(base_class, ui_class):
self
.
active_sessions_label
.
setVisible
(
any
(
active_sessions
))
self
.
active_sessions_label
.
setVisible
(
any
(
active_sessions
))
self
.
hangup_all_button
.
setEnabled
(
any
(
active_sessions
))
self
.
hangup_all_button
.
setEnabled
(
any
(
active_sessions
))
selected_indexes
=
self
.
session_list
.
selectionModel
()
.
selectedIndexes
()
selected_indexes
=
self
.
session_list
.
selectionModel
()
.
selectedIndexes
()
active_session
=
selected_indexes
[
0
]
.
data
()
if
selected_indexes
else
Null
active_session
=
selected_indexes
[
0
]
.
data
(
Qt
.
UserRole
)
if
selected_indexes
else
Null
if
active_session
.
conference
:
if
active_session
.
conference
:
self
.
conference_button
.
setEnabled
(
True
)
self
.
conference_button
.
setEnabled
(
True
)
self
.
conference_button
.
setChecked
(
True
)
self
.
conference_button
.
setChecked
(
True
)
...
...
blink/sessions.py
View file @
ea0c1df8
...
@@ -93,6 +93,9 @@ class SessionItem(QObject):
...
@@ -93,6 +93,9 @@ class SessionItem(QObject):
def
__reduce__
(
self
):
def
__reduce__
(
self
):
return
(
self
.
__class__
,
(
self
.
name
,
self
.
uri
,
Null
,
Null
,
Null
),
None
)
return
(
self
.
__class__
,
(
self
.
name
,
self
.
uri
,
Null
,
Null
,
Null
),
None
)
def
__unicode__
(
self
):
return
unicode
(
self
.
name
)
@
property
@
property
def
pending_removal
(
self
):
def
pending_removal
(
self
):
return
self
.
audio_stream
is
None
and
self
.
video_stream
is
None
return
self
.
audio_stream
is
None
and
self
.
video_stream
is
None
...
@@ -932,7 +935,7 @@ class SessionDelegate(QStyledItemDelegate):
...
@@ -932,7 +935,7 @@ class SessionDelegate(QStyledItemDelegate):
super
(
SessionDelegate
,
self
)
.
__init__
(
parent
)
super
(
SessionDelegate
,
self
)
.
__init__
(
parent
)
def
createEditor
(
self
,
parent
,
options
,
index
):
def
createEditor
(
self
,
parent
,
options
,
index
):
session
=
index
.
model
()
.
data
(
index
,
Qt
.
Display
Role
)
session
=
index
.
data
(
Qt
.
User
Role
)
session
.
widget
=
SessionWidget
(
session
,
parent
)
session
.
widget
=
SessionWidget
(
session
,
parent
)
session
.
widget
.
hold_button
.
clicked
.
connect
(
partial
(
self
.
_SH_HoldButtonClicked
,
session
))
session
.
widget
.
hold_button
.
clicked
.
connect
(
partial
(
self
.
_SH_HoldButtonClicked
,
session
))
return
session
.
widget
return
session
.
widget
...
@@ -941,7 +944,7 @@ class SessionDelegate(QStyledItemDelegate):
...
@@ -941,7 +944,7 @@ class SessionDelegate(QStyledItemDelegate):
editor
.
setGeometry
(
option
.
rect
)
editor
.
setGeometry
(
option
.
rect
)
def
paint
(
self
,
painter
,
option
,
index
):
def
paint
(
self
,
painter
,
option
,
index
):
session
=
index
.
model
()
.
data
(
index
,
Qt
.
Display
Role
)
session
=
index
.
data
(
Qt
.
User
Role
)
if
session
.
widget
.
size
()
!=
option
.
rect
.
size
():
if
session
.
widget
.
size
()
!=
option
.
rect
.
size
():
# For some reason updateEditorGeometry only receives the peak value
# For some reason updateEditorGeometry only receives the peak value
# of the size that the widget ever had, so it will never shrink it.
# of the size that the widget ever had, so it will never shrink it.
...
@@ -987,9 +990,14 @@ class SessionModel(QAbstractListModel):
...
@@ -987,9 +990,14 @@ class SessionModel(QAbstractListModel):
return
len
(
self
.
sessions
)
return
len
(
self
.
sessions
)
def
data
(
self
,
index
,
role
=
Qt
.
DisplayRole
):
def
data
(
self
,
index
,
role
=
Qt
.
DisplayRole
):
if
not
index
.
isValid
()
or
role
!=
Qt
.
DisplayRole
:
if
not
index
.
isValid
():
return
None
return
None
return
self
.
sessions
[
index
.
row
()]
item
=
self
.
sessions
[
index
.
row
()]
if
role
==
Qt
.
UserRole
:
return
item
elif
role
==
Qt
.
DisplayRole
:
return
unicode
(
item
)
return
None
def
supportedDropActions
(
self
):
def
supportedDropActions
(
self
):
return
Qt
.
CopyAction
|
Qt
.
MoveAction
return
Qt
.
CopyAction
|
Qt
.
MoveAction
...
@@ -1214,7 +1222,7 @@ class SessionModel(QAbstractListModel):
...
@@ -1214,7 +1222,7 @@ class SessionModel(QAbstractListModel):
selection_mode
=
session_list
.
selectionMode
()
selection_mode
=
session_list
.
selectionMode
()
session_list
.
setSelectionMode
(
session_list
.
NoSelection
)
session_list
.
setSelectionMode
(
session_list
.
NoSelection
)
selected
=
any
(
session
.
widget
.
selected
for
session
in
sessions
)
selected
=
any
(
session
.
widget
.
selected
for
session
in
sessions
)
selected_session
=
sel
f
.
data
(
selection_model
.
selectedIndexes
()[
0
]
)
if
selected
else
None
selected_session
=
sel
ection_model
.
selectedIndexes
()[
0
]
.
data
(
Qt
.
UserRole
)
if
selected
else
None
for
session
in
sessions
:
for
session
in
sessions
:
self
.
_remove_session
(
session
)
self
.
_remove_session
(
session
)
self
.
beginInsertRows
(
QModelIndex
(),
0
,
len
(
sessions
)
-
1
)
self
.
beginInsertRows
(
QModelIndex
(),
0
,
len
(
sessions
)
-
1
)
...
@@ -1297,9 +1305,9 @@ class SessionListView(QListView):
...
@@ -1297,9 +1305,9 @@ class SessionListView(QListView):
current_index
=
selection_model
.
currentIndex
()
current_index
=
selection_model
.
currentIndex
()
if
current_index
.
isValid
():
if
current_index
.
isValid
():
step
=
1
if
event
.
key
()
==
Qt
.
Key_Down
else
-
1
step
=
1
if
event
.
key
()
==
Qt
.
Key_Down
else
-
1
conference
=
current_index
.
data
()
.
conference
conference
=
current_index
.
data
(
Qt
.
UserRole
)
.
conference
new_index
=
current_index
.
sibling
(
current_index
.
row
()
+
step
,
current_index
.
column
())
new_index
=
current_index
.
sibling
(
current_index
.
row
()
+
step
,
current_index
.
column
())
while
conference
is
not
None
and
new_index
.
isValid
()
and
new_index
.
data
()
.
conference
is
conference
:
while
conference
is
not
None
and
new_index
.
isValid
()
and
new_index
.
data
(
Qt
.
UserRole
)
.
conference
is
conference
:
new_index
=
new_index
.
sibling
(
new_index
.
row
()
+
step
,
new_index
.
column
())
new_index
=
new_index
.
sibling
(
new_index
.
row
()
+
step
,
new_index
.
column
())
if
new_index
.
isValid
():
if
new_index
.
isValid
():
selection_model
.
select
(
new_index
,
selection_model
.
ClearAndSelect
)
selection_model
.
select
(
new_index
,
selection_model
.
ClearAndSelect
)
...
@@ -1340,7 +1348,7 @@ class SessionListView(QListView):
...
@@ -1340,7 +1348,7 @@ class SessionListView(QListView):
def
startDrag
(
self
,
supported_actions
):
def
startDrag
(
self
,
supported_actions
):
if
self
.
_pressed_index
is
not
None
and
self
.
_pressed_index
.
isValid
():
if
self
.
_pressed_index
is
not
None
and
self
.
_pressed_index
.
isValid
():
model
=
self
.
model
()
model
=
self
.
model
()
self
.
dragged_session
=
model
.
data
(
self
.
_pressed_index
)
self
.
dragged_session
=
self
.
_pressed_index
.
data
(
Qt
.
UserRole
)
rect
=
self
.
visualRect
(
self
.
_pressed_index
)
rect
=
self
.
visualRect
(
self
.
_pressed_index
)
rect
.
adjust
(
1
,
1
,
-
1
,
-
1
)
rect
.
adjust
(
1
,
1
,
-
1
,
-
1
)
pixmap
=
QPixmap
(
rect
.
size
())
pixmap
=
QPixmap
(
rect
.
size
())
...
@@ -1391,7 +1399,7 @@ class SessionListView(QListView):
...
@@ -1391,7 +1399,7 @@ class SessionListView(QListView):
if
event
.
provides
(
mime_type
):
if
event
.
provides
(
mime_type
):
index
=
self
.
indexAt
(
event
.
pos
())
index
=
self
.
indexAt
(
event
.
pos
())
rect
=
self
.
visualRect
(
index
)
rect
=
self
.
visualRect
(
index
)
session
=
self
.
model
()
.
data
(
index
)
session
=
index
.
data
(
Qt
.
UserRole
)
name
=
mime_type
.
replace
(
'/'
,
' '
)
.
replace
(
'-'
,
' '
)
.
title
()
.
replace
(
' '
,
''
)
name
=
mime_type
.
replace
(
'/'
,
' '
)
.
replace
(
'-'
,
' '
)
.
title
()
.
replace
(
' '
,
''
)
handler
=
getattr
(
self
,
'_DH_
%
s'
%
name
)
handler
=
getattr
(
self
,
'_DH_
%
s'
%
name
)
handler
(
event
,
index
,
rect
,
session
)
handler
(
event
,
index
,
rect
,
session
)
...
@@ -1461,24 +1469,24 @@ class SessionListView(QListView):
...
@@ -1461,24 +1469,24 @@ class SessionListView(QListView):
session
.
widget
.
drop_indicator
=
True
session
.
widget
.
drop_indicator
=
True
def
_SH_HangupShortcutActivated
(
self
):
def
_SH_HangupShortcutActivated
(
self
):
session
=
self
.
model
()
.
data
(
self
.
selectedIndexes
()[
0
]
)
session
=
self
.
selectedIndexes
()[
0
]
.
data
(
Qt
.
UserRole
)
if
session
.
conference
is
None
:
if
session
.
conference
is
None
:
session
.
widget
.
hangup_button
.
click
()
session
.
widget
.
hangup_button
.
click
()
def
_SH_HoldShortcutActivated
(
self
):
def
_SH_HoldShortcutActivated
(
self
):
session
=
self
.
model
()
.
data
(
self
.
selectedIndexes
()[
0
]
)
session
=
self
.
selectedIndexes
()[
0
]
.
data
(
Qt
.
UserRole
)
if
session
.
conference
is
None
:
if
session
.
conference
is
None
:
session
.
widget
.
hold_button
.
click
()
session
.
widget
.
hold_button
.
click
()
def
_SH_SelectionModelSelectionChanged
(
self
,
selected
,
deselected
):
def
_SH_SelectionModelSelectionChanged
(
self
,
selected
,
deselected
):
model
=
self
.
model
()
model
=
self
.
model
()
for
session
in
(
model
.
data
(
index
)
for
index
in
deselected
.
indexes
()):
for
session
in
(
index
.
data
(
Qt
.
UserRole
)
for
index
in
deselected
.
indexes
()):
if
session
.
conference
is
not
None
:
if
session
.
conference
is
not
None
:
for
sibling
in
session
.
conference
.
sessions
:
for
sibling
in
session
.
conference
.
sessions
:
sibling
.
widget
.
selected
=
False
sibling
.
widget
.
selected
=
False
else
:
else
:
session
.
widget
.
selected
=
False
session
.
widget
.
selected
=
False
for
session
in
(
model
.
data
(
index
)
for
index
in
selected
.
indexes
()):
for
session
in
(
index
.
data
(
Qt
.
UserRole
)
for
index
in
selected
.
indexes
()):
if
session
.
conference
is
not
None
:
if
session
.
conference
is
not
None
:
for
sibling
in
session
.
conference
.
sessions
:
for
sibling
in
session
.
conference
.
sessions
:
sibling
.
widget
.
selected
=
True
sibling
.
widget
.
selected
=
True
...
@@ -1988,8 +1996,8 @@ class SessionManager(object):
...
@@ -1988,8 +1996,8 @@ class SessionManager(object):
return
return
selected_indexes
=
selected
.
indexes
()
selected_indexes
=
selected
.
indexes
()
deselected_indexes
=
deselected
.
indexes
()
deselected_indexes
=
deselected
.
indexes
()
old_active_session
=
self
.
session_model
.
data
(
deselected_indexes
[
0
]
)
if
deselected_indexes
else
Null
old_active_session
=
deselected_indexes
[
0
]
.
data
(
Qt
.
UserRole
)
if
deselected_indexes
else
Null
new_active_session
=
sel
f
.
session_model
.
data
(
selected_indexes
[
0
]
)
if
selected_indexes
else
Null
new_active_session
=
sel
ected_indexes
[
0
]
.
data
(
Qt
.
UserRole
)
if
selected_indexes
else
Null
if
old_active_session
.
conference
and
old_active_session
.
conference
is
not
new_active_session
.
conference
:
if
old_active_session
.
conference
and
old_active_session
.
conference
is
not
new_active_session
.
conference
:
for
session
in
old_active_session
.
conference
.
sessions
:
for
session
in
old_active_session
.
conference
.
sessions
:
session
.
active
=
False
session
.
active
=
False
...
...
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