/***********************************************************************
**
**   tasklistview
**
**   This file is part of Cumulus.
**
************************************************************************
**
**   Copyright (c):  2004 by André Somers
**
**   This file is distributed under the terms of the General Public
**   Licence. See the file COPYING for more information.
**
**   $Id: tasklistview.h,v 1.3 2004/06/17 21:53:39 eckhard Exp $
**
***********************************************************************/
#ifndef TASKLISTVIEW_H
#define TASKLISTVIEW_H

#include <qwidget.h>
#include <qlistview.h>
#include <qlayout.h>
#include <qpixmap.h>
#include <qpushbutton.h>

#include "wp.h"
#include "flighttask.h"

/**
 * Presents a view that holds a list of the waypoints in the currently selected task.
 * @author André Somers
 */

class CumulusApp;

#define NUMBER_LIST_ENTRIES 40 
class TaskListView : public QWidget
{
Q_OBJECT
public:
    TaskListView(QWidget *parent = 0, const char *name = 0);

    ~TaskListView();

    /** Returns a pointer to the currently highlighted waypoint. */
    wayPoint * getSelectedWaypoint();

private:
    QListView* list;
    CumulusApp * par;
    QBoxLayout * buttonrow;
    wayPoint    selectedWp;
    bool       _outlandShow;
    QPushButton *cmdShowOl;
    QPushButton *cmdHideOl;
    QPixmap     _arrows;
    FlightTask* _task;
    wayPoint *  _selected;
    
protected:
    void showEvent(QShowEvent *);

private: // Private methods

private slots:
    /**
     * This slot is called if the user selects a certain waypoint in the task
     */
    void slot_Selected(QListViewItem *);
public slots: // Public slots
    /** 
     * This signal is called to indicate that a selection has been made. 
     */
    void slot_Select();
    /** 
     * This slot is called if the info button has been clicked, or the user pressed 'i' 
     */
    void slot_Info();
    /** 
     * Called when the listview should be closed without selection 
     */
    void slot_Close ();
    /** 
     * Retreives the waypoints from the task, and fills the list. 
     */
    void slot_setTask(const FlightTask *);

signals: // Signals
    /** 
     * This signal is emitted if a new waypoint is selected. 
     */
    void newWaypoint(wayPoint*);
    /** 
     * This signal is send if the selection is done, and the screen can be closed. 
     */
    void done();
    /** 
     * Emitted if the user clicks the Info button. 
     */
    void info(wayPoint*);
    
private:

  class _TaskPoint:public QListViewItem
  {
  public:
  _TaskPoint(QListView*, wayPoint *);
  wayPoint * wp;
  
  };
};

#endif
