summaryrefslogtreecommitdiffstats
path: root/kexi/plugins/scripting/kexidb/kexidbfield.h
blob: 4cc85f38ca4f7ec8b186d7ad264f59ad1d7b5b47 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
/***************************************************************************
 * kexidbfield.h
 * This file is part of the KDE project
 * copyright (C)2004-2005 by Sebastian Sauer (mail@dipe.org)
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 * 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
 * Library General Public License for more details.
 * You should have received a copy of the GNU Library General Public License
 * along with this program; see the file COPYING.  If not, write to
 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301, USA.
 ***************************************************************************/

#ifndef KROSS_KEXIDB_KEXIDBFIELD_H
#define KROSS_KEXIDB_KEXIDBFIELD_H

#include <tqstring.h>

#include <api/object.h>
#include <api/list.h>
#include <api/class.h>

#include <kexidb/drivermanager.h>
#include <kexidb/field.h>

namespace Kross { namespace KexiDB {

    /**
    * A field in a record.
    */
    class KexiDBField : public Kross::Api::Class<KexiDBField>
    {
        public:
            KexiDBField(::KexiDB::Field* field);
            virtual ~KexiDBField();
            virtual const TQString getClassName() const;
            ::KexiDB::Field* field() { return m_field; }

        private:

            /** Returns the type string for this field, e.g. "Integer" for Integer type. */
            const TQString type();
            /** Sets the type string for this field, e.g. "Integer" for Integer type. */
            void setType(const TQString type);

            /** Returns the optional subtype for this field. Subtype is a string providing
            additional hint for field's type. E.g. for BLOB type, it can be a MIME type or
            certain TQVariant type name, for example: TQPIXMAP_OBJECT_NAME_STRING, "TQColor" or "TQFont". */
            const TQString subType();
            /** Sets the optional subtype for this field. */
            void setSubType(const TQString& subtype);

            /** Returns the TQVariant::typeName which is equivalent to the type this field has. */
            const TQString variantType();
            /** Returns type group string for this field, e.g. "IntegerGroup" for IntegerGroup type. */
            const TQString typeGroup();

            /** Returns true if the field is autoincrement (e.g. integer/numeric). */
            bool isAutoInc();
            /** Sets auto increment flag. */
            void setAutoInc(bool autoinc);

            /** Returns true if the field is member of single-field unique key. */
            bool isUniqueKey();
            /** Specifies whether the field has single-field unique constraint or not. */
            void setUniqueKey(bool unique);

            /** Returns true if the field is member of single-field primary key. */
            bool isPrimaryKey();
            /** Specifies whether the field is single-field primary key or not. */
            void setPrimaryKey(bool primary);

            /** Returns true if the field is member of single-field foreign key. */
            bool isForeignKey();
            /** Sets whether the field has to be declared with single-field foreign key. */
            void setForeignKey(bool foreign);

            /** Returns true if the field is not allowed to be null. */
            bool isNotNull();
            /** Specifies whether the field has single-field unique constraint or not. */
            void setNotNull(bool notnull);

            /** Returns true if the field is not allowed to be empty. */
            bool isNotEmpty();
            /** Specifies whether the field has single-field unique constraint or not. */
            void setNotEmpty(bool notempty);

            /** Returns true if the field is indexed using single-field database index. */
            bool isIndexed();
            /** Specifies whether the field is indexed or not. */
            void setIndexed(bool indexed);

            /** Returns true if the field is an unsigned integer. */
            bool isUnsigned();
            /** Specifies whether the field is an unsigned integer or not. */
            void setUnsigned(bool isunsigned);

            /** Returns the name of this field. */
            const TQString name();
            /** Sets the name of this field. */
            void setName(const TQString& name);

            /** Returns the caption of this field. */
            const TQString caption();
            /** Sets the caption of this field. */
            void setCaption(const TQString& caption);

            /** Returns the descriptive text for this field. */
            const TQString description();
            /** Set the description for this field. */
            void setDescription(const TQString& desc);

            /** Returns the length of text if the field type is text. */
            uint length();
            /** Sets the length for this field. Only works for Text Type (not including LongText). */
            void setLength(uint length);

            /** Returns precision for numeric and other fields that have both length and
            precision (floating point types). */
            uint precision();
            /** Sets the precision for numeric and other fields. */
            void setPrecision(uint precision);

            /** Returns the width of this field (usually in pixels or points).
            0 (the default) means there is no hint for the width. */
            uint width();
            /** Sets the width of this field. */
            void setWidth(uint width);

            /** Returns the default value this field has. */
            TQVariant defaultValue();
            /** Sets the default value this field has. */
            void setDefaultValue(const TQVariant& defaultvalue);

        private:
            ::KexiDB::Field* m_field;
    };

}}

#endif