1142
by Scott Wheeler
Don't use the external TRM tool but instead use libtunepimp since it handles |
1 |
/***************************************************************************
|
2 |
begin : Tue Aug 3 2004
|
|
3 |
copyright : (C) 2004 by Scott Wheeler
|
|
4 |
email : wheeler@kde.org
|
|
5 |
***************************************************************************/
|
|
6 |
||
7 |
/***************************************************************************
|
|
8 |
* *
|
|
9 |
* This program is free software; you can redistribute it and/or modify *
|
|
10 |
* it under the terms of the GNU General Public License as published by *
|
|
11 |
* the Free Software Foundation; either version 2 of the License, or *
|
|
12 |
* (at your option) any later version. *
|
|
13 |
* *
|
|
14 |
***************************************************************************/
|
|
15 |
||
16 |
#include "musicbrainzquery.h" |
|
1696
by Tim Beaulen
Less use of deprecated functions. |
17 |
#ifdef HAVE_TUNEPIMP // Silence warning when HAVE_TUNEPIMP is not defined. |
1575
by Richard Lärkäng
Rename from musicbrainz to tunepimp in configure.in.in, defines etc |
18 |
#if HAVE_TUNEPIMP
|
401
by Zack Rusin
Adding MusicBrainz support :) |
19 |
|
887
by Scott Wheeler
PlaylistItem and CollectionListItem are no longer QObject. This meant moving |
20 |
#include "trackpickerdialog.h" |
1142
by Scott Wheeler
Don't use the external TRM tool but instead use libtunepimp since it handles |
21 |
#include "tag.h" |
887
by Scott Wheeler
PlaylistItem and CollectionListItem are no longer QObject. This meant moving |
22 |
#include "collectionlist.h" |
1222
by Michael Pyne
Implement bug 61340 (Add undo support for multi-tagging). |
23 |
#include "tagtransactionmanager.h" |
401
by Zack Rusin
Adding MusicBrainz support :) |
24 |
|
1774.1.1
by Kevin Ottens
Porting to KXmlGuiWindow. |
25 |
#include <kxmlguiwindow.h> |
887
by Scott Wheeler
PlaylistItem and CollectionListItem are no longer QObject. This meant moving |
26 |
#include <kapplication.h> |
27 |
#include <kstatusbar.h> |
|
420
by Frerich Raabe
- Print some progress messages in the status bar so that I can see it's |
28 |
#include <klocale.h> |
401
by Zack Rusin
Adding MusicBrainz support :) |
29 |
#include <kdebug.h> |
30 |
||
1791
by Michael Pyne
Fairly large overhaul of the JuK codebase to beat out a lot of the Qt 3 stuff. |
31 |
#include <QList> |
32 |
#include <QFileInfo> |
|
1142
by Scott Wheeler
Don't use the external TRM tool but instead use libtunepimp since it handles |
33 |
|
34 |
MusicBrainzLookup::MusicBrainzLookup(const FileHandle &file) : |
|
35 |
KTRMLookup(file.absFilePath()), |
|
1145
by Scott Wheeler
Small cleanups. Remove some debugging output; make the message display for |
36 |
m_file(file) |
37 |
{
|
|
38 |
message(i18n("Querying MusicBrainz server...")); |
|
39 |
}
|
|
1142
by Scott Wheeler
Don't use the external TRM tool but instead use libtunepimp since it handles |
40 |
|
41 |
void MusicBrainzLookup::recognized() |
|
42 |
{
|
|
43 |
KTRMLookup::recognized(); |
|
44 |
confirmation(); |
|
1474
by Scott Wheeler
Fix memory leak. |
45 |
delete this; |
1142
by Scott Wheeler
Don't use the external TRM tool but instead use libtunepimp since it handles |
46 |
}
|
47 |
||
48 |
void MusicBrainzLookup::unrecognized() |
|
49 |
{
|
|
50 |
KTRMLookup::unrecognized(); |
|
51 |
message(i18n("No matches found.")); |
|
1474
by Scott Wheeler
Fix memory leak. |
52 |
delete this; |
1142
by Scott Wheeler
Don't use the external TRM tool but instead use libtunepimp since it handles |
53 |
}
|
54 |
||
55 |
void MusicBrainzLookup::collision() |
|
56 |
{
|
|
57 |
KTRMLookup::collision(); |
|
58 |
confirmation(); |
|
1474
by Scott Wheeler
Fix memory leak. |
59 |
delete this; |
1142
by Scott Wheeler
Don't use the external TRM tool but instead use libtunepimp since it handles |
60 |
}
|
61 |
||
62 |
void MusicBrainzLookup::error() |
|
63 |
{
|
|
64 |
KTRMLookup::error(); |
|
1194
by Scott Wheeler
Give a more informative error message. |
65 |
message(i18n("Error connecting to MusicBrainz server.")); |
1474
by Scott Wheeler
Fix memory leak. |
66 |
delete this; |
1142
by Scott Wheeler
Don't use the external TRM tool but instead use libtunepimp since it handles |
67 |
}
|
68 |
||
69 |
void MusicBrainzLookup::message(const QString &s) const |
|
70 |
{
|
|
1774.1.1
by Kevin Ottens
Porting to KXmlGuiWindow. |
71 |
KXmlGuiWindow *w = static_cast<KXmlGuiWindow *>(kapp->mainWidget()); |
1145
by Scott Wheeler
Small cleanups. Remove some debugging output; make the message display for |
72 |
w->statusBar()->message(QString("%1 (%2)").arg(s).arg(m_file.fileInfo().fileName()), 3000); |
1142
by Scott Wheeler
Don't use the external TRM tool but instead use libtunepimp since it handles |
73 |
}
|
74 |
||
75 |
void MusicBrainzLookup::confirmation() |
|
76 |
{
|
|
1147
by Scott Wheeler
Queue the MusicBrainz confirmation dialogs so that multiple dialogs don't |
77 |
// Here we do a bit of queuing to make sure that we don't pop up multiple
|
78 |
// instances of the confirmation dialog at once.
|
|
79 |
||
1791
by Michael Pyne
Fairly large overhaul of the JuK codebase to beat out a lot of the Qt 3 stuff. |
80 |
static QList< QPair<FileHandle, KTRMResultList> > queue; |
1147
by Scott Wheeler
Queue the MusicBrainz confirmation dialogs so that multiple dialogs don't |
81 |
|
1142
by Scott Wheeler
Don't use the external TRM tool but instead use libtunepimp since it handles |
82 |
if(results().isEmpty()) |
83 |
return; |
|
84 |
||
1147
by Scott Wheeler
Queue the MusicBrainz confirmation dialogs so that multiple dialogs don't |
85 |
if(!queue.isEmpty()) { |
1148
by Scott Wheeler
CVS_SILENT oops -- those were tabs |
86 |
queue.append(qMakePair(m_file, results())); |
87 |
return; |
|
1147
by Scott Wheeler
Queue the MusicBrainz confirmation dialogs so that multiple dialogs don't |
88 |
}
|
89 |
||
90 |
queue.append(qMakePair(m_file, results())); |
|
91 |
||
92 |
while(!queue.isEmpty()) { |
|
1437
by Scott Wheeler
Reverting this one too. (a) Didn't compile, (b) if this actually did fix a crash |
93 |
QPair<FileHandle, KTRMResultList> item = queue.first(); |
94 |
FileHandle file = item.first; |
|
95 |
KTRMResultList results = item.second; |
|
1147
by Scott Wheeler
Queue the MusicBrainz confirmation dialogs so that multiple dialogs don't |
96 |
TrackPickerDialog dialog(file.fileInfo().fileName(), results); |
97 |
||
1437
by Scott Wheeler
Reverting this one too. (a) Didn't compile, (b) if this actually did fix a crash |
98 |
if(dialog.exec() == QDialog::Accepted && !dialog.result().isEmpty()) { |
99 |
KTRMResult result = dialog.result(); |
|
1222
by Michael Pyne
Implement bug 61340 (Add undo support for multi-tagging). |
100 |
Tag *tag = TagTransactionManager::duplicateTag(file.tag()); |
1437
by Scott Wheeler
Reverting this one too. (a) Didn't compile, (b) if this actually did fix a crash |
101 |
|
102 |
if(!result.title().isEmpty()) |
|
103 |
tag->setTitle(result.title()); |
|
104 |
if(!result.artist().isEmpty()) |
|
105 |
tag->setArtist(result.artist()); |
|
106 |
if(!result.album().isEmpty()) |
|
107 |
tag->setAlbum(result.album()); |
|
108 |
if(result.track() != 0) |
|
109 |
tag->setTrack(result.track()); |
|
110 |
if(result.year() != 0) |
|
111 |
tag->setYear(result.year()); |
|
112 |
||
113 |
PlaylistItem *item = CollectionList::instance()->lookup(file.absFilePath()); |
|
114 |
TagTransactionManager::instance()->changeTagOnItem(item, tag); |
|
115 |
TagTransactionManager::instance()->commit(); |
|
116 |
}
|
|
1791
by Michael Pyne
Fairly large overhaul of the JuK codebase to beat out a lot of the Qt 3 stuff. |
117 |
|
1147
by Scott Wheeler
Queue the MusicBrainz confirmation dialogs so that multiple dialogs don't |
118 |
queue.pop_front(); |
1142
by Scott Wheeler
Don't use the external TRM tool but instead use libtunepimp since it handles |
119 |
}
|
120 |
}
|
|
401
by Zack Rusin
Adding MusicBrainz support :) |
121 |
|
122 |
#endif
|
|
1696
by Tim Beaulen
Less use of deprecated functions. |
123 |
#endif
|
1562
by Michael Pyne
Since we're standardizing the source style, figured I'd throw in the Big Huge Vim Modeline |
124 |
|
125 |
// vim: set et sw=4 tw=0 sta:
|