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

tfry at users.sourceforge.net tfry at users.sourceforge.net
Mon Oct 15 19:37:09 UTC 2007


Revision: 2069
          http://rkward.svn.sourceforge.net/rkward/?rev=2069&view=rev
Author:   tfry
Date:     2007-10-15 12:37:09 -0700 (Mon, 15 Oct 2007)

Log Message:
-----------
Some more files compile

Modified Paths:
--------------
    branches/KDE4_port/TODO_KDE4
    branches/KDE4_port/rkward/main.cpp
    branches/KDE4_port/rkward/rkconsole.cpp
    branches/KDE4_port/rkward/rkconsole.h
    branches/KDE4_port/rkward/robjectbrowser.cpp
    branches/KDE4_port/rkward/robjectviewer.cpp

Modified: branches/KDE4_port/TODO_KDE4
===================================================================
--- branches/KDE4_port/TODO_KDE4	2007-10-15 16:21:00 UTC (rev 2068)
+++ branches/KDE4_port/TODO_KDE4	2007-10-15 19:37:09 UTC (rev 2069)
@@ -81,3 +81,7 @@
 
 rkobjectlistview:
 	- do the tool-tips for the objects work?
+
+rkconsole:
+	- does it work at all?
+	- selection, editing, naivgating
\ No newline at end of file

Modified: branches/KDE4_port/rkward/main.cpp
===================================================================
--- branches/KDE4_port/rkward/main.cpp	2007-10-15 16:21:00 UTC (rev 2068)
+++ branches/KDE4_port/rkward/main.cpp	2007-10-15 19:37:09 UTC (rev 2069)
@@ -66,38 +66,32 @@
 int RK_Debug_Level = 0;
 int RK_Debug_Flags = ALL;
 
-static const char *version = I18N_NOOP(VERSION);
-static const char *description = I18N_NOOP("RKWard");
+static KCmdLineOptions options;
 
