From 243aedce59fcd5bcdca13f563c6094d2d3981f8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Lalinsk=C3=BD?= Date: Tue, 5 Sep 2006 23:55:34 +0200 Subject: [PATCH] Removed AlbumManager. --- picard/albummanager.py | 68 ------------------------------------------ picard/tagger.py | 24 ++++++++++++--- picard/ui/itemviews.py | 11 +++---- 3 files changed, 24 insertions(+), 79 deletions(-) delete mode 100644 picard/albummanager.py diff --git a/picard/albummanager.py b/picard/albummanager.py deleted file mode 100644 index 1010b2f94..000000000 --- a/picard/albummanager.py +++ /dev/null @@ -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) - diff --git a/picard/tagger.py b/picard/tagger.py index 8d3c49437..10dad8547 100644 --- a/picard/tagger.py +++ b/picard/tagger.py @@ -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 diff --git a/picard/ui/itemviews.py b/picard/ui/itemviews.py index c8bc82f73..93a720fb8 100644 --- a/picard/ui/itemviews.py +++ b/picard/ui/itemviews.py @@ -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))