File indexing completed on 2024-12-08 11:07:14
0001 /*************************************************************************** 0002 * Copyright (C) 2004-2005 by David Saxton * 0003 * david@bluehaze.org * 0004 * * 0005 * This program is free software; you can redistribute it and/or modify * 0006 * it under the terms of the GNU General Public License as published by * 0007 * the Free Software Foundation; either version 2 of the License, or * 0008 * (at your option) any later version. * 0009 ***************************************************************************/ 0010 0011 #ifndef ITEMINTERFACE_H 0012 #define ITEMINTERFACE_H 0013 0014 #include <QMap> 0015 #include <QPointer> 0016 0017 #include "itemgroup.h" 0018 0019 class CNItemGroup; 0020 class DoubleSpinBox; 0021 class Item; 0022 class ItemDocument; 0023 class ItemGroup; 0024 class ItemInterface; 0025 class KTechlab; 0026 class MechanicsGroup; 0027 class Variant; 0028 0029 class KColorCombo; 0030 class KComboBox; 0031 class KToolBar; 0032 class KUrlRequester; 0033 class QCheckBox; 0034 class KLineEdit; 0035 class QSpinBox; 0036 0037 typedef QMap<QString, Variant *> VariantDataMap; 0038 typedef QMap<QString, KComboBox *> KComboBoxMap; 0039 typedef QMap<QString, KLineEdit *> KLineEditMap; 0040 typedef QMap<QString, DoubleSpinBox *> DoubleSpinBoxMap; 0041 typedef QMap<QString, QSpinBox *> IntSpinBoxMap; 0042 typedef QMap<QString, KColorCombo *> KColorComboMap; 0043 typedef QMap<QString, KUrlRequester *> KUrlReqMap; 0044 typedef QMap<QString, QCheckBox *> QCheckBoxMap; 0045 0046 /** 0047 This acts as an interface between the ItemDocument's and the associated 0048 Items's, and the various objects that like to know about them 0049 (e.g. ContextHelp, ItemEditor, ItemEditTB) 0050 @author David Saxton 0051 */ 0052 class ItemInterface : public QObject 0053 { 0054 Q_OBJECT 0055 public: 0056 ~ItemInterface() override; 0057 static ItemInterface *self(); 0058 /** 0059 * The current item group in use (or null if none). 0060 */ 0061 ItemGroup *itemGroup() const 0062 { 0063 return p_itemGroup; 0064 } 0065 /** 0066 * Sets the orientation of all flowparts in the group. 0067 */ 0068 void setFlowPartOrientation(unsigned orientation); 0069 /** 0070 * Sets the orientation of all components in the group. 0071 */ 0072 void setComponentOrientation(int angleDegrees, bool flipped); 0073 /** 0074 * Updates actions based on the items currently selected (e.g. rotate, 0075 * flip, etc) 0076 */ 0077 void updateItemActions(); 0078 /** 0079 * Returns a configuration widget for the component for insertion into te 0080 * ItemEditTB. 0081 */ 0082 virtual QWidget *configWidget(); 0083 0084 public slots: 0085 /** 0086 * If cnItemsAreSameType() returns true, then set the 0087 * data with the given id for all the CNItems in the group. 0088 * Else, it only sets the data for the activeCNItem() 0089 */ 0090 void slotSetData(const QString &id, QVariant value); 0091 /** 0092 * Essentially the same as slotSetData. 0093 */ 0094 void setProperty(Variant *v); 0095 /** 0096 * Called when the ItemEditTB is cleared. This clears all widget maps. 0097 */ 0098 void itemEditTBCleared(); 0099 void tbDataChanged(); 0100 void slotItemDocumentChanged(ItemDocument *view); 0101 void slotUpdateItemInterface(); 0102 void slotClearAll(); 0103 void slotMultipleSelected(); 0104 void clearItemEditorToolBar(); 0105 0106 protected: 0107 /** 0108 * Connects the specified widget to either tbDataChanged or advDataChanged 0109 * as specified by mi. 0110 */ 0111 void connectMapWidget(QWidget *widget, const char *_signal); 0112 0113 // Widget maps. 0114 KLineEditMap m_stringLineEditMap; 0115 KComboBoxMap m_stringComboBoxMap; 0116 KUrlReqMap m_stringURLReqMap; 0117 DoubleSpinBoxMap m_doubleSpinBoxMap; 0118 IntSpinBoxMap m_intSpinBoxMap; 0119 KColorComboMap m_colorComboMap; 0120 QCheckBoxMap m_boolCheckMap; 0121 0122 // Use by item editor toolbar 0123 QPointer<KToolBar> m_pActiveItemEditorToolBar; 0124 int m_toolBarWidgetID; 0125 0126 protected slots: 0127 void slotGetActionTicket(); 0128 0129 private: 0130 ItemInterface(); 0131 static ItemInterface *m_pSelf; 0132 0133 QPointer<ItemDocument> p_cvb; 0134 QPointer<ItemGroup> p_itemGroup; 0135 QPointer<Item> p_lastItem; 0136 int m_currentActionTicket; 0137 bool m_isInTbDataChanged; 0138 }; 0139 0140 #endif