@@ -1,102 +1,110 | |||||
1 | #include "collapsableperipheralwidget.h" |
|
1 | #include "collapsableperipheralwidget.h" | |
2 | #include "ui_collapsableperipheralwidget.h" |
|
2 | #include "ui_collapsableperipheralwidget.h" | |
3 | #include <QCursor> |
|
3 | #include <QCursor> | |
4 |
|
4 | |||
5 |
|
5 | |||
6 | CollapsablePeripheralWidget::CollapsablePeripheralWidget(peripheralWidget *periph, QWidget *parent) : |
|
6 | CollapsablePeripheralWidget::CollapsablePeripheralWidget(peripheralWidget *periph, QWidget *parent) : | |
7 | QWidget(parent), |
|
7 | QWidget(parent), | |
8 | ui(new Ui::CollapsablePeripheralWidget) |
|
8 | ui(new Ui::CollapsablePeripheralWidget) | |
9 | { |
|
9 | { | |
10 | m_periph=0; |
|
10 | m_periph=0; | |
11 | m_collapsed = true; |
|
11 | m_collapsed = true; | |
12 | ui->setupUi(this); |
|
12 | ui->setupUi(this); | |
13 | tthidetmr.setSingleShot(true); |
|
13 | tthidetmr.setSingleShot(true); | |
14 | tthidetmr.setInterval(200); |
|
14 | tthidetmr.setInterval(200); | |
15 | connect(this->ui->collapseQpb,SIGNAL(clicked()),this,SLOT(collapse())); |
|
15 | connect(this->ui->collapseQpb,SIGNAL(clicked()),this,SLOT(collapse())); | |
16 | connect(this->ui->periphName,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())); |
|
17 | connect(this->ui->periphName,SIGNAL(enter()),this,SLOT(showTooltip())); | |
18 | connect(this->ui->periphName,SIGNAL(leave()),&this->tthidetmr,SLOT(start())); |
|
18 | connect(this->ui->periphName,SIGNAL(leave()),&this->tthidetmr,SLOT(start())); | |
19 | connect(&this->tthidetmr,SIGNAL(timeout()),this,SLOT(hideTooltip())); |
|
19 | connect(&this->tthidetmr,SIGNAL(timeout()),this,SLOT(hideTooltip())); | |
20 | setPeripheralWidget(periph); |
|
20 | setPeripheralWidget(periph); | |
21 | } |
|
21 | } | |
22 |
|
22 | |||
23 | CollapsablePeripheralWidget::~CollapsablePeripheralWidget() |
|
23 | CollapsablePeripheralWidget::~CollapsablePeripheralWidget() | |
24 | { |
|
24 | { | |
25 | delete ui; |
|
25 | delete ui; | |
26 | } |
|
26 | } | |
27 |
|
27 | |||
28 | void CollapsablePeripheralWidget::setPeripheralWidget(peripheralWidget *periph) |
|
28 | void CollapsablePeripheralWidget::setPeripheralWidget(peripheralWidget *periph) | |
29 | { |
|
29 | { | |
30 | if(periph) |
|
30 | if(periph) | |
31 | { |
|
31 | { | |
32 | this->m_periph = periph; |
|
32 | this->m_periph = periph; | |
33 | this->ui->gridLayout->addWidget(periph,1,0,1,-1); |
|
33 | this->ui->gridLayout->addWidget(periph,1,0,1,-1); | |
34 | this->ui->periphName->setText(periph->name()); |
|
34 | this->ui->periphName->setText(periph->name()); | |
35 | this->m_periph->setVisible(false); |
|
35 | this->m_periph->setVisible(false); | |
36 | } |
|
36 | } | |
37 | } |
|
37 | } | |
38 |
|
38 | |||
39 | peripheralWidget *CollapsablePeripheralWidget::getPeripheralWidget() |
|
39 | peripheralWidget *CollapsablePeripheralWidget::getPeripheralWidget() | |
40 | { |
|
40 | { | |
41 | return m_periph; |
|
41 | return m_periph; | |
42 | } |
|
42 | } | |
43 |
|
43 | |||
44 | void CollapsablePeripheralWidget::changeEvent(QEvent *e) |
|
44 | void CollapsablePeripheralWidget::changeEvent(QEvent *e) | |
45 | { |
|
45 | { | |
46 | QWidget::changeEvent(e); |
|
46 | QWidget::changeEvent(e); | |
47 | switch (e->type()) { |
|
47 | switch (e->type()) { | |
48 | case QEvent::LanguageChange: |
|
48 | case QEvent::LanguageChange: | |
49 | ui->retranslateUi(this); |
|
49 | ui->retranslateUi(this); | |
50 | break; |
|
50 | break; | |
51 | default: |
|
51 | default: | |
52 | break; |
|
52 | break; | |
53 | } |
|
53 | } | |
54 | } |
|
54 | } | |
55 |
|
55 | |||
|
56 | void CollapsablePeripheralWidget::paintEvent(QPaintEvent *) | |||
|
57 | { | |||
|
58 | QStyleOption opt; | |||
|
59 | opt.init(this); | |||
|
60 | QPainter p(this); | |||
|
61 | style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this); | |||
|
62 | } | |||
|
63 | ||||
56 | void CollapsablePeripheralWidget::collapse() |
|
64 | void CollapsablePeripheralWidget::collapse() | |
57 | { |
|
65 | { | |
58 | this->m_periph->setVisible(m_collapsed); |
|
66 | this->m_periph->setVisible(m_collapsed); | |
59 | if(this->m_collapsed) |
|
67 | if(this->m_collapsed) | |
60 | { |
|
68 | { | |
61 | this->ui->collapseQpb->setIcon(QIcon(":/img/Gnome-list-remove.svg")); |
|
69 | this->ui->collapseQpb->setIcon(QIcon(":/img/Gnome-list-remove.svg")); | |
62 | } |
|
70 | } | |
63 | else |
|
71 | else | |
64 | { |
|
72 | { | |
65 | this->ui->collapseQpb->setIcon(QIcon(":/img/Gnome-list-add.svg")); |
|
73 | this->ui->collapseQpb->setIcon(QIcon(":/img/Gnome-list-add.svg")); | |
66 | } |
|
74 | } | |
67 | m_collapsed = !m_collapsed; |
|
75 | m_collapsed = !m_collapsed; | |
68 | } |
|
76 | } | |
69 |
|
77 | |||
70 | void CollapsablePeripheralWidget::setName(const QString &name) |
|
78 | void CollapsablePeripheralWidget::setName(const QString &name) | |
71 | { |
|
79 | { | |
72 | if(m_periph) |
|
80 | if(m_periph) | |
73 | { |
|
81 | { | |
74 | this->ui->periphName->setText(name); |
|
82 | this->ui->periphName->setText(name); | |
75 | } |
|
83 | } | |
76 | } |
|
84 | } | |
77 |
|
85 | |||
78 | void CollapsablePeripheralWidget::showTooltip() |
|
86 | void CollapsablePeripheralWidget::showTooltip() | |
79 | { |
|
87 | { | |
80 | if(!m_periph->isVisible() && m_collapsed) |
|
88 | if(!m_periph->isVisible() && m_collapsed) | |
81 | { |
|
89 | { | |
82 | m_periph->show(); |
|
90 | m_periph->show(); | |
83 | } |
|
91 | } | |
84 | } |
|
92 | } | |
85 |
|
93 | |||
86 | void CollapsablePeripheralWidget::hideTooltip() |
|
94 | void CollapsablePeripheralWidget::hideTooltip() | |
87 | { |
|
95 | { | |
88 | if(m_periph->isVisible() && m_collapsed) |
|
96 | if(m_periph->isVisible() && m_collapsed) | |
89 | { |
|
97 | { | |
90 | QRect temprect = this->geometry(); |
|
98 | QRect temprect = this->geometry(); | |
91 | temprect.moveTo(this->mapToGlobal(mapFromParent(QPoint(this->x(),this->y())))); |
|
99 | temprect.moveTo(this->mapToGlobal(mapFromParent(QPoint(this->x(),this->y())))); | |
92 | if(temprect.contains(QCursor::pos())) |
|
100 | if(temprect.contains(QCursor::pos())) | |
93 | { |
|
101 | { | |
94 | this->tthidetmr.start(); |
|
102 | this->tthidetmr.start(); | |
95 | } |
|
103 | } | |
96 | else |
|
104 | else | |
97 | { |
|
105 | { | |
98 | m_periph->hide(); |
|
106 | m_periph->hide(); | |
99 | } |
|
107 | } | |
100 | } |
|
108 | } | |
101 | } |
|
109 | } | |
102 |
|
110 |
@@ -1,56 +1,56 | |||||
1 | #ifndef COLLAPSABLEPERIPHERALWIDGET_H |
|
1 | #ifndef COLLAPSABLEPERIPHERALWIDGET_H | |
2 | #define COLLAPSABLEPERIPHERALWIDGET_H |
|
2 | #define COLLAPSABLEPERIPHERALWIDGET_H | |
3 |
|
3 | |||
4 | #include <QWidget> |
|
4 | #include <QWidget> | |
5 | #include <peripheralwidget.h> |
|
5 | #include <peripheralwidget.h> | |
6 | #include <QTimer> |
|
6 | #include <QTimer> | |
7 |
|
7 | |||
8 | namespace Ui { |
|
8 | namespace Ui { | |
9 | class CollapsablePeripheralWidget; |
|
9 | class CollapsablePeripheralWidget; | |
10 | } |
|
10 | } | |
11 |
|
11 | |||
12 | class QRegToolTipLabel : public QLabel |
|
12 | class QRegToolTipLabel : public QLabel | |
13 | { |
|
13 | { | |
14 | Q_OBJECT |
|
14 | Q_OBJECT | |
15 | public: |
|
15 | public: | |
16 | QRegToolTipLabel(QWidget * parent = 0, Qt::WindowFlags f = 0):QLabel(parent,f){} |
|
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){} |
|
17 | QRegToolTipLabel(const QString & text, QWidget * parent = 0, Qt::WindowFlags f = 0):QLabel(text,parent,f){} | |
18 | signals: |
|
18 | signals: | |
19 | void enter(); |
|
19 | void enter(); | |
20 | void leave(); |
|
20 | void leave(); | |
21 | void clicked(); |
|
21 | void clicked(); | |
22 | protected: |
|
22 | protected: | |
23 | void enterEvent(QEvent* event){emit enter();QLabel::enterEvent(event);} |
|
23 | void enterEvent(QEvent* event){emit enter();QLabel::enterEvent(event);} | |
24 | void leaveEvent(QEvent* event){emit leave();QLabel::leaveEvent(event);} |
|
24 | void leaveEvent(QEvent* event){emit leave();QLabel::leaveEvent(event);} | |
25 | void mousePressEvent(QMouseEvent * event){emit clicked();QLabel::mousePressEvent(event);} |
|
25 | void mousePressEvent(QMouseEvent * event){emit clicked();QLabel::mousePressEvent(event);} | |
26 | }; |
|
26 | }; | |
27 |
|
27 | |||
28 | class CollapsablePeripheralWidget : public QWidget |
|
28 | class CollapsablePeripheralWidget : public QWidget | |
29 | { |
|
29 | { | |
30 | Q_OBJECT |
|
30 | Q_OBJECT | |
31 |
|
31 | |||
32 | public: |
|
32 | public: | |
33 | explicit CollapsablePeripheralWidget(peripheralWidget* periph,QWidget *parent = 0); |
|
33 | explicit CollapsablePeripheralWidget(peripheralWidget* periph,QWidget *parent = 0); | |
34 | ~CollapsablePeripheralWidget(); |
|
34 | ~CollapsablePeripheralWidget(); | |
35 | void setPeripheralWidget(peripheralWidget* periph); |
|
35 | void setPeripheralWidget(peripheralWidget* periph); | |
36 | peripheralWidget* getPeripheralWidget(); |
|
36 | peripheralWidget* getPeripheralWidget(); | |
37 | protected: |
|
37 | protected: | |
38 | void changeEvent(QEvent *e); |
|
38 | void changeEvent(QEvent *e); | |
39 |
|
39 | void paintEvent(QPaintEvent *); | ||
40 | public slots: |
|
40 | public slots: | |
41 | void collapse(); |
|
41 | void collapse(); | |
42 | void setName(const QString& name); |
|
42 | void setName(const QString& name); | |
43 | void showTooltip(); |
|
43 | void showTooltip(); | |
44 | void hideTooltip(); |
|
44 | void hideTooltip(); | |
45 | signals: |
|
45 | signals: | |
46 | void clicked(peripheralWidget* sender); |
|
46 | void clicked(peripheralWidget* sender); | |
47 | void upSig(peripheralWidget* sender,int cursorIndex); |
|
47 | void upSig(peripheralWidget* sender,int cursorIndex); | |
48 | void downSig(peripheralWidget* sender,int cursorIndex); |
|
48 | void downSig(peripheralWidget* sender,int cursorIndex); | |
49 | private: |
|
49 | private: | |
50 | Ui::CollapsablePeripheralWidget *ui; |
|
50 | Ui::CollapsablePeripheralWidget *ui; | |
51 | peripheralWidget* m_periph; |
|
51 | peripheralWidget* m_periph; | |
52 | bool m_collapsed; |
|
52 | bool m_collapsed; | |
53 | QTimer tthidetmr; |
|
53 | QTimer tthidetmr; | |
54 | }; |
|
54 | }; | |
55 |
|
55 | |||
56 | #endif // COLLAPSABLEPERIPHERALWIDGET_H |
|
56 | #endif // COLLAPSABLEPERIPHERALWIDGET_H |
@@ -1,89 +1,89 | |||||
1 | <?xml version="1.0" encoding="UTF-8"?> |
|
1 | <?xml version="1.0" encoding="UTF-8"?> | |
2 | <ui version="4.0"> |
|
2 | <ui version="4.0"> | |
3 | <class>CollapsablePeripheralWidget</class> |
|
3 | <class>CollapsablePeripheralWidget</class> | |
4 | <widget class="QWidget" name="CollapsablePeripheralWidget"> |
|
4 | <widget class="QWidget" name="CollapsablePeripheralWidget"> | |
5 | <property name="geometry"> |
|
5 | <property name="geometry"> | |
6 | <rect> |
|
6 | <rect> | |
7 | <x>0</x> |
|
7 | <x>0</x> | |
8 | <y>0</y> |
|
8 | <y>0</y> | |
9 |
<width>8 |
|
9 | <width>833</width> | |
10 |
<height> |
|
10 | <height>192</height> | |
11 | </rect> |
|
11 | </rect> | |
12 | </property> |
|
12 | </property> | |
13 | <property name="sizePolicy"> |
|
13 | <property name="sizePolicy"> | |
14 | <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> |
|
14 | <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> | |
15 | <horstretch>0</horstretch> |
|
15 | <horstretch>0</horstretch> | |
16 | <verstretch>0</verstretch> |
|
16 | <verstretch>0</verstretch> | |
17 | </sizepolicy> |
|
17 | </sizepolicy> | |
18 | </property> |
|
18 | </property> | |
19 | <property name="windowTitle"> |
|
19 | <property name="windowTitle"> | |
20 | <string>Form</string> |
|
20 | <string>Form</string> | |
21 | </property> |
|
21 | </property> | |
22 | <property name="styleSheet"> |
|
22 | <property name="styleSheet"> | |
23 | <string notr="true">QWidget#CollapsablePeripheralWidget { |
|
23 | <string notr="true"/> | |
24 | border: 1px solid gray; |
|
|||
25 | border-radius: 9px; |
|
|||
26 | }</string> |
|
|||
27 | </property> |
|
24 | </property> | |
28 | <layout class="QGridLayout" name="gridLayout"> |
|
25 | <layout class="QGridLayout" name="gridLayout"> | |
29 | <item row="0" column="2"> |
|
26 | <item row="0" column="2"> | |
30 | <widget class="QPushButton" name="collapseQpb"> |
|
27 | <widget class="QPushButton" name="collapseQpb"> | |
31 | <property name="sizePolicy"> |
|
28 | <property name="sizePolicy"> | |
32 | <sizepolicy hsizetype="Maximum" vsizetype="Fixed"> |
|
29 | <sizepolicy hsizetype="Maximum" vsizetype="Fixed"> | |
33 | <horstretch>0</horstretch> |
|
30 | <horstretch>0</horstretch> | |
34 | <verstretch>0</verstretch> |
|
31 | <verstretch>0</verstretch> | |
35 | </sizepolicy> |
|
32 | </sizepolicy> | |
36 | </property> |
|
33 | </property> | |
|
34 | <property name="focusPolicy"> | |||
|
35 | <enum>Qt::NoFocus</enum> | |||
|
36 | </property> | |||
37 | <property name="text"> |
|
37 | <property name="text"> | |
38 | <string/> |
|
38 | <string/> | |
39 | </property> |
|
39 | </property> | |
40 | <property name="icon"> |
|
40 | <property name="icon"> | |
41 | <iconset resource="../ressources/peripheralwidget.qrc"> |
|
41 | <iconset resource="../ressources/peripheralwidget.qrc"> | |
42 | <normaloff>:/img/Gnome-list-add.svg</normaloff> |
|
42 | <normaloff>:/img/Gnome-list-add.svg</normaloff> | |
43 | <normalon>:/img/Gnome-list-remove.svg</normalon>:/img/Gnome-list-add.svg</iconset> |
|
43 | <normalon>:/img/Gnome-list-remove.svg</normalon>:/img/Gnome-list-add.svg</iconset> | |
44 | </property> |
|
44 | </property> | |
45 | <property name="flat"> |
|
45 | <property name="flat"> | |
46 | <bool>true</bool> |
|
46 | <bool>true</bool> | |
47 | </property> |
|
47 | </property> | |
48 | </widget> |
|
48 | </widget> | |
49 | </item> |
|
49 | </item> | |
50 | <item row="0" column="0"> |
|
50 | <item row="0" column="0"> | |
51 | <widget class="QRegToolTipLabel" name="periphName"> |
|
51 | <widget class="QRegToolTipLabel" name="periphName"> | |
52 | <property name="sizePolicy"> |
|
52 | <property name="sizePolicy"> | |
53 | <sizepolicy hsizetype="Minimum" vsizetype="Preferred"> |
|
53 | <sizepolicy hsizetype="Minimum" vsizetype="Preferred"> | |
54 | <horstretch>0</horstretch> |
|
54 | <horstretch>0</horstretch> | |
55 | <verstretch>0</verstretch> |
|
55 | <verstretch>0</verstretch> | |
56 | </sizepolicy> |
|
56 | </sizepolicy> | |
57 | </property> |
|
57 | </property> | |
58 | <property name="text"> |
|
58 | <property name="text"> | |
59 | <string>PeriphName</string> |
|
59 | <string>PeriphName</string> | |
60 | </property> |
|
60 | </property> | |
61 | </widget> |
|
61 | </widget> | |
62 | </item> |
|
62 | </item> | |
63 | <item row="0" column="1"> |
|
63 | <item row="0" column="1"> | |
64 | <spacer name="horizontalSpacer"> |
|
64 | <spacer name="horizontalSpacer"> | |
65 | <property name="orientation"> |
|
65 | <property name="orientation"> | |
66 | <enum>Qt::Horizontal</enum> |
|
66 | <enum>Qt::Horizontal</enum> | |
67 | </property> |
|
67 | </property> | |
68 | <property name="sizeHint" stdset="0"> |
|
68 | <property name="sizeHint" stdset="0"> | |
69 | <size> |
|
69 | <size> | |
70 | <width>40</width> |
|
70 | <width>40</width> | |
71 | <height>20</height> |
|
71 | <height>20</height> | |
72 | </size> |
|
72 | </size> | |
73 | </property> |
|
73 | </property> | |
74 | </spacer> |
|
74 | </spacer> | |
75 | </item> |
|
75 | </item> | |
76 | </layout> |
|
76 | </layout> | |
77 | </widget> |
|
77 | </widget> | |
78 | <customwidgets> |
|
78 | <customwidgets> | |
79 | <customwidget> |
|
79 | <customwidget> | |
80 | <class>QRegToolTipLabel</class> |
|
80 | <class>QRegToolTipLabel</class> | |
81 | <extends>QLabel</extends> |
|
81 | <extends>QLabel</extends> | |
82 | <header location="global">collapsableperipheralwidget.h</header> |
|
82 | <header location="global">collapsableperipheralwidget.h</header> | |
83 | </customwidget> |
|
83 | </customwidget> | |
84 | </customwidgets> |
|
84 | </customwidgets> | |
85 | <resources> |
|
85 | <resources> | |
86 | <include location="../ressources/peripheralwidget.qrc"/> |
|
86 | <include location="../ressources/peripheralwidget.qrc"/> | |
87 | </resources> |
|
87 | </resources> | |
88 | <connections/> |
|
88 | <connections/> | |
89 | </ui> |
|
89 | </ui> |
@@ -1,107 +1,120 | |||||
1 | #include "socregsviewernew.h" |
|
1 | #include "socregsviewernew.h" | |
2 | #include "ui_socregsviewernew.h" |
|
2 | #include "ui_socregsviewernew.h" | |
3 |
|
3 | |||
4 | SocRegsViewerNew::SocRegsViewerNew(const QString &name,QWidget *parent) : |
|
4 | SocRegsViewerNew::SocRegsViewerNew(const QString &name,QWidget *parent) : | |
5 | QWidget(parent), |
|
5 | QWidget(parent), | |
6 | ui(new Ui::SocRegsViewerNew) |
|
6 | ui(new Ui::SocRegsViewerNew) | |
7 | { |
|
7 | { | |
8 | ui->setupUi(this); |
|
8 | ui->setupUi(this); | |
9 | this->ui->socName->setText(name); |
|
9 | this->ui->socName->setText(name); | |
10 | } |
|
10 | } | |
11 |
|
11 | |||
|
12 | SocRegsViewerNew::SocRegsViewerNew(QWidget *parent): | |||
|
13 | QWidget(parent), | |||
|
14 | ui(new Ui::SocRegsViewerNew) | |||
|
15 | { | |||
|
16 | ui->setupUi(this); | |||
|
17 | this->ui->socName->setText("No name"); | |||
|
18 | } | |||
|
19 | ||||
12 | SocRegsViewerNew::~SocRegsViewerNew() |
|
20 | SocRegsViewerNew::~SocRegsViewerNew() | |
13 | { |
|
21 | { | |
14 | delete ui; |
|
22 | delete ui; | |
15 | } |
|
23 | } | |
16 |
|
24 | |||
17 | peripheralWidget *SocRegsViewerNew::peripheral(int index) |
|
25 | peripheralWidget *SocRegsViewerNew::peripheral(int index) | |
18 | { |
|
26 | { | |
19 | if(index>=0 && index<p_peripherals.count()) |
|
27 | if(index>=0 && index<p_peripherals.count()) | |
20 | { |
|
28 | { | |
21 | return p_peripherals.at(index); |
|
29 | return p_peripherals.at(index); | |
22 | } |
|
30 | } | |
23 | return NULL; |
|
31 | return NULL; | |
24 | } |
|
32 | } | |
25 |
|
33 | |||
26 | void SocRegsViewerNew::addPeripheral(peripheralWidget *peripheral) |
|
34 | void SocRegsViewerNew::addPeripheral(peripheralWidget *peripheral) | |
27 | { |
|
35 | { | |
28 | if(peripheral!=NULL) |
|
36 | if(peripheral!=NULL) | |
29 | { |
|
37 | { | |
30 | CollapsablePeripheralWidget* cperiph = new CollapsablePeripheralWidget(peripheral); |
|
38 | CollapsablePeripheralWidget* cperiph = new CollapsablePeripheralWidget(peripheral); | |
31 | cperiph->setPeripheralWidget(peripheral); |
|
39 | cperiph->setPeripheralWidget(peripheral); | |
32 | p_peripherals.append(peripheral); |
|
40 | p_peripherals.append(peripheral); | |
33 | p_CPeripherals.append(cperiph); |
|
41 | p_CPeripherals.append(cperiph); | |
34 | this->ui->scrollAreaWidgetContents->layout()->addWidget(cperiph); |
|
42 | this->ui->scrollAreaWidgetContents->layout()->addWidget(cperiph); | |
35 | connect(cperiph,SIGNAL(clicked(peripheralWidget*)),this,SLOT(periphClicked(peripheralWidget*))); |
|
43 | connect(cperiph,SIGNAL(clicked(peripheralWidget*)),this,SLOT(periphClicked(peripheralWidget*))); | |
36 | connect(cperiph,SIGNAL(upSig(peripheralWidget*,int)),this,SLOT(periphUp(peripheralWidget*,int))); |
|
44 | connect(cperiph,SIGNAL(upSig(peripheralWidget*,int)),this,SLOT(periphUp(peripheralWidget*,int))); | |
37 | connect(cperiph,SIGNAL(downSig(peripheralWidget*,int)),this,SLOT(periphDown(peripheralWidget*,int))); |
|
45 | connect(cperiph,SIGNAL(downSig(peripheralWidget*,int)),this,SLOT(periphDown(peripheralWidget*,int))); | |
38 | } |
|
46 | } | |
39 | } |
|
47 | } | |
40 |
|
48 | |||
41 | void SocRegsViewerNew::periphClicked(peripheralWidget *sender) |
|
49 | void SocRegsViewerNew::periphClicked(peripheralWidget *sender) | |
42 | { |
|
50 | { | |
43 | peripheralWidget * item; |
|
51 | peripheralWidget * item; | |
44 | if(sender!=NULL) |
|
52 | if(sender!=NULL) | |
45 | { |
|
53 | { | |
46 | for(int i=0;i<p_peripherals.count();i++) |
|
54 | for(int i=0;i<p_peripherals.count();i++) | |
47 | { |
|
55 | { | |
48 | item = p_peripherals.at(i); |
|
56 | item = p_peripherals.at(i); | |
49 | if(item!=sender) |
|
57 | if(item!=sender) | |
50 | { |
|
58 | { | |
51 | item->leave(); |
|
59 | item->leave(); | |
52 | } |
|
60 | } | |
53 | } |
|
61 | } | |
54 | } |
|
62 | } | |
55 | } |
|
63 | } | |
56 |
|
64 | |||
57 | void SocRegsViewerNew::periphUp(peripheralWidget *sender, int cursorIndex) |
|
65 | void SocRegsViewerNew::periphUp(peripheralWidget *sender, int cursorIndex) | |
58 | { |
|
66 | { | |
59 | int index,senderIndex; |
|
67 | int index,senderIndex; | |
60 | if(sender!=NULL) |
|
68 | if(sender!=NULL) | |
61 | { |
|
69 | { | |
62 | index =senderIndex= p_peripherals.indexOf(sender); |
|
70 | index =senderIndex= p_peripherals.indexOf(sender); | |
63 | while(index!=-1 && index!=0) |
|
71 | while(index!=-1 && index!=0) | |
64 | { |
|
72 | { | |
65 | if(p_peripherals.at(index-1)->count()>0) |
|
73 | if(p_peripherals.at(index-1)->count()>0) | |
66 | { |
|
74 | { | |
67 | p_peripherals.at(senderIndex)->leave(); |
|
75 | p_peripherals.at(senderIndex)->leave(); | |
68 | p_peripherals.at(index-1)->enter(cursorIndex,false); |
|
76 | p_peripherals.at(index-1)->enter(cursorIndex,false); | |
69 | // ensureWidgetVisible(p_peripherals.at(index-1)); |
|
77 | // ensureWidgetVisible(p_peripherals.at(index-1)); | |
70 | break; |
|
78 | break; | |
71 | } |
|
79 | } | |
72 | index--; |
|
80 | index--; | |
73 | } |
|
81 | } | |
74 | } |
|
82 | } | |
75 | } |
|
83 | } | |
76 |
|
84 | |||
77 | void SocRegsViewerNew::periphDown(peripheralWidget *sender, int cursorIndex) |
|
85 | void SocRegsViewerNew::periphDown(peripheralWidget *sender, int cursorIndex) | |
78 | { |
|
86 | { | |
79 | int index,senderIndex; |
|
87 | int index,senderIndex; | |
80 | if(sender!=NULL) |
|
88 | if(sender!=NULL) | |
81 | { |
|
89 | { | |
82 | index=senderIndex= p_peripherals.indexOf(sender); |
|
90 | index=senderIndex= p_peripherals.indexOf(sender); | |
83 | while((index!=-1) && (index<(p_peripherals.count()-1))) |
|
91 | while((index!=-1) && (index<(p_peripherals.count()-1))) | |
84 | { |
|
92 | { | |
85 | if(p_peripherals.at(index+1)->count()>0) |
|
93 | if(p_peripherals.at(index+1)->count()>0) | |
86 | { |
|
94 | { | |
87 | p_peripherals.at(senderIndex)->leave(); |
|
95 | p_peripherals.at(senderIndex)->leave(); | |
88 | p_peripherals.at(index+1)->enter(cursorIndex); |
|
96 | p_peripherals.at(index+1)->enter(cursorIndex); | |
89 | // ensureWidgetVisible(p_peripherals.at(index+1)); |
|
97 | // ensureWidgetVisible(p_peripherals.at(index+1)); | |
90 | break; |
|
98 | break; | |
91 | } |
|
99 | } | |
92 | index++; |
|
100 | index++; | |
93 | } |
|
101 | } | |
94 | } |
|
102 | } | |
95 | } |
|
103 | } | |
96 |
|
104 | |||
|
105 | void SocRegsViewerNew::setSocName(const QString &name) | |||
|
106 | { | |||
|
107 | this->ui->socName->setText(name); | |||
|
108 | } | |||
|
109 | ||||
97 | void SocRegsViewerNew::changeEvent(QEvent *e) |
|
110 | void SocRegsViewerNew::changeEvent(QEvent *e) | |
98 | { |
|
111 | { | |
99 | QWidget::changeEvent(e); |
|
112 | QWidget::changeEvent(e); | |
100 | switch (e->type()) { |
|
113 | switch (e->type()) { | |
101 | case QEvent::LanguageChange: |
|
114 | case QEvent::LanguageChange: | |
102 | ui->retranslateUi(this); |
|
115 | ui->retranslateUi(this); | |
103 | break; |
|
116 | break; | |
104 | default: |
|
117 | default: | |
105 | break; |
|
118 | break; | |
106 | } |
|
119 | } | |
107 | } |
|
120 | } |
@@ -1,38 +1,40 | |||||
1 | #ifndef SOCREGSVIEWERNEW_H |
|
1 | #ifndef SOCREGSVIEWERNEW_H | |
2 | #define SOCREGSVIEWERNEW_H |
|
2 | #define SOCREGSVIEWERNEW_H | |
3 |
|
3 | |||
4 | #include <QWidget> |
|
4 | #include <QWidget> | |
5 | #include <peripheralwidget.h> |
|
5 | #include <peripheralwidget.h> | |
6 | #include <collapsableperipheralwidget.h> |
|
6 | #include <collapsableperipheralwidget.h> | |
7 |
|
7 | |||
8 | namespace Ui { |
|
8 | namespace Ui { | |
9 | class SocRegsViewerNew; |
|
9 | class SocRegsViewerNew; | |
10 | } |
|
10 | } | |
11 |
|
11 | |||
12 | class SocRegsViewerNew : public QWidget |
|
12 | class SocRegsViewerNew : public QWidget | |
13 | { |
|
13 | { | |
14 | Q_OBJECT |
|
14 | Q_OBJECT | |
15 |
|
15 | |||
16 | public: |
|
16 | public: | |
17 | explicit SocRegsViewerNew(const QString &name, QWidget *parent = 0); |
|
17 | explicit SocRegsViewerNew(const QString &name, QWidget *parent = 0); | |
|
18 | explicit SocRegsViewerNew(QWidget *parent = 0); | |||
18 | ~SocRegsViewerNew(); |
|
19 | ~SocRegsViewerNew(); | |
19 |
|
20 | |||
20 | peripheralWidget *peripheral(int index); |
|
21 | peripheralWidget *peripheral(int index); | |
21 |
|
22 | |||
22 | signals: |
|
23 | signals: | |
23 |
|
24 | |||
24 | public slots: |
|
25 | public slots: | |
25 | void addPeripheral(peripheralWidget* peripheral); |
|
26 | void addPeripheral(peripheralWidget* peripheral); | |
26 | void periphClicked(peripheralWidget* sender); |
|
27 | void periphClicked(peripheralWidget* sender); | |
27 | void periphUp(peripheralWidget* sender,int cursorIndex); |
|
28 | void periphUp(peripheralWidget* sender,int cursorIndex); | |
28 | void periphDown(peripheralWidget* sender,int cursorIndex); |
|
29 | void periphDown(peripheralWidget* sender,int cursorIndex); | |
|
30 | void setSocName(const QString& name); | |||
29 | protected: |
|
31 | protected: | |
30 | void changeEvent(QEvent *e); |
|
32 | void changeEvent(QEvent *e); | |
31 |
|
33 | |||
32 | private: |
|
34 | private: | |
33 | Ui::SocRegsViewerNew *ui; |
|
35 | Ui::SocRegsViewerNew *ui; | |
34 | QList<peripheralWidget*> p_peripherals; |
|
36 | QList<peripheralWidget*> p_peripherals; | |
35 | QList<CollapsablePeripheralWidget*> p_CPeripherals; |
|
37 | QList<CollapsablePeripheralWidget*> p_CPeripherals; | |
36 | }; |
|
38 | }; | |
37 |
|
39 | |||
38 | #endif // SOCREGSVIEWERNEW_H |
|
40 | #endif // SOCREGSVIEWERNEW_H |
@@ -1,60 +1,50 | |||||
1 | <?xml version="1.0" encoding="UTF-8"?> |
|
1 | <?xml version="1.0" encoding="UTF-8"?> | |
2 | <ui version="4.0"> |
|
2 | <ui version="4.0"> | |
3 | <class>SocRegsViewerNew</class> |
|
3 | <class>SocRegsViewerNew</class> | |
4 | <widget class="QWidget" name="SocRegsViewerNew"> |
|
4 | <widget class="QWidget" name="SocRegsViewerNew"> | |
5 | <property name="geometry"> |
|
5 | <property name="geometry"> | |
6 | <rect> |
|
6 | <rect> | |
7 | <x>0</x> |
|
7 | <x>0</x> | |
8 | <y>0</y> |
|
8 | <y>0</y> | |
9 | <width>713</width> |
|
9 | <width>713</width> | |
10 | <height>357</height> |
|
10 | <height>357</height> | |
11 | </rect> |
|
11 | </rect> | |
12 | </property> |
|
12 | </property> | |
13 | <property name="windowTitle"> |
|
13 | <property name="windowTitle"> | |
14 | <string>Form</string> |
|
14 | <string>Form</string> | |
15 | </property> |
|
15 | </property> | |
16 | <layout class="QGridLayout" name="gridLayout"> |
|
16 | <layout class="QGridLayout" name="gridLayout"> | |
17 |
<item row=" |
|
17 | <item row="1" column="0" colspan="2"> | |
18 | <widget class="QComboBox" name="rootPluginCmbBx"/> |
|
|||
19 | </item> |
|
|||
20 | <item row="2" column="0" colspan="2"> |
|
|||
21 | <widget class="QScrollArea" name="PeriphList"> |
|
18 | <widget class="QScrollArea" name="PeriphList"> | |
22 | <property name="widgetResizable"> |
|
19 | <property name="widgetResizable"> | |
23 | <bool>true</bool> |
|
20 | <bool>true</bool> | |
24 | </property> |
|
21 | </property> | |
25 | <widget class="QWidget" name="scrollAreaWidgetContents"> |
|
22 | <widget class="QWidget" name="scrollAreaWidgetContents"> | |
26 | <property name="geometry"> |
|
23 | <property name="geometry"> | |
27 | <rect> |
|
24 | <rect> | |
28 | <x>0</x> |
|
25 | <x>0</x> | |
29 | <y>0</y> |
|
26 | <y>0</y> | |
30 | <width>693</width> |
|
27 | <width>693</width> | |
31 |
<height>3 |
|
28 | <height>337</height> | |
32 | </rect> |
|
29 | </rect> | |
33 | </property> |
|
30 | </property> | |
34 | <layout class="QVBoxLayout" name="verticalLayout"> |
|
31 | <layout class="QVBoxLayout" name="verticalLayout"> | |
35 | <item> |
|
32 | <item> | |
36 | <widget class="QLabel" name="socName"> |
|
33 | <widget class="QLabel" name="socName"> | |
37 | <property name="text"> |
|
34 | <property name="text"> | |
38 | <string>SocName</string> |
|
35 | <string>SocName</string> | |
39 | </property> |
|
36 | </property> | |
40 | <property name="alignment"> |
|
37 | <property name="alignment"> | |
41 | <set>Qt::AlignCenter</set> |
|
38 | <set>Qt::AlignCenter</set> | |
42 | </property> |
|
39 | </property> | |
43 | </widget> |
|
40 | </widget> | |
44 | </item> |
|
41 | </item> | |
45 | </layout> |
|
42 | </layout> | |
46 | </widget> |
|
43 | </widget> | |
47 | </widget> |
|
44 | </widget> | |
48 | </item> |
|
45 | </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> |
|
46 | </layout> | |
57 | </widget> |
|
47 | </widget> | |
58 | <resources/> |
|
48 | <resources/> | |
59 | <connections/> |
|
49 | <connections/> | |
60 | </ui> |
|
50 | </ui> |
General Comments 0
You need to be logged in to leave comments.
Login now