[rkward-cvs] rkward/rkward rkconsole.cpp,1.19,1.20 rkconsole.h,1.13,1.14 rkwatch.cpp,1.41,1.42

Thomas Friedrichsmeier tfry at users.sourceforge.net
Thu Nov 3 15:24:58 UTC 2005


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

Modified Files:
	rkconsole.cpp rkconsole.h rkwatch.cpp 
Log Message:
Significant performance improvements while processing immediate output. 1) Flush output at regular intervals and when needed, instead of always flushing small pieces. 2) setUpdatesEnabled (false) while removing superfluous lines in console/log

Index: rkwatch.cpp
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/rkwatch.cpp,v
retrieving revision 1.41
retrieving revision 1.42
diff -C2 -d -r1.41 -r1.42
*** rkwatch.cpp	2 Nov 2005 21:11:38 -0000	1.41
--- rkwatch.cpp	3 Nov 2005 15:24:56 -0000	1.42
***************
*** 85,90 ****
  	watch->append (command->command ());
  
- 	watch->setItalic (false);
- 	
  	if (RKSettingsModuleWatch::shouldRaiseWindow (command)) {
  		if (!(command->type () & RCommand::Console)) {
--- 85,88 ----
***************
*** 94,97 ****
--- 92,96 ----
  
  	linesAdded ();
+ 	watch->setItalic (false);
  }
  
***************
*** 141,149 ****
  	}
  
- 	watch->setBold (false);	
- 	watch->setColor (Qt::black);
- 
- 	linesAdded ();
- 
  	if (RKSettingsModuleWatch::shouldRaiseWindow (command)) {
  		if (!(command->type () & RCommand::Console)) {
--- 140,143 ----
***************
*** 151,154 ****
--- 145,152 ----
  		}
  	}
+ 
+ 	linesAdded ();
+ 	watch->setBold (false);
+ 	watch->setColor (Qt::black);
  }
  
***************
*** 160,169 ****
--- 158,171 ----
  		uint c = (uint) watch->paragraphs ();
  		if (c > RKSettingsModuleWatch::maxLogLines ()) {
+ 			watch->setUpdatesEnabled (false);			// major performance boost while removing lines!
  			watch->setSelection (0, 0, c - RKSettingsModuleWatch::maxLogLines (), 0, 1);
  			watch->removeSelectedText (1);
+ 			watch->setUpdatesEnabled (true);
+ 			watch->update ();
  		}
  	}
  
  // scroll to bottom
+ 	watch->moveCursor (QTextEdit::MoveEnd, false);
  	watch->scrollToBottom ();
  }

Index: rkconsole.cpp
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/rkconsole.cpp,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -d -r1.19 -r1.20
*** rkconsole.cpp	2 Nov 2005 21:11:38 -0000	1.19
--- rkconsole.cpp	3 Nov 2005 15:24:56 -0000	1.20
***************
*** 107,111 ****
  
  	if (para<paragraphs () - 1 || pos <= prefix.length () - 1){
! 		cursorAtTheEnd ();
  	}
  	
--- 107,112 ----
  
  	if (para<paragraphs () - 1 || pos <= prefix.length () - 1){
! 		moveCursor (MoveEnd, false);
! 		scrollToBottom ();
  	}
  	
***************
*** 130,134 ****
  void RKConsole::cursorAtTheEnd () {
  	RK_TRACE (APP);
! 	setCursorPosition (paragraphs () - 1, paragraphLength (paragraphs () - 1));
  }
  
--- 131,142 ----
  void RKConsole::cursorAtTheEnd () {
  	RK_TRACE (APP);
! 	scrollToBottom ();
! 	moveCursor (MoveEnd, false);
! }
! 
! void RKConsole::cursorAtTheBeginning () {
! 	RK_TRACE (APP);
! 	scrollToBottom ();
! 	setCursorPosition (paragraphs () - 1, prefix.length ());
  }
  
***************
*** 185,193 ****
  }
  
- void RKConsole::cursorAtTheBeginning () {
- 	RK_TRACE (APP);
- 	setCursorPosition (paragraphs () - 1, prefix.length ());
- }
- 
  void RKConsole::rCommandDone (RCommand *command) {
  	RK_TRACE (APP);
--- 193,196 ----
***************
*** 222,226 ****
  // TODO: handle different types of output, once we can differentiate between them
  //	insertAt (output->output, paragraphs ()-1, paragraphLength (paragraphs () - 1));
! 	cursorAtTheEnd ();
  	insert (output->output, (uint) CheckNewLines);
  
--- 225,229 ----
  // TODO: handle different types of output, once we can differentiate between them
  //	insertAt (output->output, paragraphs ()-1, paragraphLength (paragraphs () - 1));
! 	moveCursor (MoveEnd, false);
  	insert (output->output, (uint) CheckNewLines);
  
***************
*** 229,234 ****
--- 232,239 ----
  // TODO: WORKAROUND: Somehow, when removing paragraph 0, the QTextEdit scrolls to the top in between (yes, this also happens when using removeParagaph (0)). Since this may happen very often in newOutput, we're a bit sloppy, and only remove lines after a certain threshold (20) is exceeded. When the command is finished, this will be cleaned up automatically.
  		if (c > (RKSettingsModuleConsole::maxConsoleLines () + 20)) {
+ 			setUpdatesEnabled (false);		// major performace boost while removing lines!
  			setSelection (0, 0, c - RKSettingsModuleConsole::maxConsoleLines (), 0, 1);
  			removeSelectedText (1);
+ 			setUpdatesEnabled (true);
  		}
  	}
***************
*** 246,257 ****
  void RKConsole::tryNextInBatch (bool add_new_line) {
  	RK_TRACE (APP);
! 	if (add_new_line) {	
! 		append (prefix);
  		if (RKSettingsModuleConsole::maxConsoleLines ()) {
  			uint c = (uint) paragraphs ();
  			for (uint ui = c; ui > RKSettingsModuleConsole::maxConsoleLines (); --ui) {
  				removeParagraph (0);
  			}
  		}
  		cursorAtTheEnd ();
  	}
--- 251,264 ----
  void RKConsole::tryNextInBatch (bool add_new_line) {
  	RK_TRACE (APP);
! 	if (add_new_line) {
  		if (RKSettingsModuleConsole::maxConsoleLines ()) {
  			uint c = (uint) paragraphs ();
+ 			setUpdatesEnabled (false);
  			for (uint ui = c; ui > RKSettingsModuleConsole::maxConsoleLines (); --ui) {
  				removeParagraph (0);
  			}
+ 			setUpdatesEnabled (true);
  		}
+ 		append (prefix);		// somehow, it seems to be safer to do this after removing superflous lines, than before
  		cursorAtTheEnd ();
  	}

Index: rkconsole.h
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/rkconsole.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** rkconsole.h	2 Nov 2005 21:11:38 -0000	1.13
--- rkconsole.h	3 Nov 2005 15:24:56 -0000	1.14
***************
*** 38,42 ****
  	Do not construct directly. Construct an RKConsolePart instead.
  	
- 	TODO: Text display in the QTextEdit is rather slow. Find out how Konsole manages to be so much faster
  ** \sa RKwatch, KTextEdit
  ** 
--- 38,41 ----





More information about the rkward-tracker mailing list