-static KCmdLineOptions options[] =
-{
-  { "+[File]", I18N_NOOP ("file to open"), 0 },
-  { "debug-level <level>", I18N_NOOP ("Verbosity of debug messages (0-5)"), "2"}, 
-  { "debug-flags <flags>", I18N_NOOP ("Mask for components to debug (see debug.h)"), "8191" }, 
-  { "debugger <command>", I18N_NOOP ("Debugger (enclose any debugger arguments in single quotes ('') together with the command)"), ""}, 
-  { "disable-stack-check", I18N_NOOP ("Disable R C stack checking"), 0 }, 
-  { 0, 0, 0 }
-  // INSERT YOUR COMMANDLINE OPTIONS HERE
-};
-
 int main(int argc, char *argv[]) {
-	KAboutData aboutData( "rkward", I18N_NOOP ("RKWard"), version, description, KAboutData::License_GPL, "(c) 2002, 2004, 2005, 2006, 2007", 0, "http://rkward.sf.net", "rkward-devel at lists.sourceforge.net");
-	aboutData.addAuthor ("Thomas Friedrichsmeier", I18N_NOOP ("Project leader / main developer"), 0);
-	aboutData.addAuthor ("Pierre Ecochard",  I18N_NOOP ("C++ coder since 0.2.9"), 0);
-	aboutData.addAuthor ("Stefan Roediger", I18N_NOOP ("Many plugins, suggestions, marketing, translations"), 0);
-	aboutData.addAuthor ("Prasenjit Kapat", I18N_NOOP ("Many plugins, suggestions"), 0);
-	aboutData.addCredit ("Contributors in alphabetical order", 0, 0);
-	aboutData.addCredit ("Philippe Grosjean", I18N_NOOP ("Several helpful comments and discussions"), 0);
-	aboutData.addCredit ("Adrien d'Hardemare", I18N_NOOP ("Plugins and patches"), 0);
-	aboutData.addCredit ("Yves Jacolin", I18N_NOOP ("New website"), 0);
-	aboutData.addCredit ("Marco Martin", I18N_NOOP ("A cool icon"), 0);
-	aboutData.addCredit ("Daniele Medri", I18N_NOOP ("RKWard logo, many suggestions, help on wording"), 0);
-	aboutData.addCredit ("David Sibai", I18N_NOOP ("Several valuable comments, hints and patches"), 0);
-	aboutData.addCredit ("Ilias Soumpasis", I18N_NOOP ("Translation, Suggestions, plugins"), 0);
-	aboutData.addCredit ("Ralf Tautenhahn", I18N_NOOP ("Many comments, useful suggestions, and bug reports"), 0);
-	aboutData.addCredit ("Roland Vollgraf", I18N_NOOP ("Some patches"), 0);
-	aboutData.addCredit (I18N_NOOP ("Many more people on rkward-devel at lists.sourceforge.net"), I18N_NOOP ("Sorry, if we forgot to list you. Please contact us to get added"), 0);
+	options.add ("+[File]", ki18n ("file to open"), 0);
+	options.add ("debug-level <level>", ki18n ("Verbosity of debug messages (0-5)"), "2");
+	options.add ("debug-flags <flags>", ki18n ("Mask for components to debug (see debug.h)"), "8191");
+	options.add ("debugger <command>", ki18n ("Debugger (enclose any debugger arguments in single quotes ('') together with the command)"), "");
+	options.add ("disable-stack-check", ki18n ("Disable R C stack checking"), 0);
 
+	KAboutData aboutData("rkward", QByteArray (), ki18n ("RKWard"), VERSION, ki18n ("Frontend to the R statistics language"), KAboutData::License_GPL, ki18n ("(c) 2002, 2004, 2005, 2006, 2007"), KLocalizedString (), "http://rkward.sf.net", "rkward-devel at lists.sourceforge.net");
+	aboutData.addAuthor (ki18n ("%1").subs ("Thomas Friedrichsmeier"), ki18n ("Project leader / main developer"));
+	aboutData.addAuthor (ki18n ("%1").subs ("Pierre Ecochard"), ki18n ("C++ coder since 0.2.9"));
+	aboutData.addAuthor (ki18n ("%1").subs ("Stefan Roediger"), ki18n ("Many plugins, suggestions, marketing, translations"));
+	aboutData.addAuthor (ki18n ("%1").subs ("Prasenjit Kapat"), ki18n ("Many plugins, suggestions"));
+	aboutData.addCredit (ki18n ("Contributors in alphabetical order"));
+	aboutData.addCredit (ki18n ("%1").subs ("Philippe Grosjean"), ki18n ("Several helpful comments and discussions"));
+	aboutData.addCredit (ki18n ("%1").subs ("Adrien d'Hardemare"), ki18n ("Plugins and patches"));
+	aboutData.addCredit (ki18n ("%1").subs ("Yves Jacolin"), ki18n ("New website"));
+	aboutData.addCredit (ki18n ("%1").subs ("Marco Martin"), ki18n ("A cool icon"));
+	aboutData.addCredit (ki18n ("%1").subs ("Daniele Medri"), ki18n ("RKWard logo, many suggestions, help on wording"));
+	aboutData.addCredit (ki18n ("%1").subs ("David Sibai"), ki18n ("Several valuable comments, hints and patches"));
+	aboutData.addCredit (ki18n ("%1").subs ("Ilias Soumpasis"), ki18n ("Translation, Suggestions, plugins"));
+	aboutData.addCredit (ki18n ("%1").subs ("Ralf Tautenhahn"), ki18n ("Many comments, useful suggestions, and bug reports"));
+	aboutData.addCredit (ki18n ("%1").subs ("Roland Vollgraf"), ki18n ("Some patches"));
+	aboutData.addCredit (ki18n ("Many more people on rkward-devel at lists.sourceforge.net"), ki18n ("Sorry, if we forgot to list you. Please contact us to get added"));
+
 	// before initializing the commandline args, remove the ".bin" from "rkward.bin".
 	// This is so it prints "Usage rkward..." instead of "Usage rkward.bin...", etc.
 	// it seems safest to keep a copy, since the shell still owns argv[0]
@@ -116,7 +110,7 @@
 	RKWardStartupOptions *stoptions = new RKWardStartupOptions;
 	KUrl *open_url = 0;
 	if (args->count ()) {
-		open_url = new KUrl (args->makeURL (args->arg (0)));
+		open_url = new KUrl (args->makeURL (args->arg (0).latin1()));
 	}
 	stoptions->initial_url = open_url;
 	stoptions->no_stack_check = args->isSet ("disable-stack-check");

Modified: branches/KDE4_port/rkward/rkconsole.cpp
===================================================================
--- branches/KDE4_port/rkward/rkconsole.cpp	2007-10-15 16:21:00 UTC (rev 2068)
+++ branches/KDE4_port/rkward/rkconsole.cpp	2007-10-15 19:37:09 UTC (rev 2069)
@@ -37,6 +37,10 @@
 #include <kapplication.h>
 #include <kmessagebox.h>
 #include <kshellcompletion.h>
+#include <ktexteditor/editor.h>
+#include <ktexteditor/configinterface.h>
+#include <ktexteditor/markinterface.h>
+#include <kxmlguifactory.h>
 
 #include "rkglobals.h"
 #include "rkward.h"
@@ -60,43 +64,29 @@
 	Q3VBoxLayout *layout = new Q3VBoxLayout (this);
 
 	// create a Kate-part as command-editor
-#if !KDE_IS_VERSION (3, 2, 0)
-	doc = static_cast<Kate::Document *> (KTextEditor::createDocument ("libkatepart", this, "Kate::Document"));
-	view = static_cast<Kate::View *> (doc->createView (this));
-# else
-	doc = Kate::document (KTextEditor::createDocument ("libkatepart", this, "Kate::Document"));
-	RK_ASSERT (doc);
-	view = Kate::view (doc->createView (this));
-	RK_ASSERT (view);
-#endif
+	KTextEditor::Editor* editor = KTextEditor::editor("katepart");
+	RK_ASSERT (editor);
+
+	doc = editor->createDocument (this);
+	view = doc->createView (this);
 	layout->addWidget (view);
 
-	view->setDynWordWrap (false);
+// KDE4: does this work?
+	KTextEditor::ConfigInterface *confint = qobject_cast<KTextEditor::ConfigInterface*> (view);
+	RK_ASSERT (view);
+	confint->setConfigValue ("dynamic-word-wrap", false);
 
 	setFocusProxy (view);
-	setFocusPolicy (QWidget::StrongFocus);
+	setFocusPolicy (Qt::StrongFocus);
 	
 	/* We need to unplug kactions that were pluged to the KateViewInternal in kateview.cpp.
 	These actions incluse Key_Up, Key_Down, etc.
 	It's a bit boring to do, but there is no way to do that another way yet.
 	Apparently, things will be different in KDE 4.*/
-	const QObjectList *list = view->children ();
-	QObjectListIt it (*list);
-	QObject *obj;
-	
-	KActionCollection* ac=0;
-	QWidget* Kvi=0; //here we store the KateViewInternal of the view, so we can uplug actions from it
-	
-	while ((obj = it.current()) != 0) {
-		++it;
-		obj->installEventFilter (this);
-		if (obj->inherits("KActionCollection")) {
-			ac= (KActionCollection*) obj;
-		} else if(obj->inherits("KateViewInternal")) {
-			Kvi= (QWidget*) obj;
-		}
-	}
 
+// KDE4: are these still valid? Do we really need to unplug them, or is our key-press handling enough?
+/*	KActionCollection* ac = view->actionCollection ();
+
 	if (ac) {
 		unplugAction("move_line_up", ac);
 		unplugAction("move_line_down", ac);
@@ -124,7 +114,7 @@
 		unplugAction("paste", ac);
 	} else {
 		RK_DO (qDebug ("Could not retrieve the view's action collection"), APP, DL_WARNING);
-	}
+	} */
 
 	view->focusProxy()->installEventFilter(this);
 	view->installEventFilter(this);
@@ -144,9 +134,10 @@
 	prefix = nprefix;
 	command_incomplete = false;
 	output_continuation = false;
-	doc->setUndoSteps (0);
+// KDE4: a way to do this?
+//	doc->setUndoSteps (0);
 	clear ();
-	setRHighlighting ();
+	doc->setHighlightingMode ("RKWard output");
 
 	commands_history = RKSettingsModuleConsole::loadCommandHistory ();
 	commands_history_position = commands_history.constEnd ();
@@ -163,46 +154,29 @@
 	RKSettingsModuleConsole::saveCommandHistory (commands_history);
 }
 
