[rkward-cvs] rkward/rkward rkward.cpp,1.49,1.50 rkward.h,1.23,1.24 rkwardui.rc,1.12,1.13

Pierre ecoch at users.sourceforge.net
Tue Nov 2 18:51:32 UTC 2004


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

Modified Files:
	rkward.cpp rkward.h rkwardui.rc 
Log Message:
Integration of the command editor in the main window. There are still bugs, but main functionalities are there.

Index: rkward.cpp
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/rkward.cpp,v
retrieving revision 1.49
retrieving revision 1.50
diff -C2 -d -r1.49 -r1.50
*** rkward.cpp	25 Oct 2004 15:43:14 -0000	1.49
--- rkward.cpp	2 Nov 2004 18:51:27 -0000	1.50
***************
*** 105,108 ****
--- 105,117 ----
    editCopy->setEnabled(false);
    editPaste->setEnabled(false); */
+   		editUndo->setEnabled(false);
+ 		editRedo->setEnabled(false);
+ 		fileOpen->setEnabled(false);
+ 		fileSave->setEnabled(false);
+ 		fileSaveAs->setEnabled(false);
+ 		runAll->setEnabled(false);
+ 		runSelection->setEnabled(false);
+ 		fileOpenRecent->setEnabled(false);
+ 
  
  
***************
*** 110,113 ****
--- 119,123 ----
  	RKGlobals::manager = new RKEditorManager ();
  	KMdiChildView * editorManagerView = createWrapper(RKGlobals::editorManager (), i18n( "Object Editor"), i18n( "R Object Editor"));
+ 	editorManagerView->setIcon(SmallIcon("inline_table"));
  	addWindow( editorManagerView );
  	
***************
*** 115,120 ****
  
  	
! 	
! 	
  	connect (RKGlobals::editorManager (), SIGNAL (editorClosed ()), this, SLOT (slotEditorsChanged ()));
  	connect (RKGlobals::editorManager (), SIGNAL (editorOpened ()), this, SLOT (slotEditorsChanged ()));
--- 125,132 ----
  
  	
! 	connect (this, SIGNAL (childWindowCloseRequest (KMdiChildView *)), this, SLOT (slotChildWindowCloseRequest (KMdiChildView *)));
! 	connect (this, SIGNAL (viewActivated (KMdiChildView *)), this, SLOT (slotViewActivated (KMdiChildView *)));
! 
! 
  	connect (RKGlobals::editorManager (), SIGNAL (editorClosed ()), this, SLOT (slotEditorsChanged ()));
  	connect (RKGlobals::editorManager (), SIGNAL (editorOpened ()), this, SLOT (slotEditorsChanged ()));
***************
*** 126,129 ****
--- 138,143 ----
  	startup_timer->start (50);
  	connect (startup_timer, SIGNAL (timeout ()), this, SLOT (doPostInit ()));
+ 	
+ 
  }
  
***************
*** 161,170 ****
  		setCaption(i18n ("Untitled"));
  		
