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

tfry at users.sourceforge.net tfry at users.sourceforge.net
Mon Oct 8 18:03:25 UTC 2007


Revision: 2043
          http://rkward.svn.sourceforge.net/rkward/?rev=2043&view=rev
Author:   tfry
Date:     2007-10-08 11:03:25 -0700 (Mon, 08 Oct 2007)

Log Message:
-----------
Tedious porting. Mostly DBUS and Kate. First file *almost* compiles...

Modified Paths:
--------------
    branches/KDE4_port/CMakeLists.txt
    branches/KDE4_port/TODO_KDE4
    branches/KDE4_port/rkward/rkconsole.h
    branches/KDE4_port/rkward/rkward.cpp
    branches/KDE4_port/rkward/rkward.h
    branches/KDE4_port/rkward/windows/rkcommandeditorwindow.cpp
    branches/KDE4_port/rkward/windows/rkcommandeditorwindow.h

Modified: branches/KDE4_port/CMakeLists.txt
===================================================================
--- branches/KDE4_port/CMakeLists.txt	2007-10-08 15:50:44 UTC (rev 2042)
+++ branches/KDE4_port/CMakeLists.txt	2007-10-08 18:03:25 UTC (rev 2043)
@@ -3,9 +3,9 @@
 
 FIND_PACKAGE(KDE4 REQUIRED)
 
-SET(CMAKE_VERBOSE_MAKEFILE ON)
+SET(CMAKE_VERBOSE_MAKEFILE OFF)
 
-ADD_DEFINITIONS(${QT_DEFINITIONS} ${KDE4_DEFINITIONS})
+ADD_DEFINITIONS(${QT_DEFINITIONS} ${KDE4_DEFINITIONS} -DQT3_SUPPORT)
 
 LINK_DIRECTORIES(${KDE4_LIB_DIR})
 

Modified: branches/KDE4_port/TODO_KDE4
===================================================================
--- branches/KDE4_port/TODO_KDE4	2007-10-08 15:50:44 UTC (rev 2042)
+++ branches/KDE4_port/TODO_KDE4	2007-10-08 18:03:25 UTC (rev 2043)
@@ -19,3 +19,8 @@
 - adjust debian dir
 
 **Everything else**
+
+rkcommandeditorwindow
+	- code completion will be broken. Fix after porting.
+	- does the popup-menu still work? See SVN rev. 962.
+	- does highlighting work?
\ No newline at end of file

Modified: branches/KDE4_port/rkward/rkconsole.h
===================================================================
--- branches/KDE4_port/rkward/rkconsole.h	2007-10-08 15:50:44 UTC (rev 2042)
+++ branches/KDE4_port/rkward/rkconsole.h	2007-10-08 18:03:25 UTC (rev 2043)
@@ -20,8 +20,8 @@
 
 #include <kparts/part.h>
 
-#include <kate/document.h>
-#include <kate/view.h>
+#include <ktexteditor/document.h>
+#include <ktexteditor/view.h>
 
 #include <q3ptrlist.h>
 //Added by qt3to4:
@@ -146,8 +146,8 @@
 	bool output_continuation;
 
 	RCommand *current_command;
-	Kate::Document *doc;
-	Kate::View *view;
+	KTextEditor::Document *doc;
+	KTextEditor::View *view;
 	RKFunctionArgHinter *hinter;
 
 	static RKConsole *main_console;

Modified: branches/KDE4_port/rkward/rkward.cpp
===================================================================
--- branches/KDE4_port/rkward/rkward.cpp	2007-10-08 15:50:44 UTC (rev 2042)
+++ branches/KDE4_port/rkward/rkward.cpp	2007-10-08 18:03:25 UTC (rev 2043)
@@ -93,6 +93,20 @@
 	new RKEditObjectAgent (QStringList (), 0);
 }
 
