Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
ElmerCSC
GitHub Repository: ElmerCSC/elmerfem
Path: blob/devel/ElmerGUI/Application/src/dynamiceditor.cpp
3203 views
1
/*****************************************************************************
2
* *
3
* Elmer, A Finite Element Software for Multiphysical Problems *
4
* *
5
* Copyright 1st April 1995 - , CSC - IT Center for Science Ltd., Finland *
6
* *
7
* This program is free software; you can redistribute it and/or *
8
* modify it under the terms of the GNU General Public License *
9
* as published by the Free Software Foundation; either version 2 *
10
* of the License, or (at your option) any later version. *
11
* *
12
* This program is distributed in the hope that it will be useful, *
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15
* GNU General Public License for more details. *
16
* *
17
* You should have received a copy of the GNU General Public License *
18
* along with this program (in file fem/GPL-2); if not, write to the *
19
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, *
20
* Boston, MA 02110-1301, USA. *
21
* *
22
*****************************************************************************/
23
24
/*****************************************************************************
25
* *
26
* ElmerGUI dynamiceditor *
27
* *
28
*****************************************************************************
29
* *
30
* Authors: Mikko Lyly, Juha Ruokolainen and Peter R�back *
31
* Email: [email protected] *
32
* Web: http://www.csc.fi/elmer *
33
* Address: CSC - IT Center for Science Ltd. *
34
* Keilaranta 14 *
35
* 02101 Espoo, Finland *
36
* *
37
* Original Date: 15 Mar 2008 *
38
* *
39
*****************************************************************************/
40
41
#include <QtGui>
42
#include <iostream>
43
#include "dynamiceditor.h"
44
45
using namespace std;
46
47
DynLineEdit::DynLineEdit(QWidget *parent) : QWidget(parent)
48
{
49
name = "";
50
label = NULL;
51
frame = NULL;
52
layout = NULL;
53
textEdit = NULL;
54
closeButton = NULL;
55
lineEdit = new QLineEdit;
56
}
57
58
DynLineEdit::~DynLineEdit()
59
{
60
}
61
62
DynamicEditor::DynamicEditor(QWidget *parent)
63
: QWidget(parent)
64
{
65
newIcon = QIcon::fromTheme("document-new");
66
addIcon = QIcon::fromTheme("list-add");
67
okIcon = QIcon::fromTheme("dialog-accept");
68
removeIcon = QIcon::fromTheme("dialog-error-round");
69
setWindowFlags(Qt::Window);
70
71
menuAction = NULL;
72
ID = -1;
73
touched = false;
74
75
setWindowIcon(QIcon(":/icons/Mesh3D.png"));
76
}
77
78
//----------------------------------------------------------------------------
79
DynamicEditor::~DynamicEditor()
80
{
81
}
82
83
//----------------------------------------------------------------------------
84
void DynamicEditor::setupTabs(QDomDocument *elmerDefs, const QString &Section, int ID)
85
{
86
// Clear:
87
//-------
88
this->ID = ID;
89
90
hash.clear();
91
92
QLayout *layout = this->layout();
93
if(layout != NULL) {
94
QLayoutItem *item;
95
while((item = layout->takeAt(0)) != 0)
96
delete item;
97
if(tabWidget != NULL) {
98
tabWidget->clear();
99
delete tabWidget;
100
}
101
delete layout;
102
}
103
104
// Get root element of elmerDefs:
105
//-------------------------------
106
root = elmerDefs->documentElement();
107
108
tabWidget = new QTabWidget;
109
//tabWidget->setTabShape(QTabWidget::Triangular);
110
tabWidget->setUsesScrollButtons(true);
111
tabWidget->setElideMode(Qt::ElideNone);
112
all_stuff = root.firstChildElement("ALL");
113
element = root.firstChildElement("PDE");
114
115
tabs = 0;
116
117
while(!element.isNull()) {
118
119
name = element.firstChildElement("Name");
120
121
QGridLayout *grid = new QGridLayout;
122
123
int params = 0;
124
125
for( int iter=0; iter<2; iter++ )
126
{
127
if ( iter==0 ) {
128
if ( name.text().trimmed() == "General" ) continue;
129
section = all_stuff.firstChildElement(Section);
130
} else {
131
section = element.firstChildElement(Section);
132
}
133
134
param = section.firstChildElement("Parameter");
135
136
// ML: Added argument "Parameter" for nextSiblingElement(), 5. August 2010:
137
for( ; !param.isNull(); param=param.nextSiblingElement("Parameter"), params++ ) {
138
139
// label
140
QString widget_type = param.attribute("Widget","Edit");
141
QString widget_enabled = param.attribute("Enabled","True");
142
QString widget_visible = param.attribute("Visible","True");
143
QString paramType = param.firstChildElement("Type").text().trimmed();
144
QString labelName = param.firstChildElement("Name").text().trimmed();
145
QString sifName = param.firstChildElement("SifName").text().trimmed();
146
if ( sifName == "" ) sifName = labelName;
147
QString paramDefault = param.firstChildElement("DefaultValue").text().trimmed();
148
QString whatis = param.firstChildElement("Whatis").text().trimmed();
149
QString statusTip = param.firstChildElement("StatusTip").text().trimmed();
150
QString fullName = "/"+name.text().trimmed()+"/"+Section+"/"+labelName+"/"+QString::number(ID);
151
h.widget = NULL;
152
153
if ( widget_type == "Edit" ) {
154
DynLineEdit *edit = new DynLineEdit;
155
h.widget = edit->lineEdit;
156
edit->lineEdit->setText(paramDefault);
157
edit->name = fullName;
158
connect(edit->lineEdit, SIGNAL(returnPressed()),
159
edit, SLOT(editSlot()));
160
connect(edit->lineEdit, SIGNAL(textChanged(QString)),
161
this, SLOT(textChangedSlot(QString)));
162
163
} else if (widget_type == "TextEdit") {
164
QTextEdit *textEdit = new QTextEdit;
165
// set height to 5..8 lines of current font:
166
QFont currentFont = textEdit->currentFont();
167
QFontMetrics fontMetrics(currentFont);
168
int fontHeight = fontMetrics.height();
169
textEdit->setMinimumHeight(5*fontHeight);
170
textEdit->setMaximumHeight(8*fontHeight);
171
h.widget = textEdit;
172
173
} else if ( widget_type == "Combo" ) {
174
QComboBox *combo = new QComboBox;
175
h.widget = combo;
176
177
// combo->setObjectName(labelName); // removed 30. sept. 2008, ML
178
int count = 0, active=0;
179
180
QDomElement item = param.firstChildElement("Item");
181
for( ; !item.isNull(); item=item.nextSiblingElement("Item") ) {
182
QString itemType = item.attribute( "Type", "" );
183
if ( itemType == "Active" ) active=count;
184
QDomElement itemName = item.firstChildElement("Name");
185
combo->insertItem(count++,itemName.text().trimmed() );
186
}
187
combo->setCurrentIndex(active);
188
// connect(combo, SIGNAL(activated(QString)), this, SLOT(comboSlot(QString)));
189
connect(combo, SIGNAL(currentTextChanged(const QString)), this, SLOT(comboSlot(QString)));
190
191
} else if ( widget_type == "CheckBox" ) {
192
QCheckBox *l = new QCheckBox;
193
h.widget = l;
194
195
l->setText("");
196
l->setChecked(false);
197
if ( paramDefault == "True" ) l->setChecked(true);
198
connect(l, SIGNAL(stateChanged(int)), this, SLOT(lSlot(int)));
199
200
} else if ( widget_type == "Label" ) {
201
QLabel *label = new QLabel;
202
QFont font;
203
font.setBold(true);
204
font.setUnderline(true);
205
label->setFont(font);
206
label->setText(labelName);
207
h.widget = label;
208
}
209
210
if ( h.widget ) {
211
h.widget->setWhatsThis(whatis);
212
// h.widget->setToolTip(whatis); // This is to show whatis just by hovering mouse cursor
213
h.widget->setStatusTip(statusTip);
214
h.widget->setProperty( "dom address",fullName);
215
h.elem = param;
216
217
if ( widget_enabled == "False" ) h.widget->setEnabled(false);
218
219
// The next line was commented out for display scaling. ST
220
//if(widget_type != "TextEdit") h.widget->setFixedHeight(18);
221
222
if(widget_type == "TextEdit") {
223
QLabel *textEditLabel = new QLabel;
224
textEditLabel->setText(labelName);
225
h.label = textEditLabel;
226
grid->addWidget(h.widget, params, 0, 1, 2);
227
228
if ( widget_visible == "False" ) {
229
h.label->hide();
230
h.widget->hide();
231
}
232
233
} else if ( widget_type != "Label" ) {
234
QLabel *label = new QLabel;
235
label->setText(labelName);
236
h.label = label;
237
grid->addWidget(h.label, params, 0);
238
grid->addWidget(h.widget, params, 1);
239
240
if ( widget_visible == "False" ) {
241
h.label->hide();
242
h.widget->hide();
243
}
244
} else {
245
h.label = NULL;
246
grid->addWidget(h.widget, params, 0);
247
}
248
hash[fullName] = h;
249
}
250
}
251
}
252
253
// add a dummy widget in the left bottom corner:
254
QWidget *dummyWidget = new QWidget;
255
grid->addWidget(dummyWidget, params, 0);
256
grid->setRowStretch(params, 1);
257
258
// put the grid in a widget:
259
QWidget *frmWidget = new QWidget;
260
frmWidget->setLayout(grid);
261
262
// set up the scroll area:
263
QScrollArea *src = new QScrollArea;
264
src->setWidget(frmWidget);
265
src->setMinimumHeight(300);
266
src->setWidgetResizable(true);
267
268
// add the scroll area to the tab:
269
if (params>0)
270
tabWidget->addTab(src, name.text().trimmed());
271
272
tabs++;
273
element = element.nextSiblingElement("PDE"); // ML: Added "PDE" 5. August 2010
274
}
275
276
// Buttons:
277
//----------
278
QLabel *lbl = new QLabel;
279
lbl->setText("Name:");
280
281
nameEdit = new QLineEdit;
282
nameEdit->setText(Section + " " + QString::number(ID+1));
283
applyButton = new QPushButton(tr("&Add"));
284
applyButton->setIcon(addIcon);
285
connect(applyButton, SIGNAL(clicked()), this, SLOT(applyButtonClicked()));
286
nameEdit->setWhatsThis("Name of this " + Section);
287
288
discardButton = new QPushButton(tr("&Remove"));
289
discardButton->setIcon(removeIcon);
290
connect(discardButton, SIGNAL(clicked()), this, SLOT(discardButtonClicked()));
291
292
whatsThisButton = new QPushButton(tr("Whatis"));
293
whatsThisButton->setIcon(QIcon::fromTheme("text-questionmark"));
294
connect(whatsThisButton, SIGNAL(clicked()), this, SLOT(whatsThisButtonClicked()));
295
whatsThisButton->setWhatsThis("Press this button, then click the widget to be explained.");
296
297
okButton = new QPushButton(tr("&OK"));
298
okButton->setIcon(okIcon);
299
connect(okButton, SIGNAL(clicked()), this, SLOT(okButtonClicked()));
300
301
newButton = new QPushButton(tr("&New"));
302
newButton->setIcon(newIcon);
303
connect(newButton, SIGNAL(clicked()), this, SLOT(newButtonClicked()));
304
305
QHBoxLayout *nameLayout = new QHBoxLayout;
306
nameLayout->addWidget(lbl);
307
nameLayout->addWidget(nameEdit);
308
309
QHBoxLayout *buttonLayout = new QHBoxLayout;
310
buttonLayout->addWidget(newButton);
311
buttonLayout->addWidget(applyButton);
312
buttonLayout->addWidget(okButton);
313
buttonLayout->addWidget(discardButton);
314
buttonLayout->addWidget(whatsThisButton);
315
316
QHBoxLayout *spareButtonLayout = new QHBoxLayout;
317
spareButton = new QPushButton(tr("SpareButton"));;
318
spareButton->setVisible(false);
319
spareButtonLayout->addWidget(spareButton);
320
connect(spareButton, SIGNAL(clicked()), this, SLOT(spareButtonClicked()));
321
322
spareScroll = new QScrollArea;
323
spareScroll->hide();
324
325
// Main layout:
326
//-------------
327
QVBoxLayout *mainLayout = new QVBoxLayout;
328
mainLayout->addWidget(tabWidget);
329
mainLayout->addWidget(spareScroll);
330
mainLayout->addLayout(spareButtonLayout);
331
mainLayout->addLayout(nameLayout);
332
mainLayout->addLayout(buttonLayout);
333
setLayout(mainLayout);
334
335
// Window title:
336
//---------------
337
setWindowTitle(Section);
338
}
339
340
//----------------------------------------------------------------------------
341
void DynLineEdit::editSlot()
342
{
343
QLineEdit *q = lineEdit;
344
QString s = q->text();
345
#if WITH_QT5 || WITH_QT6
346
cout << string(s.toLatin1()) << endl;
347
#else
348
cout << string(s.toAscii()) << endl;
349
#endif
350
351
if ( frame ) {
352
frame->show();
353
frame->raise();
354
return;
355
}
356
357
textEdit = new QTextEdit;
358
textEdit->setLineWrapMode(QTextEdit::NoWrap);
359
360
s.replace( ';', '\n' );
361
textEdit->append(s);
362
363
closeButton = new QPushButton(tr("&Close"));
364
connect(closeButton, SIGNAL(clicked()), this, SLOT(lineEditClose()));
365
366
label = new QLabel;
367
label->setText(name);
368
369
layout = new QVBoxLayout;
370
layout->addWidget(label);
371
layout->addWidget(textEdit);
372
layout->addWidget(closeButton);
373
374
frame = new QFrame;
375
frame->setLayout(layout);
376
frame->show();
377
frame->setWindowTitle(name);
378
}
379
380
//----------------------------------------------------------------------------
381
void DynLineEdit::lineEditClose()
382
{
383
QString q = textEdit->toPlainText();
384
385
//q.replace( '\n', ';' );
386
387
lineEdit->setText(q);
388
389
frame->close();
390
391
name = "";
392
393
delete label;
394
label = NULL;
395
396
delete textEdit;
397
textEdit = NULL;
398
399
delete closeButton;
400
closeButton = NULL;
401
402
delete layout;
403
layout = NULL;
404
405
delete frame;
406
frame = NULL;
407
}
408
409
//----------------------------------------------------------------------------
410
void DynamicEditor::lSlot(int state)
411
{
412
QDomElement param;
413
QString q = QObject::sender()->property("dom address").toString();
414
415
int ind = q.lastIndexOf( '/', -1);
416
QString ID = q.mid(ind,-1);
417
418
param = hash[q].elem.firstChildElement("Activate");
419
for( ;!param.isNull(); param=param.nextSiblingElement("Activate") ) {
420
q = param.text().trimmed() + ID;
421
hash[q].widget->setEnabled(state);
422
QString widget_visible = hash[q].elem.attribute("Visible","Unknown");
423
if ( state == false && widget_visible != "Unknown" ) {
424
hash[q].label->hide(); hash[q].widget->hide();
425
} else {
426
hash[q].label->show(); hash[q].widget->show();
427
}
428
}
429
430
param = hash[q].elem.firstChildElement("Deactivate");
431
for( ;!param.isNull(); param=param.nextSiblingElement("Deactivate") ) {
432
q = param.text().trimmed() + ID;
433
hash[q].widget->setEnabled(!state);
434
QString widget_visible = hash[q].elem.attribute("Visible","Unknown");
435
if ( state == true && widget_visible != "Unknown" ) {
436
hash[q].label->hide(); hash[q].widget->hide();
437
} else {
438
hash[q].label->show(); hash[q].widget->show();
439
}
440
}
441
}
442
443
//----------------------------------------------------------------------------
444
void DynamicEditor::textChangedSlot(QString text)
445
{
446
QDomElement param;
447
QString q = QObject::sender()->property("dom address").toString();
448
449
int ind = q.lastIndexOf( '/', -1);
450
QString ID = q.mid(ind,-1);
451
452
param = hash[q].elem.firstChildElement("Activate");
453
for( ;!param.isNull(); param=param.nextSiblingElement("Activate") ) {
454
q = param.text().trimmed() + ID;
455
QString widget_visible = hash[q].elem.attribute("Visible","Uknown");
456
457
if ( text != "" ) {
458
hash[q].widget->setEnabled(true);
459
hash[q].widget->show();
460
hash[q].label->show();
461
} else {
462
hash[q].widget->setEnabled(false);
463
if ( widget_visible != "Unknown" ) {
464
hash[q].label->hide();
465
hash[q].widget->hide();
466
}
467
}
468
}
469
}
470
471
//----------------------------------------------------------------------------
472
void DynamicEditor::comboSlot(QString select)
473
{
474
QString q = QObject::sender()->property("dom address").toString();
475
QDomElement item;
476
477
int ind = q.lastIndexOf( '/', -1);
478
QString ID = q.mid(ind,-1);
479
480
item = hash[q].elem.firstChildElement("Item");
481
for( ;!item.isNull(); item=item.nextSiblingElement("Item") ) {
482
QDomElement itemName = item.firstChildElement("Name");
483
if ( itemName.text().trimmed() != select ) {
484
QDomElement activ;
485
486
activ = item.firstChildElement("Activate");
487
for( ;!activ.isNull(); activ=activ.nextSiblingElement("Activate") ) {
488
QString s=activ.text().trimmed() + ID;
489
hash_entry_t h = hash[s];
490
491
QString widget_enabled = h.elem.attribute("Enabled","True");
492
QString widget_visible = h.elem.attribute("Visible","Unknown");
493
494
h.widget->setEnabled(false);
495
if ( widget_visible != "Unknown" ) {
496
h.label->hide(); h.widget->hide();
497
}
498
}
499
}
500
}
501
502
item = hash[q].elem.firstChildElement("Item");
503
for( ;!item.isNull(); item=item.nextSiblingElement("Item") ) {
504
QDomElement itemName = item.firstChildElement("Name");
505
if ( itemName.text().trimmed() == select ) {
506
QDomElement activ;
507
activ = item.firstChildElement("Activate");
508
for( ;!activ.isNull(); activ=activ.nextSiblingElement("Activate") ) {
509
QString s=activ.text().trimmed() + ID;
510
hash_entry_t h = hash[s];
511
h.widget->setEnabled(true);
512
h.label->show(); h.widget->show();
513
}
514
}
515
}
516
// this->show(); // Removed 30. sept. 2008, ML
517
}
518
519
520
//----------------------------------------------------------------------------
521
QSize DynamicEditor::minimumSizeHint() const
522
{
523
return QSize(128, 128);
524
}
525
526
//----------------------------------------------------------------------------
527
QSize DynamicEditor::sizeHint() const
528
{
529
return QSize(400, 500);
530
}
531
532
//----------------------------------------------------------------------------
533
void DynamicEditor::spareButtonClicked()
534
{
535
emit(dynamicEditorSpareButtonClicked(tabWidget->currentIndex(), ID));
536
}
537
538
//----------------------------------------------------------------------------
539
void DynamicEditor::applyButtonClicked()
540
{
541
542
cout << "Dynamic editor: apply-button clicked" << endl;
543
cout.flush();
544
545
touched = true;
546
547
emit(dynamicEditorReady(MAT_APPLY, ID));
548
549
}
550
551
552
//----------------------------------------------------------------------------
553
void DynamicEditor::discardButtonClicked()
554
{
555
556
cout << "Dynamic editor: Remove-button clicked" << endl;
557
cout.flush();
558
559
touched = false;
560
561
emit(dynamicEditorReady(MAT_DELETE, ID));
562
}
563
564
//----------------------------------------------------------------------------
565
void DynamicEditor::okButtonClicked()
566
{
567
568
// cout << "Dynamic editor: ok-button clicked" << endl;
569
// cout.flush();
570
571
touched = false;
572
573
emit(dynamicEditorReady(MAT_OK, ID));
574
}
575
576
//----------------------------------------------------------------------------
577
void DynamicEditor::newButtonClicked()
578
{
579
cout << "Dynamic editor: next-button clicked" << endl;
580
cout.flush();
581
582
touched = false;
583
584
emit(dynamicEditorReady(MAT_NEW, ID));
585
}
586
587
//----------------------------------------------------------------------------
588
void DynamicEditor::whatsThisButtonClicked()
589
{
590
QWhatsThis::enterWhatsThisMode();
591
}
592
593
//----------------------------------------------------------------------------
594
void DynamicEditor::dumpHash(QDomDocument *projectDoc, QDomElement *item)
595
{
596
for(int j = 0; j < this->hash.count(); j++) {
597
QString key = this->hash.keys().at(j);
598
hash_entry_t value = this->hash.values().at(j);
599
QDomElement elem = value.elem;
600
QWidget *widget = value.widget;
601
602
QDomElement itemWidget = projectDoc->createElement("widget");
603
item->appendChild(itemWidget);
604
605
QDomElement itemKey = projectDoc->createElement("key");
606
QDomText itemKeyValue = projectDoc->createTextNode(key);
607
itemKey.appendChild(itemKeyValue);
608
itemWidget.appendChild(itemKey);
609
610
if(elem.attribute("Widget") == "CheckBox") {
611
QCheckBox *checkBox = (QCheckBox*)widget;
612
QDomElement itemCheckBox = projectDoc->createElement("value");
613
QDomText itemCheckBoxValue = projectDoc->createTextNode(QString::number(checkBox->isChecked()));
614
itemCheckBox.appendChild(itemCheckBoxValue);
615
itemWidget.appendChild(itemCheckBox);
616
itemWidget.setAttribute("type", "CheckBox");
617
618
} else if(elem.attribute("Widget") == "Edit") {
619
QLineEdit *lineEdit = (QLineEdit*)widget;
620
QDomElement itemLineEdit = projectDoc->createElement("value");
621
QDomText itemLineEditValue = projectDoc->createTextNode(lineEdit->text().trimmed());
622
itemLineEdit.appendChild(itemLineEditValue);
623
itemWidget.appendChild(itemLineEdit);
624
itemWidget.setAttribute("type", "Edit");
625
626
} else if(elem.attribute("Widget") == "TextEdit") {
627
QTextEdit *textEdit = (QTextEdit*)widget;
628
QDomElement itemTextEdit = projectDoc->createElement("value");
629
QDomText itemTextEditValue = projectDoc->createTextNode(textEdit->toPlainText());
630
itemTextEdit.appendChild(itemTextEditValue);
631
itemWidget.appendChild(itemTextEdit);
632
itemWidget.setAttribute("type", "TextEdit");
633
634
} else if(elem.attribute("Widget") == "Combo") {
635
QComboBox *comboBox = (QComboBox*)widget;
636
QDomElement itemComboBox = projectDoc->createElement("value");
637
QDomText itemComboBoxValue = projectDoc->createTextNode(comboBox->currentText().trimmed());
638
itemComboBox.appendChild(itemComboBoxValue);
639
itemWidget.appendChild(itemComboBox);
640
itemWidget.setAttribute("type", "Combo");
641
642
} else if(elem.attribute("Widget") == "Label") {
643
QLabel *label = (QLabel*)widget;
644
QDomElement itemLabel = projectDoc->createElement("value");
645
QDomText itemLabelValue = projectDoc->createTextNode(label->text().trimmed());
646
itemLabel.appendChild(itemLabelValue);
647
itemWidget.appendChild(itemLabel);
648
itemWidget.setAttribute("type", "Label");
649
}
650
}
651
}
652
653
void DynamicEditor::populateHash(QDomElement *item)
654
{
655
QDomElement widget = item->firstChildElement("widget");
656
657
// ML: Added argument "widget" for nextSiblingElement(), 5. August 2010:
658
for(; !widget.isNull(); widget = widget.nextSiblingElement("widget")) {
659
QString type = widget.attribute("type").trimmed();
660
QString key = widget.firstChildElement("key").text().trimmed();
661
QString value = widget.firstChildElement("value").text().trimmed();
662
663
if(value.isEmpty())
664
continue;
665
666
QStringList splittedKey = key.split("/");
667
668
// Compare with current hash:
669
//----------------------------
670
bool match_found = false;
671
for(int j = 0; j < this->hash.count(); j++) {
672
QString hashkey = this->hash.keys().at(j);
673
QStringList splittedHashKey = hashkey.split("/");
674
hash_entry_t hashvalue = this->hash.values().at(j);
675
QWidget *widget = hashvalue.widget;
676
QDomElement elem = hashvalue.elem;
677
678
if((splittedKey.at(1) == splittedHashKey.at(1)) &&
679
(splittedKey.at(2) == splittedHashKey.at(2)) &&
680
(splittedKey.at(3) == splittedHashKey.at(3))) {
681
682
match_found = true;
683
684
if(elem.attribute("Widget") == "CheckBox") {
685
if(type != "CheckBox")
686
cout << "Load project: type mismatch with checkBox" << endl;
687
QCheckBox *checkBox = (QCheckBox*)widget;
688
if(value.toInt() == 1)
689
checkBox->setChecked(true);
690
else
691
checkBox->setChecked(false);
692
693
} else if(elem.attribute("Widget") == "Edit") {
694
if(type != "Edit")
695
cout << "Load project: type mismatch with lineEdit" << endl;
696
QLineEdit *lineEdit = (QLineEdit*)widget;
697
lineEdit->setText(value);
698
699
} else if(elem.attribute("Widget") == "TextEdit") {
700
if(type != "TextEdit")
701
cout << "Load project: type mismatch with textEdit" << endl;
702
QTextEdit *textEdit = (QTextEdit*)widget;
703
textEdit->clear();
704
textEdit->append(value);
705
706
} else if(elem.attribute("Widget") == "Combo") {
707
if(type != "Combo")
708
cout << "Load project: type mismatch with comboBox" << endl;
709
QComboBox *comboBox = (QComboBox*)widget;
710
for(int k = 0; k < comboBox->count(); k++) {
711
QString current = comboBox->itemText(k).trimmed();
712
if(current == value.trimmed())
713
comboBox->setCurrentIndex(k);
714
}
715
}
716
}
717
}
718
719
if(!match_found) {
720
#if WITH_QT5 || WITH_QT6
721
cout << "Error: Unable to set menu entry: key: " << key.toLatin1().data() << endl;
722
#else
723
cout << "Error: Unable to set menu entry: key: " << key.toAscii().data() << endl;
724
#endif
725
cout.flush();
726
}
727
}
728
}
729
730