! 		StartupDialog::StartupDialogResult *result = StartupDialog::getStartupAction (this, fileOpenRecent);
  		if (result->result == StartupDialog::EmptyWorkspace) {
  		} else if (result->result == StartupDialog::OpenFile) {
  			openWorkspace (result->open_url);
  		} else if (result->result == StartupDialog::ChoseFile) {
! 			slotFileOpen ();
  		} else if (result->result == StartupDialog::EmptyTable) {
  			RObject *object = RKGlobals::rObjectList ()->createNewChild (i18n ("my.data"), 0, true, true);
--- 175,184 ----
  		setCaption(i18n ("Untitled"));
  		
! 		StartupDialog::StartupDialogResult *result = StartupDialog::getStartupAction (this, fileOpenRecentWorkspace);
  		if (result->result == StartupDialog::EmptyWorkspace) {
  		} else if (result->result == StartupDialog::OpenFile) {
  			openWorkspace (result->open_url);
  		} else if (result->result == StartupDialog::ChoseFile) {
! 			slotFileOpenWorkspace ();
  		} else if (result->result == StartupDialog::EmptyTable) {
  			RObject *object = RKGlobals::rObjectList ()->createNewChild (i18n ("my.data"), 0, true, true);
***************
*** 293,304 ****
  	// TODO: is there a way to insert actions between standard actions without having to give all standard actions custom ids?
  	new_data_frame = new KAction (i18n ("data.frame"), 0, 0, this, SLOT (slotNewDataFrame ()), actionCollection (), "new_data_frame");
! 	fileOpen = KStdAction::open(this, SLOT(slotFileOpen()), actionCollection(), "file_openx");
! 	fileOpen->setText (i18n ("Open Workspace"));
! 	fileOpenRecent = KStdAction::openRecent(this, SLOT(slotFileOpenRecent(const KURL&)), actionCollection(), "file_open_recentx");
  	file_load_libs = new KAction (i18n ("Load R Libraries"), 0, 0, this, SLOT (slotFileLoadLibs ()), actionCollection (), "file_load_libs");
- 	fileSave = KStdAction::save(this, SLOT(slotFileSave()), actionCollection(), "file_savex");
- 	fileSave->setText (i18n ("Save Workspace"));
- 	fileSaveAs = KStdAction::saveAs(this, SLOT(slotFileSaveAs()), actionCollection(), "file_save_asx");
- 	fileSaveAs->setText (i18n ("Save Workspace As"));
  	close_editor = KStdAction::close (this, SLOT(slotCloseEditor ()), actionCollection(), "editor_close");
  	close_editor->setText (i18n ("Close current editor"));
--- 307,329 ----
  	// TODO: is there a way to insert actions between standard actions without having to give all standard actions custom ids?
  	new_data_frame = new KAction (i18n ("data.frame"), 0, 0, this, SLOT (slotNewDataFrame ()), actionCollection (), "new_data_frame");
! 	new_command_editor = KStdAction::openNew(this, SLOT(slotNewCommandEditor()), actionCollection(), "new_command_editor");
! 	new_command_editor->setText (i18n ("New Command File"));
! 	
! 	fileOpen = KStdAction::open(this, SLOT(slotOpenCommandEditor()), actionCollection(), "file_openy");
! 	fileOpen->setText (i18n ("Open Command File"));
! 	fileOpenRecent = KStdAction::openRecent(this, SLOT(slotOpenRecentCommandEditor(const KURL&)), actionCollection(), "file_open_recenty");
! 	fileSave = KStdAction::save(this, SLOT(slotSaveCommandEditor()), actionCollection(), "file_savey");
! 	fileSave->setText (i18n ("Save Command File"));
! 	fileSaveAs = KStdAction::saveAs(this, SLOT(slotSaveCommandEditorAs()), actionCollection(), "file_save_asy");
! 	fileSaveAs->setText (i18n ("Save Command File As"));
! 	
! 	fileOpenWorkspace = KStdAction::open(this, SLOT(slotFileOpenWorkspace()), actionCollection(), "file_openx");
! 	fileOpenWorkspace->setText (i18n ("Open Workspace"));
! 	fileOpenRecentWorkspace = KStdAction::openRecent(this, SLOT(slotFileOpenRecentWorkspace(const KURL&)), actionCollection(), "file_open_recentx");
! 	fileSaveWorkspace = KStdAction::save(this, SLOT(slotFileSaveWorkspace()), actionCollection(), "file_savex");
! 	fileSaveWorkspace->setText (i18n ("Save Workspace"));
! 	fileSaveWorkspaceAs = KStdAction::saveAs(this, SLOT(slotFileSaveWorkspaceAs()), actionCollection(), "file_save_asx");
! 	fileSaveWorkspaceAs->setText (i18n ("Save Workspace As"));
  	file_load_libs = new KAction (i18n ("Load R Libraries"), 0, 0, this, SLOT (slotFileLoadLibs ()), actionCollection (), "file_load_libs");
  	close_editor = KStdAction::close (this, SLOT(slotCloseEditor ()), actionCollection(), "editor_close");
  	close_editor->setText (i18n ("Close current editor"));
***************
*** 309,316 ****
  	filePrint->setEnabled (false);
  	fileQuit = KStdAction::quit(this, SLOT(slotFileQuit()), actionCollection(), "file_quitx");
! 	
!   editCut = KStdAction::cut(this, SLOT(slotEditCut()), actionCollection());
!   editCopy = KStdAction::copy(this, SLOT(slotEditCopy()), actionCollection());
!   editPaste = KStdAction::paste(this, SLOT(slotEditPaste()), actionCollection());
    editPasteToTable = new KAction(i18n("Paste inside Table"), 0, 0, this, SLOT(slotEditPasteToTable()), actionCollection(), "paste_to_table");
    editPasteToSelection = new KAction(i18n("Paste inside Selection"), 0, 0, this, SLOT(slotEditPasteToSelection()), actionCollection(), "paste_to_selection");
--- 334,343 ----
  	filePrint->setEnabled (false);
  	fileQuit = KStdAction::quit(this, SLOT(slotFileQuit()), actionCollection(), "file_quitx");
! 
!   editUndo = KStdAction::undo(this, SLOT(slotEditUndo()), actionCollection(), "undo");
!   editRedo = KStdAction::redo(this, SLOT(slotEditRedo()), actionCollection(), "redo");	
!   editCut = KStdAction::cut(this, SLOT(slotEditCut()), actionCollection(), "cut");
!   editCopy = KStdAction::copy(this, SLOT(slotEditCopy()), actionCollection(), "copy");
!   editPaste = KStdAction::paste(this, SLOT(slotEditPaste()), actionCollection(), "paste");
    editPasteToTable = new KAction(i18n("Paste inside Table"), 0, 0, this, SLOT(slotEditPasteToTable()), actionCollection(), "paste_to_table");
    editPasteToSelection = new KAction(i18n("Paste inside Selection"), 0, 0, this, SLOT(slotEditPasteToSelection()), actionCollection(), "paste_to_selection");
***************
*** 321,331 ****
  	showRKOutput = new KToggleAction (i18n ("Show Output-Window"), 0, 0, this, SLOT(slotShowRKOutput ()), actionCollection(), "windows_rkoutput");
  	showRObjectBrowser = new KToggleAction (i18n ("Show Object Browser-Window"), 0, 0, this, SLOT(slotShowRObjectBrowser ()), actionCollection(), "windows_robjectbrowser");
  	configure = new KAction (i18n ("Configure Settings"), 0, 0, this, SLOT(slotConfigure ()), actionCollection(), "configure");
  
  	new_data_frame->setStatusText (i18n ("Creates a new empty data.frame and opens it for editing"));
!   fileOpen->setStatusText(i18n("Opens an existing document"));
!   fileOpenRecent->setStatusText(i18n("Opens a recently used file"));
!   fileSave->setStatusText(i18n("Saves the actual document"));
!   fileSaveAs->setStatusText(i18n("Saves the actual document as..."));
  	close_editor->setStatusText (i18n ("Closes the current data editor"));
  	close_all_editors->setStatusText (i18n ("Closes all open data editors"));
--- 348,363 ----
  	showRKOutput = new KToggleAction (i18n ("Show Output-Window"), 0, 0, this, SLOT(slotShowRKOutput ()), actionCollection(), "windows_rkoutput");
  	showRObjectBrowser = new KToggleAction (i18n ("Show Object Browser-Window"), 0, 0, this, SLOT(slotShowRObjectBrowser ()), actionCollection(), "windows_robjectbrowser");
+ 	
+ 	runAll = new KAction (i18n ("Run All"), 0, 0, this, SLOT (slotRunAll ()), actionCollection (), "run_all");
+ 	runSelection = new KAction (i18n ("Run Selection"), 0, 0, this, SLOT (slotRunSelection ()), actionCollection (), "run_selection");
+ 	
+ 	
  	configure = new KAction (i18n ("Configure Settings"), 0, 0, this, SLOT(slotConfigure ()), actionCollection(), "configure");
  
  	new_data_frame->setStatusText (i18n ("Creates a new empty data.frame and opens it for editing"));
!   fileOpenWorkspace->setStatusText(i18n("Opens an existing document"));
!   fileOpenRecentWorkspace->setStatusText(i18n("Opens a recently used file"));
!   fileSaveWorkspace->setStatusText(i18n("Saves the actual document"));
!   fileSaveWorkspaceAs->setStatusText(i18n("Saves the actual document as..."));
  	close_editor->setStatusText (i18n ("Closes the current data editor"));
  	close_all_editors->setStatusText (i18n ("Closes all open data editors"));
***************
*** 341,345 ****
    
    // use the absolute path to your rkwardui.rc file for testing purpose in createGUI();
!   setXMLFile( "rkwardui.rc" );
    createShellGUI ( true );
  
--- 373,377 ----
    
    // use the absolute path to your rkwardui.rc file for testing purpose in createGUI();
!   setXMLFile( "/home/pierre/rkward/rkward/rkward/rkwardui.rc" );
    createShellGUI ( true );
  
***************
*** 362,366 ****
  	RK_TRACE (APP);
  	new RKLoadAgent (url, false);
! 	fileOpenRecent->addURL (url);
  }
  
--- 394,398 ----
  	RK_TRACE (APP);
  	new RKLoadAgent (url, false);
! 	fileOpenRecentWorkspace->addURL (url);
  }
  
