Force placefile refresh button

This commit is contained in:
Dan Paulat 2023-11-05 06:32:47 -06:00
parent e43dcb9a6b
commit 66ef65fe2f
4 changed files with 51 additions and 1 deletions

View file

@ -508,6 +508,17 @@ void PlacefileManager::RemoveUrl(const std::string& urlString)
Q_EMIT PlacefileRemoved(urlString);
}
void PlacefileManager::Refresh(const std::string& name)
{
std::shared_lock lock {p->placefileRecordLock_};
auto it = p->placefileRecordMap_.find(name);
if (it != p->placefileRecordMap_.cend())
{
it->second->UpdateAsync();
}
}
void PlacefileManager::Impl::PlacefileRecord::Update()
{
logger_->debug("Update: {}", name_);

View file

@ -41,6 +41,8 @@ public:
bool thresholded = false);
void RemoveUrl(const std::string& urlString);
void Refresh(const std::string& name);
static std::shared_ptr<PlacefileManager> Instance();
signals:

View file

@ -56,6 +56,7 @@ PlacefileSettingsWidget::PlacefileSettingsWidget(QWidget* parent) :
ui->setupUi(this);
ui->removeButton->setEnabled(false);
ui->refreshButton->setEnabled(false);
ui->placefileView->setModel(p->placefileProxyModel_);
@ -114,6 +115,31 @@ void PlacefileSettingsWidgetImpl::ConnectSignals()
}
});
QObject::connect(self_->ui->refreshButton,
&QPushButton::clicked,
self_,
[this]()
{
auto selectionModel =
self_->ui->placefileView->selectionModel();
// Get selected URL string
QModelIndex selected =
selectionModel
->selectedRows(static_cast<int>(
model::PlacefileModel::Column::Placefile))
.first();
QVariant data = self_->ui->placefileView->model()->data(
selected, types::ItemDataRole::SortRole);
std::string urlString = data.toString().toStdString();
// Refresh placefile
if (!urlString.empty())
{
placefileManager_->Refresh(urlString);
}
});
QObject::connect(
openUrlDialog_,
&OpenUrlDialog::accepted,
@ -143,6 +169,7 @@ void PlacefileSettingsWidgetImpl::ConnectSignals()
bool itemSelected = selected.size() > 0;
self_->ui->removeButton->setEnabled(itemSelected);
self_->ui->refreshButton->setEnabled(itemSelected);
});
}

View file

@ -84,7 +84,17 @@
<bool>false</bool>
</property>
<property name="text">
<string>&amp;Remove</string>
<string>R&amp;emove</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="refreshButton">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>&amp;Refresh</string>
</property>
</widget>
</item>