/***************************************************************************
                          AudioCompilationTreeView.h  -  description
                             -------------------
    begin                : Sun Nov 18 2001
    copyright            : (C) 2001 by Alex Podolsky
    email                : alexpod@users.sf.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 AUDIOCOMPILATIONLISTVIEW_H
#define AUDIOCOMPILATIONLISTVIEW_H

#include <qwidget.h>
#include <qevent.h>
#include <qdict.h>

#include <kio/job.h>
#include <klistview.h>

class QPopupMenu;
class QListViewItem;
class AudioEstimatePnl;

class AudioCompilationTreeView : public KListView  {
   Q_OBJECT
public:
	AudioCompilationTreeView( QWidget *parent=0L, const char *name=0L);
	~AudioCompilationTreeView();
	
	void setEstimate(AudioEstimatePnl *e);
	inline QStringList* getFileList(){ return &fList;}

public slots:
	bool addOneItem(QString);
	bool addMultipleItems(QString);
	bool addMultipleItems(QStringList);
	void updateSettings();
	void compilSettingsSlot();	

	void slotProperties();
	void remove();
	void removeAll();

	void reload();
	void longProcessCanceled(QString);
	void moveDown();
	void moveUp();
		
	
signals:
	void processStarted();
	void longProcessStarted(KIO::Job *);
	void processDone();
	void longProcessDone(KIO::Job *);
	void haveStatus(const QString &);
	void popUpSettings(int type);

	void modified();

protected slots:	
	void audioPickerDone(KIO::Job *);
	void popupMenuSlot(QListViewItem*, const QPoint&, int);
	void trackDoubleClicked ( QListViewItem *);

	void dropOcurred(QDropEvent * e, QListViewItem *after);
	void openWithSlot();
    	virtual void keyPressEvent(QKeyEvent *e);
	void slotEntries( KIO::Job*, const KIO::UDSEntryList &);
	
protected:	
	bool addItem(QString);
	virtual bool acceptDrag (QDropEvent* event) const;
	
private:
	bool canAccept(QString path);
	bool pickAudioFromDir(QString path);
	bool addFileItem(QString path, QString artist, QString trackName, QString length);
	QString currentItemPath();
	QString currentItemName();
	void checkRejected();
	bool isValidType(QString path);
	bool tryToAdd(QString path);
	void correctPositions();
	
	
	
	AudioEstimatePnl *estimate;
	
	QPopupMenu *fullMenu;
	QPopupMenu *shortMenu;

	int removeAllIndex;
	
	
	QStringList fList;
	QStringList nameList;

	int totJobs;
	bool multy;
	bool errorAccepting;
	bool errorOverSizeLimit;
	
};
#endif
