GUI Error level WARN class
This commit is contained in:
21
src/errorhandle/GUIErrorLW.cpp
Normal file
21
src/errorhandle/GUIErrorLW.cpp
Normal file
@@ -0,0 +1,21 @@
|
||||
//
|
||||
// Created by Krad on 2021/12/17.
|
||||
//
|
||||
|
||||
#include <src/event/EventCenter.h>
|
||||
#include "GUIErrorLW.h"
|
||||
#include <QChar>
|
||||
|
||||
void GUIErrorLW::parse(const QString &errorMsg) {
|
||||
char s[4];
|
||||
s[0] = errorMsg.data()[0].toLatin1();
|
||||
s[1] = errorMsg.data()[1].toLatin1();
|
||||
s[2] = errorMsg.data()[2].toLatin1();
|
||||
s[3] = errorMsg.data()[3].toLatin1();
|
||||
int * v = (int*)s;
|
||||
value = *v;
|
||||
}
|
||||
|
||||
void GUIErrorLW::handle() {
|
||||
EventCenter::Default()->triggerEvent(WarnStateFlagChange, nullptr,(QObject*)&value);
|
||||
}
|
||||
42
src/errorhandle/GUIErrorLW.h
Normal file
42
src/errorhandle/GUIErrorLW.h
Normal file
@@ -0,0 +1,42 @@
|
||||
//
|
||||
// Created by Krad on 2021/12/17.
|
||||
//
|
||||
|
||||
#ifndef GUI_GUIERRORLW_H
|
||||
#define GUI_GUIERRORLW_H
|
||||
|
||||
#include "GUIErrorBase.h"
|
||||
#include <QVariant>
|
||||
class GUIErrorLW :public GUIErrorBase {
|
||||
public:
|
||||
GUIErrorLW() =default;
|
||||
|
||||
static const QStringList& getWARNMessages(){
|
||||
static QStringList message;
|
||||
if (message.isEmpty())
|
||||
{
|
||||
for (int i = 0; i < 32; ++i) {
|
||||
message<<QString("message %1!").arg(i);
|
||||
}
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
/**
|
||||
* parse error object from error msg
|
||||
* @param errorMsg
|
||||
*/
|
||||
void parse(const QString& errorMsg) override ;
|
||||
|
||||
/**
|
||||
* handle error, should be implement in sub class
|
||||
*/
|
||||
void handle() override;
|
||||
|
||||
private:
|
||||
QVariant value;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif //GUI_GUIERRORLW_H
|
||||
Reference in New Issue
Block a user