Minors modification on TagFetcher. Fixes issue #1346

This commit is contained in:
Arnaud Bienner 2011-01-24 17:03:36 +00:00
parent ed3719a950
commit 03df8195b0
6 changed files with 18 additions and 23 deletions

View File

@ -110,15 +110,15 @@ TagFetcherItem::TagFetcherItem(const QString& _filename, int _fileId, tunepimp_t
fileId_(_fileId),
pimp_(_pimp),
network_(_network),
already_tried_to_recognize(false)
already_tried_to_recognize_(false)
{ }
void TagFetcherItem::Unrecognized() {
if(already_tried_to_recognize) {
if(already_tried_to_recognize_) {
// We already tried to recognize this music and, apparently, nothing has been found: stopping here
emit FetchFinishedSignal(fileId_);
} else {
already_tried_to_recognize = true;
already_tried_to_recognize_ = true;
char trm[255];
trm[0] = 0;
track_t track = tp_GetTrack(pimp_, fileId_);

View File

@ -93,7 +93,7 @@ class TagFetcherItem : public QObject {
NetworkAccessManager *network_;
char puid_[255];
SongList songs_fetched_;
bool already_tried_to_recognize; // to prevent infinite loops while always trying to recognize a file
bool already_tried_to_recognize_; // to prevent infinite loops while always trying to recognize a file
#endif // HAVE_LIBTUNEPIMP
};

View File

@ -56,7 +56,7 @@ EditTagDialog::EditTagDialog(QWidget* parent)
cover_loader_(new BackgroundThreadImplementation<AlbumCoverLoader, AlbumCoverLoader>(this)),
cover_art_id_(0),
cover_art_is_set_(false),
resultsDialog_(new TrackSelectionDialog(this))
results_dialog_(new TrackSelectionDialog(this))
{
cover_loader_->Start(true);
cover_loader_->Worker()->SetDefaultOutputImage(QImage(":nocover.png"));
@ -65,7 +65,7 @@ EditTagDialog::EditTagDialog(QWidget* parent)
#ifdef HAVE_LIBTUNEPIMP
connect(tag_fetcher_, SIGNAL(FetchFinished(QString, SongList)),
this, SLOT(FetchTagFinished(QString, SongList)), Qt::QueuedConnection);
connect(resultsDialog_, SIGNAL(SongChoosen(QString, Song)), SLOT(FetchTagSongChoosen(QString, Song)));
connect(results_dialog_, SIGNAL(SongChoosen(QString, Song)), SLOT(FetchTagSongChoosen(QString, Song)));
#endif
ui_->setupUi(this);
@ -711,13 +711,10 @@ void EditTagDialog::FetchTagFinished(const QString& filename, const SongList& so
// If no songs have been guessed, just display a message
if(songs_guessed.empty()) {
QMessageBox messageBox(this);
messageBox.setWindowTitle(tr("Sorry"));
messageBox.setText(tr("Clementine was unable to find results for this file"));
messageBox.exec();
QMessageBox::information(this, tr("Sorry"), tr("Clementine was unable to find results for this file"));
} else { // Else, display song's tags selection dialog only if edittagdialog is still opened
resultsDialog_->Init(filename, songs_guessed);
resultsDialog_->show();
results_dialog_->Init(filename, songs_guessed);
results_dialog_->show();
}
}
#endif
@ -737,11 +734,12 @@ void EditTagDialog::FetchTagSongChoosen(const QString& filename, const Song& son
return;
}
if(song_choosen.title() != "")
// Fill tags' fields
if(!song_choosen.title().isEmpty())
ui_->title->set_text(song_choosen.title());
if(song_choosen.album() != "")
if(!song_choosen.album().isEmpty())
ui_->album->set_text(song_choosen.album());
if(song_choosen.album() != "")
if(!song_choosen.album().isEmpty())
ui_->artist->set_text(song_choosen.artist());
if(song_choosen.track() > 0)
ui_->track->set_text(QString::number(song_choosen.track()));

View File

@ -169,7 +169,7 @@ private:
QPushButton* previous_button_;
QPushButton* next_button_;
TrackSelectionDialog *resultsDialog_;
TrackSelectionDialog *results_dialog_;
};
#endif // EDITTAGDIALOG_H

View File

@ -30,7 +30,7 @@ TrackSelectionDialog::TrackSelectionDialog(QWidget *parent)
}
TrackSelectionDialog::~TrackSelectionDialog() {
Clean();
ui_->resultsTreeWidget->clear();
delete ui_;
}
@ -41,6 +41,9 @@ void TrackSelectionDialog::Init(const QString& filename, const SongList& songs)
// Set filename
ui_->filenameLabel->setText(current_filename_); //TODO: use basefilename, it's nicer
// Clear tree widget
ui_->resultsTreeWidget->clear();
// Fill tree view with songs
int song_index = 0;
foreach(const Song& song, songs) {
@ -64,11 +67,6 @@ void TrackSelectionDialog::Init(const QString& filename, const SongList& songs)
ui_->resultsTreeWidget->setColumnWidth(3, 50); // Track column
}
void TrackSelectionDialog::Clean() {
// Remove and deleted all items
ui_->resultsTreeWidget->clear();
}
void TrackSelectionDialog::accept() {
QDialog::accept();
QTreeWidgetItem *item =ui_->resultsTreeWidget->currentItem();

View File

@ -33,7 +33,6 @@ public:
~TrackSelectionDialog();
void Init(const QString& filename, const SongList& songs);
void Clean();
void accept();