Removed AlbumManager.

This commit is contained in:
Lukáš Lalinský
2006-09-05 23:55:34 +02:00
parent ac228ba641
commit 243aedce59
3 changed files with 24 additions and 79 deletions

View File

@@ -1,68 +0,0 @@
# -*- coding: utf-8 -*-
#
# Picard, the next-generation MusicBrainz tagger
# Copyright (C) 2004 Robert Kaye
# Copyright (C) 2006 Lukáš Lalinský
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
from PyQt4 import QtCore
from picard.album import Album
from picard.artist import Artist
class UnmatchedFiles(Album):
def __init__(self):
self._origName = u"Unmatched Files (%d)"
Album.__init__(self, u"[unmatched files]", self._origName)
def addUnmatchedFile(self, file):
self.name = self._origName % (self.getNumUnmatchedFiles() + 1)
Album.addUnmatchedFile(self, file)
def removeFile(self, file):
self.name = self._origName % (self.getNumUnmatchedFiles() - 1)
Album.removeFile(self, file)
class Clusters(Album):
pass
class AlbumManager(QtCore.QObject):
def __init__(self):
QtCore.QObject.__init__(self)
self.albums = []
self.unmatchedFiles = UnmatchedFiles()
self.clusters = Clusters(u"[clusters]", u"Clusters")
def load(self, albumId):
albumId = unicode(albumId)
album = Album(albumId, "[loading album information]", None)
self.albums.append(album)
self.connect(album, QtCore.SIGNAL("trackUpdated"), self, QtCore.SIGNAL("trackUpdated"))
self.emit(QtCore.SIGNAL("albumAdded"), album)
self.tagger.worker.loadAlbum(album)
#album.load()
def getAlbumById(self, id):
for album in self.albums:
if album.id == id:
return album
return None
def getNumAlbums(self):
return len(self.albums)

View File

@@ -28,8 +28,8 @@ import sys
import picard.resources
from picard.album import Album
from picard.cluster import Cluster
from picard.albummanager import AlbumManager
from picard.api import IFileOpener
from picard.browser.filelookup import FileLookup
from picard.browser.browser import BrowserIntegration
@@ -72,12 +72,13 @@ class Tagger(QtGui.QApplication, ComponentManager, Component):
self.browserIntegration = BrowserIntegration()
self.fileManager = FileManager()
self.albumManager = AlbumManager()
self.clusters = []
self.unmatchedFiles = Cluster(_(u"Unmatched Files"))
self.connect(self.browserIntegration, QtCore.SIGNAL("loadAlbum(const QString &)"), self.albumManager.load)
self.albums = []
self.connect(self.browserIntegration, QtCore.SIGNAL("loadAlbum(const QString &)"), self.loadAlbum)
self.window = MainWindow()
self.connect(self.window, QtCore.SIGNAL("addFiles"), self.onAddFiles)
@@ -175,6 +176,21 @@ class Tagger(QtGui.QApplication, ComponentManager, Component):
for file in files:
self.worker.saveFile(file)
# Albums
def loadAlbum(self, albumId):
album = Album(unicode(albumId), "[loading album information]", None)
self.albums.append(album)
self.connect(album, QtCore.SIGNAL("trackUpdated"), self, QtCore.SIGNAL("trackUpdated"))
self.emit(QtCore.SIGNAL("albumAdded"), album)
self.worker.loadAlbum(album)
def getAlbumById(self, albumId):
for album in self.albums:
if album.id == albumId:
return album
return None
def main(localeDir=None):
try:
import psyco

View File

@@ -23,7 +23,6 @@ from picard.album import Album
from picard.cluster import Cluster
from picard.file import File
from picard.track import Track
from picard.albummanager import UnmatchedFiles
from picard.util import formatTime, encodeFileName
from picard.ui.tageditor import TagEditor
@@ -194,8 +193,7 @@ class BaseTreeView(QtGui.QTreeWidget):
# application/picard.album-list
albums = data.data("application/picard.album-list")
if albums:
albums = [self.tagger.albumManager.getAlbumById(albumsId) for albumsId in str(albums).split("\n")]
print albums
albums = [self.tagger.getAlbumById(albumsId) for albumsId in str(albums).split("\n")]
self.dropAlbums(albums, target)
return True
@@ -328,9 +326,8 @@ class AlbumTreeView(BaseTreeView):
QtGui.QIcon(":/images/match-100.png"),
]
albumManager = self.tagger.albumManager
self.connect(albumManager, QtCore.SIGNAL("albumAdded"), self.addAlbum)
self.connect(albumManager, QtCore.SIGNAL("trackUpdated"), self.updateTrack)
self.connect(self.tagger, QtCore.SIGNAL("albumAdded"), self.addAlbum)
self.connect(self.tagger, QtCore.SIGNAL("trackUpdated"), self.updateTrack)
self.connect(self.tagger.worker, QtCore.SIGNAL("albumLoaded(QString)"),
self.updateAlbum)
@@ -364,7 +361,7 @@ class AlbumTreeView(BaseTreeView):
def updateAlbum(self, albumId):
self.log.debug("updateAlbum, %s", albumId)
album = self.tagger.albumManager.getAlbumById(unicode(albumId))
album = self.tagger.getAlbumById(unicode(albumId))
albumItem = self.getItemFromObject(album)
albumItem.setText(0, album.getName())
albumItem.setText(1, formatTime(album.duration))