[rkward-cvs] SF.net SVN: rkward: [2067] branches/KDE4_port

tfry at users.sourceforge.net tfry at users.sourceforge.net
Sun Oct 14 22:55:23 UTC 2007


Revision: 2067
          http://rkward.svn.sourceforge.net/rkward/?rev=2067&view=rev
Author:   tfry
Date:     2007-10-14 15:55:23 -0700 (Sun, 14 Oct 2007)

Log Message:
-----------
subdir misc compiles

Modified Paths:
--------------
    branches/KDE4_port/TODO_KDE4
    branches/KDE4_port/rkward/misc/getfilenamewidget.cpp
    branches/KDE4_port/rkward/misc/rkcommonfunctions.cpp
    branches/KDE4_port/rkward/misc/rkdummypart.cpp
    branches/KDE4_port/rkward/misc/rkobjectlistview.cpp
    branches/KDE4_port/rkward/misc/rkobjectlistview.h
    branches/KDE4_port/rkward/misc/rkprogresscontrol.cpp
    branches/KDE4_port/rkward/misc/rkspinbox.cpp
    branches/KDE4_port/rkward/misc/rkspinbox.h
    branches/KDE4_port/rkward/misc/xmlhelper.cpp
    branches/KDE4_port/rkward/plugin/rkpluginspinbox.cpp
    branches/KDE4_port/rkward/settings/rksettingsmodulegeneral.cpp
    branches/KDE4_port/rkward/settings/rksettingsmoduleplugins.cpp

Modified: branches/KDE4_port/TODO_KDE4
===================================================================
--- branches/KDE4_port/TODO_KDE4	2007-10-14 21:12:41 UTC (rev 2066)
+++ branches/KDE4_port/TODO_KDE4	2007-10-14 22:55:23 UTC (rev 2067)
@@ -72,4 +72,10 @@
 	- find out how to call dbus for the help browser!
 
 rklocalesupport:
-	- does locale switching / detection work? Does Qt have something, yet?
\ No newline at end of file
+	- does locale switching / detection work? Does Qt have something, yet?
+
+rkspinbox:
+	- does it work at all? in both modes?
+
+rkobjectlistview:
+	- do the tool-tips for the objects work?
\ No newline at end of file

Modified: branches/KDE4_port/rkward/misc/getfilenamewidget.cpp
===================================================================
--- branches/KDE4_port/rkward/misc/getfilenamewidget.cpp	2007-10-14 21:12:41 UTC (rev 2066)
+++ branches/KDE4_port/rkward/misc/getfilenamewidget.cpp	2007-10-14 22:55:23 UTC (rev 2067)
@@ -38,7 +38,7 @@
 	connect (edit, SIGNAL (textChanged (const QString &)), this, SLOT (locationEditChanged (const QString &)));
 	vbox->addWidget (edit);
 
