Browse Source

Fix settings save and restore

Neal Wilson 10 years ago
parent
commit
dfb8820c59
1 changed files with 37 additions and 7 deletions
  1. 37
    7
      src/unsupportedserial.w

+ 37
- 7
src/unsupportedserial.w View File

100
 				data.chop(2);
100
 				data.chop(2);
101
 				data = data.remove(0, 2);
101
 				data = data.remove(0, 2);
102
 			}
102
 			}
103
-			QStringList keyList = data.split(",");
103
+			QStringList keyList = data.split(", ");
104
 			for(int j = 0; j < keyList.size(); j++)
104
 			for(int j = 0; j < keyList.size(); j++)
105
 			{
105
 			{
106
 				deviceSettingsModel->setData(deviceSettingsModel->index(j, column),
106
 				deviceSettingsModel->setData(deviceSettingsModel->index(j, column),
107
 				                             QVariant(keyList.at(j)),
107
 				                             QVariant(keyList.at(j)),
108
-				                             Qt::DisplayRole);
108
+				                             Qt::EditRole);
109
 			}
109
 			}
110
 		}
110
 		}
111
 		else if(node.attribute("name") == "script")
111
 		else if(node.attribute("name") == "script")
114
 		}
114
 		}
115
 	}
115
 	}
116
 	
116
 	
117
-	connect(deviceSettingsModel, SIGNAL(dataChanged()),
117
+	connect(deviceSettingsModel, SIGNAL(dataChanged(QModelIndex, QModelIndex)),
118
 	        this, SLOT(updateConfiguration()));
118
 	        this, SLOT(updateConfiguration()));
119
 	connect(scriptEditor, SIGNAL(textChanged()), this, SLOT(saveScript()));
119
 	connect(scriptEditor, SIGNAL(textChanged()), this, SLOT(saveScript()));
120
 	setLayout(dummyLayout);
120
 	setLayout(dummyLayout);
132
 void UnsupportedSerialDeviceConfWidget::updateConfiguration()
132
 void UnsupportedSerialDeviceConfWidget::updateConfiguration()
133
 {
133
 {
134
 	updateAttribute("keys", deviceSettingsModel->arrayLiteral(0, Qt::DisplayRole));
134
 	updateAttribute("keys", deviceSettingsModel->arrayLiteral(0, Qt::DisplayRole));
135
-	updateAttribute("values", deviceSettingsModel->arrayLiteral(0, Qt::DisplayRole));
135
+	updateAttribute("values", deviceSettingsModel->arrayLiteral(1, Qt::DisplayRole));
136
 }
136
 }
137
 
137
 
138
 @ Every time the script text is changed, the new version of the script is
138
 @ Every time the script text is changed, the new version of the script is
200
 	@<Get device configuration data for current node@>@;
200
 	@<Get device configuration data for current node@>@;
201
 	for(int i = 0; i < configData.size(); i++)
201
 	for(int i = 0; i < configData.size(); i++)
202
 	{
202
 	{
203
-	
203
+		node = configData.at(i).toElement();
204
+		if(node.attribute("name") == "columnname")
205
+		{
206
+			columnName->setText(node.attribute("value"));
207
+		}
208
+		else if(node.attribute("name") == "hidden")
209
+		{
210
+			hideSeries->setChecked(node.attribute("value") == "true");
211
+		}
212
+		else if(node.attribute("name") == "keys" || node.attribute("name") == "values")
213
+		{
214
+			int column = 0;
215
+			if(node.attribute("name") == "values")
216
+			{
217
+				column = 1;
218
+			}
219
+			QString data = node.attribute("value");
220
+			if(data.length() > 3)
221
+			{
222
+				data.chop(2);
223
+				data = data.remove(0, 2);
224
+			}
225
+			QStringList keyList = data.split(", ");
226
+			for(int j = 0; j < keyList.size(); j++)
227
+			{
228
+				channelSettingsModel->setData(channelSettingsModel->index(j, column),
229
+				                              QVariant(keyList.at(j)),
230
+				                              Qt::EditRole);
231
+			}
232
+		}
204
 	}
233
 	}
205
 	connect(columnName, SIGNAL(textEdited(QString)), this, SLOT(updateColumnName(QString)));
234
 	connect(columnName, SIGNAL(textEdited(QString)), this, SLOT(updateColumnName(QString)));
206
 	connect(hideSeries, SIGNAL(toggled(bool)), this, SLOT(updateHidden(bool)));
235
 	connect(hideSeries, SIGNAL(toggled(bool)), this, SLOT(updateHidden(bool)));
207
-	connect(channelSettingsModel, SIGNAL(dataChanged()), this, SLOT(updateConfiguration()));
236
+	connect(channelSettingsModel, SIGNAL(dataChanged(QModelIndex, QModelIndex)),
237
+	        this, SLOT(updateConfiguration()));
208
 }
238
 }
209
 
239
 
210
 @ Arbitrary channel configuration data is handled in the same way as device
240
 @ Arbitrary channel configuration data is handled in the same way as device
225
 void UnsupportedDeviceChannelConfWidget::updateConfiguration()
255
 void UnsupportedDeviceChannelConfWidget::updateConfiguration()
226
 {
256
 {
227
 	updateAttribute("keys", channelSettingsModel->arrayLiteral(0, Qt::DisplayRole));
257
 	updateAttribute("keys", channelSettingsModel->arrayLiteral(0, Qt::DisplayRole));
228
-	updateAttribute("values", channelSettingsModel->arrayLiteral(0, Qt::DisplayRole));
258
+	updateAttribute("values", channelSettingsModel->arrayLiteral(1, Qt::DisplayRole));
229
 }
259
 }
230
 
260
 
231
 @ The configuration widgets need to be registered so they can be instantiated
261
 @ The configuration widgets need to be registered so they can be instantiated

Loading…
Cancel
Save