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

tfry at users.sourceforge.net tfry at users.sourceforge.net
Tue Oct 23 15:25:09 UTC 2007


Revision: 2117
          http://rkward.svn.sourceforge.net/rkward/?rev=2117&view=rev
Author:   tfry
Date:     2007-10-23 08:25:09 -0700 (Tue, 23 Oct 2007)

Log Message:
-----------
Some work on the filebrowser
* make opening files work
* better focus handling
* allow completion popup to be wider than the filebrowser widget itself

Modified Paths:
--------------
    branches/KDE4_port/rkward/windows/rkfilebrowser.cpp
    branches/KDE4_port/rkward/windows/rkfilebrowser.h

Modified: branches/KDE4_port/rkward/windows/rkfilebrowser.cpp
===================================================================
--- branches/KDE4_port/rkward/windows/rkfilebrowser.cpp	2007-10-23 13:28:12 UTC (rev 2116)
+++ branches/KDE4_port/rkward/windows/rkfilebrowser.cpp	2007-10-23 15:25:09 UTC (rev 2117)
@@ -20,16 +20,16 @@
 #include <kdiroperator.h>
 #include <kurlcombobox.h>
 #include <kurlcompletion.h>
+#include <kcompletionbox.h>
 #include <ktoolbar.h>
 #include <krun.h>
 #include <kactioncollection.h>
 
 #include <qdir.h>
 #include <qlayout.h>
-#include <q3vbox.h>
-//Added by qt3to4:
 #include <QEvent>
 #include <QVBoxLayout>
+#include <QScrollBar>
 
 #include "rkworkplace.h"
 #include "../rkward.h"
@@ -49,7 +49,7 @@
 	layout->setContentsMargins (0, 0, 0, 0);
 	layout_widget = new KVBox (this);
 	layout->addWidget (layout_widget);
-	layout_widget->setFocusPolicy (Qt::StrongFocus);
+	setFocusPolicy (Qt::StrongFocus);
 
 	RKDummyPart *part = new RKDummyPart (this, layout_widget);
 	setPart (part);
@@ -69,7 +69,7 @@
 		RK_DO (qDebug ("creating file browser"), APP, DL_INFO);
 
 		real_widget = new RKFileBrowserWidget (layout_widget);
-		layout_widget->setFocusProxy (real_widget);
+		setFocusProxy (real_widget);
 	}
 
 	RKMDIWindow::showEvent (e);
@@ -79,8 +79,8 @@
 	RK_TRACE (APP);
 }
 
+/////////////////// RKFileBrowserWidget ////////////////////
 
-
 RKFileBrowserWidget::RKFileBrowserWidget (QWidget *parent) : KVBox (parent) {
 	RK_TRACE (APP);
 
@@ -93,7 +93,8 @@
 	urlbox->setCompletionObject (cmpl);
 	urlbox->setAutoDeleteCompletionObject (true);
 	urlbox->setSizePolicy (QSizePolicy (QSizePolicy::Expanding, QSizePolicy::Fixed));
-// KDE4: do we need this (see eventFilter(), below)	urlbox->listBox ()->installEventFilter (this);
+	urlbox->completionBox (true)->installEventFilter (this);
+	setFocusProxy (urlbox);
 
 	dir = new KDirOperator (KUrl (), this);
 	dir->setView(KFile::Simple);
@@ -110,7 +111,7 @@
 	connect (urlbox, SIGNAL (returnPressed (const QString &)), this, SLOT (urlChangedInCombo (const QString &)));
 	connect (urlbox, SIGNAL (urlActivated (const KUrl&)), this, SLOT (urlChangedInCombo (const KUrl&)));
 
-	connect (dir, SIGNAL (fileSelected (const KFileItem*)), this, SLOT (fileActivated (const KFileItem*)));
+	connect (dir, SIGNAL (fileSelected (const KFileItem&)), this, SLOT (fileActivated (const KFileItem&)));
 
 	setURL (QDir::currentPath ());
 }
