1 /******************************************************************* 2 3 Part of the Fritzing project - http://fritzing.org 4 Copyright (c) 2007-2014 Fachhochschule Potsdam - http://fh-potsdam.de 5 6 Fritzing is free software: you can redistribute it and/or modify 7 it under the terms of the GNU General Public License as published by 8 the Free Software Foundation, either version 3 of the License, or 9 (at your option) any later version. 10 11 Fritzing is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 GNU General Public License for more details. 15 16 You should have received a copy of the GNU General Public License 17 along with Fritzing. If not, see <http://www.gnu.org/licenses/>. 18 19 ******************************************************************** 20 21 $Revision: 6609 $: 22 $Author: irascibl@gmail.com $: 23 $Date: 2012-10-30 14:21:08 +0100 (Di, 30. Okt 2012) $ 24 25 ********************************************************************/ 26 27 28 29 #ifndef HTMLINFOVIEW_H 30 #define HTMLINFOVIEW_H 31 32 #include <QFrame> 33 #include <QGraphicsSceneHoverEvent> 34 #include <QTimer> 35 #include <QLabel> 36 #include <QScrollArea> 37 #include <QGridLayout> 38 #include <QVBoxLayout> 39 #include <QComboBox> 40 #include <QCheckBox> 41 #include <QDoubleSpinBox> 42 43 #include "../items/itembase.h" 44 #include "../items/wire.h" 45 #include "../connectors/connectoritem.h" 46 #include "../referencemodel/referencemodel.h" 47 48 struct PropThing { 49 QPointer<QLabel> m_name; 50 QPointer<QFrame> m_frame; 51 QPointer<QLabel> m_value; 52 QPointer<QWidget> m_plugin; 53 QPointer<QVBoxLayout> m_layout; 54 }; 55 56 class TagLabel : public QLabel { 57 Q_OBJECT 58 59 public: 60 TagLabel(QWidget * parent); 61 62 protected: 63 QSize sizeHint() const; 64 }; 65 66 class HtmlInfoView : public QScrollArea 67 { 68 Q_OBJECT 69 public: 70 HtmlInfoView(QWidget * parent = 0); 71 ~HtmlInfoView(); 72 73 QSize sizeHint() const; 74 void setContent(const QString& html); 75 76 ItemBase *currentItem(); 77 void reloadContent(class InfoGraphicsView *); 78 79 void viewItemInfo(class InfoGraphicsView *, ItemBase* item, bool swappingEnabled); 80 void updateLocation(ItemBase *); 81 void updateRotation(ItemBase *); 82 83 void hoverEnterItem(class InfoGraphicsView *, QGraphicsSceneHoverEvent * event, ItemBase * item, bool swappingEnabled); 84 void hoverLeaveItem(class InfoGraphicsView *, QGraphicsSceneHoverEvent * event, ItemBase * item); 85 86 void hoverEnterConnectorItem(class InfoGraphicsView *, QGraphicsSceneHoverEvent * event, ConnectorItem * item, bool swappingEnabled); 87 void hoverLeaveConnectorItem(class InfoGraphicsView *, QGraphicsSceneHoverEvent * event, ConnectorItem * item); 88 89 void unregisterCurrentItem(); 90 void unregisterCurrentItemIf(long id); 91 92 void init(bool tinyMode); 93 94 public: 95 static const int STANDARD_ICON_IMG_WIDTH; 96 static const int STANDARD_ICON_IMG_HEIGHT; 97 98 static void cleanup(); 99 static QHash<QString, QString> getPartProperties(ModelPart * modelPart, ItemBase * itemBase, bool wantDebug, QStringList & keys); 100 101 signals: 102 void clickObsoleteSignal(); 103 104 protected slots: 105 void setContent(); 106 void setInstanceTitle(); 107 void instanceTitleEnter(); 108 void instanceTitleLeave(); 109 void instanceTitleEditable(bool editable); 110 void changeLock(bool); 111 void changeSticky(bool); 112 void clickObsolete(const QString &); 113 void xyEntry(); 114 void unitsClicked(); 115 void rotEntry(); 116 117 protected: 118 void appendStuff(ItemBase* item, bool swappingEnabled); //finds out if it's a wire or something else 119 void appendWireStuff(Wire* wire, bool swappingEnabled); 120 void appendItemStuff(ItemBase* base, bool swappingEnabled); 121 void appendItemStuff(ItemBase * base, ModelPart * modelPart, bool swappingEnabled); 122 123 void setInstanceTitleColors(class FLineEdit * edit, const QColor & base, const QColor & text); 124 125 void setCurrentItem(ItemBase *); 126 void setNullContent(); 127 void setUpTitle(ItemBase *); 128 void setUpIcons(ItemBase *, bool swappingEnabled); 129 void addTags(ModelPart * modelPart); 130 void partTitle(const QString & title, const QString & version, const QString & url, bool obsolete); 131 void displayProps(ModelPart * modelPart, ItemBase * itemBase, bool swappingEnabled); 132 void clearPropThingPlugin(PropThing * propThing); 133 void clearPropThingPlugin(PropThing * propThing, QWidget * plugin); 134 void viewConnectorItemInfo(QGraphicsSceneHoverEvent * event, ConnectorItem* item); 135 void showLayers(bool show, ItemBase *, const QString & family, const QString & value, bool swappingEnabled); 136 void makeLockFrame(); 137 void makeLocationFrame(); 138 void makeRotationFrame(); 139 void setLocation(ItemBase *); 140 void setRotation(ItemBase *); 141 142 protected: 143 QPointer<ItemBase> m_currentItem; 144 bool m_currentSwappingEnabled; // previous item (possibly hovered over) 145 146 QTimer m_setContentTimer; 147 QPointer<ItemBase> m_lastItemBase; 148 bool m_lastSwappingEnabled; // previous item (selected) 149 class FLineEdit * m_titleEdit; 150 QLabel * m_icon1; 151 QLabel * m_icon2; 152 QLabel * m_icon3; 153 QLabel * m_partTitle; 154 QLabel * m_partUrl; 155 QLabel * m_partVersion; 156 QLabel * m_tagsTextLabel; 157 QLabel * m_connDescr; 158 QLabel * m_connName; 159 QLabel * m_connType; 160 QLabel * m_propLabel; 161 QLabel * m_placementLabel; 162 QLabel * m_tagLabel; 163 QLabel * m_connLabel; 164 QLabel * m_layerLabel; 165 QLabel * m_lockLabel; 166 QLabel * m_locationLabel; 167 QLabel * m_rotationLabel; 168 QFrame * m_connFrame; 169 QFrame * m_propFrame; 170 QFrame * m_placementFrame; 171 QFrame * m_layerFrame; 172 QFrame * m_lockFrame; 173 QFrame * m_locationFrame; 174 QFrame * m_rotationFrame; 175 QCheckBox * m_lockCheckbox; 176 QCheckBox * m_stickyCheckbox; 177 QGridLayout * m_propLayout; 178 QGridLayout * m_placementLayout; 179 QVBoxLayout * m_layerLayout; 180 QList <PropThing *> m_propThings; 181 QPointer<ItemBase> m_pendingItemBase; 182 bool m_pendingSwappingEnabled; 183 QWidget * m_layerWidget; 184 QDoubleSpinBox * m_xEdit; 185 QDoubleSpinBox * m_yEdit; 186 QLabel * m_unitsLabel; 187 QDoubleSpinBox * m_rotEdit; 188 189 // note: these m_last items should only be checked for equality and not otherwise accessed 190 ItemBase * m_lastTitleItemBase; 191 QString m_lastPartTitle; 192 QString m_lastPartVersion; 193 ModelPart * m_lastTagsModelPart; 194 int m_lastConnectorItemCount; 195 ConnectorItem * m_lastConnectorItem; 196 ItemBase * m_lastIconItemBase; 197 ModelPart * m_lastPropsModelPart; 198 ItemBase * m_lastPropsItemBase; 199 bool m_lastPropsSwappingEnabled; 200 bool m_tinyMode; 201 }; 202 203 #endif 204