mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 16:20:06 +00:00
Force placefile refresh button
This commit is contained in:
parent
e43dcb9a6b
commit
66ef65fe2f
4 changed files with 51 additions and 1 deletions
|
|
@ -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_);
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -84,7 +84,17 @@
|
|||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Remove</string>
|
||||
<string>R&emove</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="refreshButton">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Refresh</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue