[rkward-cvs] rkward/rkward/windows rkcommandeditorwindow.cpp,1.21,1.22 rkcommandeditorwindow.h,1.15,1.16 rkcommandeditorwindowpart.cpp,1.2,1.3 rkcommandeditorwindowpart.h,1.2,1.3

Thomas Friedrichsmeier tfry at users.sourceforge.net
Sat Sep 17 18:04:02 UTC 2005


Update of /cvsroot/rkward/rkward/rkward/windows
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27857/rkward/windows

Modified Files:
	rkcommandeditorwindow.cpp rkcommandeditorwindow.h 
	rkcommandeditorwindowpart.cpp rkcommandeditorwindowpart.h 
Log Message:
yet more cleanups

Index: rkcommandeditorwindowpart.cpp
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/windows/rkcommandeditorwindowpart.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** rkcommandeditorwindowpart.cpp	15 Sep 2005 21:03:27 -0000	1.2
--- rkcommandeditorwindowpart.cpp	17 Sep 2005 18:04:00 -0000	1.3
***************
*** 27,31 ****
  #include "../debug.h"
  
! RKCommandEditorWindowPart::RKCommandEditorWindowPart (QWidget *parent, RKCommandEditorWindow *editor_widget) : KParts::ReadWritePart (parent) {
  	RK_TRACE (COMMANDEDITOR);
  
--- 27,31 ----
  #include "../debug.h"
  
! RKCommandEditorWindowPart::RKCommandEditorWindowPart (QWidget *parent, RKCommandEditorWindow *editor_widget) : KParts::Part (parent) {
  	RK_TRACE (COMMANDEDITOR);
  
***************
*** 37,42 ****
  	setXMLFile ("rkcommandeditorwindowpart.rc");
  
- 	setReadWrite (true);
- 
  	initializeActions ();
  }
--- 37,40 ----
***************
*** 62,67 ****
  	RK_TRACE (COMMANDEDITOR);
  
! 	if (command_editor->getSelection ().isEmpty () || command_editor->getSelection ().isNull ())
! 		return;
  
  	RKGlobals::rInterface ()->issueCommand (new RCommand (command_editor->getSelection (), RCommand::User, ""));
--- 60,64 ----
  	RK_TRACE (COMMANDEDITOR);
  
! 	if (command_editor->getSelection ().isEmpty () || command_editor->getSelection ().isNull ()) return;
  
  	RKGlobals::rInterface ()->issueCommand (new RCommand (command_editor->getSelection (), RCommand::User, ""));
***************
*** 71,76 ****
  	RK_TRACE (COMMANDEDITOR);
  
! 	if (command_editor->getLine ().isEmpty () || command_editor->getLine().isNull ())
! 		return;
  
  	RKGlobals::rInterface ()->issueCommand (new RCommand (command_editor->getLine (), RCommand::User, ""));
--- 68,72 ----
  	RK_TRACE (COMMANDEDITOR);
  
! 	if (command_editor->getLine ().isEmpty () || command_editor->getLine().isNull ()) return;
  
  	RKGlobals::rInterface ()->issueCommand (new RCommand (command_editor->getLine (), RCommand::User, ""));
***************
*** 81,86 ****
  	RK_TRACE (COMMANDEDITOR);
  
! 	if (command_editor->getText ().isEmpty () || command_editor->getText ().isNull ())
! 		return;
  		
  	RKGlobals::rInterface ()->issueCommand (new RCommand (command_editor->getText (), RCommand::User, ""));
--- 77,81 ----
  	RK_TRACE (COMMANDEDITOR);
  
! 	if (command_editor->getText ().isEmpty () || command_editor->getText ().isNull ()) return;
  		
  	RKGlobals::rInterface ()->issueCommand (new RCommand (command_editor->getText (), RCommand::User, ""));

Index: rkcommandeditorwindow.cpp
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/windows/rkcommandeditorwindow.cpp,v
retrieving revision 1.21
retrieving revision 1.22
diff -C2 -d -r1.21 -r1.22
*** rkcommandeditorwindow.cpp	15 Sep 2005 21:03:27 -0000	1.21
--- rkcommandeditorwindow.cpp	17 Sep 2005 18:04:00 -0000	1.22
***************
*** 76,80 ****
  
  	m_view->setName("Kate Part View");
! 	if (use_r_highlighting) setRHighlighting(m_doc);
  }
  
