Don't allow placefiles with an empty name

This commit is contained in:
Dan Paulat 2023-09-11 22:19:04 -05:00
parent e14db6cd21
commit df4500478c
2 changed files with 23 additions and 10 deletions

View file

@ -356,10 +356,13 @@ void PlacefileManager::Impl::ReadPlacefileSettings()
PlacefileRecord record =
boost::json::value_to<PlacefileRecord>(placefileEntry);
self_->AddUrl(record.name_,
record.title_,
record.enabled_,
record.thresholded_);
if (!record.name_.empty())
{
self_->AddUrl(record.name_,
record.title_,
record.enabled_,
record.thresholded_);
}
}
catch (const std::exception& ex)
{

View file

@ -257,6 +257,7 @@ bool PlacefileModel::setData(const QModelIndex& index,
}
const auto& placefileName = p->placefileNames_.at(index.row());
bool result = false;
switch (index.column())
{
@ -265,7 +266,7 @@ bool PlacefileModel::setData(const QModelIndex& index,
{
p->placefileManager_->set_placefile_enabled(placefileName,
value.toBool());
return true;
result = true;
}
break;
@ -274,16 +275,20 @@ bool PlacefileModel::setData(const QModelIndex& index,
{
p->placefileManager_->set_placefile_thresholded(placefileName,
value.toBool());
return true;
result = true;
}
break;
case static_cast<int>(Column::Placefile):
if (role == Qt::ItemDataRole::EditRole)
{
p->placefileManager_->set_placefile_url(
placefileName, value.toString().toStdString());
return true;
QString str = value.toString();
if (!str.isEmpty())
{
p->placefileManager_->set_placefile_url(placefileName,
str.toStdString());
result = true;
}
}
break;
@ -291,7 +296,12 @@ bool PlacefileModel::setData(const QModelIndex& index,
break;
}
return true;
if (result)
{
Q_EMIT dataChanged(index, index);
}
return result;
}
void PlacefileModel::HandlePlacefileRemoved(const std::string& name)