Skip to content

Commit

Permalink
iiodebugplugin/IIODebugInstrument: Change refresh button functionality
Browse files Browse the repository at this point in the history
The refresh button now has an icon and refreshes the selected element
from the tree view and the watchlistview

Signed-off-by: Andrei-Fabian-Pop <[email protected]>
  • Loading branch information
Andrei-Fabian-Pop committed Apr 30, 2024
1 parent 5e1ecf7 commit 5a61373
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public Q_SLOTS:
void addToWatchlist(IIOStandardItem *item);
void removeFromWatchlist(IIOStandardItem *item);
void currentTreeSelectionChanged(IIOStandardItem *item);
void refreshWatchlist();

Q_SIGNALS:
void selectedItem(IIOStandardItem *item);
Expand All @@ -38,9 +39,6 @@ public Q_SLOTS:
QList<int> m_offsets;
ApiObject *m_apiObject;
QMap<QString, WatchListEntry *> m_entryObjects;

HoverWidget *m_hoverWidget;
QPushButton *m_readllBtn;
};

class WatchListView_API : public ApiObject
Expand Down
4 changes: 2 additions & 2 deletions plugins/iiodebugplugin/src/detailsview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ DetailsView::DetailsView(QWidget *parent)
, m_tabWidget(new QTabWidget(this))
, m_guiView(new QWidget(this))
, m_iioView(new QWidget(this))
, m_readBtn(new QPushButton("Read", this))
, m_readBtn(new QPushButton(this))
, m_addToWatchlistBtn(new QPushButton(this))
, m_titleContainer(new QWidget(this))
{
Expand Down Expand Up @@ -53,7 +53,7 @@ void DetailsView::setupUi()
m_tabWidget->tabBar()->setExpanding(true);

StyleHelper::TabWidgetBarUnderline(m_tabWidget, "DetailsTabWidget");
StyleHelper::BlueButton(m_readBtn, "ReadCurrentSelectionButton");
StyleHelper::RefreshButton(m_readBtn, "RefreshCurrentSelectionButton");
m_addToWatchlistBtn->setStyleSheet("QPushButton { background-color: transparent; border: 0px; }");

m_titleContainer->layout()->addWidget(m_titleLabel);
Expand Down
7 changes: 4 additions & 3 deletions plugins/iiodebugplugin/src/iiodebuginstrument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,8 @@ void IIODebugInstrument::setupUi()

m_debugLogger = new IIODebugLogger(m_tabWidget);
m_debugLogger->setObjectName("IIODebuggerLogWidget");

m_tabWidget->addTab(m_mainWidget, "Main Window");
m_tabWidget->addTab(m_debugLogger, "Log Window");
m_tabWidget->addTab(m_mainWidget, "IIO Attributes");
m_tabWidget->addTab(m_debugLogger, "Log");
m_tabWidget->setCurrentIndex(0);
m_tabWidget->setTabPosition(QTabWidget::South);

Expand Down Expand Up @@ -159,6 +158,7 @@ void IIODebugInstrument::connectSignalsAndSlots()
qDebug(CAT_DEBUGGERIIOMODEL) << "Read button pressed.";
triggerReadOnAllChildItems(m_currentlySelectedItem);
m_detailsView->refreshIIOView();
m_watchListView->refreshWatchlist();
});

QObject::connect(m_detailsView->addToWatchlistBtn(), &QPushButton::clicked, this, [this]() {
Expand Down Expand Up @@ -191,6 +191,7 @@ void IIODebugInstrument::connectSignalsAndSlots()
.arg(oldValue.isEmpty() ? "" : oldValue + " -> ")
.arg(newValue);
m_debugLogger->appendLog(logMessage);
m_detailsView->refreshIIOView();
});
}

Expand Down
35 changes: 13 additions & 22 deletions plugins/iiodebugplugin/src/watchlistview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,6 @@ void WatchListView::setupUi()

StyleHelper::TableWidgetDebugger(this, "DebuggerTableWidget");
verticalHeader()->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);

m_readllBtn = new QPushButton("Read Watchlist", this);
StyleHelper::BlueButton(m_readllBtn, "ReadAllFromWatchlistButton");
m_hoverWidget = new HoverWidget(m_readllBtn, parentWidget(),
parentWidget()->parentWidget()->parentWidget()->parentWidget());
m_hoverWidget->setAnchorPos(HP_BOTTOMRIGHT);
m_hoverWidget->setContentPos(HP_BOTTOMLEFT);
m_hoverWidget->setAnchorOffset(QPoint(0, 5));
m_hoverWidget->setVisible(true);
m_hoverWidget->raise();
}

void WatchListView::connectSignalsAndSlots()
Expand Down Expand Up @@ -84,18 +74,6 @@ void WatchListView::connectSignalsAndSlots()
int offset = newSize - originalSize;
m_offsets[logicalIndex] = offset;
});

QObject::connect(m_readllBtn, &QPushButton::clicked, this, [this]() {
for(auto object : m_entryObjects) {
IIOStandardItem::Type type = object->item()->type();
if(type == IIOStandardItem::ContextAttribute || type == IIOStandardItem::DeviceAttribute ||
type == IIOStandardItem::ChannelAttribute) {
// leaf node
IIOWidget *iioWidget = object->item()->getIIOWidgets()[0];
iioWidget->getDataStrategy()->requestData();
}
}
});
}

void WatchListView::saveSettings(QSettings &s) { m_apiObject->save(s); }
Expand Down Expand Up @@ -177,6 +155,19 @@ void WatchListView::currentTreeSelectionChanged(IIOStandardItem *item)
}
}

void WatchListView::refreshWatchlist()
{
for(auto object : m_entryObjects) {
IIOStandardItem::Type type = object->item()->type();
if(type == IIOStandardItem::ContextAttribute || type == IIOStandardItem::DeviceAttribute ||
type == IIOStandardItem::ChannelAttribute) {
// leaf node
IIOWidget *iioWidget = object->item()->getIIOWidgets()[0];
iioWidget->getDataStrategy()->requestData();
}
}
}

void WatchListView::resizeEvent(QResizeEvent *event)
{
int w = width();
Expand Down

0 comments on commit 5a61373

Please sign in to comment.