Commit 4ae2f5f8 authored by Scott Wheeler's avatar Scott Wheeler

Some more stuff from the PlaylistItem class that's been ported over to here.

svn path=/trunk/kdemultimedia/juk/; revision=293017
parent 34b57e16
......@@ -15,6 +15,8 @@
* *
***************************************************************************/
#include <qfileinfo.h>
#include "filehandle.h"
#include "tag.h"
......@@ -39,7 +41,9 @@ public:
FileHandlePrivate() :
tag(0) {}
Tag *tag;
mutable Tag *tag;
QFileInfo fileInfo;
mutable QString absFilePath;
};
////////////////////////////////////////////////////////////////////////////////
......@@ -56,17 +60,53 @@ FileHandle::FileHandle(const FileHandle &f) : d(f.d)
d->ref();
}
FileHandle::FileHandle(const QFileInfo &info, const QString &path)
{
d = new FileHandlePrivate;
d->fileInfo = info;
d->absFilePath = path.isNull() ? info.absFilePath() : path;
}
FileHandle::FileHandle(const QString &path)
{
d = new FileHandlePrivate;
d->absFilePath = path;
d->fileInfo.setFile(path);
}
FileHandle::~FileHandle()
{
if(d->deref())
delete d;
}
void FileHandle::refresh()
{
d->fileInfo.refresh();
delete d->tag;
d->tag = Tag::createTag(d->absFilePath);
}
Tag *FileHandle::tag() const
{
if(!d->tag)
d->tag = Tag::createTag(d->absFilePath);
return d->tag;
}
QString FileHandle::absFilePath() const
{
if(d->absFilePath.isNull())
d->absFilePath = d->fileInfo.absFilePath();
return d->absFilePath;
}
const QFileInfo &FileHandle::fileInfo() const
{
return d->fileInfo;
}
FileHandle &FileHandle::operator=(const FileHandle &f)
{
if(&f == this)
......
......@@ -30,12 +30,20 @@ class FileHandle
public:
FileHandle();
FileHandle(const FileHandle &f);
FileHandle(const QFileInfo &info, const QString &path = QString::null);
FileHandle(const QString &path);
~FileHandle();
/**
* Forces the FileHandle to reread its information from the disk.
*/
void refresh();
Tag *tag() const;
QString absFilePath() const;
const QFileInfo &fileInfo() const;
FileHandle &operator=(const FileHandle &f);
bool operator==(const FileHandle &f) const;
private:
......
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