Commit 5c8e7d54 authored by Scott Wheeler's avatar Scott Wheeler

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
parent bd23685e
...@@ -215,7 +215,7 @@ bool ConfigCategoryReader::isDisabled(TagType category) const ...@@ -215,7 +215,7 @@ bool ConfigCategoryReader::isDisabled(TagType category) const
FileRenamerWidget::FileRenamerWidget(QWidget *parent) : FileRenamerWidget::FileRenamerWidget(QWidget *parent) :
FileRenamerBase(parent), CategoryReaderInterface(), FileRenamerBase(parent), CategoryReaderInterface(),
m_exampleFromFile(false), m_exampleFile(0) m_exampleFromFile(false)
{ {
QLabel *temp = new QLabel(0); QLabel *temp = new QLabel(0);
m_exampleText->setPaletteBackgroundColor(temp->paletteBackgroundColor()); m_exampleText->setPaletteBackgroundColor(temp->paletteBackgroundColor());
...@@ -293,7 +293,6 @@ void FileRenamerWidget::saveConfig() ...@@ -293,7 +293,6 @@ void FileRenamerWidget::saveConfig()
FileRenamerWidget::~FileRenamerWidget() FileRenamerWidget::~FileRenamerWidget()
{ {
delete m_exampleFile;
} }
void FileRenamerWidget::createTagRows() void FileRenamerWidget::createTagRows()
...@@ -398,9 +397,13 @@ void FileRenamerWidget::createTagRows() ...@@ -398,9 +397,13 @@ void FileRenamerWidget::createTagRows()
void FileRenamerWidget::exampleTextChanged() void FileRenamerWidget::exampleTextChanged()
{ {
kdDebug(65432) << k_funcinfo << endl;
// Just use .mp3 as an example // 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.")); m_exampleText->setText(i18n("No file selected, or selected file has no tags."));
return; return;
} }
...@@ -410,7 +413,8 @@ void FileRenamerWidget::exampleTextChanged() ...@@ -410,7 +413,8 @@ void FileRenamerWidget::exampleTextChanged()
QString FileRenamerWidget::fileCategoryValue(TagType category) const QString FileRenamerWidget::fileCategoryValue(TagType category) const
{ {
TagLib::Tag *tag = m_exampleFile->tag(); FileHandle file(m_exampleFile);
Tag *tag = file.tag();
switch(category) { switch(category) {
case Track: case Track:
...@@ -420,16 +424,16 @@ QString FileRenamerWidget::fileCategoryValue(TagType category) const ...@@ -420,16 +424,16 @@ QString FileRenamerWidget::fileCategoryValue(TagType category) const
return QString::number(tag->year()); return QString::number(tag->year());
case Title: case Title:
return TStringToQString(tag->title()); return tag->title();
case Artist: case Artist:
return TStringToQString(tag->artist()); return tag->artist();
case Album: case Album:
return TStringToQString(tag->album()); return tag->album();
case Genre: case Genre:
return TStringToQString(tag->genre()); return tag->genre();
default: default:
return QString::null; return QString::null;
...@@ -641,9 +645,7 @@ void FileRenamerWidget::exampleDialogHidden() ...@@ -641,9 +645,7 @@ void FileRenamerWidget::exampleDialogHidden()
void FileRenamerWidget::fileSelected(const QString &file) void FileRenamerWidget::fileSelected(const QString &file)
{ {
m_exampleFromFile = true; m_exampleFromFile = true;
delete m_exampleFile; m_exampleFile = file;
m_exampleFile = new TagLib::FileRef(QFile::encodeName(file));
exampleTextChanged(); exampleTextChanged();
} }
......
...@@ -415,12 +415,7 @@ private: ...@@ -415,12 +415,7 @@ private:
/// This is true if we're reading example tags from m_exampleFile. /// This is true if we're reading example tags from m_exampleFile.
bool m_exampleFromFile; bool m_exampleFromFile;
QString m_exampleFile;
/**
* This is a pointer to the FileRef holding the tags that were read from the
* user-specified file.
*/
TagLib::FileRef *m_exampleFile;
}; };
class PlaylistItem; class PlaylistItem;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment