[rkward-cvs] SF.net SVN: rkward: [1294] trunk/rkward/rkward/dialogs

tfry at users.sourceforge.net tfry at users.sourceforge.net
Fri Feb 2 13:57:35 UTC 2007


Revision: 1294
          http://svn.sourceforge.net/rkward/?rev=1294&view=rev
Author:   tfry
Date:     2007-02-02 05:57:34 -0800 (Fri, 02 Feb 2007)

Log Message:
-----------
KFileDialog "designed to allow [...] subclassing"? I don't think so...

Modified Paths:
--------------
    trunk/rkward/rkward/dialogs/rkimportdialog.cpp
    trunk/rkward/rkward/dialogs/rkimportdialog.h

Modified: trunk/rkward/rkward/dialogs/rkimportdialog.cpp
===================================================================
--- trunk/rkward/rkward/dialogs/rkimportdialog.cpp	2007-02-02 11:09:12 UTC (rev 1293)
+++ trunk/rkward/rkward/dialogs/rkimportdialog.cpp	2007-02-02 13:57:34 UTC (rev 1294)
@@ -30,9 +30,16 @@
 
 #include "../debug.h"
 
-RKImportDialog::RKImportDialog (const QString &context_id, QWidget *parent) : KFileDialog (QString::null, QString::null, parent, 0, false) {
+RKImportDialogFormatSelector::RKImportDialogFormatSelector () {
 	RK_TRACE (DIALOGS);
 
+	new QLabel (i18n ("File format: "), this);
+	combo = new QComboBox (this);
+}
+
+RKImportDialog::RKImportDialog (const QString &context_id, QWidget *parent) : KFileDialog (QString::null, QString::null, parent, 0, false, format_selector=new RKImportDialogFormatSelector ()) {
+	RK_TRACE (DIALOGS);
+
 	context = RKComponentMap::getContext (context_id);
 	if (!context) {
 		KMessageBox::sorry (this, i18n ("No plugins defined for context '%1'").arg (context_id));
@@ -59,14 +66,11 @@
 	}
 
 	// file format selection box
-	format_selection_box = new QHBox ();
-	new QLabel (i18n ("File format: "), format_selection_box);
-	format_combo = new QComboBox (format_selection_box);
-	format_combo->insertStringList (format_labels);
+	format_selector->combo->insertStringList (format_labels);
 
 	// initialize
 	setMode (KFile::File | KFile::ExistingOnly | KFile::LocalOnly);
-	init (QString::null, formats, format_selection_box);
+	setFilter (formats);
 	connect (filterWidget, SIGNAL (filterChanged ()), this, SLOT (filterChanged ()));
 	filterChanged ();
 	show ();
@@ -82,10 +86,10 @@
 	int index = filters.findIndex (filterWidget->currentFilter ());
 
 	if (index < 0) {		// All files
-		format_combo->setEnabled (true);
+		format_selector->combo->setEnabled (true);
 	} else {
-		format_combo->setEnabled (false);
-		format_combo->setCurrentItem (index);
+		format_selector->combo->setEnabled (false);
+		format_selector->combo->setCurrentItem (index);
 	}
 }
 
@@ -94,7 +98,7 @@
 
 	KFileDialog::accept ();
 
-	int index = format_combo->currentItem ();
+	int index = format_selector->combo->currentItem ();
 	QString cid = component_ids[index];
 	RKComponentHandle *handle = RKComponentMap::getComponentHandle (cid);
 	RKContextHandler *chandler = context->makeContextHandler (this, false);

Modified: trunk/rkward/rkward/dialogs/rkimportdialog.h
===================================================================
--- trunk/rkward/rkward/dialogs/rkimportdialog.h	2007-02-02 11:09:12 UTC (rev 1293)
+++ trunk/rkward/rkward/dialogs/rkimportdialog.h	2007-02-02 13:57:34 UTC (rev 1294)
@@ -21,10 +21,11 @@
 #include <kfiledialog.h>
 
 #include <qstringlist.h>
+#include <qhbox.h>
 
-class QHBox;
 class QComboBox;
 class RKContextMap;
+class RKImportDialogFormatSelector;
 
 class RKImportDialog : public KFileDialog {
 	Q_OBJECT
@@ -38,12 +39,20 @@
 	void reject ();
 private:
 	int format_count;
-	QHBox *format_selection_box;
-	QComboBox *format_combo;
+	RKImportDialogFormatSelector *format_selector;
 	QStringList format_labels;
 	QStringList filters;
 	QStringList component_ids;
 	RKContextMap *context;
 };
 
+class RKImportDialogFormatSelector : public QHBox {
+friend class RKImportDialog;
+private:
+	RKImportDialogFormatSelector ();
+	~RKImportDialogFormatSelector () {};
+
+	QComboBox *combo;
+};
+
 #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