[rkward-cvs] rkward/rkward rkward.cpp,1.120,1.121 rkward.h,1.52,1.53

Thomas Friedrichsmeier tfry at users.sourceforge.net
Sun Nov 13 19:07:42 UTC 2005


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

Modified Files:
	rkward.cpp rkward.h 
Log Message:
Some further statusbar corrections. Some code cleanups

Index: rkward.cpp
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/rkward.cpp,v
retrieving revision 1.120
retrieving revision 1.121
diff -C2 -d -r1.120 -r1.121
*** rkward.cpp	10 Nov 2005 15:59:05 -0000	1.120
--- rkward.cpp	13 Nov 2005 19:07:40 -0000	1.121
***************
*** 76,80 ****
  #include "debug.h"
  
- #define ID_STATUS_MSG 1
  #define ID_R_STATUS_MSG 2
  
--- 76,79 ----
***************
*** 97,102 ****
  	///////////////////////////////////////////////////////////////////
  	// call inits to invoke all other construction parts
- 	initStatusBar();
  	initActions();
  
  	///////////////////////////////////////////////////////////////////
--- 96,101 ----
  	///////////////////////////////////////////////////////////////////
  	// call inits to invoke all other construction parts
  	initActions();
+ 	initStatusBar();
  
  	///////////////////////////////////////////////////////////////////
***************
*** 125,128 ****
--- 124,129 ----
  	// the builder updates (recreates) the GUI
  	connect (m_manager, SIGNAL (activePartChanged (KParts::Part *)), this, SLOT (createGUI (KParts::Part *)));
+ 	connect (m_manager, SIGNAL (partAdded (KParts::Part *)), this, SLOT (partAdded (KParts::Part *)));
+ 	connect (m_manager, SIGNAL (partRemoved (KParts::Part *)), this, SLOT (partRemoved (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 *)));
***************
*** 213,222 ****
  
  	setCaption (QString::null);	// our version of setCaption takes care of creating a correct caption, so we do not need to provide it here
- 	show ();
  }
  
  void RKwardApp::initPlugins () {
  	RK_TRACE (APP);
! 	slotStatusMsg(i18n("Setting up plugins..."));
  	
  	factory ()->removeClient (RKGlobals::componentMap ());
--- 214,222 ----
  
  	setCaption (QString::null);	// our version of setCaption takes care of creating a correct caption, so we do not need to provide it here
  }
  
  void RKwardApp::initPlugins () {
  	RK_TRACE (APP);
! 	slotSetStatusBarText(i18n("Setting up plugins..."));
  	
  	factory ()->removeClient (RKGlobals::componentMap ());
***************
*** 235,239 ****
  	factory ()->addClient (RKGlobals::componentMap ());
  
! 	slotStatusReady ();
  }
  
--- 235,239 ----
  	factory ()->addClient (RKGlobals::componentMap ());
  
! 	slotSetStatusReady ();
  }
  
***************
*** 285,293 ****
  	fileSaveWorkspaceAs->setText (i18n ("Save Workspace As"));
  
! 	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");	
  
  	setStandardToolBarMenuEnabled (true);
! 	viewStatusBar = KStdAction::showStatusbar(this, SLOT (slotViewStatusBar()), actionCollection());
  
  	close_all_editors = new KAction (i18n ("Close All Data"), 0, 0, this, SLOT (slotCloseAllEditors ()), actionCollection (), "close_all_editors");
--- 285,293 ----
  	fileSaveWorkspaceAs->setText (i18n ("Save Workspace As"));
  
! 	fileQuit = KStdAction::quit(this, SLOT(close ()), actionCollection(), "file_quitx");
  	file_load_libs = new KAction (i18n ("Configure Packages"), 0, 0, this, SLOT (slotFileLoadLibs ()), actionCollection (), "file_load_libs");	
  
  	setStandardToolBarMenuEnabled (true);
! 	createStandardStatusBarAction ();
  
  	close_all_editors = new KAction (i18n ("Close All Data"), 0, 0, this, SLOT (slotCloseAllEditors ()), actionCollection (), "close_all_editors");
***************
*** 306,321 ****
  	close_all_editors->setStatusText (i18n ("Closes all open data editors"));
  	fileQuit->setStatusText(i18n("Quits the application"));
! 	viewStatusBar->setStatusText(i18n("Enables/disables the statusbar"));
  }
  
  
! void RKwardApp::initStatusBar()
! {
  	RK_TRACE (APP);
! 	///////////////////////////////////////////////////////////////////
! 	// STATUSBAR
! 	// TODO: add your own items you need for displaying current application status.
! 	statusBar()->insertItem(i18n("Ready."), ID_STATUS_MSG);
! 	statusBar()->insertItem(i18n("starting R engine"), ID_R_STATUS_MSG);
  }
  
--- 306,345 ----
  	close_all_editors->setStatusText (i18n ("Closes all open data editors"));
  	fileQuit->setStatusText(i18n("Quits the application"));
! 
! 	actionCollection ()->setHighlightingEnabled (true);
  }
  
