File indexing completed on 2025-01-05 04:47:01
0001 /*************************************************************************** 0002 * SPDX-FileCopyrightText: 2006 Tobias Koenig <tokoe@kde.org> * 0003 * SPDX-FileCopyrightText: 2013 Volker Krause <vkrause@kde.org> * 0004 * * 0005 * SPDX-License-Identifier: LGPL-2.0-or-later * 0006 ***************************************************************************/ 0007 0008 #pragma once 0009 0010 #include <QList> 0011 #include <QMap> 0012 #include <QString> 0013 #include <QStringList> 0014 0015 namespace Akonadi 0016 { 0017 namespace Server 0018 { 0019 /** 0020 * @short A helper class that describes a column of a table for the DbInitializer 0021 */ 0022 class ColumnDescription 0023 { 0024 public: 0025 enum ReferentialAction { 0026 Cascade, 0027 Restrict, 0028 SetNull, 0029 }; 0030 0031 QString name; 0032 QString type; 0033 int size = -1; 0034 bool allowNull = true; 0035 bool isAutoIncrement = false; 0036 bool isPrimaryKey = false; 0037 bool isUnique = false; 0038 bool isEnum = false; 0039 QString refTable; 0040 QString refColumn; 0041 QString defaultValue; 0042 ReferentialAction onUpdate = Cascade; 0043 ReferentialAction onDelete = Cascade; 0044 bool noUpdate = false; 0045 0046 QMap<QString, int> enumValueMap; 0047 }; 0048 0049 /** 0050 * @short A helper class that describes indexes of a table for the DbInitializer 0051 */ 0052 class IndexDescription 0053 { 0054 public: 0055 QString name; 0056 QStringList columns; 0057 bool isUnique = false; 0058 QString sort; 0059 }; 0060 0061 /** 0062 * @short A helper class that describes the predefined data of a table for the DbInitializer 0063 */ 0064 class DataDescription 0065 { 0066 public: 0067 /** 0068 * Key contains the column name, value the data. 0069 */ 0070 QMap<QString, QString> data; 0071 }; 0072 0073 /** 0074 * @short A helper class that describes a table for the DbInitializer 0075 */ 0076 class TableDescription 0077 { 0078 public: 0079 int primaryKeyColumnCount() const; 0080 0081 QString name; 0082 QList<ColumnDescription> columns; 0083 QList<IndexDescription> indexes; 0084 QList<DataDescription> data; 0085 }; 0086 0087 /** 0088 * @short A helper class that describes the relation between two tables for the DbInitializer 0089 */ 0090 class RelationDescription 0091 { 0092 public: 0093 QString firstTable; 0094 QString firstColumn; 0095 QString secondTable; 0096 QString secondColumn; 0097 QList<IndexDescription> indexes; 0098 }; 0099 0100 /** 0101 * @short TableDescription constructed based on RelationDescription 0102 */ 0103 class RelationTableDescription : public TableDescription 0104 { 0105 public: 0106 explicit RelationTableDescription(const RelationDescription &relation); 0107 }; 0108 0109 } // namespace Server 0110 } // namespace Akonadi 0111 0112 Q_DECLARE_TYPEINFO(Akonadi::Server::ColumnDescription, Q_RELOCATABLE_TYPE); 0113 Q_DECLARE_TYPEINFO(Akonadi::Server::IndexDescription, Q_RELOCATABLE_TYPE); 0114 Q_DECLARE_TYPEINFO(Akonadi::Server::DataDescription, Q_RELOCATABLE_TYPE); 0115 Q_DECLARE_TYPEINFO(Akonadi::Server::TableDescription, Q_RELOCATABLE_TYPE); 0116 Q_DECLARE_TYPEINFO(Akonadi::Server::RelationDescription, Q_RELOCATABLE_TYPE); 0117 Q_DECLARE_TYPEINFO(Akonadi::Server::RelationTableDescription, Q_RELOCATABLE_TYPE);