mirror of
				https://github.com/f4exb/sdrangel.git
				synced 2025-10-31 13:00:26 -04:00 
			
		
		
		
	Device user arguments: implemented non discoverable devices specification in GUI
This commit is contained in:
		
							parent
							
								
									4abeefff82
								
							
						
					
					
						commit
						8d2f65f967
					
				| @ -22,13 +22,13 @@ | ||||
| 
 | ||||
| QDataStream &operator<<(QDataStream &ds, const DeviceUserArgs::Args &inObj) | ||||
| { | ||||
| 	ds << inObj.m_id << inObj.m_sequence << inObj.m_args; | ||||
| 	ds << inObj.m_id << inObj.m_sequence << inObj.m_args << inObj.m_nonDiscoverable; | ||||
|     return ds; | ||||
| } | ||||
| 
 | ||||
| QDataStream &operator>>(QDataStream &ds, DeviceUserArgs::Args &outObj) | ||||
| { | ||||
| 	ds >> outObj.m_id >> outObj.m_sequence >> outObj.m_args; | ||||
| 	ds >> outObj.m_id >> outObj.m_sequence >> outObj.m_args >> outObj.m_nonDiscoverable; | ||||
|     return ds; | ||||
| } | ||||
| 
 | ||||
| @ -78,7 +78,7 @@ QString DeviceUserArgs::findUserArgs(const QString& id, int sequence) | ||||
|     return ""; | ||||
| } | ||||
| 
 | ||||
