aboutsummaryrefslogtreecommitdiffstats
path: root/src/modules/objects/KvsObject_wrapper.cpp
diff options
context:
space:
mode:
authorGravatar Fabio Bas2011-05-08 21:19:43 +0000
committerGravatar Fabio Bas2011-05-08 21:19:43 +0000
commit84d094f1e31f55481dea0c859be9a85c7cfb426c (patch)
treee7bdfd91c9efba8097adde62fe3a9b23af084c58 /src/modules/objects/KvsObject_wrapper.cpp
parentupdate (diff)
downloadKVIrc-84d094f1e31f55481dea0c859be9a85c7cfb426c.tar.gz
KVIrc-84d094f1e31f55481dea0c859be9a85c7cfb426c.tar.bz2
KVIrc-84d094f1e31f55481dea0c859be9a85c7cfb426c.zip
Objects module: fixed indentation (wip)
webview class: proper documentation misc: fixed errors and bad pratices found by lwlint git-svn-id: https://svn.kvirc.de/svn/trunk/kvirc@5834 17fca916-40b9-46aa-a4ea-0a15b648b75c
Diffstat (limited to 'src/modules/objects/KvsObject_wrapper.cpp')
-rw-r--r--src/modules/objects/KvsObject_wrapper.cpp194
1 files changed, 92 insertions, 102 deletions
diff --git a/src/modules/objects/KvsObject_wrapper.cpp b/src/modules/objects/KvsObject_wrapper.cpp
index fa6b2ea75..d3c069ae0 100644
--- a/src/modules/objects/KvsObject_wrapper.cpp
+++ b/src/modules/objects/KvsObject_wrapper.cpp
@@ -37,66 +37,66 @@
/*
- @doc: wrapper
- @keyterms:
- wrapper object class,
- @title:
- wrapper class
- @type:
- class
- @short:
- Provides a wrapper class that hooks to an existing Qt graphic object modifying it.
- @inherits:
- [class]object[/class]
- [class]widget[/class]
- @description:
- This is a class for advanced KVIrc scripting.[br]
- It can wrap any existing KVIrc widget.[br]
- This class allows some unbelievable changes to the whole graphic environment of the kvirc,[br]
- in fact, could hook every widget, you can modify the property or you can be inserted other widget as child of this...[br]
- in short you have absolute liberty. [br]
- The power of this class is fantastic, because it allows the change at "run time" of almost all the elements of the Kvirc.[br]
- But to use this class in optimal way and to exploit its power, you have to know the Qt.... so you won't have limits [br]
- The KVIrc Qt widgets are arranged in trees (just as the objects).[br]
- The difference is that there are more toplevel widgets (and so more than one tree).[br]
- You can use [fnc]$objects.dump()[/fnc] to take a look at the KVIrc Qt objects tree.[br]
- Here is a part of the tree:[br][br]
- Ptr 14332520: top level object: kvirc_frame, class KviMainWindow, visible, rect = -4, -4, 1024, 708
- Ptr 17296024: object: qt_top_dock, class QDockArea
- Ptr 14882136: object: qt_custom_toolbar, class KviCustomToolBar
- Ptr 18143368: object: qt_dockwidget_internal, class QDockWindowTitleBar
- [br][br]
- Every listed widget has a "name", a "class" and a set of properties.[br]
- The first entry in this example is a KVIrc server window, class "KviMainWindow" and name "kvirc_frame":
- it is a toplevel widget.[br]
- The "qt_top_dock", "qt_custom_toolbar" and the "qt_dockwidget_internal" are
- direct children of that widget.[br]
- To indicate a specific widget we will use the "class::name" form.[br]
- So to indicate the main KVIrc frame you will use "KviMainWindow::kvirc_main_frame".
- Look at this example:[br]
- %A=$new(wrapper,0,test,KviMainWindow::kvirc_frame,KviStatusBar::unnamed)[br]
- %A->$setBackGroundColor(FFFFFF)[br]
- For first thing we create an object type wrapper,then we flow the tree that there from the command /object.dump and we will have:[br]
- . [br]
- . [br]
- Ptr 14196288: top level object: kvirc_frame, class KviMainWindow, visible, rect = -4, -4, 1024, 712 [br]
+ @doc: wrapper
+ @keyterms:
+ wrapper object class,
+ @title:
+ wrapper class
+ @type:
+ class
+ @short:
+ Provides a wrapper class that hooks to an existing Qt graphic object modifying it.
+ @inherits:
+ [class]object[/class]
+ [class]widget[/class]
+ @description:
+ This is a class for advanced KVIrc scripting.[br]
+ It can wrap any existing KVIrc widget.[br]
+ This class allows some unbelievable changes to the whole graphic environment of the kvirc,[br]
+ in fact, could hook every widget, you can modify the property or you can be inserted other widget as child of this...[br]
+ in short you have absolute liberty. [br]
+ The power of this class is fantastic, because it allows the change at "run time" of almost all the elements of the Kvirc.[br]
+ But to use this class in optimal way and to exploit its power, you have to know the Qt.... so you won't have limits [br]
+ The KVIrc Qt widgets are arranged in trees (just as the objects).[br]
+ The difference is that there are more toplevel widgets (and so more than one tree).[br]
+ You can use [fnc]$objects.dump()[/fnc] to take a look at the KVIrc Qt objects tree.[br]
+ Here is a part of the tree:[br][br]
+ Ptr 14332520: top level object: kvirc_frame, class KviMainWindow, visible, rect = -4, -4, 1024, 708
+ Ptr 17296024: object: qt_top_dock, class QDockArea
+ Ptr 14882136: object: qt_custom_toolbar, class KviCustomToolBar
+ Ptr 18143368: object: qt_dockwidget_internal, class QDockWindowTitleBar
+ [br][br]
+ Every listed widget has a "name", a "class" and a set of properties.[br]
+ The first entry in this example is a KVIrc server window, class "KviMainWindow" and name "kvirc_frame":
+ it is a toplevel widget.[br]
+ The "qt_top_dock", "qt_custom_toolbar" and the "qt_dockwidget_internal" are
+ direct children of that widget.[br]
+ To indicate a specific widget we will use the "class::name" form.[br]
+ So to indicate the main KVIrc frame you will use "KviMainWindow::kvirc_main_frame".
+ Look at this example:[br]
+ %A=$new(wrapper,0,test,KviMainWindow::kvirc_frame,KviStatusBar::unnamed)[br]
+ %A->$setBackGroundColor(FFFFFF)[br]
+ For first thing we create an object type wrapper,then we flow the tree that there from the command /object.dump and we will have:[br]
+ . [br]
+ . [br]
+ Ptr 14196288: top level object: kvirc_frame, class KviMainWindow, visible, rect = -4, -4, 1024, 712 [br]
. [br]
- Ptr 17197360: object: unnamed, class KviStatusBar [br]
- . [br]
- . [br]
- in this way we can follow the order, father->child from the top-level widget(KviMainWindow::kvirc_frame)[br]
- to reach the child that interests us (KviStatusBar::unnamed)[br]
- Then, following the syntax we will have:
- %A=$new(wrapper,0,test,KviMainWindow::kvirc_frame,KviStatusBar::unnamed)
- Now %A. will be point to the wrapped object, therefore we could modify its property or to consider it as if it were an object created by us in scripting. [br]
- Obviously, deleting the created object (for example %A) you don't will delete the object of Kvirc (in this case the statusbar). [br]
- Another example could be this:[br]
- %A=$new(wrapper,0,test,KviMainWindow::kvirc_frame,QToolButton::kvirc.identityoptions)[br]
- %A->$setProperty(usesBigPixmap,0)[br]
- In this fool example with the function $setProperty, we has setted the property usesBigPixmap to False, making to become the small icons of the ToolBar.[br]
- [br]
- The wrapping object search can optionally start with a window
- identifier with the following syntax: WinId::<window_id>.
+ Ptr 17197360: object: unnamed, class KviStatusBar [br]
+ . [br]
+ . [br]
+ in this way we can follow the order, father->child from the top-level widget(KviMainWindow::kvirc_frame)[br]
+ to reach the child that interests us (KviStatusBar::unnamed)[br]
+ Then, following the syntax we will have:
+ %A=$new(wrapper,0,test,KviMainWindow::kvirc_frame,KviStatusBar::unnamed)
+ Now %A. will be point to the wrapped object, therefore we could modify its property or to consider it as if it were an object created by us in scripting. [br]
+ Obviously, deleting the created object (for example %A) you don't will delete the object of Kvirc (in this case the statusbar). [br]
+ Another example could be this:[br]
+ %A=$new(wrapper,0,test,KviMainWindow::kvirc_frame,QToolButton::kvirc.identityoptions)[br]
+ %A->$setProperty(usesBigPixmap,0)[br]
+ In this fool example with the function $setProperty, we has setted the property usesBigPixmap to False, making to become the small icons of the ToolBar.[br]
+ [br]
+ The wrapping object search can optionally start with a window
+ identifier with the following syntax: WinId::<window_id>.
*/
@@ -128,46 +128,38 @@ bool KvsObject_wrapper::init(KviKvsRunTimeContext * pContext,KviKvsVariantList *
pParams->at(i)->asString(s);
if (!s.isEmpty())
{
- int idx = s.indexOf("::");
- if( idx != -1 )
- {
- szClass = s.left(idx);
- szName = s.right(s.length() - idx - 2);
- }
- else
- {
- szClass = s;
- szName = "";
- }
- if(KviQString::equalCI(szClass,"WinId"))
- {
- if(pWidget)
- {
- pContext->warning(__tr2qs_ctx("The window identifier preceded by WinId must be the first object in the search path","objects"));
- return false;
- }
- else
- {
- pWidget = g_pApp->findWindow(szName);
- }
- }
- else
- {
- if(pWidget)
- {
- pWidget = findWidgetToWrap(!szClass.isEmpty() ? szClass.toUtf8().data() : "", !szName.isEmpty() ? szName.toUtf8().data() : "", pWidget);
- }
- else
- {
- pWidget = findTopLevelWidgetToWrap(!szClass.isEmpty() ? szClass.toUtf8().data() : "", !szName.isEmpty() ? szName.toUtf8().data() : "");
- }
- }
- if( !pWidget )
- {
- pContext->warning(__tr2qs_ctx("Failed to find one of the wrap path widgets ('%Q::%Q')","objects"),&szClass,&szName);
- return false;
- }
- }
+ int idx = s.indexOf("::");
+ if( idx != -1 )
+ {
+ szClass = s.left(idx);
+ szName = s.right(s.length() - idx - 2);
+ } else {
+ szClass = s;
+ szName = "";
+ }
+ if(KviQString::equalCI(szClass,"WinId"))
+ {
+ if(pWidget)
+ {
+ pContext->warning(__tr2qs_ctx("The window identifier preceded by WinId must be the first object in the search path","objects"));
+ return false;
+ } else {
+ pWidget = g_pApp->findWindow(szName);
+ }
+ } else {
+ if(pWidget)
+ {
+ pWidget = findWidgetToWrap(!szClass.isEmpty() ? szClass.toUtf8().data() : "", !szName.isEmpty() ? szName.toUtf8().data() : "", pWidget);
+ } else {
+ pWidget = findTopLevelWidgetToWrap(!szClass.isEmpty() ? szClass.toUtf8().data() : "", !szName.isEmpty() ? szName.toUtf8().data() : "");
+ }
+ }
+ if( !pWidget )
+ {
+ pContext->warning(__tr2qs_ctx("Failed to find one of the wrap path widgets ('%Q::%Q')","objects"),&szClass,&szName);
+ return false;
+ }
+ }
i++;
}
if( !pWidget )
@@ -178,6 +170,7 @@ bool KvsObject_wrapper::init(KviKvsRunTimeContext * pContext,KviKvsVariantList *
setObject(pWidget,false);
return true;
}
+
QWidget *KvsObject_wrapper::findTopLevelWidgetToWrap(const QString szClass, const QString szName)
{
QWidgetList list = g_pApp->topLevelWidgets();
@@ -216,6 +209,3 @@ QWidget *KvsObject_wrapper::findWidgetToWrap(const QString szClass, const QStrin
}
return 0;
}
-
-
-