/****************************************************************************
** Interface to the GUI.
**
**   Created : Tue 04 May 12:09:08 2004
**        by : Varol Okan using kate editor
** Copyright : (c) Varol Okan
** License   : GPL v 2.0
**
** This class will create a toolbar, which displays all currently selected
** sources for the DVD, such as all Videos, and all Audio files.
**
** Besides displaying these it will also do some background checks.
** For this it will spawn a new thread, which will analyse the file
** and see if it needs to get converted for a propper usage.
**
** tcscan is your friend.
** 
** The result will be color coded.
** o	Gray, not yet determined
** o	any shades of green -> In DVD format.
** o	any shades of blue  -> will be converted before creating DVD
** o	any shades of red   -> Can not automatically handle this format.
**
****************************************************************************/

#ifndef SOURCETOOLBAR_H
#define SOURCETOOLBAR_H

#include <qdockwindow.h>

// The following two defines specify which column the file name is to be found. 
#define MOVIE_FILE_NAME_INDEX 7
#define AUDIO_FILE_NAME_INDEX 7

#include <qmutex.h>
#include <qthread.h>

#include "uisourcewidget.h"
#include "sourcefileentry.h"

//class QDVDAuthor;
class MediaInfo;
class DialogThumbnail;
class ListViewItemMedia;

class SourceToolBar : public QDockWindow
{
	Q_OBJECT

public:
	 SourceToolBar     ( const char *, QMainWindow * );
	~SourceToolBar     ( );
 
	void addMovie      ( SourceFileEntry * );
	void addMovieList  ( QStringList &, QString *p=NULL );
	void addSound      ( QStringList & );
	void clear         ( );
	
	int  sourceFileCount                       ( );
	int  getFreeSourceSlot                     ( );
	SourceFileEntry *sourceFileEntry           ( uint );
	SourceFileEntry *sourceFileEntry           ( CXmlSlideshow *);
	SourceFileEntry *entryFromSlideshow        ( CXmlSlideshow *);
	SourceFileEntry *getCurrentSourceFileEntry ( );
	SourceFileInfo  *getCurrentSourceFileInfo  ( );
	void slideshowDone                         ( SourceFileEntry * );
	bool sourceFileEntryExists                 ( SourceFileEntry * );
	void editSourceFileInfo                    ( SourceFileInfo  * );
	bool updateListViewItem                    ( SourceFileInfo  * );
	bool checkRightAudioFormat                 ( SourceFileInfo  * );
	bool checkRightFileFormat                  ( SourceFileInfo  * );
	void createContextMenu                     ( SourceFileEntry *, QPoint & );
	void appendSourceFileEntry                 ( SourceFileEntry *, bool b=false );
	bool setRenderProgress                     ( SourceFileEntry *, float );
	void removeEntry                           ( SourceFileEntry *, bool b=true  );
	void removeEntry                           ( QString &, bool  b=true  );
	void updateStatusColor                     ( QListViewItem   *p=NULL  );
	QListView   *getStructureListView          ( );
	QTabWidget  *getTabCtrl                    ( );
	QPushButton *getButton                     ( bool );
	virtual QSize sizeHint                     ( ) const;
	QString convertFileSize                    ( uint );
	MediaInfo *getMediaInfo                    ( );

protected:
	virtual void timerEvent       ( QTimerEvent     * );
	ListViewItemMedia *getItem    ( SourceFileEntry * );

private:
	void  refreshToolBarEntries   ( );
	void *getMediaEngine          ( );
	void  importChapters          ( QString, SourceFileInfo * );
	void  updateEntryHeader       ( SourceFileEntry * );
	void  updateSlideshowItem     ( SourceFileEntry * );
	void  setAudioTranscode       ( SourceFileInfo  * );

public slots:
	virtual void slotDoubleClickedOnVideoList( QListViewItem *, const QPoint &, int );
	virtual void slotRightClickedOnVideoList ( QListViewItem *, const QPoint &, int );
	virtual void slotClickedOnVideoList      ( QListViewItem *, const QPoint &, int );
	virtual void slotPlayMovie       ( );
	virtual void slotEditMovie       ( );
	virtual void slotEditSlideshow   ( );
        virtual void slotImagesDialog    ( );
	virtual void slotRerenderSlide   ( );
	virtual void slotEditAudio       ( );
	virtual void slotDeleteSource    ( );
	virtual void slotTranscodeAll    ( );
	virtual void slotTranscodeNone   ( );
	virtual void slotAllToTitleset   ( );
	virtual void slotAddMovieOld     ( );
	virtual void slotAddMovie        ( );
	virtual void slotAddSound        ( );
	virtual void slotAddSlideshow    ( );
	virtual void slotThumbnailing    ( );
	virtual void slotSFEThumbnailing ( );
	virtual void slotSetThumbnail    ( long );
	virtual void slotRemoveEntry     ( SourceFileEntry * );

private:
	uiSourceWidget    *m_pSourceWidget;
	QMutex             m_mutexThumbnails;
	MediaInfo         *m_pMediaInfo;
	DialogThumbnail   *m_pThumbnailDialog;
	QListView         *m_pListViewAllSources;
	QValueList<SourceFileEntry *> m_listSourceFileEntries;
	SourceFileEntry   *m_pContexMenuEntry;
	SourceFileInfo    *m_pContexMenuInfo;
};

#endif // SOURCETOOLBAR_H


