/*
 * portlistview.h
 *
 * Copyright (c) 2002, 2003 Frerich Raabe <raabe@kde.org>
 *
 * 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. For licensing and distribution details, check the
 * accompanying file 'COPYING'.
 */
#ifndef PORTLISTVIEW_H
#define PORTLISTVIEW_H

#include "port.h"

#include <klistview.h>

#include <qdatetime.h>
#include <qdict.h>
#include <qmap.h>

class QListViewItem;
class QTimer;

namespace Barry
{
	class CategoryItem : public KListViewItem
	{
		friend class PortListView;
		public:
			CategoryItem( PortListView *parent, const QString &name );

			virtual void setOpen( bool open );

			QString name() const { return m_name; }

		private:
			void populate();

			QString m_name;
	};

	class PortItem : public KListViewItem
	{
		public:
			PortItem( KListView *parent, const Port &port );
			PortItem( CategoryItem *parent, const Port &port );

			Port port() const { return m_port; }

		private:
			void init();

			Port m_port;
	};

	class PortListView : public KListView
	{
		friend class CategoryItem;
		friend class PortItem;
		friend class PortSelectCommand;
		Q_OBJECT
		public:
			PortListView( QWidget *parent );

			void populate();

		signals:
			void portNameRegistered( const QString &name );
			void portSelected( const Port &port );

		public slots:
			void selectPort( const QString &port );
			void selectPort( const Port &port );
			
		private slots:
			void itemSelected( QListViewItem *item );

		private:
			QDict<KListViewItem> m_nameDict;
			QMap<Port, KListViewItem *> m_portMap;
			QListViewItem *m_oldItem;
	};
}

#endif // PORTLISTVIEW_H
// vim:ts=4:sw=4:noet:list


syntax highlighted by Code2HTML, v. 0.9.1