1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * This program is free software; you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License version 2 as
5  * published by the Free Software Foundation;
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software
14  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
15  *
16  * Author: John Abraham <john.abraham.in@gmail.com>
17  * Contributions: Dmitrii Shakshin <d.shakshin@gmail.com> (Open Source and Linux Laboratory http://dev.osll.ru/)
18  */
19 
20 #ifndef ANIMPROPERTYBROWSER_H
21 #define ANIMPROPERTYBROWSER_H
22 #include "common.h"
23 #include <QtTreePropertyBrowser>
24 #include <QtIntPropertyManager>
25 #include <QtSpinBoxFactory>
26 #include <QtLineEditFactory>
27 #include <QtDoubleSpinBoxFactory>
28 #include <QTableWidget>
29 #include "filepathmanager.h"
30 #include "fileeditfactory.h"
31 #include "table.h"
32 
33 
34 namespace netanim {
35 class AnimPropertyBroswer: public QWidget
36 {
37 Q_OBJECT
38 public:
39   static AnimPropertyBroswer * getInstance ();
40   void postParse ();
41   void systemReset ();
42   void show (bool show);
43   void setCurrentNodeId (uint32_t currentNodeId);
44   void showNodePositionTable (bool show);
45   void refresh ();
46 private:
47   typedef QVector <QtProperty *> QtPropertyVector_t;
48   AnimPropertyBroswer ();
49   void reset ();
50   void setupNodeProperties ();
51   void setupBackgroundProperties ();
52   void setupManagers ();
53   void setupFactories ();
54   void refreshBackgroundProperties ();
55   QVBoxLayout * m_vboxLayout;
56   QtAbstractPropertyBrowser * m_nodeBrowser;
57   QtAbstractPropertyBrowser * m_backgroundBrowser;
58   Table * m_nodePosTable;
59   QComboBox * m_mode;
60   QComboBox * m_nodeIdSelector;
61 
62   QtProperty * m_nodeIdProperty;
63   QtProperty * m_nodeSysIdProperty;
64   QtProperty * m_nodeDescriptionProperty;
65   QtProperty * m_nodeXProperty;
66   QtProperty * m_nodeYProperty;
67   QtProperty * m_nodeColorProperty;
68   QtProperty * m_nodeSizeProperty;
69   QtProperty * m_fileEditProperty;
70   QtProperty * m_ipv4AddressGroupProperty;
71   QtProperty * m_ipv6AddressGroupProperty;
72   QtProperty * m_macAddressGroupProperty;
73   QtProperty * m_nodePositionGroupProperty;
74   QtPropertyVector_t m_ipv4AddressVectorProperty;
75   QtPropertyVector_t m_ipv6AddressVectorProperty;
76   QtPropertyVector_t m_macAddressVectorProperty;
77   QtProperty * m_showNodeTrajectoryProperty;
78 
79   QtPropertyVector_t m_nodeCounterDoubleProperty;
80   QtPropertyVector_t m_nodeCounterUint32Property;
81 
82 
83   // Background
84   QtProperty * m_backgroundFileEditProperty;
85   QtProperty * m_backgroundX;
86   QtProperty * m_backgroundY;
87   QtProperty * m_backgroundScaleX;
88   QtProperty * m_backgroundScaleY;
89   QtProperty * m_backgroundOpacity;
90 
91   uint32_t m_currentNodeId;
92 
93   QtIntPropertyManager * m_intManager;
94   QtStringPropertyManager * m_stringManager;
95   QtDoublePropertyManager * m_doubleManager;
96   QtDoublePropertyManager * m_backgroundDoubleManager;
97 
98   QtColorPropertyManager * m_colorManager;
99   FilePathManager * m_filePathManager;
100   QtGroupPropertyManager * m_nodePositionManager;
101   QtGroupPropertyManager * m_ipv4AddressManager;
102   QtGroupPropertyManager * m_ipv6AddressManager;
103 
104   QtGroupPropertyManager * m_macAddressManager;
105   QtStringPropertyManager * m_staticStringManager;
106   QtBoolPropertyManager * m_boolManager;
107 
108   QtDoubleSpinBoxFactory * m_doubleSpinBoxFactory;
109   QtSpinBoxFactory * m_spinBoxFactory;
110   FileEditFactory * m_fileEditFactory;
111   QtLineEditFactory * m_lineEditFactory;
112   QtCheckBoxFactory * m_checkBoxFactory;
113 
114 
115 
116   typedef std::map <QtProperty *, QString> PropertyIdMap_t;
117   PropertyIdMap_t m_propertyId;
118 private slots:
119   void nodeIdSelectorSlot (QString newIndex);
120   void valueChangedSlot (QtProperty*, QString);
121   void valueChangedSlot (QtProperty*, double);
122   void valueChangedSlot (QtProperty*, QColor);
123   void valueChangedSlot (QtProperty* ,bool);
124   void modeChangedSlot (QString mode);
125 
126 };
127 
128 } // namespace netanim
129 #endif // ANIMPROPERTYBROWSER_H
130