49 buttonList.insert(save, save_button);
50 buttonList.insert(apply, apply_button);
51 connect(save, SIGNAL(clicked()),
this, SLOT(processClick()));
52 connect(apply, SIGNAL(clicked()),
this, SLOT(processClick()));
63 buttonList.insert(apply, apply_button);
64 connect(apply, SIGNAL(clicked()),
this, SLOT(processClick()));
75 buttonList.insert(save, save_button);
76 connect(save, SIGNAL(clicked()),
this, SLOT(processClick()));
82 void smartSaveButton::processClick()
86 QPushButton *button = qobject_cast<QPushButton *>(sender());
89 if (buttonList.value(button) == save_button)
91 processOperation(button, save);
101 void smartSaveButton::processOperation(QPushButton *button,
bool save)
104 QStringList failedUploads;
105 QStringList failedSaves;
106 QStringList missingObjects;
108 button->setEnabled(
false);
109 button->setIcon(QIcon(
":/uploader/images/system-run.svg"));
112 timer.setSingleShot(
true);
117 if (mandatoryList.value(obj,
true))
118 missingObjects.append(obj->
getName());
123 if (mandatoryList.value(obj,
true))
124 failedUploads.append(obj->
getName());
127 upload_result =
false;
128 current_object = obj;
132 qDebug() <<
"[smartsavebutton.cpp] Error, tried to apply/save a non-settings object: "
137 qDebug() <<
"[smartsavebutton.cpp] Sending object to remote end - " << obj->
getName();
138 connect(obj, SIGNAL(transactionCompleted(
UAVObject *,
bool)),
this,
139 SLOT(transaction_finished(
UAVObject *,
bool)));
140 connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit()));
158 if (!timer.isActive())
159 qInfo() <<
"[smartsavebutton.cpp] Upload timeout for object" << obj->
getName();
161 disconnect(obj, SIGNAL(transactionCompleted(
UAVObject *,
bool)),
this,
162 SLOT(transaction_finished(
UAVObject *,
bool)));
163 disconnect(&timer, SIGNAL(timeout()), &loop, SLOT(quit()));
165 if (upload_result ==
false) {
166 qInfo() <<
"[smartsavebutton.cpp] Object upload error:" << obj->
getName();
167 if (mandatoryList.value(obj,
true))
168 failedUploads.append(obj->
getName());
177 qDebug() <<
"[smartsavebutton.cpp] Save request for object" << obj->
getName();
178 connect(utilMngr, SIGNAL(saveCompleted(
int,
bool)),
this,
179 SLOT(saving_finished(
int,
bool)));
180 connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit()));
198 if (!timer.isActive())
199 qInfo() <<
"[smartsavebutton.cpp] Saving timeout for object" << obj->
getName();
201 disconnect(utilMngr, SIGNAL(saveCompleted(
int,
bool)),
this,
202 SLOT(saving_finished(
int,
bool)));
203 disconnect(&timer, SIGNAL(timeout()), &loop, SLOT(quit()));
205 if (save_result ==
false) {
206 qInfo() <<
"[smartsavebutton.cpp] failed to save:" << obj->
getName();
207 if (mandatoryList.value(obj,
true))
208 failedSaves.append(obj->
getName());
213 button->setEnabled(
true);
216 if (failedSaves.isEmpty() && failedUploads.isEmpty() && missingObjects.isEmpty()) {
217 result =
"All operations finished successfully";
220 if (!failedSaves.isEmpty()) {
221 result.append(
"Objects not saved:\n");
222 foreach (QString str, failedSaves) {
223 result.append(str +
"\n");
226 if (!failedUploads.isEmpty()) {
227 if (!result.isEmpty())
229 result.append(
"Objects not uploaded:\n");
230 foreach (QString str, failedUploads) {
231 result.append(str +
"\n");
234 if (!missingObjects.isEmpty()) {
235 if (!result.isEmpty())
237 result.append(
"Objects not present on the hardware:\n");
238 foreach (QString str, missingObjects) {
239 result.append(str +
"\n");
243 qDebug() <<
"RESULT" << result << missingObjects << failedSaves << failedUploads;
245 button->setToolTip(result);
248 button->setIcon(QIcon(
":/uploader/images/dialog-apply.svg"));
252 if (!failedSaves.isEmpty() || !failedUploads.isEmpty())
253 button->setIcon(QIcon(
":/uploader/images/process-stop.svg"));
255 button->setIcon(QIcon(
":/uploader/images/warning.svg"));
280 if (!objects.contains(obj))
295 if (!objects.contains(obj))
298 mandatoryList.insert(obj,
false);
309 if (objects.contains(obj))
310 objects.removeAll(obj);
327 void smartSaveButton::transaction_finished(
UAVObject *obj,
bool result)
329 if (current_object == obj) {
330 upload_result = result;
335 void smartSaveButton::saving_finished(
int id,
bool result)
340 if ((quint32)
id == current_objectID) {
341 save_result = result;
348 foreach (QPushButton *button, buttonList.keys())
349 button->setEnabled(value);
354 foreach (QPushButton *button, buttonList.keys()) {
355 button->setToolTip(
"");
356 button->setIcon(QIcon());
366 mandatoryList.insert(obj,
false);
371 processOperation(NULL,
false);
376 processOperation(NULL,
true);
Core plugin system that manages the plugins, their life cycle and their registered objects...
void saveObjectToFlash(UAVObject *obj)
UAVObjectUtilManager::saveObjectToSD Add a new object to save in the queue.
bool getIsPresentOnHardware() const
else error('Your technical computing program does not support file choosers.Please input the file name in the argument. ') end elseif nargin >0 logfile
save(matfile $(SAVEOBJECTSCODE))
static AccessMode GetGcsAccess(const Metadata &meta)