-	edit->setURL (initial);
+	edit->setUrl (initial);
 	if (mode == ExistingDirectory) {
 		edit->setMode (KFile::Directory | KFile::ExistingOnly);
 	} else if (mode == ExistingFile) {
@@ -67,7 +67,7 @@
 void GetFileNameWidget::setLocation (const QString &new_location) {
 	RK_TRACE (MISC);
 
-	edit->setURL (new_location);
+	edit->setUrl (new_location);
 }
 
 void GetFileNameWidget::locationEditChanged (const QString &) {
@@ -76,7 +76,7 @@
 }
 
 QString GetFileNameWidget::getLocation () {
-	return edit->url ();
+	return (edit->url ().path ());
 }
 
 void GetFileNameWidget::setBackgroundColor (const QColor & color) {

Modified: branches/KDE4_port/rkward/misc/rkcommonfunctions.cpp
===================================================================
--- branches/KDE4_port/rkward/misc/rkcommonfunctions.cpp	2007-10-14 21:12:41 UTC (rev 2066)
+++ branches/KDE4_port/rkward/misc/rkcommonfunctions.cpp	2007-10-14 22:55:23 UTC (rev 2067)
@@ -52,11 +52,10 @@
 		from->setXMLGUIBuildDocument (doc);
 	
 		if (recursive) {
-			Q3PtrList <KXMLGUIClient> *children = const_cast<Q3PtrList <KXMLGUIClient> *> (from->childClients ());
-			if (children) {
-				for (KXMLGUIClient *child = children->first (); child; child = children->next ()) {
-					removeContainers (child, names, true);
-				}
+			QList<KXMLGUIClient*> children = from->childClients ();
+			QList<KXMLGUIClient*>::const_iterator it;
+			for (it = children.constBegin (); it != children.constEnd (); ++it) {
+				removeContainers ((*it), names, true);
 			}
 		}
 	}
@@ -92,11 +91,10 @@
 
 		// recurse
 		if (recursive) {
-			Q3PtrList <KXMLGUIClient> *children = const_cast<Q3PtrList <KXMLGUIClient> *> (client->childClients ());
-			if (children) {
-				for (KXMLGUIClient *child = children->first (); child; child = children->next ()) {
-					moveContainer (child, tagname, name, to_name, true);
-				}
+			QList<KXMLGUIClient*> children = client->childClients ();
+			QList<KXMLGUIClient*>::const_iterator it;
+			for (it = children.constBegin (); it != children.constEnd (); ++it) {
+				moveContainer (*it, tagname, name, to_name, true);
 			}
 		}
 	}

Modified: branches/KDE4_port/rkward/misc/rkdummypart.cpp
===================================================================
--- branches/KDE4_port/rkward/misc/rkdummypart.cpp	2007-10-14 21:12:41 UTC (rev 2066)
+++ branches/KDE4_port/rkward/misc/rkdummypart.cpp	2007-10-14 22:55:23 UTC (rev 2067)
@@ -25,8 +25,7 @@
 	RK_TRACE (MISC);
 	setWidget (widget);
 
-	KInstance* instance = new KInstance ("rkward");
-	setInstance (instance);
+	setComponentData (KGlobal::mainComponent ());
 }
 
 RKDummyPart::~RKDummyPart () {

Modified: branches/KDE4_port/rkward/misc/rkobjectlistview.cpp
===================================================================
--- branches/KDE4_port/rkward/misc/rkobjectlistview.cpp	2007-10-14 21:12:41 UTC (rev 2066)
+++ branches/KDE4_port/rkward/misc/rkobjectlistview.cpp	2007-10-14 22:55:23 UTC (rev 2067)
@@ -22,6 +22,7 @@
 #include <q3popupmenu.h>
 #include <qpixmap.h>
 #include <qimage.h>
+#include <QHelpEvent>
 
 #include "../rkglobals.h"
 #include "../core/robjectlist.h"
@@ -63,16 +64,14 @@
 	menu->insertItem (i18n ("Configure Defaults"), this, SLOT (popupConfigure ()));
 	connect (this, SIGNAL (contextMenuRequested (Q3ListViewItem *, const QPoint &, int)), this, SLOT (requestedContextMenu (Q3ListViewItem*, const QPoint&, int)));
 
+// KDE4: do we need this?
 	setShowToolTips (false);
-	tip = new RKObjectListViewTip (this);
 
 	objectBrowserSettingsChanged ();
 }
 
 RKObjectListView::~RKObjectListView () {
 	RK_TRACE (APP);
-
-	delete tip;
 }
 
 void RKObjectListView::setObjectCurrent (RObject *object, bool only_if_none_current) {
@@ -343,8 +342,24 @@
 	} */
 }
 
+bool RKObjectListView::event (QEvent *event) {
+	// don't trace here!
+	if (event->type() == QEvent::ToolTip) {
+		RK_TRACE (APP);
 
+		QHelpEvent *help_event = static_cast<QHelpEvent *>(event);
+		RKListViewItem *item = static_cast<RKListViewItem *> (itemAt (help_event->pos ()));
+		if (item) {
+			RObject *object = findItemObject (item);
+			if (object) {
+				QToolTip::showText (help_event->globalPos(), object->getObjectDescription (), this, itemRect (item));
+			}
+		}
+	}
+	return Q3ListView::event(event);
+}
 
