1 /***************************************************************************
2  *   Copyright (C) 2003-2005 by David Saxton                               *
3  *   david@bluehaze.org                                                    *
4  *                                                                         *
5  *   This program is free software; you can redistribute it and/or modify  *
6  *   it under the terms of the GNU General Public License as published by  *
7  *   the Free Software Foundation; either version 2 of the License, or     *
8  *   (at your option) any later version.                                   *
9  ***************************************************************************/
10 
11 #ifndef LIBRARYITEM_H
12 #define LIBRARYITEM_H
13 
14 #include "item.h"
15 
16 class QStringList;
17 
18 /**
19 This holds details of an item - id, name, category it is displayed in in its
20 respective item selector, icon, function pointers to creating the item, etc.
21 Normally each item will only pass one id, but some items have had their IDs
22 changed during the history of ktl, so passing a stringlist will take the first
23 ID as the "active" id, and the rest as IDs that will also be recognized, but
24 never displayed to the user.
25 @short Details of an Item
26 @author David Saxton
27 */
28 class LibraryItem
29 {
30 	public:
31 		~LibraryItem();
32 
33 		enum Type
34 		{
35 			lit_flowpart,
36 			lit_component,
37 			lit_mechanical,
38 			lit_drawpart,
39 			lit_subcircuit,
40 			lit_other
41 		};
42 		LibraryItem( QStringList idList, const QString &name, const QString &category, QPixmap icon, Type type, createItemPtr createItem );
43 		LibraryItem( QStringList idList, const QString &name, const QString &category, const QString &iconName, Type type, createItemPtr createItem );
44 		LibraryItem( QStringList idList, const QString &name, const QString &category, Type type, createItemPtr createItem );
45 
46 		QString activeID() const;
allIDs()47 		QStringList allIDs() const { return m_idList; }
name()48 		QString name() const { return m_name; }
category()49 		QString category() const { return m_category; }
iconFull()50 		QPixmap iconFull() const { return m_icon_full; }
icon16()51 		QPixmap icon16() const { return m_icon_16; }
createItemFnPtr()52 		createItemPtr createItemFnPtr() const { return createItem; }
type()53 		int type() const { return m_type; }
54 
55 	protected:
56 		void createIcon16();
57 
58 	private:
59 		QStringList m_idList;
60 		QString m_name;
61 		QString m_category;
62 		QPixmap m_icon_full;
63 		QPixmap m_icon_16;
64 		createItemPtr createItem;
65 		int m_type;
66 };
67 typedef QList<LibraryItem*> LibraryItemList;
68 
69 #endif
70