add base class property for objects
parent
874d6c36ce
commit
fddfbd59c5
1
AUTHORS
1
AUTHORS
|
@ -1,4 +1,5 @@
|
||||||
Code:
|
Code:
|
||||||
|
Alison G. Watson <marrub@greyserv.net>
|
||||||
Jos van den Oever <vandenoever@kde.org>
|
Jos van den Oever <vandenoever@kde.org>
|
||||||
Art:
|
Art:
|
||||||
Alessandro Longo <alessandro.longo@kdemail.net>
|
Alessandro Longo <alessandro.longo@kdemail.net>
|
||||||
|
|
|
@ -42,6 +42,8 @@ mod json {
|
||||||
pub object_type: super::ObjectType,
|
pub object_type: super::ObjectType,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub properties: BTreeMap<String, Property>,
|
pub properties: BTreeMap<String, Property>,
|
||||||
|
#[serde(rename = "baseClass", default)]
|
||||||
|
pub base_class: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
|
@ -135,6 +137,7 @@ pub struct Object {
|
||||||
pub item_properties: BTreeMap<String, ItemProperty>,
|
pub item_properties: BTreeMap<String, ItemProperty>,
|
||||||
pub object_type: ObjectType,
|
pub object_type: ObjectType,
|
||||||
pub properties: BTreeMap<String, Property>,
|
pub properties: BTreeMap<String, Property>,
|
||||||
|
pub base_class: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ObjectPrivate for Object {
|
impl ObjectPrivate for Object {
|
||||||
|
@ -454,6 +457,7 @@ fn post_process_object(
|
||||||
object_type: a.1.object_type,
|
object_type: a.1.object_type,
|
||||||
functions: a.1.functions.clone(),
|
functions: a.1.functions.clone(),
|
||||||
item_properties: a.1.item_properties.clone(),
|
item_properties: a.1.item_properties.clone(),
|
||||||
|
base_class: a.1.base_class.clone(),
|
||||||
properties,
|
properties,
|
||||||
});
|
});
|
||||||
b.insert(a.0.clone(), object);
|
b.insert(a.0.clone(), object);
|
||||||
|
|
25
src/cpp.rs
25
src/cpp.rs
|
@ -24,11 +24,18 @@ fn write_property(name: &str) -> String {
|
||||||
format!("WRITE set{} ", upper_initial(name))
|
format!("WRITE set{} ", upper_initial(name))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn base_type(o: &Object) -> &str {
|
fn base_type(o: &Object) -> (&str, bool) {
|
||||||
if o.object_type != ObjectType::Object {
|
let model = o.object_type != ObjectType::Object;
|
||||||
return "QAbstractItemModel";
|
|
||||||
}
|
let name = if o.base_class != "" {
|
||||||
"QObject"
|
&o.base_class
|
||||||
|
} else if o.object_type == ObjectType::Object {
|
||||||
|
"QAbstractItemModel"
|
||||||
|
} else {
|
||||||
|
"QObject"
|
||||||
|
};
|
||||||
|
|
||||||
|
(name, model)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn model_is_writable(o: &Object) -> bool {
|
fn model_is_writable(o: &Object) -> bool {
|
||||||
|
@ -121,7 +128,7 @@ class {} : public {}
|
||||||
{{
|
{{
|
||||||
Q_OBJECT",
|
Q_OBJECT",
|
||||||
o.name,
|
o.name,
|
||||||
base_type(o)
|
base_type(o).0
|
||||||
)?;
|
)?;
|
||||||
for object in conf.objects.values() {
|
for object in conf.objects.values() {
|
||||||
if object.contains_object() && o.name != object.name {
|
if object.contains_object() && o.name != object.name {
|
||||||
|
@ -200,7 +207,7 @@ public:
|
||||||
}
|
}
|
||||||
writeln!(h, "){};", if f.mutable { "" } else { " const" })?;
|
writeln!(h, "){};", if f.mutable { "" } else { " const" })?;
|
||||||
}
|
}
|
||||||
if base_type(o) == "QAbstractItemModel" {
|
if base_type(o).1 {
|
||||||
write_header_item_model(h, o)?;
|
write_header_item_model(h, o)?;
|
||||||
}
|
}
|
||||||
writeln!(h, "Q_SIGNALS:")?;
|
writeln!(h, "Q_SIGNALS:")?;
|
||||||
|
@ -373,7 +380,7 @@ fn write_cpp_object(w: &mut Vec<u8>, o: &Object, conf: &Config) -> Result<()> {
|
||||||
"{}::{0}(bool /*owned*/, QObject *parent):
|
"{}::{0}(bool /*owned*/, QObject *parent):
|
||||||
{}(parent),",
|
{}(parent),",
|
||||||
o.name,
|
o.name,
|
||||||
base_type(o)
|
base_type(o).0
|
||||||
)?;
|
)?;
|
||||||
initialize_members_zero(w, o)?;
|
initialize_members_zero(w, o)?;
|
||||||
writeln!(
|
writeln!(
|
||||||
|
@ -392,7 +399,7 @@ fn write_cpp_object(w: &mut Vec<u8>, o: &Object, conf: &Config) -> Result<()> {
|
||||||
{}::{0}(QObject *parent):
|
{}::{0}(QObject *parent):
|
||||||
{}(parent),",
|
{}(parent),",
|
||||||
o.name,
|
o.name,
|
||||||
base_type(o)
|
base_type(o).0
|
||||||
)?;
|
)?;
|
||||||
initialize_members_zero(w, o)?;
|
initialize_members_zero(w, o)?;
|
||||||
write!(w, " m_d({}_new(this", lcname)?;
|
write!(w, " m_d({}_new(this", lcname)?;
|
||||||
|
|
Loading…
Reference in New Issue