Aria 2.0.0
C++23 MVVM framework (C++20 minimum) — reactive, coroutine-first, ABI-layered
Loading...
Searching...
No Matches
qt_adapter.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "aria/abi/export.hpp"
6#include "qt_view.hpp"
7
8#include <cstdint>
9#include <memory>
10#include <stdexcept>
11
13
31public:
33 ~QtAdapter() override;
34
35 [[nodiscard]] std::string_view platform_name() const noexcept override {
36 return "qt6";
37 }
38
39 // ── Handle → IView ─────────────────────────────────────────────────────
62 [[nodiscard]] QtView& view_for(QObject* obj);
63
64 // ── Text ───────────────────────────────────────────────────────────────
65 void set_text(binding::IView& v, std::string_view text) override;
66 [[nodiscard]] std::string get_text(binding::IView& v) override;
68 std::function<void(std::string_view)> cb) override;
69
70 // ── Bool ───────────────────────────────────────────────────────────────
71 void set_bool(binding::IView& v, bool value) override;
72 [[nodiscard]] bool get_bool(binding::IView& v) override;
74 std::function<void(bool)> cb) override;
75
76 // ── Int ────────────────────────────────────────────────────────────────
80 void set_int(binding::IView& v, int value) override;
81 [[nodiscard]] int get_int(binding::IView& v) override;
83 std::function<void(int)> cb) override;
84
85 // ── Int64 ──────────────────────────────────────────────────────────────
86 // Qt widgets don't speak int64 natively; these forward to set_int/get_int
87 // with saturating conversion and a diagnostic on overflow. Hosts that need the
88 // full 64-bit range (timestamps, big IDs) should use a QLineEdit bound
89 // via bind_text_converted with a user-supplied string<->int64 converter.
90 void set_int64(binding::IView& v, std::int64_t value) override;
91 [[nodiscard]] std::int64_t get_int64(binding::IView& v) override;
93 std::function<void(std::int64_t)> cb) override;
94
95 // ── UInt64 ─────────────────────────────────────────────────────────────
96 // Same forwarding strategy as int64 — Qt numeric widgets top out at int.
97 void set_uint64(binding::IView& v, std::uint64_t value) override;
98 [[nodiscard]] std::uint64_t get_uint64(binding::IView& v) override;
100 std::function<void(std::uint64_t)> cb) override;
101
102 // ── Float ──────────────────────────────────────────────────────────────
103 // Forwards to set_double/get_double; the narrowing is harmless for the
104 // QDoubleSpinBox range.
105 void set_float(binding::IView& v, float value) override;
106 [[nodiscard]] float get_float(binding::IView& v) override;
108 std::function<void(float)> cb) override;
109
110 // ── Double ─────────────────────────────────────────────────────────────
111 void set_double(binding::IView& v, double value) override;
112 [[nodiscard]] double get_double(binding::IView& v) override;
114 std::function<void(double)> cb) override;
115
116 // ── Visibility / enabled ───────────────────────────────────────────────
117 void set_visible(binding::IView& v, bool visible) override;
118 void set_enabled(binding::IView& v, bool enabled) override;
119
120 // ── Click ──────────────────────────────────────────────────────────────
121 ::aria::Subscription on_click(binding::IView& v, std::function<void()> cb) override;
122
123private:
124 struct Impl;
125 std::shared_ptr<Impl> p_;
126};
127
128} // namespace aria::adapters::qt6
RAII handle to a single subscription.
Definition subscription.hpp:44
void set_enabled(binding::IView &v, bool enabled) override
::aria::Subscription on_uint64_changed(binding::IView &v, std::function< void(std::uint64_t)> cb) override
::aria::Subscription on_double_changed(binding::IView &v, std::function< void(double)> cb) override
void set_int64(binding::IView &v, std::int64_t value) override
std::uint64_t get_uint64(binding::IView &v) override
::aria::Subscription on_int64_changed(binding::IView &v, std::function< void(std::int64_t)> cb) override
::aria::Subscription on_click(binding::IView &v, std::function< void()> cb) override
void set_int(binding::IView &v, int value) override
QComboBox uses its current index, suitable for fixed option lists.
void set_visible(binding::IView &v, bool visible) override
float get_float(binding::IView &v) override
QtView & view_for(QObject *obj)
Wrap a native QObject* (typically a QWidget) as an IView owned by this adapter.
std::int64_t get_int64(binding::IView &v) override
::aria::Subscription on_bool_changed(binding::IView &v, std::function< void(bool)> cb) override
std::string get_text(binding::IView &v) override
void set_uint64(binding::IView &v, std::uint64_t value) override
::aria::Subscription on_int_changed(binding::IView &v, std::function< void(int)> cb) override
bool get_bool(binding::IView &v) override
double get_double(binding::IView &v) override
std::string_view platform_name() const noexcept override
Definition qt_adapter.hpp:35
int get_int(binding::IView &v) override
void set_text(binding::IView &v, std::string_view text) override
::aria::Subscription on_text_changed(binding::IView &v, std::function< void(std::string_view)> cb) override
void set_double(binding::IView &v, double value) override
void set_float(binding::IView &v, float value) override
void set_bool(binding::IView &v, bool value) override
::aria::Subscription on_float_changed(binding::IView &v, std::function< void(float)> cb) override
Wraps any QWidget* (or QObject*) as an IView.
Definition qt_view.hpp:25
Abstract platform adapter — knows how to read/write/observe widgets.
Definition view_adapter.hpp:80
Abstract platform widget reference.
Definition view_adapter.hpp:28
#define ARIA_QT6_API
Definition export.hpp:57
Definition qt_adapter.hpp:12