Exemple #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))
Exemple #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))
 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)
Exemple #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))
Exemple #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)
 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()
Exemple #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()
Exemple #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))
Exemple #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))
Exemple #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()
Exemple #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()
Exemple #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))
Exemple #13
0
def deleteSource(source):
    stack.push(translate('filesystem', 'Delete source'),
               stack.Call(_deleteSource, source),
               stack.Call(_addSource, source))
Exemple #14
0
def deleteSource(source):
    stack.push(translate('filesystem', 'Delete source'),
               stack.Call(_deleteSource, source), stack.Call(_addSource, source))
Exemple #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))
Exemple #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))