feat: add clear metadata action

Signed-off-by: Sefa Eyeoglu <contact@scrumplex.net>
This commit is contained in:
Sefa Eyeoglu 2022-10-10 12:45:44 +02:00
parent aabcca5059
commit 71f3c6b461
No known key found for this signature in database
GPG Key ID: C10411294912A422
4 changed files with 32 additions and 0 deletions

View File

@ -162,6 +162,18 @@ auto HttpMetaCache::evictEntry(MetaEntryPtr entry) -> bool
return true;
}
void HttpMetaCache::evictAll()
{
for (QString& base : m_entries.keys()) {
EntryMap& map = m_entries[base];
qDebug() << "Evicting base" << base;
for (MetaEntryPtr entry : map.entry_list) {
if (!evictEntry(entry))
qWarning() << "Unexpected missing cache entry" << entry->basePath;
}
}
}
auto HttpMetaCache::staleEntry(QString base, QString resource_path) -> MetaEntryPtr
{
auto foo = new MetaEntry();

View File

@ -113,6 +113,7 @@ class HttpMetaCache : public QObject {
// evict selected entry from cache
auto evictEntry(MetaEntryPtr entry) -> bool;
void evictAll();
void addBase(QString base, QString base_root);

View File

@ -258,6 +258,7 @@ public:
QMenu * helpMenu = nullptr;
TranslatedToolButton helpMenuButton;
TranslatedAction actionClearMetadata;
TranslatedAction actionReportBug;
TranslatedAction actionDISCORD;
TranslatedAction actionMATRIX;
@ -347,6 +348,13 @@ public:
actionUndoTrashInstance->setShortcut(QKeySequence("Ctrl+Z"));
all_actions.append(&actionUndoTrashInstance);
actionClearMetadata = TranslatedAction(MainWindow);
actionClearMetadata->setObjectName(QStringLiteral("actionClearMetadata"));
actionClearMetadata->setIcon(APPLICATION->getThemedIcon("refresh"));
actionClearMetadata.setTextId(QT_TRANSLATE_NOOP("MainWindow", "&Clear Metadata Cache"));
actionClearMetadata.setTooltipId(QT_TRANSLATE_NOOP("MainWindow", "Clear cached metadata"));
all_actions.append(&actionClearMetadata);
if (!BuildConfig.BUG_TRACKER_URL.isEmpty()) {
actionReportBug = TranslatedAction(MainWindow);
actionReportBug->setObjectName(QStringLiteral("actionReportBug"));
@ -445,6 +453,8 @@ public:
helpMenu = new QMenu(MainWindow);
helpMenu->setToolTipsVisible(true);
helpMenu->addAction(actionClearMetadata);
if (!BuildConfig.BUG_TRACKER_URL.isEmpty()) {
helpMenu->addAction(actionReportBug);
}
@ -537,6 +547,8 @@ public:
helpMenu = menuBar->addMenu(tr("&Help"));
helpMenu->setSeparatorsCollapsible(false);
helpMenu->addAction(actionClearMetadata);
helpMenu->addSeparator();
helpMenu->addAction(actionAbout);
helpMenu->addAction(actionOpenWiki);
helpMenu->addAction(actionNewsMenuBar);
@ -1980,6 +1992,11 @@ void MainWindow::on_actionReportBug_triggered()
DesktopServices::openUrl(QUrl(BuildConfig.BUG_TRACKER_URL));
}
void MainWindow::on_actionClearMetadata_triggered()
{
APPLICATION->metacache()->evictAll();
}
void MainWindow::on_actionOpenWiki_triggered()
{
DesktopServices::openUrl(QUrl(BuildConfig.HELP_URL.arg("")));

View File

@ -130,6 +130,8 @@ private slots:
void on_actionReportBug_triggered();
void on_actionClearMetadata_triggered();
void on_actionOpenWiki_triggered();
void on_actionMoreNews_triggered();