Skip to content

Commit

Permalink
Implement PartialEq
Browse files Browse the repository at this point in the history
close KDAB#873
  • Loading branch information
Montel committed Feb 29, 2024
1 parent d442ed7 commit 40f7f18
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 0 deletions.
12 changes: 12 additions & 0 deletions crates/cxx-qt-lib/src/gui/qfont.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,10 @@ mod ffi {
#[doc(hidden)]
#[rust_name = "qfont_clone"]
fn construct(font: &QFont) -> QFont;

#[doc(hidden)]
#[rust_name = "qfont_eq"]
fn operatorEq(a: &QFont, b: &QFont) -> bool;
}
}

Expand Down Expand Up @@ -291,6 +295,14 @@ impl Clone for QFont {
}
}

impl PartialEq for QFont {
fn eq(&self, other: &Self) -> bool {
ffi::qfont_eq(self, other)
}
}

impl Eq for QFont {}

impl QFont {
/// Returns the bounding rectangle of the current clip if there is a clip;
/// otherwise returns `None`. Note that the clip region is given in logical coordinates.
Expand Down
12 changes: 12 additions & 0 deletions crates/cxx-qt-lib/src/gui/qimage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,10 @@ mod ffi {
#[doc(hidden)]
#[rust_name = "qimage_cache_key"]
fn qimageCacheKey(image: &QImage) -> i64;

#[doc(hidden)]
#[rust_name = "qimage_eq"]
fn operatorEq(a: &QImage, b: &QImage) -> bool;
}
}

Expand Down Expand Up @@ -270,6 +274,14 @@ impl Default for QImage {
}
}

impl PartialEq for QImage {
fn eq(&self, other: &Self) -> bool {
ffi::qimage_eq(self, other)
}
}

impl Eq for QImage {}

// Safety:
//
// Static checks on the C++ side to ensure the size & alignment is the same.
Expand Down
12 changes: 12 additions & 0 deletions crates/cxx-qt-lib/src/gui/qpen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ mod ffi {
#[doc(hidden)]
#[rust_name = "qpen_clone"]
fn construct(pen: &QPen) -> QPen;

#[doc(hidden)]
#[rust_name = "qpen_eq"]
fn operatorEq(a: &QPen, b: &QPen) -> bool;
}
}

Expand Down Expand Up @@ -143,6 +147,14 @@ impl Clone for QPen {
}
}

impl PartialEq for QPen {
fn eq(&self, other: &Self) -> bool {
ffi::qpen_eq(self, other)
}
}

impl Eq for QPen {}

impl From<&ffi::QColor> for QPen {
fn from(color: &ffi::QColor) -> Self {
ffi::qpen_init_from_qcolor(color)
Expand Down
12 changes: 12 additions & 0 deletions crates/cxx-qt-lib/src/gui/qpolygon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ mod ffi {
#[doc(hidden)]
#[rust_name = "qpolygon_clone"]
fn construct(p: &QPolygon) -> QPolygon;

#[doc(hidden)]
#[rust_name = "qpolygon_eq"]
fn operatorEq(a: &QPolygon, b: &QPolygon) -> bool;
}
}

Expand Down Expand Up @@ -107,6 +111,14 @@ impl Clone for QPolygon {
}
}

impl PartialEq for QPolygon {
fn eq(&self, other: &Self) -> bool {
ffi::qpolygon_eq(self, other)
}
}

impl Eq for QPolygon {}

// Safety:
//
// Static checks on the C++ side to ensure the size is the same.
Expand Down
12 changes: 12 additions & 0 deletions crates/cxx-qt-lib/src/gui/qpolygonf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ mod ffi {
#[doc(hidden)]
#[rust_name = "qpolygonf_clone"]
fn construct(p: &QPolygonF) -> QPolygonF;

#[doc(hidden)]
#[rust_name = "qpolygonf_eq"]
fn operatorEq(a: &QPolygonF, b: &QPolygonF) -> bool;
}
}

Expand Down Expand Up @@ -110,6 +114,14 @@ impl Clone for QPolygonF {
}
}

impl PartialEq for QPolygonF {
fn eq(&self, other: &Self) -> bool {
ffi::qpolygonf_eq(self, other)
}
}

impl Eq for QPolygonF {}

// Safety:
//
// Static checks on the C++ side to ensure the size is the same.
Expand Down

0 comments on commit 40f7f18

Please sign in to comment.