|
|
#include "socregsviewer.h"
|
|
|
|
|
|
socRegsViewer::socRegsViewer(const QString &name, QWidget *parent) :
|
|
|
QScrollArea(parent)
|
|
|
{
|
|
|
p_name = name;
|
|
|
p_scrollAreaWdgt = new QWidget(this);
|
|
|
p_scrollAreaWdgtLayout = new QGridLayout(p_scrollAreaWdgt);
|
|
|
//p_layout = new QGridLayout(this);
|
|
|
p_nameLabel = new QLabel(name);
|
|
|
setWidget(p_scrollAreaWdgt);
|
|
|
setWidgetResizable(true);
|
|
|
p_scrollAreaWdgt->setLayout(p_scrollAreaWdgtLayout);
|
|
|
p_scrollAreaWdgtLayout->addWidget(p_nameLabel,0,0,1,1);
|
|
|
}
|
|
|
|
|
|
peripheralWidget *socRegsViewer::peripheral(int index)
|
|
|
{
|
|
|
if(index>=0 && index<p_peripherals.count())
|
|
|
{
|
|
|
return p_peripherals.at(index);
|
|
|
}
|
|
|
return NULL;
|
|
|
}
|
|
|
|
|
|
void socRegsViewer::addPeripheral(peripheralWidget *peripheral)
|
|
|
{
|
|
|
if(peripheral!=NULL)
|
|
|
{
|
|
|
p_peripherals.append(peripheral);
|
|
|
p_scrollAreaWdgtLayout->addWidget(peripheral,p_peripherals.count(),0,1,-1);
|
|
|
connect(peripheral,SIGNAL(clicked(peripheralWidget*)),this,SLOT(periphClicked(peripheralWidget*)));
|
|
|
connect(peripheral,SIGNAL(upSig(peripheralWidget*,int)),this,SLOT(periphUp(peripheralWidget*,int)));
|
|
|
connect(peripheral,SIGNAL(downSig(peripheralWidget*,int)),this,SLOT(periphDown(peripheralWidget*,int)));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
void socRegsViewer::periphClicked(peripheralWidget *sender)
|
|
|
{
|
|
|
peripheralWidget * item;
|
|
|
if(sender!=NULL)
|
|
|
{
|
|
|
for(int i=0;i<p_peripherals.count();i++)
|
|
|
{
|
|
|
item = p_peripherals.at(i);
|
|
|
if(item!=sender)
|
|
|
{
|
|
|
item->leave();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
void socRegsViewer::periphUp(peripheralWidget *sender, int cursorIndex)
|
|
|
{
|
|
|
int index;
|
|
|
if(sender!=NULL)
|
|
|
{
|
|
|
index = p_peripherals.indexOf(sender);
|
|
|
if(index!=-1 && index!=0)
|
|
|
{
|
|
|
p_peripherals.at(index)->leave();
|
|
|
p_peripherals.at(index-1)->enter(cursorIndex,false);
|
|
|
ensureWidgetVisible(p_peripherals.at(index-1));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
void socRegsViewer::periphDown(peripheralWidget *sender, int cursorIndex)
|
|
|
{
|
|
|
int index;
|
|
|
if(sender!=NULL)
|
|
|
{
|
|
|
index = p_peripherals.indexOf(sender);
|
|
|
if(index!=-1 && index<(p_peripherals.count()-1))
|
|
|
{
|
|
|
p_peripherals.at(index)->leave();
|
|
|
p_peripherals.at(index+1)->enter(cursorIndex);
|
|
|
ensureWidgetVisible(p_peripherals.at(index+1));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|