~ubuntu-branches/ubuntu/utopic/taskcoach/utopic-proposed

« back to all changes in this revision

Viewing changes to taskcoachlib/command/taskCommands.py

  • Committer: Package Import Robot
  • Author(s): Matthias Klose
  • Date: 2014-08-15 14:54:44 UTC
  • mfrom: (8.1.7 sid)
  • Revision ID: package-import@ubuntu.com-20140815145444-qm2ya2zvy1pyrcl5
Tags: 1.4.0-1ubuntu1
* Merge with Debian; remaining changes:
  - Let the autopkg test depend on language-pack-en.
  - Build-depend on language-pack-en.
* Build using python-wxgtk3.0.
* Don't use /usr/share/pyshared anymore, it's gone.

Show diffs side-by-side

added added

removed removed

Lines of Context:
57
57
        self.stopTracking()
58
58
 
59
59
 
60
 
class DragAndDropTaskCommand(base.DragAndDropCommand):
 
60
class DragAndDropTaskCommand(base.OrderingDragAndDropCommand):
61
61
    plural_name = _('Drag and drop tasks')
62
62
 
63
 
    def __init__(self, *args, **kwargs):
64
 
        self.__part = kwargs.pop('part', 0)
65
 
        super(DragAndDropTaskCommand, self).__init__(*args, **kwargs)
66
 
 
67
63
    def getItemsToSave(self):
68
64
        toSave = super(DragAndDropTaskCommand, self).getItemsToSave()
69
 
        if self.__part != 0:
 
65
        if self.part != 0:
70
66
            toSave.extend(self.getSiblings())
71
 
        return toSave        
72
 
 
73
 
    def getSiblings(self):
74
 
        siblings = []
75
 
        for item in self.list:
76
 
            if item.parent() == self._itemToDropOn.parent() and item not in self.items:
77
 
                siblings.append(item)
78
 
        return siblings
 
67
        return list(set(toSave)) # Because parent may have added siblings as well
79
68
 
80
69
    def do_command(self):
81
 
        if self.__part == 0:
 
70
        if self.part == 0 or self.isOrdering():
82
71
            super(DragAndDropTaskCommand, self).do_command()
83
72
        else:
84
 
            if self.__part == -1:
 
73
            if self.part == -1:
85
74
                # Up part. Add dropped items as prerequisites of dropped on item.
86
75
                self._itemToDropOn.addPrerequisites(self.items)
87
76
                self._itemToDropOn.addTaskAsDependencyOf(self.items)
92
81
                    item.addTaskAsDependencyOf([self._itemToDropOn])
93
82
 
94
83
    def undo_command(self):
95
 
        if self.__part == 0:
 
84
        if self.part == 0 or self.isOrdering():
96
85
            super(DragAndDropTaskCommand, self).undo_command()
97
 
        elif self.__part == -1:
 
86
        elif self.part == -1:
98
87
            self._itemToDropOn.removePrerequisites(self.items)
99
88
            self._itemToDropOn.removeTaskAsDependencyOf(self.items)
100
89
        else:
103
92
                item.removeTaskAsDependencyOf([self._itemToDropOn])
104
93
 
105
94
    def redo_command(self):
106
 
        if self.__part == 0:
 
95
        if self.part == 0 or self.isOrdering():
107
96
            super(DragAndDropTaskCommand, self).redo_command()
108
 
        elif self.__part == -1:
 
97
        elif self.part == -1:
109
98
            self._itemToDropOn.addPrerequisites(self.items)
110
99
            self._itemToDropOn.addTaskAsDependencyOf(self.items)
111
100
        else: