diff --git a/src/app/qt/element/QtCodeFile.cpp b/src/app/qt/element/QtCodeFile.cpp index ca7ad3ce..ea5863bb 100644 --- a/src/app/qt/element/QtCodeFile.cpp +++ b/src/app/qt/element/QtCodeFile.cpp @@ -223,11 +223,21 @@ QWidget* QtCodeFile::findFirstActiveSnippet() const return nullptr; } - for (std::shared_ptr snippet : m_snippets) + if (m_maximizeButton->isEnabled()) { - if (snippet->isActive()) + for (std::shared_ptr snippet : m_snippets) { - return snippet.get(); + if (snippet->isActive()) + { + return snippet.get(); + } + } + } + else + { + if (m_fileSnippet->isActive()) + { + return m_fileSnippet.get(); } } diff --git a/src/app/qt/view/QtGraphView.cpp b/src/app/qt/view/QtGraphView.cpp index 591c3a89..fd6ddaee 100644 --- a/src/app/qt/view/QtGraphView.cpp +++ b/src/app/qt/view/QtGraphView.cpp @@ -3,7 +3,7 @@ #include #include #include -#include +#include #include #include #include @@ -12,6 +12,8 @@ #include "component/controller/helper/DummyEdge.h" #include "component/controller/helper/DummyNode.h" #include "component/controller/helper/GraphPostprocessor.h" +#include "component/view/GraphViewStyle.h" +#include "utility/messaging/type/MessageDeactivateEdge.h" #include "qt/utility/utilityQt.h" @@ -25,6 +27,32 @@ #include "qt/view/graphElements/QtGraphNodeExpandToggle.h" #include "settings/ColorScheme.h" +QtGraphicsView::QtGraphicsView(QWidget* parent) + : QGraphicsView(parent) +{ +} + +void QtGraphicsView::mousePressEvent(QMouseEvent *event) +{ + if (event->button() == Qt::LeftButton && !itemAt(event->pos())) + { + m_last = event->pos(); + } + + QGraphicsView::mousePressEvent(event); +} + +void QtGraphicsView::mouseReleaseEvent(QMouseEvent *event) +{ + if (event->button() == Qt::LeftButton && !itemAt(event->pos()) && event->pos() == m_last) + { + emit emptySpaceClicked(); + } + + QGraphicsView::mouseReleaseEvent(event); +} + + QtGraphView::QtGraphView(ViewLayout* viewLayout) : GraphView(viewLayout) , m_rebuildGraphFunctor( @@ -56,13 +84,15 @@ void QtGraphView::initView() widget->setLayout(layout); QGraphicsScene* scene = new QGraphicsScene(widget); - QGraphicsView* view = new QGraphicsView(widget); + QGraphicsView* view = new QtGraphicsView(widget); view->setScene(scene); view->setDragMode(QGraphicsView::ScrollHandDrag); view->setRenderHints(QPainter::Antialiasing); widget->layout()->addWidget(view); + connect(view, SIGNAL(emptySpaceClicked()), this, SLOT(clickedInEmptySpace())); + doRefreshView(); } @@ -114,6 +144,23 @@ void QtGraphView::finishedTransition() switchToNewGraphData(); } +void QtGraphView::clickedInEmptySpace() +{ + size_t activeEdgeCount = 0; + for (std::shared_ptr edge : m_oldEdges) + { + if (edge->getIsActive()) + { + activeEdgeCount++; + } + } + + if (activeEdgeCount == 1) + { + MessageDeactivateEdge().dispatch(); + } +} + void QtGraphView::switchToNewGraphData() { m_oldGraph = m_graph; @@ -239,6 +286,9 @@ void QtGraphView::doRefreshView() std::string css = utility::getStyleSheet("data/gui/graph_view/graph_view.css"); getView()->setStyleSheet(css.c_str()); + + float zoomFactor = GraphViewStyle::getZoomFactor(); + getView()->setTransform(QTransform(zoomFactor, 0, 0, zoomFactor, 0, 0)); } std::shared_ptr QtGraphView::findNodeRecursive(const std::list>& nodes, Id tokenId) diff --git a/src/app/qt/view/QtGraphView.h b/src/app/qt/view/QtGraphView.h index f54387eb..4d2dc387 100644 --- a/src/app/qt/view/QtGraphView.h +++ b/src/app/qt/view/QtGraphView.h @@ -1,21 +1,38 @@ #ifndef QT_GRAPH_VIEW_H #define QT_GRAPH_VIEW_H +#include #include -#include "utility/types.h" - -#include "qt/utility/QtThreadedFunctor.h" - #include "component/view/GraphView.h" +#include "qt/utility/QtThreadedFunctor.h" +#include "utility/types.h" struct DummyEdge; struct DummyNode; -class QGraphicsView; +class QMouseEvent; class QSequentialAnimationGroup; class QtGraphEdge; class QtGraphNode; +class QtGraphicsView + : public QGraphicsView +{ + Q_OBJECT + +public: + QtGraphicsView(QWidget* parent); + void mousePressEvent(QMouseEvent *event); + void mouseReleaseEvent(QMouseEvent *event); + +signals: + void emptySpaceClicked(); + +private: + QPoint m_last; +}; + + class QtGraphView : public QObject , public GraphView @@ -44,6 +61,7 @@ public: private slots: void centerScrollBars(); void finishedTransition(); + void clickedInEmptySpace(); private: void switchToNewGraphData(); diff --git a/src/app/qt/view/graphElements/QtGraphNodeExpandToggle.cpp b/src/app/qt/view/graphElements/QtGraphNodeExpandToggle.cpp index 2033cfb0..c8248602 100644 --- a/src/app/qt/view/graphElements/QtGraphNodeExpandToggle.cpp +++ b/src/app/qt/view/graphElements/QtGraphNodeExpandToggle.cpp @@ -70,7 +70,7 @@ void QtGraphNodeExpandToggle::updateStyle() m_icon->setPos( (m_rect->rect().width() - m_icon->pixmap().width() / QtDeviceScaledPixmap::devicePixelRatio()) / 2, - (m_invisibleSubNodeCount == 0 ? m_rect->rect().height() / 2 - 2 : m_rect->rect().height() - 8) + (m_invisibleSubNodeCount == 0 ? m_rect->rect().height() / 2 - 2 : m_rect->rect().height() - 7) ); m_icon->setPixmap(utility::colorizePixmap(m_icon->pixmap(), style.iconColor.c_str())); diff --git a/src/lib/Application.cpp b/src/lib/Application.cpp index e8b2fbc0..f4db89dd 100644 --- a/src/lib/Application.cpp +++ b/src/lib/Application.cpp @@ -53,7 +53,6 @@ void Application::loadSettings() } Application::Application() - : m_isInitialParse(true) { TaskScheduler::getInstance()->startSchedulerLoopThreaded(); MessageQueue::getInstance()->setSendMessagesAsTasks(true); @@ -106,36 +105,14 @@ void Application::handleMessage(MessageFinishedParsing* message) { m_project->logStats(); - if (!m_isInitialParse || message->errorCount > 0) + if (message->errorCount == 0) { - return; - } - - m_isInitialParse = false; - - Id nodeId = m_storageCache->getIdForNodeWithNameHierarchy(NameHierarchy("main")); - - if (!nodeId) - { - nodeId = m_storageCache->getIdForFirstNode(); - } - - if (nodeId) - { - MessageActivateNodes message; - message.addNode( - nodeId, - m_storageCache->getNodeTypeForNodeWithId(nodeId), - m_storageCache->getNameHierarchyForNodeWithId(nodeId) - ); - message.isFromSystem = true; - message.dispatch(); + MessageRefresh().refreshUiOnly().dispatch(); } } void Application::handleMessage(MessageLoadProject* message) { - m_isInitialParse = true; loadProject(message->projectSettingsFilePath); } diff --git a/src/lib/Application.h b/src/lib/Application.h index 4d425be8..049653f8 100644 --- a/src/lib/Application.h +++ b/src/lib/Application.h @@ -46,8 +46,6 @@ private: std::shared_ptr m_mainView; std::shared_ptr m_componentManager; - - bool m_isInitialParse; }; #endif // APPLICATION_H diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt index 9fddb8d9..a53ece25 100644 --- a/src/lib/CMakeLists.txt +++ b/src/lib/CMakeLists.txt @@ -239,6 +239,7 @@ add_files( utility/messaging/type/MessageActivateTokenLocations.h utility/messaging/type/MessageActivateTokens.h utility/messaging/type/MessageAutoRefreshChanged.h + utility/messaging/type/MessageDeactivateEdge.h utility/messaging/type/MessageFind.h utility/messaging/type/MessageFinishedParsing.h utility/messaging/type/MessageFlushUpdates.h diff --git a/src/lib/Project.cpp b/src/lib/Project.cpp index 48adbe83..3fd33a54 100644 --- a/src/lib/Project.cpp +++ b/src/lib/Project.cpp @@ -29,8 +29,6 @@ bool Project::loadProjectSettings(const FilePath& projectSettingsFile) if (success) { setProjectSettingsFilePath(projectSettingsFile); - - m_fileManager.clear(); updateFileManager(); } return success; @@ -66,8 +64,6 @@ void Project::reloadProjectSettings() void Project::clearStorage() { - m_fileManager.clear(); - if (m_storage) { m_storage->clear(); @@ -158,12 +154,11 @@ void Project::updateFileManager() std::shared_ptr projSettings = ProjectSettings::getInstance(); std::vector sourcePaths(projSettings->getSourcePaths()); - std::vector includePaths(sourcePaths); std::vector sourceExtensions = projSettings->getSourceExtensions(); std::vector includeExtensions = projSettings->getHeaderExtensions(); - m_fileManager.setPaths(sourcePaths, includePaths, sourceExtensions, includeExtensions); + m_fileManager.setPaths(sourcePaths, sourceExtensions, includeExtensions); } Parser::Arguments Project::getParserArguments() const @@ -176,8 +171,8 @@ Parser::Arguments Project::getParserArguments() const utility::append(args.compilerFlags, projSettings->getCompilerFlags()); utility::append(args.compilerFlags, appSettings->getCompilerFlags()); - // Add the include paths as HeaderSearchPaths as well, so clang will also look here when searching include files. - utility::append(args.systemHeaderSearchPaths, m_fileManager.getIncludePaths()); + // Add the source paths as HeaderSearchPaths as well, so clang will also look here when searching include files. + utility::append(args.systemHeaderSearchPaths, m_fileManager.getSourcePaths()); // std::vector headerSearchSubPaths; // for(FilePath p : projSettings->getHeaderSearchPaths()) diff --git a/src/lib/component/ComponentFactory.cpp b/src/lib/component/ComponentFactory.cpp index 0c70db34..c5e2caa2 100644 --- a/src/lib/component/ComponentFactory.cpp +++ b/src/lib/component/ComponentFactory.cpp @@ -77,7 +77,7 @@ std::shared_ptr ComponentFactory::createSearchComponent(ViewLayout* v std::shared_ptr ComponentFactory::createUndoRedoComponent(ViewLayout* viewLayout) { std::shared_ptr view = m_viewFactory->createUndoRedoView(viewLayout); - std::shared_ptr controller = std::make_shared(); + std::shared_ptr controller = std::make_shared(m_storageAccess); return std::make_shared(view, controller); } diff --git a/src/lib/component/controller/CodeController.cpp b/src/lib/component/controller/CodeController.cpp index 7a0d0a4e..898c524a 100644 --- a/src/lib/component/controller/CodeController.cpp +++ b/src/lib/component/controller/CodeController.cpp @@ -26,7 +26,7 @@ const uint CodeController::s_lineRadius = 2; void CodeController::handleMessage(MessageActivateTokens* message) { - if (message->isEdge && message->isIgnorable()) + if (message->keepContent() && message->isIgnorable()) { return; } @@ -47,6 +47,10 @@ void CodeController::handleMessage(MessageActivateTokens* message) if (message->isEdge) { view->showFirstActiveSnippet(); + } + + if (message->keepContent()) + { return; } diff --git a/src/lib/component/controller/FeatureController.cpp b/src/lib/component/controller/FeatureController.cpp index d9d39889..a3dd9157 100644 --- a/src/lib/component/controller/FeatureController.cpp +++ b/src/lib/component/controller/FeatureController.cpp @@ -41,10 +41,11 @@ void FeatureController::handleMessage(MessageActivateEdge* message) return; } - MessageActivateTokens msg(std::vector(1, edgeId)); - msg.isEdge = true; - msg.undoRedoType = message->undoRedoType; - msg.dispatchImmediately(); + MessageActivateTokens m(std::vector(1, edgeId)); + m.isEdge = true; + m.undoRedoType = message->undoRedoType; + m.setKeepContent(message->keepContent()); + m.dispatchImmediately(); } } @@ -52,6 +53,7 @@ void FeatureController::handleMessage(MessageActivateFile* message) { MessageActivateTokens m(std::vector(1, m_storageAccess->getTokenIdForFileNode(message->filePath))); m.undoRedoType = message->undoRedoType; + m.setKeepContent(message->keepContent()); m.dispatchImmediately(); } @@ -80,6 +82,7 @@ void FeatureController::handleMessage(MessageActivateNodes* message) MessageActivateTokens m(nodeIds); m.isFromSystem = message->isFromSystem; m.undoRedoType = message->undoRedoType; + m.setKeepContent(message->keepContent()); m.dispatchImmediately(); } @@ -88,16 +91,16 @@ void FeatureController::handleMessage(MessageActivateTokenLocations* message) std::vector nodeIds = m_storageAccess->getNodeIdsForLocationIds(message->locationIds); nodeIds = m_storageAccess->getActiveTokenIdsForTokenIds(nodeIds); - MessageActivateNodes msg; + MessageActivateNodes m; for (Id nodeId : nodeIds) { - msg.addNode( + m.addNode( nodeId, m_storageAccess->getNodeTypeForNodeWithId(nodeId), m_storageAccess->getNameHierarchyForNodeWithId(nodeId) ); } - msg.dispatchImmediately(); + m.dispatchImmediately(); } void FeatureController::handleMessage(MessageSearch* message) @@ -107,6 +110,7 @@ void FeatureController::handleMessage(MessageSearch* message) MessageActivateTokens m(tokenIds); m.undoRedoType = message->undoRedoType; + m.setKeepContent(message->keepContent()); m.dispatchImmediately(); } diff --git a/src/lib/component/controller/GraphController.cpp b/src/lib/component/controller/GraphController.cpp index cd17648d..b8800b4e 100644 --- a/src/lib/component/controller/GraphController.cpp +++ b/src/lib/component/controller/GraphController.cpp @@ -25,7 +25,7 @@ GraphController::~GraphController() void GraphController::handleMessage(MessageActivateTokens* message) { - if (message->isEdge && message->tokenIds.size() == 1) + if (message->isEdge || message->keepContent()) { m_activeEdgeIds = message->tokenIds; setActiveAndVisibility(utility::concat(m_activeNodeIds, m_activeEdgeIds)); diff --git a/src/lib/component/controller/SearchController.cpp b/src/lib/component/controller/SearchController.cpp index c826a676..d70af241 100644 --- a/src/lib/component/controller/SearchController.cpp +++ b/src/lib/component/controller/SearchController.cpp @@ -14,7 +14,7 @@ SearchController::~SearchController() void SearchController::handleMessage(MessageActivateTokens* message) { - if (!message->isEdge) + if (!message->keepContent()) { getView()->setMatches(m_storageAccess->getSearchMatchesForTokenIds(message->tokenIds)); } diff --git a/src/lib/component/controller/UndoRedoController.cpp b/src/lib/component/controller/UndoRedoController.cpp index e2a85fba..3ebc682a 100644 --- a/src/lib/component/controller/UndoRedoController.cpp +++ b/src/lib/component/controller/UndoRedoController.cpp @@ -4,9 +4,11 @@ #include "utility/messaging/type/MessageFlushUpdates.h" #include "component/view/UndoRedoView.h" +#include "data/access/StorageAccess.h" -UndoRedoController::UndoRedoController() - : m_lastCommand(nullptr, 0) +UndoRedoController::UndoRedoController(StorageAccess* storageAccess) + : m_storageAccess(storageAccess) + , m_lastCommand(nullptr, 0) { } @@ -63,6 +65,34 @@ void UndoRedoController::handleMessage(MessageActivateNodes* message) processCommand(command); } +void UndoRedoController::handleMessage(MessageDeactivateEdge* message) +{ + MessageBase* m = nullptr; + + if (m_lastCommand.message && m_lastCommand.order == 0) + { + m = m_lastCommand.message.get(); + } + else if (m_undo.size()) + { + int i = m_undo.size() - 1; + while (i >= 0 && m_undo[i].order > 0) + { + i--; + } + m = m_undo[i].message.get(); + } + + if (m) + { + bool keepContent = m->keepContent(); + m->undoRedoType = MessageBase::UNDOTYPE_NORMAL; + m->setKeepContent(true); + m->dispatch(); + m->setKeepContent(keepContent); + } +} + void UndoRedoController::handleMessage(MessageGraphNodeBundleSplit* message) { Command command(std::make_shared(*message), 1); @@ -101,8 +131,31 @@ void UndoRedoController::handleMessage(MessageRedo* message) void UndoRedoController::handleMessage(MessageRefresh* message) { + if (!message->uiOnly) + { + return; + } + if (!m_lastCommand.message) { + Id nodeId = m_storageAccess->getIdForNodeWithNameHierarchy(NameHierarchy("main")); + if (!nodeId) + { + nodeId = m_storageAccess->getIdForFirstNode(); + } + + if (nodeId) + { + MessageActivateNodes m; + m.addNode( + nodeId, + m_storageAccess->getNodeTypeForNodeWithId(nodeId), + m_storageAccess->getNameHierarchyForNodeWithId(nodeId) + ); + m.isFromSystem = true; + m.dispatch(); + } + return; } diff --git a/src/lib/component/controller/UndoRedoController.h b/src/lib/component/controller/UndoRedoController.h index 35877ed5..924bc29e 100644 --- a/src/lib/component/controller/UndoRedoController.h +++ b/src/lib/component/controller/UndoRedoController.h @@ -8,6 +8,7 @@ #include "utility/messaging/type/MessageActivateEdge.h" #include "utility/messaging/type/MessageActivateFile.h" #include "utility/messaging/type/MessageActivateNodes.h" +#include "utility/messaging/type/MessageDeactivateEdge.h" #include "utility/messaging/type/MessageGraphNodeBundleSplit.h" #include "utility/messaging/type/MessageGraphNodeExpand.h" #include "utility/messaging/type/MessageGraphNodeMove.h" @@ -21,6 +22,7 @@ #include "component/controller/Controller.h" +class StorageAccess; class UndoRedoView; class UndoRedoController @@ -28,6 +30,7 @@ class UndoRedoController , public MessageListener , public MessageListener , public MessageListener + , public MessageListener , public MessageListener , public MessageListener , public MessageListener @@ -40,7 +43,7 @@ class UndoRedoController , public MessageListener { public: - UndoRedoController(); + UndoRedoController(StorageAccess* storageAccess); virtual ~UndoRedoController(); UndoRedoView* getView(); @@ -57,6 +60,7 @@ private: virtual void handleMessage(MessageActivateEdge* message); virtual void handleMessage(MessageActivateFile* message); virtual void handleMessage(MessageActivateNodes* message); + virtual void handleMessage(MessageDeactivateEdge* message); virtual void handleMessage(MessageGraphNodeBundleSplit* message); virtual void handleMessage(MessageGraphNodeExpand* message); virtual void handleMessage(MessageGraphNodeMove* message); @@ -77,6 +81,8 @@ private: void clear(); + StorageAccess* m_storageAccess; + Command m_lastCommand; std::deque m_undo; diff --git a/src/lib/component/view/GraphViewStyle.cpp b/src/lib/component/view/GraphViewStyle.cpp index a538e83f..5b75471e 100644 --- a/src/lib/component/view/GraphViewStyle.cpp +++ b/src/lib/component/view/GraphViewStyle.cpp @@ -60,9 +60,11 @@ void GraphViewStyle::setImpl(std::shared_ptr impl) void GraphViewStyle::loadStyleSettings() { - s_fontSize = ApplicationSettings::getInstance()->getFontSize(); + s_fontSize = 14; s_fontName = ApplicationSettings::getInstance()->getFontName(); + s_zoomFactor = ApplicationSettings::getInstance()->getFontSize() / float(s_fontSize); + s_charWidths.clear(); s_charHeights.clear(); } @@ -132,7 +134,7 @@ size_t GraphViewStyle::getFontSizeOfAccessNode() size_t GraphViewStyle::getFontSizeOfExpandToggleNode() { - return s_fontSize - 5; + return s_fontSize - 3; } size_t GraphViewStyle::getFontSizeOfCountCircle() @@ -243,7 +245,7 @@ GraphViewStyle::NodeMargins GraphViewStyle::getMarginsOfExpandToggleNode() { NodeMargins margins; - margins.left = margins.right = margins.top = margins.bottom = 7; + margins.left = margins.right = margins.top = margins.bottom = 6; margins.minWidth = margins.charHeight = getFontSizeOfExpandToggleNode(); return margins; @@ -513,6 +515,11 @@ int GraphViewStyle::toGridGap(int x) return s_gridCellPadding + toGridOffset(x - s_gridCellPadding); } +float GraphViewStyle::getZoomFactor() +{ + return s_zoomFactor; +} + void GraphViewStyle::addIcon(Node::NodeType type, bool hasChildren, NodeStyle* style) { switch (type) @@ -560,3 +567,4 @@ std::shared_ptr GraphViewStyle::s_impl; int GraphViewStyle::s_fontSize; std::string GraphViewStyle::s_fontName; +float GraphViewStyle::s_zoomFactor; diff --git a/src/lib/component/view/GraphViewStyle.h b/src/lib/component/view/GraphViewStyle.h index 5be35936..af472c58 100644 --- a/src/lib/component/view/GraphViewStyle.h +++ b/src/lib/component/view/GraphViewStyle.h @@ -116,6 +116,8 @@ public: static int toGridSize(int x); static int toGridGap(int x); + static float getZoomFactor(); + static int s_gridCellSize; static int s_gridCellPadding; @@ -129,6 +131,7 @@ private: static int s_fontSize; static std::string s_fontName; + static float s_zoomFactor; }; #endif // GRAPH_VIEW_STYLE_H diff --git a/src/lib/data/Storage.cpp b/src/lib/data/Storage.cpp index d415c28f..2deef207 100644 --- a/src/lib/data/Storage.cpp +++ b/src/lib/data/Storage.cpp @@ -81,8 +81,10 @@ void Storage::clearFileElement(const FilePath& filePath) Id fileId = getFileNodeId(filePath); if (fileId != 0) { + m_sqliteStorage.beginTransaction(); m_sqliteStorage.removeElementsWithLocationInFile(fileId); m_sqliteStorage.removeFile(fileId); + m_sqliteStorage.commitTransaction(); } } diff --git a/src/lib/data/TaskCleanStorage.cpp b/src/lib/data/TaskCleanStorage.cpp index 7bd29db0..d1c7374a 100644 --- a/src/lib/data/TaskCleanStorage.cpp +++ b/src/lib/data/TaskCleanStorage.cpp @@ -48,11 +48,15 @@ Task::TaskState TaskCleanStorage::update() void TaskCleanStorage::exit() { - // std::cout << "clean duration: " << utility::duration(m_start) << std::endl; + std::stringstream ss; + ss << "clearing files done, "; + ss << std::setprecision(2) << std::fixed << utility::duration(m_start) << " seconds"; + MessageStatus(ss.str()).dispatch(); } void TaskCleanStorage::interrupt() { + MessageStatus("Clearing file interrupted", false, true).dispatch(); } void TaskCleanStorage::revert() diff --git a/src/lib/data/search/SearchNode.cpp b/src/lib/data/search/SearchNode.cpp index 131d8cd2..7aed3a93 100644 --- a/src/lib/data/search/SearchNode.cpp +++ b/src/lib/data/search/SearchNode.cpp @@ -316,10 +316,8 @@ std::pair SearchNode::fuzzyMatch( size_t pos = start; size_t weight = 0; size_t matchCount = 0; - char lastChar = '\0'; size_t ql = query.size(); - size_t ml = m_name.size(); if (!query.size()) { @@ -344,20 +342,37 @@ std::pair SearchNode::fuzzyMatch( } } - for (size_t i = 0; i < ml; i++) + char last = '\0'; + size_t nl = m_name.size(); + for (size_t i = 0; i < nl; i++) { char c = m_name[i]; + char next = (i + 1 == nl ? '\0' : m_name[i + 1]); + if (tolower(query[pos]) == tolower(c)) { weight += std::max(100 / sqrt(size + i + 1), 1); + if (matchCount) { weight += matchCount * matchCount * 10; } - else if (i == 0 || lastChar == '_' || tolower(c) != c) + + + if (i == 0) { weight += 20; } + + if (last == '_' || next == '_') + { + weight += 20; + } + else if ((tolower(c) != c && tolower(next) == next) || (tolower(c) == c && tolower(next) != next)) + { + weight += 20; + } + matchCount++; pos++; @@ -376,7 +391,7 @@ std::pair SearchNode::fuzzyMatch( matchCount = 0; } - lastChar = c; + last = c; } return std::pair(pos, weight); diff --git a/src/lib/utility/file/FileManager.cpp b/src/lib/utility/file/FileManager.cpp index 5e0a6abb..7c0927ae 100644 --- a/src/lib/utility/file/FileManager.cpp +++ b/src/lib/utility/file/FileManager.cpp @@ -20,36 +20,22 @@ const std::vector& FileManager::getSourcePaths() const return m_sourcePaths; } -const std::vector& FileManager::getIncludePaths() const -{ - return m_includePaths; -} - void FileManager::setPaths( std::vector sourcePaths, - std::vector includePaths, std::vector sourceExtensions, std::vector includeExtensions ){ m_sourcePaths = sourcePaths; - m_includePaths = includePaths; m_sourceExtensions = sourceExtensions; m_includeExtensions = includeExtensions; } -void FileManager::clear() -{ - m_files.clear(); - m_addedFiles.clear(); - m_updatedFiles.clear(); - m_removedFiles.clear(); -} - void FileManager::fetchFilePaths(const std::vector& oldFileInfos) { + m_files.clear(); for (FileInfo oldFileInfo: oldFileInfos) { - m_files[oldFileInfo.path] = oldFileInfo; + m_files.emplace(oldFileInfo.path, oldFileInfo); } m_addedFiles.clear(); @@ -135,7 +121,7 @@ std::vector FileManager::getFileInfosInProject() const std::vector fileInfos; std::vector, std::vector>> pathsExtensionsPairs; - pathsExtensionsPairs.push_back(std::make_pair(m_includePaths, m_includeExtensions)); + pathsExtensionsPairs.push_back(std::make_pair(m_sourcePaths, m_includeExtensions)); pathsExtensionsPairs.push_back(std::make_pair(m_sourcePaths, m_sourceExtensions)); for (size_t i = 0; i < pathsExtensionsPairs.size(); i++) diff --git a/src/lib/utility/file/FileManager.h b/src/lib/utility/file/FileManager.h index 36015ef7..34a24ddf 100644 --- a/src/lib/utility/file/FileManager.h +++ b/src/lib/utility/file/FileManager.h @@ -14,11 +14,9 @@ public: virtual ~FileManager(); const std::vector& getSourcePaths() const; - const std::vector& getIncludePaths() const; void setPaths( std::vector sourcePaths, - std::vector includePaths, std::vector sourceExtensions, std::vector includeExtensions ); @@ -42,7 +40,6 @@ private: std::map m_files; std::vector m_sourcePaths; - std::vector m_includePaths; std::vector m_sourceExtensions; std::vector m_includeExtensions; diff --git a/src/lib/utility/file/FileSystem.cpp b/src/lib/utility/file/FileSystem.cpp index c47601ba..e3c07d79 100644 --- a/src/lib/utility/file/FileSystem.cpp +++ b/src/lib/utility/file/FileSystem.cpp @@ -63,7 +63,6 @@ FileInfo FileSystem::getFileInfoForPath(FilePath filePath) return FileInfo(); } - std::vector FileSystem::getFileInfosFromPaths( const std::vector& paths, const std::vector& fileExtensions ){ diff --git a/src/lib/utility/messaging/MessageBase.h b/src/lib/utility/messaging/MessageBase.h index fba7824d..683fc57a 100644 --- a/src/lib/utility/messaging/MessageBase.h +++ b/src/lib/utility/messaging/MessageBase.h @@ -17,6 +17,7 @@ public: MessageBase() : undoRedoType(UNDOTYPE_NORMAL) , m_sendAsTask(true) + , m_keepContent(false) { } @@ -47,10 +48,21 @@ public: return (undoRedoType == UNDOTYPE_IGNORE); } + void setKeepContent(bool keepContent) + { + m_keepContent = keepContent; + } + + bool keepContent() const + { + return m_keepContent; + } + UndoType undoRedoType; private: bool m_sendAsTask; + bool m_keepContent; }; #endif // MESSAGE_BASE_H diff --git a/src/lib/utility/messaging/type/MessageActivateEdge.h b/src/lib/utility/messaging/type/MessageActivateEdge.h index 21a8e1cf..3075748e 100644 --- a/src/lib/utility/messaging/type/MessageActivateEdge.h +++ b/src/lib/utility/messaging/type/MessageActivateEdge.h @@ -17,6 +17,7 @@ public: , fromNameHierarchy(fromName) , toNameHierarchy(toName) { + setKeepContent(true); } static const std::string getStaticType() diff --git a/src/lib/utility/messaging/type/MessageDeactivateEdge.h b/src/lib/utility/messaging/type/MessageDeactivateEdge.h new file mode 100644 index 00000000..503aea42 --- /dev/null +++ b/src/lib/utility/messaging/type/MessageDeactivateEdge.h @@ -0,0 +1,20 @@ +#ifndef MESSAGE_DEACTIVATE_EDGE_H +#define MESSAGE_DEACTIVATE_EDGE_H + +#include "utility/messaging/Message.h" + +class MessageDeactivateEdge + : public Message +{ +public: + MessageDeactivateEdge() + { + } + + static const std::string getStaticType() + { + return "MessageDeactivateEdge"; + } +}; + +#endif // MESSAGE_DEACTIVATE_EDGE_H