diff --git a/crates/cxx-qt-lib/build.rs b/crates/cxx-qt-lib/build.rs index c8f04b3cc..5ccec5bab 100644 --- a/crates/cxx-qt-lib/build.rs +++ b/crates/cxx-qt-lib/build.rs @@ -174,6 +174,8 @@ fn main() { "core/qvector/qvector_i64", "core/qvector/qvector_qbytearray", "core/qvector/qvector_qdate", + "core/qvector/qvector_qline", + "core/qvector/qvector_qlinef", "core/qvector/qvector_qmargins", "core/qvector/qvector_qmarginsf", "core/qvector/qvector_qpersistentmodelindex", diff --git a/crates/cxx-qt-lib/include/core/qvector.h b/crates/cxx-qt-lib/include/core/qvector.h index cf0df64f3..6821867c6 100644 --- a/crates/cxx-qt-lib/include/core/qvector.h +++ b/crates/cxx-qt-lib/include/core/qvector.h @@ -154,6 +154,8 @@ using QVector_QColor = QVector<::QColor>; #endif using QVector_QDate = QVector<::QDate>; using QVector_QDateTime = QVector<::QDateTime>; +using QVector_QLine = QVector<::QLine>; +using QVector_QLineF = QVector<::QLineF>; using QVector_QMargins = QVector<::QMargins>; using QVector_QMarginsF = QVector<::QMarginsF>; using QVector_QPersistentModelIndex = QVector<::QPersistentModelIndex>; diff --git a/crates/cxx-qt-lib/src/core/init.cpp b/crates/cxx-qt-lib/src/core/init.cpp index 670632b7d..8855c0a21 100644 --- a/crates/cxx-qt-lib/src/core/init.cpp +++ b/crates/cxx-qt-lib/src/core/init.cpp @@ -37,6 +37,10 @@ static const int register_QList_QDate = qRegisterMetaType<::QList_QDate>("QList_QDate"); static const int register_QList_QDateTime = qRegisterMetaType<::QList_QDateTime>("QList_QDateTime"); +static const int register_QList_QLine = + qRegisterMetaType<::QList_QLine>("QList_QLine"); +static const int register_QList_QLineF = + qRegisterMetaType<::QList_QLineF>("QList_QLineF"); static const int register_QList_QMargins = qRegisterMetaType<::QList_QMargins>("QList_QMargins"); static const int register_QList_QMarginsF = @@ -126,6 +130,10 @@ static const int register_QVector_QDate = qRegisterMetaType<::QVector_QDate>("QVector_QDate"); static const int register_QVector_QDateTime = qRegisterMetaType<::QVector_QDateTime>("QVector_QDateTime"); +static const int register_QVector_QLine = + qRegisterMetaType<::QVector_QLine>("QVector_QLine"); +static const int register_QVector_QLineF = + qRegisterMetaType<::QVector_QLineF>("QVector_QLineF"); static const int register_QVector_QMargins = qRegisterMetaType<::QVector_QMargins>("QVector_QMargins"); static const int register_QVector_QMarginsF = diff --git a/crates/cxx-qt-lib/src/core/qvector/generate.sh b/crates/cxx-qt-lib/src/core/qvector/generate.sh index 312ef7ce2..519400a2a 100755 --- a/crates/cxx-qt-lib/src/core/qvector/generate.sh +++ b/crates/cxx-qt-lib/src/core/qvector/generate.sh @@ -215,6 +215,8 @@ generate_bridge_qt "QByteArray" "qbytearray" generate_bridge_qt "QColor" "qcolor" generate_bridge_qt "QDate" "qdate" generate_bridge_qt "QDateTime" "qdatetime" +generate_bridge_qt "QLine" "qline" +generate_bridge_qt "QLineF" "qlinef" generate_bridge_qt "QMargins" "qmargins" generate_bridge_qt "QMarginsF" "qmarginsf" generate_bridge_qt "QPersistentModelIndex" "qpersistentmodelindex" diff --git a/crates/cxx-qt-lib/src/core/qvector/mod.rs b/crates/cxx-qt-lib/src/core/qvector/mod.rs index 71c357626..1894418fe 100644 --- a/crates/cxx-qt-lib/src/core/qvector/mod.rs +++ b/crates/cxx-qt-lib/src/core/qvector/mod.rs @@ -8,8 +8,8 @@ use crate::QColor; #[cfg(not(target_os = "emscripten"))] use crate::QDateTime; use crate::{ - QByteArray, QDate, QMargins, QMarginsF, QPersistentModelIndex, QPoint, QPointF, QRect, QRectF, - QSize, QSizeF, QString, QTime, QUrl, QVariant, + QByteArray, QDate, QLine, QLineF, QMargins, QMarginsF, QPersistentModelIndex, QPoint, QPointF, + QRect, QRectF, QSize, QSizeF, QString, QTime, QUrl, QVariant, }; use core::{marker::PhantomData, mem::MaybeUninit}; use cxx::{type_id, ExternType}; @@ -355,6 +355,8 @@ impl_qvector_element!(QColor, qvector_qcolor, "QVector_QColor"); impl_qvector_element!(QDate, qvector_qdate, "QVector_QDate"); #[cfg(not(target_os = "emscripten"))] impl_qvector_element!(QDateTime, qvector_qdatetime, "QVector_QDateTime"); +impl_qvector_element!(QLine, qvector_qline, "QVector_QLine"); +impl_qvector_element!(QLineF, qvector_qlinef, "QVector_QLineF"); impl_qvector_element!(QMargins, qvector_qmargins, "QVector_QMargins"); impl_qvector_element!(QMarginsF, qvector_qmarginsf, "QVector_QMarginsF"); impl_qvector_element!( diff --git a/crates/cxx-qt-lib/src/core/qvector/qvector_qline.rs b/crates/cxx-qt-lib/src/core/qvector/qvector_qline.rs new file mode 100644 index 000000000..f421d4814 --- /dev/null +++ b/crates/cxx-qt-lib/src/core/qvector/qvector_qline.rs @@ -0,0 +1,92 @@ +// SPDX-FileCopyrightText: 2022 Klarälvdalens Datakonsult AB, a KDAB Group company +// SPDX-FileContributor: Andrew Hayzen +// +// SPDX-License-Identifier: MIT OR Apache-2.0 + +#[cxx::bridge] +pub mod ffi { + unsafe extern "C++" { + include!("cxx-qt-lib/qline.h"); + type QLine = crate::QLine; + + include!("cxx-qt-lib/qvector.h"); + type QVector_QLine = crate::QVector; + } + + unsafe extern "C++" { + #[rust_name = "cxx_clear"] + fn clear(self: &mut QVector_QLine); + #[rust_name = "cxx_contains"] + fn contains(self: &QVector_QLine, _: &QLine) -> bool; + } + + #[namespace = "rust::cxxqtlib1"] + unsafe extern "C++" { + include!("cxx-qt-lib/common.h"); + + #[rust_name = "qvector_clone_QLine"] + fn construct(_: &QVector_QLine) -> QVector_QLine; + #[rust_name = "qvector_default_QLine"] + fn construct() -> QVector_QLine; + #[rust_name = "qvector_drop_QLine"] + fn drop(_: &mut QVector_QLine); + } + + #[namespace = "rust::cxxqtlib1::qvector"] + unsafe extern "C++" { + #[rust_name = "reserve_QLine"] + fn qvectorReserve(_: &mut QVector_QLine, size: isize); + #[rust_name = "append_QLine"] + fn qvectorAppend(_: &mut QVector_QLine, _: &QLine); + #[rust_name = "get_unchecked_QLine"] + unsafe fn qvectorGetUnchecked(set: &QVector_QLine, pos: isize) -> &QLine; + #[rust_name = "index_of_QLine"] + fn qvectorIndexOf(_: &QVector_QLine, _: &QLine) -> isize; + #[rust_name = "insert_QLine"] + fn qvectorInsert(_: &mut QVector_QLine, _: isize, _: &QLine); + #[rust_name = "remove_QLine"] + fn qvectorRemove(_: &mut QVector_QLine, _: isize); + #[rust_name = "len_QLine"] + fn qvectorLen(_: &QVector_QLine) -> isize; + } +} + +pub(crate) fn append(v: &mut ffi::QVector_QLine, value: &ffi::QLine) { + ffi::append_QLine(v, value); +} + +pub(crate) fn clone(s: &ffi::QVector_QLine) -> ffi::QVector_QLine { + ffi::qvector_clone_QLine(s) +} + +pub(crate) fn reserve(v: &mut ffi::QVector_QLine, size: isize) { + ffi::reserve_QLine(v, size); +} + +pub(crate) fn default() -> ffi::QVector_QLine { + ffi::qvector_default_QLine() +} + +pub(crate) fn drop(s: &mut ffi::QVector_QLine) { + ffi::qvector_drop_QLine(s); +} + +pub(crate) unsafe fn get_unchecked(s: &ffi::QVector_QLine, pos: isize) -> &ffi::QLine { + ffi::get_unchecked_QLine(s, pos) +} + +pub(crate) fn index_of(v: &ffi::QVector_QLine, value: &ffi::QLine) -> isize { + ffi::index_of_QLine(v, value) +} + +pub(crate) fn insert(s: &mut ffi::QVector_QLine, pos: isize, value: &ffi::QLine) { + ffi::insert_QLine(s, pos, value); +} + +pub(crate) fn len(s: &ffi::QVector_QLine) -> isize { + ffi::len_QLine(s) +} + +pub(crate) fn remove(s: &mut ffi::QVector_QLine, pos: isize) { + ffi::remove_QLine(s, pos); +} diff --git a/crates/cxx-qt-lib/src/core/qvector/qvector_qlinef.rs b/crates/cxx-qt-lib/src/core/qvector/qvector_qlinef.rs new file mode 100644 index 000000000..b39a9b081 --- /dev/null +++ b/crates/cxx-qt-lib/src/core/qvector/qvector_qlinef.rs @@ -0,0 +1,92 @@ +// SPDX-FileCopyrightText: 2022 Klarälvdalens Datakonsult AB, a KDAB Group company +// SPDX-FileContributor: Andrew Hayzen +// +// SPDX-License-Identifier: MIT OR Apache-2.0 + +#[cxx::bridge] +pub mod ffi { + unsafe extern "C++" { + include!("cxx-qt-lib/qlinef.h"); + type QLineF = crate::QLineF; + + include!("cxx-qt-lib/qvector.h"); + type QVector_QLineF = crate::QVector; + } + + unsafe extern "C++" { + #[rust_name = "cxx_clear"] + fn clear(self: &mut QVector_QLineF); + #[rust_name = "cxx_contains"] + fn contains(self: &QVector_QLineF, _: &QLineF) -> bool; + } + + #[namespace = "rust::cxxqtlib1"] + unsafe extern "C++" { + include!("cxx-qt-lib/common.h"); + + #[rust_name = "qvector_clone_QLineF"] + fn construct(_: &QVector_QLineF) -> QVector_QLineF; + #[rust_name = "qvector_default_QLineF"] + fn construct() -> QVector_QLineF; + #[rust_name = "qvector_drop_QLineF"] + fn drop(_: &mut QVector_QLineF); + } + + #[namespace = "rust::cxxqtlib1::qvector"] + unsafe extern "C++" { + #[rust_name = "reserve_QLineF"] + fn qvectorReserve(_: &mut QVector_QLineF, size: isize); + #[rust_name = "append_QLineF"] + fn qvectorAppend(_: &mut QVector_QLineF, _: &QLineF); + #[rust_name = "get_unchecked_QLineF"] + unsafe fn qvectorGetUnchecked(set: &QVector_QLineF, pos: isize) -> &QLineF; + #[rust_name = "index_of_QLineF"] + fn qvectorIndexOf(_: &QVector_QLineF, _: &QLineF) -> isize; + #[rust_name = "insert_QLineF"] + fn qvectorInsert(_: &mut QVector_QLineF, _: isize, _: &QLineF); + #[rust_name = "remove_QLineF"] + fn qvectorRemove(_: &mut QVector_QLineF, _: isize); + #[rust_name = "len_QLineF"] + fn qvectorLen(_: &QVector_QLineF) -> isize; + } +} + +pub(crate) fn append(v: &mut ffi::QVector_QLineF, value: &ffi::QLineF) { + ffi::append_QLineF(v, value); +} + +pub(crate) fn clone(s: &ffi::QVector_QLineF) -> ffi::QVector_QLineF { + ffi::qvector_clone_QLineF(s) +} + +pub(crate) fn reserve(v: &mut ffi::QVector_QLineF, size: isize) { + ffi::reserve_QLineF(v, size); +} + +pub(crate) fn default() -> ffi::QVector_QLineF { + ffi::qvector_default_QLineF() +} + +pub(crate) fn drop(s: &mut ffi::QVector_QLineF) { + ffi::qvector_drop_QLineF(s); +} + +pub(crate) unsafe fn get_unchecked(s: &ffi::QVector_QLineF, pos: isize) -> &ffi::QLineF { + ffi::get_unchecked_QLineF(s, pos) +} + +pub(crate) fn index_of(v: &ffi::QVector_QLineF, value: &ffi::QLineF) -> isize { + ffi::index_of_QLineF(v, value) +} + +pub(crate) fn insert(s: &mut ffi::QVector_QLineF, pos: isize, value: &ffi::QLineF) { + ffi::insert_QLineF(s, pos, value); +} + +pub(crate) fn len(s: &ffi::QVector_QLineF) -> isize { + ffi::len_QLineF(s) +} + +pub(crate) fn remove(s: &mut ffi::QVector_QLineF, pos: isize) { + ffi::remove_QLineF(s, pos); +} diff --git a/crates/cxx-qt-lib/src/gui/qpainter.rs b/crates/cxx-qt-lib/src/gui/qpainter.rs index d5aea19f5..cb8667e2b 100644 --- a/crates/cxx-qt-lib/src/gui/qpainter.rs +++ b/crates/cxx-qt-lib/src/gui/qpainter.rs @@ -177,9 +177,9 @@ mod ffi { type QPolygon = crate::QPolygon; include!("cxx-qt-lib/qregion.h"); type QRegion = crate::QRegion; - include!("cxx-qt-lib/qlist.h"); - type QList_QLine = crate::QList; - type QList_QLineF = crate::QList; + include!("cxx-qt-lib/qvector.h"); + type QVector_QLine = crate::QVector; + type QVector_QLineF = crate::QVector; /// Returns the current background mode. #[rust_name = "background_mode"] @@ -250,11 +250,11 @@ mod ffi { /// Draws the set of lines defined by the list lines using the current pen and brush. #[rust_name = "draw_lines"] - fn drawLines(self: Pin<&mut QPainter>, lines: &QList_QLine); + fn drawLines(self: Pin<&mut QPainter>, lines: &QVector_QLine); /// Draws the set of lines defined by the list lines using the current pen and brush. #[rust_name = "draw_linefs"] - fn drawLines(self: Pin<&mut QPainter>, lines: &QList_QLineF); + fn drawLines(self: Pin<&mut QPainter>, lines: &QVector_QLineF); /// Draws the given painter path using the current pen for outline and the current brush for filling. #[rust_name = "draw_path"]