// Copyright 2015 - 2026, GIBIS-UNIFESP and the wiRedPanda contributors
// SPDX-License-Identifier: GPL-3.0-or-later

/** \file
 * \brief File-format version constants and application version accessor.
 */

#pragma once

#include <QVersionNumber>

/// Sentinel version constants for .panda file-format migrations.
namespace Versions {

inline const QVersionNumber V_1_1 = QVersionNumber(1, 1);
inline const QVersionNumber V_1_2 = QVersionNumber(1, 2);
inline const QVersionNumber V_1_3 = QVersionNumber(1, 3);
inline const QVersionNumber V_1_4 = QVersionNumber(1, 4);
inline const QVersionNumber V_1_6 = QVersionNumber(1, 6);
inline const QVersionNumber V_1_7 = QVersionNumber(1, 7);
inline const QVersionNumber V_1_9 = QVersionNumber(1, 9);
inline const QVersionNumber V_2_4 = QVersionNumber(2, 4);
inline const QVersionNumber V_2_7 = QVersionNumber(2, 7);
inline const QVersionNumber V_3_0 = QVersionNumber(3, 0);
inline const QVersionNumber V_3_1 = QVersionNumber(3, 1);
inline const QVersionNumber V_3_3 = QVersionNumber(3, 3);
inline const QVersionNumber V_4_0 = QVersionNumber(4, 0);
inline const QVersionNumber V_4_0_1 = QVersionNumber(4, 0, 1);
inline const QVersionNumber V_4_1 = QVersionNumber(4, 1);
inline const QVersionNumber V_4_2 = QVersionNumber(4, 2);
inline const QVersionNumber V_4_3 = QVersionNumber(4, 3);
inline const QVersionNumber V_4_4 = QVersionNumber(4, 4);
inline const QVersionNumber V_4_5 = QVersionNumber(4, 5);
inline const QVersionNumber V_4_6 = QVersionNumber(4, 6);
inline const QVersionNumber V_4_7 = QVersionNumber(4, 7);
inline const QVersionNumber V_5_0 = QVersionNumber(5, 0);
inline const QVersionNumber V_5_1 = QVersionNumber(5, 1);

} // namespace Versions

/// File-format revision, independent of the application release version.
///
/// Legacy revisions are the multi-segment `Versions::V_X_Y` constants above:
/// historically they tracked the app version that introduced them, which made
/// log/dialog output ambiguous once the two concepts drifted apart.
///
/// New revisions use **monotonic single-segment integers starting at 100**
/// (`Rev100`, `Rev101`, ...).  Picking 100 as the boundary keeps the on-disk
/// encoding (`QVersionNumber`) unchanged — `QVersionNumber(100)` compares
/// greater than every legacy `Versions::V_X_Y` segment-by-segment, so existing
/// readers and version comparisons keep working unmodified.  The next real
/// format change should be `Rev100`.
namespace FormatRev {

inline const QVersionNumber current = Versions::V_5_1;

} // namespace FormatRev

/// Application version derived from the CMake-defined APP_VERSION string.
namespace AppVersion {

inline const QVersionNumber current = QVersionNumber::fromString(APP_VERSION).normalized();

} // namespace AppVersion
