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

tfry at users.sourceforge.net tfry at users.sourceforge.net
Wed Oct 31 13:51:56 UTC 2007


Revision: 2153
          http://rkward.svn.sourceforge.net/rkward/?rev=2153&view=rev
Author:   tfry
Date:     2007-10-31 06:51:56 -0700 (Wed, 31 Oct 2007)

Log Message:
-----------
Make enabling / disabling single items in a dropdown work

Modified Paths:
--------------
    branches/KDE4_port/TODO_KDE4
    branches/KDE4_port/rkward/core/robjectlist.cpp
    branches/KDE4_port/rkward/plugin/rkdropdown.cpp
    branches/KDE4_port/rkward/plugin/rkdropdown.h

Modified: branches/KDE4_port/TODO_KDE4
===================================================================
--- branches/KDE4_port/TODO_KDE4	2007-10-30 16:40:56 UTC (rev 2152)
+++ branches/KDE4_port/TODO_KDE4	2007-10-31 13:51:56 UTC (rev 2153)
@@ -76,9 +76,6 @@
 rkradio:
 	- does disabling single options work (in plugins)?
 
-rkdropdown:
-	- take care of enabling / disabling single options!
-
 rksettings:
 	- check wether settings seem to be saved / loaded correctly
 	- are the defaults ok?

Modified: branches/KDE4_port/rkward/core/robjectlist.cpp
===================================================================
--- branches/KDE4_port/rkward/core/robjectlist.cpp	2007-10-30 16:40:56 UTC (rev 2152)
+++ branches/KDE4_port/rkward/core/robjectlist.cpp	2007-10-31 13:51:56 UTC (rev 2153)
@@ -16,7 +16,6 @@
  ***************************************************************************/
 #include "robjectlist.h"
 
-#define AUTO_UPDATE_INTERVAL 10000
 #define UPDATE_DELAY_INTERVAL 500
 
 #define ROBJECTLIST_UDPATE_ENVIRONMENTS_COMMAND 1
@@ -24,8 +23,6 @@
 
 #include <qtimer.h>
 #include <qstringlist.h>
-//Added by qt3to4:
-#include <Q3ValueList>
 
 #include <klocale.h>
 

Modified: branches/KDE4_port/rkward/plugin/rkdropdown.cpp
===================================================================
--- branches/KDE4_port/rkward/plugin/rkdropdown.cpp	2007-10-30 16:40:56 UTC (rev 2152)
+++ branches/KDE4_port/rkward/plugin/rkdropdown.cpp	2007-10-31 13:51:56 UTC (rev 2153)
@@ -21,8 +21,7 @@
 #include <qlabel.h>
 #include <qlayout.h>
 #include <qcombobox.h>
-//Added by qt3to4:
-#include <Q3VBoxLayout>
+#include <QListWidget>
 
 #include <klocale.h>
 
@@ -37,13 +36,17 @@
 	XMLHelper *xml = XMLHelper::getStaticHelper ();
 
 	// create layout
-	Q3VBoxLayout *vbox = new Q3VBoxLayout (this, RKGlobals::spacingHint ());
+	QVBoxLayout *vbox = new QVBoxLayout (this);
+	vbox->setContentsMargins (0, 0, 0, 0);
 
 	QLabel *label = new QLabel (xml->getStringAttribute (element, "label", i18n ("Select one:"), DL_INFO), this);
 	vbox->addWidget (label);
 
 	// create ComboBox
 	box = new QComboBox (false, this);
+	listwidget = new QListWidget (box);
+	box->setModel (listwidget->model ());
+	box->setView (listwidget);
 
 	addOptionsAndInit (element);
 
@@ -58,49 +61,30 @@
 void RKDropDown::comboItemActivated (int id) {
 	RK_TRACE (PLUGIN);
 
-//KDE4: TODO!!!
-	// make sure only selectable items get selected
-
 	itemSelected (id);
 }
 
 void RKDropDown::setItemInGUI (int id) {
 	RK_TRACE (PLUGIN);
 
-	box->setCurrentItem (id);
+	box->setCurrentIndex (id);
 }
 
 void RKDropDown::addOptionToGUI (const QString &label, int id) {
 	RK_TRACE (PLUGIN);
 
-	box->insertItem (label, id);
+	box->insertItem (id, label);
 }
 
 void RKDropDown::setItemEnabledInGUI (int id, bool enabled) {
 	RK_TRACE (PLUGIN);
 
-//	QModelIndex offset = box->model ()->createIndex (id, box->modelColumn ());
-
-//KDE4 TODO: enable/disable item
-//	item->setSelectable (enabled);
+	QListWidgetItem* item = listwidget->item (id);
+	RK_ASSERT (item);
+	int flags = item->flags ();
+	if (enabled) flags |= Qt::ItemIsEnabled | Qt::ItemIsSelectable;
+	else flags -= flags & (Qt::ItemIsEnabled | Qt::ItemIsSelectable);
+	item->setFlags ((Qt::ItemFlags) flags);
 }
 
-/*
-////////////////// RKDropDownListItem ////////////////////////
-
-#include <qpainter.h>
-
-RKDropDownListItem::RKDropDownListItem (Q3ListBox *listbox, const QString &text) : Q3ListBoxText (listbox, text) {
-	RK_TRACE (PLUGIN);
-}
-
-void RKDropDownListItem::paint (QPainter *painter) {
-	// no trace!
-	if (!isSelectable ()) {
-		painter->setPen (QColor (150, 150, 150));
-	}
-
-	Q3ListBoxText::paint (painter);
-}*/
-
 #include "rkdropdown.moc"

Modified: branches/KDE4_port/rkward/plugin/rkdropdown.h
===================================================================
--- branches/KDE4_port/rkward/plugin/rkdropdown.h	2007-10-30 16:40:56 UTC (rev 2152)
+++ branches/KDE4_port/rkward/plugin/rkdropdown.h	2007-10-31 13:51:56 UTC (rev 2153)
@@ -21,6 +21,7 @@
 #include "rkabstractoptionselector.h"
 
 class QComboBox;
+class QListWidget;
 
 /** This RKPluginWidget provides a drop down list of options for use in plugins
 @author Thomas Friedrichsmeier
@@ -40,6 +41,7 @@
 	void setItemEnabledInGUI (int id, bool enabled);
 private:
 	QComboBox *box;
+	QListWidget *listwidget;
 };
 
 #endif


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