kexi

kexiblobbuffer.h
1/* This file is part of the KDE project
2 Copyright (C) 2005 Jaroslaw Staniek <js@iidea.pl>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18*/
19
20#ifndef KEXIBLOBBUFFER_H
21#define KEXIBLOBBUFFER_H
22
23#include <tqobject.h>
24#include <tqintdict.h>
25#include <tqdict.h>
26#include <tqpixmap.h>
27
28#include <kurl.h>
29
30namespace KexiDB
31{
32 class Connection;
33}
34
36
80class KEXICORE_EXPORT KexiBLOBBuffer : public TQObject
81{
82 TQ_OBJECT
83
84
85 private:
86 class Item;
87 public:
89 typedef long Id_t;
90
92 static KexiBLOBBuffer* self();
93
94 static void setConnection(KexiDB::Connection *conn);
95
97 class KEXICORE_EXPORT Handle {
98 public:
101 Handle();
102
104 Handle(const Handle& handle);
105
106 ~Handle();
107
108 Id_t id() const { return m_item ? m_item->id : 0; }
109
112 bool stored() const { return m_item ? m_item->stored : false; }
113
115 operator bool() const { return m_item; }
116
117 Handle& operator=(const Handle& handle);
118
119 TQByteArray data() const { return m_item ? m_item->data() : TQByteArray(); }
120
121 TQPixmap pixmap() const { return m_item ? m_item->pixmap() : TQPixmap(); }
122
125 void setStoredWidthID(Id_t id);
126
127 TQString originalFileName() const { return m_item ? m_item->name: TQString(); }
128
129 TQString mimeType() const { return m_item ? m_item->mimeType : TQString(); }
130
131 Id_t folderId() const { return m_item ? m_item->folderId : 0; }
132
133 protected:
135 Handle(Item* item);
136 private:
137 Item* m_item;
138 friend class KexiBLOBBuffer;
139 };
140
143
145
151 Handle insertPixmap(const KURL& url);
152
162 Handle insertObject(const TQByteArray& data, const TQString& name,
163 const TQString& caption, const TQString& mimeType, Id_t identifier = 0);
164
166 Handle insertPixmap(const TQPixmap& pixmap);
167
171 Handle objectForId(Id_t id, bool stored);
172
175 Handle objectForId(Id_t id);
176
177 protected:
180 void removeItem(Id_t id, bool stored);
181
183 void takeItem(Item* item);
184
186 void insertItem(Item* item);
187
188 private:
189 class KEXICORE_EXPORT Item {
190 public:
191 Item(const TQByteArray& data, Id_t ident,
192 bool stored,
193 const TQString& name = TQString(),
194 const TQString& caption = TQString(),
195 const TQString& mimeType = TQString(),
196 Id_t folderId = 0,
197 const TQPixmap& pixmap = TQPixmap());
198 ~Item();
199 TQPixmap pixmap() const;
200 TQByteArray data() const;
201// KexiBLOBBuffer* buf;
202// KURL url;
203 TQString name;
204 TQString caption;
205 TQString mimeType;
206 uint refs;
207 Id_t id;
208 Id_t folderId;
209 bool stored : 1;
210 TQString prettyURL;
211 private:
212 TQByteArray *m_data;
213 TQPixmap *m_pixmap;
214 bool *m_pixmapLoaded;
216 friend class KexiBLOBBuffer;
217 };
218 class Private;
219 Private *d;
220 friend class Handle;
221};
222
223#endif
Object handle used by KexiBLOBBuffer.
Application-wide buffer for local BLOB data like pixmaps.
long Id_t
long integer for unique identifying blobs
Provides database connection, allowing queries and data modification.
Definition connection.h:62
High-level database connectivity library with database backend drivers.