logic: Made history menu use on Messages instead of SearchMatch
* Common base class MessageActivateBase for activation messages with getter for SearchMatches * Removed duplicate logic for creating SearchMatches from Messages * Fixed can't reactivate fulltext search from history menu * Renamed history message and moved to sub directory * Fixed activating node type filters didn't clear code view
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
#include <QLabel>
|
||||
#include <QScrollBar>
|
||||
|
||||
#include "utility/messaging/type/MessageToUndoRedoPosition.h"
|
||||
#include "utility/messaging/type/history/MessageHistoryToPosition.h"
|
||||
#include "utility/ResourcePaths.h"
|
||||
#include "utility/utilityString.h"
|
||||
|
||||
@@ -168,7 +168,7 @@ void QtHistoryList::onItemClicked(QListWidgetItem *item)
|
||||
{
|
||||
if (historyItem->index != m_currentIndex)
|
||||
{
|
||||
MessageToUndoRedoPosition(historyItem->index).dispatch();
|
||||
MessageHistoryToPosition(historyItem->index).dispatch();
|
||||
}
|
||||
close();
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
#include <QHBoxLayout>
|
||||
|
||||
#include "utility/messaging/type/MessageSearch.h"
|
||||
#include "utility/messaging/type/MessageActivateAll.h"
|
||||
#include "utility/ResourcePaths.h"
|
||||
|
||||
#include "qt/element/QtSearchBarButton.h"
|
||||
@@ -96,5 +96,5 @@ void QtSearchBar::refreshStyle()
|
||||
|
||||
void QtSearchBar::homeButtonClicked()
|
||||
{
|
||||
MessageSearch({ SearchMatch::createCommand(SearchMatch::COMMAND_ALL) }).dispatch();
|
||||
MessageActivateAll().dispatch();
|
||||
}
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
#include "component/view/GraphViewStyle.h"
|
||||
#include "data/NodeTypeSet.h"
|
||||
#include "settings/ColorScheme.h"
|
||||
#include "utility/messaging/type/MessageActivateFullTextSearch.h"
|
||||
#include "utility/messaging/type/MessageSearch.h"
|
||||
#include "utility/messaging/type/MessageSearchFullText.h"
|
||||
#include "utility/messaging/type/MessageSearchAutocomplete.h"
|
||||
#include "utility/utility.h"
|
||||
#include "utility/utilityString.h"
|
||||
@@ -89,7 +89,7 @@ void QtSmartSearchBox::fullTextSearch()
|
||||
caseSensitive = true;
|
||||
}
|
||||
|
||||
MessageSearchFullText(term, caseSensitive).dispatch();
|
||||
MessageActivateFullTextSearch(term, caseSensitive).dispatch();
|
||||
}
|
||||
|
||||
QtSmartSearchBox::QtSmartSearchBox(QWidget* parent)
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include <QMovie>
|
||||
|
||||
#include "qt/utility/utilityQt.h"
|
||||
#include "utility/messaging/type/MessageSearch.h"
|
||||
#include "utility/messaging/type/error/MessageErrorsAll.h"
|
||||
#include "utility/messaging/type/MessageShowStatus.h"
|
||||
#include "utility/ResourcePaths.h"
|
||||
|
||||
@@ -118,5 +118,5 @@ void QtStatusBar::showStatus()
|
||||
|
||||
void QtStatusBar::showErrors()
|
||||
{
|
||||
MessageSearch({ SearchMatch::createCommand(SearchMatch::COMMAND_ERROR) }).dispatch();
|
||||
MessageErrorsAll().dispatch();
|
||||
}
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
#include <QHBoxLayout>
|
||||
#include <QTimer>
|
||||
|
||||
#include "utility/messaging/type/MessageUndo.h"
|
||||
#include "utility/messaging/type/MessageRedo.h"
|
||||
#include "utility/messaging/type/history/MessageHistoryUndo.h"
|
||||
#include "utility/messaging/type/history/MessageHistoryRedo.h"
|
||||
#include "utility/ResourcePaths.h"
|
||||
|
||||
#include "qt/element/QtHistoryList.h"
|
||||
@@ -91,7 +91,7 @@ void QtUndoRedo::undoReleased()
|
||||
if (m_pressed)
|
||||
{
|
||||
m_pressed = false;
|
||||
MessageUndo().dispatch();
|
||||
MessageHistoryUndo().dispatch();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ void QtUndoRedo::redoReleased()
|
||||
if (m_pressed)
|
||||
{
|
||||
m_pressed = false;
|
||||
MessageRedo().dispatch();
|
||||
MessageHistoryRedo().dispatch();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
#include <QUrl>
|
||||
|
||||
#include "utility/logging/logging.h"
|
||||
#include "utility/messaging/type/MessageRedo.h"
|
||||
#include "utility/messaging/type/MessageUndo.h"
|
||||
#include "utility/messaging/type/history/MessageHistoryRedo.h"
|
||||
#include "utility/messaging/type/history/MessageHistoryUndo.h"
|
||||
|
||||
QtContextMenu* QtContextMenu::s_instance;
|
||||
|
||||
@@ -103,12 +103,12 @@ void QtContextMenu::show()
|
||||
|
||||
void QtContextMenu::undoActionTriggered()
|
||||
{
|
||||
MessageUndo().dispatch();
|
||||
MessageHistoryUndo().dispatch();
|
||||
}
|
||||
|
||||
void QtContextMenu::redoActionTriggered()
|
||||
{
|
||||
MessageRedo().dispatch();
|
||||
MessageHistoryRedo().dispatch();
|
||||
}
|
||||
|
||||
void QtContextMenu::copyFullPathActionTriggered()
|
||||
|
||||
@@ -133,12 +133,12 @@ void QtMainView::updateRecentProjectMenu()
|
||||
);
|
||||
}
|
||||
|
||||
void QtMainView::updateHistoryMenu(const std::vector<SearchMatch>& history)
|
||||
void QtMainView::updateHistoryMenu(const std::vector<std::shared_ptr<MessageBase>>& historyMenuItems)
|
||||
{
|
||||
m_onQtThread(
|
||||
[=]()
|
||||
{
|
||||
m_window->updateHistoryMenu(history);
|
||||
m_window->updateHistoryMenu(historyMenuItems);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ public:
|
||||
virtual void activateWindow();
|
||||
|
||||
virtual void updateRecentProjectMenu();
|
||||
virtual void updateHistoryMenu(const std::vector<SearchMatch>& history);
|
||||
virtual void updateHistoryMenu(const std::vector<std::shared_ptr<MessageBase>>& historyMenuItems);
|
||||
virtual void updateBookmarksMenu(const std::vector<std::shared_ptr<Bookmark>>& bookmarks);
|
||||
|
||||
private:
|
||||
|
||||
@@ -29,6 +29,10 @@
|
||||
#include "utility/file/FileSystem.h"
|
||||
#include "utility/logging/logging.h"
|
||||
#include "utility/messaging/type/error/MessageErrorsHelpMessage.h"
|
||||
#include "utility/messaging/type/history/MessageHistoryRedo.h"
|
||||
#include "utility/messaging/type/history/MessageHistoryUndo.h"
|
||||
#include "utility/messaging/type/MessageActivateAll.h"
|
||||
#include "utility/messaging/type/MessageActivateBase.h"
|
||||
#include "utility/messaging/type/MessageActivateBookmark.h"
|
||||
#include "utility/messaging/type/MessageCodeReference.h"
|
||||
#include "utility/messaging/type/MessageDisplayBookmarkCreator.h"
|
||||
@@ -37,11 +41,8 @@
|
||||
#include "utility/messaging/type/MessageFind.h"
|
||||
#include "utility/messaging/type/MessageInterruptTasks.h"
|
||||
#include "utility/messaging/type/MessageLoadProject.h"
|
||||
#include "utility/messaging/type/MessageRedo.h"
|
||||
#include "utility/messaging/type/MessageRefresh.h"
|
||||
#include "utility/messaging/type/MessageResetZoom.h"
|
||||
#include "utility/messaging/type/MessageSearch.h"
|
||||
#include "utility/messaging/type/MessageUndo.h"
|
||||
#include "utility/messaging/type/MessageWindowClosed.h"
|
||||
#include "utility/messaging/type/MessageZoom.h"
|
||||
#include "utility/ResourcePaths.h"
|
||||
@@ -83,12 +84,12 @@ bool MouseReleaseFilter::eventFilter(QObject* obj, QEvent* event)
|
||||
|
||||
if (mouseEvent->button() == m_backButton)
|
||||
{
|
||||
MessageUndo().dispatch();
|
||||
MessageHistoryUndo().dispatch();
|
||||
return true;
|
||||
}
|
||||
else if (mouseEvent->button() == m_forwardButton)
|
||||
{
|
||||
MessageRedo().dispatch();
|
||||
MessageHistoryRedo().dispatch();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -344,9 +345,9 @@ void QtMainWindow::forceEnterLicense(LicenseChecker::LicenseState state)
|
||||
connect(window, &QtWindow::canceled, dynamic_cast<QApplication*>(QCoreApplication::instance()), &QApplication::quit);
|
||||
}
|
||||
|
||||
void QtMainWindow::updateHistoryMenu(const std::vector<SearchMatch>& history)
|
||||
void QtMainWindow::updateHistoryMenu(const std::vector<std::shared_ptr<MessageBase>>& historyMenuItems)
|
||||
{
|
||||
m_history = history;
|
||||
m_history = historyMenuItems;
|
||||
setupHistoryMenu();
|
||||
}
|
||||
|
||||
@@ -394,7 +395,7 @@ void QtMainWindow::keyPressEvent(QKeyEvent* event)
|
||||
switch (event->key())
|
||||
{
|
||||
case Qt::Key_Backspace:
|
||||
MessageUndo().dispatch();
|
||||
MessageHistoryUndo().dispatch();
|
||||
break;
|
||||
|
||||
case Qt::Key_Escape:
|
||||
@@ -626,7 +627,7 @@ void QtMainWindow::codeReferenceNext()
|
||||
|
||||
void QtMainWindow::overview()
|
||||
{
|
||||
MessageSearch({ SearchMatch::createCommand(SearchMatch::COMMAND_ALL) }).dispatch();
|
||||
MessageActivateAll().dispatch();
|
||||
}
|
||||
|
||||
void QtMainWindow::closeWindow()
|
||||
@@ -659,12 +660,12 @@ void QtMainWindow::forceRefresh()
|
||||
|
||||
void QtMainWindow::undo()
|
||||
{
|
||||
MessageUndo().dispatch();
|
||||
MessageHistoryUndo().dispatch();
|
||||
}
|
||||
|
||||
void QtMainWindow::redo()
|
||||
{
|
||||
MessageRedo().dispatch();
|
||||
MessageHistoryRedo().dispatch();
|
||||
}
|
||||
|
||||
void QtMainWindow::zoomIn()
|
||||
@@ -755,9 +756,7 @@ void QtMainWindow::openHistoryAction()
|
||||
QAction* action = qobject_cast<QAction*>(sender());
|
||||
if (action)
|
||||
{
|
||||
MessageSearch msg({ m_history[action->data().toInt()] });
|
||||
msg.isFromSearch = false;
|
||||
msg.dispatch();
|
||||
m_history[action->data().toInt()]->dispatch();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -886,7 +885,13 @@ void QtMainWindow::setupHistoryMenu()
|
||||
|
||||
for (size_t i = 0; i < m_history.size(); i++)
|
||||
{
|
||||
SearchMatch& match = m_history[i];
|
||||
MessageActivateBase* msg = dynamic_cast<MessageActivateBase*>(m_history[i].get());
|
||||
if (!msg)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
const SearchMatch match = msg->getSearchMatches()[0];
|
||||
const std::wstring name = utility::elide(match.getFullName(), utility::ELIDE_RIGHT, 50);
|
||||
|
||||
QAction* action = new QAction();
|
||||
|
||||
@@ -75,7 +75,7 @@ public:
|
||||
|
||||
void forceEnterLicense(LicenseChecker::LicenseState state);
|
||||
|
||||
void updateHistoryMenu(const std::vector<SearchMatch>& history);
|
||||
void updateHistoryMenu(const std::vector<std::shared_ptr<MessageBase>>& historyMenuItems);
|
||||
void updateBookmarksMenu(const std::vector<std::shared_ptr<Bookmark>>& bookmarks);
|
||||
|
||||
void setContentEnabled(bool enabled);
|
||||
@@ -183,7 +183,7 @@ private:
|
||||
QAction* m_viewSeparator;
|
||||
|
||||
QMenu* m_historyMenu;
|
||||
std::vector<SearchMatch> m_history;
|
||||
std::vector<std::shared_ptr<MessageBase>> m_history;
|
||||
|
||||
QMenu* m_bookmarksMenu;
|
||||
std::vector<std::shared_ptr<Bookmark>> m_bookmarks;
|
||||
|
||||
Reference in New Issue
Block a user