equal
deleted
inserted
replaced
24 #include <QLineEdit> |
24 #include <QLineEdit> |
25 #include <QTabWidget> |
25 #include <QTabWidget> |
26 #include <QGroupBox> |
26 #include <QGroupBox> |
27 #include <QToolBox> |
27 #include <QToolBox> |
28 #include <QMessageBox> |
28 #include <QMessageBox> |
29 |
29 #include <QStandardItemModel> |
30 #include "sdlkeys.h" |
30 #include <QDebug> |
31 #include "SquareLabel.h" |
31 #include "SquareLabel.h" |
32 #include "HWApplication.h" |
32 #include "HWApplication.h" |
33 |
33 |
34 #include "DataManager.h" |
34 #include "DataManager.h" |
35 #include "HatModel.h" |
35 #include "HatModel.h" |
195 |
195 |
196 l = new QLabel(curW); |
196 l = new QLabel(curW); |
197 l->setText(HWApplication::translate("binds", cbinds[i].name)); |
197 l->setText(HWApplication::translate("binds", cbinds[i].name)); |
198 l->setAlignment(Qt::AlignRight); |
198 l->setAlignment(Qt::AlignRight); |
199 pagelayout->addWidget(l, num, 0); |
199 pagelayout->addWidget(l, num, 0); |
|
200 |
200 CBBind[i] = new QComboBox(curW); |
201 CBBind[i] = new QComboBox(curW); |
201 for(int j = 0; sdlkeys[j][1][0] != '\0'; j++) |
202 CBBind[i]->setModel(DataManager::instance().bindsModel()); |
202 CBBind[i]->addItem(HWApplication::translate("binds (keys)", sdlkeys[j][1]).contains(": ") ? HWApplication::translate("binds (keys)", sdlkeys[j][1]) : HWApplication::translate("binds (keys)", "Keyboard") + QString(": ") + HWApplication::translate("binds (keys)", sdlkeys[j][1]), sdlkeys[j][0]); |
|
203 pagelayout->addWidget(CBBind[i++], num++, 1); |
203 pagelayout->addWidget(CBBind[i++], num++, 1); |
204 } |
204 } |
205 |
205 |
206 return pageLayout; |
206 return pageLayout; |
207 } |
207 } |
421 CBFlag->setCurrentIndex(CBFlag->findData(team.flag())); |
421 CBFlag->setCurrentIndex(CBFlag->findData(team.flag())); |
422 |
422 |
423 CBFort->setCurrentIndex(CBFort->findText(team.fort())); |
423 CBFort->setCurrentIndex(CBFort->findText(team.fort())); |
424 CBVoicepack->setCurrentIndex(CBVoicepack->findText(team.voicepack())); |
424 CBVoicepack->setCurrentIndex(CBVoicepack->findText(team.voicepack())); |
425 |
425 |
|
426 QStandardItemModel * binds = DataManager::instance().bindsModel(); |
426 for(int i = 0; i < BINDS_NUMBER; i++) |
427 for(int i = 0; i < BINDS_NUMBER; i++) |
427 { |
428 { |
428 CBBind[i]->setCurrentIndex(CBBind[i]->findData(team.keyBind(i))); |
429 QModelIndexList mdl = binds->match(binds->index(0, 0), Qt::UserRole + 1, team.keyBind(i), 1, Qt::MatchExactly); |
|
430 |
|
431 if(mdl.size() == 1) |
|
432 CBBind[i]->setCurrentIndex(mdl[0].row()); |
|
433 else |
|
434 qDebug() << "Binds: cannot find" << team.keyBind(i); |
429 } |
435 } |
430 } |
436 } |
431 |
437 |
432 HWTeam PageEditTeam::data() |
438 HWTeam PageEditTeam::data() |
433 { |
439 { |
449 team.setGrave(CBGrave->currentText()); |
455 team.setGrave(CBGrave->currentText()); |
450 team.setFort(CBFort->currentText()); |
456 team.setFort(CBFort->currentText()); |
451 team.setVoicepack(CBVoicepack->currentText()); |
457 team.setVoicepack(CBVoicepack->currentText()); |
452 team.setFlag(CBFlag->itemData(CBFlag->currentIndex()).toString()); |
458 team.setFlag(CBFlag->itemData(CBFlag->currentIndex()).toString()); |
453 |
459 |
|
460 QStandardItemModel * binds = DataManager::instance().bindsModel(); |
454 for(int i = 0; i < BINDS_NUMBER; i++) |
461 for(int i = 0; i < BINDS_NUMBER; i++) |
455 { |
462 { |
456 team.bindKey(i,CBBind[i]->itemData(CBBind[i]->currentIndex()).toString()); |
463 team.bindKey(i, binds->index(CBBind[i]->currentIndex(), 0).data(Qt::UserRole + 1).toString()); |
457 } |
464 } |
458 |
465 |
459 return team; |
466 return team; |
460 } |
467 } |
461 |
468 |