File indexing completed on 2022-11-23 11:08:53

0001 /* This file is part of the KDE project
0002    Copyright (C) 2003-2010 Jarosław Staniek <staniek@kde.org>
0003 
0004    This library is free software; you can redistribute it and/or
0005    modify it under the terms of the GNU Library General Public
0006    License as published by the Free Software Foundation; either
0007    version 2 of the License, or (at your option) any later version.
0008 
0009    This library is distributed in the hope that it will be useful,
0010    but WITHOUT ANY WARRANTY; without even the implied warranty of
0011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0012    Library General Public License for more details.
0013 
0014    You should have received a copy of the GNU Library General Public License
0015    along with this library; see the file COPYING.LIB.  If not, write to
0016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0017  * Boston, MA 02110-1301, USA.
0018 */
0019 
0020 #ifndef KDB_OBJECT_H
0021 #define KDB_OBJECT_H
0022 
0023 #include "kdb_export.h"
0024 #include "KDbGlobal.h"
0025 
0026 /*! Provides common attributes for KDb objects: id, name, caption,
0027  help text. A KDb object is typically storable in database, for example:
0028  table schema or query schema.
0029  Default type of object is KDb::UnknownObjectType.
0030 */
0031 class KDB_EXPORT KDbObject //SDC: operator== virtual_dtor
0032 {
0033 public:
0034     /*!
0035     @getter
0036     @return the type of this object.
0037     */
0038     int type; //SDC: default=KDb::UnknownObjectType no_setter
0039 
0040     /*!
0041     @getter
0042     @return the identifier of this object, default is -1.
0043     @setter
0044     Sets the identifier for this object.
0045     */
0046     int id; //SDC: default=-1
0047 
0048     /*!
0049     @getter
0050     @return the name of this object.
0051     @setter
0052     Sets the name for this object. It should be valid identifier,
0053     i.e. start with underscore or latin letter, contain underscores, latin letters and digits.
0054     */
0055     QString name; //SDC:
0056 
0057     /*!
0058     @getter
0059     @return the caption of this object, which is user-visible extended name which can be used
0060     in user interfaces and translated.
0061     @setter
0062     Sets the caption for this object.
0063     */
0064     QString caption; //SDC:
0065 
0066     /*!
0067     @getter
0068     @return the description of this object, which is explanation
0069             of the object's purpose, etc.
0070     It can be any text and can be used in user interfaces and translated.
0071     @setter
0072     Sets the description for this object.
0073     */
0074     QString description; //SDC:
0075 
0076     /*! @return caption of this object if it is not empty, else returns object's name.
0077     */
0078     inline QString captionOrName() const {
0079         return d->caption.isEmpty() ? d->name : d->caption;
0080     }
0081 
0082     //! Creates new object of type @a type. */
0083     explicit KDbObject(int type);
0084 
0085 protected:
0086     //! Clears all properties except 'type'.
0087     virtual void clear();
0088 };
0089 
0090 //! Sends information about object @a object to debug output @a dbg.
0091 KDB_EXPORT QDebug operator<<(QDebug dbg, const KDbObject& object);
0092 
0093 #endif