Commit 0806bed8 authored by Scott Wheeler's avatar Scott Wheeler

Ok, *actually* fixing resolving of symlinks now; not just in theory.

CCMAIL:lauri@kde.org

svn path=/trunk/kdemultimedia/juk/; revision=211668
parent ce756500
......@@ -71,11 +71,12 @@ CollectionListItem *CollectionList::lookup(const QString &file)
PlaylistItem *CollectionList::createItem(const QFileInfo &file, QListViewItem *)
{
QString path = file.absFilePath();
if(m_itemsDict.find(path))
QString filePath = resolveSymLinks(file);
if(m_itemsDict.find(filePath))
return 0;
return new CollectionListItem(file, path);
return new CollectionListItem(file, filePath);
}
////////////////////////////////////////////////////////////////////////////////
......@@ -152,16 +153,6 @@ void CollectionList::contentsDragMoveEvent(QDragMoveEvent *e)
e->accept(false);
}
void CollectionList::addToDict(const QString &file, CollectionListItem *item)
{
m_itemsDict.replace(file, item);
}
void CollectionList::removeFromDict(const QString &file)
{
m_itemsDict.remove(file);
}
void CollectionList::addArtist(const QString &artist)
{
// Do a bit of caching since there will very often be "two in a row" insertions.
......@@ -220,7 +211,7 @@ CollectionListItem::~CollectionListItem()
{
CollectionList *l = CollectionList::instance();
if(l)
l->removeFromDict(data()->absFilePath());
l->removeFromDict(Playlist::resolveSymLinks(*data()));
}
void CollectionListItem::addChildItem(PlaylistItem *child)
......
......@@ -68,8 +68,8 @@ protected:
virtual void contentsDragMoveEvent(QDragMoveEvent *e);
// These methods are used by CollectionListItem, which is a friend class.
void addToDict(const QString &file, CollectionListItem *item);
void removeFromDict(const QString &file);
void addToDict(const QString &file, CollectionListItem *item) { m_itemsDict.replace(file, item); }
void removeFromDict(const QString &file) { m_itemsDict.remove(file); }
/**
* This checks to see if the artist given is in the artist list maintained
......
......@@ -394,14 +394,7 @@ void Playlist::contentsDragMoveEvent(QDragMoveEvent *e)
PlaylistItem *Playlist::createItem(const QFileInfo &file, QListViewItem *after)
{
QString filePath;
if(!file.isSymLink())
filePath = file.absFilePath();
else {
QFileInfo linkFile(file.readLink());
filePath = linkFile.absFilePath();
}
QString filePath = resolveSymLinks(file);
CollectionListItem *item = CollectionList::instance()->lookup(filePath);
......@@ -455,6 +448,22 @@ bool Playlist::isColumnVisible(int c) const
return false;
}
QString Playlist::resolveSymLinks(const QFileInfo &file)
{
if(!file.isSymLink())
return file.absFilePath();
else {
QString linkFileName = file.readLink();
QFileInfo linkFile;
if(linkFileName.startsWith("/"))
linkFile.setFile(linkFileName);
else
linkFile.setFile(file.dirPath(true) + QDir::separator() + linkFileName);
return linkFile.absFilePath();
}
}
////////////////////////////////////////////////////////////////////////////////
// private m_members
////////////////////////////////////////////////////////////////////////////////
......
......@@ -148,7 +148,9 @@ protected:
virtual void contentsDropEvent(QDropEvent *e);
virtual void contentsDragMoveEvent(QDragMoveEvent *e);
PlaylistSplitter *playlistSplitter() const { return m_splitter; }
static QString resolveSymLinks(const QFileInfo &file);
signals:
/**
* This signal is connected to PlaylistItem::refreshed() in the
......
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