| void DeviceUserArgs::addDeviceArgs(const QString& id, int sequence, const QString& deviceArgs) | ||||
| void DeviceUserArgs::addDeviceArgs(const QString& id, int sequence, const QString& deviceArgs, bool nonDiscoverable) | ||||
| { | ||||
|     int i = 0; | ||||
| 
 | ||||
| @ -90,11 +90,11 @@ void DeviceUserArgs::addDeviceArgs(const QString& id, int sequence, const QStrin | ||||
|     } | ||||
| 
 | ||||
|     if (i == m_argsByDevice.size()) { | ||||
|         m_argsByDevice.push_back(Args(id, sequence, deviceArgs)); | ||||
|         m_argsByDevice.push_back(Args(id, sequence, deviceArgs, nonDiscoverable)); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void DeviceUserArgs::addOrUpdateDeviceArgs(const QString& id, int sequence, const QString& deviceArgs) | ||||
| void DeviceUserArgs::addOrUpdateDeviceArgs(const QString& id, int sequence, const QString& deviceArgs, bool nonDiscoverable) | ||||
| { | ||||
|     int i = 0; | ||||
| 
 | ||||
| @ -106,18 +106,20 @@ void DeviceUserArgs::addOrUpdateDeviceArgs(const QString& id, int sequence, cons | ||||
|     } | ||||
| 
 | ||||
|     if (i == m_argsByDevice.size()) { | ||||
|         m_argsByDevice.push_back(Args(id, sequence, deviceArgs)); | ||||
|         m_argsByDevice.push_back(Args(id, sequence, deviceArgs, nonDiscoverable)); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void DeviceUserArgs::updateDeviceArgs(const QString& id, int sequence, const QString& deviceArgs) | ||||
| void DeviceUserArgs::updateDeviceArgs(const QString& id, int sequence, const QString& deviceArgs, bool nonDiscoverable) | ||||
| { | ||||
|     int i = 0; | ||||
| 
 | ||||
|     for (; i < m_argsByDevice.size(); i++) | ||||
|     { | ||||
|         if ((m_argsByDevice.at(i).m_id == id) && (m_argsByDevice.at(i).m_sequence == sequence)) { | ||||
|         if ((m_argsByDevice.at(i).m_id == id) && (m_argsByDevice.at(i).m_sequence == sequence)) | ||||
|         { | ||||
|             m_argsByDevice[i].m_args = deviceArgs; | ||||
|             m_argsByDevice[i].m_nonDiscoverable = nonDiscoverable; | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -31,17 +31,20 @@ public: | ||||
|         QString m_id; | ||||
|         int m_sequence; | ||||
|         QString m_args; | ||||
|         bool m_nonDiscoverable; | ||||
| 
 | ||||
|         Args() : | ||||
|             m_id(""), | ||||
|             m_sequence(0), | ||||
|             m_args("") | ||||
|             m_args(""), | ||||
|             m_nonDiscoverable(false) | ||||
|         {} | ||||
| 
 | ||||
|         Args(const QString id, int sequence, const QString& args) : | ||||
|         Args(const QString id, int sequence, const QString& args, bool nonDiscoverable) : | ||||
|             m_id(id), | ||||
|             m_sequence(sequence), | ||||
|             m_args(args) | ||||
|             m_args(args), | ||||
|             m_nonDiscoverable(nonDiscoverable) | ||||
|         {} | ||||
| 
 | ||||
|         friend QDataStream &operator << (QDataStream &ds, const Args &inObj); | ||||
| @ -51,9 +54,9 @@ public: | ||||
| 	QByteArray serialize() const; | ||||
| 	bool deserialize(const QByteArray& data); | ||||
|     QString findUserArgs(const QString& id, int sequence); | ||||
|     void addDeviceArgs(const QString& id, int sequence, const QString& args);         //!< Will not add if it exists for same reference
 | ||||
|     void addOrUpdateDeviceArgs(const QString& id, int sequence, const QString& args); //!< Add or update if it exists for same reference
 | ||||
|     void updateDeviceArgs(const QString& id, int sequence, const QString& args);      //!< Will not update if reference does not exist
 | ||||
|     void addDeviceArgs(const QString& id, int sequence, const QString& args, bool nonDiscoverable);         //!< Will not add if it exists for same reference
 | ||||
|     void addOrUpdateDeviceArgs(const QString& id, int sequence, const QString& args, bool nonDiscoverable); //!< Add or update if it exists for same reference
 | ||||
|     void updateDeviceArgs(const QString& id, int sequence, const QString& args, bool nonDiscoverable);      //!< Will not update if reference does not exist
 | ||||
|     void deleteDeviceArgs(const QString& id, int sequence); | ||||
|     const QList<Args>& getArgsByDevice() const { return m_argsByDevice; } | ||||
| 
 | ||||
|  | ||||
| @ -28,7 +28,8 @@ DeviceUserArgsDialog::DeviceUserArgsDialog( | ||||
| 	ui(new Ui::DeviceUserArgsDialog), | ||||
| 	m_deviceEnumerator(deviceEnumerator), | ||||
| 	m_hardwareDeviceUserArgs(hardwareDeviceUserArgs), | ||||
|     m_deviceUserArgsCopy(hardwareDeviceUserArgs) | ||||
|     m_deviceUserArgsCopy(hardwareDeviceUserArgs), | ||||
|     m_xDeviceSequence(0) | ||||
| { | ||||
| 	ui->setupUi(this); | ||||
| 
 | ||||
| @ -57,6 +58,9 @@ DeviceUserArgsDialog::DeviceUserArgsDialog( | ||||
|     ui->deviceTree->resizeColumnToContents(2); | ||||
| 
 | ||||
|     displayArgsByDevice(); | ||||
| 
 | ||||
|     ui->addDeviceHwIDEdit->setText(m_xDeviceHardwareId); | ||||
|     ui->addDeviceSeqEdit->setText(tr("%1").arg(m_xDeviceSequence)); | ||||
| } | ||||
| 
 | ||||
| DeviceUserArgsDialog::~DeviceUserArgsDialog() | ||||
| @ -75,14 +79,16 @@ void DeviceUserArgsDialog::displayArgsByDevice() | ||||
|     for (; it != m_deviceUserArgsCopy.getArgsByDevice().end(); ++it) | ||||
| 	{ | ||||
| 		QTreeWidgetItem *treeItem = new QTreeWidgetItem(ui->argsTree); | ||||
| 		treeItem->setText(0, it->m_id); | ||||
| 		treeItem->setText(1, tr("%1").arg(it->m_sequence)); | ||||
| 		treeItem->setText(2, it->m_args); | ||||
|         treeItem->setText(0, it->m_nonDiscoverable ? "ND" : "  "); | ||||
| 		treeItem->setText(1, it->m_id); | ||||
| 		treeItem->setText(2, tr("%1").arg(it->m_sequence)); | ||||
| 		treeItem->setText(3, it->m_args); | ||||
| 	} | ||||
| 
 | ||||
|     ui->argsTree->resizeColumnToContents(0); | ||||
|     ui->argsTree->resizeColumnToContents(1); | ||||
|     ui->argsTree->resizeColumnToContents(2); | ||||
|     ui->argsTree->resizeColumnToContents(3); | ||||
| 	ui->argsTree->blockSignals(false); | ||||
| } | ||||
| 
 | ||||
| @ -128,7 +134,7 @@ void DeviceUserArgsDialog::on_importDevice_clicked(bool checked) | ||||
|     { | ||||
|         bool ok; | ||||
|         int sequence = deviceItem->text(1).toInt(&ok); | ||||
|         m_deviceUserArgsCopy.addDeviceArgs(deviceItem->text(0), sequence, ""); | ||||
|         m_deviceUserArgsCopy.addDeviceArgs(deviceItem->text(0), sequence, "", false); | ||||
|         displayArgsByDevice(); | ||||
|     } | ||||
| } | ||||
| @ -141,8 +147,8 @@ void DeviceUserArgsDialog::on_deleteArgs_clicked(bool checked) | ||||
|     if (deviceItem) | ||||
|     { | ||||
|         bool ok; | ||||
|         int sequence = deviceItem->text(1).toInt(&ok); | ||||
|         m_deviceUserArgsCopy.deleteDeviceArgs(deviceItem->text(0), sequence); | ||||
|         int sequence = deviceItem->text(2).toInt(&ok); | ||||
|         m_deviceUserArgsCopy.deleteDeviceArgs(deviceItem->text(1), sequence); | ||||
|         displayArgsByDevice(); | ||||
|     } | ||||
| } | ||||
| @ -150,7 +156,7 @@ void DeviceUserArgsDialog::on_deleteArgs_clicked(bool checked) | ||||
| void DeviceUserArgsDialog::on_argsTree_currentItemChanged(QTreeWidgetItem* currentItem, QTreeWidgetItem* previousItem) | ||||
| { | ||||
| 	(void) previousItem; | ||||
| 	ui->argStringEdit->setText(currentItem->text(2)); | ||||
| 	ui->argStringEdit->setText(currentItem->text(3)); | ||||
| } | ||||
| 
 | ||||
| void DeviceUserArgsDialog::on_argStringEdit_editingFinished() | ||||
| @ -160,8 +166,30 @@ void DeviceUserArgsDialog::on_argStringEdit_editingFinished() | ||||
|     if (deviceItem) | ||||
|     { | ||||
|         bool ok; | ||||
|         int sequence = deviceItem->text(1).toInt(&ok); | ||||
|         m_deviceUserArgsCopy.updateDeviceArgs(deviceItem->text(0), sequence, ui->argStringEdit->text()); | ||||
|         int sequence = deviceItem->text(2).toInt(&ok); | ||||
|         bool nonDiscoverable = deviceItem->text(0) == "ND"; | ||||
|         m_deviceUserArgsCopy.updateDeviceArgs(deviceItem->text(1), sequence, ui->argStringEdit->text(), nonDiscoverable); | ||||
|         displayArgsByDevice(); | ||||
|     } | ||||
| } | ||||
| } | ||||
| 
 | ||||
| void DeviceUserArgsDialog::on_addDeviceHwIDEdit_editingFinished() | ||||
| { | ||||
|     m_xDeviceHardwareId = ui->addDeviceHwIDEdit->text(); | ||||
| } | ||||
| 
 | ||||
| void DeviceUserArgsDialog::on_addDeviceSeqEdit_editingFinished() | ||||
| { | ||||
|     bool ok; | ||||
|     int sequence = ui->addDeviceSeqEdit->text().toInt(&ok); | ||||
| 
 | ||||
|     if (ok) { | ||||
|         m_xDeviceSequence = sequence; | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void DeviceUserArgsDialog::on_addDevice_clicked(bool checked) | ||||
| { | ||||
|     m_deviceUserArgsCopy.addDeviceArgs(m_xDeviceHardwareId, m_xDeviceSequence, "", true); | ||||
|     displayArgsByDevice(); | ||||
| } | ||||
|  | ||||
| @ -58,6 +58,8 @@ private: | ||||
|     DeviceUserArgs& m_hardwareDeviceUserArgs; | ||||
|     std::vector<HWDeviceReference> m_availableHWDevices; | ||||
|     DeviceUserArgs m_deviceUserArgsCopy; | ||||
|     QString m_xDeviceHardwareId; | ||||
|     unsigned int m_xDeviceSequence; | ||||
| 
 | ||||
|     void pushHWDeviceReference(const PluginInterface::SamplingDevice *samplingDevice); | ||||
|     void displayArgsByDevice(); | ||||
| @ -69,6 +71,9 @@ private slots: | ||||
|     void on_deleteArgs_clicked(bool checked); | ||||
|     void on_argsTree_currentItemChanged(QTreeWidgetItem* currentItem, QTreeWidgetItem* previousItem); | ||||
|     void on_argStringEdit_editingFinished(); | ||||
|     void on_addDeviceHwIDEdit_editingFinished(); | ||||
|     void on_addDeviceSeqEdit_editingFinished(); | ||||
|     void on_addDevice_clicked(bool checked); | ||||
| }; | ||||
| 
 | ||||
| #endif // SDRGUI_GUI_DEVICEUSERARGSDIALOG_H
 | ||||
| @ -118,6 +118,76 @@ | ||||
|         </property> | ||||
|        </widget> | ||||
|       </item> | ||||
|       <item> | ||||
|        <spacer name="horizontalSpacer"> | ||||
|         <property name="orientation"> | ||||
|          <enum>Qt::Horizontal</enum> | ||||
|         </property> | ||||
|         <property name="sizeHint" stdset="0"> | ||||
|          <size> | ||||
|           <width>40</width> | ||||
|           <height>20</height> | ||||
|          </size> | ||||
|         </property> | ||||
|        </spacer> | ||||
|       </item> | ||||
|       <item> | ||||
|        <widget class="QLabel" name="addDeviceHwIDLabel"> | ||||
|         <property name="text"> | ||||
|          <string>HwID</string> | ||||
|         </property> | ||||
|        </widget> | ||||
|       </item> | ||||
|       <item> | ||||
|        <widget class="QLineEdit" name="addDeviceHwIDEdit"> | ||||
|         <property name="toolTip"> | ||||
|          <string>Hardware Id of non discoverable device</string> | ||||
|         </property> | ||||
|        </widget> | ||||
|       </item> | ||||
|       <item> | ||||
|        <widget class="QLabel" name="addDeviceSeqLabel"> | ||||
|         <property name="text"> | ||||
|          <string>Seq</string> | ||||
|         </property> | ||||
|        </widget> | ||||
|       </item> | ||||
|       <item> | ||||
|        <widget class="QLineEdit" name="addDeviceSeqEdit"> | ||||
|         <property name="maximumSize"> | ||||
|          <size> | ||||
|           <width>30</width> | ||||
|           <height>16777215</height> | ||||
|          </size> | ||||
|         </property> | ||||
|         <property name="toolTip"> | ||||
|          <string>Sequence of non discoverable device</string> | ||||
|         </property> | ||||
|         <property name="inputMask"> | ||||
|          <string>00</string> | ||||
|         </property> | ||||
|        </widget> | ||||
|       </item> | ||||
|       <item> | ||||
|        <widget class="QPushButton" name="addDevice"> | ||||
|         <property name="maximumSize"> | ||||
|          <size> | ||||
|           <width>24</width> | ||||
|           <height>16777215</height> | ||||
|          </size> | ||||
|         </property> | ||||
|         <property name="toolTip"> | ||||
|          <string>Add non discoverable device </string> | ||||
|         </property> | ||||
|         <property name="text"> | ||||
|          <string/> | ||||
|         </property> | ||||
|         <property name="icon"> | ||||
|          <iconset resource="../resources/res.qrc"> | ||||
|           <normaloff>:/plusw.png</normaloff>:/plusw.png</iconset> | ||||
|         </property> | ||||
|        </widget> | ||||
|       </item> | ||||
|      </layout> | ||||
|     </widget> | ||||
|     <widget class="QWidget" name="horizontalLayoutWidget_5"> | ||||
| @ -184,20 +254,37 @@ | ||||
|      <property name="toolTip"> | ||||
|       <string>List of hardware with user arguments</string> | ||||
|      </property> | ||||
|      <column> | ||||
|       <property name="text"> | ||||
|        <string>ND</string> | ||||
|       </property> | ||||
|       <property name="toolTip"> | ||||
|        <string>Non discoverable</string> | ||||
|       </property> | ||||
|      </column> | ||||
|      <column> | ||||
|       <property name="text"> | ||||
|        <string>HwID</string> | ||||
|       </property> | ||||
|       <property name="toolTip"> | ||||
|        <string>Hardware ID</string> | ||||
|       </property> | ||||
|      </column> | ||||
|      <column> | ||||
|       <property name="text"> | ||||
|        <string>Seq</string> | ||||
|       </property> | ||||
|       <property name="toolTip"> | ||||
|        <string>Sequence</string> | ||||
|       </property> | ||||
|      </column> | ||||
|      <column> | ||||
|       <property name="text"> | ||||
|        <string>Arg string</string> | ||||
|       </property> | ||||
|       <property name="toolTip"> | ||||
|        <string>Argument string</string> | ||||
|       </property> | ||||
|      </column> | ||||
|     </widget> | ||||
|    </widget> | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user