+/** DBUS interface **/
+
+void RKWardDBUSInterface::RKWardDBUSInterface (QApplication *application) : QDBusAbstractAdaptor(application) {
+	RK_TRACE (APP);
+}
+
+void RKWardDBUSInterface::openHTMLHelp (const QString &url) {
+	RK_TRACE (APP);
+
+	RKWorkplace::mainWorkplace ()->openHelpWindow (url);
+}
+
+/** Main window **/
+
 //static
 RKWardMainWindow *RKWardMainWindow::rkward_mainwin = 0;
 
@@ -156,10 +170,11 @@
 	connect (partManager (), SIGNAL (partAdded (KParts::Part *)), this, SLOT (partAdded (KParts::Part *)));
 	connect (partManager (), SIGNAL (partRemoved (KParts::Part *)), this, SLOT (partRemoved (KParts::Part *)));
 
-	if (!kapp->dcopClient ()->isRegistered ()) {
-		kapp->dcopClient ()->registerAs ("rkward");
-		kapp->dcopClient ()->setDefaultObject (objId ());
-	}
+	// create the DBUS adaptor:
+	new RKWardDBUSInterface (qApp);
+
+	// connect to D-Bus and register as an object:
+	QDBus::sessionBus ().registerObject ("/MainApplication", qApp);
 }
 
 RKWardMainWindow::~RKWardMainWindow() {
@@ -739,11 +754,6 @@
 	RKWorkplace::mainWorkplace ()->openHelpWindow (url);
 }
 
