[rkward/frameworks] /: More KDElibs4Support-code removals. This time factoring KVBox out of the plugins' main build procedure.

Thomas Friedrichsmeier thomas.friedrichsmeier at ruhr-uni-bochum.de
Fri Feb 12 20:33:17 UTC 2016


Git commit 70019d1e2426971b378c1c3cf0712a3d9cb8632e by Thomas Friedrichsmeier.
Committed on 12/02/2016 at 16:57.
Pushed by tfry into branch 'frameworks'.

More KDElibs4Support-code removals. This time factoring KVBox out of the plugins' main build procedure.
Since this is slightly non-trivial, recording it in a separate commit.

M  +1    -0    TODO
M  +1    -1    rkward/plugin/rkpluginframe.cpp
M  +2    -2    rkward/plugin/rkpluginframe.h
M  +13   -21   rkward/plugin/rkstandardcomponent.cpp
M  +3    -1    rkward/plugin/rkstandardcomponentgui.cpp
M  +3    -4    rkward/plugin/rktabpage.h

http://commits.kde.org/rkward/70019d1e2426971b378c1c3cf0712a3d9cb8632e

diff --git a/TODO b/TODO
index 6537a6f..3e5b843 100644
--- a/TODO
+++ b/TODO
@@ -8,6 +8,7 @@ Things to do:
 - Adjust platform checks
 - Device window embedding / remove qwinhost
 - Grep for "KF5 TODO"
+- Remove katepart status bar from all previews (including in wizard)
 Things to test at the end:
 - Everthing concerning loading / saving, from recent files, scripts, workspace, etc.
   - Moved installations, moved workspaces.
diff --git a/rkward/plugin/rkpluginframe.cpp b/rkward/plugin/rkpluginframe.cpp
index 80e6869..30ce7a6 100644
--- a/rkward/plugin/rkpluginframe.cpp
+++ b/rkward/plugin/rkpluginframe.cpp
@@ -37,7 +37,7 @@ RKPluginFrame::RKPluginFrame (const QDomElement &element, RKComponent *parent_co
 	layout->addWidget (frame);
 	layout = new QVBoxLayout (frame);
 	page = new KVBox (frame);
-	page->setSpacing (RKGlobals::spacingHint ());
+	static_cast<KVBox*> (page)->setSpacing (RKGlobals::spacingHint ());
 	layout->addWidget (page);
 
 	checked = 0;
diff --git a/rkward/plugin/rkpluginframe.h b/rkward/plugin/rkpluginframe.h
index e8d0301..f4f4a4f 100644
--- a/rkward/plugin/rkpluginframe.h
+++ b/rkward/plugin/rkpluginframe.h
@@ -35,7 +35,7 @@ public:
 	~RKPluginFrame ();
 
 /** returns the page child elements should be drawn in */
-	KVBox *getPage () { return page; };
+	QWidget *getPage () { return page; };
 	int type () { return ComponentFrame; };
 /** reimplemented to return the value of the checked property by default */
 	QVariant value (const QString &modifier=QString ());
@@ -49,7 +49,7 @@ private slots:
 private:
 	void initCheckedProperty ();
 	RKComponentPropertyBool *checked;
-	KVBox *page;
+	QWidget *page;
 	QGroupBox *frame;
 };
 
diff --git a/rkward/plugin/rkstandardcomponent.cpp b/rkward/plugin/rkstandardcomponent.cpp
index 65ef434..0f2efe5 100644
--- a/rkward/plugin/rkstandardcomponent.cpp
+++ b/rkward/plugin/rkstandardcomponent.cpp
@@ -27,8 +27,6 @@
 
 #include <klocale.h>
 #include <kmessagebox.h>
-#include <kvbox.h>
-#include <khbox.h>
 
 #include "rkstandardcomponentgui.h"
 #include "rkcomponentmap.h"
