コード例 #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))
コード例 #2
0
ファイル: reallevel.py プロジェクト: maestromusic/maestro
 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))
コード例 #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)
コード例 #4
0
ファイル: reallevel.py プロジェクト: maestromusic/maestro
 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))
コード例 #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)
コード例 #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()
コード例 #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()
コード例 #8
0
ファイル: reallevel.py プロジェクト: maestromusic/maestro
 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))
コード例 #9
0
ファイル: reallevel.py プロジェクト: maestromusic/maestro
 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))
コード例 #10
0
ファイル: actions.py プロジェクト: maestromusic/maestro
 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()
コード例 #11
0
ファイル: actions.py プロジェクト: maestromusic/maestro
 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()
コード例 #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))
コード例 #13
0
def deleteSource(source):
    stack.push(translate('filesystem', 'Delete source'),
               stack.Call(_deleteSource, source),
               stack.Call(_addSource, source))
コード例 #14
0
ファイル: __init__.py プロジェクト: maestromusic/maestro
def deleteSource(source):
    stack.push(translate('filesystem', 'Delete source'),
               stack.Call(_deleteSource, source), stack.Call(_addSource, source))
コード例 #15
0
ファイル: __init__.py プロジェクト: maestromusic/maestro
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))
コード例 #16
0
ファイル: __init__.py プロジェクト: maestromusic/maestro
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))