def DeleteItem(self):
     proxiedItem = getProxy(u'ui', self.itemsAndStates[self.itemNumber][0])
     trash = schema.ns('osaf.pim', self.view).trashCollection
     proxiedItem.addToCollection(trash)
     if self.originalAction == 'cutting':
         # when cutting the last collection an item appears in,
         # the recurrence dialog should use remove, not delete,
         # or THIS and THISANDFUTURE will be options.  There isn't currently
         # an API to restrict the choices in the proxy's dialog, so trick
         # the proxy into thinking the action is a remove by queuing a remove
         proxiedItem.removeFromCollection(self.selectedCollection)
예제 #2
0
 def DeleteItem(self):
     proxiedItem = getProxy(u'ui', self.itemsAndStates[self.itemNumber][0])
     trash = schema.ns('osaf.pim', self.view).trashCollection
     proxiedItem.addToCollection(trash)
     if self.originalAction == 'cutting':
         # when cutting the last collection an item appears in,
         # the recurrence dialog should use remove, not delete,
         # or THIS and THISANDFUTURE will be options.  There isn't currently
         # an API to restrict the choices in the proxy's dialog, so trick
         # the proxy into thinking the action is a remove by queuing a remove
         proxiedItem.removeFromCollection(self.selectedCollection)
예제 #3
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
예제 #5
0
    def onDeleteEvent(self, event):
        selectedCollection = self.__getPrimaryCollection()
        selection = self.__getSelectedItems()
        assert len(
            selection) > 0  # If this assert fails fix onDeleteEventUpdateUI

        oldIndex = None
        # The DetailRootBlock's contents is not a collection, so it has no 'index' method
        if hasattr(self.contents, 'index'):
            try:
                oldIndex = self.contents.index(selection[0])
            except NoSuchItemInCollectionError:
                pass

        assert selectedCollection, "Can't delete without a primary collection!"

        trash = schema.ns('osaf.pim', self.itsView).trashCollection
        if selectedCollection == trash:

            def deleteItem(item):
                # For deleting from the trash, get rid of the event's
                # master; there's no sense in asking about a particular
                # instance.
                getattr(item, 'inheritFrom', item).delete(True)
        else:

            def deleteItem(item):
                item.addToCollection(trash)

        readonly = []
        for item in selection:
            if DeleteDialog.GetReadOnlyCollection(item, self.itsView) is None:
                deleteItem(getProxy(u'ui', item))
            else:
                readonly.append((item, DeleteDialog.IN_READ_ONLY_COLLECTION))

        if len(readonly) != 0:
            DeleteDialog.ShowDeleteDialog(
                view=self.itsView,
                selectedCollection=selectedCollection,
                itemsAndStates=readonly,
                originalAction='delete')
        selection = getattr(self, 'GetSelection', lambda: self.contents)()
        if not hasattr(selection,
                       'isSelectionEmpty') or selection.isSelectionEmpty():
            self.selectionEmptiedAfterDelete(selectedCollection, oldIndex)
예제 #6
0
            def removeItem(item):
                item = getattr(item, 'inheritFrom', item)

                collections = getattr(item, "collections", None)

                if collections is not None and \
                    selectedCollection in collections:
                    item = getProxy(u'ui', item)

                #XXX This is a hack to fix bug 9691 "Using Item-Remove does not
                #    remove items from the In or Out collections". This temporary
                #    fix works around an incorrect assumption in the RecurrenceDialog
                #    code that the "selectedCollection" will be in the item's "collections"
                #    list attribute. That assumption does not apply to the Smart Collections
                #    "In", "Out", and "Dashboard". Grant will need to address this issue
                #    further post-Preview. -BrianK
                item.removeFromCollection(selectedCollection)
예제 #7
0
            def removeItem(item):
                item = getattr(item, 'inheritFrom', item)

                collections = getattr(item, "collections", None)

                if collections is not None and \
                    selectedCollection in collections:
                    item = getProxy(u'ui', item)

                #XXX This is a hack to fix bug 9691 "Using Item-Remove does not
                #    remove items from the In or Out collections". This temporary
                #    fix works around an incorrect assumption in the RecurrenceDialog
                #    code that the "selectedCollection" will be in the item's "collections"
                #    list attribute. That assumption does not apply to the Smart Collections
                #    "In", "Out", and "Dashboard". Grant will need to address this issue
                #    further post-Preview. -BrianK
                item.removeFromCollection(selectedCollection)
예제 #8
0
    def onDeleteEvent(self, event):
        selectedCollection = self.__getPrimaryCollection()
        selection = self.__getSelectedItems()
        assert len(selection) > 0 # If this assert fails fix onDeleteEventUpdateUI
        
        oldIndex = None
        # The DetailRootBlock's contents is not a collection, so it has no 'index' method
        if hasattr(self.contents, 'index'):
            try:
                oldIndex = self.contents.index (selection[0])
            except NoSuchItemInCollectionError:
                pass

        assert selectedCollection, "Can't delete without a primary collection!"

        trash = schema.ns('osaf.pim', self.itsView).trashCollection
        if selectedCollection == trash:
            def deleteItem(item):
                # For deleting from the trash, get rid of the event's
                # master; there's no sense in asking about a particular
                # instance.
                getattr(item, 'inheritFrom', item).delete(True)
        else:
            def deleteItem(item):
                item.addToCollection(trash)
        
        readonly  = []
        for item in selection:
            if DeleteDialog.GetReadOnlyCollection(item, self.itsView) is None:
                deleteItem(getProxy(u'ui', item))
            else:
                readonly.append((item, DeleteDialog.IN_READ_ONLY_COLLECTION))

        if len(readonly) != 0:
            DeleteDialog.ShowDeleteDialog(view=self.itsView,
                                          selectedCollection=selectedCollection,
                                          itemsAndStates=readonly,
                                          originalAction='delete')
        selection = getattr(self, 'GetSelection', lambda : self.contents)()
        if not hasattr(selection, 'isSelectionEmpty') or selection.isSelectionEmpty():
            self.selectionEmptiedAfterDelete (selectedCollection, oldIndex)
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
예제 #10
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