Merge pull request #29 from Scrumplex/feat-clear-metadata
This commit is contained in:
		@@ -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();
 | 
			
		||||
 
 | 
			
		||||
@@ -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);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -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);
 | 
			
		||||
@@ -1967,6 +1979,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("")));
 | 
			
		||||
 
 | 
			
		||||
@@ -130,6 +130,8 @@ private slots:
 | 
			
		||||
 | 
			
		||||
    void on_actionReportBug_triggered();
 | 
			
		||||
 | 
			
		||||
    void on_actionClearMetadata_triggered();
 | 
			
		||||
 | 
			
		||||
    void on_actionOpenWiki_triggered();
 | 
			
		||||
 | 
			
		||||
    void on_actionMoreNews_triggered();
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user