forked from 1b-agent/opencadstudio-upstream
Fix Properties hyperlink collection editor
This commit is contained in:
1 parent
bb29b987c2
commit
6a1c649016
11 files changed
+272
-13
No files matched your search
Vendored
+5
-2
@@ -30,7 +30,10 @@ pub fn general_section(entity: &EntityType) -> PropSection {
|
||||
},
|
||||
);
|
||||
|
||||
let hyperlink = crate::scene::pe_url_of(entity).unwrap_or_default().to_owned();
|
||||
let hyperlink = crate::scene::pe_url_description_of(entity)
|
||||
.or_else(|| crate::scene::pe_url_of(entity))
|
||||
.unwrap_or_default()
|
||||
.to_owned();
|
||||
|
||||
let section = PropSection {
|
||||
title: t!("General").into_owned(),
|
||||
@@ -83,7 +86,7 @@ pub fn general_section(entity: &EntityType) -> PropSection {
|
||||
Property {
|
||||
label: t!("Hyperlink").into_owned(),
|
||||
field: "hyperlink",
|
||||
value: PropValue::PlainText(hyperlink),
|
||||
value: PropValue::Hyperlink(hyperlink),
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
+1
-1
@@ -51,7 +51,7 @@ mod preview;
|
||||
mod project;
|
||||
mod scene_markers;
|
||||
mod selection;
|
||||
pub(crate) use selection::pe_url_of;
|
||||
pub(crate) use selection::{pe_url_description_of, pe_url_of};
|
||||
pub mod parametric_constraints;
|
||||
mod parametric_solve;
|
||||
|
||||
|
||||
@@ -14,6 +14,9 @@ pub enum PropValue {
|
||||
EditText(String),
|
||||
/// Editable text that must not be expression-evaluated.
|
||||
PlainText(String),
|
||||
/// Hyperlink collection summary. The value is display-only in the row;
|
||||
/// the adjacent collection button opens the URL/description editor.
|
||||
Hyperlink(String),
|
||||
/// Layer name — rendered as a combo_box.
|
||||
LayerChoice(String),
|
||||
/// Generic string choice rendered as a combo_box.
|
||||
|
||||
+19
-2
@@ -12,6 +12,20 @@ pub(crate) fn pe_url_of(entity: &EntityType) -> Option<&str> {
|
||||
.filter(|text| !text.is_empty())
|
||||
}
|
||||
|
||||
/// Optional description stored after the URL in the standard PE_URL record.
|
||||
pub(crate) fn pe_url_description_of(entity: &EntityType) -> Option<&str> {
|
||||
let record = entity.common().extended_data.get_record("PE_URL")?;
|
||||
record
|
||||
.values
|
||||
.iter()
|
||||
.filter_map(|value| match value {
|
||||
acadrust::xdata::XDataValue::String(text) => Some(text.trim()),
|
||||
_ => None,
|
||||
})
|
||||
.nth(1)
|
||||
.filter(|text| !text.is_empty())
|
||||
}
|
||||
|
||||
impl Scene {
|
||||
// ── Selection ─────────────────────────────────────────────────────────
|
||||
/// Treat a classic LEADER and its attached annotation as one logical object.
|
||||
@@ -670,7 +684,9 @@ impl Scene {
|
||||
])
|
||||
} else {
|
||||
match prop.value {
|
||||
PropValue::PlainText(_) => QSelectValueEditor::Text,
|
||||
PropValue::PlainText(_) | PropValue::Hyperlink(_) => {
|
||||
QSelectValueEditor::Text
|
||||
}
|
||||
PropValue::ReadOnly(ref value)
|
||||
| PropValue::ReadOnlyWithTooltip { ref value, .. }
|
||||
| PropValue::EditText(ref value) => {
|
||||
@@ -872,7 +888,8 @@ impl Scene {
|
||||
PropValue::ReadOnly(s)
|
||||
| PropValue::ReadOnlyWithTooltip { value: s, .. }
|
||||
| PropValue::EditText(s)
|
||||
| PropValue::PlainText(s) => s,
|
||||
| PropValue::PlainText(s)
|
||||
| PropValue::Hyperlink(s) => s,
|
||||
PropValue::LayerChoice(s) => s,
|
||||
PropValue::Choice { selected, .. } => selected,
|
||||
PropValue::EditChoice { value, .. } => value,
|
||||
|
||||
Reference in new issue
Block a user