mirror of
https://github.com/tnodir/fort
synced 2024-11-15 06:35:23 +00:00
UI: ZonesWindow: Simplify saveZoneEditForm()
This commit is contained in:
parent
8e2c84ed20
commit
bb4737be14
@ -423,23 +423,38 @@ bool ZonesWindow::saveZoneEditForm()
|
||||
|
||||
// Check custom url
|
||||
if (zone.customUrl && zone.url.isEmpty()) {
|
||||
m_editUrl->setText(zoneSource.url());
|
||||
m_editUrl->selectAll();
|
||||
m_editUrl->setFocus();
|
||||
m_editFormData->setText(zoneSource.formData());
|
||||
return false;
|
||||
return saveZoneEditFormCustom(zoneSource);
|
||||
}
|
||||
|
||||
// Add new zone
|
||||
if (m_formZoneIsNew) {
|
||||
if (confManager()->addZone(zone)) {
|
||||
m_zoneListView->selectCell(zone.zoneId - 1);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return saveZoneEditFormNew(zone);
|
||||
}
|
||||
|
||||
// Edit selected zone
|
||||
return saveZoneEditFormEdit(zone);
|
||||
}
|
||||
|
||||
bool ZonesWindow::saveZoneEditFormCustom(const ZoneSourceWrapper &zoneSource)
|
||||
{
|
||||
m_editUrl->setText(zoneSource.url());
|
||||
m_editUrl->selectAll();
|
||||
m_editUrl->setFocus();
|
||||
m_editFormData->setText(zoneSource.formData());
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ZonesWindow::saveZoneEditFormNew(Zone &zone)
|
||||
{
|
||||
if (confManager()->addZone(zone)) {
|
||||
m_zoneListView->selectCell(zone.zoneId - 1);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ZonesWindow::saveZoneEditFormEdit(Zone &zone)
|
||||
{
|
||||
const auto zoneRow = zoneListModel()->zoneRowAt(zoneListCurrentIndex());
|
||||
if (zoneRow.isNull())
|
||||
return false;
|
||||
|
@ -17,7 +17,9 @@ class TableView;
|
||||
class TaskManager;
|
||||
class WidgetWindowStateWatcher;
|
||||
class WindowManager;
|
||||
class Zone;
|
||||
class ZoneListModel;
|
||||
class ZoneSourceWrapper;
|
||||
class ZonesController;
|
||||
|
||||
class ZonesWindow : public WidgetWindow
|
||||
@ -58,6 +60,9 @@ private:
|
||||
|
||||
void updateZoneEditForm(bool editCurrentZone);
|
||||
bool saveZoneEditForm();
|
||||
bool saveZoneEditFormCustom(const ZoneSourceWrapper &zoneSource);
|
||||
bool saveZoneEditFormNew(Zone &zone);
|
||||
bool saveZoneEditFormEdit(Zone &zone);
|
||||
|
||||
void updateZone(int row, bool enabled);
|
||||
void deleteZone(int row);
|
||||
|
Loading…
Reference in New Issue
Block a user