Changeset 715

Show
Ignore:
Timestamp:
07/15/08 05:43:57 (5 months ago)
Author:
sylvain
Message:

still working to support drag/drop

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • oss/jlib/jlib/core/contact.py

    r714 r715  
    113113                    self.send(Roster(from_jid=self.from_jid, to_jid=nodeid, 
    114114                                     type=u'result', stanza_id=generate_unique()), 'result') 
    115  
     115                     
    116116                    if contact.subscription == 'none': 
    117117                        r = Roster(from_jid=self.from_jid, to_jid=nodeid, 
    118                            type=u'set', stanza_id=generate_unique()) 
     118                                   type=u'set', stanza_id=generate_unique()) 
    119119                        i = Item(nodeid) 
    120120                        i.subscription = u'remove' 
     
    192192        return QtGui.QStandardItemModel.flags(self, index) 
    193193 
     194    def mimeTypes(self):      
     195        types = QtGui.QStandardItemModel.mimeTypes(self) 
     196        types.append(QtCore.QString('text/uri-list')) 
     197        return types 
     198 
    194199    def mimeData(self, indexes): 
    195         mimeData = QtCore.QMimeData(
     200        mimeData = QtGui.QStandardItemModel.mimeData(self, indexes
    196201        urls = [] 
    197202        for index in indexes: 
    198203             if index.isValid(): 
    199204                 contact = self.getContact(index) 
    200                  urls.append(QtCore.QUrl('xmpp:%s' % str(contact.jid))) 
     205                 urls.append(QtCore.QUrl(QtCore.QString('xmpp:%s' % str(contact.jid)))) 
    201206              
    202207        mimeData.setUrls(urls) 
     
    238243    def getGroup(self, index): 
    239244        return self.itemFromIndex(index).group 
     245 
     246    def getGroupAt(self, row, column): 
     247        for group in self.group_items: 
     248            item = self.group_items[group] 
     249            if item.row() == row and item.column() == column: 
     250                return group 
    240251 
    241252    def getGroupIndex(self, group): 
  • oss/jlib/jlib/gui/contact.py

    r714 r715  
    2020        self.contacts.contextMenuEvent = self.contextMenuEvent 
    2121        self.contacts.dragEnterEvent = self.dragEnterEvent 
     22        self.contacts.dropEvent = self.dropEvent 
    2223 
    2324        self.contact = jlibContact(parent=self) 
     
    4243 
    4344        QtCore.QObject.connect(self.contacts, QtCore.SIGNAL("clicked(QModelIndex)"), self.clicked) 
    44          
     45 
    4546    def receivedRoster(self, roster): 
    4647        model = self.contacts.model() 
     
    125126    def dragEnterEvent(self, event): 
    126127        data = event.mimeData() 
    127         if not data.hasFormat('text/uri-list'): 
    128             event.ignore() 
    129             return 
    130          
    131128        model = self.contacts.model() 
    132129        index = self.contacts.indexAt(event.pos()) 
     
    137134            if group in contact.groups: 
    138135                contact.groups.remove(group) 
    139  
    140136        event.accept() 
    141137 
    142138    def dropEvent(self, event): 
    143139        model = self.contacts.model() 
     140        group = unicode(self.contacts.indexAt(event.pos()).data().toString()) 
    144141         
    145         index = self.contacts.indexAt(event.pos()) 
    146         parentIndex = index.parent() 
    147         group = model.getGroup(parentIndex) 
    148          
    149         urls = event.data().urls() 
    150         for url in urls: 
     142        for url in event.mimeData().urls(): 
    151143            xmppUrl = str(url.toString()) 
    152144            jid = xmppUrl[5:] 
    153145            contact = model.getContactByJID(jid) 
    154             contact.groups.append(group) 
    155  
    156         print contact.groups 
     146            contact.groups = [group] 
     147            self.contact.emit(QtCore.SIGNAL("changeGroup(PyQt_PyObject, PyQt_PyObject)"),  
     148                              contact.jid, contact.groups) 
    157149             
    158              
    159