model->setHeaderData(0, Qt::Horizontal, tr("IFI")); model->setHeaderData(1, Qt::Horizontal, tr("Name")); model->setHeaderData(2, Qt::Horizontal, tr("Address"));... и такая лапша на каждую таблицу, на каждое поле, не считая размеры и прочее оформление
<< QstField("LastName", FieldVisible, "Фамилия", 100)<< QstField("FirstName", FieldVisible, "Имя", 100)<< QstField("ParentName", FieldVisible, "Отчество", 100)<< QstField("vcBirthDate", FieldVisible, "Дата\nрождения", 90)<< QstField("Phone", FieldVisible, "Контактный\nтелефон", 120)<< QstField("[E-Mail]", FieldVisible, "e-mail", 120)
void uoMainWindow::createTables(){ QString dbName = qApp->applicationDirPath() + QDir::separator()+"main.db";#ifdef Q_OS_LINUX QDir home = QDir::home(); if (!home.exists(".uoReceptor")) { home.mkpath(".uoReceptor"); } dbName = home.absolutePath() + "/.uoReceptor/" + QDir::separator()+"main.db";#endif m_dbMan->setupDataBase(dbName); m_receptTable = m_dbMan->addRefTable("ШаблоныPецептов","Шаблоны рецептов",6,120); m_receptTable->setOption(codeType_Number, true); m_receptTable->addField("Комментарий", fieldType_String,150); m_templField = m_receptTable->addField("Шаблон", fieldType_TextHTML); uoMdiObserver::instance()->m_receptTableId = m_receptTable->m_baseNom; uoDbRefTable* tmlpTabl = m_dbMan->addRefTable("Лекарства","Лекарства",6, 70); tmlpTabl->addField("ЛатИмя",fieldType_String,70)->m_descr = "Латинское наименование"; tmlpTabl->addField("Описание",fieldType_Text); tmlpTabl->setOption(codeType_Number, true); tmlpTabl = m_dbMan->addRefTable("Симптомы","Симптомы",6, 100); tmlpTabl->setOption(codeType_Number, true); tmlpTabl->addField("Описание",fieldType_Text); tmlpTabl = m_dbMan->addRefTable("Заболевания","Заболевания",6, 100); tmlpTabl->setOption(codeType_Number, true); tmlpTabl->addField("Описание",fieldType_Text); m_dbMan->restructuring();// Реструктуризация m_dbMan->createGuiFactory(this); m_receptTemplDocWidget = new QDockWidget(tr("Recept template"), this); m_receptTemplDocWidget->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea); uoUrl url = m_receptTable->getUoUrlByForm(uoFormT_Tree); url.setWithElem(true); m_docTreeFormRecept = m_dbMan->getForm(url); if (m_docTreeFormRecept) { m_docTreeFormRecept->setParent(m_receptTemplDocWidget); m_receptTemplDocWidget->setWidget(m_docTreeFormRecept); addDockWidget(Qt::LeftDockWidgetArea, m_receptTemplDocWidget); m_actionShowDocRecept = m_receptTemplDocWidget->toggleViewAction(); }}
tmlpTabl->addField("ЛатИмя",fieldType_String,70)->m_descr = "Латинское наименование"; tmlpTabl->addField("Описание",fieldType_Text); tmlpTabl->setOption(codeType_Number, true); tmlpTabl = m_dbMan->addRefTable("Симптомы","Симптомы",6, 100); tmlpTabl->setOption(codeType_Number, true); tmlpTabl->addField("Описание",fieldType_Text); tmlpTabl = m_dbMan->addRefTable("Заболевания","Заболевания",6, 100); tmlpTabl->setOption(codeType_Number, true); tmlpTabl->addField("Описание",fieldType_Text);
select TABLE_NAME, TABLE_COMMENT from information_schema.tables WHERE (table_schema = 'ASRGTS') AND (TABLE_COMMENT LIKE 'Справочник%');
SELECT COLUMN_NAME, DATA_TYPE, CHARACTER_MAXIMUM_LENGTH, NUMERIC_PRECISION, NUMERIC_SCALE, COLUMN_COMMENTFROM information_schema.columns WHERE (table_name = 'CONTRACTS') AND (table_schema = 'ASRGTS');
SET TERM ^ ;CREATE PROCEDURE GET_FIELD_TYPE( TABLE_NAME CHAR(255) CHARACTER SET UTF8 COLLATE UTF8, FIELD_NAME CHAR(255) CHARACTER SET UTF8 COLLATE UTF8)RETURNS( FIELD_POSITION SMALLINT, FIELD_TYPE_NAME CHAR(50) CHARACTER SET UTF8 COLLATE UTF8)ASBEGINFOR SELECT RDB$RELATION_FIELDS.RDB$FIELD_POSITION,RDB$TYPES.RDB$TYPE_NAMEFROM RDB$RELATION_FIELDSINNER JOIN RDB$FIELDS ON(RDB$RELATION_FIELDS.RDB$FIELD_SOURCE = RDB$FIELDS.RDB$FIELD_NAME)INNER JOIN RDB$TYPES ON(RDB$FIELDS.RDB$FIELD_TYPE = RDB$TYPES.RDB$TYPE)WHERE((RDB$RELATION_FIELDS.RDB$RELATION_NAME=:TABLE_NAME)AND(RDB$TYPES.RDB$FIELD_NAME = 'RDB$FIELD_TYPE')AND (RDB$RELATION_FIELDS.RDB$FIELD_NAME=:FIELD_NAME))INTO FIELD_POSITION, FIELD_TYPE_NAMEDO SUSPEND;END^SET TERM ; ^
CREATE TABLE IF NOT EXISTS columns_description( TABLE_NAME VARCHAR(255) NOT NULL COMMENT 'Имя таблицы', COLUMN_NAME VARCHAR(255) NOT NULL COMMENT 'Имя колонки', DESCRIPTION VARCHAR(255) DEFAULT NULL COMMENT 'Описание', WIDTH DECIMAL(10, 0) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Ширина', HIDDEN TINYINT(1) NOT NULL DEFAULT 0 COMMENT 'Спрятать', READONLY TINYINT(1) NOT NULL DEFAULT 0 COMMENT 'Только чтение', UNIQUE INDEX UK_columns_description (TABLE_NAME, COLUMN_NAME))ENGINE = INNODBCHARACTER SET utf8COLLATE utf8_general_ciCOMMENT = 'Описание колонок БД'SELECT TABLE_NAME, COLUMN_NAME, COLUMN_COMMENT AS DESCRIPTION, 10*CHARACTER_MAXIMUM_LENGTH AS WIDTHFROM information_schema.COLUMNS WHERE (TABLE_SCHEMA = database()) AND (TABLE_NAME in ( SELECT TABLE_NAME FROM information_schema.TABLES WHERE (TABLE_TYPE = 'BASE TABLE') AND (TABLE_SCHEMA = database())));
CREATE OR REPLACE SQL SECURITY INVOKER VIEW columns_schemaAS SELECT `c`.`TABLE_NAME` AS `TABLE_NAME` , `c`.`COLUMN_NAME` AS `COLUMN_NAME` , `c`.`DATA_TYPE` AS `DATA_TYPE` , `c`.`CHARACTER_MAXIMUM_LENGTH` AS `CHARACTER_MAXIMUM_LENGTH` , `c`.`NUMERIC_PRECISION` AS `NUMERIC_PRECISION` , `c`.`NUMERIC_SCALE` AS `NUMERIC_SCALE` , `c`.`COLUMN_COMMENT` AS `COLUMN_COMMENT` , `d`.`DESCRIPTION` AS `DESCRIPTION` , `d`.`HIDDEN` AS `HIDDEN` , `d`.`WIDTH` AS `WIDTH` , `d`.`READONLY` AS `READONLY`FROM (`information_schema`.`COLUMNS` `c`JOIN `columns_description` `d`ON (((`c`.`TABLE_NAME` = `d`.`TABLE_NAME`) AND (`c`.`COLUMN_NAME` = `d`.`COLUMN_NAME`))))WHERE (`c`.`TABLE_SCHEMA` = database());
select * from columns_schema where TABLE_NAME='CONTRACTS';