@@ -144,36 +145,40 @@
 	dir->setUrl (url, true);
 }
 
-bool RKFileBrowserWidget::eventFilter (QObject *watched, QEvent *e) {
-	// don't trace
-/* KDE4: do we still need this?
-	// fix size of popup (copied from katefileselector.cpp)
-	Q3ListBox *lb = urlbox->listBox ();
-	if (watched == lb && e->type() == QEvent::Show) {
-		int add = lb->height() < lb->contentsHeight() ? lb->verticalScrollBar()->width() : 0;
-		int w = qMin (topLevelWidget ()->width(), lb->contentsWidth() + add);
-		lb->resize (w, lb->height());
-	} */
-	return QWidget::eventFilter (watched, e);
+bool RKFileBrowserWidget::eventFilter (QObject* o, QEvent* e) {
+	// don't trace here
+
+	if (o == urlbox->completionBox () && e->type () == QEvent::Resize) {
+		RK_TRACE (APP);
+		// this hack (originally from a KDE 3 version of kate allows the completion popup to span beyond the border of the filebrowser widget itself
+
+		KCompletionBox* box = urlbox->completionBox ();
+		RK_ASSERT (box);
+
+		int add = box->verticalScrollBar ()->isVisible () ? box->verticalScrollBar ()->width () : 0;
+		box->setMinimumWidth (qMin (topLevelWidget ()->width (), box->sizeHintForColumn (0) + add));
+
+		return false;
+	}
+
+	return (KVBox::eventFilter (o, e));
 }
 
-void RKFileBrowserWidget::fileActivated (const KFileItem *item) {
+void RKFileBrowserWidget::fileActivated (const KFileItem& item) {
 	RK_TRACE (APP);
 
-	RK_ASSERT (item);
-
-	QString mimetype = item->mimetype ();
+	QString mimetype = item.mimetype ();
 	if (mimetype.startsWith ("text/")) {
 		if (mimetype == "text/html") {
-			RKWorkplace::mainWorkplace ()->openHelpWindow (item->url (), true);
+			RKWorkplace::mainWorkplace ()->openHelpWindow (item.url (), true);
 		} else {
-			RKWorkplace::mainWorkplace ()->openScriptEditor (item->url ());
+			RKWorkplace::mainWorkplace ()->openScriptEditor (item.url ());
 		}
 	} else {
-		if (item->name (true).endsWith (".rdata")) {
-			RKWardMainWindow::getMain ()->fileOpenAskSave (item->url ());
+		if (item.name (true).endsWith (".rdata")) {
+			RKWardMainWindow::getMain ()->fileOpenAskSave (item.url ());
 		} else {
-			new KRun (item->url (), topLevelWidget(), item->mode (), item->isLocalFile ());
+			new KRun (item.url (), topLevelWidget(), item.mode (), item.isLocalFile ());
 		}
 	}
 }

Modified: branches/KDE4_port/rkward/windows/rkfilebrowser.h
===================================================================
--- branches/KDE4_port/rkward/windows/rkfilebrowser.h	2007-10-23 13:28:12 UTC (rev 2116)
+++ branches/KDE4_port/rkward/windows/rkfilebrowser.h	2007-10-23 15:25:09 UTC (rev 2117)
@@ -55,13 +55,13 @@
 	RKFileBrowserWidget (QWidget *widget);
 	~RKFileBrowserWidget ();
 
-	bool eventFilter (QObject *watched, QEvent *e);
 	void setURL (const QString &url);
+	bool eventFilter (QObject* o, QEvent* e);
 public slots:
 	void urlChangedInView (const KUrl &url);
 	void urlChangedInCombo (const QString &url);
 	void urlChangedInCombo (const KUrl &url);
-	void fileActivated (const KFileItem *item);
+	void fileActivated (const KFileItem& item);
 private:
 	KDirOperator *dir;
 	KUrlComboBox *urlbox;


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