diff --git a/bin/app/data/color_schemes/bad_rainbow.xml b/bin/app/data/color_schemes/bad_rainbow.xml index d8e16711..c2d3d67f 100644 --- a/bin/app/data/color_schemes/bad_rainbow.xml +++ b/bin/app/data/color_schemes/bad_rainbow.xml @@ -14,6 +14,13 @@ #A0A0A0 white + diff --git a/bin/app/data/color_schemes/bright.xml b/bin/app/data/color_schemes/bright.xml index 646fc9ab..f1e9f7fb 100644 --- a/bin/app/data/color_schemes/bright.xml +++ b/bin/app/data/color_schemes/bright.xml @@ -14,6 +14,13 @@ #BEBEBE grey + diff --git a/bin/app/data/color_schemes/dark.xml b/bin/app/data/color_schemes/dark.xml index 3c9dda5e..1fadec42 100644 --- a/bin/app/data/color_schemes/dark.xml +++ b/bin/app/data/color_schemes/dark.xml @@ -14,6 +14,13 @@ #808080 white + diff --git a/bin/app/data/gui/code_view/code_view.css b/bin/app/data/gui/code_view/code_view.css index e629cd65..05e548f3 100644 --- a/bin/app/data/gui/code_view/code_view.css +++ b/bin/app/data/gui/code_view/code_view.css @@ -110,6 +110,10 @@ padding-right: 5px; } +#title_bar #screen_button, #title_bar_single #screen_button { + margin-right: 7px; +} + #title_button { background-color: ; border: none; diff --git a/bin/app/data/gui/main/main.css b/bin/app/data/gui/main/main.css index 2e2e1383..f42f9e1a 100644 --- a/bin/app/data/gui/main/main.css +++ b/bin/app/data/gui/main/main.css @@ -41,3 +41,17 @@ QDockWidget::close-button { QDockWidget::float-button { margin-right: px; } + +#screen_button { + background-color: ; + border: 1px solid ; + border-radius: 5px; + color: ; + font-size: px; + padding: 4px 6px; + margin: 2px 0px; +} + +#screen_button:hover { + border: 1px solid ; +} diff --git a/bin/app/user/projects/tictactoe/src/main.cpp b/bin/app/user/projects/tictactoe/src/main.cpp index 8d15ea5f..0c1ef29e 100644 --- a/bin/app/user/projects/tictactoe/src/main.cpp +++ b/bin/app/user/projects/tictactoe/src/main.cpp @@ -4,7 +4,7 @@ int main() { TicTacToe tictactoe; while ( tictactoe.Start() ) { - tictactoe.Run(); + tictactoe.Ru(); } return 0; diff --git a/bin/app/user/projects/tictactoe/src/tictactoe.cpp b/bin/app/user/projects/tictactoe/src/tictactoe.cpp index b4ba8ef1..64416fc5 100644 --- a/bin/app/user/projects/tictactoe/src/tictactoe.cpp +++ b/bin/app/user/projects/tictactoe/src/tictactoe.cpp @@ -18,7 +18,7 @@ bool TicTacToe::Start() { Reset(); io::stringOut("Tic Tac Toe\n\n[1] Human\n[2] Computer\n[3] Quit\n\n"); - players_[0] = SelectPlayer( Field::PlayerA, "Player A" ); + player_[0] = SelectPlayer( Field::PlayerA, "Player A" ); if ( !players_[0] ) { return false; } @@ -66,7 +66,7 @@ void TicTacToe::Reset() { } } -Player* TicTacToe::SelectPlayer( Field::Token token, const char* name ) const { +Player* TicTacToe::SlectPlayer( Field::Token token, const char* name ) const { int selection = 0; while ( true ) { @@ -77,7 +77,7 @@ Player* TicTacToe::SelectPlayer( Field::Token token, const char* name ) const { selection = io::numberIn(); switch ( selection ) { - case 1 : return new HumanPlayer( token, name ); + case 1 : return new HuanPlayer( token, name ); case 2 : return new ArtificialPlayer( token, name ); case 3 : return 0; default : io::stringOut("Wrong input!\n"); diff --git a/bin/app/user/projects/tictactoe/tictactoe.srctrlprj b/bin/app/user/projects/tictactoe/tictactoe.srctrlprj index 1a4d4906..4961500b 100644 --- a/bin/app/user/projects/tictactoe/tictactoe.srctrlprj +++ b/bin/app/user/projects/tictactoe/tictactoe.srctrlprj @@ -26,5 +26,5 @@ C++ Source Group - 4 + 5 diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt index 667ae801..a50a17fd 100644 --- a/src/lib/CMakeLists.txt +++ b/src/lib/CMakeLists.txt @@ -446,6 +446,7 @@ add_files( utility/messaging/type/MessageSearchFullText.h utility/messaging/type/MessageShowErrorHelpMessage.h utility/messaging/type/MessageShowErrors.h + utility/messaging/type/MessageShowErrorsForFile.h utility/messaging/type/MessageShowReference.h utility/messaging/type/MessageShowScope.h utility/messaging/type/MessageShowStatus.h diff --git a/src/lib/component/controller/ActivationController.cpp b/src/lib/component/controller/ActivationController.cpp index 1171ca37..20a95af8 100644 --- a/src/lib/component/controller/ActivationController.cpp +++ b/src/lib/component/controller/ActivationController.cpp @@ -90,38 +90,6 @@ void ActivationController::handleMessage(MessageActivateNodes* message) m.dispatchImmediately(); } -void ActivationController::handleMessage(MessageSearch* message) -{ - const std::vector& matches = message->getMatches(); - - if (matches.size() && matches.back().searchType == SearchMatch::SEARCH_COMMAND) - { - switch (matches.back().getCommandType()) - { - case SearchMatch::COMMAND_ALL: - case SearchMatch::COMMAND_NODE_FILTER: - { - MessageActivateAll(message->acceptedNodeTypes).dispatchImmediately(); - return; - } - - case SearchMatch::COMMAND_ERROR: - { - MessageShowErrors(m_storageAccess->getErrorCount()).dispatch(); - MessageFlushUpdates().dispatch(); - return; - } - } - } - - MessageActivateTokens m(message); - m.tokenIds = message->getTokenIdsOfMatches(); - m.searchMatches = matches; - m.tokenNames = m_storageAccess->getNameHierarchiesForNodeIds(m.tokenIds); - m.isFromSearch = message->isFromSearch; - m.dispatchImmediately(); -} - void ActivationController::handleMessage(MessageActivateTokenIds* message) { MessageActivateTokens m(message); @@ -154,10 +122,47 @@ void ActivationController::handleMessage(MessageResetZoom* message) MessageRefresh().refreshUiOnly().dispatch(); } - + MessageStatus(L"Font size: " + std::to_wstring(fontSizeStd)).dispatch(); } +void ActivationController::handleMessage(MessageSearch* message) +{ + const std::vector& matches = message->getMatches(); + + if (matches.size() && matches.back().searchType == SearchMatch::SEARCH_COMMAND) + { + switch (matches.back().getCommandType()) + { + case SearchMatch::COMMAND_ALL: + case SearchMatch::COMMAND_NODE_FILTER: + { + MessageActivateAll(message->acceptedNodeTypes).dispatchImmediately(); + return; + } + + case SearchMatch::COMMAND_ERROR: + { + MessageShowErrors(m_storageAccess->getErrorCount()).dispatch(); + MessageFlushUpdates().dispatch(); + return; + } + } + } + + MessageActivateTokens m(message); + m.tokenIds = message->getTokenIdsOfMatches(); + m.searchMatches = matches; + m.tokenNames = m_storageAccess->getNameHierarchiesForNodeIds(m.tokenIds); + m.isFromSearch = message->isFromSearch; + m.dispatchImmediately(); +} + +void ActivationController::handleMessage(MessageShowErrorsForFile* message) +{ + MessageShowErrors(m_storageAccess->getErrorsForFileLimited(message->filePath)).dispatch(); +} + void ActivationController::handleMessage(MessageZoom* message) { bool zoomIn = message->zoomIn; diff --git a/src/lib/component/controller/ActivationController.h b/src/lib/component/controller/ActivationController.h index 36af042f..fd00c334 100644 --- a/src/lib/component/controller/ActivationController.h +++ b/src/lib/component/controller/ActivationController.h @@ -13,6 +13,7 @@ #include "utility/messaging/type/MessageActivateSourceLocations.h" #include "utility/messaging/type/MessageResetZoom.h" #include "utility/messaging/type/MessageSearch.h" +#include "utility/messaging/type/MessageShowErrorsForFile.h" #include "utility/messaging/type/MessageZoom.h" class StorageAccess; @@ -26,6 +27,7 @@ class ActivationController , public MessageListener , public MessageListener , public MessageListener + , public MessageListener , public MessageListener { public: @@ -38,10 +40,11 @@ private: virtual void handleMessage(MessageActivateEdge* message); virtual void handleMessage(MessageActivateFile* message); virtual void handleMessage(MessageActivateNodes* message); - virtual void handleMessage(MessageSearch* message); virtual void handleMessage(MessageActivateTokenIds* message); virtual void handleMessage(MessageActivateSourceLocations* message); virtual void handleMessage(MessageResetZoom* message); + virtual void handleMessage(MessageSearch* message); + virtual void handleMessage(MessageShowErrorsForFile* message); virtual void handleMessage(MessageZoom* message); StorageAccess* m_storageAccess; diff --git a/src/lib/component/controller/CodeController.cpp b/src/lib/component/controller/CodeController.cpp index affa3f6f..cfafb8e3 100644 --- a/src/lib/component/controller/CodeController.cpp +++ b/src/lib/component/controller/CodeController.cpp @@ -307,8 +307,13 @@ void CodeController::handleMessage(MessageShowErrors* message) CodeView::ScrollParams scrollParams(CodeView::ScrollParams::SCROLL_TO_DEFINITION); view->scrollTo(scrollParams); - std::vector errors; - m_collection = m_storageAccess->getErrorSourceLocationsLimited(&errors); + std::vector errors = message->errors; + if (!errors.size()) + { + errors = m_storageAccess->getErrorsLimited(); + } + + m_collection = m_storageAccess->getErrorSourceLocations(errors); std::vector snippets = getSnippetsForCollection(m_collection); std::sort(snippets.begin(), snippets.end(), CodeSnippetParams::sortById); diff --git a/src/lib/component/controller/ErrorController.cpp b/src/lib/component/controller/ErrorController.cpp index 0da8f1d2..b4da7d85 100644 --- a/src/lib/component/controller/ErrorController.cpp +++ b/src/lib/component/controller/ErrorController.cpp @@ -80,7 +80,12 @@ void ErrorController::handleMessage(MessageShowErrors* message) clear(); - std::vector errors = m_storageAccess->getErrorsLimited(); + std::vector errors = message->errors; + if (!errors.size()) + { + errors = m_storageAccess->getErrorsLimited(); + } + if (errors.size()) { getView()->showDockWidget(); diff --git a/src/lib/component/controller/StatusBarController.cpp b/src/lib/component/controller/StatusBarController.cpp index 2154e85c..4b4a2261 100644 --- a/src/lib/component/controller/StatusBarController.cpp +++ b/src/lib/component/controller/StatusBarController.cpp @@ -59,7 +59,7 @@ void StatusBarController::handleMessage(MessageRefresh* message) void StatusBarController::handleMessage(MessageShowErrors* message) { - if (message->errorId || message->isReplayed()) + if (message->errorId || message->errors.size() || message->isReplayed()) { return; } diff --git a/src/lib/component/controller/UndoRedoController.cpp b/src/lib/component/controller/UndoRedoController.cpp index 8d941dee..15b8d393 100644 --- a/src/lib/component/controller/UndoRedoController.cpp +++ b/src/lib/component/controller/UndoRedoController.cpp @@ -273,7 +273,8 @@ void UndoRedoController::handleMessage(MessageSearchFullText* message) void UndoRedoController::handleMessage(MessageShowErrors* message) { if (sameMessageTypeAsLast(message) && - static_cast(lastMessage())->errorId == message->errorId) + static_cast(lastMessage())->errorId == message->errorId && + static_cast(lastMessage())->errors.size() == message->errors.size()) { return; } diff --git a/src/lib/data/access/StorageAccess.h b/src/lib/data/access/StorageAccess.h index e5e89183..3ed7c40d 100644 --- a/src/lib/data/access/StorageAccess.h +++ b/src/lib/data/access/StorageAccess.h @@ -81,7 +81,9 @@ public: virtual ErrorCountInfo getErrorCount() const = 0; virtual std::vector getErrorsLimited() const = 0; - virtual std::shared_ptr getErrorSourceLocationsLimited(std::vector* errors) const = 0; + virtual std::vector getErrorsForFileLimited(const FilePath& filePath) const = 0; + virtual std::shared_ptr getErrorSourceLocations( + const std::vector& errors) const = 0; virtual void setErrorFilter(const ErrorFilter& filter); diff --git a/src/lib/data/access/StorageAccessProxy.cpp b/src/lib/data/access/StorageAccessProxy.cpp index f4c4ef6d..db9f2199 100644 --- a/src/lib/data/access/StorageAccessProxy.cpp +++ b/src/lib/data/access/StorageAccessProxy.cpp @@ -332,11 +332,22 @@ std::vector StorageAccessProxy::getErrorsLimited() const return std::vector(); } -std::shared_ptr StorageAccessProxy::getErrorSourceLocationsLimited(std::vector* errors) const +std::vector StorageAccessProxy::getErrorsForFileLimited(const FilePath& filePath) const { if (hasSubject()) { - return m_subject->getErrorSourceLocationsLimited(errors); + return m_subject->getErrorsForFileLimited(filePath); + } + + return std::vector(); +} + +std::shared_ptr StorageAccessProxy::getErrorSourceLocations( + const std::vector& errors) const +{ + if (hasSubject()) + { + return m_subject->getErrorSourceLocations(errors); } return std::make_shared(); diff --git a/src/lib/data/access/StorageAccessProxy.h b/src/lib/data/access/StorageAccessProxy.h index d9a1bac5..823aa9a7 100644 --- a/src/lib/data/access/StorageAccessProxy.h +++ b/src/lib/data/access/StorageAccessProxy.h @@ -68,7 +68,9 @@ public: virtual ErrorCountInfo getErrorCount() const override; virtual std::vector getErrorsLimited() const override; - virtual std::shared_ptr getErrorSourceLocationsLimited(std::vector* errors) const override; + virtual std::vector getErrorsForFileLimited(const FilePath& filePath) const override; + virtual std::shared_ptr getErrorSourceLocations( + const std::vector& errors) const override; // TODO: remove these from access because it's not a getter! virtual Id addNodeBookmark(const NodeBookmark& bookmark) override; diff --git a/src/lib/data/storage/PersistentStorage.cpp b/src/lib/data/storage/PersistentStorage.cpp index e99b5012..0bbcf2af 100644 --- a/src/lib/data/storage/PersistentStorage.cpp +++ b/src/lib/data/storage/PersistentStorage.cpp @@ -1452,44 +1452,83 @@ std::vector PersistentStorage::getErrorsLimited() const if (m_errorFilter.filter(error)) { errors.push_back(error); - } - if (m_errorFilter.limit > 0 && errors.size() >= m_errorFilter.limit) - { - break; + if (m_errorFilter.limit > 0 && errors.size() >= m_errorFilter.limit) + { + break; + } } } return errors; } -std::shared_ptr PersistentStorage::getErrorSourceLocationsLimited(std::vector* errors) const +std::vector PersistentStorage::getErrorsForFileLimited(const FilePath& filePath) const +{ + std::unordered_map> includingMap = getFileIdToIncludedFileIdMap(); + + std::set filePaths; + filePaths.insert(filePath); + + std::set fileIdsToProcess = includingMap[getFileNodeId(filePath)]; + std::set processedFileIds; + while (fileIdsToProcess.size()) + { + std::set nextFileIdsToProcess; + for (Id id : fileIdsToProcess) + { + if (filePaths.insert(getFileNodePath(id)).second) + { + utility::append(nextFileIdsToProcess, includingMap[id]); + } + } + fileIdsToProcess = nextFileIdsToProcess; + } + + std::vector errors; + + for (const ErrorInfo& error : m_sqliteIndexStorage.getAll()) + { + if (m_errorFilter.filter(error) && filePaths.find(FilePath(error.filePath)) != filePaths.end()) + { + errors.push_back(error); + + if (m_errorFilter.limit > 0 && errors.size() >= m_errorFilter.limit) + { + break; + } + } + } + + return errors; +} + +std::shared_ptr PersistentStorage::getErrorSourceLocations( + const std::vector& errors) const { TRACE(); std::shared_ptr collection = std::make_shared(); - for (const ErrorInfo& error : m_sqliteIndexStorage.getAll()) + size_t count = 0; + for (const ErrorInfo& error : errors) { - if (m_errorFilter.filter(error)) - { - errors->push_back(error); + // Set first bit to 1 to avoid collisions + Id locationId = ~(~Id(0) >> 1) + error.id; - // Set first bit to 1 to avoid collisions - Id locationId = ~(~Id(0) >> 1) + error.id; + collection->addSourceLocation( + LOCATION_ERROR, + locationId, + std::vector(1, error.id), + FilePath(error.filePath), + error.lineNumber, + error.columnNumber, + error.lineNumber, + error.columnNumber + ); - collection->addSourceLocation( - LOCATION_ERROR, - locationId, - std::vector(1, error.id), - FilePath(error.filePath), - error.lineNumber, - error.columnNumber, - error.lineNumber, - error.columnNumber - ); - } + count++; - if (m_errorFilter.limit > 0 && errors->size() >= m_errorFilter.limit) + if (m_errorFilter.limit > 0 && count >= m_errorFilter.limit) { break; } @@ -2002,6 +2041,16 @@ std::unordered_map> PersistentStorage::getFileIdToIncludingFile return fileIdToIncludingFileIdMap; } +std::unordered_map> PersistentStorage::getFileIdToIncludedFileIdMap() const +{ + std::unordered_map> fileIdToIncludingFileIdMap; + for (const StorageEdge& includeEdge : m_sqliteIndexStorage.getEdgesByType(Edge::typeToInt(Edge::EDGE_INCLUDE))) + { + fileIdToIncludingFileIdMap[includeEdge.sourceNodeId].insert(includeEdge.targetNodeId); + } + return fileIdToIncludingFileIdMap; +} + std::unordered_map> PersistentStorage::getFileIdToImportingFileIdMap() const { std::unordered_map> fileIdToImportingFileIdMap; @@ -2589,13 +2638,13 @@ void PersistentStorage::buildFullTextSearchIndex() const TextCodec codec(ApplicationSettings::getInstance()->getTextEncoding()); m_fullTextSearchCodec = codec.getName(); - + m_fullTextSearchIndex.clear(); for (StorageFile& file : m_sqliteIndexStorage.getAll()) { m_fullTextSearchIndex.addFile( - file.id, + file.id, codec.decode(m_sqliteIndexStorage.getFileContentById(file.id)->getText()) ); } diff --git a/src/lib/data/storage/PersistentStorage.h b/src/lib/data/storage/PersistentStorage.h index 9fe48a8c..30539f1e 100644 --- a/src/lib/data/storage/PersistentStorage.h +++ b/src/lib/data/storage/PersistentStorage.h @@ -125,7 +125,9 @@ public: virtual ErrorCountInfo getErrorCount(const std::vector& errors) const; virtual std::vector getErrors() const; virtual std::vector getErrorsLimited() const override; - virtual std::shared_ptr getErrorSourceLocationsLimited(std::vector* errors) const override; + virtual std::vector getErrorsForFileLimited(const FilePath& filePath) const override; + virtual std::shared_ptr getErrorSourceLocations( + const std::vector& errors) const override; virtual Id addNodeBookmark(const NodeBookmark& bookmark) override; virtual Id addEdgeBookmark(const EdgeBookmark& bookmark) override; @@ -153,6 +155,7 @@ private: bool getFileNodeComplete(Id fileId) const; std::unordered_map> getFileIdToIncludingFileIdMap() const; + std::unordered_map> getFileIdToIncludedFileIdMap() const; std::unordered_map> getFileIdToImportingFileIdMap() const; std::set getReferenced(const std::set& filePaths, std::unordered_map> idToReferencingIdMap) const; std::set getReferencing(const std::set& filePaths, std::unordered_map> idToReferencingIdMap) const; diff --git a/src/lib/utility/messaging/type/MessageShowErrors.h b/src/lib/utility/messaging/type/MessageShowErrors.h index 72038c4e..b84673ad 100644 --- a/src/lib/utility/messaging/type/MessageShowErrors.h +++ b/src/lib/utility/messaging/type/MessageShowErrors.h @@ -4,6 +4,7 @@ #include "utility/messaging/Message.h" #include "data/ErrorCountInfo.h" +#include "data/ErrorInfo.h" class MessageShowErrors : public Message @@ -15,6 +16,12 @@ public: { } + MessageShowErrors(const std::vector& errors) + : errors(errors) + , errorId(0) + { + } + MessageShowErrors(Id errorId) : errorId(errorId) { @@ -25,8 +32,9 @@ public: return "MessageShowErrors"; } - ErrorCountInfo errorCount; - Id errorId; + const ErrorCountInfo errorCount; + const std::vector errors; + const Id errorId; }; #endif // MESSAGE_SHOW_ERRORS_H diff --git a/src/lib/utility/messaging/type/MessageShowErrorsForFile.h b/src/lib/utility/messaging/type/MessageShowErrorsForFile.h new file mode 100644 index 00000000..fdb6b275 --- /dev/null +++ b/src/lib/utility/messaging/type/MessageShowErrorsForFile.h @@ -0,0 +1,24 @@ +#ifndef MESSAGE_SHOW_ERRORS_FOR_FILE_H +#define MESSAGE_SHOW_ERRORS_FOR_FILE_H + +#include "utility/file/FilePath.h" +#include "utility/messaging/Message.h" + +class MessageShowErrorsForFile + : public Message +{ +public: + MessageShowErrorsForFile(const FilePath& filePath) + : filePath(filePath) + { + } + + static const std::string getStaticType() + { + return "MessageShowErrorsForFile"; + } + + const FilePath filePath; +}; + +#endif // MESSAGE_SHOW_ERRORS_FOR_FILE_H diff --git a/src/lib_gui/qt/element/QtCodeFile.cpp b/src/lib_gui/qt/element/QtCodeFile.cpp index efd3d691..10a2d303 100644 --- a/src/lib_gui/qt/element/QtCodeFile.cpp +++ b/src/lib_gui/qt/element/QtCodeFile.cpp @@ -305,7 +305,7 @@ void QtCodeFile::setWholeFile(bool isWholeFile, int refCount) void QtCodeFile::setIsComplete(bool isComplete) { - m_titleBar->getTitleButton()->setIsComplete(isComplete); + m_titleBar->setIsComplete(isComplete); } void QtCodeFile::setMinimized() diff --git a/src/lib_gui/qt/element/QtCodeFileSingle.cpp b/src/lib_gui/qt/element/QtCodeFileSingle.cpp index 4c678dfa..e1b51b3f 100644 --- a/src/lib_gui/qt/element/QtCodeFileSingle.cpp +++ b/src/lib_gui/qt/element/QtCodeFileSingle.cpp @@ -304,13 +304,13 @@ void QtCodeFileSingle::setFileData(const FileData& file) if (!file.title.empty()) { titleButton->setProject(file.title); - titleButton->setIsComplete(true); + m_titleBar->setIsComplete(true); } else { titleButton->setFilePath(file.filePath); titleButton->setModificationTime(file.modificationTime); - titleButton->setIsComplete(file.isComplete); + m_titleBar->setIsComplete(file.isComplete); } updateRefCount(m_area->getActiveLocationCount()); diff --git a/src/lib_gui/qt/element/QtCodeFileTitleBar.cpp b/src/lib_gui/qt/element/QtCodeFileTitleBar.cpp index 6dbbeae2..e8df53a9 100644 --- a/src/lib_gui/qt/element/QtCodeFileTitleBar.cpp +++ b/src/lib_gui/qt/element/QtCodeFileTitleBar.cpp @@ -5,6 +5,7 @@ #include #include "utility/ResourcePaths.h" +#include "utility/messaging/type/MessageShowErrorsForFile.h" QtCodeFileTitleBar::QtCodeFileTitleBar(QWidget* parent, bool isHovering, bool isSingle) : QtHoverButton(parent) @@ -41,6 +42,20 @@ QtCodeFileTitleBar::QtCodeFileTitleBar(QWidget* parent, bool isHovering, bool is titleLayout->addStretch(3); + m_showErrorsButton = new QPushButton("show errors"); + m_showErrorsButton->setObjectName("screen_button"); + m_showErrorsButton->setToolTip("Show all errors related to this file"); + m_showErrorsButton->setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac + m_showErrorsButton->hide(); + titleLayout->addWidget(m_showErrorsButton); + + connect(m_showErrorsButton, &QPushButton::clicked, + [this]() + { + MessageShowErrorsForFile(m_titleButton->getFilePath()).dispatch(); + } + ); + FilePath imageDir = ResourcePaths::getGuiPath().concatenate(L"code_view/images/"); QColor inactiveColor(0x5E, 0x5D, 0x5D); @@ -94,6 +109,12 @@ QtCodeFileTitleButton* QtCodeFileTitleBar::getTitleButton() const return m_titleButton; } +void QtCodeFileTitleBar::setIsComplete(bool isComplete) +{ + m_titleButton->setIsComplete(isComplete); + m_showErrorsButton->setVisible(!isComplete); +} + void QtCodeFileTitleBar::updateRefCount(int refCount, bool hasErrors, size_t fatalErrorCount) { if (refCount > 0) @@ -158,6 +179,7 @@ void QtCodeFileTitleBar::setMaximized() void QtCodeFileTitleBar::updateFromOther(const QtCodeFileTitleBar* other) { m_titleButton->updateFromOther(other->getTitleButton()); + setIsComplete(m_titleButton->isComplete()); QString refString = other->m_referenceCount->text(); if (refString.size()) diff --git a/src/lib_gui/qt/element/QtCodeFileTitleBar.h b/src/lib_gui/qt/element/QtCodeFileTitleBar.h index fc5e5d83..6dc39094 100644 --- a/src/lib_gui/qt/element/QtCodeFileTitleBar.h +++ b/src/lib_gui/qt/element/QtCodeFileTitleBar.h @@ -23,6 +23,7 @@ public: QtCodeFileTitleButton* getTitleButton() const; + void setIsComplete(bool isComplete); void updateRefCount(int refCount, bool hasErrors, size_t fatalErrorCount); void setMinimized(); @@ -43,6 +44,7 @@ private slots: private: QtCodeFileTitleButton* m_titleButton; + QPushButton* m_showErrorsButton; QLabel* m_referenceCount; QtIconStateButton* m_minimizeButton; diff --git a/src/lib_gui/qt/element/QtCodeFileTitleButton.cpp b/src/lib_gui/qt/element/QtCodeFileTitleButton.cpp index 326bf667..afb43a3f 100644 --- a/src/lib_gui/qt/element/QtCodeFileTitleButton.cpp +++ b/src/lib_gui/qt/element/QtCodeFileTitleButton.cpp @@ -32,6 +32,11 @@ QtCodeFileTitleButton::~QtCodeFileTitleButton() { } +const FilePath& QtCodeFileTitleButton::getFilePath() const +{ + return m_filePath; +} + void QtCodeFileTitleButton::setFilePath(const FilePath& filePath) { setEnabled(true); @@ -56,6 +61,24 @@ void QtCodeFileTitleButton::setModificationTime(const TimeStamp modificationTime } } +void QtCodeFileTitleButton::setProject(const std::wstring& name) +{ + m_filePath = FilePath(); + + setText(QString::fromStdWString(name)); + setToolTip("edit project"); + + setIcon(utility::colorizePixmap( + QPixmap(QString::fromStdWString(ResourcePaths::getGuiPath().concatenate(L"code_view/images/edit.png").wstr())), + ColorScheme::getInstance()->getColor("code/file/title/icon").c_str() + )); +} + +bool QtCodeFileTitleButton::isComplete() const +{ + return m_isComplete; +} + void QtCodeFileTitleButton::setIsComplete(bool isComplete) { if (m_isComplete == isComplete) @@ -82,19 +105,6 @@ void QtCodeFileTitleButton::setIsComplete(bool isComplete) } } -void QtCodeFileTitleButton::setProject(const std::wstring& name) -{ - m_filePath = FilePath(); - - setText(QString::fromStdWString(name)); - setToolTip("edit project"); - - setIcon(utility::colorizePixmap( - QPixmap(QString::fromStdWString(ResourcePaths::getGuiPath().concatenate(L"code_view/images/edit.png").wstr())), - ColorScheme::getInstance()->getColor("code/file/title/icon").c_str() - )); -} - void QtCodeFileTitleButton::updateTexts() { if (m_filePath.empty()) diff --git a/src/lib_gui/qt/element/QtCodeFileTitleButton.h b/src/lib_gui/qt/element/QtCodeFileTitleButton.h index 7f51bbe6..79cf8783 100644 --- a/src/lib_gui/qt/element/QtCodeFileTitleButton.h +++ b/src/lib_gui/qt/element/QtCodeFileTitleButton.h @@ -15,11 +15,15 @@ public: QtCodeFileTitleButton(QWidget* parent = nullptr); virtual ~QtCodeFileTitleButton(); + const FilePath& getFilePath() const; void setFilePath(const FilePath& filePath); + void setModificationTime(const TimeStamp modificationTime); - void setIsComplete(bool isComplete); void setProject(const std::wstring& name); + bool isComplete() const; + void setIsComplete(bool isComplete); + void updateTexts(); void updateFromOther(const QtCodeFileTitleButton* other); diff --git a/src/lib_gui/qt/view/QtErrorView.cpp b/src/lib_gui/qt/view/QtErrorView.cpp index 3a8a2a98..d9709b2c 100644 --- a/src/lib_gui/qt/view/QtErrorView.cpp +++ b/src/lib_gui/qt/view/QtErrorView.cpp @@ -158,6 +158,7 @@ void QtErrorView::initView() { m_allButton = new QPushButton(""); + m_allButton->setObjectName("screen_button"); connect(m_allButton, &QPushButton::clicked, [=]() { @@ -173,17 +174,17 @@ void QtErrorView::initView() { - QPushButton* editButton = new QPushButton("Edit Project"); - connect(editButton, &QPushButton::clicked, + m_editButton = new QPushButton("Edit Project"); + m_editButton->setObjectName("screen_button"); + connect(m_editButton, &QPushButton::clicked, []() { MessageProjectEdit().dispatch(); } ); - checkboxes->addWidget(editButton); + checkboxes->addWidget(m_editButton); - editButton->setToolTip("edit project"); - editButton->setIcon(QPixmap(QString::fromStdWString(ResourcePaths::getGuiPath().concatenate(L"code_view/images/edit.png").wstr()))); + m_editButton->setToolTip("edit project"); } checkboxes->addSpacing(10); @@ -308,6 +309,11 @@ void QtErrorView::setStyleSheet() const m_helpButton->setColor(QColor(ColorScheme::getInstance()->getColor("table/text/normal").c_str())); + m_editButton->setIcon(utility::createButtonIcon( + ResourcePaths::getGuiPath().concatenate(L"code_view/images/edit.png"), + "window/button" + )); + m_table->updateRows(); } diff --git a/src/lib_gui/qt/view/QtErrorView.h b/src/lib_gui/qt/view/QtErrorView.h index d80fcf58..c0397aa5 100644 --- a/src/lib_gui/qt/view/QtErrorView.h +++ b/src/lib_gui/qt/view/QtErrorView.h @@ -77,6 +77,7 @@ private: QCheckBox* m_showNonIndexedFatals; QtHelpButton* m_helpButton; + QPushButton* m_editButton; QStandardItemModel* m_model; QtTable* m_table; diff --git a/src/lib_gui/qt/view/QtStatusView.cpp b/src/lib_gui/qt/view/QtStatusView.cpp index 9de3c810..4e35a287 100644 --- a/src/lib_gui/qt/view/QtStatusView.cpp +++ b/src/lib_gui/qt/view/QtStatusView.cpp @@ -63,6 +63,7 @@ void QtStatusView::initView() filters->addStretch(); QPushButton* clearButton = new QPushButton("Clear Table"); + clearButton->setObjectName("screen_button"); connect(clearButton, &QPushButton::clicked, [=]() {