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

tfry at users.sourceforge.net tfry at users.sourceforge.net
Sun Oct 14 17:32:36 UTC 2007


Revision: 2059
          http://rkward.svn.sourceforge.net/rkward/?rev=2059&view=rev
Author:   tfry
Date:     2007-10-14 10:32:35 -0700 (Sun, 14 Oct 2007)

Log Message:
-----------
rkloadlibsdialog compiles

Modified Paths:
--------------
    branches/KDE4_port/TODO_KDE4
    branches/KDE4_port/rkward/dialogs/rkloadlibsdialog.cpp
    branches/KDE4_port/rkward/dialogs/rkloadlibsdialog.h

Modified: branches/KDE4_port/TODO_KDE4
===================================================================
--- branches/KDE4_port/TODO_KDE4	2007-10-14 16:54:39 UTC (rev 2058)
+++ branches/KDE4_port/TODO_KDE4	2007-10-14 17:32:35 UTC (rev 2059)
@@ -50,3 +50,5 @@
 	- does it work?
 	- does the completion popup show up in a correct size?
 
+rkloadlibsdialog:
+	- does it work?

Modified: branches/KDE4_port/rkward/dialogs/rkloadlibsdialog.cpp
===================================================================
--- branches/KDE4_port/rkward/dialogs/rkloadlibsdialog.cpp	2007-10-14 16:54:39 UTC (rev 2058)
+++ branches/KDE4_port/rkward/dialogs/rkloadlibsdialog.cpp	2007-10-14 17:32:35 UTC (rev 2059)
@@ -25,6 +25,7 @@
 #include <qdir.h>
 #include <qregexp.h>
 #include <qtimer.h>
+#include <qtextstream.h>
 //Added by qt3to4:
 #include <Q3HBoxLayout>
 #include <Q3CString>
@@ -35,6 +36,7 @@
 #include <klocale.h>
 #include <k3process.h>
 #include <kmessagebox.h>
+#include <kvbox.h>
 
 #include "../rkglobals.h"
 #include "../rbackend/rinterface.h"
@@ -56,37 +58,41 @@
 
 #define GET_CURRENT_LIBLOCS_COMMAND 1
 
-RKLoadLibsDialog::RKLoadLibsDialog (QWidget *parent, RCommandChain *chain, bool modal) : KDialogBase (KDialogBase::Tabbed, Qt::WStyle_DialogBorder, parent, 0, modal, i18n ("Configure Packages"), KDialogBase::Ok | KDialogBase::Apply | KDialogBase::Cancel | KDialogBase::User1) {
+RKLoadLibsDialog::RKLoadLibsDialog (QWidget *parent, RCommandChain *chain, bool modal) : KPageDialog (parent) {
 	RK_TRACE (DIALOGS);
 	RKLoadLibsDialog::chain = chain;
-	
-	QFrame *page = addPage (i18n ("Local packages"));
-	Q3VBoxLayout *layout = new Q3VBoxLayout (page, 0, KDialog::spacingHint ());
+
+	setFaceType (KPageDialog::Tabbed);
+	setModal (modal);
+	setCaption (i18n ("Configure Packages"));
+	setButtons (KDialog::Ok | KDialog::Apply | KDialog::Cancel | KDialog::User1);
+
+	KVBox *page = new KVBox ();
+	addPage (page, i18n ("Local packages"));
 	LoadUnloadWidget *luwidget = new LoadUnloadWidget (this, page);
 	connect (this, SIGNAL (installedPackagesChanged ()), luwidget, SLOT (updateInstalledPackages ()));
-	layout->addWidget (luwidget);
 	
-	page = addPage (i18n ("Update"));
-	layout = new Q3VBoxLayout (page, 0, KDialog::spacingHint ());
-	layout->addWidget (new UpdatePackagesWidget (this, page));
+	page = new KVBox ();
+	addPage (page, i18n ("Update"));
+	new UpdatePackagesWidget (this, page);
 
-	page = addPage (i18n ("Install"));
-	layout = new Q3VBoxLayout (page, 0, KDialog::spacingHint ());
-	layout->addWidget (install_packages_widget = new InstallPackagesWidget (this, page));
+	page = new KVBox ();
+	install_packages_pageitem = addPage (page, i18n ("Install"));
+	install_packages_widget = new InstallPackagesWidget (this, page);
 
-	setButtonText (KDialogBase::User1, i18n ("Configure Repositories"));
+	setButtonText (KDialog::User1, i18n ("Configure Repositories"));
 
 	num_child_widgets = 3;
 	accepted = false;
 
-	RKGlobals::rInterface ()->issueCommand (".libPaths ()", RCommand::App | RCommand::GetStringVector, QString::null, this, GET_CURRENT_LIBLOCS_COMMAND, chain);
+	RKGlobals::rInterface ()->issueCommand (".libPaths ()", RCommand::App | RCommand::GetStringVector, QString (), this, GET_CURRENT_LIBLOCS_COMMAND, chain);
 }
 
 RKLoadLibsDialog::~RKLoadLibsDialog () {
 	RK_TRACE (DIALOGS);
 
-	if (accepted) accept ();
-	else reject ();
+	if (accepted) KPageDialog::accept ();
+	else KPageDialog::reject ();
 }
 
 //static
@@ -96,7 +102,7 @@
 	RKLoadLibsDialog *dialog = new RKLoadLibsDialog (parent, chain, true);
 	dialog->auto_install_package = package_name;
 	QTimer::singleShot (0, dialog, SLOT (automatedInstall ()));		// to get past the dialog->exec, below
-	dialog->showPage (2);
+	dialog->setCurrentPage (dialog->install_packages_pageitem);
 	dialog->exec ();
 	RK_TRACE (DIALOGS);
 }