@@ -151,10 +149,8 @@ RKStandardComponent::RKStandardComponent (RKComponent *parent_component, QWidget
 				build_wizard = false;
 
 				QWidget *fake_page = parent_component->addPage ();
-				QVBoxLayout *layout = new QVBoxLayout (fake_page);	
-				KVBox *box = new KVBox (fake_page);
-				layout->addWidget (box);
-				parent_widget = box;
+				new QVBoxLayout (fake_page);
+				parent_widget = fake_page;
 			}
 		} else {
 			gui_element = xml->getChildElement (doc_element, "dialog", DL_WARNING);
@@ -576,6 +572,7 @@ void RKComponentBuilder::buildElement (const QDomElement &element, XMLHelper &xm
 	
 	XMLChildList::const_iterator it;
 	for (it = children.constBegin (); it != children.constEnd (); ++it) {
+		bool add_to_layout = true;
 		RKComponent *widget = 0;
 		QDomElement e = *it;		// shorthand
 		QString id = xml.getStringAttribute (e, "id", QString (), DL_INFO);
@@ -586,30 +583,25 @@ void RKComponentBuilder::buildElement (const QDomElement &element, XMLHelper &xm
 
 		if (allow_pages && (e.tagName () == QLatin1String ("page"))) {
 			widget = component ()->addPage ();
-			QVBoxLayout *layout = new QVBoxLayout (widget);
-			KVBox *box = new KVBox (widget);
-			layout->addWidget (box);
-			buildElement (e, xml, box, false);
+			add_to_layout = false;   // For wizards, that's done inside addPage()
+			new QVBoxLayout (widget);
+			buildElement (e, xml, widget, false);
 		} else if (e.tagName () == QLatin1String ("row")) {
 			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);
+			QHBoxLayout *layout = new QHBoxLayout (widget);
 			layout->setContentsMargins (0, 0, 0, 0);
-			KHBox *box = new KHBox (widget);
-			layout->addWidget (box);
-			buildElement (e, xml, box, false);
+			buildElement (e, xml, widget, false);
 		} else if (e.tagName () == QLatin1String ("stretch")) {
 			QWidget *stretch = new QWidget (parent_widget);
 			stretch->setSizePolicy (QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
-			KHBox *box = dynamic_cast<KHBox *> (parent_widget);
+			QBoxLayout *box = dynamic_cast<QBoxLayout *> (parent_widget->layout ());
 			// RK_ASSERT (box);  <- NO, also meaningful in a <frame>
 			if (box) box->setStretchFactor (stretch, 100);
 		} else if (e.tagName () == QLatin1String ("column")) {
 			widget = new RKComponent (component (), parent_widget);
 			QVBoxLayout *layout = new QVBoxLayout (widget);
 			layout->setContentsMargins (0, 0, 0, 0);
-			KVBox *box = new KVBox (widget);
-			layout->addWidget (box);
-			buildElement (e, xml, box, false);
+			buildElement (e, xml, widget, false);
 		} else if (e.tagName () == QLatin1String ("frame")) {
 			RKPluginFrame *frame = new RKPluginFrame (e, component (), parent_widget);
 			widget = frame;
@@ -658,7 +650,6 @@ void RKComponentBuilder::buildElement (const QDomElement &element, XMLHelper &xm
 		} else if (e.tagName () == QLatin1String ("text")) {
 			widget = new RKText (e, component (), parent_widget);
 		} else if (e.tagName () == QLatin1String ("preview")) {
-			QWidget *pwidget = parent_widget;
 			if (!parent->isWizardish ()) {
 				RKStandardComponent *uicomp = parent->topmostStandardComponent ();
 				if (uicomp) {
@@ -701,8 +692,9 @@ void RKComponentBuilder::buildElement (const QDomElement &element, XMLHelper &xm
 			xml.displayError (&e, QString ("Invalid tagname '%1'").arg (e.tagName ()), DL_ERROR);
 		}
 
-		if (widget && (!(id.isNull ()))) {
-			parent->addChild (id, widget);
+		if (widget) {
+			if (add_to_layout) parent_widget->layout ()->addWidget (widget);
+			if (!id.isNull ()) parent->addChild (id, widget);
 		}
 	}
 }
diff --git a/rkward/plugin/rkstandardcomponentgui.cpp b/rkward/plugin/rkstandardcomponentgui.cpp
index 3b8458e..6c533f6 100644
--- a/rkward/plugin/rkstandardcomponentgui.cpp
+++ b/rkward/plugin/rkstandardcomponentgui.cpp
@@ -729,8 +729,10 @@ RKComponent *RKStandardComponentStack::addPage (RKComponent *parent) {
 	RK_TRACE (PLUGIN);
 
 	PageDef *def = new PageDef;
-	KVBox *wrap = new KVBox (this);
+	QWidget *wrap = new QWidget ();
+	new QVBoxLayout (wrap);
 	def->page = new RKComponent (parent, wrap);
+	wrap->layout ()->addWidget (def->page);
 	setCurrentIndex (addWidget (wrap));
 	pages.append (def);
 
diff --git a/rkward/plugin/rktabpage.h b/rkward/plugin/rktabpage.h
index 51f79ab..7ba8676 100644
--- a/rkward/plugin/rktabpage.h
+++ b/rkward/plugin/rktabpage.h
@@ -24,7 +24,6 @@
 
 class QDomElement;
 class QTabWidget;
-class KVBox;
 
 /** A passive component acting as a page in a tabbook. The only function is, that if the component is hidden, the corresponding tab in the tabbook is also hidden.
 
@@ -37,8 +36,8 @@ public:
 
 	~RKTabPage ();
 
-	// returns the page child elements should be drawn in
-	KVBox *getPage () { return page; };
+	/** @returns the page child elements should be drawn in */
+	QWidget *getPage () { return page; };
 
 	int type () { return ComponentTab; };
 
@@ -46,7 +45,7 @@ public slots:
 /** called when visibile or enabled properties change */
 	void visibleEnabledChanged (RKComponentPropertyBase *property);
 private:
-	KVBox *page;
+	QWidget *page;
 	QTabWidget *tabbook;
 	int index;
 	QString label;



More information about the rkward-tracker mailing list