summaryrefslogtreecommitdiffstats
path: root/src/iteminterface.h
blob: 5cc8702606e98edb16f0c8648bcc1bbd7c5819f4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
/***************************************************************************
 *   Copyright (C) 2004-2005 by David Saxton                               *
 *   [email protected]                                                    *
 *                                                                         *
 *   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 ITEMINTERFACE_H
#define ITEMINTERFACE_H

#include <tqguardedptr.h>

class CNItemGroup;
class DoubleSpinBox;
class Item;
class ItemDocument;
class ItemGroup;
class ItemInterface;
class KTechlab;
class MechanicsGroup;
class Variant;

class ColorCombo;
class KComboBox;
class KToolBar;
class KURLRequester;
class TQCheckBox;
class KLineEdit;
class KIntSpinBox;


typedef TQMap<TQString, Variant*> VariantDataMap;
typedef TQMap<TQString, KComboBox*> KComboBoxMap;
typedef TQMap<TQString, KLineEdit*> KLineEditMap;
typedef TQMap<TQString, DoubleSpinBox*> DoubleSpinBoxMap;
typedef TQMap<TQString, KIntSpinBox*> IntSpinBoxMap;
typedef TQMap<TQString, ColorCombo*> ColorComboMap;
typedef TQMap<TQString, KURLRequester*> KURLReqMap;
typedef TQMap<TQString, TQCheckBox*> TQCheckBoxMap;

/**
This acts as an interface between the ItemDocument's and the associated
Items's, and the various objects that like to know about them
(e.g. ContextHelp, ItemEditor, ItemEditTB)
@author David Saxton
*/
class ItemInterface : public TQObject
{
	Q_OBJECT
  TQ_OBJECT
	public:
		~ItemInterface();
		static ItemInterface * self( KTechlab * ktechlab = 0l );
		
		/**
		 * Sets the orientation of all flowparts in the group.
		 */
		void setFlowPartOrientation( unsigned orientation );
		/**
		 * Sets the orientation of all components in the group.
		 */
		void setComponentOrientation( int angleDegrees, bool flipped );
		/**
		 * Updates actions based on the items currently selected (e.g. rotate,
		 * flip, etc)
		 */
		void updateItemActions();
		/**
		 * Returns a configuration widget for the component for insertion into te
		 * ItemEditTB.
		 * @param showAdvanced Whether advanced data should be shown
		 */
		virtual TQWidget * configWidget();
	
	public slots:
		/**
		 * If cnItemsAreSameType() returns true, then set the
		 * data with the given id for all the CNItems in the group.
		 * Else, it only sets the data for the activeCNItem()
		 */
		void slotSetData( const TQString &id, TQVariant value );
		/**
		 * Called when the ItemEditTB is cleared. This clears all widget maps.
		 */
		void itemEditTBCleared();
		void tbDataChanged();
		void slotItemDocumentChanged( ItemDocument *view );
		void slotUpdateItemInterface();
		void slotClearAll();
		void slotMultipleSelected();
		void clearItemEditorToolBar();
	
	protected:
		/**
		 * Connects the specified widget to either tbDataChanged or advDataChanged
		 * as specified by mi.
		 */
		void connectMapWidget( TQWidget *widget, const char *_signal);
		
		KTechlab * const p_ktechlab;
	
		// Widget maps.
		KLineEditMap m_stringLineEditMap;
		KComboBoxMap m_stringComboBoxMap;
		KURLReqMap m_stringURLReqMap;
		DoubleSpinBoxMap m_doubleSpinBoxMap;
		IntSpinBoxMap m_intSpinBoxMap;
		ColorComboMap m_colorComboMap;
		TQCheckBoxMap m_boolCheckMap;
		
		// Use by item editor toolbar
		TQGuardedPtr<KToolBar> m_pActiveItemEditorToolBar;
		int m_toolBarWidgetID;
		
		
	protected slots:
		void slotGetActionTicket();

	private:
		ItemInterface( KTechlab * ktechlab );
		static ItemInterface * m_pSelf;
	
		TQGuardedPtr<ItemDocument> p_cvb;
		TQGuardedPtr<ItemGroup> p_itemGroup;
		TQGuardedPtr<Item> p_lastItem;
		int m_currentActionTicket;
};

#endif