kexi
kexicustompropertyfactory_p.cpp00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "kexicustompropertyfactory_p.h"
00021
00022 #include <qlineedit.h>
00023 #include <kdebug.h>
00024 #include <koproperty/property.h>
00025 #include <kexiutils/identifier.h>
00026
00027 using namespace KoProperty;
00028
00029 KexiImagePropertyEdit::KexiImagePropertyEdit(
00030 Property *property, QWidget *parent, const char *name)
00031 : PixmapEdit(property, parent, name)
00032 , m_id(0)
00033 {
00034 }
00035
00036 KexiImagePropertyEdit::~KexiImagePropertyEdit()
00037 {
00038 }
00039
00040 void KexiImagePropertyEdit::selectPixmap()
00041 {
00042 QString fileName( PixmapEdit::selectPixmapFileName() );
00043 if (fileName.isEmpty())
00044 return;
00045 KexiBLOBBuffer::Handle h(KexiBLOBBuffer::self()->insertPixmap( KURL(fileName) ));
00046 setValue((uint)h.id());
00047 #if 0 //will be reenabled for new image collection
00048 if(!m_manager->activeForm() || !property())
00049 return;
00050
00051 ObjectTreeItem *item = m_manager->activeForm()->objectTree()->lookup(m_manager->activeForm()->selectedWidget()->name());
00052 QString name = item ? item->pixmapName(property()->name()) : "";
00053 PixmapCollectionChooser dialog( m_manager->activeForm()->pixmapCollection(), name, topLevelWidget() );
00054 if(dialog.exec() == QDialog::Accepted) {
00055 setValue(dialog.pixmap(), true);
00056 item->setPixmapName(property()->name(), dialog.pixmapName());
00057 }
00058 #endif
00059 }
00060
00061 QVariant KexiImagePropertyEdit::value() const
00062 {
00063 return (uint)m_id;
00064 }
00065
00066 void KexiImagePropertyEdit::setValue(const QVariant &value, bool emitChange)
00067 {
00068 m_id = value.toInt();
00069 PixmapEdit::setValue(KexiBLOBBuffer::self()->objectForId(m_id).pixmap(), emitChange);
00070 }
00071
00072 void KexiImagePropertyEdit::drawViewer(QPainter *p, const QColorGroup &cg, const QRect &r,
00073 const QVariant &value)
00074 {
00075 KexiBLOBBuffer::Handle h( KexiBLOBBuffer::self()->objectForId(value.toInt()) );
00076 PixmapEdit::drawViewer(p, cg, r, h.pixmap());
00077 }
00078
00079
00080
00081 KexiIdentifierPropertyEdit::KexiIdentifierPropertyEdit(
00082 Property *property, QWidget *parent, const char *name)
00083 : StringEdit(property, parent, name)
00084 {
00085 m_edit->setValidator(
00086 new KexiUtils::IdentifierValidator(m_edit, "KexiIdentifierPropertyEdit Validator") );
00087 }
00088
00089 KexiIdentifierPropertyEdit::~KexiIdentifierPropertyEdit()
00090 {
00091 }
00092
00093 void KexiIdentifierPropertyEdit::setValue(const QVariant &value, bool emitChange)
00094 {
00095 QString string(value.toString());
00096 if (string.isEmpty()) {
00097 kdWarning() << "KexiIdentifierPropertyEdit::setValue(): "
00098 "Value cannot be empty. This call has no effect." << endl;
00099 return;
00100 }
00101 QString identifier( KexiUtils::string2Identifier(string) );
00102 if (identifier!=string)
00103 kdDebug() << QString("KexiIdentifierPropertyEdit::setValue(): "
00104 "String \"%1\" converted to identifier \"%2\".").arg(string).arg(identifier) << endl;
00105 StringEdit::setValue( identifier, emitChange );
00106 }
00107
00108 #include "kexicustompropertyfactory_p.moc"
|