***************
*** 376,380 ****
  	RKSettings::saveSettings (config);
  	
!   fileOpenRecent->saveEntries(config,"Recent Files");
  }
  
--- 408,412 ----
  	RKSettings::saveSettings (config);
  	
!   fileOpenRecentWorkspace->saveEntries(config,"Recent Files");
  }
  
***************
*** 408,412 ****
    
    // initialize the recent file list
!   fileOpenRecent->loadEntries(config,"Recent Files");
  
  	// do this last, since we may be setting some different config-group(s) in the process
--- 440,444 ----
    
    // initialize the recent file list
!   fileOpenRecentWorkspace->loadEntries(config,"Recent Files");
  
  	// do this last, since we may be setting some different config-group(s) in the process
***************
*** 467,470 ****
--- 499,518 ----
  bool RKwardApp::queryClose () {
  	RK_TRACE (APP);
+ 	
+ 	/*QValueList<KMdiChildView *> children;
+ 	for(KMdiChildView *w = m_pDocumentViews->first();w;w= m_pDocumentViews->next()){
+ 		children.append(w);
+ 	}
+ 	QValueListIterator<KMdiChildView *> childIt;
+ 	for (childIt = children.begin(); childIt != children.end(); ++childIt) {
+ 		if ((*childIt)->inherits("RKCommandEditorWindow") ) {
+ 			if (! (*childIt)->close()) {
+ 				//If a child refuses to close, we return false.
+ 				return false;
+ 			}
+ 		}
+ 	}*/
+ 	
+ 	
  	if (RKGlobals::rObjectList ()->isEmpty ()) return true;
  
***************
*** 538,547 ****
  }
  
