/* This file is part of FSView.
   Copyright (C) 2002, 2003 Josef Weidendorfer <Josef.Weidendorfer@gmx.de>

   KCachegrind 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, version 2.

   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; see the file COPYING.  If not, write to
   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
   Boston, MA 02110-1301, USA.
*/

/*
 * The KPart embedding the FSView widget
 */

#ifndef FSVIEW_PART_H
#define FSVIEW_PART_H

#include <tdeparts/part.h>
#include <tdeparts/browserextension.h>
#include <tdeio/jobclasses.h>

#include "fsview.h"

class TDEAboutData;
class TDEActionMenu;

class FSViewPart;

class FSViewBrowserExtension : public KParts::BrowserExtension
{
  Q_OBJECT
  

public:
  FSViewBrowserExtension(FSViewPart *viewPart, const char *name=0L);
  ~FSViewBrowserExtension();

protected slots:
  void selected(TreeMapItem*);
  void contextMenu(TreeMapItem*,const TQPoint&);

  void updateActions();
  void refresh();

  void copy() { copySelection( false ); }
  void cut() { copySelection( true ); }
  void trash();
  void del();
  void editMimeType();

private:
  void copySelection( bool move );

  FSView* _view;  
};

class FSJob: public TDEIO::Job
{
  Q_OBJECT
  

public:
  FSJob(FSView*);

  virtual void kill( bool quietly = true );

public slots:
  void progressSlot(int percent, int dirs, const TQString& lastDir);

private:
  FSView* _view;
};


class FSViewPart : public KParts::ReadOnlyPart
{
  Q_OBJECT
  
  TQ_PROPERTY( bool supportsUndo READ supportsUndo )
public:
  FSViewPart(TQWidget *parentWidget, const char *widgetName,
             TQObject *parent, const char *name, const TQStringList &args);

  virtual ~FSViewPart();

  bool supportsUndo() const { return false; }

  static TDEAboutData* createAboutData();
  FSView* view() const { return _view; }

public slots:
  void showInfo();
  void showHelp(); 
  void startedSlot();
  void completedSlot(int dirs);
  void slotShowVisMenu();
  void slotShowAreaMenu();
  void slotShowDepthMenu();
  void slotShowColorMenu();
  void slotSettingsChanged(int);

protected:
  /**
   * This must be implemented by each part
   */
  virtual bool openFile();
  virtual bool openURL(const KURL &url);
  virtual bool closeURL();

private:
  FSView* _view;
  FSJob* _job;
  FSViewBrowserExtension* _ext;
  TDEActionMenu *_visMenu, *_areaMenu, *_depthMenu, *_colorMenu;
};

#endif // FSVIEW_PART_H
