Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 634e518d authored by Scott Wheeler's avatar Scott Wheeler

Modified the API for FileListItemData -- this had somewhat recusive effects

svn path=/trunk/kdemultimedia/juk/; revision=149548
parent 32198be2
......@@ -71,7 +71,7 @@ void FileList::append(FileListItem *item)
{
if(item && members.contains(item->absFilePath()) == 0) {
members.append(item->absFilePath());
(void) new FileListItem(item, this);
(void) new FileListItem(*item, this);
}
}
......@@ -84,6 +84,15 @@ void FileList::append(QPtrList<QListViewItem> *items)
}
}
void FileList::remove(QPtrList<QListViewItem> *items)
{
QPtrListIterator<QListViewItem> it(*items);
while(it.current()) {
delete(it.current());
++it;
}
}
FileListItem *FileList::getSelectedItem()
{
return(dynamic_cast<FileListItem *>(currentItem()));
......@@ -117,28 +126,27 @@ void FileList::setup()
void FileList::appendImpl(QString item)
{
processEvents();
QFileInfo *file = new QFileInfo(QDir::cleanDirPath(item));
if(file->exists()) {
if(file->isDir()) {
QDir dir(file->filePath());
QFileInfo file(QDir::cleanDirPath(item));
if(file.exists()) {
if(file.isDir()) {
QDir dir(file.filePath());
QStringList dirContents=dir.entryList();
for(QStringList::Iterator it = dirContents.begin(); it != dirContents.end(); ++it) {
if(*it != "." && *it != "..") {
appendImpl(file->filePath() + QDir::separator() + *it);
appendImpl(file.filePath() + QDir::separator() + *it);
}
}
}
else {
// QFileInfo::extension() doesn't always work, so I'm getting old-school on this. -- fixed in Qt 3
// QString extension = file->filePath().right(file->filePath().length() - (file->filePath().findRev(".") + 1));
QString extension = file->extension(false);
if(extensions.contains(extension) > 0 && members.contains(file->absFilePath()) == 0) {
members.append(file->absFilePath());
// QString extension = file.filePath().right(file.filePath().length() - (file.filePath().findRev(".") + 1));
QString extension = file.extension(false);
if(extensions.contains(extension) > 0 && members.contains(file.absFilePath()) == 0) {
members.append(file.absFilePath());
(void) new FileListItem(file, this);
}
}
}
delete(file);
}
////////////////////////////////////////////////////////////////////////////////
......
......@@ -37,6 +37,8 @@ public:
void append(QStringList *items);
void append(FileListItem *item);
void append(QPtrList<QListViewItem> *items);
void remove(QPtrList<QListViewItem> *items);
FileListItem *getSelectedItem();
......
......@@ -23,21 +23,19 @@
// public methods
////////////////////////////////////////////////////////////////////////////////
FileListItem::FileListItem(QFileInfo *file, KListView *parent) : QObject(parent), KListViewItem(parent)
FileListItem::FileListItem(QFileInfo &file, KListView *parent) : QObject(parent), KListViewItem(parent)
{
data = new FileListItemData(file);
refresh();
}
FileListItem::FileListItem(FileListItem *item, KListView *parent) : QObject(parent), KListViewItem(parent)
FileListItem::FileListItem(FileListItem &item, KListView *parent) : QObject(parent), KListViewItem(parent)
{
if(item) {
data = item->getData()->newUser();
connect(item, SIGNAL(destroyed(FileListItem *)), this, SLOT(parentDestroyed(FileListItem *)));
addSibling(item);
refresh();
}
data = item.getData()->newUser();
// connect(&item, SIGNAL(destroyed(FileListItem *)), this, SLOT(parentDestroyed(FileListItem *)));
addSibling(&item);
refresh();
}
FileListItem::~FileListItem()
......
......@@ -33,8 +33,8 @@ public:
enum ColumnType { TrackColumn = 0, ArtistColumn = 1, AlbumColumn = 2, TrackNumberColumn = 3,
GenreColumn = 4, YearColumn = 5, LengthColumn = 6, FileNameColumn = 7 };
FileListItem(QFileInfo *file, KListView *parent);
FileListItem(FileListItem *item, KListView *parent);
FileListItem(QFileInfo &file, KListView *parent);
FileListItem(FileListItem &item, KListView *parent);
~FileListItem();
FileListItemData *getData();
......
......@@ -21,7 +21,7 @@
// public methods
////////////////////////////////////////////////////////////////////////////////
FileListItemData::FileListItemData(QFileInfo *file) : QFileInfo(*file)
FileListItemData::FileListItemData(QFileInfo &file) : QFileInfo(file)
{
referenceCount = 1;
......@@ -46,8 +46,7 @@ FileListItemData *FileListItemData::newUser()
void FileListItemData::deleteUser()
{
referenceCount--;
if(referenceCount <= 0)
if(--referenceCount == 0)
delete(this);
}
......
......@@ -20,6 +20,8 @@
#include <qfileinfo.h>
#include <stdlib.h>
#include "tag.h"
#include "cacheitem.h"
#include "audiodata.h"
......@@ -27,7 +29,7 @@
class FileListItemData : public QFileInfo
{
public:
FileListItemData(QFileInfo *file);
FileListItemData(QFileInfo &file);
~FileListItemData();
FileListItemData *newUser();
......
......@@ -58,6 +58,13 @@ void PlaylistWidget::add(QPtrList<QListViewItem> *items)
playlistList->append(items);
}
void PlaylistWidget::remove(QPtrList<QListViewItem> *items)
{
playlistList->remove(items);
}
FileList *PlaylistWidget::getPlaylistList()
{
return(playlistList);
......
......@@ -36,6 +36,8 @@ public:
void add(FileListItem *item);
void add(QPtrList<QListViewItem> *items);
void remove(QPtrList<QListViewItem> *items);
FileList *getPlaylistList();
QPtrList<QListViewItem> *getSelectedItems();
FileListItem *firstItem();
......
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