2014-09-26 08:46:48 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Copyright (C) 2014 by Amaury Pouly
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
2013-08-21 18:16:26 +00:00
|
|
|
#include "regtab.h"
|
|
|
|
|
|
|
|
#include <QSizePolicy>
|
|
|
|
#include <QStringBuilder>
|
|
|
|
#include <QFileDialog>
|
2014-02-03 23:18:51 +00:00
|
|
|
#include <QDebug>
|
2014-02-10 22:10:55 +00:00
|
|
|
#include <QStyle>
|
2014-05-11 17:51:55 +00:00
|
|
|
#include <QMessageBox>
|
2013-08-21 18:16:26 +00:00
|
|
|
#include "backend.h"
|
|
|
|
#include "analyser.h"
|
2014-04-07 09:28:04 +00:00
|
|
|
#include "regdisplaypanel.h"
|
2013-08-21 18:16:26 +00:00
|
|
|
|
2014-04-07 09:28:04 +00:00
|
|
|
namespace
|
2014-02-10 22:10:55 +00:00
|
|
|
{
|
|
|
|
|
2014-04-07 09:28:04 +00:00
|
|
|
enum
|
2014-02-10 22:10:55 +00:00
|
|
|
{
|
2014-04-07 09:28:04 +00:00
|
|
|
RegTreeDevType = QTreeWidgetItem::UserType,
|
2014-08-09 16:39:45 +00:00
|
|
|
RegTreeRegType,
|
|
|
|
RegTreeSocType
|
|
|
|
};
|
|
|
|
|
|
|
|
class SocTreeItem : public QTreeWidgetItem
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
SocTreeItem(const QString& string, const SocRef& ref)
|
|
|
|
:QTreeWidgetItem(QStringList(string), RegTreeSocType), m_ref(ref) {}
|
|
|
|
|
|
|
|
const SocRef& GetRef() { return m_ref; }
|
|
|
|
private:
|
|
|
|
SocRef m_ref;
|
2014-04-07 09:28:04 +00:00
|
|
|
};
|
2014-02-10 22:10:55 +00:00
|
|
|
|
2014-04-07 09:28:04 +00:00
|
|
|
class DevTreeItem : public QTreeWidgetItem
|
2014-02-10 22:10:55 +00:00
|
|
|
{
|
2014-04-07 09:28:04 +00:00
|
|
|
public:
|
|
|
|
DevTreeItem(const QString& string, const SocDevRef& ref)
|
|
|
|
:QTreeWidgetItem(QStringList(string), RegTreeDevType), m_ref(ref) {}
|
2014-02-10 22:10:55 +00:00
|
|
|
|
2014-04-07 09:28:04 +00:00
|
|
|
const SocDevRef& GetRef() { return m_ref; }
|
|
|
|
private:
|
|
|
|
SocDevRef m_ref;
|
|
|
|
};
|
2014-02-10 22:10:55 +00:00
|
|
|
|
2014-04-07 09:28:04 +00:00
|
|
|
class RegTreeItem : public QTreeWidgetItem
|
2014-02-10 22:10:55 +00:00
|
|
|
{
|
2014-04-07 09:28:04 +00:00
|
|
|
public:
|
|
|
|
RegTreeItem(const QString& string, const SocRegRef& ref)
|
|
|
|
:QTreeWidgetItem(QStringList(string), RegTreeRegType), m_ref(ref) {}
|
2014-02-10 22:10:55 +00:00
|
|
|
|
2014-04-07 09:28:04 +00:00
|
|
|
const SocRegRef& GetRef() { return m_ref; }
|
|
|
|
private:
|
|
|
|
SocRegRef m_ref;
|
|
|
|
};
|
2014-02-10 22:10:55 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-04-07 09:28:04 +00:00
|
|
|
* EmptyRegTabPanel
|
2014-02-10 22:10:55 +00:00
|
|
|
*/
|
2014-04-07 09:28:04 +00:00
|
|
|
EmptyRegTabPanel::EmptyRegTabPanel(QWidget *parent)
|
|
|
|
:QWidget(parent)
|
2014-02-10 22:10:55 +00:00
|
|
|
{
|
2014-04-07 09:28:04 +00:00
|
|
|
QVBoxLayout *l = new QVBoxLayout;
|
|
|
|
l->addStretch();
|
|
|
|
setLayout(l);
|
2014-02-10 22:10:55 +00:00
|
|
|
}
|
|
|
|
|
2014-04-07 09:28:04 +00:00
|
|
|
void EmptyRegTabPanel::AllowWrite(bool en)
|
2014-02-10 22:10:55 +00:00
|
|
|
{
|
2014-04-07 09:28:04 +00:00
|
|
|
Q_UNUSED(en);
|
2014-02-10 22:10:55 +00:00
|
|
|
}
|
|
|
|
|
2014-04-07 09:28:04 +00:00
|
|
|
QWidget *EmptyRegTabPanel::GetWidget()
|
2014-02-10 22:10:55 +00:00
|
|
|
{
|
2014-04-07 09:28:04 +00:00
|
|
|
return this;
|
2014-02-10 22:10:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* RegTab
|
|
|
|
*/
|
|
|
|
|
2014-04-07 09:28:04 +00:00
|
|
|
RegTab::RegTab(Backend *backend, QWidget *parent)
|
|
|
|
:QSplitter(parent), m_backend(backend)
|
2013-08-21 18:16:26 +00:00
|
|
|
{
|
|
|
|
QWidget *left = new QWidget;
|
2014-02-04 16:35:09 +00:00
|
|
|
this->addWidget(left);
|
|
|
|
this->setStretchFactor(0, 1);
|
2013-08-21 18:16:26 +00:00
|
|
|
QVBoxLayout *left_layout = new QVBoxLayout;
|
|
|
|
left->setLayout(left_layout);
|
|
|
|
|
|
|
|
QGroupBox *top_group = new QGroupBox("SOC selection");
|
|
|
|
QVBoxLayout *top_group_layout = new QVBoxLayout;
|
|
|
|
m_soc_selector = new QComboBox;
|
|
|
|
top_group_layout->addWidget(m_soc_selector);
|
|
|
|
top_group->setLayout(top_group_layout);
|
|
|
|
|
|
|
|
m_reg_tree = new QTreeWidget();
|
|
|
|
m_reg_tree->setColumnCount(1);
|
|
|
|
m_reg_tree->setHeaderLabel(QString("Name"));
|
|
|
|
|
|
|
|
m_analysers_list = new QListWidget;
|
|
|
|
|
|
|
|
m_type_selector = new QTabWidget;
|
|
|
|
m_type_selector->addTab(m_reg_tree, "Registers");
|
|
|
|
m_type_selector->addTab(m_analysers_list, "Analyzers");
|
|
|
|
m_type_selector->setTabPosition(QTabWidget::West);
|
|
|
|
|
|
|
|
left_layout->addWidget(top_group);
|
|
|
|
left_layout->addWidget(m_type_selector);
|
|
|
|
|
|
|
|
m_right_panel = new QVBoxLayout;
|
|
|
|
QGroupBox *data_sel_group = new QGroupBox("Data selection");
|
|
|
|
QHBoxLayout *data_sel_layout = new QHBoxLayout;
|
2014-09-18 17:02:54 +00:00
|
|
|
m_backend_selector = new BackendSelector(m_backend, this);
|
2014-02-10 22:10:55 +00:00
|
|
|
m_readonly_check = new QCheckBox("Read-only");
|
|
|
|
m_readonly_check->setCheckState(Qt::Checked);
|
2013-08-21 18:16:26 +00:00
|
|
|
m_data_soc_label = new QLabel;
|
2014-05-11 17:51:55 +00:00
|
|
|
m_dump = new QPushButton("Dump", this);
|
|
|
|
m_dump->setIcon(QIcon::fromTheme("system-run"));
|
|
|
|
m_data_sel_reload = new QPushButton(this);
|
|
|
|
m_data_sel_reload->setIcon(QIcon::fromTheme("view-refresh"));
|
|
|
|
m_data_sel_reload->setToolTip("Reload data");
|
2014-09-18 17:02:54 +00:00
|
|
|
data_sel_layout->addWidget(m_backend_selector);
|
2014-02-10 22:10:55 +00:00
|
|
|
data_sel_layout->addWidget(m_readonly_check);
|
2013-08-21 18:16:26 +00:00
|
|
|
data_sel_layout->addWidget(m_data_soc_label);
|
2014-05-11 17:51:55 +00:00
|
|
|
data_sel_layout->addWidget(m_dump);
|
|
|
|
data_sel_layout->addWidget(m_data_sel_reload);
|
2013-08-21 18:16:26 +00:00
|
|
|
data_sel_group->setLayout(data_sel_layout);
|
|
|
|
m_data_soc_label->setFrameStyle(QFrame::StyledPanel | QFrame::Raised);
|
2014-09-27 11:29:44 +00:00
|
|
|
m_msg = new MessageWidget(this);
|
2013-08-21 18:16:26 +00:00
|
|
|
|
2014-04-07 09:28:04 +00:00
|
|
|
m_right_panel->addWidget(data_sel_group, 0);
|
2014-09-27 11:29:44 +00:00
|
|
|
m_right_panel->addWidget(m_msg, 0);
|
2014-04-07 09:28:04 +00:00
|
|
|
m_right_content = 0;
|
|
|
|
SetPanel(new EmptyRegTabPanel);
|
2013-08-21 18:16:26 +00:00
|
|
|
QWidget *w = new QWidget;
|
|
|
|
w->setLayout(m_right_panel);
|
2014-02-04 16:35:09 +00:00
|
|
|
this->addWidget(w);
|
|
|
|
this->setStretchFactor(1, 2);
|
2013-08-21 18:16:26 +00:00
|
|
|
|
2014-09-18 17:03:08 +00:00
|
|
|
m_io_backend = m_backend_selector->GetBackend();
|
2013-08-21 18:16:26 +00:00
|
|
|
|
2014-04-07 09:28:04 +00:00
|
|
|
connect(m_soc_selector, SIGNAL(currentIndexChanged(int)),
|
|
|
|
this, SLOT(OnSocChanged(int)));
|
2013-08-21 18:16:26 +00:00
|
|
|
connect(m_backend, SIGNAL(OnSocListChanged()), this, SLOT(OnSocListChanged()));
|
2014-09-18 11:01:35 +00:00
|
|
|
connect(m_reg_tree, SIGNAL(itemClicked(QTreeWidgetItem*, int)),
|
|
|
|
this, SLOT(OnRegItemClicked(QTreeWidgetItem*, int)));
|
2013-08-21 18:16:26 +00:00
|
|
|
connect(m_data_soc_label, SIGNAL(linkActivated(const QString&)), this,
|
|
|
|
SLOT(OnDataSocActivated(const QString&)));
|
2014-09-18 11:01:35 +00:00
|
|
|
connect(m_analysers_list, SIGNAL(itemClicked(QListWidgetItem *)),
|
|
|
|
this, SLOT(OnAnalyserClicked(QListWidgetItem *)));
|
2014-09-18 17:02:54 +00:00
|
|
|
connect(m_backend_selector, SIGNAL(OnSelect(IoBackend *)),
|
|
|
|
this, SLOT(OnBackendSelect(IoBackend *)));
|
2014-02-10 22:10:55 +00:00
|
|
|
connect(m_readonly_check, SIGNAL(clicked(bool)), this, SLOT(OnReadOnlyClicked(bool)));
|
2014-05-11 17:51:55 +00:00
|
|
|
connect(m_dump, SIGNAL(clicked(bool)), this, SLOT(OnDumpRegs(bool)));
|
2014-09-18 17:02:54 +00:00
|
|
|
connect(m_data_sel_reload, SIGNAL(clicked(bool)), this, SLOT(OnBackendReload(bool)));
|
|
|
|
connect(m_type_selector, SIGNAL(currentChanged(int)), this, SLOT(OnTypeChanged(int)));
|
2013-08-21 18:16:26 +00:00
|
|
|
|
2014-09-27 11:29:44 +00:00
|
|
|
SetMessage(MessageWidget::Information,
|
|
|
|
"You can browse the registers. Select a data source to analyse the values.");
|
|
|
|
|
2013-08-21 18:16:26 +00:00
|
|
|
OnSocListChanged();
|
2014-09-18 17:02:54 +00:00
|
|
|
SetDataSocName("");
|
2014-09-27 11:28:44 +00:00
|
|
|
UpdateTabName();
|
2013-08-21 18:16:26 +00:00
|
|
|
}
|
|
|
|
|
2014-09-18 19:36:17 +00:00
|
|
|
QWidget *RegTab::GetWidget()
|
|
|
|
{
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2014-02-09 01:17:14 +00:00
|
|
|
RegTab::~RegTab()
|
|
|
|
{
|
2014-09-18 17:02:54 +00:00
|
|
|
/* backend will be deleted by backend selector */
|
2014-02-09 01:17:14 +00:00
|
|
|
}
|
|
|
|
|
2014-04-07 09:28:04 +00:00
|
|
|
bool RegTab::Quit()
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-08-21 18:16:26 +00:00
|
|
|
void RegTab::SetDataSocName(const QString& socname)
|
|
|
|
{
|
|
|
|
if(socname.size() != 0)
|
|
|
|
{
|
|
|
|
m_data_soc_label->setText("<a href=\"" + socname + "\">" + socname + "</a>");
|
|
|
|
m_data_soc_label->setTextFormat(Qt::RichText);
|
|
|
|
m_data_soc_label->show();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_data_soc_label->setText("");
|
|
|
|
m_data_soc_label->hide();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void RegTab::OnDataSocActivated(const QString& str)
|
|
|
|
{
|
|
|
|
int index = m_soc_selector->findText(str);
|
|
|
|
if(index != -1)
|
|
|
|
m_soc_selector->setCurrentIndex(index);
|
|
|
|
}
|
|
|
|
|
2014-09-18 19:36:17 +00:00
|
|
|
void RegTab::UpdateTabName()
|
|
|
|
{
|
|
|
|
/* do it the ugly way: try to cast to the different possible backends */
|
|
|
|
FileIoBackend *file = dynamic_cast< FileIoBackend* >(m_io_backend);
|
|
|
|
#ifdef HAVE_HWSTUB
|
|
|
|
HWStubIoBackend *hwstub = dynamic_cast< HWStubIoBackend* >(m_io_backend);
|
|
|
|
#endif
|
|
|
|
if(file)
|
|
|
|
{
|
|
|
|
QFileInfo info(file->GetFileName());
|
|
|
|
SetTabName(info.fileName());
|
|
|
|
}
|
|
|
|
#ifdef HAVE_HWSTUB
|
|
|
|
else if(hwstub)
|
|
|
|
{
|
|
|
|
HWStubDevice *dev = hwstub->GetDevice();
|
|
|
|
SetTabName(QString("HWStub %1.%2").arg(dev->GetBusNumber())
|
|
|
|
.arg(dev->GetDevAddress()));
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SetTabName("Register Tab");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-09-18 17:02:54 +00:00
|
|
|
void RegTab::OnBackendSelect(IoBackend *backend)
|
2013-08-21 18:16:26 +00:00
|
|
|
{
|
2014-09-18 17:02:54 +00:00
|
|
|
m_io_backend = backend;
|
|
|
|
SetReadOnlyIndicator();
|
|
|
|
SetDataSocName(m_io_backend->GetSocName());
|
|
|
|
OnDataSocActivated(m_io_backend->GetSocName());
|
2013-08-21 18:16:26 +00:00
|
|
|
OnDataChanged();
|
2014-09-18 19:36:17 +00:00
|
|
|
UpdateTabName();
|
2013-08-21 18:16:26 +00:00
|
|
|
}
|
|
|
|
|
2014-02-09 01:16:43 +00:00
|
|
|
void RegTab::SetReadOnlyIndicator()
|
|
|
|
{
|
2014-02-10 22:10:55 +00:00
|
|
|
if(m_io_backend->IsReadOnly())
|
|
|
|
m_readonly_check->setCheckState(Qt::Checked);
|
2014-02-09 01:16:43 +00:00
|
|
|
}
|
|
|
|
|
2013-08-21 18:16:26 +00:00
|
|
|
void RegTab::OnDataChanged()
|
|
|
|
{
|
2014-09-18 11:01:35 +00:00
|
|
|
OnRegItemClicked(m_reg_tree->currentItem(), 0);
|
2013-08-21 18:16:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void RegTab::OnRegItemClicked(QTreeWidgetItem *current, int col)
|
|
|
|
{
|
2014-04-07 09:28:04 +00:00
|
|
|
Q_UNUSED(col);
|
|
|
|
if(current == 0)
|
2013-08-21 18:16:26 +00:00
|
|
|
return;
|
2014-08-09 16:39:45 +00:00
|
|
|
if(current->type() == RegTreeSocType)
|
|
|
|
{
|
|
|
|
SocTreeItem *item = dynamic_cast< SocTreeItem * >(current);
|
|
|
|
DisplaySoc(item->GetRef());
|
|
|
|
}
|
2014-04-07 09:28:04 +00:00
|
|
|
if(current->type() == RegTreeRegType)
|
|
|
|
{
|
|
|
|
RegTreeItem *item = dynamic_cast< RegTreeItem * >(current);
|
|
|
|
DisplayRegister(item->GetRef());
|
|
|
|
}
|
|
|
|
else if(current->type() == RegTreeDevType)
|
|
|
|
{
|
|
|
|
DevTreeItem *item = dynamic_cast< DevTreeItem * >(current);
|
|
|
|
DisplayDevice(item->GetRef());
|
|
|
|
}
|
2013-08-21 18:16:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void RegTab::OnAnalyserClicked(QListWidgetItem *current)
|
|
|
|
{
|
|
|
|
if(current == 0)
|
|
|
|
return;
|
|
|
|
AnalyserFactory *ana = AnalyserFactory::GetAnalyserByName(current->text());
|
2014-04-07 09:28:04 +00:00
|
|
|
SetPanel(ana->Create(m_cur_soc, m_io_backend));
|
2013-08-21 18:16:26 +00:00
|
|
|
}
|
|
|
|
|
2014-02-09 01:13:53 +00:00
|
|
|
void RegTab::DisplayRegister(const SocRegRef& ref)
|
2014-04-07 09:28:04 +00:00
|
|
|
{
|
|
|
|
SetPanel(new RegDisplayPanel(this, m_io_backend, ref));
|
|
|
|
}
|
|
|
|
|
|
|
|
void RegTab::DisplayDevice(const SocDevRef& ref)
|
|
|
|
{
|
|
|
|
SetPanel(new DevDisplayPanel(this, ref));
|
|
|
|
}
|
|
|
|
|
2014-08-09 16:39:45 +00:00
|
|
|
void RegTab::DisplaySoc(const SocRef& ref)
|
|
|
|
{
|
|
|
|
SetPanel(new SocDisplayPanel(this, ref));
|
|
|
|
}
|
|
|
|
|
2014-09-27 11:29:44 +00:00
|
|
|
void RegTab::SetMessage(MessageWidget::MessageType type, const QString& msg)
|
|
|
|
{
|
|
|
|
m_msg->SetMessage(type, msg);
|
|
|
|
}
|
|
|
|
|
2014-04-07 09:28:04 +00:00
|
|
|
void RegTab::SetPanel(RegTabPanel *panel)
|
2013-08-21 18:16:26 +00:00
|
|
|
{
|
|
|
|
delete m_right_content;
|
2014-02-10 22:10:55 +00:00
|
|
|
m_right_content = panel;
|
2014-04-07 09:28:04 +00:00
|
|
|
m_right_content->AllowWrite(m_readonly_check->checkState() == Qt::Unchecked);
|
|
|
|
m_right_panel->addWidget(m_right_content->GetWidget(), 1);
|
2013-08-21 18:16:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void RegTab::OnSocListChanged()
|
|
|
|
{
|
|
|
|
m_soc_selector->clear();
|
2014-04-07 09:28:04 +00:00
|
|
|
QList< SocRef > socs = m_backend->GetSocList();
|
2013-08-21 18:16:26 +00:00
|
|
|
for(int i = 0; i < socs.size(); i++)
|
2014-04-07 09:28:04 +00:00
|
|
|
{
|
|
|
|
QVariant v;
|
|
|
|
v.setValue(socs[i]);
|
|
|
|
m_soc_selector->addItem(QString::fromStdString(socs[i].GetSoc().name), v);
|
|
|
|
}
|
2013-08-21 18:16:26 +00:00
|
|
|
}
|
|
|
|
|
2014-04-07 09:28:04 +00:00
|
|
|
void RegTab::FillDevSubTree(QTreeWidgetItem *_item)
|
2013-08-21 18:16:26 +00:00
|
|
|
{
|
2014-04-07 09:28:04 +00:00
|
|
|
DevTreeItem *item = dynamic_cast< DevTreeItem* >(_item);
|
2014-02-09 01:13:53 +00:00
|
|
|
const soc_dev_t& dev = item->GetRef().GetDev();
|
|
|
|
for(size_t i = 0; i < dev.reg.size(); i++)
|
2013-08-21 18:16:26 +00:00
|
|
|
{
|
2014-02-09 01:13:53 +00:00
|
|
|
const soc_reg_t& reg = dev.reg[i];
|
2013-08-21 18:16:26 +00:00
|
|
|
for(size_t j = 0; j < reg.addr.size(); j++)
|
|
|
|
{
|
2014-02-09 01:13:53 +00:00
|
|
|
RegTreeItem *reg_item = new RegTreeItem(reg.addr[j].name.c_str(),
|
|
|
|
SocRegRef(item->GetRef(), i, j));
|
2013-08-21 18:16:26 +00:00
|
|
|
item->addChild(reg_item);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-08-09 16:39:45 +00:00
|
|
|
void RegTab::FillSocSubTree(QTreeWidgetItem *_item)
|
2013-08-21 18:16:26 +00:00
|
|
|
{
|
2014-08-09 16:39:45 +00:00
|
|
|
SocTreeItem *item = dynamic_cast< SocTreeItem* >(_item);
|
|
|
|
const soc_t& soc = item->GetRef().GetSoc();
|
|
|
|
for(size_t i = 0; i < soc.dev.size(); i++)
|
2013-08-21 18:16:26 +00:00
|
|
|
{
|
2014-08-09 16:39:45 +00:00
|
|
|
const soc_dev_t& dev = soc.dev[i];
|
2014-02-09 01:13:53 +00:00
|
|
|
for(size_t j = 0; j < dev.addr.size(); j++)
|
2013-08-21 18:16:26 +00:00
|
|
|
{
|
2014-02-09 01:13:53 +00:00
|
|
|
DevTreeItem *dev_item = new DevTreeItem(dev.addr[j].name.c_str(),
|
|
|
|
SocDevRef(m_cur_soc, i, j));
|
2013-08-21 18:16:26 +00:00
|
|
|
FillDevSubTree(dev_item);
|
2014-08-09 16:39:45 +00:00
|
|
|
item->addChild(dev_item);
|
2013-08-21 18:16:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-08-09 16:39:45 +00:00
|
|
|
void RegTab::FillRegTree()
|
|
|
|
{
|
|
|
|
SocTreeItem *soc_item = new SocTreeItem(m_cur_soc.GetSoc().name.c_str(),
|
|
|
|
m_cur_soc);
|
|
|
|
FillSocSubTree(soc_item);
|
|
|
|
m_reg_tree->addTopLevelItem(soc_item);
|
|
|
|
m_reg_tree->expandItem(soc_item);
|
|
|
|
}
|
|
|
|
|
2013-08-21 18:16:26 +00:00
|
|
|
void RegTab::FillAnalyserList()
|
|
|
|
{
|
|
|
|
m_analysers_list->clear();
|
2014-02-09 01:13:53 +00:00
|
|
|
m_analysers_list->addItems(AnalyserFactory::GetAnalysersForSoc(m_cur_soc.GetSoc().name.c_str()));
|
2013-08-21 18:16:26 +00:00
|
|
|
}
|
|
|
|
|
2014-04-07 09:28:04 +00:00
|
|
|
void RegTab::OnSocChanged(int index)
|
2013-08-21 18:16:26 +00:00
|
|
|
{
|
2014-04-07 09:28:04 +00:00
|
|
|
if(index == -1)
|
2013-08-21 18:16:26 +00:00
|
|
|
return;
|
2014-04-07 09:28:04 +00:00
|
|
|
m_reg_tree->clear();
|
|
|
|
m_cur_soc = m_soc_selector->itemData(index).value< SocRef >();
|
2013-08-21 18:16:26 +00:00
|
|
|
FillRegTree();
|
|
|
|
FillAnalyserList();
|
|
|
|
}
|
2014-02-09 01:16:43 +00:00
|
|
|
|
2014-02-10 22:10:55 +00:00
|
|
|
void RegTab::OnReadOnlyClicked(bool checked)
|
2014-02-09 01:16:43 +00:00
|
|
|
{
|
2014-02-10 22:10:55 +00:00
|
|
|
if(m_io_backend->IsReadOnly())
|
|
|
|
return SetReadOnlyIndicator();
|
2014-04-07 09:28:04 +00:00
|
|
|
m_right_content->AllowWrite(!checked);
|
2014-02-09 01:16:43 +00:00
|
|
|
}
|
2014-05-11 17:51:55 +00:00
|
|
|
|
|
|
|
void RegTab::OnDumpRegs(bool c)
|
|
|
|
{
|
|
|
|
Q_UNUSED(c);
|
|
|
|
QFileDialog *fd = new QFileDialog(this);
|
|
|
|
fd->setAcceptMode(QFileDialog::AcceptSave);
|
|
|
|
fd->setFilter("Textual files (*.txt);;All files (*)");
|
|
|
|
fd->setDirectory(Settings::Get()->value("loaddatadir", QDir::currentPath()).toString());
|
|
|
|
if(!fd->exec())
|
|
|
|
return;
|
|
|
|
QStringList filenames = fd->selectedFiles();
|
|
|
|
Settings::Get()->setValue("loaddatadir", fd->directory().absolutePath());
|
|
|
|
BackendHelper bh(m_io_backend, m_cur_soc);
|
|
|
|
if(!bh.DumpAllRegisters(filenames[0]))
|
|
|
|
{
|
|
|
|
QMessageBox::warning(this, "The register dump was not saved",
|
|
|
|
"There was an error when dumping the registers");
|
|
|
|
}
|
|
|
|
}
|
2014-09-18 17:03:25 +00:00
|
|
|
|
|
|
|
void RegTab::OnBackendReload(bool c)
|
|
|
|
{
|
|
|
|
Q_UNUSED(c);
|
|
|
|
m_io_backend->Reload();
|
|
|
|
OnDataChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
void RegTab::OnTypeChanged(int index)
|
|
|
|
{
|
|
|
|
if(index == -1)
|
|
|
|
return;
|
|
|
|
if(index == 0) /* registers */
|
|
|
|
OnRegItemClicked(m_reg_tree->currentItem(), 0);
|
|
|
|
else if(index == 1) /* analysers */
|
|
|
|
OnAnalyserClicked(m_analysers_list->currentItem());
|
|
|
|
}
|