Commit 23bcfa4c authored by Scott Wheeler's avatar Scott Wheeler

Redid the indenting in everything using the kdesdk Emacs script.

svn path=/trunk/kdemultimedia/juk/; revision=158611
parent 156172ca
/***************************************************************************
AudioData.cpp is a modified version of fileinfo.cpp which is a part of
Mp3Kult (C) 2001 by Stefano Brustia (hio@lombardiacom.it) which is
AudioData.cpp is a modified version of fileinfo.cpp which is a part of
Mp3Kult (C) 2001 by Stefano Brustia (hio@lombardiacom.it) which is
available at:
http://mp3kult.sourceforge.net/
fileinfo.cpp was modified to just include header information instead of
fileinfo.cpp was modified to just include header information instead of
header and id3 information. These changes were made by Scott Wheeler
(scott@slackorama.net) on 1/13/2002 based on Mp3Kult v0.5.
***************************************************************************/
***************************************************************************/
/***************************************************************************
* This program is free software; you can redistribute it and/or modify *
......@@ -25,17 +25,17 @@
unsigned int bitrates[3][3][15] =
{
{
{0, 32, 64, 96, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448},
{0, 32, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384},
{0, 32, 64, 96, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448},
{0, 32, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384},
{0, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320}
},
{
{0, 32, 48, 56, 64, 80, 96, 112, 128, 144, 160, 176, 192, 224, 256},
{0, 32, 48, 56, 64, 80, 96, 112, 128, 144, 160, 176, 192, 224, 256},
{0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160},
{0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160}
},
{
{0, 32, 48, 56, 64, 80, 96, 112, 128, 144, 160, 176, 192, 224, 256},
{0, 32, 48, 56, 64, 80, 96, 112, 128, 144, 160, 176, 192, 224, 256},
{0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160},
{0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160}
}};
......@@ -48,175 +48,175 @@ unsigned int s_freq[3][4] =
};
static const char *mode_names[5] =
{"Stereo", "Joint Stereo", "Dual Ch", "Mono", "Multi Ch"};
{"Stereo", "Joint Stereo", "Dual Ch", "Mono", "Multi Ch"};
const char *layer_names[3] =
{"I", "II", "III"};
{"I", "II", "III"};
const char *version_names[3] =
{"MPEG-1", "MPEG-2 LSF", "MPEG-2.5"};
{"MPEG-1", "MPEG-2 LSF", "MPEG-2.5"};
const char *version_nums[3] =
{"1", "2", "2.5"};
{"1", "2", "2.5"};
AudioData::AudioData(const char* filein)
{
success = false;
fileglob = strdup(filein);
lengthchar = 0;
FILE* file;
if ((file = fopen(filein, "r")))
{
success=readLayerInfo(file);
fclose(file);
}
else // File isn't readable
{
success = false;
}
success = false;
fileglob = strdup(filein);
lengthchar = 0;
FILE* file;
if ((file = fopen(filein, "r")))
{
success=readLayerInfo(file);
fclose(file);
}
else // File isn't readable
{
success = false;
}
}
AudioData::~AudioData()
{
free(fileglob);
if(lengthchar)
free(lengthchar);
free(fileglob);
if(lengthchar)
free(lengthchar);
}
bool AudioData::readLayerInfo (FILE* file)
{
unsigned char buf[4];
unsigned long head;
struct stat fi;
fstat(fileno(file), &fi);
filelen = fi.st_size;
fseek(file, 0, SEEK_SET);
if (fread(buf, 1, 4, file) != 4)
return false;
head = ((unsigned long) buf[0] << 24) | ((unsigned long) buf[1] << 16) |
((unsigned long) buf[2] << 8) | ((unsigned long) buf[3]);
while (!headCheck(head))
{
head <<= 8;
if (fread(buf, 1, 1, file) != 1)
{
return false;
}
head |= buf[0];
}
switch (((head >> 19) & 0x3) )
{
case 3:
version = 0;
break;
case 2:
version = 1;
break;
case 0:
version = 2;
break;
default:
return false;
}
layer = 4 - ((head >> 17) & 3);
error_protection = ((head >> 16) & 0x1) ^ 0x1;
bitrate_index = ((head >> 12) & 0xf);
sampling_frequency = ((head >> 10) & 0x3);
padding = ((head >> 9) & 0x1);
extension = ((head >> 8) & 0x1);
mode = ((head >> 6) & 0x3);
mode_ext = ((head >> 4) & 0x3);
copyright = ((head >> 3) & 0x1);
original = ((head >> 2) & 0x1);
emphasis = head & 0x3;
if (!bitrate_index)
return false;
length = filelen / ((getBitrate()) * 125);
return true;
unsigned char buf[4];
unsigned long head;
struct stat fi;
fstat(fileno(file), &fi);
filelen = fi.st_size;
fseek(file, 0, SEEK_SET);
if (fread(buf, 1, 4, file) != 4)
return false;
head = ((unsigned long) buf[0] << 24) | ((unsigned long) buf[1] << 16) |
((unsigned long) buf[2] << 8) | ((unsigned long) buf[3]);
while (!headCheck(head))
{
head <<= 8;
if (fread(buf, 1, 1, file) != 1)
{
return false;
}
head |= buf[0];
}
switch (((head >> 19) & 0x3) )
{
case 3:
version = 0;
break;
case 2:
version = 1;
break;
case 0:
version = 2;
break;
default:
return false;
}
layer = 4 - ((head >> 17) & 3);
error_protection = ((head >> 16) & 0x1) ^ 0x1;
bitrate_index = ((head >> 12) & 0xf);
sampling_frequency = ((head >> 10) & 0x3);
padding = ((head >> 9) & 0x1);
extension = ((head >> 8) & 0x1);
mode = ((head >> 6) & 0x3);
mode_ext = ((head >> 4) & 0x3);
copyright = ((head >> 3) & 0x1);
original = ((head >> 2) & 0x1);
emphasis = head & 0x3;
if (!bitrate_index)
return false;
length = filelen / ((getBitrate()) * 125);
return true;
}
bool AudioData::headCheck(unsigned long head)
{
if ((head & 0xffe00000) != 0xffe00000)
return false;
if (!((head >> 17) & 3))
return false;
if (((head >> 12) & 0xf) == 0xf)
return false;
if (!((head >> 12) & 0xf))
return false;
if (((head >> 10) & 0x3) == 0x3)
return false;
if (((head >> 19) & 1) == 1 && ((head >> 17) & 3) == 3 &&
((head >> 16) & 1) == 1)
return false;
if ((head & 0xffff0000) == 0xfffe0000)
return false;
return true;
if ((head & 0xffe00000) != 0xffe00000)
return false;
if (!((head >> 17) & 3))
return false;
if (((head >> 12) & 0xf) == 0xf)
return false;
if (!((head >> 12) & 0xf))
return false;
if (((head >> 10) & 0x3) == 0x3)
return false;
if (((head >> 19) & 1) == 1 && ((head >> 17) & 3) == 3 &&
((head >> 16) & 1) == 1)
return false;
if ((head & 0xffff0000) == 0xfffe0000)
return false;
return true;
}
int AudioData::getBitrate(){
return (bitrates[version][layer - 1][bitrate_index]);
return (bitrates[version][layer - 1][bitrate_index]);
}
int AudioData::getSamplerate(){
return (s_freq[version][sampling_frequency]);
return (s_freq[version][sampling_frequency]);
}
const char* AudioData::getMpegver(){
return (version_names[version]);
return (version_names[version]);
}
int AudioData::getLayer() {
return layer;
return layer;
}
const char* AudioData::getMode(int mode)
{
if ((mode >= 0) && (mode < 5))
return (mode_names[mode]);
if ((mode >= 0) && (mode < 5))
return (mode_names[mode]);
return "Stereo";
return "Stereo";
}
int AudioData::getMode()
{
return mode;
return mode;
}
int AudioData::getLength() {
return length;
return length;
}
char* AudioData::getLengthChar() {
int min, sec;
char buf[6];
min=length/60;
sec=length%60;
/* if (sec < 10)
sprintf (buf, "%d:0%d", min, sec);
else */
sprintf (buf, "%d:%02d", min, sec);
lengthchar=strdup (buf);
return lengthchar;
int min, sec;
char buf[6];
min=length/60;
sec=length%60;
/* if (sec < 10)
sprintf (buf, "%d:0%d", min, sec);
else */
sprintf (buf, "%d:%02d", min, sec);
lengthchar=strdup (buf);
return lengthchar;
}
int AudioData::getSize() {
return filelen;
return filelen;
}
bool AudioData::getResult()
{
return success;
return success;
}
/***************************************************************************
AudioData.h is a modified version of fileinfo.h which is a part of
Mp3Kult (C) 2001 by Stefano Brustia (hio@lombardiacom.it) which is
AudioData.h is a modified version of fileinfo.h which is a part of
Mp3Kult (C) 2001 by Stefano Brustia (hio@lombardiacom.it) which is
available at:
http://mp3kult.sourceforge.net/
fileinfo.h was modified to just include header information instead of
fileinfo.h was modified to just include header information instead of
header and id3 information. These changes were made by Scott Wheeler
(scott@slackorama.net) on 1/13/2002 based on Mp3Kult v0.5.
***************************************************************************/
***************************************************************************/
/***************************************************************************
* This program is free software; you can redistribute it and/or modify *
......@@ -29,43 +29,43 @@ class AudioData
{
public:
AudioData(const char* filein);
~AudioData();
AudioData(const char* filein);
~AudioData();
int getBitrate();
int getSamplerate();
const char* getMpegver();
int getLayer();
static const char* getMode(int mode);
int getMode();
int getLength();
char* getLengthChar();
int getSize();
int getBitrate();
int getSamplerate();
const char* getMpegver();
int getLayer();
static const char* getMode(int mode);
int getMode();
int getLength();
char* getLengthChar();
int getSize();
bool getResult();
bool getResult();
private:
bool success;
char* fileglob;
int length;
char* lengthchar;
int version;
int filelen;
int layer;
int error_protection;
int bitrate_index;
int sampling_frequency;
int padding;
int extension;
int mode;
int mode_ext;
int copyright;
int original;
int emphasis;
bool success;
char* fileglob;
int length;
char* lengthchar;
int version;
int filelen;
int layer;
int error_protection;
int bitrate_index;
int sampling_frequency;
int padding;
int extension;
int mode;
int mode_ext;
int copyright;
int original;
int emphasis;
bool headCheck(unsigned long head);
bool readLayerInfo(FILE* file);
bool headCheck(unsigned long head);
bool readLayerInfo(FILE* file);
};
#endif // MPEGHEADER_H
......@@ -4,7 +4,7 @@
begin : Fri Mar 22 2002
copyright : (C) 2002 by Scott Wheeler
email : scott@slackorama.net
***************************************************************************/
***************************************************************************/
/***************************************************************************
* *
......@@ -19,8 +19,10 @@
CacheItem::CacheItem()
{
}
CacheItem::~CacheItem()
{
}
......@@ -4,7 +4,7 @@
begin : Fri Mar 22 2002
copyright : (C) 2002 by Scott Wheeler
email : scott@slackorama.net
***************************************************************************/
***************************************************************************/
/***************************************************************************
* *
......@@ -18,11 +18,11 @@
#ifndef CACHEITEM_H
#define CACHEITEM_H
class CacheItem
class CacheItem
{
public:
CacheItem();
~CacheItem();
public:
CacheItem();
~CacheItem();
};
#endif
......@@ -4,7 +4,7 @@
begin : Wed Feb 6 2002
copyright : (C) 2002 by Scott Wheeler
email : scott@slackorama.net
***************************************************************************/
***************************************************************************/
/***************************************************************************
* *
......@@ -22,9 +22,9 @@
////////////////////////////////////////////////////////////////////////////////
CustomAction::CustomAction(const QString &text, QObject *parent, const char *name)
: KAction(text, 0, parent, name)
: KAction(text, 0, parent, name)
{
toolbar=NULL;
toolbar=NULL;
}
CustomAction::~CustomAction()
......@@ -33,44 +33,44 @@ CustomAction::~CustomAction()
int CustomAction::plug(QWidget *parent, int index)
{
customWidget = createWidget(parent);
if(customWidget) {
// the check for null makes sure that there is only one toolbar that this is
// "plugged" in to
if (parent->inherits("KToolBar") && !toolbar) {
toolbar = static_cast<KToolBar *>(parent);
int id = KAction::getToolButtonID();
toolbar->insertWidget(id, customWidget->width(), customWidget, index);
addContainer(toolbar, id);
connect(toolbar, SIGNAL(destroyed()), this, SLOT(slotDestroyed()));
return (containerCount() - 1);
customWidget = createWidget(parent);
if(customWidget) {
// the check for null makes sure that there is only one toolbar that this is
// "plugged" in to
if (parent->inherits("KToolBar") && !toolbar) {
toolbar = static_cast<KToolBar *>(parent);
int id = KAction::getToolButtonID();
toolbar->insertWidget(id, customWidget->width(), customWidget, index);
addContainer(toolbar, id);
connect(toolbar, SIGNAL(destroyed()), this, SLOT(slotDestroyed()));
return (containerCount() - 1);
}
return(-1);
}
else {
return(-1);
}
return(-1);
}
else {
return(-1);
}
}
void CustomAction::unplug(QWidget *parent)
{
if (parent->inherits("KToolBar")) {
toolbar = static_cast<KToolBar *>(parent);
int index = findContainer(toolbar);
if (index != -1) {
toolbar->removeItem(itemId(index));
removeContainer(index);
toolbar = 0;
if (parent->inherits("KToolBar")) {
toolbar = static_cast<KToolBar *>(parent);
int index = findContainer(toolbar);
if (index != -1) {
toolbar->removeItem(itemId(index));
removeContainer(index);
toolbar = 0;
}
}
}
}
////////////////////////////////////////////////////////////////////////////////
......@@ -79,5 +79,5 @@ void CustomAction::unplug(QWidget *parent)
KToolBar *CustomAction::getToolBar()
{
return(toolbar);
return(toolbar);
}
......@@ -4,7 +4,7 @@
begin : Wed Feb 6 2002
copyright : (C) 2002 by Scott Wheeler
email : scott@slackorama.net
***************************************************************************/
***************************************************************************/
/***************************************************************************
* *
......@@ -24,27 +24,27 @@
#include <qstring.h>
#include <qobject.h>
class CustomAction : public KAction
class CustomAction : public KAction
{
Q_OBJECT
public:
CustomAction(const QString &text, QObject *parent, const char *name);
~CustomAction();
Q_OBJECT
public:
CustomAction(const QString &text, QObject *parent, const char *name);
~CustomAction();
virtual int plug(QWidget *parent, int index = -1);
virtual void unplug(QWidget *widget);
virtual int plug(QWidget *parent, int index = -1);
virtual void unplug(QWidget *widget);
protected:
KToolBar *getToolBar();
KToolBar *getToolBar();
QWidget *customWidget;
KToolBar *toolbar;
QWidget *customWidget;
KToolBar *toolbar;
private:
virtual QWidget *createWidget(QWidget *parent) = 0;
private:
virtual QWidget *createWidget(QWidget *parent) = 0;
signals:
void pluggedIn(QWidget *parent);
void pluggedIn(QWidget *parent);
};
......
......@@ -4,7 +4,7 @@
begin : Sat Feb 16 2002
copyright : (C) 2002 by Scott Wheeler
email : scott@slackorama.net
***************************************************************************/
***************************************************************************/
/***************************************************************************
* *
......@@ -22,7 +22,7 @@
#include <qdir.h>
#include <qtimer.h>
#include <qapplication.h>
#include <qptrlist.h>
#include <qptrlist.h>
#include "filelist.h"
......@@ -32,91 +32,91 @@
FileList::FileList(QWidget *parent, const char *name) : KListView(parent, name)
{
setup();
setup();
}
FileList::FileList(QString &item, QWidget *parent, const char *name) : KListView(parent, name)
{
setup();
append(item);
setup();
append(item);
}
FileList::FileList(QStringList &items, QWidget *parent, const char *name) : KListView(parent, name)
{
setup();
append(items);
setup();
append(items);
}
FileList::~FileList()
{
delete(artistList);
delete(albumList);
delete(artistList);
delete(albumList);
}
void FileList::append(QString item)
{
QApplication::setOverrideCursor(Qt::waitCursor);
appendImpl(item);
QApplication::restoreOverrideCursor();
emit(dataChanged());
QApplication::setOverrideCursor(Qt::waitCursor);
appendImpl(item);
QApplication::restoreOverrideCursor();
emit(dataChanged());
}
void FileList::append(QStringList &items)
{
QApplication::setOverrideCursor(Qt::waitCursor);
for(QStringList::Iterator it = items.begin(); it != items.end(); ++it)
appendImpl(*it);
QApplication::restoreOverrideCursor();
emit(dataChanged());
QApplication::setOverrideCursor(Qt::waitCursor);
for(QStringList::Iterator 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());
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
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;