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 53c3ae59 authored by Scott Wheeler's avatar Scott Wheeler

removing extra files

svn path=/trunk/kdemultimedia/juk/; revision=177616
parent bd3330cf
/***************************************************************************
filelist.cpp - description
-------------------
begin : Sat Feb 16 2002
copyright : (C) 2002 by Scott Wheeler
email : scott@slackorama.net
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include <klocale.h>
#include <kdebug.h>
#include <qfileinfo.h>
#include <qdir.h>
#include <qtimer.h>
#include <qapplication.h>
#include <qptrlist.h>
#include "filelist.h"
////////////////////////////////////////////////////////////////////////////////
// public members
////////////////////////////////////////////////////////////////////////////////
FileList::FileList(QWidget *parent, const char *name) : KListView(parent, name)
{
setup();
}
FileList::FileList(QString &item, QWidget *parent, const char *name) : KListView(parent, name)
{
setup();
append(item);
}
FileList::FileList(QStringList &items, QWidget *parent, const char *name) : KListView(parent, name)
{
setup();
append(items);
}
FileList::~FileList()
{
}
void FileList::append(const QString &item)
{
QApplication::setOverrideCursor(Qt::waitCursor);
appendImpl(item);
QApplication::restoreOverrideCursor();
emit(dataChanged());
}
void FileList::append(const QStringList &items)
{
QApplication::setOverrideCursor(Qt::waitCursor);
for(QStringList::ConstIterator it = items.begin(); it != items.end(); ++it)
appendImpl(*it);
QApplication::restoreOverrideCursor();
emit(dataChanged());
}
void FileList::append(FileListItem *item)
{
if(item && members.contains(item->absFilePath()) == 0) {
members.append(item->absFilePath());
(void) new FileListItem(*item, this);
}
emit(dataChanged());
}
void FileList::append(QPtrList<FileListItem> &items)
{
QPtrListIterator<FileListItem> it(items);
while(it.current()) {
append(it.current());
++it;
}
// the emit(dataChanged()) is handled in the above function
}
void FileList::remove(QPtrList<FileListItem> &items)
{
QPtrListIterator<FileListItem> it(items);
while(it.current()) {
members.remove(it.current()->absFilePath());
delete(it.current());
++it;
}
}
QPtrList<FileListItem> FileList::selectedItems()
{
QPtrList<FileListItem> list;
for(FileListItem *i = static_cast<FileListItem *>(firstChild()); i != 0; i = static_cast<FileListItem *>(i->itemBelow())) {
if(i->isSelected())
list.append(i);
}
return(list);
}
QStringList FileList::getArtistList() const
{
return(artistList);
}
QStringList FileList::getAlbumList() const
{
return(albumList);
}
////////////////////////////////////////////////////////////////////////////////
// private members
////////////////////////////////////////////////////////////////////////////////
void FileList::setup()
{
processed = 0;
extensions.append("mp3");
addColumn(i18n("Track Name"));
addColumn(i18n("Artist"));
addColumn(i18n("Album"));
addColumn(i18n("Track"));
addColumn(i18n("Genre"));
addColumn(i18n("Year"));
addColumn(i18n("Length"));
addColumn(i18n("File Name"));
setAllColumnsShowFocus(true);
setSelectionMode(QListView::Extended);
setShowSortIndicator(true);
setItemMargin(3);
setSorting(1);
}
void FileList::appendImpl(const QString &item)
{
processEvents();
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);
}
}
}
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());
(void) new FileListItem(file, this);
}
}
}
}
void FileList::processEvents()
{
if(processed == 0)
qApp->processEvents();
processed = ( processed + 1 ) % 10;
}
/***************************************************************************
filelist.h - description
-------------------
begin : Sat Feb 16 2002
copyright : (C) 2002 by Scott Wheeler
email : scott@slackorama.net
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef FILELIST_H
#define FILELIST_H
#include <klistview.h>
#include <qstringlist.h>
#include "filelistitem.h"
class FileList : public KListView
{
Q_OBJECT
public:
FileList(QWidget *parent = 0, const char *name = 0);
FileList(QString &item, QWidget *parent = 0, const char *name = 0);
FileList(QStringList &items, QWidget *parent = 0, const char *name = 0);
virtual ~FileList();
void append(const QString &item);
void append(const QStringList &items);
void append(FileListItem *item);
void append(QPtrList<FileListItem> &items);
void remove(QPtrList<FileListItem> &items);
QPtrList<FileListItem> selectedItems();
// yay for implicit sharing!
QStringList getArtistList() const;
QStringList getAlbumList() const;
private:
void setup();
void appendImpl(const QString &item);
QStringList extensions;
QStringList members;
QStringList artistList;
QStringList albumList;
void processEvents();
int processed;
signals:
void dataChanged();
};
#endif
This diff is collapsed.
/***************************************************************************
filelistitem.h - description
-------------------
begin : Sun Feb 17 2002
copyright : (C) 2002 by Scott Wheeler
email : scott@slackorama.net
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef FILELISTITEM_H
#define FILELISTITEM_H
#include <klistview.h>
#include <qfileinfo.h>
#include <qobject.h>
#include "tag.h"
#include "audiodata.h"
class FileList;
class FileListItem : public QObject, public KListViewItem
{
Q_OBJECT
public:
enum ColumnType { TrackColumn = 0, ArtistColumn = 1, AlbumColumn = 2, TrackNumberColumn = 3,
GenreColumn = 4, YearColumn = 5, LengthColumn = 6, FileNameColumn = 7 };
FileListItem(const QFileInfo &file, FileList *parent);
FileListItem(FileListItem &item, FileList *parent);
virtual ~FileListItem();
// these can't be const members because they fetch the data "on demand"
Tag *getTag();
AudioData *getAudioData();
void setFile(const QString &file);
// QFileInfo-ish methods
QString fileName() const;
QString filePath() const;
QString absFilePath() const;
QString dirPath(bool absPath = false) const;
bool isWritable() const;
public slots:
void refresh();
protected slots:
void addSibling(const FileListItem *sibling);
void removeSibling(const FileListItem *sibling);
signals:
void refreshed();
private:
class Data;
Data *getData();
int compare(QListViewItem *item, int column, bool ascending) const;
int compare(FileListItem *firstItem, FileListItem *secondItem, int column, bool ascending) const;
Data *data;
};
#endif
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