diff options
| author | 2009-02-17 16:39:30 +0000 | |
|---|---|---|
| committer | 2009-02-17 16:39:30 +0000 | |
| commit | 363260b05b3f6edb1a6a9e2244fd8c7b8c559652 (patch) | |
| tree | 70258362129d962852b4f9b8a25ae26ded004c1c /src/modules | |
| parent | fix for #368 (diff) | |
| download | KVIrc-363260b05b3f6edb1a6a9e2244fd8c7b8c559652.tar.gz KVIrc-363260b05b3f6edb1a6a9e2244fd8c7b8c559652.tar.bz2 KVIrc-363260b05b3f6edb1a6a9e2244fd8c7b8c559652.zip | |
More work on objects module (w.i.p.)
git-svn-id: https://svn.kvirc.de/svn/trunk/kvirc@3079 17fca916-40b9-46aa-a4ea-0a15b648b75c
Diffstat (limited to 'src/modules')
| -rw-r--r-- | src/modules/objects/class_button.cpp | 4 | ||||
| -rw-r--r-- | src/modules/objects/class_datetimeedit.cpp | 4 | ||||
| -rw-r--r-- | src/modules/objects/class_painter.cpp | 2 | ||||
| -rw-r--r-- | src/modules/objects/class_pixmap.cpp | 478 | ||||
| -rw-r--r-- | src/modules/objects/class_pixmap.h | 39 | ||||
| -rw-r--r-- | src/modules/objects/class_sql.cpp | 33 | ||||
| -rw-r--r-- | src/modules/objects/class_sql.h | 2 | ||||
| -rw-r--r-- | src/modules/objects/class_tablewidget.cpp | 75 | ||||
| -rw-r--r-- | src/modules/objects/class_tablewidget.h | 6 | ||||
| -rw-r--r-- | src/modules/objects/class_treewidget.cpp | 2 | ||||
| -rw-r--r-- | src/modules/objects/class_widget.cpp | 6 | ||||
| -rw-r--r-- | src/modules/objects/libkviobjects.cpp | 12 |
12 files changed, 382 insertions, 281 deletions
diff --git a/src/modules/objects/class_button.cpp b/src/modules/objects/class_button.cpp index 6dc64094d..b4f450fed 100644 --- a/src/modules/objects/class_button.cpp +++ b/src/modules/objects/class_button.cpp @@ -61,7 +61,9 @@ @signals: !sg: $clicked() This signal is emitted by the default implementation of [classfnc]$clickEvent[/classfnc](). - + @properties: + !pr: $scaledContents() + This property holds whether the label will scale its contents to fill all available space. */ diff --git a/src/modules/objects/class_datetimeedit.cpp b/src/modules/objects/class_datetimeedit.cpp index b2a7d8ad0..078b72af3 100644 --- a/src/modules/objects/class_datetimeedit.cpp +++ b/src/modules/objects/class_datetimeedit.cpp @@ -75,7 +75,9 @@ KVSO_END_DESTRUCTOR(KviKvsObject_datetimeedit) bool KviKvsObject_datetimeedit::init(KviKvsRunTimeContext *,KviKvsVariantList *) { - SET_OBJECT(QDateTimeEdit); + QDateTimeEdit *obj=new QDateTimeEdit(QDate::currentDate(),parentScriptWidget()); + obj->setObjectName(getName()); + setObject(obj,true); // connect(widget(),SIGNAL(clicked()),this,SLOT(slotClicked())); return true; } diff --git a/src/modules/objects/class_painter.cpp b/src/modules/objects/class_painter.cpp index 72f889bf7..5991585ee 100644 --- a/src/modules/objects/class_painter.cpp +++ b/src/modules/objects/class_painter.cpp @@ -1046,7 +1046,7 @@ KVSO_CLASS_FUNCTION(painter,begin) return true; } attachDevice(pObject,pd); - if (pObject->inheritsClass("pixmap")) ((KviKvsObject_pixmap *)pObject)->pixmapChanged(); + //if (pObject->inheritsClass("pixmap")) ((KviKvsObject_pixmap *)pObject)->pixmapChanged(); return true; } diff --git a/src/modules/objects/class_pixmap.cpp b/src/modules/objects/class_pixmap.cpp index 627c8eedd..d8edf2100 100644 --- a/src/modules/objects/class_pixmap.cpp +++ b/src/modules/objects/class_pixmap.cpp @@ -24,7 +24,10 @@ //============================================================================= #include "class_pixmap.h" +#include "class_widget.h" + #include "class_memorybuffer.h" +#include "kvi_animatedpixmap.h" #include "kvi_debug.h" #include "kvi_locale.h" @@ -52,306 +55,299 @@ Note that x_offset, y_offest are offsets in the widget. !fn: $resize(<width:integer>,<height:integer>) Resizes the pixmap to w width and h height. Set wh or hg to 0, to have a null pixmap. - !fn: $scale(<width:integer>,<height:integer>,[<aspect_ratio:string>,<transformation_type:string>]) - Scales the pixmap by sx horizontally and sy vertically. + !fn: $scale(<width:integer>,<height:integer>,[<aspect_ratio:string>]) + Scales the pixmap or the animation by sx horizontally and sy vertically. Aspect_ratio values: - IgnoreAspectRatio:the pixmap is scaled ignoring his aspect ratio. - KeepAspectRatio: pixmap is scaled to a rectangle as large as possible inside size, preserving the aspect ratio. - KeepAspectRatioByExpanding, the pixmap is scaled to a rectangle as small as possible outside size, preserving the aspect ratio. - Transformation type values: - - Fast: fast transformation but less quality. - - Smooth: more quality using bilinear filtering. - !fn: $rotate(<a:real>) - Rotates the pixmap by a degrees. - !fn: $load(<file_name:string>) - Load a pixmap from the <file>. + Default value is KeepAspectRatio. + !fn: $load(<file_name:string>) + Load a pixmap from the file <file_name>. + !fn: $save(<file_name:string>) + Save the pixmap or the current animation frame to the file <file_name>. + !fn: $loadAnimation(<file_name:string>) + Load an animation from the file <file_name> and start it. + !fn: $startAnimation() + Start the animation. + !fn: $stopAnimation() + Stop the animation. !fn: <integer> $height() - Return the height of the pixmap. + Return the height of the pixmap or of the animation. !fn: <integer> $width() - Return the width of the pixmap. + Return the width of the pixmap or of the animation. + !fn: $frameChangedEvent() + This event is triggered by KVIrc when the current animation frame changes. + @signals: + !sg: $frameChanged() + This signal is emitted by the default implementation of [classfnc]$frameChangedEvent[/classfnc]().[br] */ KVSO_BEGIN_REGISTERCLASS(KviKvsObject_pixmap,"pixmap","object") - KVSO_REGISTER_HANDLER_BY_NAME(KviKvsObject_pixmap,fill) - KVSO_REGISTER_HANDLER_BY_NAME(KviKvsObject_pixmap,resize) - KVSO_REGISTER_HANDLER_BY_NAME(KviKvsObject_pixmap,load) - KVSO_REGISTER_HANDLER_BY_NAME(KviKvsObject_pixmap,loadFromMemoryBuffer) - - KVSO_REGISTER_HANDLER_BY_NAME(KviKvsObject_pixmap,height) - - KVSO_REGISTER_HANDLER_BY_NAME(KviKvsObject_pixmap,width) - KVSO_REGISTER_HANDLER_BY_NAME(KviKvsObject_pixmap,setOpacity) - KVSO_REGISTER_HANDLER_BY_NAME(KviKvsObject_pixmap,scale) - KVSO_REGISTER_HANDLER_BY_NAME(KviKvsObject_pixmap,rotate) + KVSO_REGISTER_HANDLER_BY_NAME(KviKvsObject_pixmap,fill) + KVSO_REGISTER_HANDLER_BY_NAME(KviKvsObject_pixmap,resize) + KVSO_REGISTER_HANDLER_BY_NAME(KviKvsObject_pixmap,scale) + KVSO_REGISTER_HANDLER_BY_NAME(KviKvsObject_pixmap,load) + KVSO_REGISTER_HANDLER_BY_NAME(KviKvsObject_pixmap,loadAnimation) + KVSO_REGISTER_HANDLER_BY_NAME(KviKvsObject_pixmap,save) + KVSO_REGISTER_HANDLER_BY_NAME(KviKvsObject_pixmap,startAnimation) + KVSO_REGISTER_HANDLER_BY_NAME(KviKvsObject_pixmap,stopAnimation) + KVSO_REGISTER_HANDLER_BY_NAME(KviKvsObject_pixmap,loadFromMemoryBuffer) + KVSO_REGISTER_HANDLER_BY_NAME(KviKvsObject_pixmap,height) + KVSO_REGISTER_HANDLER_BY_NAME(KviKvsObject_pixmap,width) + KVSO_REGISTER_HANDLER_BY_NAME(KviKvsObject_pixmap,grabWidget) + KVSO_REGISTER_HANDLER_BY_NAME(KviKvsObject_pixmap,frameChangedEvent) KVSO_END_REGISTERCLASS(KviKvsObject_pixmap) KVSO_BEGIN_CONSTRUCTOR(KviKvsObject_pixmap,KviKvsObject) - m_pPixmap=new QPixmap(); - m_pImage=new QImage(); - bPixmapModified=false; - bImageModified=false; + m_pAnimatedPixmap = 0; + m_pPixmap = 0; KVSO_END_CONSTRUCTOR(KviKvsObject_pixmap) KVSO_BEGIN_DESTRUCTOR(KviKvsObject_pixmap) - - emit aboutToDie(); - delete m_pPixmap; - if (m_pImage) delete m_pImage; - + emit aboutToDie(); + if (m_pPixmap)delete m_pPixmap; + if (m_pAnimatedPixmap) delete m_pAnimatedPixmap; KVSO_END_CONSTRUCTOR(KviKvsObject_pixmap) KVSO_CLASS_FUNCTION(pixmap,fill) { - CHECK_INTERNAL_POINTER(m_pPixmap) - KviKvsObject *pObject; - kvs_int_t iXoffset,iYoffset; - kvs_hobject_t hObject; - KVSO_PARAMETERS_BEGIN(c) - KVSO_PARAMETER("widget",KVS_PT_HOBJECT,0,hObject) - KVSO_PARAMETER("x_offset",KVS_PT_INT,0,iXoffset) - KVSO_PARAMETER("y_offset",KVS_PT_INT,0,iYoffset) - KVSO_PARAMETERS_END(c) + KviKvsObject *pObject; + kvs_int_t iXoffset,iYoffset; + kvs_hobject_t hObject; + KVSO_PARAMETERS_BEGIN(c) + KVSO_PARAMETER("widget",KVS_PT_HOBJECT,0,hObject) + KVSO_PARAMETER("x_offset",KVS_PT_INT,0,iXoffset) + KVSO_PARAMETER("y_offset",KVS_PT_INT,0,iYoffset) + KVSO_PARAMETERS_END(c) - pObject=KviKvsKernel::instance()->objectController()->lookupObject(hObject); - CHECK_HOBJECT_IS_WIDGET(pObject) - bPixmapModified=true; - m_pPixmap->fill(((QWidget *)(pObject->object())),iXoffset,iYoffset); - return true; + pObject=KviKvsKernel::instance()->objectController()->lookupObject(hObject); + CHECK_HOBJECT_IS_WIDGET(pObject) + if (m_pAnimatedPixmap) + { + delete m_pAnimatedPixmap; + m_pAnimatedPixmap=0; + } + if(!m_pPixmap) m_pPixmap=new QPixmap(); + m_pPixmap->fill(((QWidget *)(pObject->object())),iXoffset,iYoffset); + return true; +} +KVSO_CLASS_FUNCTION(pixmap,resize) +{ + kvs_int_t iWidth,iHeight; + KVSO_PARAMETERS_BEGIN(c) + KVSO_PARAMETER("width",KVS_PT_INTEGER,0,iWidth) + KVSO_PARAMETER("height",KVS_PT_INTEGER,0,iHeight) + KVSO_PARAMETERS_END(c) + if(m_pPixmap) delete m_pPixmap; + if (m_pAnimatedPixmap){ + delete m_pAnimatedPixmap; + m_pAnimatedPixmap=0; + } + m_pPixmap=new QPixmap(iWidth,iHeight); + return true; } - KVSO_CLASS_FUNCTION(pixmap,scale) { - CHECK_INTERNAL_POINTER(m_pPixmap) - kvs_int_t iScaleW,iScaleH; - QString szAspectRatio, szTransformation; - KVSO_PARAMETERS_BEGIN(c) - KVSO_PARAMETER("new_width",KVS_PT_INTEGER,0,iScaleW) - KVSO_PARAMETER("new_height",KVS_PT_INTEGER,0,iScaleH) - KVSO_PARAMETER("aspect_ratio",KVS_PT_STRING,KVS_PF_OPTIONAL,szAspectRatio) - KVSO_PARAMETER("tranformation_type",KVS_PT_STRING,KVS_PF_OPTIONAL,szTransformation) - KVSO_PARAMETERS_END(c) - Qt::AspectRatioMode ratio=Qt::IgnoreAspectRatio; - if (KviQString::equalCI(szAspectRatio,"IgnoreAspectRatio")) ratio=Qt::IgnoreAspectRatio; - else if (KviQString::equalCI(szAspectRatio,"KeepAspectRatio")) ratio=Qt::KeepAspectRatio; - else if (KviQString::equalCI(szAspectRatio,"KeepAspectRatioByExpanding")) ratio=Qt::KeepAspectRatioByExpanding; - else if (!szAspectRatio.isEmpty())c->warning(__tr2qs_ctx("Unknown aspect ratio: using default value IgnoreAspectRatio","objects")); - Qt::TransformationMode tmode=Qt::FastTransformation; - if (KviQString::equalCI(szTransformation,"Fast")) tmode=Qt::FastTransformation; - else if (KviQString::equalCI(szTransformation,"Smooth")) tmode=Qt::SmoothTransformation; - else if (!szAspectRatio.isEmpty())c->warning(__tr2qs_ctx("Unknown tranformation mode: using default value Fast","objects")); - - *m_pPixmap = m_pPixmap->scaled(iScaleW, iScaleH,ratio,tmode); - bPixmapModified=true; - return true; + kvs_int_t iWidth,iHeight; + QString szAspectRatio; + KVSO_PARAMETERS_BEGIN(c) + KVSO_PARAMETER("width",KVS_PT_INTEGER,0,iWidth) + KVSO_PARAMETER("height",KVS_PT_INTEGER,0,iHeight) + KVSO_PARAMETER("aspect_ratio",KVS_PT_STRING,KVS_PF_OPTIONAL,szAspectRatio) + KVSO_PARAMETERS_END(c) + Qt::AspectRatioMode ratio=Qt::KeepAspectRatio; + if(!m_pPixmap || m_pAnimatedPixmap) return true; + if(!szAspectRatio.isEmpty()) + { + if(KviQString::equalCI(szAspectRatio,"IgnoreAspectRatio")) ratio=Qt::IgnoreAspectRatio; + else if (KviQString::equalCI(szAspectRatio,"KeepAspectRatio")) ratio=Qt::KeepAspectRatio; + else if (KviQString::equalCI(szAspectRatio,"KeepAspectRatioByExpanding")) ratio=Qt::KeepAspectRatioByExpanding; + else c->warning(__tr2qs_ctx("Unknown aspect ratio %Q - Switching to KeepAspectRatio ratio","objects"),&szAspectRatio); + } + if (m_pAnimatedPixmap) m_pAnimatedPixmap->resize(QSize(iWidth,iHeight),ratio); + else *m_pPixmap=m_pPixmap->scaled(iWidth,iHeight,ratio,Qt::SmoothTransformation); + return true; } +KVSO_CLASS_FUNCTION(pixmap,loadAnimation) -KVSO_CLASS_FUNCTION(pixmap,rotate) { - CHECK_INTERNAL_POINTER(m_pPixmap) - kvs_real_t uDegrees; - KVSO_PARAMETERS_BEGIN(c) - KVSO_PARAMETER("a",KVS_PT_REAL,0,uDegrees) - KVSO_PARAMETERS_END(c) - QMatrix m; - m.rotate(uDegrees); - *m_pPixmap = m_pPixmap->transformed(m); - bPixmapModified=true; - return true; + QString szFile; + KVSO_PARAMETERS_BEGIN(c) + KVSO_PARAMETER("file",KVS_PT_STRING,0,szFile) + KVSO_PARAMETERS_END(c) + if(!QFile::exists(szFile)) + { + c->warning(__tr2qs_ctx("I can't find the specified file '%Q'.","objects"),&szFile); + return true; + } + if (m_pAnimatedPixmap) delete m_pAnimatedPixmap; + if (m_pPixmap) + { + delete m_pPixmap; + m_pPixmap=0; + } + m_pAnimatedPixmap= new KviAnimatedPixmap(szFile); + connect(m_pAnimatedPixmap,SIGNAL(frameChanged()),this,SLOT(frameChanged())); + return true; } -KVSO_CLASS_FUNCTION(pixmap,resize) +KVSO_CLASS_FUNCTION(pixmap,startAnimation) { - CHECK_INTERNAL_POINTER(m_pPixmap) - kvs_int_t uWidth,uHeight; - KVSO_PARAMETERS_BEGIN(c) - KVSO_PARAMETER("width",KVS_PT_UNSIGNEDINTEGER,0,uWidth) - KVSO_PARAMETER("height",KVS_PT_UNSIGNEDINTEGER,0,uHeight) - KVSO_PARAMETERS_END(c) - delete m_pPixmap; - m_pPixmap=new QPixmap(uWidth,uHeight); - bPixmapModified=true; - return true; + if (m_pAnimatedPixmap) m_pAnimatedPixmap->start(); + return true; +} +KVSO_CLASS_FUNCTION(pixmap,stopAnimation) +{ + if (m_pAnimatedPixmap) m_pAnimatedPixmap->stop(); + return true; } - - KVSO_CLASS_FUNCTION(pixmap,load) { - CHECK_INTERNAL_POINTER(m_pPixmap) - QString szFile; - KVSO_PARAMETERS_BEGIN(c) - KVSO_PARAMETER("file",KVS_PT_STRING,0,szFile) - KVSO_PARAMETERS_END(c) - if(!QFile::exists(szFile)) - { - c->warning(__tr2qs_ctx("I can't find the specified file '%Q'.","objects"),&szFile); + QString szFile; + KVSO_PARAMETERS_BEGIN(c) + KVSO_PARAMETER("file",KVS_PT_STRING,0,szFile) + KVSO_PARAMETERS_END(c) + if(!QFile::exists(szFile)) + { + c->warning(__tr2qs_ctx("I can't find the specified file '%Q'.","objects"),&szFile); + return true; + } + if (m_pAnimatedPixmap) delete m_pAnimatedPixmap; + if(!m_pPixmap) m_pPixmap=new QPixmap(); + m_pPixmap->load(szFile); + return true; +} +KVSO_CLASS_FUNCTION(pixmap,save) +{ + QString szFile; + KVSO_PARAMETERS_BEGIN(c) + KVSO_PARAMETER("file",KVS_PT_STRING,0,szFile) + KVSO_PARAMETERS_END(c) + if (m_pAnimatedPixmap) m_pAnimatedPixmap->pixmap()->save(szFile); + else if(m_pPixmap) m_pPixmap->save(szFile); return true; - } - m_pPixmap->load(szFile); - bPixmapModified=true; - return true; } +/* +KVSO_CLASS_FUNCTION(pixmap,save) +{ + //CHECK_INTERNAL_POINTER(m_pPixmap) + QString szFile; + KVSO_PARAMETERS_BEGIN(c) + KVSO_PARAMETER("file",KVS_PT_STRING,0,szFile) + KVSO_PARAMETERS_END(c) + if(!QFile::exists(szFile)) + { + c->warning(__tr2qs_ctx("I can't find the specified file '%Q'.","objects"),&szFile); + return true; + } + if (m_pAnimatedPixmap) delete m_pAnimatedPixmap; + m_pAnimatedPixmap= new KviAnimatedPixmap(szFile); + connect(m_pAnimatedPixmap,SIGNAL(frameChanged()),this,SLOT(frameChanged())); + //bPixmapModified=true; + + return true; +} +*/ KVSO_CLASS_FUNCTION(pixmap,loadFromMemoryBuffer) { - CHECK_INTERNAL_POINTER(m_pPixmap) - KviKvsObject * pObject; - kvs_hobject_t hObject; - KVSO_PARAMETERS_BEGIN(c) - KVSO_PARAMETER("hobject",KVS_PT_HOBJECT,0,hObject) - KVSO_PARAMETERS_END(c) - pObject=KviKvsKernel::instance()->objectController()->lookupObject(hObject); - if (!pObject) - { - c->warning(__tr2qs_ctx("Buffer parameter is not an object","objects")); - return true; - } - if (!pObject->inheritsClass("memorybuffer")) - { - c->warning(__tr2qs_ctx("Buffer parameter is not a memorybuffer object","objects")); - return true; - } + KviKvsObject * pObject; + kvs_hobject_t hObject; + KVSO_PARAMETERS_BEGIN(c) + KVSO_PARAMETER("hobject",KVS_PT_HOBJECT,0,hObject) + KVSO_PARAMETERS_END(c) - m_pPixmap->loadFromData(((KviKvsObject_memorybuffer *)pObject)->dataBuffer()); + pObject=KviKvsKernel::instance()->objectController()->lookupObject(hObject); + if (!pObject) + { + c->warning(__tr2qs_ctx("Buffer parameter is not an object","objects")); + return true; + } + if (!pObject->inheritsClass("memorybuffer")) + { + c->warning(__tr2qs_ctx("Buffer parameter is not a memorybuffer object","objects")); + return true; + } + if (m_pAnimatedPixmap){ + delete m_pAnimatedPixmap; + m_pAnimatedPixmap=0; + } + if (!m_pPixmap) m_pPixmap=new QPixmap(); + m_pPixmap->loadFromData(((KviKvsObject_memorybuffer *)pObject)->dataBuffer()); + return true; +} - bPixmapModified=true; +KVSO_CLASS_FUNCTION(pixmap,grabWidget) +{ + CHECK_INTERNAL_POINTER(m_pPixmap) + KviKvsObject * pObject; + kvs_hobject_t hObject; + KVSO_PARAMETERS_BEGIN(c) + KVSO_PARAMETER("widget",KVS_PT_HOBJECT,0,hObject) + KVSO_PARAMETERS_END(c) + pObject=KviKvsKernel::instance()->objectController()->lookupObject(hObject); + CHECK_HOBJECT_IS_WIDGET(pObject) + if (m_pAnimatedPixmap){ + delete m_pAnimatedPixmap; + m_pAnimatedPixmap=0; + } + if (!m_pPixmap) m_pPixmap=new QPixmap(); + *m_pPixmap=QPixmap::grabWidget(((KviKvsObject_widget *)pObject)->widget()); + /* QString szFileName; + KVSO_PARAMETERS_BEGIN(c) + KVSO_PARAMETER("file_name",KVS_PT_STRING,0,szFileName) + KVSO_PARAMETERS_END(c) + QPrinter printer;//(QPrinter::HighResolution); + printer.setOutputFormat(QPrinter::PdfFormat); + printer.setPaperSize(QPrinter::A4); + printer.setOutputFileName(szFileName); - return true; -} + QPixmap pixmap=QPixmap::grabWidget(((QTableWidget *)widget())); + QPainter painter(&printer); + painter.drawPixmap(QPoint(0,0), pixmap, pixmap.rect()); + */ + return true; +} KVSO_CLASS_FUNCTION(pixmap,height) { - CHECK_INTERNAL_POINTER(m_pPixmap) - c->returnValue()->setInteger(m_pPixmap->height()); - return true; + if(!m_pAnimatedPixmap && !m_pPixmap) c->returnValue()->setInteger(0); + else if(m_pAnimatedPixmap) c->returnValue()->setInteger(m_pAnimatedPixmap->size().height()); + else c->returnValue()->setInteger(m_pPixmap->height()); + return true; } KVSO_CLASS_FUNCTION(pixmap,width) { - CHECK_INTERNAL_POINTER(m_pPixmap) - c->returnValue()->setInteger(m_pPixmap->width()); - return true; -} -// maybe DEPRECATED? -KVSO_CLASS_FUNCTION(pixmap,setOpacity) -{ - CHECK_INTERNAL_POINTER(m_pPixmap) - kvs_real_t dOpacity; - kvs_uint_t uXoffset,uYoffset; - kvs_uint_t uWidth,uHeight; - - KviKvsObject * pObDest; - kvs_hobject_t hObject; - - KVSO_PARAMETERS_BEGIN(c) - KVSO_PARAMETER("opacity_factor",KVS_PT_DOUBLE,0,dOpacity) - KVSO_PARAMETER("destination",KVS_PT_HOBJECT,0,hObject) - KVSO_PARAMETER("x_offset",KVS_PT_UNSIGNEDINTEGER,KVS_PF_OPTIONAL,uXoffset) - KVSO_PARAMETER("y_offset",KVS_PT_UNSIGNEDINTEGER,KVS_PF_OPTIONAL,uYoffset) - KVSO_PARAMETER("width",KVS_PT_UNSIGNEDINTEGER,KVS_PF_OPTIONAL,uWidth) - KVSO_PARAMETER("height",KVS_PT_UNSIGNEDINTEGER,KVS_PF_OPTIONAL,uHeight) - KVSO_PARAMETERS_END(c) - pObDest=KviKvsKernel::instance()->objectController()->lookupObject(hObject); - - if (!pObDest) - { - c->warning(__tr2qs_ctx("Destination parameter is not an object","objects")); - return true; - } - - if(!pObDest->inheritsClass("pixmap")) - { - c->warning(__tr2qs_ctx("Destination must be a pixmap object","objects")); - return true; - } - QImage *buffer=((KviKvsObject_pixmap *)pObDest)->getImage(); - ((KviKvsObject_pixmap *)pObDest)->imageChanged(); - if (bPixmapModified) { - *m_pImage=m_pPixmap->toImage(); - } - if (uWidth > (uint) buffer->width() || uHeight > (uint) buffer->height()) - { - c->warning(__tr2qs_ctx("Area dimensions are out of destination size ","objects")); - return true; - } - if (!uWidth) - { - if(m_pImage->width()>buffer->width()) - { - c->warning(__tr2qs_ctx("Pixmap dimensions are out of destination size ","objects")); - return true; - } - } - - if (!uHeight) - { - if(m_pImage->height()>buffer->height()) - { - c->warning(__tr2qs_ctx("Pixmap dimensions are out of destination size ","objects")); - return true; - } - } - - if(uXoffset + uWidth > (uint) m_pImage->width()) - { - c->warning(__tr2qs_ctx("Offset width area is out of pixmap size ","objects")); - return true; - } - if(uYoffset + uHeight > (uint) m_pImage->height()) - { - c->warning(__tr2qs_ctx("Offset height area is out of pixmap size ","objects")); - return true; - } - -// buffer->setAlphaBuffer(true); - int iHedge=uHeight?uHeight:m_pImage->height(); - int iWedge=uWidth?uWidth:m_pImage->width(); - - for(int y = uYoffset;y<iHedge;y++) - { - QRgb * dst = (QRgb *)buffer->scanLine(y); - QRgb * src = (QRgb *)m_pImage->scanLine(y); - src += uXoffset; - QRgb * end; - end = src + iWedge; - while(src < end) - { - *dst = qRgba( - (int)(qRed(*src)), - (int)(qGreen(*src)), - (int)(qBlue(*src)), - (int)(qAlpha(*src)*dOpacity) - ); - src++; - dst++; - } - } - return true; + if(!m_pAnimatedPixmap && !m_pPixmap) c->returnValue()->setInteger(0); + else if(m_pAnimatedPixmap) c->returnValue()->setInteger(m_pAnimatedPixmap->size().width()); + else c->returnValue()->setInteger(m_pPixmap->width()); + return true; } - QPixmap * KviKvsObject_pixmap::getPixmap() { - if (bImageModified) - { - m_pPixmap->fromImage(*m_pImage); - bImageModified=false; - } - return m_pPixmap; + if (!m_pAnimatedPixmap && !m_pPixmap) return new QPixmap(); + else if(m_pAnimatedPixmap) return m_pAnimatedPixmap->pixmap(); + else return m_pPixmap; } -QImage * KviKvsObject_pixmap::getImage() +KVSO_CLASS_FUNCTION(pixmap,frameChangedEvent) { - if (bPixmapModified) - { - *m_pImage=m_pPixmap->toImage(); - bPixmapModified=false; - } + emitSignal("frameChanged",c); + return true; +} - return m_pImage; +// slots +void KviKvsObject_pixmap::frameChanged() +{ + KviKvsVariantList *params=0; + callFunction(this,"frameChangedEvent",params); } #ifndef COMPILE_USE_STANDALONE_MOC_SOURCES diff --git a/src/modules/objects/class_pixmap.h b/src/modules/objects/class_pixmap.h index 4a00f7cd3..59fb2bc25 100644 --- a/src/modules/objects/class_pixmap.h +++ b/src/modules/objects/class_pixmap.h @@ -30,6 +30,7 @@ #include <qpixmap.h> #include <qimage.h> #include <QMatrix> +#include <kvi_animatedpixmap.h> #include "kvi_string.h" @@ -43,31 +44,33 @@ class KviKvsObject_pixmap : public KviKvsObject public: KVSO_DECLARE_OBJECT(KviKvsObject_pixmap); QPixmap * getPixmap(); - QImage * getImage(); - void pixmapChanged(){bPixmapModified=true;} - void imageChanged(){bImageModified=true;} - QPixmap * pixmap(){ return m_pPixmap; } + //QPixmap * pixmap(){ return m_pPixmap; } protected: - QPixmap * m_pPixmap; - QImage * m_pImage; - bool bImageModified; - bool bPixmapModified; + KviAnimatedPixmap * m_pAnimatedPixmap; + QPixmap * m_pPixmap; signals: void aboutToDie(); - protected: - bool fill(KviKvsObjectFunctionCall *c); - bool resize(KviKvsObjectFunctionCall *c); - bool scale(KviKvsObjectFunctionCall *c); - bool rotate(KviKvsObjectFunctionCall *c); - bool load(KviKvsObjectFunctionCall *c); - bool height(KviKvsObjectFunctionCall *c); - bool width(KviKvsObjectFunctionCall *c); - bool setOpacity(KviKvsObjectFunctionCall *c); - bool loadFromMemoryBuffer(KviKvsObjectFunctionCall *c); + bool fill(KviKvsObjectFunctionCall *c); + bool resize(KviKvsObjectFunctionCall *c); + bool scale(KviKvsObjectFunctionCall *c); + //bool rotate(KviKvsObjectFunctionCall *c); + bool save(KviKvsObjectFunctionCall *c); + bool startAnimation(KviKvsObjectFunctionCall *c); + bool stopAnimation(KviKvsObjectFunctionCall *c); + bool loadAnimation(KviKvsObjectFunctionCall *c); + bool load(KviKvsObjectFunctionCall *c); + bool height(KviKvsObjectFunctionCall *c); + bool width(KviKvsObjectFunctionCall *c); + bool grabWidget(KviKvsObjectFunctionCall *c); +// bool setOpacity(KviKvsObjectFunctionCall *c); + bool loadFromMemoryBuffer(KviKvsObjectFunctionCall *c); + bool frameChangedEvent(KviKvsObjectFunctionCall *c); +protected slots: + void frameChanged(); }; #endif // !_CLASS_PIXMAP_H_ diff --git a/src/modules/objects/class_sql.cpp b/src/modules/objects/class_sql.cpp index 3cba363e0..acf36fbc1 100644 --- a/src/modules/objects/class_sql.cpp +++ b/src/modules/objects/class_sql.cpp @@ -103,6 +103,7 @@ KVSO_BEGIN_REGISTERCLASS(KviKvsObject_sql,"sql","object") KVSO_REGISTER_HANDLER_BY_NAME(KviKvsObject_sql,setConnection) KVSO_REGISTER_HANDLER_BY_NAME(KviKvsObject_sql,setCurrentQuery) + KVSO_REGISTER_HANDLER_BY_NAME(KviKvsObject_sql,tablesList) KVSO_REGISTER_HANDLER_BY_NAME(KviKvsObject_sql,currentQuery) KVSO_REGISTER_HANDLER_BY_NAME(KviKvsObject_sql,closeConnection) KVSO_REGISTER_HANDLER_BY_NAME(KviKvsObject_sql,queryInit) @@ -116,6 +117,7 @@ KVSO_BEGIN_REGISTERCLASS(KviKvsObject_sql,"sql","object") KVSO_REGISTER_HANDLER_BY_NAME(KviKvsObject_sql,queryLast) KVSO_REGISTER_HANDLER_BY_NAME(KviKvsObject_sql,queryFirst) KVSO_REGISTER_HANDLER_BY_NAME(KviKvsObject_sql,queryRecord) + KVSO_REGISTER_HANDLER_BY_NAME(KviKvsObject_sql,lastError) KVSO_END_REGISTERCLASS(KviKvsObject_sql) @@ -132,7 +134,7 @@ while (t.hasNext()) t.next(); QString szConnectionName=t.key(); connectionsDict.value(szConnectionName)->finish(); - delete connectionsDict.value(szConnectionName); + // delete connectionsDict.value(szConnectionName); QSqlDatabase::removeDatabase(szConnectionName); } connectionsDict.clear(); @@ -193,6 +195,29 @@ KVSO_CLASS_FUNCTION(sql,closeConnection) return true; } +KVSO_CLASS_FUNCTION(sql,tablesList) +{ + QString szConnectionName; + KVSO_PARAMETERS_BEGIN(c) + KVSO_PARAMETER("connectionName",KVS_PT_STRING,0,szConnectionName) + KVSO_PARAMETERS_END(c) + + QStringList connections = QSqlDatabase::connectionNames(); + if (!connections.contains(szConnectionName)) + { + c->warning(__tr2qs_ctx("Connection %Q does not exists","objects"),&szConnectionName); + return true; + } + QSqlDatabase db=QSqlDatabase::database(szConnectionName); + QStringList tables=db.tables(); + KviKvsArray *pArray=new KviKvsArray(); + for(int i=0;i<tables.count();i++) + { + pArray->set(i,new KviKvsVariant(tables.at(i))); + } + c->returnValue()->setArray(pArray); + return true; +} KVSO_CLASS_FUNCTION(sql,setCurrentQuery) { QString szConnectionName; @@ -289,7 +314,7 @@ KVSO_CLASS_FUNCTION(sql,queryBindValue) KVSO_PARAMETERS_END(c) QString szType; v->getTypeName(szType); - if (v->isString()) + if (v->isString()|| v->isNothing()) { QString szText; v->asString(szText); @@ -340,7 +365,7 @@ KVSO_CLASS_FUNCTION(sql,queryExec) KVSO_PARAMETERS_END(c) bool bOk; if (szQuery.isEmpty()) bOk=currentSQlQuery->exec(); - else bOk=currentSQlQuery->exec(szQuery); + else bOk=currentSQlQuery->exec(szQuery.toLatin1()); c->returnValue()->setBoolean(bOk); return true; } @@ -381,11 +406,9 @@ KVSO_CLASS_FUNCTION(sql,queryRecord) CHECK_QUERY_IS_INIT KviKvsHash *pHash=new KviKvsHash(); QSqlRecord record=currentSQlQuery->record(); - debug ("count %d",record.count()); for(int i=0;i<record.count();i++) { KviKvsVariant *pValue=0; - debug ("type %s",record.value(i).typeName()); QVariant value=record.value(i); if (value.type()==QVariant::LongLong) pValue=new KviKvsVariant((kvs_int_t) value.toLongLong()); else if (value.type()==QVariant::String) pValue=new KviKvsVariant(value.toString()); diff --git a/src/modules/objects/class_sql.h b/src/modules/objects/class_sql.h index c25d81f7d..77f608543 100644 --- a/src/modules/objects/class_sql.h +++ b/src/modules/objects/class_sql.h @@ -46,6 +46,8 @@ protected: return *currentSQlQuery; }; bool setConnection(KviKvsObjectFunctionCall *c); + bool tablesList(KviKvsObjectFunctionCall *c); + bool queryResultsSize(KviKvsObjectFunctionCall *c); bool queryNext(KviKvsObjectFunctionCall *c); bool queryPrevious(KviKvsObjectFunctionCall *c); diff --git a/src/modules/objects/class_tablewidget.cpp b/src/modules/objects/class_tablewidget.cpp index 00f00c2d8..571ad871c 100644 --- a/src/modules/objects/class_tablewidget.cpp +++ b/src/modules/objects/class_tablewidget.cpp @@ -31,8 +31,15 @@ #include "class_tablewidget.h" #include "class_pixmap.h" #include "class_sql.h" - #include <QTableWidget> +#include <QTableWidget> +#include <QHeaderView> + +#include <QPainter> +#include <QPrinter> +#include <QApplication> +#include <QPoint> +#include <QPaintEvent> /* @doc:tablewidget @title: @@ -48,7 +55,11 @@ This widget provides a table widget. @functions: !fn: $setText([<text:string>]) - @signals: + !fn: $text() + !fn: $setHorizontalHeaderLabels + !fn: $hideHorizontalHeaderLabels + !fn: $setHorizontalHeaderLabels + @signals: !sg: $clicked() This signal is emitted by the default implementation of [classfnc]$clickEvent[/classfnc](). @@ -57,15 +68,27 @@ KVSO_BEGIN_REGISTERCLASS(KviKvsObject_tablewidget,"tablewidget","widget") - KVSO_REGISTER_HANDLER_BY_NAME(KviKvsObject_tablewidget,setText) - KVSO_REGISTER_HANDLER_BY_NAME(KviKvsObject_tablewidget,text) - KVSO_REGISTER_HANDLER_BY_NAME(KviKvsObject_tablewidget,setIcon) + // Horizontal Header + KVSO_REGISTER_HANDLER_BY_NAME(KviKvsObject_tablewidget,setHorizontalHeaderLabels) + KVSO_REGISTER_HANDLER_BY_NAME(KviKvsObject_tablewidget,hideHorizontalHeader) + KVSO_REGISTER_HANDLER_BY_NAME(KviKvsObject_tablewidget,hideVerticalHeader) + + // Vertical Header + KVSO_REGISTER_HANDLER_BY_NAME(KviKvsObject_tablewidget,setVerticalHeaderLabels) + KVSO_REGISTER_HANDLER_BY_NAME(KviKvsObject_tablewidget,showHorizontalHeader) + KVSO_REGISTER_HANDLER_BY_NAME(KviKvsObject_tablewidget,showVerticalHeader) + + // Rows-Columns KVSO_REGISTER_HANDLER_BY_NAME(KviKvsObject_tablewidget,setRowCount) KVSO_REGISTER_HANDLER_BY_NAME(KviKvsObject_tablewidget,rowCount) KVSO_REGISTER_HANDLER_BY_NAME(KviKvsObject_tablewidget,setColumnCount) KVSO_REGISTER_HANDLER_BY_NAME(KviKvsObject_tablewidget,columnCount) - KVSO_REGISTER_HANDLER_BY_NAME(KviKvsObject_tablewidget,setHorizontalHeaderLabels) - KVSO_REGISTER_HANDLER_BY_NAME(KviKvsObject_tablewidget,setVerticalHeaderLabels) + + // Item (text. icon, widget) + KVSO_REGISTER_HANDLER_BY_NAME(KviKvsObject_tablewidget,setText) + KVSO_REGISTER_HANDLER_BY_NAME(KviKvsObject_tablewidget,text) + KVSO_REGISTER_HANDLER_BY_NAME(KviKvsObject_tablewidget,setCellWidget) + KVSO_REGISTER_HANDLER_BY_NAME(KviKvsObject_tablewidget,setIcon) KVSO_END_REGISTERCLASS(KviKvsObject_tablewidget) @@ -216,6 +239,44 @@ KVSO_CLASS_FUNCTION(tablewidget,setVerticalHeaderLabels) return true; } +KVSO_CLASS_FUNCTION(tablewidget,setCellWidget) +{ + CHECK_INTERNAL_POINTER(widget()) + KviKvsObject * pObject; + kvs_hobject_t hObject; + kvs_uint_t uRow,uCol; + KVSO_PARAMETERS_BEGIN(c) + KVSO_PARAMETER("row",KVS_PT_UNSIGNEDINTEGER,0,uRow) + KVSO_PARAMETER("column",KVS_PT_UNSIGNEDINTEGER,0,uCol) + KVSO_PARAMETER("widget",KVS_PT_HOBJECT,0,hObject) + KVSO_PARAMETERS_END(c) + pObject=KviKvsKernel::instance()->objectController()->lookupObject(hObject); + CHECK_HOBJECT_IS_WIDGET(pObject) + ((QTableWidget *)object())->setCellWidget(uRow,uCol,((QWidget *)(pObject->object()))); + return true; +} +KVSO_CLASS_FUNCTION(tablewidget,hideHorizontalHeader) +{ + ((QTableWidget *)widget())->horizontalHeader()->hide(); + return true; +} +KVSO_CLASS_FUNCTION(tablewidget,hideVerticalHeader) +{ + ((QTableWidget *)widget())->verticalHeader()->hide(); + return true; +} + +KVSO_CLASS_FUNCTION(tablewidget,showHorizontalHeader) +{ + ((QTableWidget *)widget())->horizontalHeader()->show(); + return true; +} +KVSO_CLASS_FUNCTION(tablewidget,showVerticalHeader) +{ + ((QTableWidget *)widget())->verticalHeader()->show(); + return true; +} + #ifndef COMPILE_USE_STANDALONE_MOC_SOURCES #include "m_class_tablewidget.moc" diff --git a/src/modules/objects/class_tablewidget.h b/src/modules/objects/class_tablewidget.h index a86a44a86..795c5f336 100644 --- a/src/modules/objects/class_tablewidget.h +++ b/src/modules/objects/class_tablewidget.h @@ -53,6 +53,12 @@ protected: bool rowCount(KviKvsObjectFunctionCall *c); bool setHorizontalHeaderLabels(KviKvsObjectFunctionCall *c); bool setVerticalHeaderLabels(KviKvsObjectFunctionCall *c); + bool setCellWidget(KviKvsObjectFunctionCall *c); + + bool hideHorizontalHeader(KviKvsObjectFunctionCall *c); + bool showHorizontalHeader(KviKvsObjectFunctionCall *c); + bool hideVerticalHeader(KviKvsObjectFunctionCall *c); + bool showVerticalHeader(KviKvsObjectFunctionCall *c); //bool clickEvent(KviKvsObjectFunctionCall *c); protected slots: diff --git a/src/modules/objects/class_treewidget.cpp b/src/modules/objects/class_treewidget.cpp index 64d3f8c5e..7e6a7ea19 100644 --- a/src/modules/objects/class_treewidget.cpp +++ b/src/modules/objects/class_treewidget.cpp @@ -31,6 +31,7 @@ #include "kvi_iconmanager.h" #include <QTreeWidget> + #include <QSqlDatabase> // FIXME: fix the doc (function QT4 renamed) // OLD: @@ -250,7 +251,6 @@ KVSO_END_CONSTRUCTOR(KviKvsObject_treewidget) bool KviKvsObject_treewidget::init(KviKvsRunTimeContext *,KviKvsVariantList *) { setObject(new KviKvsTreeWidget(parentScriptWidget(),getName().toUtf8().data(),this),true); - // hack for compatibility with "old" addColumn method; ((QTreeWidget*) widget())->setColumnCount(0); diff --git a/src/modules/objects/class_widget.cpp b/src/modules/objects/class_widget.cpp index e693f0dde..168dd18f2 100644 --- a/src/modules/objects/class_widget.cpp +++ b/src/modules/objects/class_widget.cpp @@ -49,6 +49,10 @@ #include <QIcon> #include <QStatusBar> #include <QUrl> +#include <QPainter> +#include <QPrinter> +#include <QApplication> +#include <QPoint> #ifdef COMPILE_WEBKIT_SUPPORT #include <QtWebKit/QWebView> @@ -1967,6 +1971,8 @@ KVSO_CLASS_FUNCTION(widget,removeFromStatusBar) return true; } + + #ifdef COMPILE_WEBKIT_SUPPORT KVSO_CLASS_FUNCTION(widget,setWebView) { diff --git a/src/modules/objects/libkviobjects.cpp b/src/modules/objects/libkviobjects.cpp index 1e4c5fc55..3313214d3 100644 --- a/src/modules/objects/libkviobjects.cpp +++ b/src/modules/objects/libkviobjects.cpp @@ -612,7 +612,6 @@ static bool objects_kvs_cmd_disconnect(KviKvsModuleCommandCall * c) } - static bool objects_kvs_cmd_bitBlt(KviKvsModuleCommandCall * c) { /* @@ -680,7 +679,7 @@ static bool objects_kvs_cmd_bitBlt(KviKvsModuleCommandCall * c) return true; } if(obDst->inheritsClass("pixmap")){ - ((KviKvsObject_pixmap *)obDst)->pixmapChanged(); + //((KviKvsObject_pixmap *)obDst)->pixmapChanged(); } /*FIXME @@ -714,7 +713,7 @@ static bool objects_kvs_cmd_bitBlt(KviKvsModuleCommandCall * c) static bool objects_kvs_cmd_blend(KviKvsModuleCommandCall * c) { - KviKvsObject *obFor; +/* KviKvsObject *obFor; KviKvsObject *obBck; KviKvsObject *obDest; @@ -772,11 +771,11 @@ static bool objects_kvs_cmd_blend(KviKvsModuleCommandCall * c) return true; } - if(obDest->inheritsClass("pixmap")) ((KviKvsObject_pixmap *)obDest)->pixmapChanged(); +// if(obDest->inheritsClass("pixmap")) ((KviKvsObject_pixmap *)obDest)->pixmapChanged(); - QImage *img_back=((KviKvsObject_pixmap *)obBck)->getImage(); - QImage *img_fore=((KviKvsObject_pixmap *)obFor)->getImage(); + //QImage *img_back=((KviKvsObject_pixmap *)obBck)->getImage(); + //QImage *img_fore=((KviKvsObject_pixmap *)obFor)->getImage(); // check size if ((iBkX+uW>img_back->width())||(iBkY+uH>img_back->height())) @@ -818,6 +817,7 @@ static bool objects_kvs_cmd_blend(KviKvsModuleCommandCall * c) QPainter p(pdDest); QRect rect(iDesX,iDesY,buffer.width(),buffer.height()); p.drawImage(rect,buffer); + */ return true; } |
