Ejemplo n.º 1
0
def changeSource(source, **data):
    oldData = {
        attr: getattr(source, attr)
        for attr in ('name', 'path', 'domain', 'extensions', 'enabled')
    }
    stack.push(translate('filesystem', "Change source"),
               stack.Call(_changeSource, source, data),
               stack.Call(_changeSource, source, oldData))
Ejemplo n.º 2
0
 def removeFromDb(self, elements):
     """Remove the given elements with all their tags etc. from the database. Containers are also
     removed from the real level. No element may be contained in any container unless this container
     is also in *elements*.
     """
     if len(elements):
         stack.push(self.tr("Remove elements from database"),
                    stack.Call(self._removeFromDb, elements),
                    stack.Call(self._addToDb, elements))
Ejemplo n.º 3
0
 def insertElements(self, parent, row, elements):
     """Undoably insert *elements* (a list) under *parent*, which is a wrapper.
     
     This convenience function either pushes an InsertIntoRootCommand, if *parent* is this model's
     root, or updates the level otherwise.
     """
     if parent is self.root:
         stack.push(InsertIntoRootCommand(self, row, [element.id for element in elements]))
     else: self.level.insertContentsAuto(parent.element, row, elements)
Ejemplo n.º 4
0
 def removeFromDb(self, elements):
     """Remove the given elements with all their tags etc. from the database. Containers are also
     removed from the real level. No element may be contained in any container unless this container
     is also in *elements*.
     """
     if len(elements):
         stack.push(self.tr("Remove elements from database"),
                    stack.Call(self._removeFromDb, elements),
                    stack.Call(self._addToDb, elements))
Ejemplo n.º 5
0
 def insertElements(self, parent, row, elements):
     """Undoably insert *elements* (a list) under *parent*, which is a wrapper.
     
     This convenience function either pushes an InsertIntoRootCommand, if *parent* is this model's
     root, or updates the level otherwise.
     """
     if parent is self.root:
         stack.push(
             InsertIntoRootCommand(self, row,
                                   [element.id for element in elements]))
     else:
         self.level.insertContentsAuto(parent.element, row, elements)
Ejemplo n.º 6
0
 def removeElements(self, parent, rows):
     """Undoably remove elements in *rows* under *parent* (a wrapper, an element or the root node).
     
     This convenience function either alters the RootNode, if parent is self.root, or updates
     the level.
     """
     stack.beginMacro(self.tr('remove elements'))
     if parent is self.root:
         stack.push(RemoveFromRootCommand(self, rows))
     else:
         element = parent if isinstance(parent, elements.Element) else parent.element
         self.level.removeContentsAuto(element, indexes=rows)
     stack.endMacro()
Ejemplo n.º 7
0
 def removeElements(self, parent, rows):
     """Undoably remove elements in *rows* under *parent* (a wrapper, an element or the root node).
     
     This convenience function either alters the RootNode, if parent is self.root, or updates
     the level.
     """
     stack.beginMacro(self.tr('remove elements'))
     if parent is self.root:
         stack.push(RemoveFromRootCommand(self, rows))
     else:
         element = parent if isinstance(
             parent, elements.Element) else parent.element
         self.level.removeContentsAuto(element, indexes=rows)
     stack.endMacro()
Ejemplo n.º 8
0
 def addToDb(self, elements):
     """Add the given elements to the database including their tags, flags, stickers and contents.
     Remarks:
     
         - element.level must be this level,
         - files must already be loaded on real, containers must not,
         - this method will not change the elements but assume that in particular their parent-lists
           are correct (on the real level).
     
     """
     if len(elements):
         assert all(element.level is self for element in elements)
         stack.push(self.tr("Add elements to database"),
                    stack.Call(self._addToDb, elements),
                    stack.Call(self._removeFromDb, elements))
Ejemplo n.º 9
0
 def addToDb(self, elements):
     """Add the given elements to the database including their tags, flags, stickers and contents.
     Remarks:
     
         - element.level must be this level,
         - files must already be loaded on real, containers must not,
         - this method will not change the elements but assume that in particular their parent-lists
           are correct (on the real level).
     
     """
     if len(elements):
         assert all(element.level is self for element in elements)
         stack.push(self.tr("Add elements to database"),
                    stack.Call(self._addToDb, elements),
                    stack.Call(self._removeFromDb, elements))
Ejemplo n.º 10
0
 def accept(self):
     stack.beginMacro(self.tr("Hide values"), transaction=True)
     from maestro.core import tagcommands
     for i in range(self.treeWidget.topLevelItemCount()):
         tagItem = self.treeWidget.topLevelItem(i)
         tag = tagItem.data(0, Qt.UserRole)
         vids = []
         if tagItem.checkState(0) != Qt.Unchecked:
             for j in range(tagItem.childCount()):
                 valueItem = tagItem.child(j)
                 if valueItem.checkState(0) == Qt.Checked:
                     vids.append(valueItem.data(0, Qt.UserRole))
         if len(vids) > 0:
             stack.push(tagcommands.HiddenAttributeCommand(tag, vids, True))
     stack.endMacro()
     self.close()
Ejemplo n.º 11
0
 def accept(self):
     stack.beginMacro(self.tr("Hide values"), transaction=True)
     from maestro.core import tagcommands
     for i in range(self.treeWidget.topLevelItemCount()):
         tagItem = self.treeWidget.topLevelItem(i)
         tag = tagItem.data(0, Qt.UserRole)
         vids = []
         if tagItem.checkState(0) != Qt.Unchecked:
             for j in range(tagItem.childCount()):
                 valueItem = tagItem.child(j)
                 if valueItem.checkState(0) == Qt.Checked:
                     vids.append(valueItem.data(0, Qt.UserRole))
         if len(vids) > 0:
             stack.push(tagcommands.HiddenAttributeCommand(tag, vids, True))
     stack.endMacro()
     self.close()
Ejemplo n.º 12
0
def addSource(**data):
    from maestro.filesystem.sources import Source
    source = Source(**data)
    stack.push(translate('Filesystem', 'Add source'),
               stack.Call(_addSource, source),
               stack.Call(_deleteSource, source))
Ejemplo n.º 13
0
def deleteSource(source):
    stack.push(translate('filesystem', 'Delete source'),
               stack.Call(_deleteSource, source),
               stack.Call(_addSource, source))
Ejemplo n.º 14
0
def deleteSource(source):
    stack.push(translate('filesystem', 'Delete source'),
               stack.Call(_deleteSource, source), stack.Call(_addSource, source))
Ejemplo n.º 15
0
def addSource(**data):
    from maestro.filesystem.sources import Source
    source = Source(**data)
    stack.push(translate('Filesystem', 'Add source'),
               stack.Call(_addSource, source), stack.Call(_deleteSource, source))
Ejemplo n.º 16
0
def changeSource(source, **data):
    oldData = {attr: getattr(source, attr) for attr in ('name', 'path', 'domain', 'extensions', 'enabled')}
    stack.push(translate('filesystem', "Change source"),
               stack.Call(_changeSource, source, data),
               stack.Call(_changeSource, source, oldData))