! void RKwardApp::slotFileOpen () {
  	RK_TRACE (APP);
  	fileOpenAskSave ("");
  }
  
! void RKwardApp::slotFileOpenRecent(const KURL& url)
  {
  	RK_TRACE (APP);
--- 586,595 ----
  }
  
! void RKwardApp::slotFileOpenWorkspace () {
  	RK_TRACE (APP);
  	fileOpenAskSave ("");
  }
  
! void RKwardApp::slotFileOpenRecentWorkspace(const KURL& url)
  {
  	RK_TRACE (APP);
***************
*** 555,564 ****
  }
  
! void RKwardApp::slotFileSave () {
  	RK_TRACE (APP);
  	new RKSaveAgent (RKGlobals::rObjectList ()->getWorkspaceURL ());
  }
  
! void RKwardApp::slotFileSaveAs () {
  	RK_TRACE (APP);
  	new RKSaveAgent (RKGlobals::rObjectList ()->getWorkspaceURL (), true);
--- 603,612 ----
  }
  
! void RKwardApp::slotFileSaveWorkspace () {
  	RK_TRACE (APP);
  	new RKSaveAgent (RKGlobals::rObjectList ()->getWorkspaceURL ());
  }
  
! void RKwardApp::slotFileSaveWorkspaceAs () {
  	RK_TRACE (APP);
  	new RKSaveAgent (RKGlobals::rObjectList ()->getWorkspaceURL (), true);
***************
*** 601,618 ****
  {
  	RK_TRACE (APP);
! 	slotStatusMsg(i18n("Cutting selection..."));
! 	slotEditCopy ();
! 	RKGlobals::editorManager ()->currentEditor ()->clearSelected ();
! 	slotStatusMsg(i18n("Ready."));
  }
  
  void RKwardApp::slotEditCopy() {
  	RK_TRACE (APP);
! 
! 	slotStatusMsg(i18n("Copying selection to clipboard..."));
! 
! 	QApplication::clipboard()->setData(RKGlobals::editorManager ()->currentEditor ()->makeDrag ());
! 
! 	slotStatusMsg(i18n("Ready."));
  }
  
--- 649,673 ----
  {
  	RK_TRACE (APP);
! 	if (! activeWindow()->inherits("RKCommandEditorWindow")) {
! 		slotStatusMsg(i18n("Cutting selection..."));
! 		slotEditCopy ();
! 		RKGlobals::editorManager ()->currentEditor ()->clearSelected ();
! 		slotStatusMsg(i18n("Ready."));
! 	}
! 	else {
! 		((RKCommandEditorWindow*) activeWindow())->cut();
! 	}
  }
  
  void RKwardApp::slotEditCopy() {
  	RK_TRACE (APP);
! 	if (! activeWindow()->inherits("RKCommandEditorWindow")) {
! 		slotStatusMsg(i18n("Copying selection to clipboard..."));
! 		QApplication::clipboard()->setData(RKGlobals::editorManager ()->currentEditor ()->makeDrag ());
! 		slotStatusMsg(i18n("Ready."));
! 	}
! 	else {
! 		((RKCommandEditorWindow*) activeWindow())->copy();
! 	}
  }
  
***************
*** 636,646 ****
  
  void RKwardApp::slotEditPaste() {
! 	RK_TRACE (APP);
! 	RKGlobals::editorManager ()->currentEditor ()->setPasteMode (RKEditor::PasteEverywhere);
!  	doPaste ();
  }
  
  void RKwardApp::slotEditPasteToTable() {
  	RK_TRACE (APP);
  	RKGlobals::editorManager ()->currentEditor ()->setPasteMode (RKEditor::PasteToTable);
  	doPaste();
--- 691,710 ----
  
  void RKwardApp::slotEditPaste() {
! 	if (! activeWindow()->inherits("RKCommandEditorWindow")) {
! 		RK_TRACE (APP);
! 		RKGlobals::editorManager ()->currentEditor ()->setPasteMode (RKEditor::PasteEverywhere);
!  		doPaste ();
! 	}
! 	else {
! 		((RKCommandEditorWindow*) activeWindow())->paste();
! 	}
  }
  
  void RKwardApp::slotEditPasteToTable() {
  	RK_TRACE (APP);
+ 	if (activeWindow()->inherits("RKCommandEditorWindow"))
+ 		return;
+ 		
+ 	
  	RKGlobals::editorManager ()->currentEditor ()->setPasteMode (RKEditor::PasteToTable);
  	doPaste();
***************
*** 648,651 ****
--- 712,718 ----
  void RKwardApp::slotEditPasteToSelection() {
  	RK_TRACE (APP);
+ 	if (activeWindow()->inherits("RKCommandEditorWindow"))
+ 		return;		
+ 
  	RKGlobals::editorManager ()->currentEditor ()->setPasteMode (RKEditor::PasteToSelection);
  	doPaste();
***************
*** 745,746 ****
--- 812,1059 ----
  	}
  }
+ 
+ 
+ 
+ void RKwardApp::slotNewCommandEditor(){
+ 	RKCommandEditorWindow *editor = new RKCommandEditorWindow;
+ 	editor->setIcon(SmallIcon("source"));
+ 	editor->name("RCEditor");
+ 	addWindow(editor);
+ 	
+ }
+ 
+ 
+ void RKwardApp::slotOpenURL(const KURL &url){
+ 	RKCommandEditorWindow *editor;
+ 	
+ 	if (!url.isLocalFile())
+ 	{
+ 		KMessageBox::messageBox(this,KMessageBox::Information,
+ 				"The file you specified is not a local file","Cannot open file");
+ 		return;
+ 	}
+ 	
+ 	editor = new RKCommandEditorWindow;
+ 	
+ 	if (!editor->openURL(url))
+ 	{
+ 		QString errstr = "Unable to open ";
+ 		
+ 		errstr += url.prettyURL();
+ 		
+ 		KMessageBox::messageBox(this,KMessageBox::Error,
+ 				errstr,"Error!");
+ 		delete editor;
+ 		return;
+ 	}
+ 	
+ 
+ 	editor->setIcon(SmallIcon("source"));
+ 	editor->name("RCEditor");
+ 	addWindow(editor);
+ 	
+ 
+ };
+ 
+ void RKwardApp::slotOpenCommandEditor(){
+ 	KURL::List urls;
+ 	KURL::List::const_iterator it;
+ 	
+ 	KFileDialog dlg(QString("."),QString("*.R *.r"),this,i18n("Open file"),true);
+ 	
+ 	dlg.setOperationMode(KFileDialog::Opening);
+ 	dlg.setMode(KFile::Files);
+ 	if (dlg.exec() == QDialog::Rejected)
+ 		return;
+ 	
+ 	urls = dlg.selectedURLs();
+ 	for (it = urls.begin() ; it != urls.end() ; ++it)
+ 		slotOpenURL(*it);
+ 
+ };
+ 
+ 
+ void RKwardApp::slotSaveCommandEditor(){
+ 
+ 	if (! activeWindow()->inherits("RKCommandEditorWindow"))
+ 		return;
+ 
+ 
+ 	RKCommandEditorWindow *editor;
+ 	KURL url;
+ 	QString strURL;
+ 	
+ 	editor = (RKCommandEditorWindow *)activeWindow();
+ 	if (!editor)
+ 		return;
+ 	url = editor->url();
+ 	strURL = url.url();
+ 	
+ 	if (strURL.length() == 0) // was a new document
+ 		saveAsProcedure(editor);
+ 	else
+ 	{
+ 		if (!editor->save())
+ 			KMessageBox::messageBox(this,KMessageBox::Information,i18n("Could not save document"),i18n("Warning"));
+ 	}
+ };
+ void RKwardApp::slotSaveCommandEditorAs(){
+ 	if (! activeWindow()->inherits("RKCommandEditorWindow"))
+ 		return;
+ 		
+ 	RKCommandEditorWindow *editor;
+ 	
+ 	editor = (RKCommandEditorWindow *)activeWindow();
+ 	if (editor == 0)
+ 		return;
+ 	saveAsProcedure(editor);
+ };
+ 
+ void RKwardApp::slotCloseCommandEditor(){
+ 	if (! activeWindow()->inherits("RKCommandEditorWindow"))
+ 		return;
+ 	
+ 	activeWindow()->close();
+ };
+ 
+ 
+ void RKwardApp::saveAsProcedure(RKCommandEditorWindow *editor)
+ {
+ 	KFileDialog dlg(QString("."),QString("*.R *.r"),this,i18n("Save file"),true);
+ 	KURL url;
+ 	QString fname;
+ 		
+ 	dlg.setOperationMode(KFileDialog::Saving);
+ 	if (dlg.exec() == QDialog::Rejected)
+ 		return;
+ 	url = dlg.selectedURL();
+ 	if (editor->saveAs(url))
+ 	{
+ 		if (getFilenameAndPath(url,&fname))
+ 			editor->setTabCaption(fname);	
+ 		else
+ 			editor->setTabCaption(url.prettyURL());
+ 	}
+ 	else
+ 		KMessageBox::messageBox(this,KMessageBox::Information,i18n("Could not save document"),i18n("Warning"));
+ }
+ 
+ 
+ bool RKwardApp::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;
+ }
+ 
+ 
+ 
+ void RKwardApp::slotChildWindowCloseRequest (KMdiChildView * window) {
+ 	//If it's an unsaved command editor window, there is a warning.
+ 	if (window->inherits("RKCommandEditorWindow")) 	{
+ 		RKCommandEditorWindow * editor = (RKCommandEditorWindow*) window;
+ 		if (editor->isModified()) {
+ 			int status = KMessageBox::warningYesNo(this,i18n("The document has been modified. Close anyway?"),i18n("File not saved"));
+ 	
+ 			if (status == KMessageBox::Yes) {
+ 				window->hide();
+ 				delete window;
+ 			}
+ 		}
+ 		else {
+ 			window->hide();
+ 			delete window;	
+ 		}
+ 		
+ 
+ 		
+ 	}
+ }
+ 
+ 
+ 
+ 
+ void RKwardApp::slotRunSelection() {
+ 	if (! activeWindow()->inherits("RKCommandEditorWindow"))
+ 		return;
+ 		
+ 	RKGlobals::rInterface ()->issueCommand (new RCommand ( ((RKCommandEditorWindow*) activeWindow())->getSelection(), RCommand::User, ""));
+ }
+ 
+ 
+ 
+ void RKwardApp::slotRunAll() {
+ 	if (! activeWindow()->inherits("RKCommandEditorWindow"))
+ 		return;
+ 		
+ 	RKGlobals::rInterface ()->issueCommand (new RCommand ( ((RKCommandEditorWindow*) activeWindow())->getText(), RCommand::User, ""));
+ }
+ 
+ 
+ 
+ void RKwardApp::slotEditUndo()
+ {
+ 	if (! activeWindow()->inherits("RKCommandEditorWindow"))
+ 		return;
+ 	((RKCommandEditorWindow*) activeWindow())->undo();
+ }
+ 
+ 
+ 
+ void RKwardApp::slotEditRedo()
+ {
+ 	if (! activeWindow()->inherits("RKCommandEditorWindow"))
+ 		return;
+ 	((RKCommandEditorWindow*) activeWindow())->redo();
+ }
+ 
+ 
+ 
+ void RKwardApp::slotViewActivated (KMdiChildView * window)
+ {
+ 	if (window->inherits("RKCommandEditorWindow")) {
+ 		editUndo->setEnabled(true);
+ 		editRedo->setEnabled(true);
+ 		fileOpen->setEnabled(true);
+ 		fileSave->setEnabled(true);
+ 		fileSaveAs->setEnabled(true);
+ 		runAll->setEnabled(true);
+ 		runSelection->setEnabled(true);
+ 		fileOpenRecent->setEnabled(true);
+ 	}
+ 	else {
+ 		editUndo->setEnabled(false);
+ 		editRedo->setEnabled(false);
+ 		fileOpen->setEnabled(false);
+ 		fileSave->setEnabled(false);
+ 		fileSaveAs->setEnabled(false);
+ 		runAll->setEnabled(false);
+ 		runSelection->setEnabled(false);
+ 		fileOpenRecent->setEnabled(false);
+ 	}
+ }

Index: rkward.h
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/rkward.h,v
retrieving revision 1.23
retrieving revision 1.24
diff -C2 -d -r1.23 -r1.24
*** rkward.h	25 Oct 2004 15:43:14 -0000	1.23
--- rkward.h	2 Nov 2004 18:51:30 -0000	1.24
***************
*** 2,6 ****
                            rkward.h  -  description
                               -------------------
!     begin                : Tue Oct 29 20:06:08 CET 2002
      copyright            : (C) 2002 by Thomas Friedrichsmeier 
      email                : tfry at users.sourceforge.net
--- 2,6 ----
                            rkward.h  -  description
                               -------------------
!     begin                : Tue Oct 29 20:06:08 CET 2002 
      copyright            : (C) 2002 by Thomas Friedrichsmeier 
      email                : tfry at users.sourceforge.net
***************
*** 47,50 ****
--- 47,51 ----
  class RKMenuList;
  class RKDocManager;
+ class RKCommandEditorWindow;
  
  /**
***************
*** 122,132 ****
  	void slotNewDataFrame ();
      /** open a file and load it into the document*/
!     void slotFileOpen();
      /** opens a file from the recent files menu */
!     void slotFileOpenRecent(const KURL& url);
      /** save a document */
!     void slotFileSave();
      /** save a document by a new filename*/
!     void slotFileSaveAs();
  	/** shows the dialog to install/load/unload packages */
  	void slotFileLoadLibs ();
--- 123,133 ----
  	void slotNewDataFrame ();
      /** open a file and load it into the document*/
!     void slotFileOpenWorkspace();
      /** opens a file from the recent files menu */
!     void slotFileOpenRecentWorkspace(const KURL& url);
      /** save a document */
!     void slotFileSaveWorkspace();
      /** save a document by a new filename*/
!     void slotFileSaveWorkspaceAs();
  	/** shows the dialog to install/load/unload packages */
  	void slotFileLoadLibs ();
***************
*** 190,193 ****
--- 191,207 ----
  	
  	void slotEditorsChanged ();
+ 	
+ 	void slotNewCommandEditor();
+ 	void slotOpenCommandEditor();
+ 	void slotSaveCommandEditor();
+ 	void slotSaveCommandEditorAs();
+ 	void slotCloseCommandEditor();
+ 	void slotOpenURL(const KURL &url);
+     void slotChildWindowCloseRequest (KMdiChildView * window);
+     void slotRunSelection();
+     void slotRunAll();
+     void slotEditUndo();
+     void slotEditRedo();
+     void slotViewActivated (KMdiChildView *window);
    private:
      /** the configuration object of the application */
***************
*** 205,208 ****
--- 219,227 ----
      KAction* fileSave;
      KAction* fileSaveAs;
+     
+     KAction* fileOpenWorkspace;
+     KRecentFilesAction* fileOpenRecentWorkspace;
+     KAction* fileSaveWorkspace;
+     KAction* fileSaveWorkspaceAs;
      KAction* filePrint;
      KAction* fileQuit;
***************
*** 211,214 ****
--- 230,237 ----
  	KAction* close_all_editors;
  	KAction* new_data_frame;
+ 	KAction* new_command_editor;
+ 	
+ 	KAction* editUndo;
+ 	KAction* editRedo;
  	KAction* editCut;
      KAction* editCopy;
***************
*** 222,225 ****
--- 245,252 ----
  	KToggleAction* showRKOutput;
  	KToggleAction* showRObjectBrowser;
+ 	
+ 	KAction* runAll;
+ 	KAction* runSelection;
+ 	
  	KAction* configure;
  
***************
*** 249,252 ****
--- 276,284 ----
  	friend class RInterface;
  	void setRStatus (bool busy);
+ 	
+ 	bool getFilenameAndPath(const KURL &url,QString *fname);
+ 	void saveAsProcedure(RKCommandEditorWindow *editor);
+ signals:
+     void childWindowCloseRequest(KMdiChildView * window);
  };
   

