[rkward-cvs] rkward/rkward rkward.cpp,1.119,1.120 rkward.h,1.51,1.52

Thomas Friedrichsmeier tfry at users.sourceforge.net
Thu Nov 10 15:59:07 UTC 2005


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

Modified Files:
	rkward.cpp rkward.h 
Log Message:
Some code cleanups, and keep window captions up to date

Index: rkward.cpp
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/rkward.cpp,v
retrieving revision 1.119
retrieving revision 1.120
diff -C2 -d -r1.119 -r1.120
*** rkward.cpp	9 Nov 2005 22:53:26 -0000	1.119
--- rkward.cpp	10 Nov 2005 15:59:05 -0000	1.120
***************
*** 125,128 ****
--- 125,131 ----
  	// the builder updates (recreates) the GUI
  	connect (m_manager, SIGNAL (activePartChanged (KParts::Part *)), this, SLOT (createGUI (KParts::Part *)));
+ 	// a few calls to setCaption too many result from the lines below, but it seems to be the only way to catch all cases where the caption should be changed
+ 	connect (this, SIGNAL (viewActivated (KMdiChildView *)), this, SLOT (viewChanged (KMdiChildView *)));
+ 	connect (this, SIGNAL (viewDeactivated (KMdiChildView *)), this, SLOT (viewChanged (KMdiChildView *)));
  
  	if (!kapp->dcopClient ()->isRegistered ()) {
***************
*** 132,138 ****
  }
  
! void RKwardApp::activateGUI (KParts::Part *part) {
  	RK_TRACE (APP);
! 	createGUI (part);
  }
  
--- 135,143 ----
  }
  
! void RKwardApp::addWindow (KMdiChildView *view, int flags) {
  	RK_TRACE (APP);
! 
! 	KMdiMainFrm::addWindow (view, flags);
! 	connect (view, SIGNAL (windowCaptionChanged (const QString &)), this, SLOT (setCaption (const QString &)));
  }
  
***************
*** 193,198 ****
  		delete initial_url;
  	} else {
- 		setCaption(i18n ("Untitled"));
- 		
  		StartupDialog::StartupDialogResult *result = StartupDialog::getStartupAction (this, fileOpenRecentWorkspace);
  		if (result->result == StartupDialog::EmptyWorkspace) {
--- 198,201 ----
***************
*** 208,212 ****
  		delete result;
  	}
! 	
  	show ();
  }
--- 211,216 ----
  		delete result;
  	}
! 
! 	setCaption (QString::null);	// our version of setCaption takes care of creating a correct caption, so we do not need to provide it here
  	show ();
  }
***************
*** 281,286 ****
  	fileSaveWorkspaceAs->setText (i18n ("Save Workspace As"));
  
- 	filePrint = KStdAction::print(this, SLOT(slotFilePrint()), actionCollection(), "file_printx");
- 	filePrint->setEnabled (false);
  	fileQuit = KStdAction::quit(this, SLOT(slotFileQuit()), actionCollection(), "file_quitx");
  	file_load_libs = new KAction (i18n ("Configure Packages"), 0, 0, this, SLOT (slotFileLoadLibs ()), actionCollection (), "file_load_libs");	
--- 285,288 ----
***************
*** 303,307 ****
  	fileSaveWorkspaceAs->setStatusText(i18n("Saves the actual document as..."));
  	close_all_editors->setStatusText (i18n ("Closes all open data editors"));
- 	filePrint ->setStatusText(i18n("Prints out the actual document"));
  	fileQuit->setStatusText(i18n("Quits the application"));
  	viewStatusBar->setStatusText(i18n("Enables/disables the statusbar"));
--- 305,308 ----
***************
*** 416,420 ****
  //      doc->openDocument(_url);
        doc->setModified();
-       setCaption(_url.fileName(),true);
        QFile::remove(tempname);
      }
--- 417,420 ----
***************
*** 425,436 ****
      {
  //      doc->openDocument(url);
-       setCaption(url.fileName(),false);
      }
    } */
! }		
  
  bool RKwardApp::queryClose () {
  	RK_TRACE (APP);
  
  	if (!RKGlobals::rObjectList ()->isEmpty ()) {
  		int res;
--- 425,438 ----
      {
  //      doc->openDocument(url);
      }
    } */
! }
  
  bool RKwardApp::queryClose () {
  	RK_TRACE (APP);
  
+ 	slotStatusMsg (i18n ("Exiting..."));
+ 	saveOptions ();
+ 
  	if (!RKGlobals::rObjectList ()->isEmpty ()) {
  		int res;
***************
*** 439,442 ****
--- 441,445 ----
  			new RKSaveAgent (RKGlobals::rObjectList ()->getWorkspaceURL (), false, RKSaveAgent::Quit);
  		} else if (res != KMessageBox::No) {
+ 			slotStatusReady ();
  			return false;
  		}
***************
*** 457,460 ****
--- 460,464 ----
  		if (!(*childIt)->close ()) {
  			// If a child refuses to close, we return false.
+ 			slotStatusReady ();
  			return false;
  		}
***************
*** 464,473 ****
  }
  
- bool RKwardApp::queryExit () {
- 	RK_TRACE (APP);
- 	saveOptions ();
- 	return true;
- }
- 
  void RKwardApp::raiseWatch () {
  	RK_TRACE (APP);
--- 468,471 ----
***************
*** 555,605 ****
  }
  
