##// END OF EJS Templates
added soc viewer.
jeandet -
r6:7a60353699c8 default
parent child
Show More
@@ -0,0 +1,33
1 #include "socregsviewer.h"
2
3 socRegsViewer::socRegsViewer(const QString &name, QWidget *parent) :
4 QScrollArea(parent)
5 {
6 p_name = name;
7 p_scrollAreaWdgt = new QWidget(this);
8 p_scrollAreaWdgtLayout = new QGridLayout(p_scrollAreaWdgt);
9 //p_layout = new QGridLayout(this);
10 p_nameLabel = new QLabel(name);
11 setWidget(p_scrollAreaWdgt);
12 setWidgetResizable(true);
13 p_scrollAreaWdgt->setLayout(p_scrollAreaWdgtLayout);
14 p_scrollAreaWdgtLayout->addWidget(p_nameLabel,0,0,1,1);
15 }
16
17 peripheralWidget *socRegsViewer::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 socRegsViewer::addPeripheral(peripheralWidget *peripheral)
27 {
28 if(peripheral!=NULL)
29 {
30 p_peripherals.append(peripheral);
31 p_scrollAreaWdgtLayout->addWidget(peripheral,p_peripherals.count(),0,1,-1);
32 }
33 }
@@ -0,0 +1,28
1 #ifndef SOCREGSVIEWER_H
2 #define SOCREGSVIEWER_H
3
4 #include <QWidget>
5 #include <QtWidgets>
6 #include "peripheralwidget.h"
7
8 class socRegsViewer : public QScrollArea
9 {
10 Q_OBJECT
11 public:
12 explicit socRegsViewer(const QString& name,QWidget *parent = 0);
13 peripheralWidget* peripheral(int index);
14
15 signals:
16
17 public slots:
18 void addPeripheral(peripheralWidget* peripheral);
19
20 private:
21 QWidget* p_scrollAreaWdgt;
22 QString p_name;
23 QGridLayout* p_layout,*p_scrollAreaWdgtLayout;
24 QLabel* p_nameLabel;
25 QList<peripheralWidget*> p_peripherals;
26 };
27
28 #endif // SOCREGSVIEWER_H
@@ -1,9 +1,14
1
1
2 PERIPHERAL_WDGT_SOURCES =\
2 PERIPHERAL_WDGT_SOURCES =\
3 src/peripheralwidget.cpp \
3 src/peripheralwidget.cpp \
4 src/registerwidget.cpp
4 src/registerwidget.cpp \
5 src/socregsviewer.cpp
6
7
5
8
6 PERIPHERAL_WDGT_HEADERS += \
9 PERIPHERAL_WDGT_HEADERS += \
7 src/peripheralwidget.h \
10 src/peripheralwidget.h \
8 src/registerwidget.h
11 src/registerwidget.h \
12 src/socregsviewer.h
9
13
14
@@ -1,11 +1,26
1 #include "mainwindow.h"
1 #include "mainwindow.h"
2 #include <QApplication>
2 #include <QApplication>
3 #include "socregsviewer.h"
3
4
4 int main(int argc, char *argv[])
5 int main(int argc, char *argv[])
5 {
6 {
6 QApplication a(argc, argv);
7 QApplication a(argc, argv);
7 MainWindow w;
8 // MainWindow w;
8 w.show();
9 // w.show();
9
10 qint32 baseAddress = 0x8000100;
11 qint32 baseAddress2 = 0x8000200;
12 // testWidget = new peripheralWidget("UART1",baseAddress,this);
13 // for(int i=0;i<10;i++)
14 // testWidget->addRegister(QString("REG%1").arg((uint)i),baseAddress+(i*4));
15 socRegsViewer* socViewer;
16 socViewer = new socRegsViewer("leon 3");
17 socViewer->addPeripheral(new peripheralWidget("UART1",baseAddress));
18 socViewer->addPeripheral(new peripheralWidget("UART2",baseAddress2));
19 for(int i=0;i<10;i++)
20 {
21 socViewer->peripheral(0)->addRegister(QString("REG%1").arg((uint)i),baseAddress+(i*4));
22 socViewer->peripheral(1)->addRegister(QString("REG%1").arg((uint)i),baseAddress2+(i*4));
23 }
24 socViewer->show();
10 return a.exec();
25 return a.exec();
11 }
26 }
@@ -4,10 +4,19 MainWindow::MainWindow(QWidget *parent)
4 : QMainWindow(parent)
4 : QMainWindow(parent)
5 {
5 {
6 qint32 baseAddress = 0x8000100;
6 qint32 baseAddress = 0x8000100;
7 testWidget = new peripheralWidget("UART1",baseAddress,this);
7 qint32 baseAddress2 = 0x8000200;
8 // testWidget = new peripheralWidget("UART1",baseAddress,this);
9 // for(int i=0;i<10;i++)
10 // testWidget->addRegister(QString("REG%1").arg((uint)i),baseAddress+(i*4));
11 socViewer = new socRegsViewer("leon 3");
12 socViewer->addPeripheral(new peripheralWidget("UART1",baseAddress,this));
13 socViewer->addPeripheral(new peripheralWidget("UART2",baseAddress2,this));
8 for(int i=0;i<10;i++)
14 for(int i=0;i<10;i++)
9 testWidget->addRegister(QString("REG%1").arg((uint)i),baseAddress+(i*4));
15 {
10 this->setCentralWidget(testWidget);
16 socViewer->peripheral(0)->addRegister(QString("REG%1").arg((uint)i),baseAddress+(i*4));
17 socViewer->peripheral(1)->addRegister(QString("REG%1").arg((uint)i),baseAddress2+(i*4));
18 }
19 this->setCentralWidget(socViewer);
11 }
20 }
12
21
13 MainWindow::~MainWindow()
22 MainWindow::~MainWindow()
@@ -3,6 +3,7
3
3
4 #include <QMainWindow>
4 #include <QMainWindow>
5 #include "peripheralwidget.h"
5 #include "peripheralwidget.h"
6 #include "socregsviewer.h"
6
7
7 class MainWindow : public QMainWindow
8 class MainWindow : public QMainWindow
8 {
9 {
@@ -13,6 +14,7 public:
13 ~MainWindow();
14 ~MainWindow();
14
15
15 peripheralWidget* testWidget;
16 peripheralWidget* testWidget;
17 socRegsViewer* socViewer;
16 };
18 };
17
19
18 #endif // MAINWINDOW_H
20 #endif // MAINWINDOW_H
General Comments 0
You need to be logged in to leave comments. Login now