File indexing completed on 2024-04-28 16:30:31
0001 /*************************************************************************** 0002 * SPDX-FileCopyrightText: 2022 S. MANKOWSKI stephane@mankowski.fr 0003 * SPDX-FileCopyrightText: 2022 G. DE BURE support@mankowski.fr 0004 * SPDX-License-Identifier: GPL-3.0-or-later 0005 ***************************************************************************/ 0006 /** @file 0007 * This file defines classes SKGNamedObject. 0008 * 0009 * @author Stephane MANKOWSKI / Guillaume DE BURE 0010 */ 0011 #include "skgnamedobject.h" 0012 #include "skgdocument.h" 0013 0014 SKGNamedObject::SKGNamedObject() : SKGNamedObject(nullptr) 0015 {} 0016 0017 SKGNamedObject::SKGNamedObject(SKGDocument* iDocument, const QString& iTable, int iID) : SKGObjectBase(iDocument, iTable, iID) 0018 {} 0019 0020 SKGNamedObject::SKGNamedObject(const SKGNamedObject& iObject) = default; 0021 0022 SKGNamedObject::SKGNamedObject(const SKGObjectBase& iObject) : SKGObjectBase(iObject) 0023 {} 0024 0025 SKGNamedObject& SKGNamedObject::operator= (const SKGObjectBase& iObject) 0026 { 0027 copyFrom(iObject); 0028 return *this; 0029 } 0030 0031 SKGNamedObject& SKGNamedObject::operator= (const SKGNamedObject& iObject) 0032 { 0033 copyFrom(iObject); 0034 return *this; 0035 } 0036 0037 SKGNamedObject::~SKGNamedObject() 0038 = default; 0039 0040 SKGError SKGNamedObject::setName(const QString& iName) 0041 { 0042 return setAttribute(QStringLiteral("t_name"), iName); 0043 } 0044 0045 QString SKGNamedObject::getName() const 0046 { 0047 return getAttribute(QStringLiteral("t_name")); 0048 } 0049 0050 QString SKGNamedObject::getWhereclauseId() const 0051 { 0052 // Could we use the id 0053 QString output = SKGObjectBase::getWhereclauseId(); 0054 if (output.isEmpty()) { 0055 // No, so we use the name 0056 QString name = SKGServices::stringToSqlString(getName()); 0057 if (!name.isEmpty() || getID() == 0) { 0058 output = "t_name='" % name % '\''; 0059 } 0060 } 0061 return output; 0062 } 0063 0064 SKGError SKGNamedObject::getObjectByName(SKGDocument* iDocument, const QString& iTable, const QString& iName, SKGObjectBase& oObject) 0065 { 0066 return iDocument != nullptr ? iDocument->getObject(iTable, "t_name='" % SKGServices::stringToSqlString(iName) % '\'', oObject) : SKGError(); 0067 }