[rkward-cvs] rkward/rkward rkeditormanager.cpp,1.12,1.13 rkeditormanager.h,1.7,1.8 rkward.cpp,1.110,1.111

Thomas Friedrichsmeier tfry at users.sourceforge.net
Fri Oct 21 15:23:38 UTC 2005


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

Modified Files:
	rkeditormanager.cpp rkeditormanager.h rkward.cpp 
Log Message:
Make windows detachable. Some more work needs to be done, but basically functioning

Index: rkward.cpp
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/rkward.cpp,v
retrieving revision 1.110
retrieving revision 1.111
diff -C2 -d -r1.110 -r1.111
*** rkward.cpp	20 Oct 2005 19:45:54 -0000	1.110
--- rkward.cpp	21 Oct 2005 15:23:36 -0000	1.111
***************
*** 74,77 ****
--- 74,78 ----
  #include "windows/rkhtmlwindow.h"
  #include "windows/rcontrolwindow.h"
+ #include "windows/detachedwindowcontainer.h"
  #include "khelpdlg.h"
  #include "rkconsole.h"
***************
*** 343,346 ****
--- 344,349 ----
  void RKwardApp::openWorkspace (const KURL &url) {
  	RK_TRACE (APP);
+ 	if (url.isEmpty ()) return;
+ 
  	new RKLoadAgent (url, false);
  	fileOpenRecentWorkspace->addURL (url);
***************
*** 463,470 ****
  	}
  
  	QValueList<KMdiChildView *> child_copy;
! 	for(KMdiChildView *w = m_pDocumentViews->first ();w;w= m_pDocumentViews->next ()){
  		child_copy.append (w);
  	}
  	QValueListIterator<KMdiChildView *> childIt;
  	for (childIt = child_copy.begin (); childIt != child_copy.end (); ++childIt) {
--- 466,479 ----
  	}
  
+ // generate a (copy) list of all child views (detached or not)
  	QValueList<KMdiChildView *> child_copy;
! 	for (KMdiChildView *w = m_pDocumentViews->first ();w;w= m_pDocumentViews->next ()){
  		child_copy.append (w);
  	}
+ 	for (KMdiChildView *w = DetachedWindowContainer::detachedWindows ()->first (); w; w = DetachedWindowContainer::detachedWindows ()->next ()) {
+ 		child_copy.append (w);
+ 	}
+ 
+ // try to close all the children
  	QValueListIterator<KMdiChildView *> childIt;
  	for (childIt = child_copy.begin (); childIt != child_copy.end (); ++childIt) {
***************
*** 645,654 ****
  	RK_TRACE (APP);
  
! 	if (activeWindow ()) {
! 		detachWindow (activeWindow ());
  	}
  }
  