- void RKwardApp::slotFilePrint()
- {
- 		RK_TRACE (APP);
- 	slotStatusMsg(i18n("Printing..."));
- 	
- 	QPrinter printer;
- 	if (printer.setup(this))
- 	{
- 	//    view->print(&printer);
- 	}
- 	
- 	slotStatusReady ();
- }
- 
  void RKwardApp::slotFileQuit () {
  	RK_TRACE (APP);
- 	slotStatusMsg(i18n("Exiting..."));
- 	saveOptions();
  	close ();
  }
  
! void RKwardApp::slotViewStatusBar()
! {
  	RK_TRACE (APP);
!   slotStatusMsg(i18n("Toggling statusbar..."));
!   ///////////////////////////////////////////////////////////////////
!   //turn Statusbar on or off
!   if(!viewStatusBar->isChecked())
!   {
!     statusBar()->hide();
!   }
!   else
!   {
!     statusBar()->show();
!   }
! 
!   slotStatusReady ();
  }
  
- 
  void RKwardApp::slotStatusMsg(const QString &text) {
  	RK_TRACE (APP);
  
!   ///////////////////////////////////////////////////////////////////
!   // change status message permanently
!   statusBar()->clear();
!   statusBar()->changeItem(text, ID_STATUS_MSG);
  }
  
--- 553,570 ----
  }
  
  void RKwardApp::slotFileQuit () {
  	RK_TRACE (APP);
  	close ();
  }
  
! void RKwardApp::slotViewStatusBar () {
  	RK_TRACE (APP);
! 	statusBar ()->setShown (viewStatusBar->isChecked ());
  }
  
  void RKwardApp::slotStatusMsg(const QString &text) {
  	RK_TRACE (APP);
  
! 	statusBar ()->changeItem (text, ID_STATUS_MSG);
  }
  
***************
*** 654,658 ****
  	RK_TRACE (APP);
  	if (busy) {
! 		statusBar()->changeItem(i18n ("R engine busy"), ID_R_STATUS_MSG);
  	} else {
  		statusBar ()->changeItem (i18n ("R engine idle"), ID_R_STATUS_MSG);
--- 619,623 ----
  	RK_TRACE (APP);
  	if (busy) {
! 		statusBar ()->changeItem(i18n ("R engine busy"), ID_R_STATUS_MSG);
  	} else {
  		statusBar ()->changeItem (i18n ("R engine idle"), ID_R_STATUS_MSG);
***************
*** 721,723 ****
--- 686,700 ----
  }
  
+ void RKwardApp::setCaption (const QString &) {
+ 	RK_TRACE (APP);
+ 
+ 	QString wcaption = RKGlobals::rObjectList ()->getWorkspaceURL ().fileName ();
+ 	if (wcaption.isEmpty ()) wcaption = RKGlobals::rObjectList ()->getWorkspaceURL ().prettyURL ();
+ 	if (wcaption.isEmpty ()) wcaption = i18n ("[Unnamed Workspace]");
+ 	if (activeWindow ()) {
+ 		wcaption.append (" - " + activeWindow ()->caption ());
+ 	}
+ 	KMdiMainFrm::setCaption (wcaption);
+ }
+ 
  #include "rkward.moc"

Index: rkward.h
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/rkward.h,v
retrieving revision 1.51
retrieving revision 1.52
diff -C2 -d -r1.51 -r1.52
*** rkward.h	19 Oct 2005 22:39:32 -0000	1.51
--- rkward.h	10 Nov 2005 15:59:05 -0000	1.52
***************
*** 104,110 ****
  
  	KParts::PartManager *m_manager;
- 
- /** it seems, sometimes, when creating a new part-object, we need to help the partmanager a little to notice... */
- 	void activateGUI (KParts::Part *part);
  protected:
  	void openWorkspace (const KURL &url);
--- 104,107 ----
***************
*** 125,135 ****
  	*/
  	virtual bool queryClose();
- 	/** queryExit is called by KTMainWindow when the last window of the application is going to be closed during the closeEvent().
- 	* Against the default implementation that just returns true, this calls saveOptions() to save the settings of the last window's	
- 	* properties.
- 	* @see KTMainWindow#queryExit
- 	* @see KTMainWindow#closeEvent
- 	*/
- 	virtual bool queryExit();
  	/** saves the window properties for each open window during session end to the session config file, including saving the currently
  	* opened file by a temporary filename provided by KApplication.
--- 122,125 ----
***************
*** 164,169 ****
  	/** close all editor windows */
  	void slotCloseAllEditors ();
- 	/** print the actual file */
- 	void slotFilePrint();
  	/** closes all open windows by calling close() on each memberList item until the list is empty, then quits the application.
  	* If queryClose() returns false because the user canceled the saveModified() dialog, the closing breaks.
--- 154,157 ----
***************
*** 205,208 ****
--- 193,202 ----
  /** ensure output window is shown. */
  	void slotOutputShow ();
+ /** reimplemented from KMainWindow, to additionally include the workspace url. Actually, we also ignore the caption-parameter, as it sometimes is not the one we want. Rather we create one according to the active view */
+ 	void setCaption (const QString &caption);
+ /** a view has been activated or deactivated. We should make sure to update the main caption to fix strange quirks */
+ 	void viewChanged (KMdiChildView *) { setCaption (QString::null); };
+ /** reimplemented from KMdiMainFrm to connect windowCaptionChanged to setCaption. It's beyond me, why the default implementation does not do this. */
+ 	void addWindow (KMdiChildView *view, int flags=KMdi::StandardAdd);
  private:
  	// KAction pointers to enable/disable actions
***************
*** 214,218 ****
  	KAction* fileSaveWorkspace;
  	KAction* fileSaveWorkspaceAs;
- 	KAction* filePrint;
  	KAction* fileQuit;
  	KAction* file_load_libs;
--- 208,211 ----





More information about the rkward-tracker mailing list