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
d7b7107f
Commit
d7b7107f
authored
Apr 30, 2010
by
Dan Pascu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplified contact and group mime data encoding
parent
017c9039
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
24 deletions
+12
-24
contacts.py
blink/contacts.py
+12
-24
No files found.
blink/contacts.py
View file @
d7b7107f
...
@@ -5,8 +5,10 @@ from __future__ import with_statement
...
@@ -5,8 +5,10 @@ from __future__ import with_statement
__all__
=
[
'Contact'
,
'ContactGroup'
,
'ContactDelegate'
,
'ContactModel'
,
'ContactSearchModel'
,
'ContactListView'
,
'ContactSearchListView'
]
__all__
=
[
'Contact'
,
'ContactGroup'
,
'ContactDelegate'
,
'ContactModel'
,
'ContactSearchModel'
,
'ContactListView'
,
'ContactSearchListView'
]
import
cPickle
as
pickle
from
PyQt4
import
uic
from
PyQt4
import
uic
from
PyQt4.QtCore
import
Qt
,
QAbstractListModel
,
QByteArray
,
Q
DataStream
,
QEvent
,
QIODevice
,
QMimeData
,
QModelIndex
,
QPointF
,
QRectF
,
QSize
,
QStringList
,
QTimer
,
QVariant
from
PyQt4.QtCore
import
Qt
,
QAbstractListModel
,
QByteArray
,
Q
Event
,
QMimeData
,
QModelIndex
,
QPointF
,
QRectF
,
QSize
,
QStringList
,
QTimer
from
PyQt4.QtGui
import
QBrush
,
QColor
,
QKeyEvent
,
QLinearGradient
,
QListView
,
QMouseEvent
,
QPainter
,
QPainterPath
,
QPalette
,
QPen
,
QPixmap
,
QPolygonF
,
QStyle
from
PyQt4.QtGui
import
QBrush
,
QColor
,
QKeyEvent
,
QLinearGradient
,
QListView
,
QMouseEvent
,
QPainter
,
QPainterPath
,
QPalette
,
QPen
,
QPixmap
,
QPolygonF
,
QStyle
from
PyQt4.QtGui
import
QSortFilterProxyModel
,
QStyledItemDelegate
from
PyQt4.QtGui
import
QSortFilterProxyModel
,
QStyledItemDelegate
...
@@ -408,20 +410,12 @@ class ContactModel(QAbstractListModel):
...
@@ -408,20 +410,12 @@ class ContactModel(QAbstractListModel):
def
mimeData
(
self
,
indexes
):
def
mimeData
(
self
,
indexes
):
mime_data
=
QMimeData
()
mime_data
=
QMimeData
()
contact_data
=
QByteArray
()
contacts
=
[
item
for
item
in
(
self
.
items
[
index
.
row
()]
for
index
in
indexes
if
index
.
isValid
())
if
type
(
item
)
is
Contact
]
contact_group_data
=
QByteArray
()
groups
=
[
item
for
item
in
(
self
.
items
[
index
.
row
()]
for
index
in
indexes
if
index
.
isValid
())
if
type
(
item
)
is
ContactGroup
]
contact_stream
=
QDataStream
(
contact_data
,
QIODevice
.
WriteOnly
)
if
contacts
:
contact_group_stream
=
QDataStream
(
contact_group_data
,
QIODevice
.
WriteOnly
)
mime_data
.
setData
(
'application/x-blink-contact-list'
,
QByteArray
(
pickle
.
dumps
(
contacts
)))
for
index
in
(
index
for
index
in
indexes
if
index
.
isValid
()):
if
groups
:
row
=
index
.
row
()
mime_data
.
setData
(
'application/x-blink-contact-group-list'
,
QByteArray
(
pickle
.
dumps
(
groups
)))
item
=
self
.
items
[
row
]
stream
=
contact_group_stream
if
type
(
item
)
is
ContactGroup
else
contact_stream
stream
.
writeInt32
(
row
)
stream
.
writeQVariant
(
QVariant
(
item
))
if
contact_data
:
mime_data
.
setData
(
'application/x-blink-contact-list'
,
contact_data
)
if
contact_group_data
:
mime_data
.
setData
(
'application/x-blink-contact-group-list'
,
contact_group_data
)
return
mime_data
return
mime_data
def
dropMimeData
(
self
,
mime_data
,
action
,
row
,
column
,
parent_index
):
def
dropMimeData
(
self
,
mime_data
,
action
,
row
,
column
,
parent_index
):
...
@@ -632,15 +626,9 @@ class ContactSearchModel(QSortFilterProxyModel):
...
@@ -632,15 +626,9 @@ class ContactSearchModel(QSortFilterProxyModel):
def
mimeData
(
self
,
indexes
):
def
mimeData
(
self
,
indexes
):
mime_data
=
QMimeData
()
mime_data
=
QMimeData
()
contact_data
=
QByteArray
()
contacts
=
[
self
.
items
[
index
.
row
()]
for
index
in
indexes
if
index
.
isValid
()]
stream
=
QDataStream
(
contact_data
,
QIODevice
.
WriteOnly
)
if
contacts
:
for
index
in
(
index
for
index
in
indexes
if
index
.
isValid
()):
mime_data
.
setData
(
'application/x-blink-contact-list'
,
QByteArray
(
pickle
.
dumps
(
contacts
)))
row
=
index
.
row
()
item
=
self
.
data
(
index
)
stream
.
writeInt32
(
row
)
stream
.
writeQVariant
(
QVariant
(
item
))
if
contact_data
:
mime_data
.
setData
(
'application/x-blink-contact-list'
,
contact_data
)
return
mime_data
return
mime_data
def
dropMimeData
(
self
,
mime_data
,
action
,
row
,
column
,
parent_index
):
def
dropMimeData
(
self
,
mime_data
,
action
,
row
,
column
,
parent_index
):
...
...
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