[rkward-cvs] SF.net SVN: rkward:[3671] trunk/rkward/rkward/plugin
tfry at users.sourceforge.net
tfry at users.sourceforge.net
Sat Jun 4 11:25:51 UTC 2011
Revision: 3671
http://rkward.svn.sourceforge.net/rkward/?rev=3671&view=rev
Author: tfry
Date: 2011-06-04 11:25:51 +0000 (Sat, 04 Jun 2011)
Log Message:
-----------
Support checkable frames.
Modified Paths:
--------------
trunk/rkward/rkward/plugin/CMakeLists.txt
trunk/rkward/rkward/plugin/rkcomponent.h
trunk/rkward/rkward/plugin/rkstandardcomponent.cpp
Added Paths:
-----------
trunk/rkward/rkward/plugin/rkpluginframe.cpp
trunk/rkward/rkward/plugin/rkpluginframe.h
Modified: trunk/rkward/rkward/plugin/CMakeLists.txt
===================================================================
--- trunk/rkward/rkward/plugin/CMakeLists.txt 2011-06-04 10:48:32 UTC (rev 3670)
+++ trunk/rkward/rkward/plugin/CMakeLists.txt 2011-06-04 11:25:51 UTC (rev 3671)
@@ -24,6 +24,7 @@
rkpreviewbox.cpp
rkpluginsaveobject.cpp
rkabstractoptionselector.cpp
+ rkpluginframe.cpp
)
QT4_AUTOMOC(${plugin_STAT_SRCS})
Modified: trunk/rkward/rkward/plugin/rkcomponent.h
===================================================================
--- trunk/rkward/rkward/plugin/rkcomponent.h 2011-06-04 10:48:32 UTC (rev 3670)
+++ trunk/rkward/rkward/plugin/rkcomponent.h 2011-06-04 11:25:51 UTC (rev 3671)
@@ -57,6 +57,7 @@
ComponentDropDown = 2013,
ComponentPreviewBox = 2014,
ComponentSaveObject = 2015,
+ ComponentFrame = 2016,
ComponentStandard = 2100,
ComponentContextHandler = 2900,
ComponentUser = 3000 /**< for user expansion */
Added: trunk/rkward/rkward/plugin/rkpluginframe.cpp
===================================================================
--- trunk/rkward/rkward/plugin/rkpluginframe.cpp (rev 0)
+++ trunk/rkward/rkward/plugin/rkpluginframe.cpp 2011-06-04 11:25:51 UTC (rev 3671)
@@ -0,0 +1,88 @@
+/***************************************************************************
+ rkpluginframe.cpp - description
+ -------------------
+ begin : Sat Jun 4 2011
+ copyright : (C) 2011 by Thomas Friedrichsmeier
+ email : tfry at users.sourceforge.net
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#include "rkpluginframe.h"
+
+#include <QVBoxLayout>
+#include <QGroupBox>
+
+#include <kvbox.h>
+
+#include "../rkglobals.h"
+#include "../misc/xmlhelper.h"
+#include "../debug.h"
+
+RKPluginFrame::RKPluginFrame (const QDomElement &element, RKComponent *parent_component, QWidget *parent_widget) : RKComponent (parent_component, parent_widget) {
+ RK_TRACE (PLUGIN);
+
+ XMLHelper* xml = XMLHelper::getStaticHelper ();
+
+ QVBoxLayout *layout = new QVBoxLayout (this);
+ layout->setContentsMargins (0, 0, 0, 0);
+ frame = new QGroupBox (xml->getStringAttribute (element, "label", QString(), DL_INFO), this);
+ layout->addWidget (frame);
+ layout = new QVBoxLayout (frame);
+ page = new KVBox (this);
+ page->setSpacing (RKGlobals::spacingHint ());
+ layout->addWidget (page);
+
+ checked = 0;
+ if (xml->getBoolAttribute (element, "checkable", false, DL_INFO)) {
+ frame->setCheckable (true);
+ frame->setChecked (xml->getBoolAttribute (element, "checked", false, DL_INFO));
+ initCheckedProperty ();
+ connect (frame, SIGNAL (toggled(bool)), this, SLOT (checkedChanged()));
+ }
+}
+
+RKPluginFrame::~RKPluginFrame () {
+ RK_TRACE (PLUGIN);
+}
+
+void RKPluginFrame::initCheckedProperty () {
+ RK_TRACE (PLUGIN);
+ RK_ASSERT (!checked);
+ if (!frame->isCheckable ()) {
+ RK_DO (qDebug ("This frame does not have a property 'checked', as it is not checkable"), PLUGIN, DL_DEBUG);
+ return;
+ }
+
+ addChild ("checked", checked = new RKComponentPropertyBool (this, false, frame->isChecked ()));
+ connect (checked, SIGNAL (valueChanged (RKComponentPropertyBase *)), this, SLOT (propertyChanged (RKComponentPropertyBase *)));
+ checked->setInternal (true);
+}
+
+RKComponentBase* RKPluginFrame::lookupComponent (const QString& identifier, QString* remainder) {
+ if ((!checked) && (identifier == "checked")) initCheckedProperty ();
+ return RKComponentBase::lookupComponent(identifier, remainder);
+}
+
+void RKPluginFrame::propertyChanged (RKComponentPropertyBase* property) {
+ RK_TRACE (PLUGIN);
+
+ RK_ASSERT (checked && (property == checked));
+ if (frame->isChecked () != checked->boolValue ()) frame->setChecked (checked->boolValue ());
+}
+
+void RKPluginFrame::checkedChanged () {
+ RK_TRACE (PLUGIN);
+ RK_ASSERT (checked);
+
+ if (frame->isChecked () != checked->boolValue ()) checked->setBoolValue (frame->isChecked ());
+}
+
+#include "rkpluginframe.moc"
Added: trunk/rkward/rkward/plugin/rkpluginframe.h
===================================================================
--- trunk/rkward/rkward/plugin/rkpluginframe.h (rev 0)
+++ trunk/rkward/rkward/plugin/rkpluginframe.h 2011-06-04 11:25:51 UTC (rev 3671)
@@ -0,0 +1,54 @@
+/***************************************************************************
+ rkpluginframe.cpp - description
+ -------------------
+ begin : Sat Jun 4 2011
+ copyright : (C) 2011 by Thomas Friedrichsmeier
+ email : tfry at users.sourceforge.net
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef RKPLUGINFRAME_H
+#define RKPLUGINFRAME_H
+
+#include "rkcomponent.h"
+
+class QDomElement;
+class QGroupBox;
+class KVBox;
+
+/** A passive component acting as a group box. Provides property "checked".
+
+ at author Thomas Friedrichsmeier
+*/
+class RKPluginFrame : public RKComponent {
+ Q_OBJECT
+public:
+ RKPluginFrame (const QDomElement &element, RKComponent *parent_component, QWidget *parent_widget);
+ ~RKPluginFrame ();
+
+/** returns the page child elements should be drawn in */
+ KVBox *getPage () { return page; };
+ int type () { return ComponentFrame; };
+
+/** re-implemented to create "checked" property on demand. */
+ RKComponentBase* lookupComponent (const QString &identifier, QString *remainder);
+private slots:
+/** called when checked property changes */
+ void propertyChanged (RKComponentPropertyBase *property);
+ void checkedChanged ();
+private:
+ void initCheckedProperty ();
+ RKComponentPropertyBool *checked;
+ KVBox *page;
+ QGroupBox *frame;
+};
+
+#endif
Modified: trunk/rkward/rkward/plugin/rkstandardcomponent.cpp
===================================================================
--- trunk/rkward/rkward/plugin/rkstandardcomponent.cpp 2011-06-04 10:48:32 UTC (rev 3670)
+++ trunk/rkward/rkward/plugin/rkstandardcomponent.cpp 2011-06-04 11:25:51 UTC (rev 3671)
@@ -53,6 +53,7 @@
#include "rkpreviewbox.h"
#include "rktext.h"
#include "rktabpage.h"
+#include "rkpluginframe.h"
#include "../rkglobals.h"
@@ -566,7 +567,7 @@
layout->addWidget (box);
buildElement (e, box, false);
} else if (e.tagName () == "row") {
- widget = new RKComponent (component (), parent_widget); // wrapping this (and column, frame below) inside an RKComponent has the benefit, that it can have an id, and hence can be set to visibile/hidden, enabled/disabled
+ widget = new RKComponent (component (), parent_widget); // wrapping this (and column, below) inside an RKComponent has the benefit, that it can have an id, and hence can be set to visibile/hidden, enabled/disabled
QVBoxLayout *layout = new QVBoxLayout (widget);
layout->setContentsMargins (0, 0, 0, 0);
KHBox *box = new KHBox (widget);
@@ -586,16 +587,9 @@
layout->addWidget (box);
buildElement (e, box, false);
} else if (e.tagName () == "frame") {
- widget = new RKComponent (component (), parent_widget);
- QVBoxLayout *layout = new QVBoxLayout (widget);
- layout->setContentsMargins (0, 0, 0, 0);
- QGroupBox *box = new QGroupBox (e.attribute ("label"), widget);
- layout->addWidget (box);
- QVBoxLayout* internal_layout = new QVBoxLayout (box);
- KVBox* internal_box = new KVBox (box);
- internal_box->setSpacing (RKGlobals::spacingHint ());
- internal_layout->addWidget (internal_box);
- buildElement (e, internal_box, false);
+ RKPluginFrame *frame = new RKPluginFrame (e, component (), parent_widget);
+ widget = frame;
+ buildElement (e, frame->getPage (), false);
} else if (e.tagName () == "tabbook") {
QTabWidget *tabbook = new QTabWidget (parent_widget);
QDomNodeList tabs = e.childNodes ();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the rkward-tracker
mailing list