valentina/src/libs/vmisc/customevents.h

129 lines
3.7 KiB
C
Raw Normal View History

/************************************************************************
**
** @file customevents.h
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 23 6, 2014
**
** @brief
** @copyright
** This source code is part of the Valentina project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2013-2015 Valentina project
** <https://gitlab.com/smart-pattern/valentina> All Rights Reserved.
**
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#ifndef CUSTOMEVENTS_H
#define CUSTOMEVENTS_H
#include <QEvent>
#include <QString>
2023-07-13 16:49:20 +02:00
enum CustomEventType
{
UndoEventType = 1,
LiteParseEventType = 2,
FitBestCurrentEventType = 3,
2020-11-20 12:18:38 +01:00
WarningMessageEventType = 4,
};
//---------------------------------------------------------------------------------------------------------------------
// Define undo event identifier
const QEvent::Type UNDO_EVENT =
static_cast<QEvent::Type>(QEvent::User + static_cast<int>(CustomEventType::UndoEventType));
2021-09-24 13:57:30 +02:00
class UndoEvent : public QEvent
{
public:
2023-07-13 16:49:20 +02:00
UndoEvent();
~UndoEvent() override = default;
};
2023-07-13 16:49:20 +02:00
inline UndoEvent::UndoEvent()
: QEvent(UNDO_EVENT)
{
}
//---------------------------------------------------------------------------------------------------------------------
const QEvent::Type LITE_PARSE_EVENT =
static_cast<QEvent::Type>(QEvent::User + static_cast<int>(CustomEventType::LiteParseEventType));
2021-09-24 13:57:30 +02:00
class LiteParseEvent : public QEvent
{
public:
2023-07-13 16:49:20 +02:00
LiteParseEvent();
~LiteParseEvent() override = default;
};
2023-07-13 16:49:20 +02:00
inline LiteParseEvent::LiteParseEvent()
: QEvent(LITE_PARSE_EVENT)
{
}
//---------------------------------------------------------------------------------------------------------------------
const QEvent::Type FIT_BEST_CURRENT_EVENT =
static_cast<QEvent::Type>(QEvent::User + static_cast<int>(CustomEventType::FitBestCurrentEventType));
2021-09-24 13:57:30 +02:00
class FitBestCurrentEvent : public QEvent
{
public:
2023-07-13 16:49:20 +02:00
FitBestCurrentEvent();
~FitBestCurrentEvent() override = default;
};
2023-07-13 16:49:20 +02:00
inline FitBestCurrentEvent::FitBestCurrentEvent()
: QEvent(FIT_BEST_CURRENT_EVENT)
{
}
//---------------------------------------------------------------------------------------------------------------------
const QEvent::Type WARNING_MESSAGE_EVENT =
static_cast<QEvent::Type>(QEvent::User + static_cast<int>(CustomEventType::WarningMessageEventType));
2021-09-24 13:57:30 +02:00
2020-11-20 12:18:38 +01:00
class WarningMessageEvent : public QEvent
{
public:
2023-07-13 16:49:20 +02:00
WarningMessageEvent(const QString &message, QtMsgType severity);
~WarningMessageEvent() override = default;
2023-05-03 13:07:02 +02:00
auto Message() const -> QString;
2023-05-03 13:07:02 +02:00
auto Severity() const -> QtMsgType;
private:
QString m_message;
QtMsgType m_severity;
};
2023-07-13 16:49:20 +02:00
inline WarningMessageEvent::WarningMessageEvent(const QString &message, QtMsgType severity)
: QEvent(WARNING_MESSAGE_EVENT),
m_message(message),
m_severity(severity)
{
}
2023-05-03 13:07:02 +02:00
inline auto WarningMessageEvent::Message() const -> QString
{
return m_message;
}
2023-05-03 13:07:02 +02:00
inline auto WarningMessageEvent::Severity() const -> QtMsgType
{
return m_severity;
}
2020-03-29 19:52:26 +02:00
#endif // CUSTOMEVENTS_H