Index: rkwardui.rc
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/rkwardui.rc,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** rkwardui.rc	6 Sep 2004 16:50:30 -0000	1.12
--- rkwardui.rc	2 Nov 2004 18:51:30 -0000	1.13
***************
*** 5,28 ****
  		<Menu name="new_data"><text>&Create New</text>
  			<Action name="new_data_frame"/>
  		</Menu>
  		<Separator/>
  		<Action name="file_openx"/>
  		<Action name="file_open_recentx"/>
- 		<Action name="file_load_libs"/>
- 		<Separator/>
  		<Action name="file_savex"/>
  		<Action name="file_save_asx"/>
  		<Separator/>
! 		<Action name="file_printx"/>
  		<Separator/>
! 		<Action name="editor_close"/>
! 		<Action name="close_all_editors"/>
  		<Separator/>
  		<Action name="file_quitx"/>
  	</Menu>
! 	<Menu name="edit"><text>&Edit</text>
  		<Action name="paste_to_selection"/>
  		<Action name="paste_to_table"/>
  	</Menu>
  	<Menu name="settings"><text>&Settings</text>
  		<Action name="configure"></Action>
--- 5,50 ----
  		<Menu name="new_data"><text>&Create New</text>
  			<Action name="new_data_frame"/>
+ 			<Action name="new_command_editor"/>
  		</Menu>
