| 166 | } |
| 167 | |
| 168 | bool editNetEntry(QWidget* parent, NetEntry& entry, |
| 169 | const NetSchedulerDialog::CaptureFn& capture, bool isNew) |
| 170 | { |
| 171 | QDialog dlg(parent); |
| 172 | dlg.setWindowTitle(isNew ? QStringLiteral("Add Net") : QStringLiteral("Edit Net")); |
| 173 | dlg.setModal(true); |
| 174 | dlg.setMinimumWidth(440); |
| 175 | |
| 176 | EditorControls c; |
| 177 | auto* root = new QVBoxLayout(&dlg); |
| 178 | root->setContentsMargins(16, 16, 16, 16); |
| 179 | root->setSpacing(12); |
| 180 | |
| 181 | auto* form = new QFormLayout(); |
| 182 | form->setLabelAlignment(Qt::AlignRight); |
| 183 | form->setSpacing(8); |
| 184 | root->addLayout(form); |
| 185 | |
| 186 | c.name = new QLineEdit(&dlg); |
| 187 | c.name->setPlaceholderText(QStringLiteral("e.g. Tuesday County ARES Net")); |
| 188 | form->addRow(QStringLiteral("Name"), c.name); |
| 189 | |
| 190 | // Repeats row. |
| 191 | auto* repeatRow = new QHBoxLayout(); |
| 192 | c.freqUnit = new QComboBox(&dlg); |
| 193 | c.freqUnit->addItems({QStringLiteral("Once (no repeat)"), QStringLiteral("Daily"), |
| 194 | QStringLiteral("Weekly"), QStringLiteral("Monthly")}); |
| 195 | c.freqUnit->setCurrentIndex(2); |
| 196 | repeatRow->addWidget(c.freqUnit); |
| 197 | auto* everyLabel = new QLabel(QStringLiteral("every"), &dlg); |
| 198 | repeatRow->addWidget(everyLabel); |
| 199 | c.interval = new QSpinBox(&dlg); |
| 200 | c.interval->setRange(1, 52); |
| 201 | c.interval->setValue(1); |
| 202 | repeatRow->addWidget(c.interval); |
| 203 | c.intervalUnit = new QLabel(QStringLiteral("week(s)"), &dlg); |
| 204 | repeatRow->addWidget(c.intervalUnit); |
| 205 | repeatRow->addStretch(1); |
| 206 | form->addRow(QStringLiteral("Repeats"), repeatRow); |
| 207 | |
| 208 | // One-time date (Once only). |
| 209 | c.date = new QDateEdit(QDate::currentDate(), &dlg); |
| 210 | c.date->setCalendarPopup(true); |
| 211 | c.date->setDisplayFormat(QStringLiteral("ddd MMM d, yyyy")); |
| 212 | c.dateLabel = new QLabel(QStringLiteral("On date"), &dlg); |
| 213 | form->addRow(c.dateLabel, c.date); |
| 214 | |
| 215 | // Weekday chips (weekly only). |
| 216 | c.weekdayRow = new QFrame(&dlg); |
| 217 | auto* chipRow = new QHBoxLayout(c.weekdayRow); |
| 218 | chipRow->setContentsMargins(0, 0, 0, 0); |
| 219 | chipRow->setSpacing(4); |
| 220 | for (int i = 0; i < 7; ++i) { |
| 221 | auto* chip = new QPushButton(QString::fromLatin1(kWeekdayShort[i]), c.weekdayRow); |
| 222 | chip->setCheckable(true); |
| 223 | chip->setFixedWidth(34); |
| 224 | chip->setCursor(Qt::PointingHandCursor); |
| 225 | chip->setAccessibleName(QString::fromLatin1(kWeekdayLong[i])); |
no test coverage detected