-void RKWardMainWindow::openHTMLHelp (const QString & url) {
-	RK_TRACE (APP);
-	openHTML (url);
-}
-
 void RKWardMainWindow::setCaption (const QString &) {
 	RK_TRACE (APP);
 

Modified: branches/KDE4_port/rkward/rkward.h
===================================================================
--- branches/KDE4_port/rkward/rkward.h	2007-10-08 15:50:44 UTC (rev 2042)
+++ branches/KDE4_port/rkward/rkward.h	2007-10-08 18:03:25 UTC (rev 2043)
@@ -23,17 +23,21 @@
 #include <config.h>
 #endif
 
-#include <dcopobject.h>
+#include<QDBusAbstractAdaptor>
 //Added by qt3to4:
 #include <QLabel>
 #include <QCloseEvent>
 
-/** This base provides the DCOP-Interface for RKWardMainWindow */
-class RKWardDCOPInterface : virtual public DCOPObject {
-	K_DCOP
-	k_dcop:
-
-	virtual void openHTMLHelp (const QString &url) = 0;
+/** This base provides the DBUS-Interface for RKWardMainWindow */
+class RKWardDBUSInterface : virtual public QDBusAbstractAdaptor {
+	Q_OBJECT
+	Q_CLASSINFO("D-Bus Interface", "org.kde.rkward")
+public:
+	RKWardDBUSInterface (QApplication *application);
+	~RKWardDBUSInterface () {};
+public slots:
+	/** Open the given html help page */
+	void openHTMLHelp (const QString &url);
 };
 
 
@@ -42,7 +46,6 @@
 // include files for KDE 
 #include <kapplication.h>
 #include <k3mdimainfrm.h>
-#include <kaccel.h>
 #include <kaction.h>
 #include <kurl.h>
 #include <kparts/partmanager.h>
@@ -71,7 +74,7 @@
 /**
 The main class of rkward. This is where all strings are tied togther, controlls the initialization, and there are some of the most important slots for user actions. All real work is done elsewhere.
 */
-class RKWardMainWindow : public KMdiMainFrm, virtual public KParts::PartBase, virtual public RKWardDCOPInterface {
+class RKWardMainWindow : public KMdiMainFrm, virtual public KParts::PartBase {
 	Q_OBJECT
 public:
 /** construtor
@@ -87,8 +90,6 @@
 	void fileOpenNoSave (const KUrl &url);
 /** open a workspace. If the current workspace is not empty, ask wether to save first. */
 	void fileOpenAskSave (const KUrl &url);
-/** opens the given url, assuming it is an HTML-help page. Like openHTML (), but with a QString parameter instead for DCOP. Generally you should use openHTML () instead. */
-	void openHTMLHelp (const QString &url);
 /** opens the given url, assuming it is an HTML-help page. */
 	void openHTML (const KUrl &url);
 

Modified: branches/KDE4_port/rkward/windows/rkcommandeditorwindow.cpp
===================================================================
--- branches/KDE4_port/rkward/windows/rkcommandeditorwindow.cpp	2007-10-08 15:50:44 UTC (rev 2042)
+++ branches/KDE4_port/rkward/windows/rkcommandeditorwindow.cpp	2007-10-08 18:03:25 UTC (rev 2043)
@@ -23,11 +23,7 @@
 
 #include <ktexteditor/configinterface.h>
 #include <ktexteditor/sessionconfiginterface.h>
-#include <ktexteditor/viewcursorinterface.h>
-#include <ktexteditor/printinterface.h>
-#include <ktexteditor/encodinginterface.h>
 #include <ktexteditor/editorchooser.h>
-#include <ktexteditor/popupmenuinterface.h>
 
 #include <qlayout.h>
 #include <q3popupmenu.h>
@@ -51,7 +47,6 @@
 #include <kfiledialog.h>
 #include <kaction.h>
 #include <kstandardaction.h>
-#include <kaccel.h>
 #include <klibloader.h>
 #include <kiconloader.h>
 
@@ -70,14 +65,13 @@
 RKCommandEditorWindow::RKCommandEditorWindow (QWidget *parent, bool use_r_highlighting) : RKMDIWindow (parent, RKMDIWindow::CommandEditorWindow) {
 	RK_TRACE (COMMANDEDITOR);
 
-	KLibFactory *factory = KLibLoader::self()->factory( "libkatepart" );
-	if (factory) {
-		// Create the part
-		m_doc = (Kate::Document *) factory->create( this, "katepart", "KParts::ReadWritePart" );
-		RK_ASSERT (m_doc);
-		m_view = (Kate::View *) m_doc->widget();
-	}
+	KTextEditor::Editor* editor = KTextEditor::editor("katepart");
+	RK_ASSERT (editor);
 
+	m_doc = editor->createDocument (this);
+	RK_ASSERT (m_doc);
+	m_view = m_doc->createView (this);
+
 	// strip down the khtmlpart's GUI. remove some stuff we definitely don't need.
 	RKCommonFunctions::removeContainers (m_doc, QStringList::split (',', "bookmarks,tools_spelling,tools_spelling_from_cursor,tools_spelling_selection,switch_to_cmd_line"), true);
 	RKCommonFunctions::moveContainer (m_doc, "Menu", "tools", "edit", true);
@@ -96,7 +90,7 @@
 	connect (m_doc, SIGNAL (modifiedChanged ()), this, SLOT (updateCaption ()));		// of course most of the time this causes a redundant call to updateCaption. Not if a modification is undone, however.
 	connect (m_doc, SIGNAL (textChanged ()), this, SLOT (tryCompletionProxy ()));
 	connect (m_view, SIGNAL (filterInsertString (KTextEditor::CompletionEntry *, QString *)), this, SLOT (fixCompletion (KTextEditor::CompletionEntry *, QString *)));
-	connect (m_view, SIGNAL (gotFocus (Kate::View *)), this, SLOT (setPopupMenu (Kate::View *)));
+//KDE4	connect (m_view, SIGNAL (gotFocus (Kate::View *)), this, SLOT (setPopupMenu (Kate::View *)));
 	completion_timer = new QTimer (this);
 	connect (completion_timer, SIGNAL (timeout ()), this, SLOT (tryCompletion()));
 
@@ -108,7 +102,7 @@
 	}
 
 	updateCaption ();	// initialize
-	QTimer::singleShot (0, this, SLOT (setPopupMenu ()));
+//KDE4	QTimer::singleShot (0, this, SLOT (setPopupMenu ()));
 }
 
 RKCommandEditorWindow::~RKCommandEditorWindow () {
@@ -117,6 +111,8 @@
 	delete m_doc;
 }
 
+/*
+KDE4 TODO: still needed? Alternatives?
 void RKCommandEditorWindow::setPopupMenu () {
 	RK_TRACE (COMMANDEDITOR);
 
@@ -126,7 +122,7 @@
 
 void RKCommandEditorWindow::setPopupMenu (Kate::View*) {
 	setPopupMenu ();
-}
+}*/
 
 QString RKCommandEditorWindow::fullCaption () {
 	RK_TRACE (COMMANDEDITOR);
@@ -159,29 +155,20 @@
 	QWidget::closeEvent (e);
 }
 
+// KDE4 TODO: inline
 void RKCommandEditorWindow::setRHighlighting () {
+	RK_TRACE (COMMANDEDITOR);
+
 	// set syntax-highlighting for R
-	int modes_count = highlightingInterface (m_doc)->hlModeCount ();
-	bool found_mode = false;
-	int i;
-	for (i = 0; i < modes_count; ++i) {
-		if (highlightingInterface (m_doc)->hlModeName (i).toLower() == "r script") {
-			found_mode = true;
-			break;
-		}
-	}
-	if (found_mode) {
-		highlightingInterface (m_doc)->setHlMode (i);
-	} else {
-		RK_DO (qDebug ("No syntax highlighting definition found for r script."), COMMANDEDITOR, DL_WARNING);
-	}
+	m_doc->setHighlightingMode("R Script");
 }
 
+/* KDE4 no longer needed?
 void RKCommandEditorWindow::copy () {
 	RK_TRACE (COMMANDEDITOR);
 
 	m_view->copy ();
-}
+} */
 
 void RKCommandEditorWindow::setReadOnly (bool ro) {
 	RK_TRACE (COMMANDEDITOR);
@@ -191,7 +178,7 @@
 
 bool RKCommandEditorWindow::openURL (const KUrl &url, bool use_r_highlighting, bool read_only){
 	RK_TRACE (COMMANDEDITOR);
-	if (m_doc->openURL (url)){
+	if (m_doc->openUrl (url)){
 		if (use_r_highlighting) setRHighlighting ();
 		setReadOnly (read_only);
 
@@ -214,8 +201,9 @@
 }
 
 void RKCommandEditorWindow::insertText (const QString &text) {
+// KDE4: inline?
 	RK_TRACE (COMMANDEDITOR);
-	m_doc->insertText (m_view->cursorLine  (), m_view->cursorColumn (), text);
+	m_view->insertText (text);
 	setFocus();
 }
 
@@ -236,12 +224,11 @@
 
 void RKCommandEditorWindow::showHelp () {
 	RK_TRACE (COMMANDEDITOR);
-	uint para=0; uint p=0;
-	m_view->cursorPosition (&para, &p);
 
-	QString line = m_view->currentTextLine() + ' ';
+	KTextEditor::Cursor c = m_view->cursorPosition();
+	QString line = m_doc->line(c.line ()) + ' ';
 
-	RKHelpSearchWindow::mainHelpSearch ()->getContextHelp (line, p);
+	RKHelpSearchWindow::mainHelpSearch ()->getContextHelp (line, c.column());
 }
 
 void RKCommandEditorWindow::tryCompletionProxy () {
@@ -252,9 +239,10 @@
 	// TODO: merge this with RKConsole::doTabCompletion () somehow
 	RK_TRACE (COMMANDEDITOR);
 
-	uint para=0; uint cursor_pos=0;
-	m_view->cursorPosition (&para, &cursor_pos);
-	QString current_line = m_view->currentTextLine ();
+	KTextEditor::Cursor c = m_view->cursorPosition();
+	uint para=c.line(); uint cursor_pos=c.column();
+
+	QString current_line = m_doc->line (para);
 	if (current_line.findRev ("#", cursor_pos) >= 0) return;	// do not hint while in comments
 
 	QString current_symbol = RKCommonFunctions::getCurrentSymbol (current_line, cursor_pos, false);
@@ -262,7 +250,7 @@
 		RObject::RObjectMap map;
 		RObject::RObjectMap::const_iterator it;
 		RObjectList::getObjectList ()->findObjectsMatching (current_symbol, &map);
-
+/* KDE4: TODO rework!
 		if (!map.isEmpty ()) {
 			Q3ValueList<KTextEditor::CompletionEntry> list;
 	
@@ -273,10 +261,11 @@
 			}
 
 			m_view->showCompletionBox (list);
-		}
+		} */
 	}
 }
 
+/* KDE4 TODO: maybe this is not needed anymore?
 void RKCommandEditorWindow::fixCompletion (KTextEditor::CompletionEntry *entry, QString *string) {
 	RK_TRACE (COMMANDEDITOR);
 	RK_ASSERT (entry);
@@ -294,13 +283,13 @@
 
 	// remove the start of the word, as the whole string will be inserted by katepart
 	m_doc->removeText (current_line_num, word_start, current_line_num, word_end);
-}
+} */
 
 bool RKCommandEditorWindow::provideContext (unsigned int line_rev, QString *context, int *cursor_position) {
 	RK_TRACE (COMMANDEDITOR);
 
-	uint current_line_num=0; uint cursor_pos=0;
-	m_view->cursorPosition (&current_line_num, &cursor_pos);
+	KTextEditor::Cursor c = m_view->cursorPosition();
+	uint current_line_num=c.line(); uint cursor_pos=c.column();
 
 	if (line_rev > current_line_num) return false;
 
@@ -309,7 +298,7 @@
 	} else {
 		*cursor_position = -1;
 	}
-	*context = m_doc->textLine (current_line_num - line_rev);
+	*context = m_doc->line (current_line_num - line_rev);
 
 	return true;
 }
@@ -317,7 +306,7 @@
 void RKCommandEditorWindow::runSelection() {
 	RK_TRACE (COMMANDEDITOR);
 
-	QString command = m_doc->selection ();
+	QString command = m_view->selectionText ();
 	if (command.isEmpty ()) return;
 
 	RKConsole::pipeUserCommand (new RCommand (command, RCommand::User, QString::null));
@@ -326,12 +315,13 @@
 void RKCommandEditorWindow::runLine() {
 	RK_TRACE (COMMANDEDITOR);
 
-	QString command = m_view->currentTextLine ();
+	KTextEditor::Cursor c = m_view->cursorPosition();
+	QString command = m_doc->line (c.line());
 	if (!command.isEmpty ()) RKConsole::pipeUserCommand (new RCommand (command, RCommand::User, QString::null));
 
-	uint para=0; uint p=0;			// advance to next line (NOTE: m_view->down () won't work on auto-wrapped lines)
-	m_view->cursorPosition (&para, &p);
-	m_view->setCursorPosition (para+1, p);
+	// advance to next line (NOTE: m_view->down () won't work on auto-wrapped lines)
+	c.setLine(c.line() + 1);
+	m_view->setCursorPosition (c);
 }
 
 
@@ -351,21 +341,22 @@
 
 #include "../core/rfunctionobject.h"
 
-RKFunctionArgHinter::RKFunctionArgHinter (RKScriptContextProvider *provider, Kate::View* view) {
+RKFunctionArgHinter::RKFunctionArgHinter (RKScriptContextProvider *provider, KTextEditor::View* view) {
 	RK_TRACE (COMMANDEDITOR);
 
 	RKFunctionArgHinter::provider = provider;
 	RKFunctionArgHinter::view = view;
 
-	const QObjectList *children = view->children ();
-	QObjectListIt it (*children);
+	const QObjectList children = view->children ();
+	QObjectList::const_iterator it = children.constBegin();
 	QObject *obj;
-	while ((obj = it.current()) != 0) {
+	while ((obj = *it) != 0) {
 		++it;
 		obj->installEventFilter (this);
 	}
 
-	arghints_popup = new Q3VBox (0, 0, WType_Popup);
+//KDE4: we could/should use KTextEditor::TextHintInterface
+	arghints_popup = new Q3VBox (0, 0, Qt::Popup);
 	arghints_popup->setFrameStyle (Q3Frame::Box | Q3Frame::Plain);
 	arghints_popup->setLineWidth (1);
 	arghints_popup_text = new QLabel (arghints_popup);
@@ -455,7 +446,7 @@
 	// initialize and show popup
 	arghints_popup_text->setText (effective_symbol + " (" + static_cast<RFunctionObject*> (object)->printArgs () + ')');
 	arghints_popup->resize (arghints_popup_text->sizeHint () + QSize (2, 2));
-	arghints_popup->move (view->mapToGlobal (view->cursorCoordinates () + QPoint (0, arghints_popup->height ())));
+	arghints_popup->move (view->mapToGlobal (view->cursorPositionCoordinates () + QPoint (0, arghints_popup->height ())));
 	arghints_popup->show ();
 }
 

Modified: branches/KDE4_port/rkward/windows/rkcommandeditorwindow.h
===================================================================
--- branches/KDE4_port/rkward/windows/rkcommandeditorwindow.h	2007-10-08 15:50:44 UTC (rev 2042)
+++ branches/KDE4_port/rkward/windows/rkcommandeditorwindow.h	2007-10-08 18:03:25 UTC (rev 2043)
@@ -24,8 +24,8 @@
 #include <QLabel>
 #include <QCloseEvent>
 
-#include <kate/view.h>
-#include <kate/document.h>
+#include <ktexteditor/view.h>
+#include <ktexteditor/document.h>
 #include <kurl.h>
 
 #include "../windows/rkmdiwindow.h"
@@ -37,7 +37,7 @@
 class RKScriptContextProvider {
 public:
 	RKScriptContextProvider () {};
-	~RKScriptContextProvider () {};
+	virtual ~RKScriptContextProvider () {};
 
 	/** to be implemented in subclasses. Provide some context (probably a line, but you may provide chunks in arbitrary size). If line_rev is 0, provide the line, the cursor is in. If line_rev is greater than 0, provide context before that.
 	@param context Place the context here
@@ -50,7 +50,7 @@
 class RKFunctionArgHinter : public QObject {
 	Q_OBJECT
 public:
-	RKFunctionArgHinter (RKScriptContextProvider *provider, Kate::View* view);
+	RKFunctionArgHinter (RKScriptContextProvider *provider, KTextEditor::View* view);
 	~RKFunctionArgHinter ();
 
 	/** Try to show an arg hint now */
@@ -65,7 +65,7 @@
 	bool eventFilter (QObject *, QEvent *e);
 private:
 	RKScriptContextProvider *provider;
-	Kate::View *view;
+	KTextEditor::View *view;
 
 	Q3VBox *arghints_popup;
 	QLabel *arghints_popup_text;
@@ -100,7 +100,7 @@
 /** set the current text (clear all previous text, and sets new text) */
 	void setText (const QString &text);
 /** copy current selection. Wrapper for use by external classes */
-	void copy ();
+//KDE4: no longer needed?	void copy ();
 
 	QString getDescription ();
 
@@ -121,9 +121,10 @@
 /** show a code completion box if appropriate. Use tryCompletionProxy () instead, which will call this function after a timeout */
 	void tryCompletion ();
 /** called by the Kate part, if an entry was selected from the code completion box. Will remove the current symbol, as the kate part is about to re-add it (in completed form) */
-	void fixCompletion (KTextEditor::CompletionEntry *, QString *);
-	void setPopupMenu (Kate::View *);
-	void setPopupMenu ();
+// KDE4 TODO: still needed?
+//	void fixCompletion (KTextEditor::CompletionEntry *, QString *);
+//KDE4	void setPopupMenu (KTextEditor::View *);
+//KDE4	void setPopupMenu ();
 /** Show help about the current word. */
 	void showHelp ();
 /** run the currently selected command(s) */
@@ -136,8 +137,8 @@
 /** reimplemented from KMdiChildView: give the editor window a chance to object to being closed (if unsaved) */
 	void closeEvent (QCloseEvent *e);
 private:
-	Kate::Document *m_doc;
-	Kate::View *m_view;
+	KTextEditor::Document *m_doc;
+	KTextEditor::View *m_view;
 	RKFunctionArgHinter *hinter;
 
 	QTimer *completion_timer;


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