+
 //////////////////// RKListViewItem //////////////////////////
 int RKListViewItem::width (const QFontMetrics &fm, const Q3ListView * lv, int c) const {
 	if (parent ()) {
@@ -499,27 +514,4 @@
 	return true;
 }
 
-
-///////// RKObjectListViewTip ////////////
-RKObjectListViewTip::RKObjectListViewTip (RKObjectListView *parent) : QToolTip (parent->viewport ()) {
-	RK_TRACE (APP);
-
-	view = parent;
-}
-
-RKObjectListViewTip::~RKObjectListViewTip () {
-	RK_TRACE (APP);
-}
-
-void RKObjectListViewTip::maybeTip (const QPoint &pos) {
-	RK_TRACE (APP);
-
-	RKListViewItem *item = static_cast<RKListViewItem *> (view->itemAt (pos));
-	if (!item) return;
-	RObject *object = view->findItemObject (item);
-	if (!object) return;
-
-	tip (view->itemRect (item), object->getObjectDescription ());
-}
-
 #include "rkobjectlistview.moc"

Modified: branches/KDE4_port/rkward/misc/rkobjectlistview.h
===================================================================
--- branches/KDE4_port/rkward/misc/rkobjectlistview.h	2007-10-14 21:12:41 UTC (rev 2066)
+++ branches/KDE4_port/rkward/misc/rkobjectlistview.h	2007-10-14 22:55:23 UTC (rev 2067)
@@ -28,7 +28,6 @@
 class QPixmap;
 class Q3PopupMenu;
 class RKListViewItem;
-class RKObjectListViewTip;
 class RKObjectListViewSettings;
 
 /**
@@ -80,6 +79,9 @@
 	void requestedContextMenu (Q3ListViewItem *item, const QPoint &pos, int col);
 	
 	virtual void popupConfigure ();
+protected:
+/** reimplemented for tool tips */
+	bool event (QEvent *event);
 private:
 // TODO: keep an additional map from RObject to RKListViewItem, in order to make this (often called) more efficient
 	RKListViewItem *findObjectItem (RObject *object);
@@ -97,7 +99,6 @@
 	RObject *menu_object;
 
 	RKObjectListViewSettings *settings;
-	RKObjectListViewTip *tip;
 
 	static QPixmap *icon_function;
 	static QPixmap *icon_list;
@@ -118,16 +119,6 @@
 	int width (const QFontMetrics &fm, const Q3ListView * lv, int c) const;
 };
 
