@@ -0,0 +1,25 | |||
|
1 | <?xml version="1.0" encoding="UTF-8" standalone="no"?> | |
|
2 | <!-- Created with Inkscape (http://www.inkscape.org/) --> | |
|
3 | <svg xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://web.resource.org/cc/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" width="48" height="48" id="svg4289" sodipodi:version="0.32" inkscape:version="0.45" version="1.0" sodipodi:docbase="/home/dobey/Projects/gnome-icon-theme/scalable/actions" sodipodi:docname="list-add.svg" inkscape:export-filename="/home/andreas/project/gnome-icon-theme/scalable/actions/list-add.png" inkscape:export-xdpi="90" inkscape:export-ydpi="90" inkscape:output_extension="org.inkscape.output.svg.inkscape"> | |
|
4 | <defs id="defs4291"> | |
|
5 | <linearGradient inkscape:collect="always" id="linearGradient4622"> | |
|
6 | <stop style="stop-color:#b4b5b3;stop-opacity:1" offset="0" id="stop4624"/> | |
|
7 | <stop style="stop-color:#d8d9d7;stop-opacity:1" offset="1" id="stop4626"/> | |
|
8 | </linearGradient> | |
|
9 | <linearGradient inkscape:collect="always" xlink:href="#linearGradient4622" id="linearGradient4320" gradientUnits="userSpaceOnUse" gradientTransform="matrix(2.810197,0,0,2.747234,1.562312,1.675085)" x1="8.6790628" y1="6.7354665" x2="8.7223368" y2="10.858153"/> | |
|
10 | </defs> | |
|
11 | <sodipodi:namedview id="base" pagecolor="#ffffff" bordercolor="#666666" borderopacity="1.0" inkscape:pageopacity="0.0" inkscape:pageshadow="2" inkscape:zoom="16" inkscape:cx="28.380765" inkscape:cy="26.638236" inkscape:current-layer="layer1" showgrid="false" inkscape:grid-bbox="true" inkscape:document-units="px" width="48px" height="48px" showguides="true" inkscape:guide-bbox="true" inkscape:window-width="1673" inkscape:window-height="968" inkscape:window-x="1" inkscape:window-y="27"/> | |
|
12 | <metadata id="metadata4294"> | |
|
13 | <rdf:RDF> | |
|
14 | <cc:Work rdf:about=""> | |
|
15 | <dc:format>image/svg+xml</dc:format> | |
|
16 | <dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/> | |
|
17 | </cc:Work> | |
|
18 | </rdf:RDF> | |
|
19 | </metadata> | |
|
20 | <g id="layer1" inkscape:label="Layer 1" inkscape:groupmode="layer"> | |
|
21 | <path style="opacity:1;fill:url(#linearGradient4320);fill-opacity:1;stroke:#555753;stroke-width:1.00000048;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" d="M 8.4999995,21.548779 L 8.4999995,26.514266 L 21.542175,26.514266 L 21.542175,38.455753 L 26.527841,38.500024 L 26.499007,26.514266 L 39.499998,26.469995 L 39.499998,21.548779 L 26.478909,21.548779 L 26.482175,8.542935 L 21.498141,8.5000092 L 21.496508,21.55147 L 8.4999995,21.548779 z " id="path4314" sodipodi:nodetypes="ccccccccccccc"/> | |
|
22 | <path style="opacity:0.2;fill:white;fill-opacity:1;stroke:none;stroke-width:0.99999994;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1" d="M 9,22.072045 L 22.070199,22.072045 L 22.065556,9 L 26.002778,9.1688851 L 25.957932,22.156486 L 38.906989,22.072045 L 38.906989,24.048454 L 9,24.048454 L 9,22.072045 z " id="path4316" sodipodi:nodetypes="ccccccccc"/> | |
|
23 | <path style="opacity:0.4;fill:none;fill-opacity:1;stroke:white;stroke-width:1.00000024;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" d="M 9.5000012,22.518518 L 9.5000012,25.561981 L 22.540436,25.561981 L 22.540436,37.458666 L 25.525069,37.499986 L 25.498095,25.561981 L 38.500003,25.520661 L 38.500003,22.518518 L 25.567682,22.518518 L 25.570737,9.540046 L 22.499243,9.499982 L 22.497715,22.52103 L 9.5000012,22.518518 z " id="path5202" sodipodi:nodetypes="ccccccccccccc"/> | |
|
24 | </g> | |
|
25 | </svg> No newline at end of file |
@@ -0,0 +1,48 | |||
|
1 | <?xml version="1.0" encoding="UTF-8" standalone="no"?> | |
|
2 | <!-- Created with Inkscape (http://www.inkscape.org/) --> | |
|
3 | <svg xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://web.resource.org/cc/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" width="48" height="48" id="svg4289" sodipodi:version="0.32" inkscape:version="0.45" version="1.0" sodipodi:docbase="/home/dobey/Projects/gnome-icon-theme/scalable/actions" sodipodi:docname="list-remove.svg" inkscape:export-filename="/home/andreas/project/gnome-icon-theme/22x22/actions/list-add.png" inkscape:export-xdpi="90" inkscape:export-ydpi="90" inkscape:output_extension="org.inkscape.output.svg.inkscape"> | |
|
4 | <defs id="defs4291"> | |
|
5 | <linearGradient inkscape:collect="always" id="linearGradient4622"> | |
|
6 | <stop style="stop-color:#b4b5b3;stop-opacity:1" offset="0" id="stop4624"/> | |
|
7 | <stop style="stop-color:#d8d9d7;stop-opacity:1" offset="1" id="stop4626"/> | |
|
8 | </linearGradient> | |
|
9 | <linearGradient inkscape:collect="always" xlink:href="#linearGradient4622" id="linearGradient4320" gradientUnits="userSpaceOnUse" gradientTransform="matrix(2.810197,0,0,2.747234,1.562312,1.675085)" x1="8.6790628" y1="6.7354665" x2="8.7223368" y2="10.858153"/> | |
|
10 | </defs> | |
|
11 | <sodipodi:namedview id="base" pagecolor="#ffffff" bordercolor="#666666" borderopacity="1.0" inkscape:pageopacity="0.0" inkscape:pageshadow="2" inkscape:zoom="16" inkscape:cx="28.380765" inkscape:cy="26.606986" inkscape:current-layer="layer1" showgrid="false" inkscape:grid-bbox="true" inkscape:document-units="px" width="48px" height="48px" showguides="true" inkscape:guide-bbox="true" inkscape:window-width="1673" inkscape:window-height="968" inkscape:window-x="1" inkscape:window-y="27"/> | |
|
12 | <metadata id="metadata4294"> | |
|
13 | <rdf:RDF> | |
|
14 | <cc:Work rdf:about=""> | |
|
15 | <dc:format>image/svg+xml</dc:format> | |
|
16 | <dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/> | |
|
17 | <cc:license rdf:resource="http://creativecommons.org/licenses/GPL/2.0/"/> | |
|
18 | <dc:title>List remove</dc:title> | |
|
19 | <dc:date>August 2006</dc:date> | |
|
20 | <dc:creator> | |
|
21 | <cc:Agent> | |
|
22 | <dc:title>Andreas Nilsson</dc:title> | |
|
23 | </cc:Agent> | |
|
24 | </dc:creator> | |
|
25 | <dc:source>http://www.gnome.org</dc:source> | |
|
26 | <dc:subject> | |
|
27 | <rdf:Bag> | |
|
28 | <rdf:li>remove</rdf:li> | |
|
29 | <rdf:li>minus</rdf:li> | |
|
30 | </rdf:Bag> | |
|
31 | </dc:subject> | |
|
32 | </cc:Work> | |
|
33 | <cc:License rdf:about="http://creativecommons.org/licenses/GPL/2.0/"> | |
|
34 | <cc:permits rdf:resource="http://web.resource.org/cc/Reproduction"/> | |
|
35 | <cc:permits rdf:resource="http://web.resource.org/cc/Distribution"/> | |
|
36 | <cc:requires rdf:resource="http://web.resource.org/cc/Notice"/> | |
|
37 | <cc:permits rdf:resource="http://web.resource.org/cc/DerivativeWorks"/> | |
|
38 | <cc:requires rdf:resource="http://web.resource.org/cc/ShareAlike"/> | |
|
39 | <cc:requires rdf:resource="http://web.resource.org/cc/SourceCode"/> | |
|
40 | </cc:License> | |
|
41 | </rdf:RDF> | |
|
42 | </metadata> | |
|
43 | <g id="layer1" inkscape:label="Layer 1" inkscape:groupmode="layer"> | |
|
44 | <path style="opacity:1;fill:url(#linearGradient4320);fill-opacity:1;stroke:#555753;stroke-width:1.00000048;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" d="M 8.4999995,21.548779 L 8.4999995,26.514266 L 39.499998,26.469995 L 39.499998,21.548779 L 8.4999995,21.548779 z " id="path4314" sodipodi:nodetypes="ccccc"/> | |
|
45 | <path style="opacity:0.2;fill:white;fill-opacity:1;stroke:none;stroke-width:0.99999994;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1" d="M 9,22.072045 L 38.906989,22.072045 L 38.906989,24.048454 L 9,24.048454 L 9,22.072045 z " id="path4316" sodipodi:nodetypes="ccccc"/> | |
|
46 | <path style="opacity:0.4;fill:none;fill-opacity:1;stroke:white;stroke-width:1.00000024;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" d="M 9.5000012,22.518518 L 9.5000012,25.561981 L 38.500003,25.520661 L 38.500003,22.518518 L 9.5000012,22.518518 z " id="path5202" sodipodi:nodetypes="ccccc"/> | |
|
47 | </g> | |
|
48 | </svg> No newline at end of file |
@@ -0,0 +1,6 | |||
|
1 | <RCC> | |
|
2 | <qresource prefix="/img"> | |
|
3 | <file>Gnome-list-add.svg</file> | |
|
4 | <file>Gnome-list-remove.svg</file> | |
|
5 | </qresource> | |
|
6 | </RCC> |
@@ -0,0 +1,102 | |||
|
1 | #include "collapsableperipheralwidget.h" | |
|
2 | #include "ui_collapsableperipheralwidget.h" | |
|
3 | #include <QCursor> | |
|
4 | ||
|
5 | ||
|
6 | CollapsablePeripheralWidget::CollapsablePeripheralWidget(peripheralWidget *periph, QWidget *parent) : | |
|
7 | QWidget(parent), | |
|
8 | ui(new Ui::CollapsablePeripheralWidget) | |
|
9 | { | |
|
10 | m_periph=0; | |
|
11 | m_collapsed = true; | |
|
12 | ui->setupUi(this); | |
|
13 | tthidetmr.setSingleShot(true); | |
|
14 | tthidetmr.setInterval(200); | |
|
15 | connect(this->ui->collapseQpb,SIGNAL(clicked()),this,SLOT(collapse())); | |
|
16 | connect(this->ui->periphName,SIGNAL(clicked()),this,SLOT(collapse())); | |
|
17 | connect(this->ui->periphName,SIGNAL(enter()),this,SLOT(showTooltip())); | |
|
18 | connect(this->ui->periphName,SIGNAL(leave()),&this->tthidetmr,SLOT(start())); | |
|
19 | connect(&this->tthidetmr,SIGNAL(timeout()),this,SLOT(hideTooltip())); | |
|
20 | setPeripheralWidget(periph); | |
|
21 | } | |
|
22 | ||
|
23 | CollapsablePeripheralWidget::~CollapsablePeripheralWidget() | |
|
24 | { | |
|
25 | delete ui; | |
|
26 | } | |
|
27 | ||
|
28 | void CollapsablePeripheralWidget::setPeripheralWidget(peripheralWidget *periph) | |
|
29 | { | |
|
30 | if(periph) | |
|
31 | { | |
|
32 | this->m_periph = periph; | |
|
33 | this->ui->gridLayout->addWidget(periph,1,0,1,-1); | |
|
34 | this->ui->periphName->setText(periph->name()); | |
|
35 | this->m_periph->setVisible(false); | |
|
36 | } | |
|
37 | } | |
|
38 | ||
|
39 | peripheralWidget *CollapsablePeripheralWidget::getPeripheralWidget() | |
|
40 | { | |
|
41 | return m_periph; | |
|
42 | } | |
|
43 | ||
|
44 | void CollapsablePeripheralWidget::changeEvent(QEvent *e) | |
|
45 | { | |
|
46 | QWidget::changeEvent(e); | |
|
47 | switch (e->type()) { | |
|
48 | case QEvent::LanguageChange: | |
|
49 | ui->retranslateUi(this); | |
|
50 | break; | |
|
51 | default: | |
|
52 | break; | |
|
53 | } | |
|
54 | } | |
|
55 | ||
|
56 | void CollapsablePeripheralWidget::collapse() | |
|
57 | { | |
|
58 | this->m_periph->setVisible(m_collapsed); | |
|
59 | if(this->m_collapsed) | |
|
60 | { | |
|
61 | this->ui->collapseQpb->setIcon(QIcon(":/img/Gnome-list-remove.svg")); | |
|
62 | } | |
|
63 | else | |
|
64 | { | |
|
65 | this->ui->collapseQpb->setIcon(QIcon(":/img/Gnome-list-add.svg")); | |
|
66 | } | |
|
67 | m_collapsed = !m_collapsed; | |
|
68 | } | |
|
69 | ||
|
70 | void CollapsablePeripheralWidget::setName(const QString &name) | |
|
71 | { | |
|
72 | if(m_periph) | |
|
73 | { | |
|
74 | this->ui->periphName->setText(name); | |
|
75 | } | |
|
76 | } | |
|
77 | ||
|
78 | void CollapsablePeripheralWidget::showTooltip() | |
|
79 | { | |
|
80 | if(!m_periph->isVisible() && m_collapsed) | |
|
81 | { | |
|
82 | m_periph->show(); | |
|
83 | } | |
|
84 | } | |
|
85 | ||
|
86 | void CollapsablePeripheralWidget::hideTooltip() | |
|
87 | { | |
|
88 | if(m_periph->isVisible() && m_collapsed) | |
|
89 | { | |
|
90 | QRect temprect = this->geometry(); | |
|
91 | temprect.moveTo(this->mapToGlobal(mapFromParent(QPoint(this->x(),this->y())))); | |
|
92 | if(temprect.contains(QCursor::pos())) | |
|
93 | { | |
|
94 | this->tthidetmr.start(); | |
|
95 | } | |
|
96 | else | |
|
97 | { | |
|
98 | m_periph->hide(); | |
|
99 | } | |
|
100 | } | |
|
101 | } | |
|
102 |
@@ -0,0 +1,56 | |||
|
1 | #ifndef COLLAPSABLEPERIPHERALWIDGET_H | |
|
2 | #define COLLAPSABLEPERIPHERALWIDGET_H | |
|
3 | ||
|
4 | #include <QWidget> | |
|
5 | #include <peripheralwidget.h> | |
|
6 | #include <QTimer> | |
|
7 | ||
|
8 | namespace Ui { | |
|
9 | class CollapsablePeripheralWidget; | |
|
10 | } | |
|
11 | ||
|
12 | class QRegToolTipLabel : public QLabel | |
|
13 | { | |
|
14 | Q_OBJECT | |
|
15 | public: | |
|
16 | QRegToolTipLabel(QWidget * parent = 0, Qt::WindowFlags f = 0):QLabel(parent,f){} | |
|
17 | QRegToolTipLabel(const QString & text, QWidget * parent = 0, Qt::WindowFlags f = 0):QLabel(text,parent,f){} | |
|
18 | signals: | |
|
19 | void enter(); | |
|
20 | void leave(); | |
|
21 | void clicked(); | |
|
22 | protected: | |
|
23 | void enterEvent(QEvent* event){emit enter();QLabel::enterEvent(event);} | |
|
24 | void leaveEvent(QEvent* event){emit leave();QLabel::leaveEvent(event);} | |
|
25 | void mousePressEvent(QMouseEvent * event){emit clicked();QLabel::mousePressEvent(event);} | |
|
26 | }; | |
|
27 | ||
|
28 | class CollapsablePeripheralWidget : public QWidget | |
|
29 | { | |
|
30 | Q_OBJECT | |
|
31 | ||
|
32 | public: | |
|
33 | explicit CollapsablePeripheralWidget(peripheralWidget* periph,QWidget *parent = 0); | |
|
34 | ~CollapsablePeripheralWidget(); | |
|
35 | void setPeripheralWidget(peripheralWidget* periph); | |
|
36 | peripheralWidget* getPeripheralWidget(); | |
|
37 | protected: | |
|
38 | void changeEvent(QEvent *e); | |
|
39 | ||
|
40 | public slots: | |
|
41 | void collapse(); | |
|
42 | void setName(const QString& name); | |
|
43 | void showTooltip(); | |
|
44 | void hideTooltip(); | |
|
45 | signals: | |
|
46 | void clicked(peripheralWidget* sender); | |
|
47 | void upSig(peripheralWidget* sender,int cursorIndex); | |
|
48 | void downSig(peripheralWidget* sender,int cursorIndex); | |
|
49 | private: | |
|
50 | Ui::CollapsablePeripheralWidget *ui; | |
|
51 | peripheralWidget* m_periph; | |
|
52 | bool m_collapsed; | |
|
53 | QTimer tthidetmr; | |
|
54 | }; | |
|
55 | ||
|
56 | #endif // COLLAPSABLEPERIPHERALWIDGET_H |
@@ -0,0 +1,89 | |||
|
1 | <?xml version="1.0" encoding="UTF-8"?> | |
|
2 | <ui version="4.0"> | |
|
3 | <class>CollapsablePeripheralWidget</class> | |
|
4 | <widget class="QWidget" name="CollapsablePeripheralWidget"> | |
|
5 | <property name="geometry"> | |
|
6 | <rect> | |
|
7 | <x>0</x> | |
|
8 | <y>0</y> | |
|
9 | <width>845</width> | |
|
10 | <height>249</height> | |
|
11 | </rect> | |
|
12 | </property> | |
|
13 | <property name="sizePolicy"> | |
|
14 | <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> | |
|
15 | <horstretch>0</horstretch> | |
|
16 | <verstretch>0</verstretch> | |
|
17 | </sizepolicy> | |
|
18 | </property> | |
|
19 | <property name="windowTitle"> | |
|
20 | <string>Form</string> | |
|
21 | </property> | |
|
22 | <property name="styleSheet"> | |
|
23 | <string notr="true">QWidget#CollapsablePeripheralWidget { | |
|
24 | border: 1px solid gray; | |
|
25 | border-radius: 9px; | |
|
26 | }</string> | |
|
27 | </property> | |
|
28 | <layout class="QGridLayout" name="gridLayout"> | |
|
29 | <item row="0" column="2"> | |
|
30 | <widget class="QPushButton" name="collapseQpb"> | |
|
31 | <property name="sizePolicy"> | |
|
32 | <sizepolicy hsizetype="Maximum" vsizetype="Fixed"> | |
|
33 | <horstretch>0</horstretch> | |
|
34 | <verstretch>0</verstretch> | |
|
35 | </sizepolicy> | |
|
36 | </property> | |
|
37 | <property name="text"> | |
|
38 | <string/> | |
|
39 | </property> | |
|
40 | <property name="icon"> | |
|
41 | <iconset resource="../ressources/peripheralwidget.qrc"> | |
|
42 | <normaloff>:/img/Gnome-list-add.svg</normaloff> | |
|
43 | <normalon>:/img/Gnome-list-remove.svg</normalon>:/img/Gnome-list-add.svg</iconset> | |
|
44 | </property> | |
|
45 | <property name="flat"> | |
|
46 | <bool>true</bool> | |
|
47 | </property> | |
|
48 | </widget> | |
|
49 | </item> | |
|
50 | <item row="0" column="0"> | |
|
51 | <widget class="QRegToolTipLabel" name="periphName"> | |
|
52 | <property name="sizePolicy"> | |
|
53 | <sizepolicy hsizetype="Minimum" vsizetype="Preferred"> | |
|
54 | <horstretch>0</horstretch> | |
|
55 | <verstretch>0</verstretch> | |
|
56 | </sizepolicy> | |
|
57 | </property> | |
|
58 | <property name="text"> | |
|
59 | <string>PeriphName</string> | |
|
60 | </property> | |
|
61 | </widget> | |
|
62 | </item> | |
|
63 | <item row="0" column="1"> | |
|
64 | <spacer name="horizontalSpacer"> | |
|
65 | <property name="orientation"> | |
|
66 | <enum>Qt::Horizontal</enum> | |
|
67 | </property> | |
|
68 | <property name="sizeHint" stdset="0"> | |
|
69 | <size> | |
|
70 | <width>40</width> | |
|
71 | <height>20</height> | |
|
72 | </size> | |
|
73 | </property> | |
|
74 | </spacer> | |
|
75 | </item> | |
|
76 | </layout> | |
|
77 | </widget> | |
|
78 | <customwidgets> | |
|
79 | <customwidget> | |
|
80 | <class>QRegToolTipLabel</class> | |
|
81 | <extends>QLabel</extends> | |
|
82 | <header location="global">collapsableperipheralwidget.h</header> | |
|
83 | </customwidget> | |
|
84 | </customwidgets> | |
|
85 | <resources> | |
|
86 | <include location="../ressources/peripheralwidget.qrc"/> | |
|
87 | </resources> | |
|
88 | <connections/> | |
|
89 | </ui> |
@@ -0,0 +1,107 | |||
|
1 | #include "socregsviewernew.h" | |
|
2 | #include "ui_socregsviewernew.h" | |
|
3 | ||
|
4 | SocRegsViewerNew::SocRegsViewerNew(const QString &name,QWidget *parent) : | |
|
5 | QWidget(parent), | |
|
6 | ui(new Ui::SocRegsViewerNew) | |
|
7 | { | |
|
8 | ui->setupUi(this); | |
|
9 | this->ui->socName->setText(name); | |
|
10 | } | |
|
11 | ||
|
12 | SocRegsViewerNew::~SocRegsViewerNew() | |
|
13 | { | |
|
14 | delete ui; | |
|
15 | } | |
|
16 | ||
|
17 | peripheralWidget *SocRegsViewerNew::peripheral(int index) | |
|
18 | { | |
|
19 | if(index>=0 && index<p_peripherals.count()) | |
|
20 | { | |
|
21 | return p_peripherals.at(index); | |
|
22 | } | |
|
23 | return NULL; | |
|
24 | } | |
|
25 | ||
|
26 | void SocRegsViewerNew::addPeripheral(peripheralWidget *peripheral) | |
|
27 | { | |
|
28 | if(peripheral!=NULL) | |
|
29 | { | |
|
30 | CollapsablePeripheralWidget* cperiph = new CollapsablePeripheralWidget(peripheral); | |
|
31 | cperiph->setPeripheralWidget(peripheral); | |
|
32 | p_peripherals.append(peripheral); | |
|
33 | p_CPeripherals.append(cperiph); | |
|
34 | this->ui->scrollAreaWidgetContents->layout()->addWidget(cperiph); | |
|
35 | connect(cperiph,SIGNAL(clicked(peripheralWidget*)),this,SLOT(periphClicked(peripheralWidget*))); | |
|
36 | connect(cperiph,SIGNAL(upSig(peripheralWidget*,int)),this,SLOT(periphUp(peripheralWidget*,int))); | |
|
37 | connect(cperiph,SIGNAL(downSig(peripheralWidget*,int)),this,SLOT(periphDown(peripheralWidget*,int))); | |
|
38 | } | |
|
39 | } | |
|
40 | ||
|
41 | void SocRegsViewerNew::periphClicked(peripheralWidget *sender) | |
|
42 | { | |
|
43 | peripheralWidget * item; | |
|
44 | if(sender!=NULL) | |
|
45 | { | |
|
46 | for(int i=0;i<p_peripherals.count();i++) | |
|
47 | { | |
|
48 | item = p_peripherals.at(i); | |
|
49 | if(item!=sender) | |
|
50 | { | |
|
51 | item->leave(); | |
|
52 | } | |
|
53 | } | |
|
54 | } | |
|
55 | } | |
|
56 | ||
|
57 | void SocRegsViewerNew::periphUp(peripheralWidget *sender, int cursorIndex) | |
|
58 | { | |
|
59 | int index,senderIndex; | |
|
60 | if(sender!=NULL) | |
|
61 | { | |
|
62 | index =senderIndex= p_peripherals.indexOf(sender); | |
|
63 | while(index!=-1 && index!=0) | |
|
64 | { | |
|
65 | if(p_peripherals.at(index-1)->count()>0) | |
|
66 | { | |
|
67 | p_peripherals.at(senderIndex)->leave(); | |
|
68 | p_peripherals.at(index-1)->enter(cursorIndex,false); | |
|
69 | // ensureWidgetVisible(p_peripherals.at(index-1)); | |
|
70 | break; | |
|
71 | } | |
|
72 | index--; | |
|
73 | } | |
|
74 | } | |
|
75 | } | |
|
76 | ||
|
77 | void SocRegsViewerNew::periphDown(peripheralWidget *sender, int cursorIndex) | |
|
78 | { | |
|
79 | int index,senderIndex; | |
|
80 | if(sender!=NULL) | |
|
81 | { | |
|
82 | index=senderIndex= p_peripherals.indexOf(sender); | |
|
83 | while((index!=-1) && (index<(p_peripherals.count()-1))) | |
|
84 | { | |
|
85 | if(p_peripherals.at(index+1)->count()>0) | |
|
86 | { | |
|
87 | p_peripherals.at(senderIndex)->leave(); | |
|
88 | p_peripherals.at(index+1)->enter(cursorIndex); | |
|
89 | // ensureWidgetVisible(p_peripherals.at(index+1)); | |
|
90 | break; | |
|
91 | } | |
|
92 | index++; | |
|
93 | } | |
|
94 | } | |
|
95 | } | |
|
96 | ||
|
97 | void SocRegsViewerNew::changeEvent(QEvent *e) | |
|
98 | { | |
|
99 | QWidget::changeEvent(e); | |
|
100 | switch (e->type()) { | |
|
101 | case QEvent::LanguageChange: | |
|
102 | ui->retranslateUi(this); | |
|
103 | break; | |
|
104 | default: | |
|
105 | break; | |
|
106 | } | |
|
107 | } |
@@ -0,0 +1,38 | |||
|
1 | #ifndef SOCREGSVIEWERNEW_H | |
|
2 | #define SOCREGSVIEWERNEW_H | |
|
3 | ||
|
4 | #include <QWidget> | |
|
5 | #include <peripheralwidget.h> | |
|
6 | #include <collapsableperipheralwidget.h> | |
|
7 | ||
|
8 | namespace Ui { | |
|
9 | class SocRegsViewerNew; | |
|
10 | } | |
|
11 | ||
|
12 | class SocRegsViewerNew : public QWidget | |
|
13 | { | |
|
14 | Q_OBJECT | |
|
15 | ||
|
16 | public: | |
|
17 | explicit SocRegsViewerNew(const QString &name, QWidget *parent = 0); | |
|
18 | ~SocRegsViewerNew(); | |
|
19 | ||
|
20 | peripheralWidget *peripheral(int index); | |
|
21 | ||
|
22 | signals: | |
|
23 | ||
|
24 | public slots: | |
|
25 | void addPeripheral(peripheralWidget* peripheral); | |
|
26 | void periphClicked(peripheralWidget* sender); | |
|
27 | void periphUp(peripheralWidget* sender,int cursorIndex); | |
|
28 | void periphDown(peripheralWidget* sender,int cursorIndex); | |
|
29 | protected: | |
|
30 | void changeEvent(QEvent *e); | |
|
31 | ||
|
32 | private: | |
|
33 | Ui::SocRegsViewerNew *ui; | |
|
34 | QList<peripheralWidget*> p_peripherals; | |
|
35 | QList<CollapsablePeripheralWidget*> p_CPeripherals; | |
|
36 | }; | |
|
37 | ||
|
38 | #endif // SOCREGSVIEWERNEW_H |
@@ -0,0 +1,60 | |||
|
1 | <?xml version="1.0" encoding="UTF-8"?> | |
|
2 | <ui version="4.0"> | |
|
3 | <class>SocRegsViewerNew</class> | |
|
4 | <widget class="QWidget" name="SocRegsViewerNew"> | |
|
5 | <property name="geometry"> | |
|
6 | <rect> | |
|
7 | <x>0</x> | |
|
8 | <y>0</y> | |
|
9 | <width>713</width> | |
|
10 | <height>357</height> | |
|
11 | </rect> | |
|
12 | </property> | |
|
13 | <property name="windowTitle"> | |
|
14 | <string>Form</string> | |
|
15 | </property> | |
|
16 | <layout class="QGridLayout" name="gridLayout"> | |
|
17 | <item row="0" column="1"> | |
|
18 | <widget class="QComboBox" name="rootPluginCmbBx"/> | |
|
19 | </item> | |
|
20 | <item row="2" column="0" colspan="2"> | |
|
21 | <widget class="QScrollArea" name="PeriphList"> | |
|
22 | <property name="widgetResizable"> | |
|
23 | <bool>true</bool> | |
|
24 | </property> | |
|
25 | <widget class="QWidget" name="scrollAreaWidgetContents"> | |
|
26 | <property name="geometry"> | |
|
27 | <rect> | |
|
28 | <x>0</x> | |
|
29 | <y>0</y> | |
|
30 | <width>693</width> | |
|
31 | <height>302</height> | |
|
32 | </rect> | |
|
33 | </property> | |
|
34 | <layout class="QVBoxLayout" name="verticalLayout"> | |
|
35 | <item> | |
|
36 | <widget class="QLabel" name="socName"> | |
|
37 | <property name="text"> | |
|
38 | <string>SocName</string> | |
|
39 | </property> | |
|
40 | <property name="alignment"> | |
|
41 | <set>Qt::AlignCenter</set> | |
|
42 | </property> | |
|
43 | </widget> | |
|
44 | </item> | |
|
45 | </layout> | |
|
46 | </widget> | |
|
47 | </widget> | |
|
48 | </item> | |
|
49 | <item row="0" column="0"> | |
|
50 | <widget class="QLabel" name="label"> | |
|
51 | <property name="text"> | |
|
52 | <string>Root Plugin</string> | |
|
53 | </property> | |
|
54 | </widget> | |
|
55 | </item> | |
|
56 | </layout> | |
|
57 | </widget> | |
|
58 | <resources/> | |
|
59 | <connections/> | |
|
60 | </ui> |
@@ -1,14 +1,23 | |||
|
1 | 1 | |
|
2 | 2 | PERIPHERAL_WDGT_SOURCES =\ |
|
3 | 3 | src/peripheralwidget.cpp \ |
|
4 | 4 | src/registerwidget.cpp \ |
|
5 | src/socregsviewer.cpp | |
|
6 | ||
|
5 | src/socregsviewer.cpp \ | |
|
6 | src/socregsviewernew.cpp \ | |
|
7 | src/collapsableperipheralwidget.cpp | |
|
7 | 8 | |
|
8 | 9 | |
|
9 | 10 | PERIPHERAL_WDGT_HEADERS += \ |
|
10 | 11 | src/peripheralwidget.h \ |
|
11 | 12 | src/registerwidget.h \ |
|
12 | src/socregsviewer.h | |
|
13 | src/socregsviewer.h \ | |
|
14 | src/socregsviewernew.h \ | |
|
15 | src/collapsableperipheralwidget.h | |
|
13 | 16 | |
|
17 | PERIPHERAL_WDGT_FORMS += \ | |
|
18 | src/socregsviewernew.ui \ | |
|
19 | src/collapsableperipheralwidget.ui | |
|
14 | 20 | |
|
21 | PERIPHERAL_WDGT_RESOURCES += \ | |
|
22 | $$PWD/ressources/peripheralwidget.qrc | |
|
23 |
@@ -1,279 +1,293 | |||
|
1 | 1 | /*------------------------------------------------------------------------------ |
|
2 | 2 | -- This file is a part of the SocExplorer Software |
|
3 | 3 | -- Copyright (C) 2014, Plasma Physics Laboratory - CNRS |
|
4 | 4 | -- |
|
5 | 5 | -- This program is free software; you can redistribute it and/or modify |
|
6 | 6 | -- it under the terms of the GNU General Public License as published by |
|
7 | 7 | -- the Free Software Foundation; either version 3 of the License, or |
|
8 | 8 | -- (at your option) any later version. |
|
9 | 9 | -- |
|
10 | 10 | -- This program is distributed in the hope that it will be useful, |
|
11 | 11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 | 12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 | 13 | -- GNU General Public License for more details. |
|
14 | 14 | -- |
|
15 | 15 | -- You should have received a copy of the GNU General Public License |
|
16 | 16 | -- along with this program; if not, write to the Free Software |
|
17 | 17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
18 | 18 | -------------------------------------------------------------------------------*/ |
|
19 | 19 | /*-- Author : Alexis Jeandet |
|
20 | 20 | -- Mail : alexis.jeandet@member.fsf.org |
|
21 | 21 | ----------------------------------------------------------------------------*/ |
|
22 | 22 | #include "peripheralwidget.h" |
|
23 | 23 | |
|
24 | peripheralWidget::peripheralWidget(const QString &name, qint32 baseAddress, QWidget *parent) : | |
|
24 | peripheralWidget::peripheralWidget(const QString &name, qint32 baseAddress, readWriteProxy *proxy, QWidget *parent) : | |
|
25 | 25 | QWidget(parent) |
|
26 | 26 | { |
|
27 | 27 | p_name = name; |
|
28 | 28 | p_timer = new QTimer(this); |
|
29 | 29 | p_timer->setInterval(500); |
|
30 | 30 | p_baseAddress = baseAddress; |
|
31 | 31 | p_header = p_name + QString(" @0x%1").arg((uint)p_baseAddress,8,16); |
|
32 | p_proxy = proxy; | |
|
32 | 33 | setAttribute(Qt::WA_AlwaysShowToolTips); |
|
33 | 34 | setMouseTracking(true); |
|
34 | 35 | setFocusPolicy(Qt::StrongFocus); |
|
35 | 36 | selectedReg = -1; |
|
36 | 37 | registersWdgts.clear(); |
|
37 | 38 | connect(p_timer,SIGNAL(timeout()),this,SLOT(blinkCursor())); |
|
38 | 39 | setFont(QFont("Utopia", 14,QFont::Bold)); |
|
40 | setMinimumSize(400,100); | |
|
41 | updateGeometry(); | |
|
39 | 42 | } |
|
40 | 43 | |
|
41 | 44 | int peripheralWidget::count() |
|
42 | 45 | { |
|
43 | 46 | return registersWdgts.count(); |
|
44 | 47 | } |
|
45 | 48 | |
|
49 | const QString &peripheralWidget::name() | |
|
50 | { | |
|
51 | return this->p_name; | |
|
52 | } | |
|
53 | ||
|
46 | 54 | void peripheralWidget::blinkCursor() |
|
47 | 55 | { |
|
48 | 56 | if(selectedReg!=-1) |
|
49 | 57 | registersWdgts.at(selectedReg)->blinkCursor(); |
|
50 | 58 | repaint(); |
|
51 | 59 | } |
|
52 | 60 | |
|
53 | 61 | void peripheralWidget::addRegister(const QString &name, qint32 address) |
|
54 | 62 | { |
|
55 | 63 | /*TODO Should regs by address*/ |
|
56 | 64 | registersWdgts.append(new registerWidget(name,address)); |
|
57 | 65 | connect(registersWdgts.last(),SIGNAL(repaint()),this,SLOT(repaint())); |
|
58 | 66 | } |
|
59 | 67 | |
|
60 | 68 | void peripheralWidget::leave() |
|
61 | 69 | { |
|
62 | 70 | if(selectedReg!=-1) |
|
63 | 71 | { |
|
64 | 72 | p_timer->stop(); |
|
65 | 73 | registersWdgts.at(selectedReg)->leave(); |
|
66 | 74 | selectedReg = -1; |
|
67 | 75 | repaint(); |
|
68 | 76 | } |
|
69 | 77 | } |
|
70 | 78 | |
|
71 | 79 | void peripheralWidget::enter(int cursorIndex, bool fromTop) |
|
72 | 80 | { |
|
73 | 81 | if(cursorIndex>=0 && cursorIndex<32) |
|
74 | 82 | { |
|
75 | 83 | if(fromTop) |
|
76 | 84 | { |
|
77 | 85 | registersWdgts.at(0)->enter(cursorIndex); |
|
78 | 86 | selectedReg = 0; |
|
79 | 87 | } |
|
80 | 88 | else |
|
81 | 89 | { |
|
82 | 90 | registersWdgts.at(registersWdgts.count()-1)->enter(cursorIndex); |
|
83 | 91 | selectedReg = registersWdgts.count()-1; |
|
84 | 92 | } |
|
85 | 93 | p_timer->start(); |
|
86 | 94 | this->setFocus(); |
|
87 | 95 | } |
|
88 | 96 | } |
|
89 | 97 | |
|
98 | void peripheralWidget::setReadWriteProxy(peripheralWidget::readWriteProxy *proxy) | |
|
99 | { | |
|
100 | this->p_proxy = proxy; | |
|
101 | } | |
|
102 | ||
|
90 | 103 | void peripheralWidget::mousePressEvent(QMouseEvent *event) |
|
91 | 104 | { |
|
92 | 105 | p_timer->stop(); |
|
93 | 106 | if(selectedReg!=-1) |
|
94 | 107 | { |
|
95 | 108 | registersWdgts.at(selectedReg)->leave(); |
|
96 | 109 | selectedReg = -1; |
|
97 | 110 | } |
|
98 | 111 | for(int i=0; i<registersWdgts.count();i++) |
|
99 | 112 | { |
|
100 | 113 | if(registersWdgts.at(i)->contains(event->pos())) |
|
101 | 114 | { |
|
102 | 115 | registersWdgts.at(i)->enter(registersWdgts.at(i)->cursorIndex(event->pos().x())); |
|
103 | 116 | selectedReg = i; |
|
104 | 117 | p_timer->start(); |
|
105 | 118 | emit clicked(this); |
|
106 | 119 | } |
|
107 | 120 | } |
|
108 | 121 | repaint(); |
|
109 | 122 | } |
|
110 | 123 | |
|
111 | 124 | void peripheralWidget::mouseMoveEvent(QMouseEvent *event) |
|
112 | 125 | { |
|
113 | 126 | bool match=false; |
|
114 | 127 | if(event->buttons()==Qt::LeftButton) |
|
115 | 128 | { |
|
116 | 129 | for(int i=0; i<registersWdgts.count();i++) |
|
117 | 130 | { |
|
118 | 131 | if(registersWdgts.at(i)->contains(event->pos())) |
|
119 | 132 | { |
|
120 | 133 | registersWdgts.at(i)->updateSelection(registersWdgts.at(i)->cursorIndex(event->pos().x())); |
|
121 | 134 | } |
|
122 | 135 | } |
|
123 | 136 | } |
|
124 | 137 | else |
|
125 | 138 | { |
|
126 | 139 | for(int i=0; i<registersWdgts.count();i++) |
|
127 | 140 | { |
|
128 | 141 | if(registersWdgts.at(i)->contains(event->pos())) |
|
129 | 142 | { |
|
130 | 143 | match = true; |
|
131 | 144 | int bitfieldIndex=registersWdgts.at(i)->cursorIndex(event->pos().x()); |
|
132 | ||
|
133 | 145 | QString toolTipText ="<b>< font color='Black'>"+registersWdgts.at(i)->bitFieldName(bitfieldIndex) +"</b><br />"; |
|
134 | 146 | toolTipText+= "Hexadecimal=<b>< font color='Blue'>"+registersWdgts.at(i)->bitFieldToHex(bitfieldIndex)+"</b>"; |
|
135 | 147 | toolTipText+= " Decimal=<b>< font color='BlueViolet'>"+registersWdgts.at(i)->bitFieldToDec(bitfieldIndex)+"</b><br />"; |
|
136 | 148 | toolTipText+= registersWdgts.at(i)->bitFieldDesc(bitfieldIndex); |
|
137 | 149 | QToolTip::showText(event->globalPos(),toolTipText,(QWidget*)this); |
|
138 | 150 | } |
|
139 | 151 | } |
|
140 | 152 | if(!match)QToolTip::hideText(); |
|
141 | 153 | } |
|
142 | 154 | } |
|
143 | 155 | |
|
144 | 156 | void peripheralWidget::mouseReleaseEvent(QMouseEvent *event) |
|
145 | 157 | { |
|
146 | 158 | Q_UNUSED(event) |
|
147 | 159 | } |
|
148 | 160 | |
|
149 | 161 | void peripheralWidget::keyPressEvent(QKeyEvent *event) |
|
150 | 162 | { |
|
151 | 163 | if(this->selectedReg!=-1){ |
|
152 | 164 | if(event->modifiers()==Qt::ControlModifier) |
|
153 | 165 | { |
|
154 | 166 | switch(event->key()) |
|
155 | 167 | { |
|
156 | 168 | case Qt::Key_Up: |
|
157 | 169 | registersWdgts.at(selectedReg)->set(registersWdgts.at(selectedReg)->cursorIndex()); |
|
158 | 170 | break; |
|
159 | 171 | case Qt::Key_Down: |
|
160 | 172 | registersWdgts.at(selectedReg)->clear(registersWdgts.at(selectedReg)->cursorIndex()); |
|
161 | 173 | break; |
|
162 | 174 | case Qt::Key_W: |
|
163 |
|
|
|
175 | p_proxy->writeReg(registersWdgts.at(selectedReg)->address(),registersWdgts.at(selectedReg)->value()); | |
|
164 | 176 | registersWdgts.at(selectedReg)->setUpdated(true); |
|
165 | 177 | registersWdgts.at(selectedReg)->repaint(); |
|
166 | 178 | break; |
|
167 | 179 | case Qt::Key_R: |
|
168 | 180 | qint32 value; |
|
169 |
value = |
|
|
181 | value = p_proxy->readReg(registersWdgts.at(selectedReg)->address()); | |
|
170 | 182 | registersWdgts.at(selectedReg)->setValue(value); |
|
171 | 183 | break; |
|
172 | 184 | default: |
|
173 | 185 | break; |
|
174 | 186 | } |
|
175 | 187 | } |
|
176 | 188 | else |
|
177 | 189 | { |
|
178 | 190 | switch(event->key()) |
|
179 | 191 | { |
|
180 | 192 | case Qt::Key_0: |
|
181 | 193 | registersWdgts.at(selectedReg)->clear(registersWdgts.at(selectedReg)->cursorIndex()); |
|
182 | 194 | registersWdgts.at(selectedReg)->moveCursorRight(1); |
|
183 | 195 | break; |
|
184 | 196 | case Qt::Key_1: |
|
185 | 197 | registersWdgts.at(selectedReg)->set(registersWdgts.at(selectedReg)->cursorIndex()); |
|
186 | 198 | registersWdgts.at(selectedReg)->moveCursorRight(1); |
|
187 | 199 | break; |
|
188 | 200 | case Qt::Key_Right: |
|
189 | 201 | registersWdgts.at(selectedReg)->moveCursorRight(1); |
|
190 | 202 | this->repaint(); |
|
191 | 203 | break; |
|
192 | 204 | case Qt::Key_Left: |
|
193 | 205 | registersWdgts.at(selectedReg)->moveCursorLeft(1); |
|
194 | 206 | this->repaint(); |
|
195 | 207 | break; |
|
196 | 208 | case Qt::Key_Up: |
|
197 | 209 | up(); |
|
198 | 210 | break; |
|
199 | 211 | case Qt::Key_Down: |
|
200 | 212 | down(); |
|
201 | 213 | break; |
|
202 | 214 | case Qt::Key_W: |
|
203 |
|
|
|
215 | p_proxy->writeReg(registersWdgts.at(selectedReg)->address(),registersWdgts.at(selectedReg)->value()); | |
|
204 | 216 | registersWdgts.at(selectedReg)->setUpdated(true); |
|
205 | 217 | registersWdgts.at(selectedReg)->repaint(); |
|
206 | 218 | break; |
|
207 | 219 | case Qt::Key_R: |
|
208 | 220 | qint32 value; |
|
209 |
value = |
|
|
221 | value = p_proxy->readReg(registersWdgts.at(selectedReg)->address()); | |
|
210 | 222 | registersWdgts.at(selectedReg)->setValue(value); |
|
211 | 223 | break; |
|
212 | 224 | default: |
|
213 | 225 | break; |
|
214 | 226 | } |
|
215 | 227 | } |
|
216 | 228 | |
|
217 | 229 | } |
|
218 | 230 | } |
|
219 | 231 | |
|
220 | 232 | void peripheralWidget::paintEvent(QPaintEvent *event) |
|
221 | 233 | { |
|
222 | 234 | Q_UNUSED(event) |
|
223 | 235 | |
|
224 | 236 | QPainter painter(this); |
|
225 | 237 | QPoint offset=QPoint(0,0); |
|
226 | 238 | int nameWidth = fontMetrics().width(p_header); |
|
227 | 239 | if(registersWdgts.count()==0) |
|
228 | 240 | { |
|
229 | 241 | setMinimumSize(2*nameWidth+10,fontMetrics().height()+10); |
|
230 | 242 | } |
|
231 | 243 | painter.drawText((this->minimumWidth()/2)-nameWidth,4,fontMetrics().width(p_header),fontMetrics().height()+4,Qt::AlignCenter,p_header); |
|
232 | 244 | offset+=QPoint(0,fontMetrics().height()+8); |
|
233 | 245 | for(int i=0;i<registersWdgts.count();i++) |
|
234 | 246 | { |
|
235 | 247 | offset = registersWdgts.at(i)->paint(&painter,offset); |
|
236 | 248 | } |
|
237 | 249 | if(registersWdgts.count()>0) |
|
238 | 250 | { |
|
239 |
|
|
|
251 | int w=registersWdgts.first()->boundingRect().width(); | |
|
252 | int h=offset.y(); | |
|
253 | setMinimumSize(w,h); | |
|
240 | 254 | } |
|
241 | 255 | updateGeometry(); |
|
242 | 256 | |
|
243 | 257 | } |
|
244 | 258 | |
|
245 | 259 | void peripheralWidget::up() |
|
246 | 260 | { |
|
247 | 261 | if(selectedReg!=-1) |
|
248 | 262 | { |
|
249 | 263 | if(selectedReg >0) |
|
250 | 264 | { |
|
251 | 265 | registersWdgts.at(selectedReg-1)->enter(registersWdgts.at(selectedReg)->cursorIndex()); |
|
252 | 266 | registersWdgts.at(selectedReg)->leave(); |
|
253 | 267 | selectedReg-=1; |
|
254 | 268 | repaint(); |
|
255 | 269 | } |
|
256 | 270 | else |
|
257 | 271 | { |
|
258 | 272 | emit upSig(this,registersWdgts.at(selectedReg)->cursorIndex()); |
|
259 | 273 | } |
|
260 | 274 | } |
|
261 | 275 | } |
|
262 | 276 | |
|
263 | 277 | void peripheralWidget::down() |
|
264 | 278 | { |
|
265 | 279 | if(selectedReg!=-1) |
|
266 | 280 | { |
|
267 | 281 | if(selectedReg <(registersWdgts.count()-1)) |
|
268 | 282 | { |
|
269 | 283 | registersWdgts.at(selectedReg+1)->enter(registersWdgts.at(selectedReg)->cursorIndex()); |
|
270 | 284 | registersWdgts.at(selectedReg)->leave(); |
|
271 | 285 | selectedReg+=1; |
|
272 | 286 | repaint(); |
|
273 | 287 | } |
|
274 | 288 | else |
|
275 | 289 | { |
|
276 | 290 | emit downSig(this,registersWdgts.at(selectedReg)->cursorIndex()); |
|
277 | 291 | } |
|
278 | 292 | } |
|
279 | 293 | } |
@@ -1,83 +1,95 | |||
|
1 | 1 | /*------------------------------------------------------------------------------ |
|
2 | 2 | -- This file is a part of the SocExplorer Software |
|
3 | 3 | -- Copyright (C) 2014, Plasma Physics Laboratory - CNRS |
|
4 | 4 | -- |
|
5 | 5 | -- This program is free software; you can redistribute it and/or modify |
|
6 | 6 | -- it under the terms of the GNU General Public License as published by |
|
7 | 7 | -- the Free Software Foundation; either version 3 of the License, or |
|
8 | 8 | -- (at your option) any later version. |
|
9 | 9 | -- |
|
10 | 10 | -- This program is distributed in the hope that it will be useful, |
|
11 | 11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 | 12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 | 13 | -- GNU General Public License for more details. |
|
14 | 14 | -- |
|
15 | 15 | -- You should have received a copy of the GNU General Public License |
|
16 | 16 | -- along with this program; if not, write to the Free Software |
|
17 | 17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
18 | 18 | -------------------------------------------------------------------------------*/ |
|
19 | 19 | /*-- Author : Alexis Jeandet |
|
20 | 20 | -- Mail : alexis.jeandet@member.fsf.org |
|
21 | 21 | ----------------------------------------------------------------------------*/ |
|
22 | 22 | #ifndef PERIPHERALWIDGET_H |
|
23 | 23 | #define PERIPHERALWIDGET_H |
|
24 | 24 | |
|
25 | 25 | #include <QWidget> |
|
26 | 26 | #include <QGroupBox> |
|
27 | 27 | #include <QVBoxLayout> |
|
28 | 28 | #include <QList> |
|
29 | 29 | #include <QTimer> |
|
30 | 30 | #include "registerwidget.h" |
|
31 | 31 | #if defined(SOCEXPLORER_SDK_BUILD) |
|
32 | 32 | # define SOCEXPLORER_SDK_EXPORT Q_DECL_EXPORT |
|
33 | 33 | #else |
|
34 | 34 | # define SOCEXPLORER_SDK_EXPORT Q_DECL_IMPORT |
|
35 | 35 | #endif |
|
36 | 36 | |
|
37 | 37 | /* |
|
38 | 38 | * TODO ADD an outdated marker |
|
39 | 39 | * Show outdated registers with a different color for example |
|
40 | 40 | */ |
|
41 | ||
|
41 | 42 | class SOCEXPLORER_SDK_EXPORT peripheralWidget : public QWidget |
|
42 | 43 | { |
|
43 | 44 | Q_OBJECT |
|
44 | 45 | public: |
|
45 | explicit peripheralWidget(const QString& name,qint32 baseAddress, QWidget *parent = 0); | |
|
46 | class readWriteProxy | |
|
47 | { | |
|
48 | public: | |
|
49 | readWriteProxy() {} | |
|
50 | virtual void writeReg(qint32 address,qint32 value)=0; | |
|
51 | virtual qint32 readReg(qint32 address)=0; | |
|
52 | }; | |
|
53 | ||
|
54 | explicit peripheralWidget(const QString& name,qint32 baseAddress,readWriteProxy* proxy=0, QWidget *parent = 0); | |
|
46 | 55 | registerWidget* registerAt(int index) |
|
47 | 56 | { |
|
48 | 57 | if(index>=0 && index<registersWdgts.count()) |
|
49 | 58 | return registersWdgts.at(index); |
|
50 | 59 | return NULL; |
|
51 | 60 | } |
|
52 | 61 | int count(); |
|
62 | const QString& name(); | |
|
53 | 63 | signals: |
|
54 | 64 | void writeRegSig(qint32 address,qint32 value); |
|
55 | 65 | qint32 readRegSig(qint32 address); |
|
56 | 66 | void clicked(peripheralWidget* sender); |
|
57 | 67 | void upSig(peripheralWidget* sender,int cursorIndex); |
|
58 | 68 | void downSig(peripheralWidget* sender,int cursorIndex); |
|
59 | 69 | public slots: |
|
60 | 70 | void blinkCursor(); |
|
61 | 71 | void addRegister(const QString& name,qint32 address); |
|
62 | 72 | void leave(); |
|
63 | 73 | void enter(int cursorIndex,bool fromTop=true); |
|
74 | void setReadWriteProxy(readWriteProxy* proxy); | |
|
64 | 75 | protected: |
|
65 | 76 | void mousePressEvent(QMouseEvent *event); |
|
66 | 77 | void mouseMoveEvent(QMouseEvent *event); |
|
67 | 78 | void mouseReleaseEvent(QMouseEvent *event); |
|
68 | 79 | void keyPressEvent(QKeyEvent * event); |
|
69 | 80 | void paintEvent(QPaintEvent* event); |
|
70 | 81 | |
|
71 | 82 | private: |
|
72 | 83 | void up(); |
|
73 | 84 | void down(); |
|
74 | 85 | QString p_name; |
|
75 | 86 | QString p_header; |
|
76 | 87 | qint32 p_baseAddress; |
|
77 | 88 | QList<registerWidget*> registersWdgts; |
|
78 | 89 | int selectedReg; |
|
79 | 90 | QTimer* p_timer; |
|
91 | readWriteProxy* p_proxy; | |
|
80 | 92 | |
|
81 | 93 | }; |
|
82 | 94 | |
|
83 | 95 | #endif // PERIPHERALWIDGET_H |
General Comments 0
You need to be logged in to leave comments.
Login now