Codegen question

Login or register to post comments
1 reply [Last post]
Steven Warren's picture
Offline
Joined: 11/06/2008

Suppose I have three tables:

CREATE TABLE `agent` (
`id` int(10) unsigned NOT NULL,
`first` varchar(45) NOT NULL,
`middle` varchar(45) DEFAULT NULL,
`last` varchar(45) NOT NULL,
`address` int(10) unsigned NOT NULL,
PRIMARY KEY (`id`),
KEY `FK_agent_address` (`address`),
CONSTRAINT `FK_agent_address` FOREIGN KEY (`address`) REFERENCES `tbl_address` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
)

CREATE TABLE `branch_office` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`office_name` varchar(45) NOT NULL,
`address` int(10) unsigned NOT NULL,
`website` varchar(45) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `FK_branch_office_address` (`address`),
CONSTRAINT `FK_branch_office_address` FOREIGN KEY (`address`) REFERENCES `tbl_address` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
)

CREATE TABLE `tbl_address` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`address` varchar(100) NOT NULL,
`unit` varchar(45) DEFAULT NULL,
`city` varchar(45) NOT NULL,
`state` int(10) unsigned NOT NULL,
`zip_code` varchar(45) NOT NULL,
PRIMARY KEY (`id`)
)

When I run codegen the drafts create a ListBox for the Address object in both the AgentsEdit and BranchOfficeEdit drafts, as is the default behavior. I would like to be able to codegen this scenario and have the AddressEdit classes controls displayed as part of the AgentsEdit and BranchOfficeEdit drafts.

Is there any stock way of doing this in QCubed? If not, what would be the best approach to extend the codegen templates to create this behavior?

alex94040's picture
Offline
Joined: 11/06/2008

Instead of editing the codegen templates, I encourage you to build a custom reusable QPanel that allows you to edit all of these related objects at once.