- 
  void RKwardApp::newOutput () {
  	RK_TRACE (APP);
--- 654,672 ----
  	RK_TRACE (APP);
  
! 	KMdiChildView *window = activeWindow ();
! 	if (window) {
! 		KParts::Part *part = m_manager->activePart ();
! 		if (part) {
! 			m_manager->removePart (part);
! 			removeWindowFromMdi (window);
! 			m_pDocumentViews->remove (window);			// WORKAROUND: shouldn't this happen automatically in the above call? Apparently not so.
! 			DetachedWindowContainer *detached = new DetachedWindowContainer (part, window);
! 			detached->show ();
! 		} else{
! 			RK_ASSERT (false);
! 		}
  	}
  }
  
  void RKwardApp::newOutput () {
  	RK_TRACE (APP);
***************
*** 708,725 ****
  void RKwardApp::slotChildWindowCloseRequest (KMdiChildView * window) {
  	RK_TRACE (APP);
- 	//If it's an unsaved command editor window, there is a warning.
- 	// TODO: it's sort of ugly, having to handle this here. Can't we somehow handle it in RKCommandEditorWindow instead?
- 	if (window->inherits("RKCommandEditorWindow")) {
- 		RKCommandEditorWindow * editor = (RKCommandEditorWindow*) window;
- 		if (editor->isModified()) {
- 			int status = KMessageBox::warningYesNo(this,i18n("The document \"%1\" has been modified. Close it anyway?").arg(editor->tabCaption()),i18n("File not saved"));
- 	
- 			if (status != KMessageBox::Yes) {
- 				return;
- 			}
- 		}
- 	}
  
! 	closeWindow(window);
  }
  
--- 726,731 ----
  void RKwardApp::slotChildWindowCloseRequest (KMdiChildView * window) {
  	RK_TRACE (APP);
  
! 	closeWindow (window);
  }
  

Index: rkeditormanager.h
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/rkeditormanager.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** rkeditormanager.h	16 Sep 2005 16:08:11 -0000	1.7
--- rkeditormanager.h	21 Oct 2005 15:23:36 -0000	1.8
***************
*** 31,35 ****
  
  /**
! This class is used to manage open editor windows. For now, it will arrange opened editors in a tabbook. Later it will also be responsible for docking/undocking editors, etc. This class does only GUI-related stuff. It knows nothing about the types of editors and the data they hold.
  
  @author Thomas Friedrichsmeier
--- 31,35 ----
  
  /**
! This class is used to manage open editor windows. It is used to do some generic functions, like notifying the backend, when an editor window has been closed. Also (and perhaps most importantly), it contains a function editObject (), which will open any editable RObject with the editor capable to do so.
  
  @author Thomas Friedrichsmeier
***************
*** 43,60 ****
  
  	RKEditor *editObject (RObject *object, bool initialize_to_empty=false);
! /// tries to open the editors/objects that were last opened
  	void restoreEditors ();
  	
! 	void closeEditor (RKEditor *editor);
  
  	void flushAll ();
  	void closeAll ();
! 	
  	bool canEditObject (RObject *object);
  
! /// returns the currently active editor
  	void setEditorName (RKEditor *editor, const QString &new_name);
- public slots:
- 	void editorDestroyed (QObject* editor);
  protected:
  	void rCommandDone (RCommand *command);
--- 43,59 ----
  
  	RKEditor *editObject (RObject *object, bool initialize_to_empty=false);
! /** tries to open the editors/objects that were last opened (in the previous session) */
  	void restoreEditors ();
  	
! 	void closedEditor (RKEditor *editor);
  
  	void flushAll ();
  	void closeAll ();
! 
! /** is an editor availble for the type of object given? */
  	bool canEditObject (RObject *object);
  
! /** set the name (caption) of an editor */
  	void setEditorName (RKEditor *editor, const QString &new_name);
  protected:
  	void rCommandDone (RCommand *command);

Index: rkeditormanager.cpp
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/rkeditormanager.cpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** rkeditormanager.cpp	20 Oct 2005 18:42:37 -0000	1.12
--- rkeditormanager.cpp	21 Oct 2005 15:23:36 -0000	1.13
***************
*** 107,111 ****
  }
  
! void RKEditorManager::closeEditor (RKEditor *editor) {
  	RK_TRACE (APP);
  	
--- 107,111 ----
  }
  
! void RKEditorManager::closedEditor (RKEditor *editor) {
  	RK_TRACE (APP);
  	
***************
*** 113,117 ****
  	
  	RObject *object = editor->getObject ();
! 	editor->close ();
  
  	RCommand *command = new RCommand (".rk.editor.closed (" + object->getFullName() + ")", RCommand::App | RCommand::Sync);
--- 113,119 ----
  	
  	RObject *object = editor->getObject ();
! 	object->setObjectOpened (editor, false);
! 	QValueList<RKEditor*>::iterator it = editors.find (editor);
! 	if (it != editors.end ()) editors.erase (it);
  
  	RCommand *command = new RCommand (".rk.editor.closed (" + object->getFullName() + ")", RCommand::App | RCommand::Sync);
***************
*** 135,139 ****
  		RKEditor *ed = *it;
  		++it;
! 		ed->close ();			// will be removed from list of editors in editorDestroyed ()
  	}
  }
--- 137,141 ----
  		RKEditor *ed = *it;
  		++it;
! 		ed->close ();			// will be removed from list of editors in closedEditor ()
  	}
  }
***************
*** 164,180 ****
  	part->getEditor ()->setFocus ();		// somehow we need to call this explicitely
  	editors.append (part->getEditor ());
- 	connect (part->getEditor (), SIGNAL (destroyed (QObject*)), this, SLOT (editorDestroyed (QObject*)));
  
  	return part->getEditor ();
  }
  
- void RKEditorManager::editorDestroyed (QObject* editor) {
- 	RK_TRACE (APP);
- 
- 	RKEditor *ed = static_cast<RKEditor*> (editor);
- 	QValueList<RKEditor*>::iterator it = editors.find (ed);
- 	if (it != editors.end ()) editors.erase (it);
- 
- }
- 
  #include "rkeditormanager.moc"
--- 166,172 ----





More information about the rkward-tracker mailing list