+ 		<Merge/> 
+ 		<Separator/>
+ 		<Action name="file_openy"/>
+ 		<Action name="file_open_recenty"/>
+ 		<Action name="file_savey"/>
+ 		<Action name="file_save_asy"/>
  		<Separator/>
  		<Action name="file_openx"/>
  		<Action name="file_open_recentx"/>
  		<Action name="file_savex"/>
  		<Action name="file_save_asx"/>
  		<Separator/>
! 		<Action name="file_load_libs"/>
  		<Separator/>
! 		<Action name="file_printx"/>
  		<Separator/>
  		<Action name="file_quitx"/>
  	</Menu>
! 	
! 	
! 	<Menu name="edit" noMerge="1"><text>&Edit</text>
! 		<Action name="undo"/>
! 		<Action name="redo"/>
! 		<Separator/>
! 		<Action name="cut"/>
! 		<Action name="copy"/>
! 		<Action name="paste"/>
! 		<Separator/>
  		<Action name="paste_to_selection"/>
  		<Action name="paste_to_table"/>
  	</Menu>
+   
+ 	<Menu name="run"><text>&Run</text>
+ 		<Separator/>
+ 		<Action name="run_all"/>
+ 		<Action name="run_selection"/>
+ 		<Separator/>
+ 		<Action name="interrupt"/>
+ 	</Menu>   
+  
  	<Menu name="settings"><text>&Settings</text>
  		<Action name="configure"></Action>
***************
*** 35,38 ****
--- 57,61 ----
  		<Action name="windows_robjectbrowser"/>
  	</Menu>
+  	<Merge/>
  </MenuBar>
  </kpartgui>





More information about the rkward-tracker mailing list