/***************************************************************************
 *   Copyright (C) 2005 by James Thorniley                                 *
 *   james@uncommonlygood.co.uk                                            *
 *                                                                         *
 *   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.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/
#ifndef BURNSIDEBARPLUGIN_H
#define BURNSIDEBARPLUGIN_H

#include <konqsidebarplugin.h>
#include <qwidget.h>
#include <qlabel.h>
#include <qscrollview.h>
#include <kdirlister.h>
#include <qmap.h>
#include <kfileitem.h>
#include <kdockwidget.h>
#include <kdebug.h>

#include "burnk3bdoccreator.h"

class K3bDoc;
class BurnAudioCDConfigWidget;
class BurnDataCDConfigWidget;
class BurnDataDVDConfigWidget;
class BurnProjectTypeWidget;
class QVBox;
class QComboBox;
class KListView;
class QWidgetStack;
class KDirWatch;
class QCustomEvent;
class BurnDeviceScanner;
class KConfig;
class QLabel;
class QFrame;
namespace K3bDevice{
class DeviceManager;
}

/**
@author James Thorniley
*/
class BurnSidebarPlugin : public KonqSidebarPlugin
{
  Q_OBJECT
  public:
  
    enum DiscType {
      DataCD, AudioCD, DataDVD
    };

    BurnSidebarPlugin(
      KInstance *inst,QObject *parent,
      QWidget *widgetParent, 
      QString &desktopName_, 
      const char* name=0);

    ~BurnSidebarPlugin();

    virtual QWidget *getWidget(){return m_mainView;}   
    virtual void *provides(const QString &) {return 0;}  

    bool isDVDEnabled(){ return m_enableDVD; }
    K3bDoc *k3bDoc(){ return m_docCreator->k3bDoc(); }

    KDirLister *dirLister(){ return m_dataDirLister; }

    virtual void customEvent( QCustomEvent *e );

    static KConfig *config();

    
  signals:
    /**When a new directory is added to the data area,
    this signal will be emitted with the new DirLister for
    that directory. This should not be deleted
    **/
    void dirAdded( KDirLister *newLister );

  protected:
    virtual void handleURL(const KURL &url);

  private:
    QScrollView *m_mainView;
    QVBox *m_vbox;
    KListView *m_projectView;
    QWidgetStack *m_configWidget, *m_deviceWidget;
    QComboBox *m_deviceCombo;
    BurnK3bDocCreator *m_docCreator;
    BurnDataCDConfigWidget *m_dataCDConfig;
    BurnAudioCDConfigWidget *m_audioCDConfig;
    BurnDataDVDConfigWidget *m_dataDVDConfig;
    BurnDeviceScanner *m_scanner;
    KDockWidget *m_dock;
    static KConfig *m_burnConfig;

    bool m_enableDVD;

    ///watches our data directory, signals are used by config objects
    KDirLister *m_dataDirLister;

    void initGui(QWidget *parent);

    ///called if the dirlister is finished when it is created, e.g. because it is cached
    void addSubDirs();
  private slots:
    void slotDiscTypeSelected( BurnSidebarPlugin::DiscType type );
    void slotNewItems( const KFileItemList &newItems );

};

#endif
