logic: Moved all error handling logic into ErrorController (issue #577)
* Handle all error related messages in ErrorController * Moved error filter state from Storage to ErrorController * Moved all error related messages to type/error subdirectory * Enable all errors shown by default * Always show unfiltered error count in status bar and overview * Fixed all errors shown again when changing error filter on errors for file
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
#ifndef MESSAGE_FILTER_ERROR_COUNT_UPDATE_H
|
||||
#define MESSAGE_FILTER_ERROR_COUNT_UPDATE_H
|
||||
|
||||
#include "utility/messaging/MessageFilter.h"
|
||||
#include "utility/messaging/type/error/MessageErrorCountUpdate.h"
|
||||
|
||||
class MessageFilterErrorCountUpdate
|
||||
: public MessageFilter
|
||||
{
|
||||
void filter(MessageQueue::MessageBufferType* messageBuffer) override
|
||||
{
|
||||
if (messageBuffer->size() < 2)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
MessageBase* message = messageBuffer->front().get();
|
||||
if (message->getType() == MessageErrorCountUpdate::getStaticType())
|
||||
{
|
||||
for (auto it = messageBuffer->begin() + 1; it != messageBuffer->end(); it++)
|
||||
{
|
||||
if ((*it)->getType() == MessageErrorCountUpdate::getStaticType())
|
||||
{
|
||||
messageBuffer->pop_front();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
#endif // MESSAGE_FILTER_ERROR_COUNT_UPDATE_H
|
||||
@@ -1,41 +0,0 @@
|
||||
#ifndef MESSAGE_FILTER_NEW_ERRORS_H
|
||||
#define MESSAGE_FILTER_NEW_ERRORS_H
|
||||
|
||||
#include "utility/messaging/MessageFilter.h"
|
||||
#include "utility/messaging/type/MessageNewErrors.h"
|
||||
|
||||
class MessageFilterNewErrors
|
||||
: public MessageFilter
|
||||
{
|
||||
void filter(MessageQueue::MessageBufferType* messageBuffer) override
|
||||
{
|
||||
if (messageBuffer->size() < 2)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
MessageBase* message = messageBuffer->front().get();
|
||||
if (message->getType() == MessageNewErrors::getStaticType())
|
||||
{
|
||||
for (auto it = messageBuffer->begin() + 1; it != messageBuffer->end(); it++)
|
||||
{
|
||||
if ((*it)->getType() == MessageNewErrors::getStaticType())
|
||||
{
|
||||
MessageNewErrors* frontErrorsMessage = dynamic_cast<MessageNewErrors*>(message);
|
||||
MessageNewErrors* backErrorsMessage = dynamic_cast<MessageNewErrors*>(it->get());
|
||||
|
||||
backErrorsMessage->errors.insert(
|
||||
backErrorsMessage->errors.begin(),
|
||||
frontErrorsMessage->errors.begin(),
|
||||
frontErrorsMessage->errors.end()
|
||||
);
|
||||
|
||||
messageBuffer->pop_front();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
#endif // MESSAGE_FILTER_NEW_ERRORS_H
|
||||
@@ -1,21 +0,0 @@
|
||||
#ifndef MESSAGE_CLEAR_ERROR_COUNT_H
|
||||
#define MESSAGE_CLEAR_ERROR_COUNT_H
|
||||
|
||||
#include "utility/messaging/Message.h"
|
||||
|
||||
class MessageClearErrorCount
|
||||
: public Message<MessageClearErrorCount>
|
||||
{
|
||||
public:
|
||||
MessageClearErrorCount()
|
||||
{
|
||||
setSendAsTask(false);
|
||||
}
|
||||
|
||||
static const std::string getStaticType()
|
||||
{
|
||||
return "MessageClearErrorCount";
|
||||
}
|
||||
};
|
||||
|
||||
#endif // MESSAGE_CLEAR_ERROR_COUNT_H
|
||||
@@ -1,26 +0,0 @@
|
||||
#ifndef MESSAGE_ERROR_FILTER_CHANGED_H
|
||||
#define MESSAGE_ERROR_FILTER_CHANGED_H
|
||||
|
||||
#include "utility/messaging/Message.h"
|
||||
#include "data/ErrorFilter.h"
|
||||
|
||||
class MessageErrorFilterChanged
|
||||
: public Message<MessageErrorFilterChanged>
|
||||
{
|
||||
public:
|
||||
MessageErrorFilterChanged(const ErrorFilter& filter, bool showErrors)
|
||||
: errorFilter(filter)
|
||||
, showErrors(showErrors)
|
||||
{
|
||||
}
|
||||
|
||||
static const std::string getStaticType()
|
||||
{
|
||||
return "MessageErrorFilterChanged";
|
||||
}
|
||||
|
||||
const ErrorFilter errorFilter;
|
||||
const bool showErrors;
|
||||
};
|
||||
|
||||
#endif // MESSAGE_ERROR_FILTER_CHANGED_H
|
||||
@@ -1,23 +0,0 @@
|
||||
#ifndef MESSAGE_SHOW_ERROR_HELP_MESSAGE_H
|
||||
#define MESSAGE_SHOW_ERROR_HELP_MESSAGE_H
|
||||
|
||||
#include "utility/messaging/Message.h"
|
||||
|
||||
class MessageShowErrorHelpMessage:
|
||||
public Message<MessageShowErrorHelpMessage>
|
||||
{
|
||||
public:
|
||||
MessageShowErrorHelpMessage(bool force = false)
|
||||
: force(force)
|
||||
{
|
||||
}
|
||||
|
||||
static const std::string getStaticType()
|
||||
{
|
||||
return "MessageShowErrorHelpMessage";
|
||||
}
|
||||
|
||||
const bool force;
|
||||
};
|
||||
|
||||
#endif // MESSAGE_SHOW_ERROR_HELP_MESSAGE_H
|
||||
@@ -1,42 +0,0 @@
|
||||
#ifndef MESSAGE_SHOW_ERRORS_H
|
||||
#define MESSAGE_SHOW_ERRORS_H
|
||||
|
||||
#include "utility/messaging/Message.h"
|
||||
|
||||
#include "data/ErrorCountInfo.h"
|
||||
|
||||
class MessageShowErrors
|
||||
: public Message<MessageShowErrors>
|
||||
{
|
||||
public:
|
||||
MessageShowErrors(ErrorCountInfo errorCount)
|
||||
: errorCount(errorCount)
|
||||
, errorId(0)
|
||||
{
|
||||
}
|
||||
|
||||
MessageShowErrors(const std::vector<Id>& errorIds)
|
||||
: errorIds(errorIds)
|
||||
, errorId(0)
|
||||
, showsOnlyErrorIds(true)
|
||||
{
|
||||
}
|
||||
|
||||
MessageShowErrors(Id errorId)
|
||||
: errorId(errorId)
|
||||
{
|
||||
}
|
||||
|
||||
static const std::string getStaticType()
|
||||
{
|
||||
return "MessageShowErrors";
|
||||
}
|
||||
|
||||
const ErrorCountInfo errorCount;
|
||||
const std::vector<Id> errorIds;
|
||||
const Id errorId;
|
||||
|
||||
bool showsOnlyErrorIds = false;
|
||||
};
|
||||
|
||||
#endif // MESSAGE_SHOW_ERRORS_H
|
||||
@@ -1,24 +0,0 @@
|
||||
#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<MessageShowErrorsForFile>
|
||||
{
|
||||
public:
|
||||
MessageShowErrorsForFile(const FilePath& filePath)
|
||||
: filePath(filePath)
|
||||
{
|
||||
}
|
||||
|
||||
static const std::string getStaticType()
|
||||
{
|
||||
return "MessageShowErrorsForFile";
|
||||
}
|
||||
|
||||
const FilePath filePath;
|
||||
};
|
||||
|
||||
#endif // MESSAGE_SHOW_ERRORS_FOR_FILE_H
|
||||
@@ -0,0 +1,26 @@
|
||||
#ifndef MESSAGE_ACTIVATE_ERRORS_H
|
||||
#define MESSAGE_ACTIVATE_ERRORS_H
|
||||
|
||||
#include "data/ErrorFilter.h"
|
||||
#include "utility/messaging/Message.h"
|
||||
|
||||
class MessageActivateErrors
|
||||
: public Message<MessageActivateErrors>
|
||||
{
|
||||
public:
|
||||
static const std::string getStaticType()
|
||||
{
|
||||
return "MessageActivateErrors";
|
||||
}
|
||||
|
||||
MessageActivateErrors(const ErrorFilter& filter, const FilePath& file = FilePath())
|
||||
: filter(filter)
|
||||
, file(file)
|
||||
{
|
||||
}
|
||||
|
||||
const ErrorFilter filter;
|
||||
const FilePath file;
|
||||
};
|
||||
|
||||
#endif // MESSAGE_ACTIVATE_ERRORS_H
|
||||
@@ -0,0 +1,21 @@
|
||||
#ifndef MESSAGE_ERROR_COUNT_CLEAR_H
|
||||
#define MESSAGE_ERROR_COUNT_CLEAR_H
|
||||
|
||||
#include "utility/messaging/Message.h"
|
||||
|
||||
class MessageErrorCountClear
|
||||
: public Message<MessageErrorCountClear>
|
||||
{
|
||||
public:
|
||||
static const std::string getStaticType()
|
||||
{
|
||||
return "MessageErrorCountClear";
|
||||
}
|
||||
|
||||
MessageErrorCountClear()
|
||||
{
|
||||
setSendAsTask(false);
|
||||
}
|
||||
};
|
||||
|
||||
#endif // MESSAGE_ERROR_COUNT_CLEAR_H
|
||||
@@ -0,0 +1,26 @@
|
||||
#ifndef MESSAGE_ERROR_COUNT_UPDATE_H
|
||||
#define MESSAGE_ERROR_COUNT_UPDATE_H
|
||||
|
||||
#include "utility/messaging/Message.h"
|
||||
|
||||
#include "data/ErrorCountInfo.h"
|
||||
|
||||
class MessageErrorCountUpdate
|
||||
: public Message<MessageErrorCountUpdate>
|
||||
{
|
||||
public:
|
||||
static const std::string getStaticType()
|
||||
{
|
||||
return "MessageErrorCountUpdate";
|
||||
}
|
||||
|
||||
MessageErrorCountUpdate(const ErrorCountInfo& errorCount)
|
||||
: errorCount(errorCount)
|
||||
{
|
||||
setSendAsTask(false);
|
||||
}
|
||||
|
||||
const ErrorCountInfo errorCount;
|
||||
};
|
||||
|
||||
#endif // MESSAGE_ERROR_COUNT_UPDATE_H
|
||||
@@ -0,0 +1,20 @@
|
||||
#ifndef MESSAGE_ERRORS_ALL_H
|
||||
#define MESSAGE_ERRORS_ALL_H
|
||||
|
||||
#include "utility/messaging/Message.h"
|
||||
|
||||
class MessageErrorsAll:
|
||||
public Message<MessageErrorsAll>
|
||||
{
|
||||
public:
|
||||
static const std::string getStaticType()
|
||||
{
|
||||
return "MessageErrorsAll";
|
||||
}
|
||||
|
||||
MessageErrorsAll()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
#endif // MESSAGE_ERRORS_ALL_H
|
||||
@@ -0,0 +1,23 @@
|
||||
#ifndef MESSAGE_ERRORS_FOR_FILE_H
|
||||
#define MESSAGE_ERRORS_FOR_FILE_H
|
||||
|
||||
#include "utility/messaging/Message.h"
|
||||
|
||||
class MessageErrorsForFile:
|
||||
public Message<MessageErrorsForFile>
|
||||
{
|
||||
public:
|
||||
static const std::string getStaticType()
|
||||
{
|
||||
return "MessageErrorsForFile";
|
||||
}
|
||||
|
||||
MessageErrorsForFile(const FilePath& file)
|
||||
: file(file)
|
||||
{
|
||||
}
|
||||
|
||||
const FilePath& file;
|
||||
};
|
||||
|
||||
#endif // MESSAGE_ERRORS_FOR_FILE_H
|
||||
@@ -0,0 +1,23 @@
|
||||
#ifndef MESSAGE_ERRORS_HELP_MESSAGE_H
|
||||
#define MESSAGE_ERRORS_HELP_MESSAGE_H
|
||||
|
||||
#include "utility/messaging/Message.h"
|
||||
|
||||
class MessageErrorsHelpMessage:
|
||||
public Message<MessageErrorsHelpMessage>
|
||||
{
|
||||
public:
|
||||
static const std::string getStaticType()
|
||||
{
|
||||
return "MessageErrorsHelpMessage";
|
||||
}
|
||||
|
||||
MessageErrorsHelpMessage(bool force = false)
|
||||
: force(force)
|
||||
{
|
||||
}
|
||||
|
||||
const bool force;
|
||||
};
|
||||
|
||||
#endif // MESSAGE_ERRORS_HELP_MESSAGE_H
|
||||
@@ -0,0 +1,23 @@
|
||||
#ifndef MESSAGE_SHOW_ERROR_H
|
||||
#define MESSAGE_SHOW_ERROR_H
|
||||
|
||||
#include "utility/messaging/Message.h"
|
||||
|
||||
class MessageShowError
|
||||
: public Message<MessageShowError>
|
||||
{
|
||||
public:
|
||||
static const std::string getStaticType()
|
||||
{
|
||||
return "MessageShowError";
|
||||
}
|
||||
|
||||
MessageShowError(Id errorId)
|
||||
: errorId(errorId)
|
||||
{
|
||||
}
|
||||
|
||||
const Id errorId;
|
||||
};
|
||||
|
||||
#endif // MESSAGE_SHOW_ERROR_H
|
||||
Reference in New Issue
Block a user