Skip to content

Commit f3f8fc9

Browse files
andreidanila1AlexandraTrifan
authored andcommitted
iioExplorer: Add iio_context pointer to IIOStandardItem.
Store iio_context on context and context-attribute items so that CliDetailsView can query libiio directly without depending on IIOWidget data strategies. Guard connectLog against empty widget lists to support eagerly created attribute items. Signed-off-by: andreidanila1 <andrei.danila@analog.com>
1 parent 1fddabd commit f3f8fc9

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

packages/generic-plugins/plugins/debugger/include/debugger/iiostandarditem.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,9 @@ class IIOStandardItem : public QObject, public QStandardItem
105105
bool childrenLoaded() const;
106106
void setChildrenLoaded(bool loaded);
107107

108+
struct iio_context *context() const;
109+
void setContext(struct iio_context *ctx);
110+
108111
struct iio_device *device() const;
109112
struct iio_channel *channel() const;
110113

@@ -127,6 +130,7 @@ protected Q_SLOTS:
127130
void extractDataFromDevice();
128131
void extractDataFromChannel();
129132

133+
struct iio_context *m_context;
130134
struct iio_device *m_device;
131135
struct iio_channel *m_channel;
132136
QList<IIOWidget *> m_iioWidgets;

packages/generic-plugins/plugins/debugger/src/iioexplorer/iiostandarditem.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ using namespace scopy::debugger;
2626

2727
IIOStandardItem::IIOStandardItem(QList<IIOWidget *> widgets, QString name, QString path, IIOStandardItem::Type type)
2828
: QStandardItem(name)
29+
, m_context(nullptr)
2930
, m_device(nullptr)
3031
, m_channel(nullptr)
3132
, m_iioWidgets(widgets)
@@ -48,6 +49,7 @@ IIOStandardItem::IIOStandardItem(QList<IIOWidget *> widgets, QString name, QStri
4849

4950
IIOStandardItem::IIOStandardItem(QList<IIOWidget *> widgets, QString name, QString id, QString path, Type type)
5051
: QStandardItem((!name.isEmpty()) ? id + ": " + name : id)
52+
, m_context(nullptr)
5153
, m_device(nullptr)
5254
, m_channel(nullptr)
5355
, m_iioWidgets(widgets)
@@ -167,7 +169,10 @@ void IIOStandardItem::connectLog()
167169
return;
168170
}
169171

170-
// this is leaf iio widget, it can probably read/write
172+
if(m_iioWidgets.isEmpty()) {
173+
return;
174+
}
175+
171176
IIOWidget *widget = m_iioWidgets.at(0);
172177

173178
connect(dynamic_cast<QObject *>(widget->getDataStrategy()),
@@ -280,6 +285,10 @@ bool IIOStandardItem::childrenLoaded() const { return m_childrenLoaded; }
280285

281286
void IIOStandardItem::setChildrenLoaded(bool loaded) { m_childrenLoaded = loaded; }
282287

288+
struct iio_context *IIOStandardItem::context() const { return m_context; }
289+
290+
void IIOStandardItem::setContext(struct iio_context *ctx) { m_context = ctx; }
291+
283292
struct iio_device *IIOStandardItem::device() const { return m_device; }
284293

285294
struct iio_channel *IIOStandardItem::channel() const { return m_channel; }
@@ -290,6 +299,7 @@ void IIOStandardItem::setIIOWidgets(QList<IIOWidget *> widgets)
290299
for(IIOWidget *w : qAsConst(m_iioWidgets)) {
291300
w->hide();
292301
}
302+
connectLog();
293303
}
294304

295305
#include "moc_iiostandarditem.cpp"

0 commit comments

Comments
 (0)