/***********************************************************************
**
**   waypointlistview.h
**
**   This file is part of Cumulus.
**
************************************************************************
**
**   Copyright (c):  2002 by André Somers
**
**   This file is distributed under the terms of the General Public
**   Licence. See the file COPYING for more information.
**
**   $Id: airfieldlistview.h,v 1.3 2005/02/21 18:24:21 andre Exp $
**
***********************************************************************/

#ifndef AIRFIELDISTVIEW_H
#define AIRFIELDISTVIEW_H

#include <qwidget.h>
#include "qlistview.h"
#include "wp.h"
#include <qlayout.h>
#include "listviewfilter.h"
#include "mapcontents.h"

/**This widget provides a list of waypoints and a means to select one.
  *@author André Somers
  */
class CumulusApp;

class AirfieldListView : public QWidget  {
   Q_OBJECT
public: 
  AirfieldListView(CumulusApp *parent=0, const char *name=0);
  ~AirfieldListView();

  /** Returns a pointer to the currently highlighted waypoint. */
  wayPoint * getSelectedAirfield();
  enum MapContents::MapContentsListID itemList[3];
private:
  QListView* list;
  CumulusApp * par;
  QBoxLayout * buttonrow;
  ListViewFilter * filter;
  wayPoint *wp;
  bool listFilled;
  
protected:
  void showEvent(QShowEvent *);

private: // Private methods

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 ();
  /** Called when the selected waypoint should be deleted from the catalog */
  void fillWpList();
  /** Called to set a waypoint as homesite */
  void slot_setHome();
  
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*);

  /** Emitted if a new home position is selected */
  void newHomePosition(const QPoint*);

private:

  class _AirfieldItem:public QListViewItem
  {
  public:
    _AirfieldItem(QListView*, Airport*);
    Airport* airport;
  
  };

};

#endif