+ void RKwardApp::partAdded (KParts::Part *part) {
+ 	RK_TRACE (APP);
  
! 	if (!part->actionCollection ()) {
! 		RK_ASSERT (false);
! 		return;
! 	}
! 
! 	part->actionCollection ()->setHighlightingEnabled (true);
! 	connect (part->actionCollection (), SIGNAL (actionStatusText (const QString &)), this, SLOT (slotSetStatusBarText (const QString &)));
! 	connect (part->actionCollection (), SIGNAL (clearStatusText ()), this, SLOT (slotSetStatusReady ()));
! }
! 
! void RKwardApp::partRemoved (KParts::Part *part) {
  	RK_TRACE (APP);
! 
! 	if (!part->actionCollection ()) {
! 		RK_ASSERT (false);
! 		return;
! 	}
! 
! 	disconnect (part->actionCollection (), SIGNAL (actionStatusText (const QString &)), this, SLOT (slotSetStatusBarText (const QString &)));
! 	disconnect (part->actionCollection (), SIGNAL (clearStatusText ()), this, SLOT (slotSetStatusReady ()));
! }
! 
! void RKwardApp::initStatusBar () {
! 	RK_TRACE (APP);
! 
! 	statusBar()->insertItem (i18n ("starting R engine"), ID_R_STATUS_MSG, 0, true);
! 
! 	connect (actionCollection (), SIGNAL (actionStatusText (const QString &)), this, SLOT (slotSetStatusBarText (const QString &)));
! 	connect (actionCollection (), SIGNAL (clearStatusText ()), this, SLOT (slotSetStatusReady ()));
  }
  
***************
*** 328,348 ****
  }
  
! void RKwardApp::saveOptions () {	
  	RK_TRACE (APP);
  	KConfig *config = kapp->config ();
  
! 	config->setGroup("General Options");
! 	config->writeEntry("Geometry", size());
! //	config->writeEntry("Show Toolbar", viewToolBar->isChecked());
! 	config->writeEntry("Show Statusbar",viewStatusBar->isChecked());
! 	config->writeEntry("ToolBarPos", (int) toolBar("mainToolBar")->barPos());
! /*	config->writeEntry("EditBarPos", (int) toolBar("editToolBar")->barPos());
! 	config->writeEntry("RunBarPos", (int) toolBar("runToolBar")->barPos()); */
  
! 	RKSettings::saveSettings (config);
! 	
  	fileOpenRecentWorkspace->saveEntries(config, "Recent Files");
  	fileOpenRecent->saveEntries(config, "Recent Command Files");
  
  	config->sync ();
  }
--- 352,369 ----
  }
  
! void RKwardApp::saveOptions () {
  	RK_TRACE (APP);
  	KConfig *config = kapp->config ();
  
! 	saveMainWindowSettings (config, "main window options");
  
! 	config->setGroup("General Options");
! // TODO: WORKAROUND. See corresponding line in readOptions ()
! 	config->writeEntry("Geometry", size ());
  	fileOpenRecentWorkspace->saveEntries(config, "Recent Files");
  	fileOpenRecent->saveEntries(config, "Recent Command Files");
  
+ 	RKSettings::saveSettings (config);
+ 
  	config->sync ();
  }
***************
*** 352,379 ****
  	RK_TRACE (APP);
  	KConfig *config = kapp->config ();
- 	
- 	config->setGroup("General Options");
- 	
- 	// bar status settings
- //	viewToolBar->setChecked (config->readBoolEntry ("Show Toolbar", true));
  
! 	viewStatusBar->setChecked (config->readBoolEntry ("Show Statusbar", true));
! 	slotViewStatusBar();
  
! 	// bar position settings
! 	toolBar("mainToolBar")->setBarPos ((KToolBar::BarPosition) config->readNumEntry ("ToolBarPos", KToolBar::Top));
! /*	toolBar("editToolBar")->setBarPos ((KToolBar::BarPosition) config->readNumEntry ("EditBarPos", KToolBar::Top));
! 	toolBar("runToolBar")->setBarPos ((KToolBar::BarPosition) config->readNumEntry("RunBarPos", KToolBar::Top)); */
! //	delete toolBar ("KMdiTaskBar");
! 	
! 	QSize size=config->readSizeEntry("Geometry");
  	if(!size.isEmpty ()) {
  		resize (size);
  	}
! 	
  	// initialize the recent file list
  	fileOpenRecentWorkspace->loadEntries (config,"Recent Files");
  	fileOpenRecent->loadEntries (config,"Recent Command Files");
! 	
  	// do this last, since we may be setting some different config-group(s) in the process
  	RKSettings::loadSettings (config);
--- 373,390 ----
  	RK_TRACE (APP);
  	KConfig *config = kapp->config ();
  
! 	applyMainWindowSettings (kapp->config (), "main window options", true);
  
! // TODO: WORKAROUND: Actually applyMainWindowSettings could/should do this, but apparently this just does not work for maximized windows. Therefore we use our own version instead.
! 	config->setGroup("General Options");
! 	QSize size=config->readSizeEntry ("Geometry");
  	if(!size.isEmpty ()) {
  		resize (size);
  	}
