diff --git a/iio-widgets/include/iio-widgets/datastrategy/emptydatastrategy.h b/iio-widgets/include/iio-widgets/datastrategy/emptydatastrategy.h new file mode 100644 index 0000000000..8efb929d15 --- /dev/null +++ b/iio-widgets/include/iio-widgets/datastrategy/emptydatastrategy.h @@ -0,0 +1,36 @@ +#ifndef EMPTYDATASTRATEGY_H +#define EMPTYDATASTRATEGY_H + +#include +#include "datastrategy/datastrategyinterface.h" +#include "scopy-iio-widgets_export.h" + +namespace scopy { +class SCOPY_IIO_WIDGETS_EXPORT EmptyDataStrategy : public QObject, public DataStrategyInterface +{ + Q_OBJECT + Q_INTERFACES(scopy::DataStrategyInterface) +public: + explicit EmptyDataStrategy(QObject *parent = nullptr); + + QString data() override; + QString optionalData() override; + +public Q_SLOTS: + int write(QString data) override; + QPair read() override; + void writeAsync(QString data) override; + void readAsync() override; + +Q_SIGNALS: + void sendData(QString data, QString dataOptions) override; + void aboutToWrite(QString oldData, QString newData) override; + void emitStatus(QDateTime timestamp, QString oldData, QString newData, int returnCode, bool isReadOp) override; + +private: + QString m_data; + QString m_previousData; +}; +} // namespace scopy + +#endif // EMPTYDATASTRATEGY_H diff --git a/iio-widgets/include/iio-widgets/iioconfigurationpopup.h b/iio-widgets/include/iio-widgets/iioconfigurationpopup.h index bcce6ac46a..dc450aa200 100644 --- a/iio-widgets/include/iio-widgets/iioconfigurationpopup.h +++ b/iio-widgets/include/iio-widgets/iioconfigurationpopup.h @@ -25,6 +25,7 @@ class SCOPY_IIO_WIDGETS_EXPORT IIOConfigurationPopup : public QWidget Q_SIGNALS: void selectButtonClicked(IIOItem *selected); + void emptyButtonClicked(); void exitButtonClicked(); protected Q_SLOTS: @@ -39,6 +40,7 @@ protected Q_SLOTS: IIOWidgetSelector *m_widgetSelector; QPushButton *m_exitButton; QPushButton *m_selectButton; + QPushButton *m_emptyButton; IIOItem *m_root; }; } // namespace scopy diff --git a/iio-widgets/include/iio-widgets/iiowidget.h b/iio-widgets/include/iio-widgets/iiowidget.h index 6d70e250a3..518c3399a8 100644 --- a/iio-widgets/include/iio-widgets/iiowidget.h +++ b/iio-widgets/include/iio-widgets/iiowidget.h @@ -124,7 +124,20 @@ class SCOPY_IIO_WIDGETS_EXPORT IIOWidget : public QWidget */ int lastReturnCode(); + /** + * @brief setUItoDataConversion Adds a function that is called before sending the data given as imput by the + * user and modifies this data. The function receives as parameter a QString, converts it and returns the + * converted string that will be sent to the DS after. + * @param func std::function + */ void setUItoDataConversion(std::function func); + + /** + * @brief setDataToUIConversion Adds a function that is called before sending the data read by the IIOWidget + * and modifies this data. The function receives as parameter a QString, converts it and returns the + * converted string that will be sent to the UI after. + * @param func std::function + */ void setDataToUIConversion(std::function func); /** @@ -239,12 +252,12 @@ protected Q_SLOTS: void setLastOperationTimestamp(QDateTime timestamp); void setLastOperationState(IIOWidget::State state); - // Core variables + /* Core variables */ GuiStrategyInterface *m_uiStrategy; DataStrategyInterface *m_dataStrategy; IIOWidgetFactoryRecipe m_recipe; - // Logged data + /* Logged data */ QString m_lastData; SmallProgressBar *m_progressBar; QDateTime *m_lastOpTimestamp; @@ -255,7 +268,7 @@ protected Q_SLOTS: std::function m_UItoDS; std::function m_DStoUI; - // Optional configuration + /* Optional configuration */ QPushButton *m_configBtn; IIOConfigurationPopup *m_configPopup; bool m_isConfigurable; diff --git a/iio-widgets/include/iio-widgets/iiowidgetbuilder.h b/iio-widgets/include/iio-widgets/iiowidgetbuilder.h index bb374dacca..75e5e59cd3 100644 --- a/iio-widgets/include/iio-widgets/iiowidgetbuilder.h +++ b/iio-widgets/include/iio-widgets/iiowidgetbuilder.h @@ -42,6 +42,7 @@ class SCOPY_IIO_WIDGETS_EXPORT IIOWidgetBuilder : public QObject TriggerData, DeviceAttrData, ContextAttrData, + EmptyData, }; enum UIS @@ -53,7 +54,7 @@ class SCOPY_IIO_WIDGETS_EXPORT IIOWidgetBuilder : public QObject RangeUi, }; - explicit IIOWidgetBuilder(QObject *parent = nullptr); + explicit IIOWidgetBuilder(QWidget *parent = nullptr); ~IIOWidgetBuilder(); /** @@ -109,6 +110,13 @@ class SCOPY_IIO_WIDGETS_EXPORT IIOWidgetBuilder : public QObject */ IIOWidgetBuilder &configMode(bool isConfigurable); + /** + * @brief title Sets the title of the IIOWidget + * @param title QString + * @return + */ + IIOWidgetBuilder &title(QString title); + /** * @brief Sets the context that will be used, if no iio_device or iio_channel * is set, the build functions will work with the context. @@ -168,12 +176,6 @@ class SCOPY_IIO_WIDGETS_EXPORT IIOWidgetBuilder : public QObject */ IIOWidgetBuilder &uiStrategy(IIOWidgetBuilder::UIS uiStrategy); - /** - * @brief Sets the parent of the IIOWidget that will be built. - * @param parent - */ - IIOWidgetBuilder &parent(QWidget *parent); - private: DataStrategyInterface *createDS(); GuiStrategyInterface *createUIS(); @@ -188,6 +190,7 @@ class SCOPY_IIO_WIDGETS_EXPORT IIOWidgetBuilder : public QObject QString m_attribute; QString m_optionsAttribute; QString m_optionsValues; + QString m_title; IIOWidgetBuilder::DS m_dataStrategy; IIOWidgetBuilder::UIS m_uiStrategy; QWidget *m_widgetParent; diff --git a/iio-widgets/src/datastrategy/emptydatastrategy.cpp b/iio-widgets/src/datastrategy/emptydatastrategy.cpp new file mode 100644 index 0000000000..2b4051f2cb --- /dev/null +++ b/iio-widgets/src/datastrategy/emptydatastrategy.cpp @@ -0,0 +1,38 @@ +#include "emptydatastrategy.h" + +using namespace scopy; + +EmptyDataStrategy::EmptyDataStrategy(QObject *parent) + : QObject{parent} + , m_data("") + , m_previousData("") +{} + +QString EmptyDataStrategy::data() { return m_data; } + +QString EmptyDataStrategy::optionalData() { return ""; } + +int EmptyDataStrategy::write(QString data) +{ + m_previousData = data; + m_data = data; + return 0; +} + +QPair EmptyDataStrategy::read() { return {m_data, ""}; } + +void EmptyDataStrategy::writeAsync(QString data) +{ + int res = write(data); + Q_EMIT emitStatus(QDateTime::currentDateTime(), m_data, data, (int)(res), false); + readAsync(); +} + +void EmptyDataStrategy::readAsync() +{ + QPair res = read(); + Q_EMIT emitStatus(QDateTime::currentDateTime(), m_previousData, m_data, 0, true); + Q_EMIT sendData(res.first, res.second); +} + +#include "moc_emptydatastrategy.cpp" diff --git a/iio-widgets/src/iioconfigurationpopup.cpp b/iio-widgets/src/iioconfigurationpopup.cpp index 68ea66a3f9..31e6e22cf0 100644 --- a/iio-widgets/src/iioconfigurationpopup.cpp +++ b/iio-widgets/src/iioconfigurationpopup.cpp @@ -134,6 +134,7 @@ void IIOConfigurationPopup::init() Q_EMIT selectButtonClicked(iioItem); }); + QObject::connect(m_emptyButton, &QPushButton::clicked, this, &IIOConfigurationPopup::emptyButtonClicked); QObject::connect(m_exitButton, &QPushButton::clicked, this, &IIOConfigurationPopup::exitButtonClicked); m_selectButton->setDisabled(true); } @@ -161,12 +162,11 @@ void IIOConfigurationPopup::initUI() buttonGroupLayout->setSpacing(10); m_selectButton = new QPushButton("Select", buttonGroup); - m_selectButton->setObjectName("selectButton"); - + m_emptyButton = new QPushButton("No Data", buttonGroup); m_exitButton = new QPushButton("Exit", buttonGroup); - m_exitButton->setObjectName("exitButton"); buttonGroupLayout->addWidget(m_exitButton); + buttonGroupLayout->addWidget(m_emptyButton); buttonGroupLayout->addWidget(m_selectButton); backgroundLayout->addWidget(m_titleLabel); @@ -175,9 +175,10 @@ void IIOConfigurationPopup::initUI() backgroundWidget->setLayout(backgroundLayout); - StyleHelper::TutorialChapterTitleLabel(m_titleLabel, "titleLabel"); - StyleHelper::BlueButton(m_selectButton, "selectButton"); - StyleHelper::BlueButton(m_exitButton, "exitButton"); + StyleHelper::TutorialChapterTitleLabel(m_titleLabel, "TitleLabel"); + StyleHelper::BlueButton(m_selectButton, "SelectButton"); + StyleHelper::BlueButton(m_emptyButton, "EmptyButton"); + StyleHelper::BlueButton(m_exitButton, "ExitButton"); StyleHelper::OverlayMenu(this, "IIOConfigurationPopupOverlay"); } diff --git a/iio-widgets/src/iiowidget.cpp b/iio-widgets/src/iiowidget.cpp index 9a3e59125f..4b101bcacc 100644 --- a/iio-widgets/src/iiowidget.cpp +++ b/iio-widgets/src/iiowidget.cpp @@ -19,16 +19,18 @@ */ #include "iiowidget.h" -#include "channelattrdatastrategy.h" -#include "contextattrdatastrategy.h" -#include "deviceattrdatastrategy.h" -#include "iiowidgetselector.h" +#include "datastrategy/channelattrdatastrategy.h" +#include "datastrategy/contextattrdatastrategy.h" +#include "datastrategy/deviceattrdatastrategy.h" +#include "datastrategy/emptydatastrategy.h" + #include -#include -#include #include #include +#include +#include + using namespace scopy; Q_LOGGING_CATEGORY(CAT_IIOWIDGET, "iioWidget") @@ -46,15 +48,27 @@ IIOWidget::IIOWidget(GuiStrategyInterface *uiStrategy, DataStrategyInterface *da , m_DStoUI(nullptr) , m_isConfigurable(false) { + // Config button + m_configBtn->setStyleSheet("border-image: url(\":/gui/icons/scopy-default/icons/gear_wheel.svg\");"); + m_configBtn->setVisible(m_isConfigurable); + + // General layout setLayout(new QVBoxLayout(this)); layout()->setContentsMargins(0, 0, 0, 0); layout()->setSpacing(0); setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); + QWidget *topWidget = new QWidget(this); + topWidget->setLayout(new QHBoxLayout(topWidget)); + topWidget->layout()->setContentsMargins(0, 0, 0, 0); + QWidget *ui = m_uiStrategy->ui(); if(ui) { - layout()->addWidget(ui); + topWidget->layout()->addWidget(ui); } + topWidget->layout()->addWidget(m_configBtn); + + layout()->addWidget(topWidget); layout()->addWidget(m_progressBar); QObject *uiStrategyObject = dynamic_cast(m_uiStrategy); @@ -65,23 +79,31 @@ IIOWidget::IIOWidget(GuiStrategyInterface *uiStrategy, DataStrategyInterface *da connect(m_progressBar, &SmallProgressBar::progressFinished, this, [this]() { this->convertUItoDS(m_lastData); }); + connect(m_configBtn, &QPushButton::clicked, this, &IIOWidget::reconfigure); connect(uiStrategyObject, SIGNAL(emitData(QString)), this, SLOT(startTimer(QString))); + connect(uiStrategyObject, SIGNAL(emitData(QString)), this, SIGNAL(emitData(QString))); + connect(uiStrategyObject, SIGNAL(displayedNewData(QString, QString)), this, + SIGNAL(displayedNewData(QString, QString))); connect(dataStrategyObject, SIGNAL(emitStatus(QDateTime, QString, QString, int, bool)), this, SLOT(emitDataStatus(QDateTime, QString, QString, int, bool))); // forward data request from ui strategy to data strategy connect(uiStrategyObject, SIGNAL(requestData()), dataStrategyObject, SLOT(readAsync())); + connect(dataStrategyObject, SIGNAL(sendData(QString, QString)), this, SIGNAL(sendData(QString, QString))); + connect(dataStrategyObject, SIGNAL(emitStatus(QDateTime, QString, QString, int, bool)), this, + SIGNAL(emitStatus(QDateTime, QString, QString, int, bool))); // forward data from data strategy to ui strategy connect(dataStrategyObject, SIGNAL(sendData(QString, QString)), this, SLOT(convertDStoUI(QString, QString))); + connect(dataStrategyObject, SIGNAL(aboutToWrite(QString, QString)), this, + SIGNAL(aboutToWrite(QString, QString))); // intercept the sendData from dataStrategy to collect information connect(dataStrategyObject, SIGNAL(sendData(QString, QString)), this, SLOT(storeReadInfo(QString, QString))); - // The data will be populated here - bool useLazyLoading = Preferences::GetInstance()->get("iiowidgets_use_lazy_loading").toBool(); + bool useLazyLoading = Preferences::get("iiowidgets_use_lazy_loading").toBool(); if(!useLazyLoading) { // force skip lazy load LAZY_LOAD(initialize); } @@ -97,41 +119,41 @@ void IIOWidget::writeAsync(QString data) { m_dataStrategy->writeAsync(data); } DataStrategyInterface *IIOWidget::swapDataStrategy(DataStrategyInterface *dataStrategy) { - QWidget *dataStrategyWidget = dynamic_cast(m_dataStrategy); - QWidget *uiStrategyWidget = dynamic_cast(m_uiStrategy); - QWidget *newDataStrategyWidget = dynamic_cast(dataStrategy); + QObject *dataStrategyObject = dynamic_cast(m_dataStrategy); + QObject *uiStrategyObject = dynamic_cast(m_uiStrategy); + QObject *newDataStrategyObject = dynamic_cast(dataStrategy); // disconnect old data strategy - disconnect(dataStrategyWidget, SIGNAL(emitStatus(QDateTime, QString, QString, int, bool)), this, + disconnect(dataStrategyObject, SIGNAL(emitStatus(QDateTime, QString, QString, int, bool)), this, SLOT(emitDataStatus(QDateTime, QString, QString, int, bool))); - disconnect(uiStrategyWidget, SIGNAL(requestData()), dataStrategyWidget, SLOT(readAsync())); - disconnect(dataStrategyWidget, SIGNAL(sendData(QString, QString)), uiStrategyWidget, + disconnect(uiStrategyObject, SIGNAL(requestData()), dataStrategyObject, SLOT(readAsync())); + disconnect(dataStrategyObject, SIGNAL(sendData(QString, QString)), uiStrategyObject, SLOT(receiveData(QString, QString))); - disconnect(dataStrategyWidget, SIGNAL(sendData(QString, QString)), this, + disconnect(dataStrategyObject, SIGNAL(sendData(QString, QString)), this, SLOT(storeReadInfo(QString, QString))); // TODO: maybe do something with this slot.. - disconnect(dataStrategyWidget, SIGNAL(sendData(QString, QString)), this, SIGNAL(sendData(QString, QString))); - disconnect(dataStrategyWidget, SIGNAL(emitStatus(QDateTime, QString, QString, int, bool)), this, + disconnect(dataStrategyObject, SIGNAL(sendData(QString, QString)), this, SIGNAL(sendData(QString, QString))); + disconnect(dataStrategyObject, SIGNAL(emitStatus(QDateTime, QString, QString, int, bool)), this, SIGNAL(emitStatus(QDateTime, QString, QString, int, bool))); - disconnect(dataStrategyWidget, SIGNAL(aboutToWrite(QString, QString)), this, + disconnect(dataStrategyObject, SIGNAL(aboutToWrite(QString, QString)), this, SIGNAL(aboutToWrite(QString, QString))); - disconnect(uiStrategyWidget, SIGNAL(emitData(QString)), this, SIGNAL(emitData(QString))); - disconnect(uiStrategyWidget, SIGNAL(displayedNewData(QString, QString)), this, + disconnect(uiStrategyObject, SIGNAL(emitData(QString)), this, SIGNAL(emitData(QString))); + disconnect(uiStrategyObject, SIGNAL(displayedNewData(QString, QString)), this, SIGNAL(displayedNewData(QString, QString))); // connect new data strategy - connect(newDataStrategyWidget, SIGNAL(emitStatus(QDateTime, QString, QString, int, bool)), this, + connect(newDataStrategyObject, SIGNAL(emitStatus(QDateTime, QString, QString, int, bool)), this, SLOT(emitDataStatus(QDateTime, QString, QString, int, bool))); - connect(uiStrategyWidget, SIGNAL(requestData()), newDataStrategyWidget, SLOT(readAsync())); - connect(newDataStrategyWidget, SIGNAL(sendData(QString, QString)), uiStrategyWidget, + connect(uiStrategyObject, SIGNAL(requestData()), newDataStrategyObject, SLOT(readAsync())); + connect(newDataStrategyObject, SIGNAL(sendData(QString, QString)), uiStrategyObject, SLOT(receiveData(QString, QString))); - connect(newDataStrategyWidget, SIGNAL(sendData(QString, QString)), this, SLOT(storeReadInfo(QString, QString))); - connect(dataStrategyWidget, SIGNAL(sendData(QString, QString)), this, SIGNAL(sendData(QString, QString))); - connect(dataStrategyWidget, SIGNAL(emitStatus(QDateTime, QString, QString, int, bool)), this, + connect(newDataStrategyObject, SIGNAL(sendData(QString, QString)), this, SLOT(storeReadInfo(QString, QString))); + connect(dataStrategyObject, SIGNAL(sendData(QString, QString)), this, SLOT(convertDStoUI(QString, QString))); + connect(dataStrategyObject, SIGNAL(emitStatus(QDateTime, QString, QString, int, bool)), this, SIGNAL(emitStatus(QDateTime, QString, QString, int, bool))); - connect(dataStrategyWidget, SIGNAL(aboutToWrite(QString, QString)), this, + connect(dataStrategyObject, SIGNAL(aboutToWrite(QString, QString)), this, SIGNAL(aboutToWrite(QString, QString))); - connect(uiStrategyWidget, SIGNAL(emitData(QString)), this, SIGNAL(emitData(QString))); - connect(uiStrategyWidget, SIGNAL(displayedNewData(QString, QString)), this, + connect(uiStrategyObject, SIGNAL(emitData(QString)), this, SIGNAL(emitData(QString))); + connect(uiStrategyObject, SIGNAL(displayedNewData(QString, QString)), this, SIGNAL(displayedNewData(QString, QString))); // save the new data strategy and return the old one @@ -263,6 +285,13 @@ void IIOWidget::reconfigure() connect(m_configPopup, &IIOConfigurationPopup::exitButtonClicked, this, [&]() { m_configPopup->deleteLater(); }); + connect(m_configPopup, &IIOConfigurationPopup::emptyButtonClicked, this, [&]() { + DataStrategyInterface *ds = new EmptyDataStrategy(this); + DataStrategyInterface *oldDS = swapDataStrategy(ds); + delete oldDS; + delete m_configPopup; + m_uiStrategy->changeName("Empty"); + }); connect(m_configPopup, &IIOConfigurationPopup::selectButtonClicked, this, [&](IIOItem *item) { DataStrategyInterface *dsCreated = nullptr; switch(item->type()) { diff --git a/iio-widgets/src/iiowidgetbuilder.cpp b/iio-widgets/src/iiowidgetbuilder.cpp index e6bfe1741b..f4ae127bdf 100644 --- a/iio-widgets/src/iiowidgetbuilder.cpp +++ b/iio-widgets/src/iiowidgetbuilder.cpp @@ -21,12 +21,15 @@ #include "iiowidgetbuilder.h" #include "guistrategy/editableguistrategy.h" #include "guistrategy/switchguistrategy.h" +#include "guistrategy/comboguistrategy.h" +#include "guistrategy/rangeguistrategy.h" #include "datastrategy/channelattrdatastrategy.h" #include "datastrategy/triggerdatastrategy.h" #include "datastrategy/deviceattrdatastrategy.h" #include "datastrategy/contextattrdatastrategy.h" #include "datastrategy/cmdqchannelattrdatastrategy.h" #include "datastrategy/cmdqdeviceattrdatastrategy.h" +#include "datastrategy/emptydatastrategy.h" #include "guistrategy/comboguistrategy.h" #include "guistrategy/rangeguistrategy.h" #include @@ -37,7 +40,7 @@ using namespace scopy; Q_LOGGING_CATEGORY(CAT_ATTRBUILDER, "AttrBuilder") -IIOWidgetBuilder::IIOWidgetBuilder(QObject *parent) +IIOWidgetBuilder::IIOWidgetBuilder(QWidget *parent) : QObject(parent) , m_connection(nullptr) , m_isCompact(false) @@ -49,9 +52,10 @@ IIOWidgetBuilder::IIOWidgetBuilder(QObject *parent) , m_attribute("") , m_optionsAttribute("") , m_optionsValues("") + , m_title("") , m_dataStrategy(DS::NoDataStrategy) , m_uiStrategy(UIS::NoUIStrategy) - , m_widgetParent(nullptr) + , m_widgetParent(parent) {} IIOWidgetBuilder::~IIOWidgetBuilder() {} @@ -61,7 +65,7 @@ IIOWidget *IIOWidgetBuilder::buildSingle() DataStrategyInterface *ds = nullptr; GuiStrategyInterface *ui = nullptr; - if(!m_context && !m_device && !m_channel) { + if(!m_context && !m_device && !m_channel && m_dataStrategy != DS::EmptyData) { qWarning(CAT_ATTRBUILDER) << "No channel/device/context set."; return nullptr; } @@ -87,6 +91,9 @@ IIOWidget *IIOWidgetBuilder::buildSingle() IIOWidget *widget = new IIOWidget(ui, ds, m_widgetParent); widget->setRecipe(m_generatedRecipe); widget->setConfigurable(m_isConfigurable); + if(!m_title.isEmpty()) { + widget->changeTitle(m_title); + } return widget; } @@ -215,6 +222,7 @@ void IIOWidgetBuilder::clear() m_attribute = ""; m_optionsAttribute = ""; m_optionsValues = ""; + m_title = ""; m_dataStrategy = DS::NoDataStrategy; m_uiStrategy = UIS::NoUIStrategy; m_widgetParent = nullptr; @@ -244,6 +252,12 @@ IIOWidgetBuilder &IIOWidgetBuilder::configMode(bool isConfigurable) return *this; } +IIOWidgetBuilder &IIOWidgetBuilder::title(QString title) +{ + m_title = title; + return *this; +} + IIOWidgetBuilder &IIOWidgetBuilder::context(iio_context *context) { m_context = context; @@ -292,12 +306,6 @@ IIOWidgetBuilder &IIOWidgetBuilder::uiStrategy(UIS uiStrategy) return *this; } -IIOWidgetBuilder &IIOWidgetBuilder::parent(QWidget *parent) -{ - m_widgetParent = parent; - return *this; -} - DataStrategyInterface *IIOWidgetBuilder::createDS() { DataStrategyInterface *ds = nullptr; @@ -338,6 +346,9 @@ DataStrategyInterface *IIOWidgetBuilder::createDS() case DS::TriggerData: ds = new TriggerDataStrategy(m_generatedRecipe, m_widgetParent); break; + case DS::EmptyData: + ds = new EmptyDataStrategy(m_widgetParent); + break; default: qWarning(CAT_ATTRBUILDER) << "No valid Data Strategy was provided."; break; diff --git a/plugins/datalogger/src/menus/channelattributesmenu.cpp b/plugins/datalogger/src/menus/channelattributesmenu.cpp index 51cd5a28f5..2006555065 100644 --- a/plugins/datalogger/src/menus/channelattributesmenu.cpp +++ b/plugins/datalogger/src/menus/channelattributesmenu.cpp @@ -39,9 +39,8 @@ ChannelAttributesMenu::ChannelAttributesMenu(DataMonitorModel *model, QWidget *p if(qobject_cast(model)) { QList attrWidgets = - IIOWidgetBuilder() + IIOWidgetBuilder(parent) .channel(dynamic_cast(model)->iioChannel()) - .parent(parent) .buildAll(); for(auto w : attrWidgets) { diff --git a/plugins/debugger/src/iioexplorer/iiostandarditem.cpp b/plugins/debugger/src/iioexplorer/iiostandarditem.cpp index b8bb5026d1..8dc34a255a 100644 --- a/plugins/debugger/src/iioexplorer/iiostandarditem.cpp +++ b/plugins/debugger/src/iioexplorer/iiostandarditem.cpp @@ -147,8 +147,7 @@ void IIOStandardItem::connectLog() // this is leaf iio widget, it can probably read/write IIOWidget *widget = m_iioWidgets.at(0); - connect(dynamic_cast(widget->getDataStrategy()), - SIGNAL(emitStatus(QDateTime, QString, QString, int, bool)), this, + connect(widget, SIGNAL(emitStatus(QDateTime, QString, QString, int, bool)), this, SLOT(forwardLog(QDateTime, QString, QString, int, bool))); } diff --git a/plugins/debugger/src/iioexplorer/watchlistentry.cpp b/plugins/debugger/src/iioexplorer/watchlistentry.cpp index c143f3096e..310f92a53a 100644 --- a/plugins/debugger/src/iioexplorer/watchlistentry.cpp +++ b/plugins/debugger/src/iioexplorer/watchlistentry.cpp @@ -77,7 +77,7 @@ void WatchListEntry::setupWidget(IIOWidget *widget) { // if you can cast the uiStrategy to combo, this value ui will be a combo, otherwise it will be a lineedit // GuiStrategyInterface *ui = dynamic_cast(widget->getUiStrategy()); - bool isCombo = widget->isDSInstanceOf(); + bool isCombo = widget->isUISInstanceOf(); if(isCombo) { // https://forum.qt.io/topic/139728/can-t-set-qcombobox-qslider-margins // QFrame because QWidget does not have the paintEvent implemented @@ -120,7 +120,7 @@ void WatchListEntry::setupWidget(IIOWidget *widget) m_valueUi = m_lineedit; } - QObject::connect(dynamic_cast(widget->getDataStrategy()), SIGNAL(sendData(QString, QString)), this, + QObject::connect(dynamic_cast(widget), SIGNAL(sendData(QString, QString)), this, SLOT(setNewData(QString, QString))); } diff --git a/plugins/swiot/src/ad74413r/buffermenu.cpp b/plugins/swiot/src/ad74413r/buffermenu.cpp index af1431bfe7..ae179a0e02 100644 --- a/plugins/swiot/src/ad74413r/buffermenu.cpp +++ b/plugins/swiot/src/ad74413r/buffermenu.cpp @@ -37,13 +37,12 @@ BufferMenu::BufferMenu(QWidget *parent, QString chnlFunction, Connection *conn, , m_chnls(chnls) { if(m_chnls.contains(INPUT_CHNL)) { - m_samplingFreq = IIOWidgetBuilder() + m_samplingFreq = IIOWidgetBuilder(this) .connection(const_cast(m_connection)) .channel(const_cast(m_chnls[INPUT_CHNL])) .attribute("sampling_frequency") .optionsAttribute("sampling_frequency_available") .uiStrategy(IIOWidgetBuilder::UIS::ComboUi) - .parent(this) .buildSingle(); addMenuWidget(m_samplingFreq); connect(m_samplingFreq, &IIOWidget::displayedNewData, this, @@ -88,12 +87,11 @@ CurrentInLoopMenu::CurrentInLoopMenu(QWidget *parent, QString chnlFunction, Conn : BufferMenu(parent, chnlFunction, conn, chnls) { // dac code - output channel - IIOWidget *dacCode = IIOWidgetBuilder() + IIOWidget *dacCode = IIOWidgetBuilder(this) .connection(const_cast(m_connection)) .channel(const_cast(m_chnls[OUTPUT_CHNL])) .attribute("raw") .optionsValues("[0 1 8191]") - .parent(this) .buildSingle(); dacCode->changeTitle("DAC_CODE"); addMenuWidget(dacCode); @@ -134,24 +132,22 @@ DigitalInLoopMenu::DigitalInLoopMenu(QWidget *parent, QString chnlFunction, Conn : BufferMenu(parent, chnlFunction, conn, chnls) { // threshold - input channel - m_threshold = IIOWidgetBuilder() + m_threshold = IIOWidgetBuilder(this) .connection(const_cast(m_connection)) .channel(const_cast(m_chnls[INPUT_CHNL])) .attribute("threshold") .optionsValues("[0 1 16000]") - .parent(this) .buildSingle(); addMenuWidget(m_threshold); connect(m_threshold, &IIOWidget::emitData, this, &BufferMenu::thresholdChangeStart); connect(m_threshold, &IIOWidget::emitStatus, this, &DigitalInLoopMenu::onEmitStatus); // dac code - output channel - IIOWidget *dacCode = IIOWidgetBuilder() + IIOWidget *dacCode = IIOWidgetBuilder(this) .connection(const_cast(m_connection)) .channel(const_cast(m_chnls[OUTPUT_CHNL])) .attribute("raw") .optionsValues("[0 1 8191]") - .parent(this) .buildSingle(); dacCode->changeTitle("DAC_CODE"); addMenuWidget(dacCode); @@ -212,12 +208,11 @@ VoltageOutMenu::VoltageOutMenu(QWidget *parent, QString chnlFunction, Connection : BufferMenu(parent, chnlFunction, conn, chnls) { // dac code - output channel - IIOWidget *dacCode = IIOWidgetBuilder() + IIOWidget *dacCode = IIOWidgetBuilder(this) .connection(const_cast(m_connection)) .channel(const_cast(m_chnls[OUTPUT_CHNL])) .attribute("raw") .optionsValues("[0 1 8191]") - .parent(this) .buildSingle(); dacCode->changeTitle("DAC_CODE"); addMenuWidget(dacCode); @@ -236,34 +231,31 @@ VoltageOutMenu::VoltageOutMenu(QWidget *parent, QString chnlFunction, Connection connect(dacCode, &IIOWidget::sendData, this, &VoltageOutMenu::updateCnvtLabel); // slew - output channel - IIOWidget *slewOptions = IIOWidgetBuilder() + IIOWidget *slewOptions = IIOWidgetBuilder(this) .connection(const_cast(m_connection)) .channel(const_cast(m_chnls[OUTPUT_CHNL])) .attribute("slew_en") .optionsValues("0 1") - .parent(this) .buildSingle(); addMenuWidget(slewOptions); // slew step - output channel - IIOWidget *slewStep = IIOWidgetBuilder() + IIOWidget *slewStep = IIOWidgetBuilder(this) .connection(const_cast(m_connection)) .channel(const_cast(m_chnls[OUTPUT_CHNL])) .attribute("slew_step") .optionsAttribute("slew_step_available") .uiStrategy(IIOWidgetBuilder::UIS::ComboUi) - .parent(this) .buildSingle(); addMenuWidget(slewStep); // slew rate - output channel - IIOWidget *slewRate = IIOWidgetBuilder() + IIOWidget *slewRate = IIOWidgetBuilder(this) .connection(const_cast(m_connection)) .channel(const_cast(m_chnls[OUTPUT_CHNL])) .attribute("slew_rate") .optionsAttribute("slew_rate_available") .uiStrategy(IIOWidgetBuilder::UIS::ComboUi) - .parent(this) .buildSingle(); addMenuWidget(slewRate); } @@ -290,12 +282,11 @@ CurrentOutMenu::CurrentOutMenu(QWidget *parent, QString chnlFunction, Connection : BufferMenu(parent, chnlFunction, conn, chnls) { // dac code - output channel - IIOWidget *dacCode = IIOWidgetBuilder() + IIOWidget *dacCode = IIOWidgetBuilder(this) .connection(const_cast(m_connection)) .channel(const_cast(m_chnls[OUTPUT_CHNL])) .attribute("raw") .optionsValues("[0 1 8191]") - .parent(this) .buildSingle(); dacCode->changeTitle("DAC_CODE"); addMenuWidget(dacCode); @@ -314,34 +305,31 @@ CurrentOutMenu::CurrentOutMenu(QWidget *parent, QString chnlFunction, Connection connect(dacCode, &IIOWidget::sendData, this, &CurrentOutMenu::updateCnvtLabel); // slew - output channel - IIOWidget *slewOptions = IIOWidgetBuilder() + IIOWidget *slewOptions = IIOWidgetBuilder(this) .connection(const_cast(m_connection)) .channel(const_cast(m_chnls[OUTPUT_CHNL])) .attribute("slew_en") .optionsValues("0 1") - .parent(this) .buildSingle(); addMenuWidget(slewOptions); // slew step - output channel - IIOWidget *slewStep = IIOWidgetBuilder() + IIOWidget *slewStep = IIOWidgetBuilder(this) .connection(const_cast(m_connection)) .channel(const_cast(m_chnls[OUTPUT_CHNL])) .attribute("slew_step") .optionsAttribute("slew_step_available") .uiStrategy(IIOWidgetBuilder::UIS::ComboUi) - .parent(this) .buildSingle(); addMenuWidget(slewStep); // slew rate - output channel - IIOWidget *slewRate = IIOWidgetBuilder() + IIOWidget *slewRate = IIOWidgetBuilder(this) .connection(const_cast(m_connection)) .channel(const_cast(m_chnls[OUTPUT_CHNL])) .attribute("slew_rate") .optionsAttribute("slew_rate_available") .uiStrategy(IIOWidgetBuilder::UIS::ComboUi) - .parent(this) .buildSingle(); addMenuWidget(slewRate); } @@ -368,13 +356,12 @@ DiagnosticMenu::DiagnosticMenu(QWidget *parent, QString chnlFunction, Connection : BufferMenu(parent, chnlFunction, conn, chnls) { // diag options - input channel - IIOWidget *diagOptions = IIOWidgetBuilder() + IIOWidget *diagOptions = IIOWidgetBuilder(this) .connection(const_cast(m_connection)) .channel(const_cast(m_chnls[INPUT_CHNL])) .attribute("diag_function") .optionsAttribute("diag_function_available") .uiStrategy(IIOWidgetBuilder::UIS::ComboUi) - .parent(this) .buildSingle(); addMenuWidget(diagOptions); @@ -412,12 +399,11 @@ DigitalInMenu::DigitalInMenu(QWidget *parent, QString chnlFunction, Connection * : BufferMenu(parent, chnlFunction, conn, chnls) { // threshold - input channel - m_threshold = IIOWidgetBuilder() + m_threshold = IIOWidgetBuilder(this) .connection(const_cast(m_connection)) .channel(const_cast(m_chnls[INPUT_CHNL])) .attribute("threshold") .optionsValues("[0 1 16000]") - .parent(this) .buildSingle(); addMenuWidget(m_threshold); connect(m_threshold, &IIOWidget::emitData, this, &BufferMenu::thresholdChangeStart); diff --git a/tmp/grutil/src/grdeviceaddon.cpp b/tmp/grutil/src/grdeviceaddon.cpp index 3b4af9383b..6095871085 100644 --- a/tmp/grutil/src/grdeviceaddon.cpp +++ b/tmp/grutil/src/grdeviceaddon.cpp @@ -27,15 +27,14 @@ QWidget *GRDeviceAddon::createAttrMenu(QWidget *parent) MenuSectionWidget *attrContainer = new MenuSectionWidget(parent); MenuCollapseSection *attr = new MenuCollapseSection("ATTRIBUTES", MenuCollapseSection::MHCW_NONE, attrContainer); - QList attrWidgets = IIOWidgetBuilder().device(m_src->iioDev()).parent(parent).buildAll(); + QList attrWidgets = IIOWidgetBuilder(parent).device(m_src->iioDev()).buildAll(); const struct iio_context *ctx = iio_device_get_context(m_src->iioDev()); - attrWidgets.append(IIOWidgetBuilder() + attrWidgets.append(IIOWidgetBuilder(parent) .context(const_cast(ctx)) .device(m_src->iioDev()) .attribute("Triggers") .uiStrategy(IIOWidgetBuilder::UIS::ComboUi) .dataStrategy(IIOWidgetBuilder::DS::TriggerData) - .parent(parent) .buildSingle()); auto layout = new QVBoxLayout(); diff --git a/tmp/grutil/src/grtimechanneladdon.cpp b/tmp/grutil/src/grtimechanneladdon.cpp index 20ae393313..f4bcc39424 100644 --- a/tmp/grutil/src/grtimechanneladdon.cpp +++ b/tmp/grutil/src/grtimechanneladdon.cpp @@ -193,7 +193,7 @@ QWidget *GRTimeChannelAddon::createAttrMenu(QWidget *parent) MenuSectionWidget *attrcontainer = new MenuSectionWidget(parent); MenuCollapseSection *attr = new MenuCollapseSection("ATTRIBUTES", MenuCollapseSection::MHCW_NONE, attrcontainer); - QList attrWidgets = IIOWidgetBuilder().channel(grch()->channel()).parent(parent).buildAll(); + QList attrWidgets = IIOWidgetBuilder(parent).channel(grch()->channel()).buildAll(); auto layout = new QVBoxLayout(); layout->setSpacing(10);