From bb3a8bf35171a96cf558663a161ccda0981715d8 Mon Sep 17 00:00:00 2001 From: Eberhard Graether Date: Wed, 23 Sep 2015 16:44:39 +0200 Subject: [PATCH] ui: force refresh option in menu for reloading whole project --- src/app/qt/element/QtSmartSearchBox.cpp | 2 -- src/app/qt/window/QtMainWindow.cpp | 16 +++++++++++++++ src/app/qt/window/QtMainWindow.h | 1 + src/lib/Application.cpp | 5 +++++ src/lib/Project.cpp | 20 ++++++++++--------- src/lib/Project.h | 3 +-- .../controller/FeatureController.cpp | 4 ++-- src/lib/data/Storage.cpp | 9 +++++++-- src/lib/utility/file/FileManager.cpp | 2 +- src/lib/utility/file/FileManager.h | 2 +- .../utility/messaging/type/MessageRefresh.h | 20 ++++++++++++++++--- 11 files changed, 62 insertions(+), 22 deletions(-) diff --git a/src/app/qt/element/QtSmartSearchBox.cpp b/src/app/qt/element/QtSmartSearchBox.cpp index f90ce87d..5070cec1 100644 --- a/src/app/qt/element/QtSmartSearchBox.cpp +++ b/src/app/qt/element/QtSmartSearchBox.cpp @@ -830,9 +830,7 @@ void QtSmartSearchBox::hideAutoCompletions() completer()->popup()->hide(); } -// #include "data/query/QueryTree.h" std::deque QtSmartSearchBox::getMatchesForInput(const std::string& text) const { - // return SearchMatch::stringDequeToSearchMatchDeque(QueryTree::tokenizeQuery(text)); return std::deque(1, SearchMatch(text)); } diff --git a/src/app/qt/window/QtMainWindow.cpp b/src/app/qt/window/QtMainWindow.cpp index aa41c9c7..90b6daff 100644 --- a/src/app/qt/window/QtMainWindow.cpp +++ b/src/app/qt/window/QtMainWindow.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include "component/view/View.h" #include "component/view/CompositeView.h" @@ -329,6 +330,11 @@ void QtMainWindow::refresh() MessageRefresh().dispatch(); } +void QtMainWindow::forceRefresh() +{ + MessageRefresh().refreshAll().dispatch(); +} + void QtMainWindow::saveProject() { MessageSaveProject("").dispatch(); @@ -434,6 +440,16 @@ void QtMainWindow::setupEditMenu() menu->addSeparator(); menu->addAction(tr("&Refresh"), this, SLOT(refresh()), QKeySequence::Refresh); + + if (QSysInfo::windowsVersion() != QSysInfo::WV_None) + { + menu->addAction(tr("&Force Refresh"), this, SLOT(forceRefresh()), QKeySequence(Qt::SHIFT + Qt::Key_F5)); + } + else + { + menu->addAction(tr("&Force Refresh"), this, SLOT(forceRefresh()), QKeySequence(Qt::SHIFT + Qt::CTRL + Qt::Key_R)); + } + menu->addAction(tr("&Find"), this, SLOT(find()), QKeySequence::Find); } diff --git a/src/app/qt/window/QtMainWindow.h b/src/app/qt/window/QtMainWindow.h index 270e80ad..da307386 100644 --- a/src/app/qt/window/QtMainWindow.h +++ b/src/app/qt/window/QtMainWindow.h @@ -70,6 +70,7 @@ public slots: void find(); void closeWindow(); void refresh(); + void forceRefresh(); void saveProject(); void saveAsProject(); diff --git a/src/lib/Application.cpp b/src/lib/Application.cpp index a763d9cb..03d6c62b 100644 --- a/src/lib/Application.cpp +++ b/src/lib/Application.cpp @@ -143,6 +143,11 @@ void Application::handleMessage(MessageRefresh* message) { m_componentManager->refreshViews(); } + else if (message->all) + { + m_project->clearStorage(); + refreshProject(); + } else { refreshProject(); diff --git a/src/lib/Project.cpp b/src/lib/Project.cpp index f446a617..d36ff31d 100644 --- a/src/lib/Project.cpp +++ b/src/lib/Project.cpp @@ -28,7 +28,7 @@ bool Project::loadProjectSettings(const FilePath& projectSettingsFile) { setProjectSettingsFilePath(projectSettingsFile); - m_fileManager.reset(); + m_fileManager.clear(); updateFileManager(); } return success; @@ -53,14 +53,6 @@ bool Project::saveProjectSettings(const FilePath& projectSettingsFile) return true; } -void Project::clearProjectSettings() -{ - setProjectSettingsFilePath(FilePath()); - ProjectSettings::getInstance()->clear(); - - m_fileManager.reset(); -} - void Project::reloadProjectSettings() { if (!m_projectSettingsFilepath.empty()) @@ -70,6 +62,16 @@ void Project::reloadProjectSettings() } } +void Project::clearStorage() +{ + m_fileManager.clear(); + + if (m_storage) + { + m_storage->clear(); + } +} + void Project::parseCode() { if (m_projectSettingsFilepath.empty()) diff --git a/src/lib/Project.h b/src/lib/Project.h index 88e48574..42474e28 100644 --- a/src/lib/Project.h +++ b/src/lib/Project.h @@ -19,10 +19,9 @@ public: bool loadProjectSettings(const FilePath& projectSettingsFile); bool saveProjectSettings(const FilePath& projectSettingsFile); - - void clearProjectSettings(); void reloadProjectSettings(); + void clearStorage(); void parseCode(); void logStats() const; diff --git a/src/lib/component/controller/FeatureController.cpp b/src/lib/component/controller/FeatureController.cpp index 84bb2b0c..20dd4238 100644 --- a/src/lib/component/controller/FeatureController.cpp +++ b/src/lib/component/controller/FeatureController.cpp @@ -123,7 +123,7 @@ void FeatureController::handleMessage(MessageSwitchColorScheme* message) settings->setColorSchemePath(message->colorSchemeFilePath); settings->save(); - MessageRefresh(true).dispatch(); + MessageRefresh().refreshUiOnly().dispatch(); } void FeatureController::handleMessage(MessageZoom* message) @@ -132,5 +132,5 @@ void FeatureController::handleMessage(MessageZoom* message) settings->setFontSize(std::max(settings->getFontSize() + (message->zoomIn ? 1 : -1), 5)); settings->save(); - MessageRefresh(true).dispatch(); + MessageRefresh().refreshUiOnly().dispatch(); } diff --git a/src/lib/data/Storage.cpp b/src/lib/data/Storage.cpp index c9210143..cbdd682f 100644 --- a/src/lib/data/Storage.cpp +++ b/src/lib/data/Storage.cpp @@ -896,7 +896,7 @@ std::shared_ptr Storage::getTokenLocationsForTokenIds(c const StorageSourceLocation& location = locations[i]; StorageFile storageFile = m_sqliteStorage.getFileById(location.fileNodeId); - collection->addTokenLocation( + TokenLocation* loc = collection->addTokenLocation( location.id, location.elementId, storageFile.filePath, @@ -904,7 +904,12 @@ std::shared_ptr Storage::getTokenLocationsForTokenIds(c location.startCol, location.endLine, location.endCol - )->setType(location.isScope ? TokenLocation::LOCATION_SCOPE : TokenLocation::LOCATION_TOKEN); + ); + + if (loc) + { + loc->setType(location.isScope ? TokenLocation::LOCATION_SCOPE : TokenLocation::LOCATION_TOKEN); + } } } } diff --git a/src/lib/utility/file/FileManager.cpp b/src/lib/utility/file/FileManager.cpp index 1e86c92a..5e0a6abb 100644 --- a/src/lib/utility/file/FileManager.cpp +++ b/src/lib/utility/file/FileManager.cpp @@ -37,7 +37,7 @@ void FileManager::setPaths( m_includeExtensions = includeExtensions; } -void FileManager::reset() +void FileManager::clear() { m_files.clear(); m_addedFiles.clear(); diff --git a/src/lib/utility/file/FileManager.h b/src/lib/utility/file/FileManager.h index 7d6c302d..36015ef7 100644 --- a/src/lib/utility/file/FileManager.h +++ b/src/lib/utility/file/FileManager.h @@ -23,7 +23,7 @@ public: std::vector includeExtensions ); - void reset(); + void clear(); void fetchFilePaths(const std::vector& oldFileInfos); std::set getAddedFilePaths() const; diff --git a/src/lib/utility/messaging/type/MessageRefresh.h b/src/lib/utility/messaging/type/MessageRefresh.h index 307e2442..c3855969 100644 --- a/src/lib/utility/messaging/type/MessageRefresh.h +++ b/src/lib/utility/messaging/type/MessageRefresh.h @@ -6,8 +6,9 @@ class MessageRefresh: public Message { public: - MessageRefresh(bool uiOnly = false) - : uiOnly(uiOnly) + MessageRefresh() + : uiOnly(false) + , all(false) { } @@ -16,7 +17,20 @@ public: return "MessageRefresh"; } - const bool uiOnly; + MessageRefresh& refreshUiOnly() + { + uiOnly = true; + return *this; + } + + MessageRefresh& refreshAll() + { + all = true; + return *this; + } + + bool uiOnly; + bool all; }; #endif // MESSAGE_REFRESH_H