Exemplo n.º 1
0
 def OnItemDrag(self, event):
     if isReadOnly(self.blockItem.contentsCollection):
         event.Skip(False)
         wx.MessageBox(_(
             u'This collection is read-only. You cannot drag items out of read-only collections.'
         ),
                       _(u'Warning'),
                       parent=self)
     else:
         return super(wxDashboard, self).OnItemDrag(event)
Exemplo n.º 2
0
def GetReadOnlyCollection(item, view):
    """Return the first read-only collection the item is in, or None."""
    app_ns = schema.ns('osaf.app', view)
    pim_ns = schema.ns('osaf.pim', view)
    allCollection = pim_ns.allCollection
    
    sidebarCollections = app_ns.sidebarCollection
    
    memberItem = getProxy(u'ui', item).getMembershipItem()
    for collection in [col for col in sidebarCollections if sharing.isReadOnly(col)]:
        if memberItem in collection:
            return collection
    return None
def GetReadOnlyCollection(item, view):
    """Return the first read-only collection the item is in, or None."""
    app_ns = schema.ns('osaf.app', view)
    pim_ns = schema.ns('osaf.pim', view)
    allCollection = pim_ns.allCollection

    sidebarCollections = app_ns.sidebarCollection

    memberItem = getProxy(u'ui', item).getMembershipItem()
    for collection in [
            col for col in sidebarCollections if sharing.isReadOnly(col)
    ]:
        if memberItem in collection:
            return collection
    return None
Exemplo n.º 4
0
 def AddItems(self, itemList):
     """
     The table's self.contents may contain a collectionList, in
     case this collection is composed of other collections. In this
     case, collectionList.first() is the 'primary' collection that
     should handle adds/deletes and other status updates
     """
     collection = self.blockItem.contents
     if hasattr (collection, 'collectionList'):
         collection = collection.collectionList.first()
     
     # Vefify that we don't have a readonly collection
     if __debug__:
         assert not isReadOnly(collection), "Can't add items to readonly collection - should block before the drop"
     
     for item in itemList:
         RecurrenceDialog.getProxy(u'ui', item).addToCollection(collection)
Exemplo n.º 5
0
    def AddItems(self, itemList):
        """
        The table's self.contents may contain a collectionList, in
        case this collection is composed of other collections. In this
        case, collectionList.first() is the 'primary' collection that
        should handle adds/deletes and other status updates
        """
        collection = self.blockItem.contents
        if hasattr(collection, 'collectionList'):
            collection = collection.collectionList.first()

        # Vefify that we don't have a readonly collection
        if __debug__:
            assert not isReadOnly(
                collection
            ), "Can't add items to readonly collection - should block before the drop"

        for item in itemList:
            RecurrenceDialog.getProxy(u'ui', item).addToCollection(collection)
def GetItemRemovalState(selectedCollection, item, view):
    """
    Determine how an item that's supposed to be removed ought to be handled.

    It may be simply removed, or its collection membership may indicate that
    it should be deleted, or it could be treated as read-only.
    
    """
    app_ns = schema.ns('osaf.app', view)
    pim_ns = schema.ns('osaf.pim', view)
    allCollection = pim_ns.allCollection

    sidebarCollections = app_ns.sidebarCollection
    readonlyCollections = [
        col for col in sidebarCollections if sharing.isReadOnly(col)
    ]

    # you can always remove from the trash
    if selectedCollection is pim_ns.trashCollection:
        return REMOVE_NORMAL

    elif selectedCollection in readonlyCollections:
        return READ_ONLY_SELECTED

    else:
        memberItem = getProxy(u'ui', item).getMembershipItem()
        if selectedCollection is allCollection:
            # Items in the dashboard because they're in a mine collection
            # can't be removed, they're always deleted
            if GetReadOnlyCollection(item, view) is None:
                for collection in memberItem.appearsIn or []:
                    if collection in pim_ns.mine.sources:
                        return DELETE_DASHBOARD
            else:
                return IN_READ_ONLY_COLLECTION

        if len(memberItem.appearsIn) > 1:
            return REMOVE_NORMAL
        else:
            return DELETE_LAST
Exemplo n.º 7
0
def GetItemRemovalState(selectedCollection, item, view):
    """
    Determine how an item that's supposed to be removed ought to be handled.

    It may be simply removed, or its collection membership may indicate that
    it should be deleted, or it could be treated as read-only.
    
    """
    app_ns = schema.ns('osaf.app', view)
    pim_ns = schema.ns('osaf.pim', view)
    allCollection = pim_ns.allCollection
    
    sidebarCollections = app_ns.sidebarCollection
    readonlyCollections = [col for col in sidebarCollections
                           if sharing.isReadOnly(col)]

    # you can always remove from the trash
    if selectedCollection is pim_ns.trashCollection:
        return REMOVE_NORMAL

    elif selectedCollection in readonlyCollections:
        return READ_ONLY_SELECTED

    else:
        memberItem = getProxy(u'ui', item).getMembershipItem()
        if selectedCollection is allCollection:
            # Items in the dashboard because they're in a mine collection
            # can't be removed, they're always deleted
            if GetReadOnlyCollection(item, view) is None:
                for collection in memberItem.appearsIn or []:
                    if collection in pim_ns.mine.sources:
                        return DELETE_DASHBOARD
            else:
                return IN_READ_ONLY_COLLECTION

        if len(memberItem.appearsIn) > 1:
            return REMOVE_NORMAL
        else:
            return DELETE_LAST
Exemplo n.º 8
0
 def OnItemDrag(self, event):
     if isReadOnly(self.blockItem.contentsCollection):
         event.Skip(False)
         wx.MessageBox(_(u'This collection is read-only. You cannot drag items out of read-only collections.'), _(u'Warning'), parent=self)
     else:
         return super(wxDashboard, self).OnItemDrag(event)
Exemplo n.º 9
0
 def CanAdd(self):
     return not sharing.isReadOnly(self.contentsCollection)
Exemplo n.º 10
0
 def isAttributeModifiable(self, attribute):
     """ Determine if an item's attribute is modifiable based on the
         shares it's in """
     from osaf.sharing import isReadOnly
     return not isReadOnly(self)
Exemplo n.º 11
0
 def isAttributeModifiable(self, attribute):
     """ Determine if an item's attribute is modifiable based on the
         shares it's in """
     from osaf.sharing import isReadOnly
     return not isReadOnly(self)
Exemplo n.º 12
0
 def CanAdd(self):
     return not sharing.isReadOnly(self.contentsCollection)