summaryrefslogtreecommitdiffstats
path: root/kexi/core/kexiblobbuffer.cpp
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2011-06-25 05:28:35 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2011-06-25 05:28:35 +0000
commitf008adb5a77e094eaf6abf3fc0f36958e66896a5 (patch)
tree8e9244c4d4957c36be81e15b566b4aa5ea26c982 /kexi/core/kexiblobbuffer.cpp
parent1210f27b660efb7b37ff43ec68763e85a403471f (diff)
downloadkoffice-f008adb5a77e094eaf6abf3fc0f36958e66896a5.tar.gz
koffice-f008adb5a77e094eaf6abf3fc0f36958e66896a5.zip
TQt4 port koffice
This should enable compilation under both Qt3 and Qt4; fixes for any missed components will be forthcoming git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/koffice@1238284 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kexi/core/kexiblobbuffer.cpp')
-rw-r--r--kexi/core/kexiblobbuffer.cpp84
1 files changed, 42 insertions, 42 deletions
diff --git a/kexi/core/kexiblobbuffer.cpp b/kexi/core/kexiblobbuffer.cpp
index d66d69af..d1f78c4a 100644
--- a/kexi/core/kexiblobbuffer.cpp
+++ b/kexi/core/kexiblobbuffer.cpp
@@ -21,9 +21,9 @@
#include <assert.h>
-#include <qfile.h>
-#include <qfileinfo.h>
-#include <qbuffer.h>
+#include <tqfile.h>
+#include <tqfileinfo.h>
+#include <tqbuffer.h>
#include <kdebug.h>
#include <kstaticdeleter.h>
@@ -47,11 +47,11 @@ class KexiBLOBBuffer::Private
{
}
Id_t maxId; //!< Used to compute maximal recently used identifier for unstored BLOB
-//! @todo will be changed to QHash<quint64, Item>
- QIntDict<Item> inMemoryItems; //!< for unstored BLOBs
- QIntDict<Item> storedItems; //!< for stored items
- QDict<Item> itemsByURL;
- QGuardedPtr<KexiDB::Connection> conn;
+//! @todo will be changed to TQHash<quint64, Item>
+ TQIntDict<Item> inMemoryItems; //!< for unstored BLOBs
+ TQIntDict<Item> storedItems; //!< for stored items
+ TQDict<Item> itemsByURL;
+ TQGuardedPtr<KexiDB::Connection> conn;
};
//-----------------
@@ -110,22 +110,22 @@ void KexiBLOBBuffer::Handle::setStoredWidthID(KexiBLOBBuffer::Id_t id)
//-----------------
-KexiBLOBBuffer::Item::Item(const QByteArray& data, KexiBLOBBuffer::Id_t ident, bool _stored,
- const QString& _name, const QString& _caption, const QString& _mimeType,
- Id_t _folderId, const QPixmap& pixmap)
+KexiBLOBBuffer::Item::Item(const TQByteArray& data, KexiBLOBBuffer::Id_t ident, bool _stored,
+ const TQString& _name, const TQString& _caption, const TQString& _mimeType,
+ Id_t _folderId, const TQPixmap& pixmap)
: name(_name), caption(_caption), mimeType(_mimeType), refs(0),
id(ident), folderId(_folderId), stored(_stored),
m_pixmapLoaded(new bool(false)/*workaround for pixmap() const*/)
{
if (pixmap.isNull())
- m_pixmap = new QPixmap();
+ m_pixmap = new TQPixmap();
else
- m_pixmap = new QPixmap(pixmap);
+ m_pixmap = new TQPixmap(pixmap);
if (data.isEmpty())
- m_data = new QByteArray();
+ m_data = new TQByteArray();
else
- m_data = new QByteArray(data);
+ m_data = new TQByteArray(data);
}
KexiBLOBBuffer::Item::~Item()
@@ -138,10 +138,10 @@ KexiBLOBBuffer::Item::~Item()
delete m_pixmapLoaded;
}
-QPixmap KexiBLOBBuffer::Item::pixmap() const
+TQPixmap KexiBLOBBuffer::Item::pixmap() const
{
if (!*m_pixmapLoaded && m_pixmap->isNull() && !m_data->isEmpty()) {
- QString type( KImageIO::typeForMime(mimeType) );
+ TQString type( KImageIO::typeForMime(mimeType) );
if (!KImageIO::canRead( type ) || !m_pixmap->loadFromData(*m_data, type.latin1())) {
//! @todo inform about error?
}
@@ -150,18 +150,18 @@ QPixmap KexiBLOBBuffer::Item::pixmap() const
return *m_pixmap;
}
-QByteArray KexiBLOBBuffer::Item::data() const
+TQByteArray KexiBLOBBuffer::Item::data() const
{
if (!m_data->isEmpty())
return *m_data;
if (m_data->isEmpty() && m_pixmap->isNull())
- return QByteArray();
+ return TQByteArray();
if (m_data->isEmpty() && !m_pixmap->isNull()) {
//convert pixmap to byte array
//(do it only on demand)
- QBuffer buffer( *m_data );
+ TQBuffer buffer( *m_data );
buffer.open( IO_WriteOnly );
m_pixmap->save( &buffer, mimeType.isEmpty() ? (const char*)"PNG"/*! @todo default? */ : mimeType.latin1() );
}
@@ -171,7 +171,7 @@ QByteArray KexiBLOBBuffer::Item::data() const
//-----------------
KexiBLOBBuffer::KexiBLOBBuffer()
- : QObject()
+ : TQObject()
, d(new Private())
{
Q_ASSERT(!m_buffer);
@@ -193,38 +193,38 @@ KexiBLOBBuffer::Handle KexiBLOBBuffer::insertPixmap(const KURL& url)
return KexiBLOBBuffer::Handle();
}
//! @todo what about searching by filename only and then compare data?
- Item * item = d->itemsByURL.find(url.prettyURL());
+ Item * item = d->itemsByURL.tqfind(url.prettyURL());
if (item)
return KexiBLOBBuffer::Handle(item);
- QString fileName = url.isLocalFile() ? url.path() : url.prettyURL();
+ TQString fileName = url.isLocalFile() ? url.path() : url.prettyURL();
//! @todo download the file if remote, then set fileName properly
- QFile f(fileName);
+ TQFile f(fileName);
if (!f.open(IO_ReadOnly)) {
//! @todo err msg
return KexiBLOBBuffer::Handle();
}
- QString mimeType( KImageIO::mimeType( fileName ) );
+ TQString mimeType( KImageIO::mimeType( fileName ) );
- QByteArray data( f.readAll() );
+ TQByteArray data( f.readAll() );
if (f.status()!=IO_Ok) {
//! @todo err msg
return KexiBLOBBuffer::Handle();
}
- QFileInfo fi(url.fileName());
- QString caption(fi.baseName().replace('_', " ").simplifyWhiteSpace());
+ TQFileInfo fi(url.fileName());
+ TQString caption(fi.baseName().tqreplace('_', " ").simplifyWhiteSpace());
item = new Item(data, ++d->maxId, /*!stored*/false, url.fileName(), caption, mimeType);
insertItem(item);
//cache
item->prettyURL = url.prettyURL();
- d->itemsByURL.replace(url.prettyURL(), item);
+ d->itemsByURL.tqreplace(url.prettyURL(), item);
return KexiBLOBBuffer::Handle(item);
}
-KexiBLOBBuffer::Handle KexiBLOBBuffer::insertObject(const QByteArray& data,
- const QString& name, const QString& caption, const QString& mimeType, KexiBLOBBuffer::Id_t identifier)
+KexiBLOBBuffer::Handle KexiBLOBBuffer::insertObject(const TQByteArray& data,
+ const TQString& name, const TQString& caption, const TQString& mimeType, KexiBLOBBuffer::Id_t identifier)
{
KexiBLOBBuffer::Id_t newIdentifier;
if (identifier>0)
@@ -237,17 +237,17 @@ KexiBLOBBuffer::Handle KexiBLOBBuffer::insertObject(const QByteArray& data,
return KexiBLOBBuffer::Handle(item);
}
-KexiBLOBBuffer::Handle KexiBLOBBuffer::insertPixmap(const QPixmap& pixmap)
+KexiBLOBBuffer::Handle KexiBLOBBuffer::insertPixmap(const TQPixmap& pixmap)
{
if (pixmap.isNull())
return KexiBLOBBuffer::Handle();
Item * item = new Item(
- QByteArray(), //(pixmap will be converted to byte array on demand)
+ TQByteArray(), //(pixmap will be converted to byte array on demand)
++d->maxId,
false, //not stored
- QString::null,
- QString::null,
+ TQString(),
+ TQString(),
"image/png", //!< @todo OK? What about jpegs?
0, //folder id
pixmap);
@@ -261,7 +261,7 @@ KexiBLOBBuffer::Handle KexiBLOBBuffer::objectForId(Id_t id, bool stored)
if (id<=0)
return KexiBLOBBuffer::Handle();
if (stored) {
- Item *item = d->storedItems.find(id);
+ Item *item = d->storedItems.tqfind(id);
if (item || !d->conn)
return KexiBLOBBuffer::Handle(item);
//retrieve stored BLOB:
@@ -273,7 +273,7 @@ KexiBLOBBuffer::Handle KexiBLOBBuffer::objectForId(Id_t id, bool stored)
//! @todo err msg
return KexiBLOBBuffer::Handle();
}
-/* QStringList where;
+/* TQStringList where;
where << "o_id";
KexiDB::PreparedStatement::Ptr st = d->conn->prepareStatement(
KexiDB::PreparedStatement::SelectStatement, *blobsTable, where);*/
@@ -284,13 +284,13 @@ KexiBLOBBuffer::Handle KexiBLOBBuffer::objectForId(Id_t id, bool stored)
schema.addField( blobsTable->field("o_caption") );
schema.addField( blobsTable->field("o_mime") );
schema.addField( blobsTable->field("o_folder_id") );
- schema.addToWhereExpression(blobsTable->field("o_id"), QVariant((Q_LLONG)id));
+ schema.addToWhereExpression(blobsTable->field("o_id"), TQVariant((TQ_LLONG)id));
KexiDB::RowData rowData;
tristate res = d->conn->querySingleRecord(
schema,
-// QString::fromLatin1("SELECT o_data, o_name, o_caption, o_mime FROM kexi__blobs where o_id=")
-// +QString::number(id),
+// TQString::tqfromLatin1("SELECT o_data, o_name, o_caption, o_mime FROM kexi__blobs where o_id=")
+// +TQString::number(id),
rowData);
if (res!=true || rowData.size()<4) {
//! @todo err msg
@@ -306,7 +306,7 @@ KexiBLOBBuffer::Handle KexiBLOBBuffer::objectForId(Id_t id, bool stored)
rowData[1].toString(),
rowData[2].toString(),
rowData[3].toString(),
- (Id_t)rowData[4].toInt() //!< @todo folder id: fix Id_t for Qt4
+ (Id_t)rowData[4].toInt() //!< @todo folder id: fix Id_t for TQt4
);
insertItem(item);
@@ -314,7 +314,7 @@ KexiBLOBBuffer::Handle KexiBLOBBuffer::objectForId(Id_t id, bool stored)
//#endif
}
else
- return KexiBLOBBuffer::Handle(d->inMemoryItems.find(id));
+ return KexiBLOBBuffer::Handle(d->inMemoryItems.tqfind(id));
}
KexiBLOBBuffer::Handle KexiBLOBBuffer::objectForId(Id_t id)