Herunterladen als
root/src/tableschema.cpp @ 696666eb
c22391b2 | Christian Ehringfeld | /*
|
|
* Copyright (C) 2015 Christian Ehringfeld <c.ehringfeld@t-online.de>
|
|||
*
|
|||
* This program is free software; you can redistribute it and/or modify it
|
|||
* under the terms of the GNU Lesser General Public License as published by
|
|||
* the Free Software Foundation.
|
|||
*
|
|||
* This program is distributed in the hope that it will be useful, but
|
|||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|||
* for more details.
|
|||
*
|
|||
* You should have received a copy of the GNU Lesser General Public License
|
|||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
|||
*/
|
|||
4d58ef6a | Christian Ehringfeld | #include "tableschema.h"
|
|
b0b8dac3 | Christian Ehringfeld | using namespace CuteEntityManager;
|
|
4d58ef6a | Christian Ehringfeld | ||
426974c6 | Christian Ehringfeld | TableSchema::TableSchema() {
|
|
4d58ef6a | Christian Ehringfeld | ||
}
|
|||
426974c6 | Christian Ehringfeld | TableSchema::~TableSchema() {
|
|
4d58ef6a | Christian Ehringfeld | ||
}
|
|||
14f9beed | Christian Ehringfeld | const QSharedPointer<QSqlField> TableSchema::getColumn(QString name) const {
|
|
auto columns = this->getColumns();
|
|||
foreach (auto schema, columns) {
|
|||
if (schema.data()->name() == name) {
|
|||
return schema;
|
|||
}
|
|||
}
|
|||
return QSharedPointer<QSqlField>();
|
|||
426974c6 | Christian Ehringfeld | }
|
|
14f9beed | Christian Ehringfeld | const QStringList TableSchema::getColumnNames() {
|
|
QStringList l;
|
|||
auto columns = this->getColumns();
|
|||
foreach (auto schema, columns) {
|
|||
l.append(schema.data()->name());
|
|||
}
|
|||
return l;
|
|||
426974c6 | Christian Ehringfeld | }
|
|
caea9141 | Christian Ehringfeld | ||
426974c6 | Christian Ehringfeld | QString TableSchema::getSchemaName() const {
|
|
return schemaName;
|
|||
}
|
|||
void TableSchema::setSchemaName(const QString &value) {
|
|||
schemaName = value;
|
|||
}
|
|||
QString TableSchema::getName() const {
|
|||
return name;
|
|||
}
|
|||
void TableSchema::setName(const QString &value) {
|
|||
name = value;
|
|||
}
|
|||
QString TableSchema::getFullName() const {
|
|||
return fullName;
|
|||
}
|
|||
void TableSchema::setFullName(const QString &value) {
|
|||
fullName = value;
|
|||
}
|
|||
14f9beed | Christian Ehringfeld | QStringList TableSchema::getPrimaryKeys() const {
|
|
426974c6 | Christian Ehringfeld | return primaryKeys;
|
|
}
|
|||
14f9beed | Christian Ehringfeld | void TableSchema::setPrimaryKeys(const QStringList &value) {
|
|
426974c6 | Christian Ehringfeld | primaryKeys = value;
|
|
}
|
|||
QString TableSchema::getSequenceName() const {
|
|||
return sequenceName;
|
|||
}
|
|||
void TableSchema::setSequenceName(const QString &value) {
|
|||
sequenceName = value;
|
|||
}
|
|||
14f9beed | Christian Ehringfeld | QHash<QString, QSharedPointer<QSqlField> > TableSchema::getColumns() const {
|
|
426974c6 | Christian Ehringfeld | return columns;
|
|
}
|
|||
e0e1ead8 | Christian Ehringfeld | void TableSchema::setColumns(const QHash<QString, QSharedPointer<QSqlField> >
|
|
&value) {
|
|||
426974c6 | Christian Ehringfeld | columns = value;
|
|
}
|
|||
e0e1ead8 | Christian Ehringfeld | QHash<QString, QSharedPointer<QSqlRelation> > TableSchema::getRelations()
|
|
const {
|
|||
14f9beed | Christian Ehringfeld | return relations;
|
|
}
|
|||
e0e1ead8 | Christian Ehringfeld | void TableSchema::setRelations(
|
|
const QHash<QString, QSharedPointer<QSqlRelation> > &value) {
|
|||
14f9beed | Christian Ehringfeld | relations = value;
|
|
}
|
|||
b0e92bc6 | Christian Ehringfeld | ||
QSharedPointer<QSqlRelationalTableModel> TableSchema::getTableModel() const {
|
|||
QSqlRelationalTableModel *model = new QSqlRelationalTableModel;
|
|||
model->setTable(this->getName());
|
|||
return QSharedPointer<QSqlRelationalTableModel>(model);
|
|||
}
|