| 40 | } |
| 41 | |
| 42 | WidgetSettingList::WidgetSettingList(QTreeWidget *tree, QTreeWidgetItem *item, const SettingMetaList &meta, |
| 43 | SettingDataSet &data_set) |
| 44 | : WidgetSettingBase(tree, item), |
| 45 | meta(meta), |
| 46 | data_set(data_set), |
| 47 | search(nullptr), |
| 48 | field(new QLineEdit(this)), |
| 49 | add_button(new QPushButton(this)), |
| 50 | list(meta.list) { |
| 51 | std::vector<EnabledNumberOrString> value = this->data().value; |
| 52 | for (std::size_t i = 0, n = value.size(); i < n; ++i) { |
| 53 | ::RemoveValue(this->list, value[i]); |
| 54 | } |
| 55 | |
| 56 | const char *tooltip = GetFieldToolTip(this->meta, this->list.empty()); |
| 57 | |
| 58 | this->field->show(); |
| 59 | this->field->setText(""); |
| 60 | this->field->setToolTip(tooltip); |
| 61 | this->field->setFont(this->tree->font()); |
| 62 | this->field->setFocusPolicy(Qt::StrongFocus); |
| 63 | this->field->installEventFilter(this); |
| 64 | this->ResetCompleter(); |
| 65 | |
| 66 | this->connect(this->field, SIGNAL(textChanged(const QString &)), this, SLOT(OnTextEdited(const QString &))); |
| 67 | this->connect(this->field, SIGNAL(returnPressed()), this, SLOT(OnElementAppended()), Qt::QueuedConnection); |
| 68 | |
| 69 | this->add_button->show(); |
| 70 | this->add_button->setText("+"); |
| 71 | this->add_button->setFont(this->tree->font()); |
| 72 | |
| 73 | this->connect(this->add_button, SIGNAL(clicked()), this, SLOT(OnElementAppended()), Qt::QueuedConnection); |
| 74 | |
| 75 | std::sort(value.begin(), value.end()); |
| 76 | this->data().value = value; |
| 77 | |
| 78 | this->item->setText(0, (this->meta.label + " ").c_str()); |
| 79 | this->item->setFont(0, this->tree->font()); |
| 80 | this->item->setToolTip(0, this->meta.description.c_str()); |
| 81 | this->item->setSizeHint(0, QSize(0, ITEM_HEIGHT)); |
| 82 | this->tree->setItemWidget(this->item, 0, this); |
| 83 | |
| 84 | this->Refresh(REFRESH_ENABLE_AND_STATE); |
| 85 | } |
| 86 | |
| 87 | void WidgetSettingList::Refresh(RefreshAreas refresh_areas) { |
| 88 | const SettingDependenceMode enabled = ::CheckDependence(this->meta, data_set); |
nothing calls this directly
no test coverage detected