/***************************************************************************
                          DataCompilationTreeView.h  -  description
                             -------------------
    begin                : Mon Nov 19 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 DATACOMPILATIONLISTVIEW_H
#define DATACOMPILATIONLISTVIEW_H

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

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

class QPopupMenu;
class QListViewItem;
class EstimatePnl;
class KConfig;
class FolderItem;

class QListViewItem;
class CdboFileItem;
class QDropEvent;

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

public slots:
	void updateSettings();
	void slotReload();
	void compilSettingsSlot();
	
	void collapse();
	void recalculate();
	void longProcessCanceled(QString);

	bool addOneItem(QString);
	bool addMultipleItems(QString);
	bool addMultipleItems(QStringList);
	void remove();
	void removeAll();
	
	void slotProperties();


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 gotSize(KIO::Job *);
	void slotEntries( KIO::Job * , const KIO::UDSEntryList & );

	void slotSelectItem(QListViewItem *);
	void slotShowHidden();
	void popupMenuSlot(QListViewItem*, const QPoint&, int);

	void dropOcurred(QDropEvent * e, QListViewItem *after);
	void openWithSlot();
    	virtual void keyPressEvent(QKeyEvent *e);


protected:
	virtual bool acceptDrag (QDropEvent* event) const;
	int currentItemSize();
	
	bool addItem(QString);
	QString currentItemPath();
	QString currentItemName();
	QListViewItem* getItemForDeletion();
	
private:
	bool canAccept(QString path);
	void addFileItem(QString path, int size);
	void calculateDirSize( QString path);

	CdboFileItem *top;
	EstimatePnl *estimate;
	QStringList fList;
	QStringList nameList;
	
	KConfig *config;
	QDict <FolderItem>map;//////////////////

	///menus
	QPopupMenu *folderMenu;
	QPopupMenu *fileMenu;
	QPopupMenu *isoMenu;
	///menu indexes
	int hiddenIndex;
	int hiddenFIndex;
	int createIsoIndex;
	int createIsoIndexInFileMenu;
	int createIsoIndexInFolderMenu;
	bool showHidden;
	int haveItemsIndex;
	int createCDIndex;
	int createISOIndex;

};
#endif
