From 5c8e7d548b152668d500687b977d9f4a9648294f Mon Sep 17 00:00:00 2001 From: Scott Wheeler Date: Tue, 2 Nov 2004 00:52:45 +0000 Subject: [PATCH] This is the more canonical JuK way of doing things -- leave the TagLib handling code to our already existing abstractions. svn path=/trunk/kdemultimedia/juk/; revision=359727 --- filerenamer.cpp | 24 +++++++++++++----------- filerenamer.h | 7 +------ 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/filerenamer.cpp b/filerenamer.cpp index fe98ab54..206f3a9d 100644 --- a/filerenamer.cpp +++ b/filerenamer.cpp @@ -215,7 +215,7 @@ bool ConfigCategoryReader::isDisabled(TagType category) const FileRenamerWidget::FileRenamerWidget(QWidget *parent) : FileRenamerBase(parent), CategoryReaderInterface(), - m_exampleFromFile(false), m_exampleFile(0) + m_exampleFromFile(false) { QLabel *temp = new QLabel(0); m_exampleText->setPaletteBackgroundColor(temp->paletteBackgroundColor()); @@ -293,7 +293,6 @@ void FileRenamerWidget::saveConfig() FileRenamerWidget::~FileRenamerWidget() { - delete m_exampleFile; } void FileRenamerWidget::createTagRows() @@ -398,9 +397,13 @@ void FileRenamerWidget::createTagRows() void FileRenamerWidget::exampleTextChanged() { + kdDebug(65432) << k_funcinfo << endl; + // Just use .mp3 as an example - if(m_exampleFromFile && (!m_exampleFile || !m_exampleFile->file())) { + if(m_exampleFromFile && (m_exampleFile.isEmpty() || + !FileHandle(m_exampleFile).tag()->isValid())) + { m_exampleText->setText(i18n("No file selected, or selected file has no tags.")); return; } @@ -410,7 +413,8 @@ void FileRenamerWidget::exampleTextChanged() QString FileRenamerWidget::fileCategoryValue(TagType category) const { - TagLib::Tag *tag = m_exampleFile->tag(); + FileHandle file(m_exampleFile); + Tag *tag = file.tag(); switch(category) { case Track: @@ -420,16 +424,16 @@ QString FileRenamerWidget::fileCategoryValue(TagType category) const return QString::number(tag->year()); case Title: - return TStringToQString(tag->title()); + return tag->title(); case Artist: - return TStringToQString(tag->artist()); + return tag->artist(); case Album: - return TStringToQString(tag->album()); + return tag->album(); case Genre: - return TStringToQString(tag->genre()); + return tag->genre(); default: return QString::null; @@ -641,9 +645,7 @@ void FileRenamerWidget::exampleDialogHidden() void FileRenamerWidget::fileSelected(const QString &file) { m_exampleFromFile = true; - delete m_exampleFile; - m_exampleFile = new TagLib::FileRef(QFile::encodeName(file)); - + m_exampleFile = file; exampleTextChanged(); } diff --git a/filerenamer.h b/filerenamer.h index 7db628e7..7502567b 100644 --- a/filerenamer.h +++ b/filerenamer.h @@ -415,12 +415,7 @@ private: /// This is true if we're reading example tags from m_exampleFile. bool m_exampleFromFile; - - /** - * This is a pointer to the FileRef holding the tags that were read from the - * user-specified file. - */ - TagLib::FileRef *m_exampleFile; + QString m_exampleFile; }; class PlaylistItem; -- GitLab