| 91 | } // namespace |
| 92 | |
| 93 | UpdateSubmodulesDialog::UpdateSubmodulesDialog(const git::Repository &repo, |
| 94 | QWidget *parent) |
| 95 | : QDialog(parent) { |
| 96 | mTable = new QTableView(this); |
| 97 | mTable->setShowGrid(false); |
| 98 | mTable->setSelectionMode(QAbstractItemView::NoSelection); |
| 99 | |
| 100 | Model *model = new Model(repo, this); |
| 101 | mTable->setModel(model); |
| 102 | |
| 103 | mTable->verticalHeader()->hide(); |
| 104 | mTable->horizontalHeader()->hide(); |
| 105 | mTable->horizontalHeader()->setStretchLastSection(false); |
| 106 | mTable->horizontalHeader()->setSectionResizeMode( |
| 107 | QHeaderView::ResizeToContents); |
| 108 | |
| 109 | mRecursive = new QCheckBox(tr("Recursive"), this); |
| 110 | mRecursive->setChecked(true); |
| 111 | |
| 112 | mInit = new QCheckBox(tr("Init"), this); |
| 113 | |
| 114 | QDialogButtonBox *buttons = new QDialogButtonBox(this); |
| 115 | buttons->addButton(QDialogButtonBox::Cancel); |
| 116 | QPushButton *update = |
| 117 | buttons->addButton(tr("Update"), QDialogButtonBox::AcceptRole); |
| 118 | update->setEnabled(!model->enabledSubmodules().isEmpty()); |
| 119 | connect(buttons, &QDialogButtonBox::accepted, this, &QDialog::accept); |
| 120 | connect(buttons, &QDialogButtonBox::rejected, this, &QDialog::reject); |
| 121 | |
| 122 | connect(model, &Model::dataChanged, [model, update] { |
| 123 | update->setEnabled(!model->enabledSubmodules().isEmpty()); |
| 124 | }); |
| 125 | |
| 126 | QVBoxLayout *layout = new QVBoxLayout(this); |
| 127 | layout->addWidget(mTable); |
| 128 | layout->addWidget(mRecursive); |
| 129 | layout->addWidget(mInit); |
| 130 | layout->addWidget(buttons); |
| 131 | } |
| 132 | |
| 133 | QList<git::Submodule> UpdateSubmodulesDialog::submodules() const { |
| 134 | return static_cast<Model *>(mTable->model())->enabledSubmodules(); |
nothing calls this directly
no test coverage detected