ui: switch to single file mode with snippet maximize
* switch back to snippet view with snippet button in file title bar * use new title bar widget in single view as well * restore view mode on undo, store current view mode for every message id (added id to message) * treat view mode switch as adapt message on undo stack * fixed crash after snippet expansion * fixed hatching in file title not shown
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
#include "utility/messaging/MessageBase.h"
|
||||
|
||||
Id MessageBase::s_nextId = 1;
|
||||
@@ -4,11 +4,14 @@
|
||||
#include <ostream>
|
||||
#include <sstream>
|
||||
|
||||
#include "utility/types.h"
|
||||
|
||||
class MessageBase
|
||||
{
|
||||
public:
|
||||
MessageBase()
|
||||
: m_isParallel(false)
|
||||
: m_id(s_nextId++)
|
||||
, m_isParallel(false)
|
||||
, m_isReplayed(false)
|
||||
, m_sendAsTask(true)
|
||||
, m_keepContent(false)
|
||||
@@ -24,6 +27,11 @@ public:
|
||||
virtual std::string getType() const = 0;
|
||||
virtual void dispatch() = 0;
|
||||
|
||||
Id getId() const
|
||||
{
|
||||
return m_id;
|
||||
}
|
||||
|
||||
bool sendAsTask() const
|
||||
{
|
||||
return m_sendAsTask;
|
||||
@@ -95,6 +103,10 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
static size_t s_nextId;
|
||||
|
||||
Id m_id;
|
||||
|
||||
bool m_isParallel;
|
||||
bool m_isReplayed;
|
||||
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
#include "utility/messaging/MessageListenerBase.h"
|
||||
|
||||
uint MessageListenerBase::s_nextId = 0;
|
||||
Id MessageListenerBase::s_nextId = 1;
|
||||
|
||||
@@ -26,7 +26,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
uint getId() const
|
||||
Id getId() const
|
||||
{
|
||||
return m_id;
|
||||
}
|
||||
@@ -57,9 +57,9 @@ private:
|
||||
virtual std::string doGetType() const = 0;
|
||||
virtual void doHandleMessageBase(MessageBase*) = 0;
|
||||
|
||||
static uint s_nextId;
|
||||
static Id s_nextId;
|
||||
|
||||
uint m_id;
|
||||
Id m_id;
|
||||
bool m_alive;
|
||||
};
|
||||
|
||||
|
||||
@@ -64,12 +64,12 @@ void MessageQueue::unregisterListener(MessageListenerBase* listener)
|
||||
LOG_ERROR("Listener was not found");
|
||||
}
|
||||
|
||||
MessageListenerBase* MessageQueue::getListenerById(const uint id) const
|
||||
MessageListenerBase* MessageQueue::getListenerById(Id listenerId) const
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_listenersMutex);
|
||||
for (size_t i = 0; i < m_listeners.size(); i++)
|
||||
{
|
||||
if (m_listeners[i]->getId() == id)
|
||||
if (m_listeners[i]->getId() == listenerId)
|
||||
{
|
||||
return m_listeners[i];
|
||||
}
|
||||
@@ -284,7 +284,7 @@ void MessageQueue::sendMessageAsTask(std::shared_ptr<MessageBase> message, bool
|
||||
|
||||
if (listener->getType() == message->getType())
|
||||
{
|
||||
uint listenerId = listener->getId();
|
||||
Id listenerId = listener->getId();
|
||||
taskGroup->addTask(std::make_shared<TaskLambda>(
|
||||
[listenerId, message]()
|
||||
{
|
||||
|
||||
@@ -24,7 +24,7 @@ public:
|
||||
void registerListener(MessageListenerBase* listener);
|
||||
void unregisterListener(MessageListenerBase* listener);
|
||||
|
||||
MessageListenerBase* getListenerById(const uint id) const;
|
||||
MessageListenerBase* getListenerById(Id listenerId) const;
|
||||
|
||||
void addMessageFilter(std::shared_ptr<MessageFilter> filter);
|
||||
|
||||
|
||||
@@ -12,20 +12,30 @@ public:
|
||||
{
|
||||
FILE_MINIMIZED,
|
||||
FILE_SNIPPETS,
|
||||
FILE_MAXIMIZED,
|
||||
FILE_DEFAULT_FOR_MODE
|
||||
FILE_MAXIMIZED
|
||||
};
|
||||
|
||||
enum ViewMode
|
||||
{
|
||||
VIEW_LIST,
|
||||
VIEW_SINGLE,
|
||||
VIEW_CURRENT
|
||||
};
|
||||
|
||||
MessageChangeFileView(
|
||||
const FilePath& filePath,
|
||||
FileState state,
|
||||
ViewMode viewMode,
|
||||
bool needsData,
|
||||
bool showErrors
|
||||
bool showErrors,
|
||||
bool switchesViewMode = false
|
||||
)
|
||||
: filePath(filePath)
|
||||
, state(state)
|
||||
, viewMode(viewMode)
|
||||
, needsData(needsData)
|
||||
, showErrors(showErrors)
|
||||
, switchesViewMode(switchesViewMode)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -41,7 +51,13 @@ public:
|
||||
case FILE_MINIMIZED: os << "minimize"; break;
|
||||
case FILE_SNIPPETS: os << "snippets"; break;
|
||||
case FILE_MAXIMIZED: os << "maximize"; break;
|
||||
case FILE_DEFAULT_FOR_MODE: os << "default"; break;
|
||||
}
|
||||
|
||||
switch (viewMode)
|
||||
{
|
||||
case VIEW_LIST: os << ", list"; break;
|
||||
case VIEW_SINGLE: os << ", single"; break;
|
||||
case VIEW_CURRENT: os << ", current"; break;
|
||||
}
|
||||
|
||||
if (needsData)
|
||||
@@ -50,11 +66,12 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
FilePath filePath;
|
||||
FileState state;
|
||||
|
||||
bool needsData;
|
||||
bool showErrors;
|
||||
const FilePath filePath;
|
||||
const FileState state;
|
||||
const ViewMode viewMode;
|
||||
const bool needsData;
|
||||
const bool showErrors;
|
||||
const bool switchesViewMode;
|
||||
};
|
||||
|
||||
#endif // MESSAGE_CHANGE_FILE_VIEW_H
|
||||
|
||||
Reference in New Issue
Block a user