-class RKObjectListViewTip : public QToolTip {
-protected:
-friend class RKObjectListView;
-	RKObjectListViewTip (RKObjectListView *parent);
-	~RKObjectListViewTip ();
-
-	void maybeTip (const QPoint &pos);
-	RKObjectListView *view;
-};
-
 /** Represents the filter/view settings possible for an RKListView. */
 class RKObjectListViewSettings : public QObject {
 	Q_OBJECT

Modified: branches/KDE4_port/rkward/misc/rkprogresscontrol.cpp
===================================================================
--- branches/KDE4_port/rkward/misc/rkprogresscontrol.cpp	2007-10-14 21:12:41 UTC (rev 2066)
+++ branches/KDE4_port/rkward/misc/rkprogresscontrol.cpp	2007-10-14 22:55:23 UTC (rev 2067)
@@ -227,7 +227,7 @@
 
 		output_text = new Q3TextEdit (output_box);
 		output_text->setReadOnly (true);
-		output_text->setTextFormat (PlainText);
+		output_text->setTextFormat (Qt::PlainText);
 		output_text->setUndoRedoEnabled (false);
 
 		if (!(mode_flags & RKProgressControl::OutputShownByDefault)) {

Modified: branches/KDE4_port/rkward/misc/rkspinbox.cpp
===================================================================
--- branches/KDE4_port/rkward/misc/rkspinbox.cpp	2007-10-14 21:12:41 UTC (rev 2066)
+++ branches/KDE4_port/rkward/misc/rkspinbox.cpp	2007-10-14 22:55:23 UTC (rev 2067)
@@ -20,6 +20,7 @@
 #include <qlineedit.h>
 
 #include <math.h>
+#include <limits.h>
 #include <stdlib.h>
 
 #include "../debug.h"
@@ -29,6 +30,11 @@
 	mode = Integer;
 	updating = updating_b = false;
 	real_value = 0;
+	int_value = 0;
+	int_min = INT_MIN;
+	int_max = INT_MAX;
+
+	connect (this, SIGNAL (valueChanged(int)), this, SLOT(updateValue(int)));
 }
 
 RKSpinBox::~RKSpinBox () {
@@ -38,31 +44,53 @@
 void RKSpinBox::setRealValue (double new_value) {
 	real_value = new_value;
 	setValue (0);
-};
+}
 
-void RKSpinBox::interpretText () {
-	if (updating) return;
-	updating = true;
+void RKSpinBox::setIntValue (int new_value) {
+	int_value = new_value;
+	setValue (0);
+}
 
+
+QString RKSpinBox::textFromValue (int) const {
 	if (mode == Real) {
+		return (QString ().setNum (real_value));
+	} else {
+		return (QString ().setNum (int_value));
+	}
+}
+
+int RKSpinBox::valueFromText (const QString & text) const {
+	if (mode == Real) {
 		bool ok;
-		double new_value = text ().toFloat (&ok);
-		if (ok) real_value = new_value;
-		valueChange ();
+		double new_value = text.toFloat (&ok);
+		if (ok) {
+			double *cheat = const_cast<double*> (&real_value);
+			*cheat = new_value;
+		}
+		return 0;
 	} else {
-		QSpinBox::interpretText ();
+		bool ok;
+		int new_value = text.toInt (&ok);
+		if (ok) {
+			int *cheat = const_cast<int*> (&int_value);
+			*cheat = new_value;
+		}
+		return 0;
 	}
+}
 
-	updating = false;
+void RKSpinBox::stepBy (int steps) {
+	setValue (steps);
 }
 
-void RKSpinBox::updateDisplay () {
-	if (updating_b) return;
-	updating_b = true;
+QValidator::State RKSpinBox::validate (QString &input, int &pos ) const {
+	return (validator->validate (input, pos));
+}
 
+void RKSpinBox::updateValue (int change) {
 	if (mode == Real) {
-		if (value () != 0) {
-			int change = value ();
+		if (change != 0) {
 			setValue (0);
 
 			int power;
@@ -79,22 +107,22 @@
 			if (real_value > real_max) real_value = real_max;
 			if (real_value < real_min) real_value = real_min;
 		}
-		setUpdatesEnabled (false);
-		QSpinBox::updateDisplay ();	// need this to enable/disable the button correctly
-		editor ()->setText (QString ().setNum (real_value));
-		setUpdatesEnabled (true);
 	} else {
-		QSpinBox::updateDisplay ();
+		if (change != 0) {
+			setValue (0);
 
-		int power;
-		if (value () != 0) power = (int) log10 (abs (value ()));
-		else power = 1;
-		int step = (int) pow (10, power-1);
-		if (step < 1) step = 1;
-		setSteps (step, 10*step);
+			int power;
+			if (int_value != 0) {
+				power = (int) log10 (abs (int_value));
+			} else {
+				power = -default_precision;
+			}
+			int step = (int) pow (10, power-1);
+			if (step < 1) step = 1;
+
+			int_value += change * step;
+		}
 	}
-
-	updating_b = false;
 }
 
 void RKSpinBox::setRealMode (double min, double max, double initial, int default_precision, int max_precision) {
@@ -102,7 +130,6 @@
 
 	mode = Real;
 	QValidator *new_validator = new QDoubleValidator (min, max, max_precision, this);
-	setValidator (new_validator);
 	delete validator;
 	validator = new_validator;
 
@@ -112,7 +139,7 @@
 		3) goto 1 */
 	setMinValue (-1000);
 	setMaxValue (1000);
-	setSteps (1, 10);
+	setSingleStep (1);
 
 	real_value = initial;
 	real_min = min;
@@ -125,16 +152,21 @@
 void RKSpinBox::setIntMode (int min, int max, int initial) {
 	QValidator *new_validator = new QIntValidator (min, max, this);
 
-	setMinValue (min);
-	setMaxValue (max);
-	setValue (initial);
+	/* see setRealMode for comments */
 
-	setValidator (new_validator);
+	setMinValue (-1000);
+	setMaxValue (1000);
+	setSingleStep (1);
+
+	int_min = min;
+	int_max = max;
+	int_value = initial;
+
 	delete validator;
 	validator = new_validator;
 	mode = Integer;
 
-	updateDisplay ();
+	setValue (0);
 }
 
 #include "rkspinbox.moc"

Modified: branches/KDE4_port/rkward/misc/rkspinbox.h
===================================================================
--- branches/KDE4_port/rkward/misc/rkspinbox.h	2007-10-14 21:12:41 UTC (rev 2066)
+++ branches/KDE4_port/rkward/misc/rkspinbox.h	2007-10-14 22:55:23 UTC (rev 2067)
@@ -17,7 +17,7 @@
 #ifndef RKSPINBOX_H
 #define RKSPINBOX_H
 
-#include <qspinbox.h>
+#include <QSpinBox>
 #include <qstring.h>
 
 class QValidator;
@@ -51,14 +51,25 @@
 /** Only meaningful, when in real mode! Returns the current value
 @returns the value if in real mode */
 	double realValue () { return real_value; };
+/** Only meaningful, when in int mode! Returns the current value
+ at returns the value if in int mode */
+	int intValue () { return int_value; };
 /** Only meaningful, when in real mode! Sets the new value
 @param new_value the new value */
 	void setRealValue (double new_value);
+/** Only meaningful, when in int mode! Sets the new value
+ at param new_value the new value */
+	void setIntValue (int int_value);
 protected:
-/** reimplemented from QSpinBox to update steps and value whenever the internal value changed */
-	void updateDisplay ();
-/** reimplemented from QSpinBox to update steps and value whenever the text was changed */
-	void interpretText ();
+/** reimplemented from QSpinBox to always return the text suitable for the *internal* value. The value given as parameter is ignored. */
+	QString textFromValue (int) const;
+/** reimplemented from QSpinBox to update steps and value whenever the text was changed. WARNING: not really const */
+	int valueFromText (const QString & text) const;
+/** reimplemented from QSpinBox to adjust the internal value */
+	void stepBy (int steps);
+	QValidator::State validate (QString &input, int &pos ) const;
+private slots:
+	void updateValue (int value);
 private:
 	enum Mode { Integer=0, Real=1 };
 	Mode mode;
@@ -67,6 +78,9 @@
 	double real_value;
 	double real_min;
 	double real_max;
+	int int_value;
+	int int_min;
+	int int_max;
 	int default_precision;
 	QValidator *validator;
 };

Modified: branches/KDE4_port/rkward/misc/xmlhelper.cpp
===================================================================
--- branches/KDE4_port/rkward/misc/xmlhelper.cpp	2007-10-14 21:12:41 UTC (rev 2066)
+++ branches/KDE4_port/rkward/misc/xmlhelper.cpp	2007-10-14 22:55:23 UTC (rev 2067)
@@ -330,7 +330,7 @@
 
 		backtrace += list.join ("->");
 
-		RK_DO (qDebug ("%s: %s", backtrace.toLatin1 (), message.toLatin1 ()), XML, message_level);
+		RK_DO (qDebug ("%s: %s", backtrace.toLatin1 ().data (), message.toLatin1 ().data ()), XML, message_level);
 	}
 }
 

Modified: branches/KDE4_port/rkward/plugin/rkpluginspinbox.cpp
===================================================================
--- branches/KDE4_port/rkward/plugin/rkpluginspinbox.cpp	2007-10-14 21:12:41 UTC (rev 2066)
+++ branches/KDE4_port/rkward/plugin/rkpluginspinbox.cpp	2007-10-14 22:55:23 UTC (rev 2067)
@@ -106,7 +106,7 @@
 
 	// update GUI
 	if (intmode) {
-		spinbox->setValue (intvalue->intValue ());
+		spinbox->setIntValue (intvalue->intValue ());
 	} else {
 		spinbox->setRealValue (realvalue->doubleValue ());
 	}
@@ -118,7 +118,7 @@
 	RK_TRACE (PLUGIN);
 
 	if (intmode) {
-		intvalue->setIntValue (spinbox->value ());
+		intvalue->setIntValue (spinbox->intValue ());
 	} else {
 		// this may be ugly, but we have to set via text to make sure we get the exact same display
 		realvalue->setValue (spinbox->text ());

Modified: branches/KDE4_port/rkward/settings/rksettingsmodulegeneral.cpp
===================================================================
--- branches/KDE4_port/rkward/settings/rksettingsmodulegeneral.cpp	2007-10-14 21:12:41 UTC (rev 2066)
+++ branches/KDE4_port/rkward/settings/rksettingsmodulegeneral.cpp	2007-10-14 22:55:23 UTC (rev 2067)
@@ -136,7 +136,7 @@
 #else
 	workplace_save_mode = static_cast<WorkplaceSaveMode> (workplace_save_chooser->selectedId ());
 #endif
-	warn_size_object_edit = warn_size_object_edit_box->value ();
+	warn_size_object_edit = warn_size_object_edit_box->intValue ();
 }
 
 void RKSettingsModuleGeneral::save (KConfig *config) {

Modified: branches/KDE4_port/rkward/settings/rksettingsmoduleplugins.cpp
===================================================================
--- branches/KDE4_port/rkward/settings/rksettingsmoduleplugins.cpp	2007-10-14 21:12:41 UTC (rev 2066)
+++ branches/KDE4_port/rkward/settings/rksettingsmoduleplugins.cpp	2007-10-14 22:55:23 UTC (rev 2067)
@@ -120,7 +120,7 @@
 	interface_pref = static_cast<PluginPrefs> (button_group->selectedId ());
 #endif
 	show_code = show_code_box->isChecked ();
-	code_size = code_size_box->value ();
+	code_size = code_size_box->intValue ();
 
 	RKWardMainWindow::getMain ()->initPlugins();
 }


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