@@ -122,38 +128,35 @@
 	tryDestruct ();
 }
 
-void RKLoadLibsDialog::slotOk () {
+void RKLoadLibsDialog::slotButtonClicked (int button) {
 	RK_TRACE (DIALOGS);
 
-	accepted = true;
-	hide ();
-	emit (okClicked ());
+	switch (button) {
+	case KDialog::Ok:
+		accepted = true;
+		hide ();
+		emit (okClicked ()); // will self-destruct via childDeleted ()
+		break;
+	case KDialog::Cancel:
+		accepted = false;
+		hide ();
+		emit (cancelClicked ()); // will self-destruct via childDeleted ()
+		break;
+	case KDialog::Apply:
+		emit (applyClicked ());
+		break;
+	case KDialog::User1:
+		RKSettings::configureSettings (RKSettings::RPackages, this, chain);
+		break;
+	}
 }
 
-void RKLoadLibsDialog::slotApply () {
-	RK_TRACE (DIALOGS);
-
-	emit (apply ());
-}
-
-void RKLoadLibsDialog::slotCancel () {
-	RK_TRACE (DIALOGS);
-	
-	accepted = false;
-	hide ();
-	emit (cancelClicked ()); // will self-destruct via childDeleted ()
-}
-
-void RKLoadLibsDialog::slotUser1 () {
-	RK_TRACE (DIALOGS);
-
-	RKSettings::configureSettings (RKSettings::RPackages, this, chain);
-}
-
 void RKLoadLibsDialog::closeEvent (QCloseEvent *e) {
 	RK_TRACE (DIALOGS);
 	e->accept ();
-	slotCancel ();
+
+	// do as if cancel button was clicked:
+	slotButtonClicked (KDialog::Cancel);
 }
 
 void RKLoadLibsDialog::rCommandDone (RCommand *command) {
@@ -187,7 +190,7 @@
 	QFile file (dir.filePath ("install_script.R"));
 // WORKADOUND END
 	if (file.open (QIODevice::WriteOnly)) {
-		Q3TextStream stream (&file);
+		QTextStream stream (&file);
 		stream << "options (repos=" + repos_string + ")\n" + command_string;
 		if (as_root) {
 #ifdef __FreeBSD__
@@ -288,7 +291,7 @@
 	loadedvbox->addWidget (loaded_view);
 
 	connect (dialog, SIGNAL (okClicked ()), this, SLOT (ok ()));
-	connect (dialog, SIGNAL (apply ()), this, SLOT (apply ()));
+	connect (dialog, SIGNAL (applyClicked ()), this, SLOT (apply ()));
 	connect (dialog, SIGNAL (cancelClicked ()), this, SLOT (cancel ()));
 	connect (this, SIGNAL (destroyed ()), dialog, SLOT (childDeleted ()));
 

Modified: branches/KDE4_port/rkward/dialogs/rkloadlibsdialog.h
===================================================================
--- branches/KDE4_port/rkward/dialogs/rkloadlibsdialog.h	2007-10-14 16:54:39 UTC (rev 2058)
+++ branches/KDE4_port/rkward/dialogs/rkloadlibsdialog.h	2007-10-14 17:32:35 UTC (rev 2059)
@@ -17,7 +17,7 @@
 #ifndef RKLOADLIBSDIALOG_H
 #define RKLOADLIBSDIALOG_H
 
-#include <kdialogbase.h>
+#include <kpagedialog.h>
 
 #include <qstringlist.h>
 //Added by qt3to4:
@@ -27,6 +27,7 @@
 #include "../rbackend/rcommandreceiver.h"
 
 class Q3ListView;
+class Q3ListViewItem;
 class QComboBox;
 class QPushButton;
 class RKProgressControl;
@@ -41,12 +42,14 @@
 /**
 Dialog which excapsulates widgets to load/unload, update and install R packages
 
+TODO: The logic of passing on the button presses (ok, cancel, etc.) is rather surprising and a bit confusing. This should be made more straight-forward.
+
 @author Thomas Friedrichsmeier
 */
 
 // TODO: add a static member to create (single) instance of the dialog
 
-class RKLoadLibsDialog : public KDialogBase, public RCommandReceiver {
+class RKLoadLibsDialog : public KPageDialog, public RCommandReceiver {
 Q_OBJECT
 public:
 	RKLoadLibsDialog (QWidget *parent, RCommandChain *chain, bool modal=false);
@@ -71,11 +74,8 @@
 	void rCommandDone (RCommand *command);
 	void closeEvent (QCloseEvent *e);
 protected slots:
-	void slotOk ();
-	void slotApply ();
-	void slotCancel ();
-/** User1-button was clicked, i.e.: "Configure Repositories" */
-	void slotUser1 ();
+/** overloaded to catch button presses. */
+	void slotButtonClicked (int button);
 	void childDeleted ();
 	void processExited (K3Process *);
 	void installationProcessOutput (K3Process *proc, char *buffer, int buflen);
@@ -89,6 +89,7 @@
 	RCommandChain *chain;
 
 	InstallPackagesWidget *install_packages_widget;	// needed for automated installation
+	KPageWidgetItem *install_packages_pageitem;
 
 	QString auto_install_package;
 	int num_child_widgets;


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