! 
  	// initialize the recent file list
  	fileOpenRecentWorkspace->loadEntries (config,"Recent Files");
  	fileOpenRecent->loadEntries (config,"Recent Command Files");
! 
  	// do this last, since we may be setting some different config-group(s) in the process
  	RKSettings::loadSettings (config);
***************
*** 432,436 ****
  	RK_TRACE (APP);
  
! 	slotStatusMsg (i18n ("Exiting..."));
  	saveOptions ();
  
--- 443,447 ----
  	RK_TRACE (APP);
  
! 	slotSetStatusBarText (i18n ("Exiting..."));
  	saveOptions ();
  
***************
*** 441,445 ****
  			new RKSaveAgent (RKGlobals::rObjectList ()->getWorkspaceURL (), false, RKSaveAgent::Quit);
  		} else if (res != KMessageBox::No) {
! 			slotStatusReady ();
  			return false;
  		}
--- 452,456 ----
  			new RKSaveAgent (RKGlobals::rObjectList ()->getWorkspaceURL (), false, RKSaveAgent::Quit);
  		} else if (res != KMessageBox::No) {
! 			slotSetStatusReady ();
  			return false;
  		}
***************
*** 460,464 ****
  		if (!(*childIt)->close ()) {
  			// If a child refuses to close, we return false.
! 			slotStatusReady ();
  			return false;
  		}
--- 471,475 ----
  		if (!(*childIt)->close ()) {
  			// If a child refuses to close, we return false.
! 			slotSetStatusReady ();
  			return false;
  		}
***************
*** 498,502 ****
  	slotCloseAllEditors ();
  
! 	slotStatusMsg(i18n("Opening workspace..."));
  	KURL lurl = url;
  	if (lurl.isEmpty ()) {
--- 509,513 ----
  	slotCloseAllEditors ();
  
! 	slotSetStatusBarText(i18n("Opening workspace..."));
  	KURL lurl = url;
  	if (lurl.isEmpty ()) {
***************
*** 506,510 ****
  		openWorkspace (lurl);
  	}
! 	slotStatusReady ();
  }
  
--- 517,521 ----
  		openWorkspace (lurl);
  	}
! 	slotSetStatusReady ();
  }
  
***************
*** 553,576 ****
  }
  
! 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);
! }
! 
! void RKwardApp::slotStatusReady () {
  	RK_TRACE (APP);
  
! 	slotStatusMsg (i18n ("Ready"));
  }
  
--- 564,577 ----
  }
  
! void RKwardApp::slotSetStatusBarText (const QString &text) {
  	RK_TRACE (APP);
  
! 	QString ntext = text.stripWhiteSpace ();
! 	ntext.replace ("<qt>", "");	// WORKAROUND: what the ?!? is going on? The KTHMLPart seems to post such messages.
! 	if (ntext.isEmpty ()) {
! 		statusBar ()->message (i18n ("Ready."));
! 	} else {
! 		statusBar ()->message (ntext);
! 	}
  }
  

Index: rkward.h
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/rkward.h,v
retrieving revision 1.52
retrieving revision 1.53
diff -C2 -d -r1.52 -r1.53
*** rkward.h	10 Nov 2005 15:59:05 -0000	1.52
--- rkward.h	13 Nov 2005 19:07:40 -0000	1.53
***************
*** 154,170 ****
  	/** close all editor windows */
  	void slotCloseAllEditors ();
! 	/** 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.
! 	*/
! 	void slotFileQuit();
! 	/** toggles the statusbar
! 	*/
! 	void slotViewStatusBar();
! 	/** changes the statusbar contents for the standard label permanently, used to indicate current actions.
  	* @param text the text that is displayed in the statusbar
  	*/
! 	void slotStatusMsg(const QString &text);
! /** changes the status-message to "Ready". See \ref slotStatusMsg (). */
! 	void slotStatusReady ();
  
  /** configures RKward-settings */
--- 154,163 ----
  	/** close all editor windows */
  	void slotCloseAllEditors ();
! 	/** Reimplemented from KParts::MainWindow to be more pretty
  	* @param text the text that is displayed in the statusbar
  	*/
! 	void slotSetStatusBarText (const QString &text);
! /** Basically a shortcut to slotSetStatusBarText (QString::null). Needed as a slot without parameters. */
! 	void slotSetStatusReady () { slotSetStatusBarText (QString::null); };
  
  /** configures RKward-settings */
***************
*** 199,202 ****
--- 192,200 ----
  /** 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);
+ 
+ /** connected to m_manager->partAdded (). Connects statusbar notifications */
+ 	void partAdded (KParts::Part *part);
+ /** connected to m_manager->partAdded (). Disconnects statusbar notifications */
+ 	void partRemoved (KParts::Part *part);
  private:
  	// KAction pointers to enable/disable actions
***************
*** 219,224 ****
  	KAction* outputShow;
  
- 	KToggleAction* viewStatusBar;
- 
  	KAction* window_close;
  	KAction* window_close_all;
--- 217,220 ----





More information about the rkward-tracker mailing list