Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cxx-qt-lib: Add support for QUuid #1149

Merged
merged 19 commits into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion crates/cxx-qt-lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,15 @@ http = { version = "1.0", optional = true }
rgb = { version = "0.8", optional = true }
time = { version = "0.3.20", optional = true }
url = { version = "2.3", optional = true }
uuid = { version = "1.1.0", optional = true }
serde = { version = "1", features=["derive"], optional = true }

[build-dependencies]
cxx-qt-build.workspace = true
qt-build-utils.workspace = true

[features]
full = ["qt_full", "serde", "url", "time", "rgb", "http", "chrono", "bytes"]
full = ["qt_full", "serde", "url", "uuid", "time", "rgb", "http", "chrono", "bytes"]
default = []

qt_full = ["qt_gui", "qt_qml", "qt_quickcontrols"]
Expand All @@ -51,6 +52,7 @@ rgb = ["dep:rgb"]
time = ["dep:time"]
url = ["dep:url"]
serde = ["dep:serde"]
uuid = ["dep:uuid"]
link_qt_object_files = ["cxx-qt-build/link_qt_object_files"]

[lints]
Expand Down
6 changes: 6 additions & 0 deletions crates/cxx-qt-lib/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ fn main() {
"core/qlist/qlist_qstring",
"core/qlist/qlist_qtime",
"core/qlist/qlist_qurl",
"core/qlist/qlist_quuid",
"core/qlist/qlist_qvariant",
"core/qlist/qlist_u8",
"core/qlist/qlist_u16",
Expand Down Expand Up @@ -137,6 +138,7 @@ fn main() {
"core/qset/qset_qstring",
"core/qset/qset_qtime",
"core/qset/qset_qurl",
"core/qset/qset_quuid",
"core/qset/qset_u8",
"core/qset/qset_u16",
"core/qset/qset_u32",
Expand All @@ -148,6 +150,7 @@ fn main() {
"core/qt",
"core/qtime",
"core/qurl",
"core/quuid",
"core/qvariant/mod",
"core/qvariant/qvariant_bool",
"core/qvariant/qvariant_f32",
Expand All @@ -170,6 +173,7 @@ fn main() {
"core/qvariant/qvariant_qstringlist",
"core/qvariant/qvariant_qtime",
"core/qvariant/qvariant_qurl",
"core/qvariant/qvariant_quuid",
"core/qvariant/qvariant_u8",
"core/qvariant/qvariant_u16",
"core/qvariant/qvariant_u32",
Expand Down Expand Up @@ -197,6 +201,7 @@ fn main() {
"core/qvector/qvector_qstring",
"core/qvector/qvector_qtime",
"core/qvector/qvector_qurl",
"core/qvector/qvector_quuid",
"core/qvector/qvector_qvariant",
"core/qvector/qvector_u8",
"core/qvector/qvector_u16",
Expand Down Expand Up @@ -272,6 +277,7 @@ fn main() {
"core/qstringlist",
"core/qtime",
"core/qurl",
"core/quuid",
"core/qvariant/qvariant",
"core/qvector/qvector",
];
Expand Down
2 changes: 2 additions & 0 deletions crates/cxx-qt-lib/include/core/qlist.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <QtCore/QString>
#include <QtCore/QTime>
#include <QtCore/QUrl>
#include <QtCore/QUuid>
#include <QtCore/QVariant>

#ifdef CXX_QT_GUI_FEATURE
Expand Down Expand Up @@ -170,6 +171,7 @@ using QList_QSizeF = QList<::QSizeF>;
using QList_QString = QList<::QString>;
using QList_QTime = QList<::QTime>;
using QList_QUrl = QList<::QUrl>;
using QList_QUuid = QList<::QUuid>;
using QList_QVariant = QList<::QVariant>;
using QList_u8 = QList<::std::uint8_t>;
using QList_u16 = QList<::std::uint16_t>;
Expand Down
2 changes: 2 additions & 0 deletions crates/cxx-qt-lib/include/core/qset.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <QtCore/QString>
#include <QtCore/QTime>
#include <QtCore/QUrl>
#include <QtCore/QUuid>

#include "rust/cxx.h"

Expand Down Expand Up @@ -84,6 +85,7 @@ using QSet_QPersistentModelIndex = QSet<::QPersistentModelIndex>;
using QSet_QString = QSet<::QString>;
using QSet_QTime = QSet<::QTime>;
using QSet_QUrl = QSet<::QUrl>;
using QSet_QUuid = QSet<::QUuid>;
using QSet_u8 = QSet<::std::uint8_t>;
using QSet_u16 = QSet<::std::uint16_t>;
using QSet_u32 = QSet<::std::uint32_t>;
Expand Down
34 changes: 34 additions & 0 deletions crates/cxx-qt-lib/include/core/quuid.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// clang-format off
// SPDX-FileCopyrightText: 2022 Klarälvdalens Datakonsult AB, a KDAB Group company <[email protected]>
// clang-format on
// SPDX-FileContributor: Andrew Hayzen <[email protected]>
jnbooth marked this conversation as resolved.
Show resolved Hide resolved
// SPDX-FileContributor: Joshua Booth <[email protected]>
//
// SPDX-License-Identifier: MIT OR Apache-2.0
#pragma once

#include <QtCore/QUuid>

#include "rust/cxx.h"

using QUuidVariant = QUuid::Variant;
using QUuidVersion = QUuid::Version;

namespace rust {
namespace cxxqtlib1 {
QUuid
quuidNewV3(const QUuid& ns, ::rust::Slice<const ::std::uint8_t> slice);

QUuid
quuidNewV4();

QUuid
quuidNewV5(const QUuid& ns, ::rust::Slice<const ::std::uint8_t> slice);

QString
quuidToString(const QUuid& uuid);

QUuid
quuidFromString(QAnyStringView string);
}
}
2 changes: 2 additions & 0 deletions crates/cxx-qt-lib/include/core/qvariant.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <QtCore/QStringList>
#include <QtCore/QTime>
#include <QtCore/QUrl>
#include <QtCore/QUuid>

#ifdef CXX_QT_GUI_FEATURE
#include <QtGui/QColor>
Expand Down Expand Up @@ -91,6 +92,7 @@ CXX_QT_QVARIANT_CAN_CONVERT(QString)
CXX_QT_QVARIANT_CAN_CONVERT(QStringList)
CXX_QT_QVARIANT_CAN_CONVERT(QTime)
CXX_QT_QVARIANT_CAN_CONVERT(QUrl)
CXX_QT_QVARIANT_CAN_CONVERT(QUuid)
CXX_QT_QVARIANT_CAN_CONVERT(U8)
CXX_QT_QVARIANT_CAN_CONVERT(U16)
CXX_QT_QVARIANT_CAN_CONVERT(U32)
Expand Down
2 changes: 2 additions & 0 deletions crates/cxx-qt-lib/include/core/qvector.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <QtCore/QString>
#include <QtCore/QTime>
#include <QtCore/QUrl>
#include <QtCore/QUuid>
#include <QtCore/QVariant>

#ifdef CXX_QT_GUI_FEATURE
Expand Down Expand Up @@ -167,6 +168,7 @@ using QVector_QSizeF = QVector<::QSizeF>;
using QVector_QString = QVector<::QString>;
using QVector_QTime = QVector<::QTime>;
using QVector_QUrl = QVector<::QUrl>;
using QVector_QUuid = QVector<::QUuid>;
using QVector_QVariant = QVector<::QVariant>;
using QVector_u8 = QVector<::std::uint8_t>;
using QVector_u16 = QVector<::std::uint16_t>;
Expand Down
3 changes: 3 additions & 0 deletions crates/cxx-qt-lib/src/core/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ pub use qpointf::QPointF;
mod qurl;
pub use qurl::QUrl;

mod quuid;
pub use quuid::{QUuid, QUuidVariant, QUuidVersion};

mod qvariant;
pub use qvariant::{QVariant, QVariantValue};

Expand Down
1 change: 1 addition & 0 deletions crates/cxx-qt-lib/src/core/qlist/generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ generate_bridge_qt "QSizeF" "qsizef"
generate_bridge_qt "QString" "qstring"
generate_bridge_qt "QTime" "qtime"
generate_bridge_qt "QUrl" "qurl"
generate_bridge_qt "QUuid" "quuid"
generate_bridge_qt "QVariant" "qvariant"
generate_bridge_qt "QLine" "qline"
generate_bridge_qt "QLineF" "qlinef"
Expand Down
3 changes: 2 additions & 1 deletion crates/cxx-qt-lib/src/core/qlist/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::QColor;
use crate::QDateTime;
use crate::{
QByteArray, QDate, QLine, QLineF, QMargins, QMarginsF, QPersistentModelIndex, QPoint, QPointF,
QRect, QRectF, QSize, QSizeF, QString, QTime, QUrl, QVariant,
QRect, QRectF, QSize, QSizeF, QString, QTime, QUrl, QUuid, QVariant,
};
use core::{marker::PhantomData, mem::MaybeUninit};
use cxx::{type_id, ExternType};
Expand Down Expand Up @@ -373,6 +373,7 @@ impl_qlist_element!(QSizeF, qlist_qsizef, "QList_QSizeF");
impl_qlist_element!(QString, qlist_qstring, "QList_QString");
impl_qlist_element!(QTime, qlist_qtime, "QList_QTime");
impl_qlist_element!(QUrl, qlist_qurl, "QList_QUrl");
impl_qlist_element!(QUuid, qlist_quuid, "QList_QUuid");
impl_qlist_element!(QVariant, qlist_qvariant, "QList_QVariant");
impl_qlist_element!(u8, qlist_u8, "QList_u8");
impl_qlist_element!(u16, qlist_u16, "QList_u16");
Expand Down
1 change: 1 addition & 0 deletions crates/cxx-qt-lib/src/core/qlist/qlist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ CXX_QT_QLIST_ASSERTS(::QSizeF, QSizeF);
CXX_QT_QLIST_ASSERTS(::QString, QString);
CXX_QT_QLIST_ASSERTS(::QTime, QTime);
CXX_QT_QLIST_ASSERTS(::QUrl, QUrl);
CXX_QT_QLIST_ASSERTS(::QUuid, QUuid);
CXX_QT_QLIST_ASSERTS(::QVariant, QVariant);
CXX_QT_QLIST_ASSERTS(::std::uint8_t, u8);
CXX_QT_QLIST_ASSERTS(::std::uint16_t, u16);
Expand Down
92 changes: 92 additions & 0 deletions crates/cxx-qt-lib/src/core/qlist/qlist_quuid.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/cxx-qt-lib/src/core/qset/generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ generate_bridge_qt "QPersistentModelIndex" "qpersistentmodelindex"
generate_bridge_qt "QString" "qstring"
generate_bridge_qt "QTime" "qtime"
generate_bridge_qt "QUrl" "qurl"
generate_bridge_qt "QUuid" "quuid"
generate_bridge_primitive "u8"
generate_bridge_primitive "u16"
generate_bridge_primitive "u32"
Expand Down
3 changes: 2 additions & 1 deletion crates/cxx-qt-lib/src/core/qset/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// SPDX-License-Identifier: MIT OR Apache-2.0
#[cfg(not(target_os = "emscripten"))]
use crate::QDateTime;
use crate::{QByteArray, QDate, QPersistentModelIndex, QString, QTime, QUrl};
use crate::{QByteArray, QDate, QPersistentModelIndex, QString, QTime, QUrl, QUuid};
use core::{marker::PhantomData, mem::MaybeUninit};
use cxx::{type_id, ExternType};

Expand Down Expand Up @@ -262,6 +262,7 @@ impl_qset_element!(
impl_qset_element!(QString, qset_qstring, "QSet_QString");
impl_qset_element!(QTime, qset_qtime, "QSet_QTime");
impl_qset_element!(QUrl, qset_qurl, "QSet_QUrl");
impl_qset_element!(QUuid, qset_quuid, "QSet_QUuid");
impl_qset_element!(u8, qset_u8, "QSet_u8");
impl_qset_element!(u16, qset_u16, "QSet_u16");
impl_qset_element!(u32, qset_u32, "QSet_u32");
Expand Down
1 change: 1 addition & 0 deletions crates/cxx-qt-lib/src/core/qset/qset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ CXX_QT_QSET_ASSERTS(::QPersistentModelIndex, QPersistentModelIndex);
CXX_QT_QSET_ASSERTS(::QString, QString);
CXX_QT_QSET_ASSERTS(::QTime, QTime);
CXX_QT_QSET_ASSERTS(::QUrl, QUrl);
CXX_QT_QSET_ASSERTS(::QUuid, QUuid);
CXX_QT_QSET_ASSERTS(::std::uint8_t, u8);
CXX_QT_QSET_ASSERTS(::std::uint16_t, u16);
CXX_QT_QSET_ASSERTS(::std::uint32_t, u32);
Expand Down
Loading