summaryrefslogtreecommitdiffstats
path: root/kexi/widget/kexicustompropertyfactory_p.cpp
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-01-20 01:29:50 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-01-20 01:29:50 +0000
commit8362bf63dea22bbf6736609b0f49c152f975eb63 (patch)
tree0eea3928e39e50fae91d4e68b21b1e6cbae25604 /kexi/widget/kexicustompropertyfactory_p.cpp
downloadkoffice-8362bf63dea22bbf6736609b0f49c152f975eb63.tar.gz
koffice-8362bf63dea22bbf6736609b0f49c152f975eb63.zip
Added old abandoned KDE3 version of koffice
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/koffice@1077364 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kexi/widget/kexicustompropertyfactory_p.cpp')
-rw-r--r--kexi/widget/kexicustompropertyfactory_p.cpp108
1 files changed, 108 insertions, 0 deletions
diff --git a/kexi/widget/kexicustompropertyfactory_p.cpp b/kexi/widget/kexicustompropertyfactory_p.cpp
new file mode 100644
index 00000000..0e0a054d
--- /dev/null
+++ b/kexi/widget/kexicustompropertyfactory_p.cpp
@@ -0,0 +1,108 @@
+/* This file is part of the KDE project
+ Copyright (C) 2005 Jaroslaw Staniek <[email protected]>
+
+ This library 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 library 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 library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+#include "kexicustompropertyfactory_p.h"
+
+#include <qlineedit.h>
+#include <kdebug.h>
+#include <koproperty/property.h>
+#include <kexiutils/identifier.h>
+
+using namespace KoProperty;
+
+KexiImagePropertyEdit::KexiImagePropertyEdit(
+ Property *property, QWidget *parent, const char *name)
+ : PixmapEdit(property, parent, name)
+ , m_id(0)
+{
+}
+
+KexiImagePropertyEdit::~KexiImagePropertyEdit()
+{
+}
+
+void KexiImagePropertyEdit::selectPixmap()
+{
+ QString fileName( PixmapEdit::selectPixmapFileName() );
+ if (fileName.isEmpty())
+ return;
+ KexiBLOBBuffer::Handle h(KexiBLOBBuffer::self()->insertPixmap( KURL(fileName) ));
+ setValue((uint)/*! @todo unsafe*/h.id());
+#if 0 //will be reenabled for new image collection
+ if(!m_manager->activeForm() || !property())
+ return;
+
+ ObjectTreeItem *item = m_manager->activeForm()->objectTree()->lookup(m_manager->activeForm()->selectedWidget()->name());
+ QString name = item ? item->pixmapName(property()->name()) : "";
+ PixmapCollectionChooser dialog( m_manager->activeForm()->pixmapCollection(), name, topLevelWidget() );
+ if(dialog.exec() == QDialog::Accepted) {
+ setValue(dialog.pixmap(), true);
+ item->setPixmapName(property()->name(), dialog.pixmapName());
+ }
+#endif
+}
+
+QVariant KexiImagePropertyEdit::value() const
+{
+ return (uint)/*! @todo unsafe*/m_id;
+}
+
+void KexiImagePropertyEdit::setValue(const QVariant &value, bool emitChange)
+{
+ m_id = value.toInt();
+ PixmapEdit::setValue(KexiBLOBBuffer::self()->objectForId(m_id).pixmap(), emitChange);
+}
+
+void KexiImagePropertyEdit::drawViewer(QPainter *p, const QColorGroup &cg, const QRect &r,
+ const QVariant &value)
+{
+ KexiBLOBBuffer::Handle h( KexiBLOBBuffer::self()->objectForId(value.toInt()) );
+ PixmapEdit::drawViewer(p, cg, r, h.pixmap());
+}
+
+//----------------------------------------------------------------
+
+KexiIdentifierPropertyEdit::KexiIdentifierPropertyEdit(
+ Property *property, QWidget *parent, const char *name)
+ : StringEdit(property, parent, name)
+{
+ m_edit->setValidator(
+ new KexiUtils::IdentifierValidator(m_edit, "KexiIdentifierPropertyEdit Validator") );
+}
+
+KexiIdentifierPropertyEdit::~KexiIdentifierPropertyEdit()
+{
+}
+
+void KexiIdentifierPropertyEdit::setValue(const QVariant &value, bool emitChange)
+{
+ QString string(value.toString());
+ if (string.isEmpty()) {
+ kdWarning() << "KexiIdentifierPropertyEdit::setValue(): "
+ "Value cannot be empty. This call has no effect." << endl;
+ return;
+ }
+ QString identifier( KexiUtils::string2Identifier(string) );
+ if (identifier!=string)
+ kdDebug() << QString("KexiIdentifierPropertyEdit::setValue(): "
+ "String \"%1\" converted to identifier \"%2\".").arg(string).arg(identifier) << endl;
+ StringEdit::setValue( identifier, emitChange );
+}
+
+#include "kexicustompropertyfactory_p.moc"