-void RKConsole::setRHighlighting () {
-	// set syntax-highlighting for R
-	int modes_count = doc->hlModeCount ();
-	bool found_mode = false;
-	int i;
-	RK_DO (qDebug ("%s", "Looking for syntax highlighting definition"), COMMANDEDITOR, DL_INFO);
-	for (i = 0; i < modes_count; ++i) {
-		RK_DO (qDebug ("%s", doc->hlModeName(i).toLower().toLatin1 ()), COMMANDEDITOR, DL_DEBUG);
-		if (doc->hlModeName(i).toLower() == "rkward output") {
-			found_mode = true;
-			break;
-		}
-	}
-	if (found_mode) {
-		doc->setHlMode(i);
-	} else {
-		RK_DO (qDebug ("rkward output highlighting not found"), COMMANDEDITOR, DL_WARNING);
-	}
-}
-
-
 bool RKConsole::handleKeyPress (QKeyEvent *e) {
 
-	uint para=0; uint pos=0;
-	view->cursorPosition (&para, &pos);
+	KTextEditor::Cursor c = view->cursorPosition ();
+	int para=c.line (); int pos=c.column ();
 	command_was_piped = false;
 
-	if (para < doc->numLines() - 1 || pos < prefix.length ()) {	// not inside the last line?
+	if (para < doc->lines () - 1 || pos < prefix.length ()) {	// not inside the last line?
 		int t = (int) pos;					// adjust position before interpreting keystroke
 		if (prefix.length()>pos) t=prefix.length ();
-		view->setCursorPosition (doc->numLines () -1, t);
+		view->setCursorPosition (KTextEditor::Cursor (doc->lines () -1, t));
 	}
 
-	if (hasSelectedText () && (selectionInterfaceExt(doc)->selStartCol () < (int) prefix.length () || selectionInterfaceExt (doc)->selStartLine () < (int) doc->numLines () -1)) { // There is a selection outside the command line
-		// Eat the key and beep (unless it's just a modifier key). Otherwise it might overwrite or delete the selection
-		if (e->state () == e->stateAfter ()) {
-			KApplication::kApplication ()->beep ();
-			e->ignore ();
+	if (view->selection ()) {
+		KTextEditor::Range selrange = view->selectionRange ();
+		if (selrange.start ().column () < (doc->lines () - 1) || selrange.start ().line () < prefix.length ()) {
+			// There is a selection outside the command line
+			// Eat the key and beep (unless it's just a modifier key). Otherwise it might overwrite or delete the selection
+			if (e->key () - (e->key () & (Qt::ShiftModifier | Qt::ControlModifier | Qt::AltModifier | Qt::MetaModifier | Qt::KeypadModifier | Qt::GroupSwitchModifier))) {
+				KApplication::kApplication ()->beep ();
+				e->ignore ();
+			}
+			return true;
 		}
-		return true;
 	}
 
 	if (current_command) {
@@ -211,63 +185,54 @@
 	}
 
 	if (e->key () == Qt::Key_Up) {
-		commandsListUp (RKSettingsModuleConsole::shouldDoHistoryContextSensitive (e->state ()));
+		commandsListUp (RKSettingsModuleConsole::shouldDoHistoryContextSensitive (e->modifiers ()));
 		return true;
 	}
 	else if (e->key () == Qt::Key_Down) {
-		commandsListDown (RKSettingsModuleConsole::shouldDoHistoryContextSensitive (e->state ()));
+		commandsListDown (RKSettingsModuleConsole::shouldDoHistoryContextSensitive (e->modifiers ()));
 		return true;
 	}
 	command_edited = true; // all other keys are considered as "editing" the current comand
 
+	if (e->key () == Qt::Key_Home) {
+		if (e->modifiers () == Qt::ShiftModifier) {
+			int lastline = doc->lines () - 1;
+			int firstcol = prefix.length ();
+			KTextEditor::Range newrange (lastline, firstcol, lastline, pos);
+
+			if (view->selection ()) {
+				KTextEditor::Range oldrange = view->selectionRange ();
+				if (oldrange.end ().column () == pos) {
+					newrange.setBothColumns (firstcol);
+				} else {
+					newrange.expandToRange (oldrange);
+				}
+			}
+			view->setSelection (newrange);
+		} else {
+			cursorAtTheBeginning ();
+		}
+		return true;
+	}
+
 	if (e->key() == Qt::Key_Enter || e->key() == Qt::Key_Return) {
 		hinter->hideArgHint ();
 		submitCommand ();
 		return true;
-	}
-	else if (e->state () == Qt::ShiftModifier && e->key () == Qt::Key_Home){
-		if(hasSelectedText())
-			pos=selectionInterfaceExt(doc)->selEndCol (); //There is already a selection, we take it into account.
-		selectionInterface(doc)->setSelection(doc->numLines()-1,prefix.length (),doc->numLines()-1, pos);
-		cursorAtTheBeginning ();
-		return true;
-	}
-	else if (e->state () == Qt::ShiftModifier && e->key () == Qt::Key_Left){
+	} else if (e->key () == Qt::Key_Left){
 		if(pos<=prefix.length ()){
 			return true;
-		} else {
-			view->shiftCursorLeft ();
-			return false;
 		}
 	}
-	else if (e->key () == Qt::Key_Left){
-		if(pos<=prefix.length ()){
-			return true;
-		} else {
-			view->cursorLeft();
-			return true;
-		}
-	}
 	else if (e->key () == Qt::Key_Backspace){
 		if(pos<=prefix.length ()){
 			return true;
-		} else {
-			view->backspace();
-			return true;
 		}
 	}
 	else if (e->key () == Qt::Key_Tab){
 		doTabCompletion ();
 		return true;
 	}
-	else if (e->key () == Qt::Key_Home){
-		cursorAtTheBeginning ();
-		return true;
-	}
-	else if (e->key() == Qt::Key_Delete) {
-		view->keyDelete();
-		return true;
-	}
 
 	return false;
 }
@@ -292,8 +257,7 @@
 	RK_TRACE (APP);
 
 	int offset = prefix.length ();
-	doc->removeText (line_num, offset + word_start, line_num, offset + word_end);
-	doc->insertText (line_num, offset + word_start, completion);
+	doc->replaceText (KTextEditor::Range (line_num, offset + word_start, line_num, offset + word_end), completion);
 }
 
 bool RKConsole::doTabCompletionHelper (int line_num, const QString &line, int word_start, int word_end, const QStringList &entries) {
@@ -310,13 +274,13 @@
 		int i=0;
 		for (it = entries.constBegin (); it != entries.constEnd (); ++it) {
 			if (i % 3) {
-				doc->insertText (doc->numLines () - 1, 0, (*it).leftJustified (35));
+				doc->insertText (KTextEditor::Cursor (doc->lines () - 1, 0), (*it).leftJustified (35));
 			} else {
-				doc->insertText (doc->numLines (), 0, *it);
+				doc->insertText (KTextEditor::Cursor (doc->lines (), 0), *it);
 			}
 			++i;
 		}
-		doc->insertText (doc->numLines (), 0, prefix + line);
+		doc->insertText (KTextEditor::Cursor (doc->lines (), 0), prefix + line);
 		cursorAtTheEnd ();
 	} else {
 		tab_key_pressed_before = true;
@@ -363,7 +327,7 @@
 	RK_TRACE (APP);
 
 	QString current_line = currentCommand ();
-	int current_line_num = doc->numLines () - 1;
+	int current_line_num = doc->lines () - 1;
 	int word_start;
 	int word_end;
 	int cursor_pos = currentCursorPositionInCommand ();
@@ -443,9 +407,9 @@
 			// prevent cursor from leaving last line
 			uint para=0; uint p=0;
 			view->cursorPosition (&para, &p);
-			if (para != doc->numLines () - 1) {
+			if (para != doc->lines () - 1) {
 				int y = view->y ();
-				view->setCursorPosition (doc->numLines() -1, p);
+				view->setCursorPosition (doc->lines() -1, p);
 				int y2 = view->y ();
 				qDebug ("%d, %d", y, y2);
 				view->scroll (0, y - y2);
@@ -459,26 +423,28 @@
 
 QString RKConsole::currentCommand () {
 	RK_TRACE (APP);
-	return (doc->textLine (doc->numLines () - 1).mid (prefix.length ()));
+	return (doc->line (doc->lines () - 1).mid (prefix.length ()));
 }
 
 void RKConsole::setCurrentCommand (const QString &command) {
 	RK_TRACE (APP);
-	editInterface(doc)->removeText (doc->numLines() - 1, 0, doc->numLines() - 1, editInterface(doc)->textLine(doc->numLines() - 1).length());
-	editInterface(doc)->insertText (doc->numLines() - 1, 0, prefix + command);
+
+	int lastline = doc->lines () - 1;
+	doc->replaceText (KTextEditor::Range (lastline, prefix.length (), lastline, doc->lineLength (lastline)), command);
 	cursorAtTheEnd ();
 }
 
 void RKConsole::cursorAtTheEnd () {
 	RK_TRACE (APP);
-	view->setCursorPosition (doc->numLines() -1, editInterface(doc)->lineLength (doc->numLines() -1));
-	view->scrollDown ();
+
+	view->setCursorPosition (doc->endOfLine (doc->lines () - 1));
+// KDE4 TODO: view->scrollDown ();
 }
 
 void RKConsole::cursorAtTheBeginning () {
 	RK_TRACE (APP);
-	view->scrollDown ();
-	view->setCursorPosition (doc->numLines() - 1, prefix.length ());
+// KDE4 TODO: view->scrollDown ();
+	view->setCursorPosition (KTextEditor::Cursor (doc->lines() - 1, prefix.length ()));
 }
 
 void RKConsole::submitCommand () {
@@ -492,7 +458,7 @@
 		command.prepend (incomplete_command + '\n');
 	}
 
-	doc->insertText (doc->numLines () - 1, editInterface (doc)->lineLength (doc->numLines () -1), "\n");
+	doc->insertLine (doc->lines (), QString ());
 	if (!current_line.isEmpty ()) {
 		current_command = new RCommand (command, RCommand::User | RCommand::Console, QString::null, this);
 		RKGlobals::rInterface ()->issueCommand (current_command);
@@ -569,7 +535,7 @@
 void RKConsole::rCommandDone (RCommand *command) {
 	RK_TRACE (APP);
 	if (command->errorSyntax () && command->error ().isEmpty ()) {
-		editInterface(doc)->insertLine(doc->numLines()-1, i18n ("Syntax error\n"));
+		doc->insertLine (doc->lines () - 1, i18n ("Syntax error\n"));
 	}
 
 	if (command->errorIncomplete ()) {
@@ -582,7 +548,7 @@
 		incomplete_command = QString::null;
 	}
 
-	if (output_continuation) doc->insertLine (doc->numLines (), "");
+	if (output_continuation) doc->insertLine (doc->lines (), "");
 	output_continuation = false;
 	commands_history_position = commands_history.constEnd ();
 	tryNextInBatch ();
@@ -591,27 +557,28 @@
 void RKConsole::newOutput (RCommand *, ROutput *output) {
 	RK_TRACE (APP);
 
-	int start_line = doc->numLines () -1;
+	int start_line = doc->lines () -1;
 	if (output_continuation) {
-		editInterface (doc)->insertText (doc->numLines () -1, editInterface (doc)->lineLength (doc->numLines () -1), output->output);
+		doc->insertText (doc->documentEnd (), output->output);
 	} else {
-		editInterface (doc)->insertText (doc->numLines () -1, 0, output->output);
+		doc->insertText (KTextEditor::Cursor (doc->lines () -1, 0), output->output);
 	}
-	int end_line = doc->numLines () -1;
+	int end_line = doc->lines () -1;
 	if (output->type != ROutput::Output) {
+		KTextEditor::MarkInterface *markiface = qobject_cast<KTextEditor::MarkInterface*> (doc);
+		RK_ASSERT (markiface);
 		for (int line = start_line; line < end_line; ++line) {
-			doc->addMark (line, KTextEditor::MarkInterface::BreakpointActive);
+			markiface->addMark (line, KTextEditor::MarkInterface::BreakpointActive);
 		}
 	}
 
 	if (RKSettingsModuleConsole::maxConsoleLines ()) {
-		uint c = (uint) doc->numLines();
+		uint c = (uint) doc->lines();
 // TODO: WORKAROUND: Somehow, when removing paragraph 0, the QTextEdit scrolls to the top in between (yes, this also happens when using removeParagaph (0)). Since this may happen very often in newOutput, we're a bit sloppy, and only remove lines after a certain threshold (20) is exceeded. When the command is finished, this will be cleaned up automatically.
 		if (c > (RKSettingsModuleConsole::maxConsoleLines () + 20)) {
 			view->setUpdatesEnabled (false);		// major performance boost while removing lines!
 			//TODO : deal with the case when there is already a selection
-			selectionInterface (doc)->setSelection (0, 0, c - RKSettingsModuleConsole::maxConsoleLines (), 0);
-			selectionInterface (doc)->removeSelectedText ();
+			doc->removeText (KTextEditor::Range (0, 0, c - RKSettingsModuleConsole::maxConsoleLines (), 0));
 			view->setUpdatesEnabled (true);
 		}
 	}
@@ -631,14 +598,14 @@
 	RK_TRACE (APP);
 	if (add_new_line) {
 		if (RKSettingsModuleConsole::maxConsoleLines ()) {
-			uint c = (uint) doc->numLines();
+			uint c = (uint) doc->lines();
 			setUpdatesEnabled (false);
 			for (uint ui = c; ui > RKSettingsModuleConsole::maxConsoleLines (); --ui) {
-				editInterface(doc)->removeText (0, 0,0, editInterface(doc)->textLine(0).length());
+				doc->removeLine (0);
 			}
 			setUpdatesEnabled (true);
 		}
-		editInterface(doc)->insertText (doc->numLines ()-1, 0, prefix);		// somehow, it seems to be safer to do this after removing superfluous lines, than before
+		doc->insertLine (doc->lines (), prefix);		// somehow, it seems to be safer to do this after removing superfluous lines, than before
 		cursorAtTheEnd ();
 	}
 
@@ -668,11 +635,11 @@
 void RKConsole::clear () {
 	RK_TRACE (APP);
 	doc->clear ();
-	doc->insertLine (doc->numLines (), "");
 	tryNextInBatch ();
-	// need this HACK to remove empty line at start
+// KDE 4: still needed?
+/*	// need this HACK to remove empty line at start
 	selectionInterface (doc)->setSelection (0, 0, 1, 0);
-	selectionInterface (doc)->removeSelectedText ();
+	selectionInterface (doc)->removeSelectedText (); */
 }
 
 void RKConsole::addCommandToHistory (const QString &command) {
@@ -693,7 +660,7 @@
 QString RKConsole::cleanedSelection () {
 	RK_TRACE (APP);
 
-	QString ret = doc->selection ();
+	QString ret = view->selectionText ();
 	ret.replace ('\n' + QString (nprefix), "\n");
 	ret.replace ('\n' + QString (iprefix), "\n");
 	if (ret.startsWith (nprefix)) {
@@ -711,24 +678,20 @@
 
 void RKConsole::literalCopy () {
 	RK_TRACE (APP);
-	view->copy();
+
+	QApplication::clipboard()->setText (view->selectionText ());
 }
 
 int RKConsole::currentCursorPosition (){
-	uint para=0; uint p=0;
-	view->cursorPosition (&para, &p);
-	return((int) p);
+	KTextEditor::Cursor c = view->cursorPosition ();
+	return(c.column ());
 }
 
-bool RKConsole::hasSelectedText () {
-	RK_TRACE (APP);
-	return (selectionInterface (doc)->hasSelection ());
-}
-
+//KDE4 still needed? (see ctor)
 void RKConsole::unplugAction(const QString &action, KActionCollection* ac) {
-	KAction* a = ac->action(action.toLatin1 ());
+	QAction* a = ac->action (action);
 	if( a ){
-		a->setEnabled(false);
+		a->setEnabled (false);
 	}
 }
 
@@ -744,7 +707,7 @@
 	prefix = nprefix;
 	command_incomplete = false;
 	incomplete_command = QString::null;
-	doc->insertLine (doc->numLines (), "");
+	doc->insertLine (doc->lines (), "");
 
 	tryNextInBatch (true);
 }
@@ -782,20 +745,31 @@
 void RKConsole::initializeActions (KActionCollection *ac) {
 	RK_TRACE (APP);
 
-	context_help_action = new KAction (i18n ("&Function reference"), KShortcut ("F2"), this, SLOT (showContextHelp ()), ac, "function_reference");
-	run_selection_action = new KAction (i18n ("Run selection"), QIcon (RKCommonFunctions::getRKWardDataDir () + "icons/run_selection.png"), KShortcut ("F8"), this, SLOT (runSelection ()), ac, "run_selection");
+	context_help_action = ac->addAction ("function_reference", this, SLOT(showContextHelp()));
+	context_help_action->setText (i18n ("&Function reference"));
+	context_help_action->setShortcut (Qt::Key_F2);
 
-	interrupt_command_action = new KAction (i18n ("Interrupt running command"), KShortcut ("Ctrl+C"), this, SLOT (slotInterruptCommand ()), ac, "interrupt");
-	interrupt_command_action->setIcon ("player_stop");
+	run_selection_action = ac->addAction ("run_selection", this, SLOT (runSelection()));
+	run_selection_action->setText (i18n ("Run selection"));
+	run_selection_action->setIcon (QIcon (RKCommonFunctions::getRKWardDataDir () + "icons/run_selection.png"));
+	run_selection_action->setShortcut (Qt::Key_F8);
+
+	interrupt_command_action = ac->addAction ("interrupt", this, SLOT (slotInterruptCommand()));
+	interrupt_command_action->setText (i18n ("Interrupt running command"));
+	interrupt_command_action->setShortcut (Qt::ControlModifier + Qt::Key_C);
+	interrupt_command_action->setIcon (KIcon ("player_stop"));
 	interrupt_command_action->setEnabled (false);
-// ugly HACK: we need this to override the default Ctrl+C binding
-	interrupt_command_action->setShortcut ("Ctrl+C");
 
-	copy_action = new KAction (i18n ("Copy selection cleaned"), 0, this, SLOT (copy ()), ac, "rkconsole_copy");
-	copy_literal_action = new KAction (i18n ("Copy selection literally"), 0, this, SLOT (literalCopy ()), ac, "rkconsole_copy_literal");
-	KStandardAction::clear (this, SLOT (clear ()), ac, "rkconsole_clear");
-	paste_action = KStandardAction::paste (this, SLOT (paste ()), ac, "rkconsole_paste");
-	new KAction (i18n ("Configure"), 0, this, SLOT (configure ()), ac, "rkconsole_configure");
+	copy_action = ac->addAction ("rkconsole_copy", this, SLOT (copy()));
+	copy_action->setText (i18n ("Copy selection cleaned"));
+
+	copy_literal_action = ac->addAction ("rkconsole_copy_literal", this, SLOT (literalCopy()));
+	copy_literal_action->setText (i18n ("Copy selection literally"));
+
+	ac->addAction (KStandardAction::Clear, "rkconsole_clear", this, SLOT (clear()));
+	paste_action = ac->addAction (KStandardAction::Paste, "rkconsole_paste", this, SLOT (paste()));
+	QAction *action = ac->addAction ("rkconsole_configure", this, SLOT (configure()));
+	action->setText (i18n ("Configure"));
 }
 
 void RKConsole::pipeUserCommand (const QString &command) {
@@ -836,7 +810,7 @@
 			}
 		}
 		text.replace ('\n', QString ("\n") + iprefix);
-		doc->insertText (doc->numLines () - 1, QString (nprefix).length (), text + '\n');
+		doc->insertText (KTextEditor::Cursor (doc->lines () - 1, QString (nprefix).length ()), text + '\n');
 		command->addReceiver (this);
 		command->addTypeFlag (RCommand::Console);
 		current_command = command;
@@ -853,9 +827,9 @@
 void RKConsole::doPopupMenu (const QPoint &pos) {
 	RK_TRACE (APP);
 
-	copy_action->setEnabled (hasSelectedText ());
-	copy_literal_action->setEnabled (hasSelectedText ());
-	run_selection_action->setEnabled (hasSelectedText ());
+	copy_action->setEnabled (view->selection ());
+	copy_literal_action->setEnabled (view->selection ());
+	run_selection_action->setEnabled (view->selection ());
 
 	console_part->showPopupMenu (pos);
 
@@ -871,8 +845,7 @@
 RKConsolePart::RKConsolePart (RKConsole *console) : KParts::Part (0) {
 	RK_TRACE (APP);
 
-	KInstance* instance = new KInstance ("rkward");
-	setInstance (instance);
+	setComponentData (KGlobal::mainComponent ());
 
 	setWidget (console);
 

Modified: branches/KDE4_port/rkward/rkconsole.h
===================================================================
--- branches/KDE4_port/rkward/rkconsole.h	2007-10-15 16:21:00 UTC (rev 2068)
+++ branches/KDE4_port/rkward/rkconsole.h	2007-10-15 19:37:09 UTC (rev 2069)
@@ -67,8 +67,6 @@
 	int currentCursorPosition ();
 /** Returns the current cursor position, within the current command (without taking into account the prefix).*/
 	int currentCursorPositionInCommand ();
-/** Returns TRUE if some text is selected; otherwise returns FALSE.  */
-	bool hasSelectedText ();
 /** interrupt the current incomplete command (if any) */
 	void resetIncompleteCommand ();
 	void doTabCompletion ();
@@ -92,8 +90,6 @@
 private:
 friend class RKConsolePart;
 	bool eventFilter (QObject *o, QEvent *e);
-/** set syntax-highlighting for R */
-	void setRHighlighting ();
 	bool doTabCompletionHelper (int line_num, const QString &line, int word_start, int word_end, const QStringList &entries);
 /** a helper function to doTabCompletionHelper */
 	void insertCompletion (int line_num, int word_start, int word_end, const QString &completion);
@@ -154,12 +150,12 @@
 
 	bool tab_key_pressed_before;
 
-	KAction* context_help_action;
-	KAction* run_selection_action;
-	KAction* interrupt_command_action;
-	KAction* copy_action;
-	KAction* copy_literal_action;
-	KAction* paste_action;
+	QAction* context_help_action;
+	QAction* run_selection_action;
+	QAction* interrupt_command_action;
+	QAction* copy_action;
+	QAction* copy_literal_action;
+	QAction* paste_action;
 
 	void initializeActions (KActionCollection *ac);
 	void pipeCommandThroughConsoleLocal (RCommand *command);

Modified: branches/KDE4_port/rkward/robjectbrowser.cpp
===================================================================
--- branches/KDE4_port/rkward/robjectbrowser.cpp	2007-10-15 16:21:00 UTC (rev 2068)
+++ branches/KDE4_port/rkward/robjectbrowser.cpp	2007-10-15 19:37:09 UTC (rev 2069)
@@ -60,7 +60,7 @@
 	Q3VBoxLayout *layout = new Q3VBoxLayout (this);
 	layout_widget = new Q3VBox (this);
 	layout->addWidget (layout_widget);
-	layout_widget->setFocusPolicy (QWidget::StrongFocus);
+	layout_widget->setFocusPolicy (Qt::StrongFocus);
 
 	RKDummyPart *part = new RKDummyPart (this, layout_widget);
 	setPart (part);
@@ -104,7 +104,7 @@
 ///////////////////////// RObjectBrowserInternal /////////////////////////////
 RObjectBrowserInternal::RObjectBrowserInternal (QWidget *parent) : QWidget (parent) {
 	RK_TRACE (APP);
-	setFocusPolicy (QWidget::ClickFocus);
+	setFocusPolicy (Qt::ClickFocus);
 
 	Q3VBoxLayout *vbox = new Q3VBoxLayout (this);
 
@@ -143,7 +143,7 @@
 	RK_TRACE (APP);
 
 	list_view->setFocus ();
-	if (e->reason () != QFocusEvent::Mouse) {
+	if (e->reason () != Qt::MouseFocusReason) {
 		list_view->setObjectCurrent (RObjectList::getGlobalEnv (), true);
 	}
 }

Modified: branches/KDE4_port/rkward/robjectviewer.cpp
===================================================================
--- branches/KDE4_port/rkward/robjectviewer.cpp	2007-10-15 16:21:00 UTC (rev 2068)
+++ branches/KDE4_port/rkward/robjectviewer.cpp	2007-10-15 19:37:09 UTC (rev 2069)
@@ -23,6 +23,7 @@
 #include <qlabel.h>
 #include <q3textedit.h>
 #include <qfont.h>
+#include <QPushButton>
 //Added by qt3to4:
 #include <Q3VBoxLayout>
 #include <QCloseEvent>
@@ -53,7 +54,7 @@
 	wrapper->addChild (box);
 	layout->addWidget (wrapper);
 
-	wrapper->setFocusPolicy (QWidget::StrongFocus);
+	wrapper->setFocusPolicy (Qt::StrongFocus);
 	setPart (new RKDummyPart (this, wrapper));
 	initializeActivationSignals ();
 
@@ -76,7 +77,7 @@
 	connect (toggle_summary_button, SIGNAL (clicked ()), this, SLOT (toggleSummary ()));
 
 	summary_area = new Q3TextEdit (box);
-	summary_area->setTextFormat (PlainText);
+	summary_area->setTextFormat (Qt::PlainText);
 	summary_area->setReadOnly (true);
 	summary_area->setCurrentFont (font);
 	summary_area->setWordWrap (Q3TextEdit::NoWrap);
@@ -88,7 +89,7 @@
 	connect (toggle_print_button, SIGNAL (clicked ()), this, SLOT (togglePrint ()));
 
 	print_area = new Q3TextEdit (box);
-	print_area->setTextFormat (PlainText);
+	print_area->setTextFormat (Qt::PlainText);
 	print_area->setReadOnly (true);
 	print_area->setCurrentFont (font);
 	print_area->setWordWrap (Q3TextEdit::NoWrap);


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