--- 76,80 ----
  
  	m_view->setName("Kate Part View");
! 	if (use_r_highlighting) setRHighlighting ();
  }
  
***************
*** 85,95 ****
  
  
! void RKCommandEditorWindow::setRHighlighting (Kate::Document *doc) {
  	// set syntax-highlighting for R
! 	int modes_count = highlightingInterface (doc)->hlModeCount ();
  	bool found_mode = false;
  	int i;
  	for (i = 0; i < modes_count; ++i) {
! 		if (highlightingInterface (doc)->hlModeName (i).lower() == "r script") {
  			found_mode = true;
  			break;
--- 85,95 ----
  
  
! void RKCommandEditorWindow::setRHighlighting () {
  	// 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).lower() == "r script") {
  			found_mode = true;
  			break;
***************
*** 97,101 ****
  	}
  	if (found_mode) {
! 		highlightingInterface (doc)->setHlMode (i);
  	} else {
  		RK_DO (qDebug ("No syntax highlighting definition found for r script."), COMMANDEDITOR, DL_WARNING);
--- 97,101 ----
  	}
  	if (found_mode) {
! 		highlightingInterface (m_doc)->setHlMode (i);
  	} else {
  		RK_DO (qDebug ("No syntax highlighting definition found for r script."), COMMANDEDITOR, DL_WARNING);
***************
*** 104,126 ****
  
  
! 
! 
! 
! 
! QString RKCommandEditorWindow::getSelection()
! {
!     	RK_TRACE (COMMANDEDITOR);
! 	return selectionInterface(m_doc)->selection();
  }
  
! QString RKCommandEditorWindow::getLine()
! {
!     	RK_TRACE (COMMANDEDITOR);
! 	return m_view->currentTextLine();
  }
  
! QString RKCommandEditorWindow::getText()
! {
! 	return editInterface(m_doc)->text();
  }
  
--- 104,119 ----
  
  
! QString RKCommandEditorWindow::getSelection () {
! 	RK_TRACE (COMMANDEDITOR);
! 	return selectionInterface (m_doc)->selection ();
  }
  
! QString RKCommandEditorWindow::getLine () {
! 	RK_TRACE (COMMANDEDITOR);
! 	return m_view->currentTextLine ();
  }
  
! QString RKCommandEditorWindow::getText () {
! 	return editInterface (m_doc)->text ();
  }
  
***************
*** 128,132 ****
  bool RKCommandEditorWindow::openURL (const KURL &url, bool use_r_highlighting, bool read_only){
  	if (m_doc->openURL (url)){
! 		if (use_r_highlighting) setRHighlighting (m_doc);
  		m_doc->setReadWrite (!read_only);
  
--- 121,125 ----
  bool RKCommandEditorWindow::openURL (const KURL &url, bool use_r_highlighting, bool read_only){
  	if (m_doc->openURL (url)){
! 		if (use_r_highlighting) setRHighlighting ();
  		m_doc->setReadWrite (!read_only);
  
***************
*** 138,171 ****
  }
  
- bool RKCommandEditorWindow::getFilenameAndPath(const KURL &url,QString *fname){
- 	QString fullpath = url.path();
- 	int i,length,fnamepos;
- 	bool done;
- 	
- 	if ((length = (int)fullpath.length()) == 0)
- 		return false;
- 
- 	fnamepos = 0;
- 	for (i = length-1,done = false ; i >= 0 && !done ; i--){
- 		if (fullpath[i] == '/'){
- 			done = true;
- 			fnamepos = i+1;
- 		}
- 	}
- 
- 	if (!done)
- 		return false;
- 	
- 	if (fnamepos >= length)
- 		return false;
- 
- 	if (fname)
- 		*fname = fullpath.right(length-fnamepos);
- 
- 	return true;
- }
- 
- 
- 
  bool RKCommandEditorWindow::isModified() {
      return m_doc->isModified();
--- 131,134 ----
***************
*** 173,179 ****
  
  
! void RKCommandEditorWindow::insertText(QString text)
! {
! 	m_doc->insertText(m_view->cursorLine(),m_view->cursorColumn(),text);
  	setFocus();
  }
--- 136,141 ----
  
  
! void RKCommandEditorWindow::insertText (const QString &text) {
! 	m_doc->insertText (m_view->cursorLine  (), m_view->cursorColumn (), text);
  	setFocus();
  }
***************
*** 181,191 ****
  
  
! void RKCommandEditorWindow::updateTabCaption(const KURL &url)
! {
! 	QString fname;
! 	if (getFilenameAndPath(url,&fname)){
  		setTabCaption(fname);
! 	}
! 	else {
  		setTabCaption(url.prettyURL());
  	}
--- 143,151 ----
  
  
! void RKCommandEditorWindow::updateTabCaption (const KURL &url) {
! 	QString fname = url.fileName ();
! 	if (!fname.isEmpty ()) {
  		setTabCaption(fname);
! 	} else {
  		setTabCaption(url.prettyURL());
  	}
***************
*** 203,213 ****
  
  	QString line=m_view->currentTextLine() + " ";
! 	if(line.isEmpty() || line.isNull())
! 		return;
  	
  	
  	// We want to match any valid R name, that is, everything composed of letters, 0-9, '.'s and '_'s..
! 	QRegExp rx( "[^A-Za-z0-9'.''_']" );
! 	QRegExp rx2( "[A-Za-z0-9'.''_']" );
  	
  	QStringList list=QStringList::split(rx,line);
--- 163,172 ----
  
  	QString line=m_view->currentTextLine() + " ";
! 	if (line.isEmpty () || line.isNull ()) return;
  	
  	
  	// We want to match any valid R name, that is, everything composed of letters, 0-9, '.'s and '_'s..
! 	QRegExp rx( "[^A-Za-z0-9\\._]" );
! 	QRegExp rx2( "[A-Za-z0-9\\._]" );
  	
  	QStringList list=QStringList::split(rx,line);
***************
*** 230,242 ****
  
  	
! 	if(result=="" && !line.isEmpty()){
  		//There is only one word on this line
! 		result=line;
  	}
  		
! 	chain=0;
! 	QString s="help(\"";
! 	s.append(result);
! 	s.append("\", htmlhelp=TRUE)[1]");
  	
  	RKGlobals::rInterface ()->issueCommand (s, RCommand::App | RCommand::Sync | RCommand::GetStringVector, "", this, GET_HELP_URL, chain);
--- 189,199 ----
  
  	
! 	if(result == "" && !line.isEmpty()){
  		//There is only one word on this line
! 		result = line;
  	}
  		
! 	chain = 0;
! 	QString s = "help(\"" + result + "\", htmlhelp=TRUE)[1]";
  	
  	RKGlobals::rInterface ()->issueCommand (s, RCommand::App | RCommand::Sync | RCommand::GetStringVector, "", this, GET_HELP_URL, chain);

Index: rkcommandeditorwindowpart.h
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/windows/rkcommandeditorwindowpart.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** rkcommandeditorwindowpart.h	15 Sep 2005 21:03:27 -0000	1.2
--- rkcommandeditorwindowpart.h	17 Sep 2005 18:04:00 -0000	1.3
***************
*** 29,33 ****
  @author Thomas Friedrichsmeier
  */
! class RKCommandEditorWindowPart : public KParts::ReadWritePart {
  	Q_OBJECT
  public:
--- 29,33 ----
  @author Thomas Friedrichsmeier
  */
! class RKCommandEditorWindowPart : public KParts::Part {
  	Q_OBJECT
  public:
***************
*** 51,57 ****
  
  	KAction* helpFunction;
- protected:
- 	bool openFile () { return false; };
- 	bool saveFile () { return false; };
  };
  
--- 51,54 ----

Index: rkcommandeditorwindow.h
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/windows/rkcommandeditorwindow.h,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** rkcommandeditorwindow.h	15 Sep 2005 11:50:03 -0000	1.15
--- rkcommandeditorwindow.h	17 Sep 2005 18:04:00 -0000	1.16
***************
*** 21,33 ****
  #include <qstring.h>
  
- 
  #include <kate/view.h>
  #include <kate/document.h>
! 
  #include <kmdichildview.h>
  
  #include "../rbackend/rcommandreceiver.h"
  
- #include <kurl.h>
  
  class RKCommandEditor;
--- 21,31 ----
  #include <qstring.h>
  
  #include <kate/view.h>
  #include <kate/document.h>
! #include <kurl.h>
  #include <kmdichildview.h>
  
  #include "../rbackend/rcommandreceiver.h"
  
  
  class RKCommandEditor;
***************
*** 42,48 ****
  While being called RKCommandEditorWindow, this class handles all sort of text-files, both read/write and read-only. It is an MDI child that is added to the main window, based on KatePart.
  
- TODO: find out, whether save (), saveAs (), and some others are still needed. Clean up includes after that.
- TODO: once ShowEditTextFileWindow is done, derive this class from that.
- 
  @author Pierre Ecochard
  */
--- 40,43 ----
***************
*** 51,75 ****
  	Q_OBJECT
  public:
!     RKCommandEditorWindow (QWidget *parent = 0, bool use_r_highlighting=true);
! 
!     ~RKCommandEditorWindow();
!     QString getSelection();
!     QString getLine();
!     QString getText();
!     bool openURL(const KURL &url, bool use_r_highlighting=true, bool read_only=false);
!     bool isModified();
!     void insertText(QString text);
!     /** Show help about the current word. */
!     void showHelp();
!     void rCommandDone (RCommand *command);
  private:
  	Kate::Document *m_doc;
  	Kate::View *m_view;
! 	
! 	void setRHighlighting (Kate::Document *doc);
! 	bool getFilenameAndPath(const KURL &url,QString *fname);
! private:
!     void updateTabCaption(const KURL &url);
!     RCommandChain *chain;
  };
  
--- 46,82 ----
  	Q_OBJECT
  public:
! /** constructor
! @param use_r_highlighting Initialize the view to use R syntax highlighting. Use, if you're going to edit an R syntax file */
! 	RKCommandEditorWindow (QWidget *parent = 0, bool use_r_highlighting=true);
! /** destructor */
! 	~RKCommandEditorWindow ();
! /** return text of current selection */
! 	QString getSelection();
! /** return text in current line */
! 	QString getLine();
! /** return entire text */
! 	QString getText();
! /** open given URL. 
! @param use_r_highlighting Initialize the view to use R syntax highlighting. Use, if you're going to edit an R syntax file
! @param read_only Open the file in read-only mode */
! 	bool openURL (const KURL &url, bool use_r_highlighting=true, bool read_only=false);
! /** returns, whether the document was modified since the last save */
! 	bool isModified ();
! /** insert the given text into the document at the current cursor position. Additionally, focuses the view */
! 	void insertText (const QString &text);
! /** Show help about the current word. */
! 	void showHelp();
! /** re-implemented from \ref RCommandReceiver. */
! 	void rCommandDone (RCommand *command);
  private:
  	Kate::Document *m_doc;
  	Kate::View *m_view;
! 
! /** set syntax highlighting-mode to R syntax */
! 	void setRHighlighting ();
! 
! /** update Tab caption according to the given url. Display the filename-component of the URL, or - if not available - a more elaborate description of the url */
! 	void updateTabCaption(const KURL &url);
! 	RCommandChain *chain;
  };
  





More information about the rkward-tracker mailing list