/***************************************************************************
                          ProjectWid.h  -  description
                             -------------------
    begin                : sam jui 5 2003
    copyright            : (C) 2003 by Alain Gibaud
    email                : alain.gibaud@univ-valenciennes.fr
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   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 PROJECTWID_H
#define PROJECTWID_H

#include <qwidget.h>
#include <qvbox.h>
#include <qlistview.h>

#include "Project.h"
#include "EditorManager.h"
#include "PikMain.h"

/**A widget to display and edit  informations about the current project
  *@author Alain Gibaud
  */
class NewProject ;
class QPopupMenu ;
class PikMain ;
class ProjectEditorWid ;

class ProjectWid : public QVBox
{
   Q_OBJECT
public: 
	ProjectWid(PikMain *mainwindow, QWidget *parent, const char *name);
	~ProjectWid();
  /** Add a file name to the project tree
(filename is absolute or relative to the project file location) */
  void addFile2Tree(const QString&name);
  /** Returns the current project object (might be NULL) */
  Project *getProject();
  /** Drag and drop management
 */
  virtual void dragEnterEvent(QDragEnterEvent *);
  /** Drop on project widget */
  virtual void dropEvent(QDropEvent *ev);
public slots:
  void slotProjectRButton (QListViewItem *, const QPoint &, int )   ;
  /** No descriptions */
  void slotCreateProject(const QString&, const QString&, const QString&);
  /** No descriptions */
  void slotNewProjectClosed();
  /** No descriptions */
  void slotCloseProject();
  /** No descriptions */
  void slotInsertFile();
  /** No descriptions */
  void slotOpenProject();
  /** remove the current item from tree (and the file from project)  */
  void slotRemoveFile();
  /** No descriptions */
  void slotInsertCurrentFile();
  /** Calls the Project Editor Widget */
  void slotEditProject();
  /** No descriptions */
  void slotNewProject();
  /** Updates the UI when a project is opened/closed */
  void slotProjectIsOpen(bool open);
  /** No descriptions */
  void slotProjectEditorClosed();
  /** No descriptions */
  void slotOpenProjectFile(const QString& filename) ;
private: // Private attributes
  /** New project widget */
  NewProject * newproject;
  /** Last selected item */
  QListViewItem *currentListViewItem ;   
  /** Root of Project tree */
  QListViewItem *projectTree;
  Project *project ;
  /** Link to main window */
  PikMain *main_window ;
  ProjectEditorWid * projecteditor;
private: // Private methods
  /** Make an empty popup menu with "title" header */
  QPopupMenu *makePopup(const QString& title, QWidget  *parent);
  /** insert a new absolute filename - returns true if OK, false if already exists */
   bool insertAbsFile(const QString &fname) ;
private slots: // Private slots
  /** No descriptions */
  void slotProjectElementClicked(QListViewItem *);
public: // Public attributes
};

#endif
